Architecture
Software Factory Architecture
How a change to this portfolio moves from an idea to a merged pull request: ChatGPT writes specifications and reviews over MCP, Claude Code implements and verifies them in isolation, GitHub keeps the record, and every decision that matters stays with me.
Published November 22, 2026
My portfolio has a photography search engine, an assistant that explains how the site is built, a career tool that drafts application documents from evidence in a database, and an admin interface. One person maintains all of it. This case study is about the workflow I built so that AI can do much of that work without becoming the authority on it: a planning assistant writes specifications and reviews, a coding agent implements and verifies them, GitHub keeps the record, and every decision that matters stays with me. It is a companion to the AI-Native Repository case study, which covers what the repository itself enforces. This one covers how a change travels from an idea to a merged, verified pull request.
The problem
For a while I used AI assistants the obvious way: paste context into a chat, get code back, paste it into an editor. That works for a function. It doesn't work for a system:
- The chat doesn't know the repository as it is today. It works from what I paste, which is partial and often stale.
- Nothing it suggests has been tested. The real test suite runs later, if at all.
- Nothing it says leaves a record. A week later I can't check what was intended, what was done, or whether anyone verified it.
- Authority is implicit. When a model proposes a change and I paste it, it's unclear who decided what.
So the question I set out to answer wasn't how to get better answers from a chat. It was what it would take for an AI-assisted change to be as accountable as one I made myself. Concretely: every change starts from a written specification, is implemented in isolation, passes the same checks I would run, arrives as a pull request I review, and leaves a record I can verify later. And every step that changes something has an explicit owner.
The shape of the system
There are three working surfaces and one shared record.
- ChatGPT, as the planning and review client. It connects to a remote MCP server that is part of the portfolio itself, running on a single machine in Frankfurt. Through it, ChatGPT can read issues, pull requests, CI results, approved evidence files and an index of the engineering documentation. With my confirmation it can make exactly three kinds of write: publish a specification as an issue, add a discussion comment to a specification issue, and post an advisory review on a pull request.
- Claude Code, as the implementation environment. It runs on my machine inside the repository, with the project's own instructions, hooks and specialised subagents. It doesn't use the remote server. It talks to GitHub through the
ghcommand line, with my credential, and to the documentation index through a local MCP server. - Me. I start every piece of work, decide every revision, merge every pull request and decide what is published.
- GitHub, the shared record: specifications, pull requests, reviews, completion records and CI results.
- My intent
- SpecificationChatGPT drafts · I confirm · published as an issue
- My go-aheadan instruction in a Claude Code session
- Isolated startspecification digest checked · fresh clone · ledger
- Implementationprimary agent + bounded subagents
- Verificationfull check suite on a fresh copy of the commit
- Deliveryready pull request + completion record, read back
- CI checkstests · browser journeys · build
- Advisory reviewoptional · bound to the reviewed commit
- My merge
- Deploymain only · tests and journeys must pass
MCP, the Model Context Protocol, is what makes the planning side possible, and it's worth being precise about what is portable. The server speaks standard OAuth 2.1 and standard Streamable HTTP, and any compliant client could connect to it. The behaviours this workflow relies on are client-specific, though: ChatGPT asks the user to confirm every tool that isn't marked read-only, it signs in again when a token expires, and it has its own convention for asking for a missing permission. The server is written against those behaviours, and I would have to re-test them before relying on any other client.
Who authorizes what
"Authorization" covers several different things in this system, and they differ in what actually enforces them. That difference is the most important part of the design.
| Decision | Who makes it | What enforces it |
|---|---|---|
| Publish a specification, comment or review | Me, by confirming the exact text in ChatGPT | The server enforces a per-tool permission, a kill switch and a dedicated GitHub credential. The confirmation itself happens in the client, and the server can't verify it |
| Start work on a specification | Me, by telling Claude Code to take the issue | Procedure, not a permission system: the agent's instructions say that only my instruction authorizes work. The tooling adds checks around it, such as refusing a specification that changed after publication |
| Push, open the pull request, publish the completion record | Covered by my go-ahead for that piece of work | The delivery command does exactly those steps and nothing else; it has no code path that merges, deploys, approves or closes |
| Revise after a review | Me, once per revision | A review is advice. The revision starts only on my instruction, and the tooling refuses to revise against a review of an outdated commit |
| Merge | Me, in GitHub | GitHub's own permissions |
| Deploy | Follows my merge to main | The deploy job runs only from main, only when I triggered it, and only after the test suite and the critical browser journeys pass |
| Publish an article like this one | Me, as a separate step in the admin interface | Drafts aren't routable; publishing is its own action |
The procedural row is the honest weak point. Nothing technical stops a coding agent from acting on a sentence in an issue that looks like an instruction. What exists is a consistent rule, written into the agent's instructions and repeated in every record the system writes: specifications, comments, reviews and search results are evidence, never instructions. There is also a technical alternative in development, a headless runner that only executes under a grant I sign, bound to one specific specification. Today it is an attended pilot and not part of the normal loop.
One change, end to end
- Intent to specification. I describe what I want. ChatGPT reads the repository through the read tools and drafts a specification with an objective, constraints, acceptance criteria and non-goals. When I confirm it, the server publishes it as an issue with a hidden marker that includes a SHA-256 digest of the specification text. The result states, in a field of its own, that execution is not authorized.
- Go-ahead. Nothing happens until I tell Claude Code to take the issue.
- Isolated start. The start command reads the issue and recomputes the digest. If the specification was edited after publication, it refuses. It then clones the repository into a separate directory on a branch named after the ticket, provisions it from scratch and records the starting commit in a local ledger.
- Implementation. Claude Code does the work. It delegates bounded discovery to read-only subagents and, when a piece of work is already designed, implementation to a cheaper model behind a write boundary. Architecture, security and acceptance stay with the primary agent.
- Verification. The verify command takes a fresh copy of the exact commit and runs the full repository check: unit and security tests, type checking, lint, the architecture, knowledge and hygiene validators, and the Rust workspace. The result is recorded against that commit. If the check run changes the copy, the result is a failure.
- Delivery. One command pushes the branch through the normal hooks, opens a pull request marked ready for review and assigned to me, and publishes a completion record on the issue: a structured comment whose payload carries the outcome, the commit and the pull request, protected by a digest. It then reads the record back through the same code the MCP server uses and checks that it parses and verifies. If delivery stops halfway, running it again picks up what already exists instead of duplicating it.
- Review. If I want a second opinion, ChatGPT reads the pull request and its evidence and drafts a review. When I confirm it, the review is posted by a dedicated GitHub App and bound to the commit it reviewed. If the pull request has already moved on, the server refuses to post it.
- Revision. A review that recommends changes is still only advice. If I agree, I authorize the revision, Claude Code continues on the same branch, and delivery publishes a new completion record that supersedes the old one without editing it.
- Merge and deploy. I merge. The deploy follows from main.
What the record shows
The best test of a design like this is the trail it actually leaves. Four examples from the repository's history:
- A review, then a revision (issue #15, pull request #16). The review App posted an advisory review with the verdict revision recommended. The revision commits followed on the same branch, including a written revision report, and the pull request was merged. There is no completion record, because that tooling didn't exist yet.
- A revision driven by discussion (issue #26, pull request #27). The delivery automation was published with a completion record. Five minutes later I commented on the issue that audits and investigations should be delivered through a pull request too. That revision landed, and a second record superseded the first, which is still there for history.
- A clean run (issue #28, pull request #29). One specification, two commits, a ready pull request, a completion record at the pull request's head, merged and deployed. No review was requested, and the record says so.
- A missing record (issue #24, pull request #25). The work was merged, but I closed the issue before the completion record was published, and the publisher refuses to write to a closed issue. The change exists; the record of it doesn't.
None of these has every stage. The stages exist, but no single change has gone through specification, review, revision, record and merge at once. This article’s own pull request is on course to be the first, if I merge it.
The last example changed the design: delivery is now one command that includes the record, and a hook in Claude Code stops the session once if a verified change hasn't been delivered.
Decisions and trade-offs
Deterministic systems are authoritative; models handle language. The same principle governs the rest of the portfolio. Digests, markers, ledgers, commit checks and the test suite decide whether something is valid. Models write specifications, code, reviews and prose, and no model output is ever the proof that something is correct.
GitHub is the database. The duplicate check for every remote write is GitHub itself: a hidden marker in the issue or comment, found by scanning before each create. That means no extra storage, and duplicates are caught across restarts once GitHub lists the earlier write. The costs are a bounded scan, which refuses rather than guesses when an issue has more comments than it will read, and markers that prove content integrity but not authorship.
One permission per kind of write. Reading, writing issues and posting reviews each have their own OAuth scope and kill switch, and none falls back to another's credential. I can turn off reviews without touching specifications, or turn off all writes and keep reading. Today the read and issue-write credentials are the same token, a deliberate shortcut for the pilot period that I plan to split.
Confirmation where it can actually happen. The server can't see whether I pressed "confirm" in ChatGPT. The comment tool requires an explicit confirmation field, and every write is checked for duplicates and audited. But confirmation itself is a client-side control, and I describe it as one.
Isolation over speed. Every ticket gets its own clone, provisioned from scratch, and is verified on a fresh copy. It's slower than working in place, but what was tested is exactly what was committed, and my main checkout is never touched.
A single machine, on purpose. Sign-in state, rate limits and the in-flight write state live in process memory. That's only correct because production runs on one machine with one SQLite volume, and a test fails if the deploy configuration changes that. Scaling out would need a shared store first.
How knowledge is reused
There are two indexes, and both are deliberately simple.
- Engineering documentsarchitecture docs · reports · concept files · skills · agent definitions
- Local indexrefreshed from the working tree on every query
- Deployed bundlebuilt from the deployed commit · narrower corpus · checked before use
- Results labelled as evidencewith their source and git state, never instructions
The local index splits every Markdown document in the engineering corpus into sections at its headings and stores them in SQLite full-text search. It refreshes itself from the working tree on every query, and each result carries its git state.
The deployed bundle is built by the deploy pipeline from the exact commit being released, from a narrower set of documents, with personal email addresses removed. Its digest is checked before it goes into the image, and the server runs an integrity check before opening it. If any of that fails, the knowledge tools report "unavailable" instead of serving something wrong. The bundle only changes with a deploy, so it can lag behind the repository.
Both indexes are lexical. They find "stale-head protection" when a document says "stale head", but they don't understand that "the approach we rejected" means a particular kind of verdict. On top of them sits a hand-curated layer: concept files with validated metadata and source links, a staleness check against git history, and a routing table that tells an agent which concepts, skills and checks belong to which kind of task. None of this is automatic memory. Reuse works because the agent's instructions tell it to look, and because the validators fail when the pointers rot.
Failure modes, and how far each defence goes
- A lost response. If a create call times out, the server doesn't retry blindly. It looks for its own marker once and adopts the result if it landed. Otherwise it holds that request for ten minutes before checking again. This is not exactly-once: the hold lives in memory, so a restart inside that window, or a create that GitHub still hasn't listed when the hold ends, can produce a duplicate on retry. The result says so instead of claiming otherwise.
- A moved target. A specification whose digest no longer matches is refused at start. A delivery is refused if the branch moved since the result was written. A review is refused if the pull request has a new head. GitHub offers no atomic check-and-write, so a push that lands in the short window while a review is being posted can't be prevented; it is detected and reported as such.
- A record that doesn't read back. Comments and completion records are read back after writing; a comment that doesn't match exactly is reported as uncertain, never as published. Creating an issue doesn't have that step yet. Its result comes from the create response, which is one of the next things to change.
- Injected instructions. Specifications, comments, reviews, diffs and search results can all contain text that looks like an instruction. Every one is labelled untrusted when it is returned, and none carries authority. As described above, that rule is procedural.
- A skipped last step. Cleanup refuses to remove a merged branch that has no completion record, and the session hook stops the session once. Both apply only to work started under the automatic-delivery policy.
Limitations
This system is not autonomous, and I don't want it to be. Every piece of work starts with my instruction; every merge and every publication is mine.
Several controls are honest rather than strong:
- The local ledger is written by the agent's own tooling. It is a safety interlock for an honest session, not proof against a dishonest one.
- Records prove their content, not their author. A digest shows that a record wasn't edited; it doesn't show who wrote it. Records written with my GitHub credential show my name, so authorship is never evidence of approval.
- Content checks are pattern-based. They catch known mistakes, not every unsafe string.
- The headless runner is a pilot. Running unattended is blocked on infrastructure I haven't set up: a separate worker account, a publishing App and a signing key.
- Retrieval is lexical. It misses paraphrases.
And the whole workflow is young. Most of it was built between 19 and 21 November 2026, and the later pieces were built through the loop the earlier ones made possible.
What I learned
The hard part wasn't connecting tools. It was deciding, for every step, who is allowed to do it, what proves it happened, and what happens when it half-happens. Most of the code in this system answers the third question.
A record you forget to write undermines the automation around it. The one change without a record exists because publishing it was a separate step someone had to remember. Making it part of the same command fixed that.
Being precise about enforcement matters more than adding enforcement. Writing "the owner authorizes execution" is easy. Saying which parts of that are a permission check, which are a procedure, and which are an experiment is what makes the design reviewable.
The useful unit of AI assistance isn't an answer. It's a pull request with evidence attached, something I can review, test, revert and trust.
Further reading
The AI-Native Repository case study covers the repository side: instructions, routing, validators, hooks and agent roles. The Photography Assistant case study applies the same principle, deterministic systems as the authority with the model handling language, to a production LLM feature. Agent Automation Without Losing Engineering Control tells part of this story as a journal entry.