▦ OpenSpec Software Factory ES

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
  1. One fact, one place
  2. Few scripts, each with an owner
  3. The curator: the part that makes the factory learn
  4. The wiki layer: optional, not a requirement

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

LayerWhat it holdsWhen it is read
SpecificationWhat must be true, with scenariosBefore implementing
ContractStack, commands, limits, trapsAlways
RunbookOperation, deploy, rollbackWhen touching infrastructure
StateWhat is done, what is blockedOn session start or block change
RecordWhy a rule is the way it isWhen a rule is unclear
EvaluationOutcomes and evidenceWhen 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

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:

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 /curar command, guided by the docs/harness.md record.

Trace agent · cost · cause Record gap · decision Rule where it lives · commit Next pass better rules the incident becomes a row; the row becomes a rule with a commit

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?

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:

DateOriginGapDecisionWhereCommit
21-novIncidentThe rule was updated in AGENTS.md but stayed stale in a commandSingle source and references, not copiesAGENTS.md, commandsa1b2c3d

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:

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

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

When it does not

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

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 documentationAccumulated knowledge
Contract, runbooks, stateConcepts, sources, comparisons
Written by handMaintained by the agent
Expires by dateExpires 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.