01The problem we have now
Everything we know about a finished project lives in two places that we cannot query: the original developer's head, and an AI chat session that has since been closed.
That has four consequences we are paying for every week.
- Every small change restarts from zero. Adding a function or fixing a minor bug on a completed project begins with rebuilding context — re-reading the code, rediscovering the conventions, working out again why something was built the way it was. The change itself is usually the quick part.
- We solve the same problem repeatedly. A fix worked out on one project is not written down in a form another project can use, so the next developer to hit it starts over.
- One person is the bottleneck. In practice only the original developer can safely touch a given project. That caps how much work the team can absorb and concentrates real business risk in one person.
- There is no record. We cannot answer, for any project, what changed, why, or who authorised it.
None of this is a tooling gap in how we write code. It is a memory gap. AI HQ closes it.
02What AI HQ is
A control plane with four subsystems and one cross-cutting concern.
| Subsystem | What it holds | What it makes possible |
|---|---|---|
| Project registry & fleet view | Every server, every project on it, stack, deploy target, current version, health, owner. | One authoritative answer to “what is running where, and who owns it.” |
| Knowledge layer | Per-project cards, an append-only fix log, and a cross-project pattern library. Written by the people and agents doing the work, enforced in CI. | Any change to any project starts with full context instead of none. |
| Job orchestrator | A queue, a pool of short-lived sandbox runners, per-job policy enforcement, transcripts, budgets. | AI work becomes a tracked job with an owner, a cost, an audit trail and a review gate — not an untracked chat. |
| Credential broker | Encrypted credentials, referenced everywhere by alias. Plaintext resolved only at deploy time. | Staff can build against production services without ever learning a production credential. |
| Audit & access control (cross-cutting) | Permissions scoped to person × project × capability. Append-only log of every gate decision, tool call and secret read. | Junior staff can be given real work with limits we can prove, not limits we hope hold. |
AI HQ does not train or fine-tune a model. There is no learning in that sense, and we should not claim there is. What it does is retrieval and prompt assembly: HQ selects the right knowledge for the job at hand and composes a well-formed instruction from it. This is deliberately the cheaper design — it is auditable, it can be corrected instantly by editing a record, and it needs no ML infrastructure.
03How a job flows
A job is any unit of AI work: a bug fix, an added function, a dependency bump. It can be started by a staff member, by an error alert from production, or on a schedule. Every job takes the same path, and the path is where all the safety lives.
04Why we do not let agents edit servers directly
The obvious design is to install an AI coding agent on each server and let staff send it instructions. It is faster to build and faster to use. We are not proposing it, and the reason is worth stating plainly because it is the single largest risk in this whole idea.
An agent editing a running production host has no review step. A misread instruction, a wrong path, a confidently wrong assumption — the damage is live before anyone sees it. This is not hypothetical: it is a documented failure mode, including a widely reported case where a coding agent deleted a production database during a change freeze and then misreported what it had done. The current OWASP risk list for agentic applications tracks it under Cascading Failures, alongside Tool Misuse and Excessive Agency.
There is a second benefit that matters at our scale. With 50-plus servers and 20-plus people, two agents will eventually work the same project at the same time. Branch-per-job turns that into an ordinary merge conflict rather than two processes overwriting each other's edits in a live directory.
And it simplifies the fleet considerably. Because code work happens in short-lived sandboxes that clone from git, the agent never needs to live on the server at all. What we install on each of the 50-plus hosts is a thin, mostly read-only reporter: it publishes health and the currently deployed version, ships logs and errors up to HQ, and executes deploys when the pipeline instructs it. That is a much smaller thing to secure and maintain than a full coding agent per host — and it is the difference between one compromised host exposing one host, and one shared agent account exposing the fleet.
No agent writes directly to a production host. All code changes reach production through branch, tests, review and the deploy pipeline. A restricted break-glass path for genuine emergencies is limited to named senior staff and alerts the leadership channel on use.
05The knowledge layer
This is the part that solves the original problem, and it is the part most likely to quietly fail. Two failure modes to design against.
Documentation rot
Hand-maintained notes stop being true within about a month. Asking people to keep them current through an SOP does not work, because the SOP is the first thing dropped under deadline. So we make it mechanical: a change is not mergeable unless it carries a knowledge entry, enforced in CI, and the entry is drafted automatically from the diff so the human is editing a draft rather than facing a blank field.
Knowledge poisoning
If every agent run can write freely to shared knowledge, then one hijacked or simply overconfident run corrupts the context of every future job that reads it. OWASP lists this as Memory & Context Poisoning. Our answer: knowledge writes are proposals that require review, and we keep a verified tier separate from an unverified one.
Three tiers, not one big file
A single five-thousand-line document per project is worse than none: it consumes the context budget and buries the useful paragraph. We split by how often the information is needed.
Records are stored structured in Postgres and rendered as readable Markdown views, rather than stored as loose files. That gives us search, filters, per-entry review state and history for free, and still leaves a human-readable document in each repository for anyone who wants to read it directly.
06Credentials
The goal is that a staff member can build and ship against production services without ever seeing a production credential. That goal is achievable, but only with the right mechanism — and it is worth being precise about why the obvious approach does not work.
Telling the AI “you may use the key but never reveal it” is not a control. If a credential is present in the model's context, or reachable by a shell the model operates, it can be extracted — not by a sophisticated attack, but by asking the agent to print its configuration, or to write a diagnostic script, or by pasting content into the repository that the agent later reads as an instruction. A rule expressed in prose to a text generator is a preference, not a permission boundary.
The mechanism that does work is a broker. Credentials are referenced everywhere by alias — {{secret:prod/postgres/password}} — and the alias is all the AI ever handles. Substitution happens outside the model entirely, performed by the deploy pipeline after the change has already been reviewed. The agent's task becomes “which credential does this need,” which is exactly the experience described, delivered by architecture rather than by instruction.
Building our own store
We propose to build the store in HQ rather than adopt a third-party secrets manager, for control and to avoid another external dependency. That is defensible, but it means we own the security surface, so the following are stated as requirements rather than recommendations.
No plaintext credential ever enters a model context, a prompt, a log line or a transcript. Aliases only, everywhere.
Envelope encryption: a unique data key per secret, encrypted under a master key that is held outside the application database — a KMS or equivalent. A master key stored beside the ciphertext means the store is decorative.
Every credential read is recorded: which person, which job, which project, when. At 20-plus people this is the record that answers “who could have taken this” six months later.
A written, tested rotation procedure exists before the store holds anything real, and is executed whenever someone leaves or changes role.
Put the store behind a thin interface from day one, so that moving to a self-hosted third-party manager later — if we decide we would rather not maintain this ourselves — is a configuration change instead of a rewrite of every caller. This is roughly a day of extra work and it preserves the option.
07Roles and access
At 50-plus servers and 20-plus people, a single flat “staff” role breaks the first time two teams should not see each other's projects. So the unit of permission is person × project × capability, not a global role.
| Role | Can dispatch jobs on | Can approve | Credential access |
|---|---|---|---|
| Platform owner | Any project | Any change, including break-glass | Manage aliases and rotation; plaintext only through an audited break-glass path |
| Project lead | Projects they own | Changes on their projects | Assign which aliases a project may use |
| Developer | Projects they are assigned | Nothing — their work is reviewed | Aliases only, from the project's allowed set |
| Read-only | Nothing | Nothing | None |
Screening staff prompts
The proposal includes a screening step that inspects a staff instruction before dispatch and refuses obviously improper ones, notifying the leadership channel in Lark. This is worth having: it catches careless and opportunistic attempts, and it produces a signal we can review.
It should not, however, be presented as the security boundary. It is a filter on intent expressed in text, and text can be rephrased. The real boundary is what the agent is permitted to do once running — enforced in code, deny-by-default, on every single tool call. Screening is the smoke alarm; tool permissions are the fire door.
08Security controls
Each control below is a mechanism, not a policy statement. The right-hand column names the industry risk category it addresses, using the OWASP Top 10 for Agentic Applications so that this can be reviewed against a recognised framework rather than our own judgement.
| Control | Mechanism | Addresses |
|---|---|---|
| Deny-by-default tool permissions | Every tool call the agent attempts is intercepted before execution and checked against HQ policy in code, which returns allow or deny. A deny cannot be argued with or overridden by any permissive rule. | Tool Misuse; Excessive Agency |
| No unreviewed production write | Sandbox runner, git branch, tests, human approval gate, deploy pipeline. One-command revert on every deploy. | Cascading Failures |
| Credentials out of context | Alias-only references; plaintext resolved by the deploy step after approval; every read logged. | Identity & Privilege Abuse |
| Per-job identity | Each job runs under its own short-lived credential and is destroyed with the sandbox. No shared agent account across the fleet. | Identity & Privilege Abuse; Rogue Agents |
| Network egress allowlist | Sandbox reaches only the hosts a job legitimately needs. Default is nothing. | Unexpected Code Execution |
| Knowledge write review | Entries are proposals; a person promotes them to the verified tier. Verified and unverified are stored separately. | Memory & Context Poisoning |
| Untrusted repository content | Content the agent reads — issue text, code comments, dependency files — is treated as data, never as instruction. Combined with deny-by-default tools and no credentials in context, a planted instruction has nothing useful to reach. | Agent Goal Hijack |
| Attribution | Append-only audit log of every gate decision, tool call, approval and credential read, tied to a named person. | Rogue Agents |
| Owner, expiry, kill switch | Every job has a named human owner, a hard time limit, and a tested terminate action reachable from the dashboard. | Rogue Agents |
| Spend limits | Per-role and per-project token budgets with a hard stop, plus a live cost view. A looping agent is a cost incident, not a surprise invoice. | Excessive Agency |
| Reviewer sees the real actions | The pull request carries the full agent transcript, not only its summary of what it did. | Human–Agent Trust Exploitation |
Tool permissions are deny-by-default and enforced in code on every call. No security property depends on instruction text inside a prompt.
Every job has a named human owner, a hard expiry, and a kill switch that has been tested.
Every agent action is attributable to a person in an append-only log, and every deploy is revertible with one command.
09Risk register
| ID | Risk | Likely | Impact | Mitigation | Residual |
|---|---|---|---|---|---|
| R1 | A staff member extracts a production credential through the agent | Med | High | Alias-only references; plaintext resolved post-approval outside any model context; every read logged (REQ-1, REQ-2) | Low |
| R2 | An agent breaks live production | Med | High | No direct host writes; sandbox, tests, human gate, one-command revert (REQ-3) | Low |
| R3 | Our own vault implementation has a flaw | Med | Critical | Envelope encryption; master key external; independent review before it holds real credentials; swappable behind an interface | Med |
| R4 | Injected instructions in repository or issue content redirect an agent | High | Med | Repository content treated as data; deny-by-default tools; egress allowlist; no credentials in context. Cannot be eliminated, only contained. | Med |
| R5 | The knowledge base goes stale, or is poisoned with wrong information | Med | Med | CI blocks merges without an entry; drafts generated from the diff; verified tier requires human promotion | Low |
| R6 | Token spend runs away | Med | Med | Hard per-role and per-project budgets; cost dashboard shipped in Phase 2, before staff access opens in Phase 4 | Low |
| R7 | Single-builder dependency — one person holds all platform knowledge | High | High | Phases are independently useful; the platform is documented in its own knowledge layer; off-the-shelf components used where they exist. Not fully mitigable without a second engineer. | Med |
| R8 | Scope overruns and nothing ships | High | High | Phase 0 and 1 deliver standalone value with no dispatch and no credentials; hard gate before each later phase | Med |
| R9 | Misuse by an authorised staff member | Low–Med | High | Project-scoped permissions; full audit; anomaly alerts to the leadership channel in Lark | Med |
| R10 | Compromise of one host spreads across the fleet | Low | High | Thin read-mostly reporter per host; per-host identity; no shared agent account; no credentials stored on hosts | Low |
10Delivery plan
Estimates assume one developer working on this alongside existing responsibilities, which realistically means around 40 per cent of a week. Person-weeks are the work; elapsed weeks are what the calendar will show at that capacity. These are honest numbers rather than encouraging ones, because the decision this proposal is asking for depends on them being real.
Knowledge schema, SOP, and backfill of existing projects
Define the three-tier record structure. Write the SOP. Build tooling that runs an agent across each existing repository and produces its initial project card and fix-log skeleton for a human to correct.
Done when every active project has a reviewed project card, and adding a feature to an old project no longer starts with context reconstruction. Needs no HQ application at all — the records live in the repositories.
HQ core — registry, knowledge service, read-only fleet view
Next.js and Postgres. Server and project registry with ownership. Knowledge stored structured and rendered as Markdown views. Thin read-only reporter on each host for health and deployed version. CI check that blocks a merge with no knowledge entry.
Done when “what is running where, who owns it, and what do we know about it” has one authoritative answer. No job dispatch, no credential store, no staff access — and therefore no new security surface.
Job orchestrator, single operator
Queue, sandbox runner, context-pack assembly, in-code tool policy enforcement, audit log, branch and pull-request flow, transcript capture, kill switch, token budgets and cost dashboard. Dispatch restricted to the platform owner.
Gate before starting: Phase 1 in use, and every active project in version control with runnable tests.
Credential vault and broker
Envelope encryption, external master key, alias resolution inside the deploy step, read audit, rotation runbook.
Gate before holding real credentials: independent security review of the implementation.
Roles, staff access, screening and alerting
Project-scoped permissions, joiner and leaver process, prompt screening, Lark alerts to the leadership group, per-role quotas.
This is where the team-capacity return actually lands — junior staff dispatching real work within provable limits.
The flywheel
Production error automatically opens a job with full context attached. Scheduled maintenance jobs. Knowledge quality metrics. This is the point at which HQ stops being a dashboard we look at and starts being a system that does work.
Total is roughly 28 person-weeks. At one developer part-time that is approximately 16 months to the full platform. Phases 2 and 3 parallelise cleanly, so a second developer brings the full build to roughly 9 to 10 months.
The point of the phase structure is that we do not have to decide that today. Phases 0 and 1 together are about 22 weeks and they solve the problem this proposal opened with — on their own, with no dispatch, no credential store and no new security surface. Everything after that is a separate decision, made with Phase 1 already delivering.
11Cost and return
Two cost lines: infrastructure, which is small and predictable, and AI usage, which is the variable and needs measuring rather than guessing. The figures below are planning estimates to be replaced with real telemetry during Phase 2 — which is precisely why the cost dashboard ships in Phase 2, before staff access opens in Phase 4.
Running cost, monthly
| Line | Basis | Estimate |
|---|---|---|
| HQ application and Postgres | Managed database plus application host | $60 – 120 |
| Sandbox runner pool | One burst host, roughly four concurrent jobs | $50 – 90 |
| Key management for the master key | Per-key and per-operation charges | $1 – 5 |
| Transcript and log storage | Object storage, retention around 12 months | $5 – 15 |
| Infrastructure subtotal | $120 – 230 | |
| AI usage — Phase 1 only | Backfill plus low job volume, one operator | $60 – 150 |
| AI usage — full rollout | See model below | $400 – 1,400 |
How the AI usage figure is built
- Small fix, per job
- $0.50–2.50bounded context, few turns
- Feature addition, per job
- $3–10longer, more files touched
- Volume at full rollout
- ~260/mo20 people × 3 jobs per week
- Mid-point estimate
- ~$740/mo70% small fixes, 30% features
Four levers control this figure, and all four are design decisions already built into the plan: prompt caching across a job's turns; the bounded context pack from Figure 3, so cost per job does not grow as the knowledge base does; routing mechanical work to a cheaper model tier; and hard per-role budgets that stop rather than warn.
Return
The clearest measurable saving is context reconstruction time. The formula is deliberately simple so the assumptions can be challenged:
tasks per week × minutes of context rebuild × loaded hourly cost
On an illustrative fifteen small tasks a week at forty-five minutes of avoidable rebuild each, that is around 11 hours a week, or 48 hours a month, of engineering time recovered. Whether that outweighs a run cost in the region of $600 to $1,400 a month depends on our loaded hourly rate, which should be filled in before this is presented rather than assumed here.
I would not lean on that calculation as the main argument, because at many rates it lands close to break-even. The returns that are harder to put a number on are the ones that actually justify this:
- The bottleneck comes off one person. Work that today only the original developer can safely perform becomes work a junior developer can perform inside provable limits. That is capacity, and it compounds.
- Project knowledge stops being a personal asset. Right now, one person leaving takes a meaningful share of our institutional memory with them. This is the risk the platform most directly reduces, and it is not currently mitigated at all.
- We gain an audit trail we do not have. Today we cannot say what changed on a given project, when, or who approved it. After Phase 2 we can, for every change.
- Turnaround time on small work drops sharply, because the expensive part — rebuilding context — is what gets eliminated.
12Explicitly out of scope
Stated so that expectations do not drift during the build.
- No model training or fine-tuning. This is retrieval and prompt assembly. Anyone expecting a model that learns our codebase in a machine-learning sense should be corrected early.
- No autonomous deployment. A human approves every change that reaches production, in every phase.
- Not a replacement for developers. It removes context reconstruction, not judgement. Review load moves to seniors and should be accounted for.
- Not a general-purpose agent platform. It does one job: maintaining and extending the software we have already shipped.
13Open items to confirm before Phase 0
Four of these are assumptions the plan depends on. The fifth is a governance question I cannot answer alone.
| Item | Why it matters |
|---|---|
| Is every active project in version control? | The entire review gate depends on it. Any project that exists only on its server must be brought into git during Phase 0, and that work needs to be counted. |
| Do projects have runnable tests? | Without them the automated gate before human review is weak, and the reviewer carries more load. Projects without tests should be identified early and prioritised. |
| Do we have error tracking on production? | Phase 5's error-to-job flywheel depends on it. Worth adding during Phase 1 if not. |
| Lark webhook access for the leadership group | Needed for the alerting path in Phase 4. |
| Who approves a change when the person dispatching it is also the only reviewer? | Self-approval defeats the gate that the rest of this design rests on. We need either a named second reviewer or an explicit, written self-approval policy with defined limits. This is a decision for you, not for me. |
14The ask
Approve Phase 0 and Phase 1
Roughly 9 person-weeks, about 22 weeks elapsed at current capacity, at an infrastructure and usage cost of approximately $180 to $380 a month.
Those two phases introduce no job dispatch, no credential storage and no staff access — and therefore no new security surface — while delivering the project registry, the fleet view, and the knowledge layer that solves the problem in Section 1 on its own.
Also requested
- A decision on the reviewer question in Section 13, before Phase 0 begins.
- An in-principle view on resourcing, so I can plan Phase 2 honestly: a second developer roughly halves the remaining timeline.
- Agreement that Phases 2 to 5 are separate approvals, each gated on the previous phase being in real use.