How it runs
How it runs
The method is not held together by prompts: it is held together by documents that do not lie, a few scripts with an owner, a curator that fixes rules and an optional knowledge layer.
This page brings together what keeps the factory alive over time: documents, scripts, the curator and, when needed, an optional knowledge layer.
On this page
One fact, one place
Documentation is not an archive: it is the context the agent reads before working. If a piece of data lives in two places, one of them will eventually lie.
The layers
| Layer | What it holds | When it is read |
|---|---|---|
| Specification | What must be true, with scenarios | Before implementing |
| Contract | Stack, commands, limits, traps | Always |
| Runbook | Operation, deploy, rollback | When touching infrastructure |
| State | What is done, what is blocked | On session start or block change |
| Record | Why a rule is the way it is | When a rule is unclear |
| Evaluation | Outcomes and evidence | When closing a change |
The contract
One rules file at the root, and one per side when the project has distinct sides (backend, front). The contract does not tell the story of each rule: only the rule. The why lives in the record.
If a rule needs three paragraphs to justify itself, the problem is not the rule: it is not decided.
State
Operational memory is short on purpose: state, current decisions and pending items. It is not a diary or an inventory. Technical detail lives in runbooks; chronology, in change history.
A 300-line state is not read. The guideline is 85 lines; the shorter, the better.
The index
The documentation index is generated: it walks the files, reads their frontmatter and writes the table with type, sections, state, expiry and size. It is not edited by hand.
---
type: Runbook
hint: deploy, pre and production
stale_after: 2027-02-13
---
CI fails if a document does not declare its type, if the index does not match, or if an expiry date has passed. That way the map does not age in silence.
Expiry
A review date is not bureaucracy: it is how you detect a runbook that no longer describes the server. The periodic documentation check exists to find an expired document without anyone touching anything.
What is not documented
- Generic framework semantics.
- Console steps that can be inferred from code.
- Decisions already closed in the specification.
- The detail of a task: that belongs to its trace and its commit.
Documenting too much costs context every turn. Documenting too little costs rework. The rule is: what the agent needs in order not to be wrong, and nothing more.
Few scripts, each with an owner
The temptation is to automate with scripts. The method does the opposite: it writes rules as text and keeps scripts only for what text cannot guarantee.
The rule
A new script is justified only if it removes a human decision or prevents a document from lying. If it only reorganizes, it does not go in. And every script needs a CI consumer; otherwise it is a personal tool.
The ones that hold the method
docs-sync.mjs
Keeps three things in sync:
- The documentation index, from frontmatter.
- The progress figures in memory, by counting tasks.
- The archive of long traces, moved out of
tasks.mdinto a history file.
It has three modes:
node scripts/docs-sync.mjs # fix
node scripts/docs-sync.mjs --check # validate; fail if anything is off
node scripts/docs-sync.mjs --plan <change> # print the plan as JSON
check-secrets.mjs
Walks the text files and fails if it finds a credential, a user path or a term from the forbidden list. It is the gate that prevents the template from carrying data from the project it came from.
It lives in the site and in the template. A secrets gate that does not run in CI protects nothing: wire it into the documentation workflow.
node scripts/check-secrets.mjs # fails with the finding and its line
The public list (data/forbidden.json) only holds examples. The terms for the concrete project are read from ~/.config/openspec-software-factory/forbidden.json (or OPENSPEC_FORBIDDEN_FILE), outside the repository: the gate does not publish the data it watches for.
worktree-deps.mjs
Links the heavy directories declared in worktree.sharedDirs (for instance node_modules) into each worktree or review copy only when the normalized lockfile SHA-256 matches the main tree; when it differs, it skips the link and asks for a clean install so the main tree is never polluted. On teardown (unlink), it removes only symlinks/junctions and runs codegraph uninit --force when .codegraph/ is present. Its test suite runs in CI.
node scripts/worktree-deps.mjs link paralelo/<change>-<block>
node scripts/worktree-deps.mjs unlink paralelo/<change>-<block>
--plan
Turns tasks into something a machine can query:
{ "id": "1.2", "bloque": 1, "nivel": "NORMAL", "estado": "pendiente", "deps": ["1.1"] }
It answers "what is next?" without interpreting prose.
The ones that do not belong in the template
Personal diagnostic tools —measuring time, listing slow tests— have no CI consumer. They stay out: a script nobody runs rots.
Workflows
Workflows are not scripts: they are the CI skeleton. Each project defines its own; the table of patterns and triggers lives in Gates → CI.
The curator: the part that makes the factory learn
Without a curator, a factory does work. With a curator, the system that does the work improves. The difference between the two is the difference between a workflow and a factory.
The curator is not an autonomous agent: it is the main session's
/curarcommand, guided by thedocs/harness.mdrecord.
From trace to rule
Every block leaves evidence: tasks, cost, deltas, verdicts and causes. The curator reads it and asks an uncomfortable question: which rule allowed this to happen?
- An ambiguous brief that caused two review rounds → close the brief.
- A test that passed with the mutation applied → fix the test.
- A command that hung in the runner → deny it.
- A rule repeated in two files → remove it from one.
The result is not a note in a chat: it is a row in the record, with gap, decision, where it lives and commit.
The record
A real record looks like this. Example row:
| Date | Origin | Gap | Decision | Where | Commit |
|---|---|---|---|---|---|
| 21-nov | Incident | The rule was updated in AGENTS.md but stayed stale in a command | Single source and references, not copies | AGENTS.md, commands | a1b2c3d |
The record does not keep every change. It keeps decisions: what changed the behaviour of the system. A budget adjustment or a package version does not go in; if it did, the record would stop explaining why the system is the way it is.
Cadence
The curator does not run on inspiration. The recommended cadence is:
- When a block closes, if there was an incident or a pattern.
- When a change closes, before archiving.
- Optionally once a week, if there have been no recent closures and there is accumulated trace.
The command is /curar <change> [block] or /curar --semana as an optional sweep. It proposes 0–3 rows per batch and does not change a rule without approval. A row that touches AGENTS.md, an agent or a command is propagated in the same batch to the site (data/template.json and content/) and to the readmes that index it: a registry without propagation leaves two truths.
No cron cures: the periodic check only validates documentation. Curation is a human review.
Ten minutes are enough if the trace exists. Without a trace, the curator guesses, and a curator that guesses is another source of debt.
What it prevents
- Zombie rules: rules that no longer apply and nobody dares to delete.
- Duplication: the same fact in two documents, with two versions.
- False autonomy: a loop that works because the human corrects it in silence.
- Complexity without return: a new script nobody runs.
What it is not
It is not a pretty report to show off. It is a control system: if a rule cannot be checked, it is not a rule, it is an intention.
The wiki layer: optional, not a requirement
The LLM wiki pattern is powerful: immutable sources, generated pages, index, log and lint. But not every project needs a wiki, and a project with good documentation can get worse if you add another layer. In the current version the wiki is design only: there is no module to turn on.
When it makes sense
- You accumulate external research: papers, articles, client notes, comparisons.
- You need traceability to the source: which document backs each claim.
- Knowledge crosses topics and you want the connections preserved.
- Several people or sessions consult the same material and nobody wants to rebuild it.
When it does not
- Your documentation is already operational: contract, runbooks, state. Adding
raw/would be one more folder to maintain. - Knowledge changes daily and the wiki would go stale.
- Nobody reads it: a wiki without readers is context debt.
The three layers
raw/ immutable sources. The agent reads, never writes.
wiki/ generated pages: concepts, entities, sources, comparisons.
schema AGENTS.md with conventions and workflows.
And two special files: index.md (catalogue read first) and log.md (append-only chronological record).
The operations
- Ingest: a source comes in, is summarised, connected to what already exists and logged.
- Query: read the index, pick the relevant pages and synthesise with citations.
- Lint: contradictions, orphan pages, broken links and stale claims.
The part worth copying
The deterministic lint: broken links, pages with no inbound links, incomplete frontmatter, sources that no longer exist. A script can check it and make CI fail.
Semantic lint —"these two pages contradict each other"— is useful as manual review, but not as a gate: a model that is wrong must not block a merge.
Relation to docs/
They are not the same:
docs/ | wiki/ |
|---|---|
| Project documentation | Accumulated knowledge |
| Contract, runbooks, state | Concepts, sources, comparisons |
| Written by hand | Maintained by the agent |
| Expires by date | Expires by new source |
If the project already has mature docs/, the wiki starts as a research folder, not as a second documentation.
Recommendation
The wiki is not a part of the method: it is an optional module. Adopt it only if you accumulate external sources and need traceability; if your operational documentation is already mature, do not add the layer.