From 713426b909eae3d13f077589f0693269adb4e176 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:37:29 +0100 Subject: [PATCH] NapkinStack: v0.6.2 -> v0.34.11 Agent-Session: flet-rehearsal-1 --- .agents/skills/data-migration/SKILL.md | 132 +++++ .agents/skills/discovery/SKILL.md | 135 +++++ .agents/skills/documentation/SKILL.md | 94 +++ .agents/skills/framing/SKILL.md | 227 ++++++++ .agents/skills/operations/SKILL.md | 184 ++++++ .agents/skills/pause-and-resume/SKILL.md | 90 +++ .agents/skills/security/SKILL.md | 134 +++++ .agents/skills/tests/SKILL.md | 218 +++++++ .agents/skills/ux/SKILL.md | 136 +++++ .agents/skills/verification/SKILL.md | 145 +++++ .claude/skills/data-migration/SKILL.md | 132 +++++ .claude/skills/discovery/SKILL.md | 135 +++++ .claude/skills/documentation/SKILL.md | 94 +++ .claude/skills/framing/SKILL.md | 227 ++++++++ .claude/skills/operations/SKILL.md | 184 ++++++ .claude/skills/pause-and-resume/SKILL.md | 90 +++ .claude/skills/security/SKILL.md | 134 +++++ .claude/skills/tests/SKILL.md | 218 +++++++ .claude/skills/ux/SKILL.md | 136 +++++ .claude/skills/verification/SKILL.md | 145 +++++ .copier-answers.yml | 14 +- .gitattributes | 3 + .github/CODEOWNERS | 9 +- .github/ISSUE_TEMPLATE/01-feature.yml | 106 ---- .github/ISSUE_TEMPLATE/01-request.yml | 31 + .github/ISSUE_TEMPLATE/02-bug.yml | 11 +- .github/ISSUE_TEMPLATE/03-architecture.yml | 4 +- .../{05-debt.yml => 04-debt.yml} | 2 +- .github/ISSUE_TEMPLATE/04-spike.yml | 26 - .github/ISSUE_TEMPLATE/05-acceptance.yml | 54 ++ .github/pull_request_template.md | 62 +- .github/workflows/commits-on-main.yml | 7 +- .github/workflows/governance.yml | 32 +- .github/workflows/module-checks.yml | 129 +---- .github/workflows/plan-on-the-forge.yml | 55 ++ .github/workflows/pull-request.yml | 25 +- .gitignore | 19 +- .nstack/check-modules.sh | 55 ++ .nstack/fitness-before-push.sh | 130 +++++ docs/adr/_TEMPLATE.md => .nstack/forms/adr.md | 14 +- .../forms/charter.md | 10 +- .nstack/forms/cycle.md | 76 +++ .../forms/discovery.md | 4 +- docs/pdr/_TEMPLATE.md => .nstack/forms/pdr.md | 16 +- .nstack/forms/rules.md | 12 + {docs/os => .nstack/handbook}/00-overview.md | 80 ++- .../os => .nstack/handbook}/01-principles.md | 0 {docs/os => .nstack/handbook}/02-modules.md | 20 +- {docs/os => .nstack/handbook}/03-contracts.md | 43 +- .../os => .nstack/handbook}/04-ai-context.md | 47 +- .nstack/handbook/05-workflow.md | 476 +++++++++++++++ {docs/os => .nstack/handbook}/06-decisions.md | 113 +++- .nstack/handbook/07-governance.md | 545 ++++++++++++++++++ {docs/os => .nstack/handbook}/08-quality.md | 23 +- {docs/os => .nstack/handbook}/09-platform.md | 108 ++-- .../os => .nstack/handbook}/10-measurement.md | 11 +- .nstack/handbook/INSTALL.md | 469 +++++++++++++++ .nstack/handbook/README.md | 109 ++++ .nstack/handbook/RULES.md | 192 ++++++ .nstack/handbook/glossary.md | 93 +++ .nstack/handbook/project.md | 231 ++++++++ .nstack/install-engine.sh | 77 ++- .../playbooks}/data-migration.md | 23 +- {playbooks => .nstack/playbooks}/discovery.md | 29 +- .nstack/playbooks/documentation.md | 86 +++ .nstack/playbooks/framing.md | 219 +++++++ .../playbooks}/operations.md | 19 +- .nstack/playbooks/pause-and-resume.md | 82 +++ {playbooks => .nstack/playbooks}/security.md | 20 +- {playbooks => .nstack/playbooks}/tests.md | 65 ++- {playbooks => .nstack/playbooks}/ux.md | 8 +- .nstack/playbooks/verification.md | 137 +++++ .nstack/skills.yaml | 70 +-- {docs => .nstack}/tooling-profile.md | 9 +- .pre-commit-config.yaml | 62 +- .yamllint.yaml | 4 +- AGENTS.md | 76 ++- CONTRIBUTING.md | 97 +++- README.md | 36 +- SECURITY.md | 2 +- contracts/.gitkeep | 0 contracts/AGENTS.md | 26 - contracts/MANIFEST.yaml | 29 - contracts/README.md | 40 -- contracts/docs/runbook.md | 15 - contracts/tests/.gitkeep | 0 ...-split-the-agent-github-identity-in-two.md | 2 +- docs/adr/README.md | 4 +- docs/architecture/.gitkeep | 0 docs/os/05-workflow.md | 301 ---------- docs/os/07-governance.md | 328 ----------- docs/os/README.md | 104 ---- docs/pdr/0002-three-verdicts-not-two.md | 2 +- docs/pdr/README.md | 4 +- docs/project/README.md | 41 -- docs/project/charter.md | 2 +- docs/project/cycles/_TEMPLATE.md | 49 -- docs/project/discovery.md | 8 +- docs/runbooks/.gitkeep | 0 modules/.gitkeep | 0 modules/README.md | 2 +- modules/copying/MANIFEST.yaml | 10 +- modules/copying/docs/runbook.md | 2 +- modules/screening/MANIFEST.yaml | 10 +- ...02-python-and-a-client-that-cannot-sign.md | 2 +- modules/screening/docs/runbook.md | 2 +- playbooks/framing.md | 110 ---- playbooks/verification.md | 70 --- 108 files changed, 7021 insertions(+), 1719 deletions(-) create mode 100644 .agents/skills/data-migration/SKILL.md create mode 100644 .agents/skills/discovery/SKILL.md create mode 100644 .agents/skills/documentation/SKILL.md create mode 100644 .agents/skills/framing/SKILL.md create mode 100644 .agents/skills/operations/SKILL.md create mode 100644 .agents/skills/pause-and-resume/SKILL.md create mode 100644 .agents/skills/security/SKILL.md create mode 100644 .agents/skills/tests/SKILL.md create mode 100644 .agents/skills/ux/SKILL.md create mode 100644 .agents/skills/verification/SKILL.md create mode 100644 .claude/skills/data-migration/SKILL.md create mode 100644 .claude/skills/discovery/SKILL.md create mode 100644 .claude/skills/documentation/SKILL.md create mode 100644 .claude/skills/framing/SKILL.md create mode 100644 .claude/skills/operations/SKILL.md create mode 100644 .claude/skills/pause-and-resume/SKILL.md create mode 100644 .claude/skills/security/SKILL.md create mode 100644 .claude/skills/tests/SKILL.md create mode 100644 .claude/skills/ux/SKILL.md create mode 100644 .claude/skills/verification/SKILL.md create mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE/01-feature.yml create mode 100644 .github/ISSUE_TEMPLATE/01-request.yml rename .github/ISSUE_TEMPLATE/{05-debt.yml => 04-debt.yml} (92%) delete mode 100644 .github/ISSUE_TEMPLATE/04-spike.yml create mode 100644 .github/ISSUE_TEMPLATE/05-acceptance.yml create mode 100644 .github/workflows/plan-on-the-forge.yml create mode 100755 .nstack/check-modules.sh create mode 100755 .nstack/fitness-before-push.sh rename docs/adr/_TEMPLATE.md => .nstack/forms/adr.md (80%) rename docs/project/_CHARTER_TEMPLATE.md => .nstack/forms/charter.md (68%) create mode 100644 .nstack/forms/cycle.md rename docs/project/_DISCOVERY_TEMPLATE.md => .nstack/forms/discovery.md (95%) rename docs/pdr/_TEMPLATE.md => .nstack/forms/pdr.md (80%) create mode 100644 .nstack/forms/rules.md rename {docs/os => .nstack/handbook}/00-overview.md (61%) rename {docs/os => .nstack/handbook}/01-principles.md (100%) rename {docs/os => .nstack/handbook}/02-modules.md (92%) rename {docs/os => .nstack/handbook}/03-contracts.md (74%) rename {docs/os => .nstack/handbook}/04-ai-context.md (76%) create mode 100644 .nstack/handbook/05-workflow.md rename {docs/os => .nstack/handbook}/06-decisions.md (59%) create mode 100644 .nstack/handbook/07-governance.md rename {docs/os => .nstack/handbook}/08-quality.md (89%) rename {docs/os => .nstack/handbook}/09-platform.md (66%) rename {docs/os => .nstack/handbook}/10-measurement.md (93%) create mode 100644 .nstack/handbook/INSTALL.md create mode 100644 .nstack/handbook/README.md create mode 100644 .nstack/handbook/RULES.md create mode 100644 .nstack/handbook/glossary.md create mode 100644 .nstack/handbook/project.md rename {playbooks => .nstack/playbooks}/data-migration.md (78%) rename {playbooks => .nstack/playbooks}/discovery.md (71%) create mode 100644 .nstack/playbooks/documentation.md create mode 100644 .nstack/playbooks/framing.md rename {playbooks => .nstack/playbooks}/operations.md (88%) create mode 100644 .nstack/playbooks/pause-and-resume.md rename {playbooks => .nstack/playbooks}/security.md (81%) rename {playbooks => .nstack/playbooks}/tests.md (51%) rename {playbooks => .nstack/playbooks}/ux.md (92%) create mode 100644 .nstack/playbooks/verification.md rename {docs => .nstack}/tooling-profile.md (80%) delete mode 100644 contracts/.gitkeep delete mode 100644 contracts/AGENTS.md delete mode 100644 contracts/MANIFEST.yaml delete mode 100644 contracts/README.md delete mode 100644 contracts/docs/runbook.md delete mode 100644 contracts/tests/.gitkeep delete mode 100644 docs/architecture/.gitkeep delete mode 100644 docs/os/05-workflow.md delete mode 100644 docs/os/07-governance.md delete mode 100644 docs/os/README.md delete mode 100644 docs/project/README.md delete mode 100644 docs/project/cycles/_TEMPLATE.md delete mode 100644 docs/runbooks/.gitkeep delete mode 100644 modules/.gitkeep delete mode 100644 playbooks/framing.md delete mode 100644 playbooks/verification.md diff --git a/.agents/skills/data-migration/SKILL.md b/.agents/skills/data-migration/SKILL.md new file mode 100644 index 0000000..07483cf --- /dev/null +++ b/.agents/skills/data-migration/SKILL.md @@ -0,0 +1,132 @@ +--- +name: data-migration +description: 'The project''s rules on data and migrations: schema expand/contract, backfill, data deletion, data ownership by module. Load this playbook when you are touching: a data schema, a migration, existing data.' +--- + + + +# Playbook — Data and migrations + +> **Trigger.** Load this playbook when you are touching: a data schema, a migration, +> existing data. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/data-migration.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| DM1 | **A migration is a production change**, not a code change. It falls under high-risk actions (kernel §5). | +| DM2 | **Each module owns its data.** No direct access to another module's database — you go through its contract. | +| DM3 | **Never rename or delete in place.** You add, you let both coexist, you migrate, you remove. | +| DM4 | **Every migration has a rollback plan**, or a written justification for not having one. | +| DM5 | **Never run a destructive migration without explicit confirmation.** | + +--- + +## 1. Expand / Contract applied to the schema + +The same logic as contracts (`.nstack/handbook/03-contracts.md`), for the same reason: the old and +the new code coexist during the deployment. + +```mermaid +flowchart TD + A["Need: rename a field
or change its type"] --> B["1 · EXPAND the schema
add the new field,
nullable, touching nothing"] + B --> C["2 · Double write
the code writes both"] + C --> D["3 · Backfill
fill in the existing rows,
in batches, idempotent, resumable"] + D --> E["4 · Switch reads
the code reads the new field"] + E --> F{"Stable in
production?"} + F -->|No| E2["Read from the
old field again"] --> D + F -->|Yes| G["5 · Stop writing
the old field"] + G --> H["6 · CONTRACT
drop the old field"] + + style B fill:#065f46,color:#fff + style D fill:#1f2937,color:#fff + style H fill:#7c2d12,color:#fff +``` + +**Legend** — green: the additive step, always safe · dark grey: the operational step · +red: the irreversible step, the one that gets forgotten. + +Each step is **a pull request deployable on its own**. At no point is the system in a +state where a rollback would break the data. + +Step 6 is the most forgotten. It carries a date and an owner, in a *Technical debt* +issue: no check reads a schema's dates, so the contraction is the project's to track. + +--- + +## 2. Before any migration + +| Question | If the answer is missing | +|---|---| +| How many rows are affected? | Measure before writing the migration | +| Does it lock a table? For how long? | Test on a representative volume | +| Does the old code still work afterwards? | It must, during the deployment | +| Does the new code work beforehand? | Same, the other way round | +| What happens to non-conforming data? | Count it, decide explicitly | +| How do you roll back? | Write the plan, or justify its absence | +| How will you know it went well? | Define the verification before starting | + +--- + +## 3. Backfill + +A backfill over a large volume is an operational procedure, not a script. + +- **In batches**, with a pause between batches — never process everything at once. +- **Idempotent**: re-runnable with no side effect. +- **Resumable**: remembers its progress, survives an interruption. +- **Observable**: progress, errors, estimated duration. +- **Interruptible**: it must be possible to stop it without corrupting the state. +- **Measured beforehand**: row count, estimated duration, impact on load. + +--- + +## 4. Deleting data + +This is irreversible. Mandatory procedure: + +``` +1. count exactly what will be deleted +2. check the selection criterion against a sample +3. back up or archive what is being deleted +4. run in dry-run mode first +5. ask for explicit confirmation, with the exact count +6. delete in batches, with a stopping point +7. verify afterwards +``` + +A deletion triggered by a retention rule is a product decision: it belongs to a PDR, not +to a technical task. + +--- + +## 5. Data ownership + +Implicit data sharing is the hardest form of coupling to undo, because it is invisible +in the code. + +| Situation | Handling | +|---|---| +| A module reads another's table | A violation — detected by a fitness function | +| Database shared between two modules | ADR required, with explicit ownership per table | +| Data duplicated across modules | Acceptable when a source of truth is designated and the synchronisation is contractual | +| A join across domains is needed | A signal of a bad boundary — do not work around it with direct access | + +--- + +## 6. Closing checklist + +- [ ] Migration tested on a representative volume +- [ ] Old and new code both work during the transition +- [ ] Backfill in batches, idempotent, resumable +- [ ] Rollback plan written, or its absence justified +- [ ] Post-migration verification defined **before** the run +- [ ] Contraction step planned, with a date and an owner +- [ ] Destructive action explicitly confirmed, with the exact count +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.agents/skills/discovery/SKILL.md b/.agents/skills/discovery/SKILL.md new file mode 100644 index 0000000..74757ee --- /dev/null +++ b/.agents/skills/discovery/SKILL.md @@ -0,0 +1,135 @@ +--- +name: discovery +description: 'The project''s discovery rules: turning an idea into a decision — intake, sourced market research, definition, the value hypothesis and no-gos, a challenge by another session (pre-mortem, four risks), then go, clarify or kill. Load this playbook when you are touching: an idea to test, a discovery to challenge or decide.' +--- + + + +# Playbook — Discovery + +> **Trigger.** Load this playbook when you are touching: an idea to test, a discovery to +> challenge or decide. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/discovery.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Your posture + +You run stages 1 to 4 as the **framer**, stage 5 only as the **challenger** — never both in +the same session. The decider decides, at stage 6. For the framer and the challenger, this +playbook replaces the kernel's working loop (§2); its closing summary (§8) still applies. + +| You do | You never do | +|---|---| +| Framer: ask one question at a time, only what you cannot infer | Agree to please; soften an objection | +| Give every market fact its source | State a fact you cannot source — write it as an assumption | +| Keep the document to what could change the decision | Fill a canvas, size a market, invent personas | +| End each round with a decision | Open a new direction before the round is decided | + +The engine's `discover` command created `docs/project/discovery.md`: one section per stage, +each ending with its open questions. When the decider cannot answer now, write the question +there — most decision-changing first — and go on; never answer it in their place. + +--- + +## 1. Intake + +Read the idea file entirely. Restate the idea in one paragraph — for whom, where, which +problem, what the product does — and ask the decider to correct it. Record the decider in +the front matter. Until the decider confirms the paragraph, mark it *unconfirmed*: the round +cannot be decided while it is. + +Ask, once, **in which language the project writes** — its documents, its code, its commit +messages. The idea file may be in one language and the framework's forms in another; nobody +notices until half the documents are in each. The answer is the project's first rule: one +line of `docs/project/rules/always.md`, written now, with the idea file left as it was given. + +Ask, once, **what has already been asked of, promised to, or received from someone outside the +team** — a client, a vendor, a partner — by mail, chat or meeting. A fresh session remembers none +of it, and an outside party asked twice, or asked differently, pays for it in patience. Each answer +is an entry of the project's log issue, opened now if there is none (`.nstack/handbook/06-decisions.md` +§9): who, what, when, by which channel — never a secret or a credential, and nothing the outside +party would not have public in a public repository's issue (`security.md`). + +## 2. Research + +With the research tools of `.nstack/tooling-profile.md` — or, when that row is empty, the tools +at hand, named in the document — look for: + +- what users do today instead, including nothing; +- the direct and indirect alternatives, their positioning and their price; +- the business models of the field; +- the legal and regulatory constraints, for the countries concerned. + +Each finding goes in the evidence table, with what it changes for the idea and its source. +Prefer the primary source; mark figures a company reports about itself, and claims seen only +in a search excerpt. A claim without a source goes to *Assumptions*. Stop when each of the +four points has at least one sourced finding, or an explicit "not found". + +**A legal or regulatory claim is read at its primary source — the text itself, the +regulator's page — or it is an assumption.** A summary of a law by someone who sells a +product under it is not a source, and a rule the design will rest on is the last thing to +take second-hand: say "not read" rather than mark it as seen elsewhere. + +## 3. Define + +With the decider: the users; their problem — quoted from users, saying who and how many, +since words reported by the decider alone are an assumption; the constraints — who runs it, +budget, platforms, regulation; and the success signals — what will be observed, and by when, +if the idea is right. If this stage changes the users or the model, revisit stage 2. + +## 4. Shape + +- **The value hypothesis** — why a user would switch from what they do today, in one or two + sentences, stated so that it can be proven wrong. Not a list of features. +- **A short press release**, dated launch day — a placeholder if none is set: the user, the + problem, the product, one quote, labelled as imagined. Record whether it convinces the + decider; if it does not, that is a finding. +- **No-gos** — what the product deliberately will not do: the decider's, and any the framer + proposes, marked *proposed*. + +## 5. Challenge — in another session + +A session that did not write stages 1 to 4, or a human; it starts once section 1 is +confirmed — otherwise it names the reading it challenges. The challenger does not interview +the decider: its questions go into its objections. It reads the idea file and the document, +then: + +1. **Pre-mortem** — the product launched a year ago and failed: the plausible reasons, each + tagged with its risk. +2. **The four risks** — *value*: will they use it, or buy it? *usability*: can they use it? + *feasibility*: can it be built with the means at hand? *viability*: does it hold for the + business — cost, law, operations? For each, the riskiest assumption and the cheapest test + that could refute it: what is done, for how long, and the result that refutes it — a + threshold proposed, for the decider to set. +3. **Counter-evidence** — what contradicts the value hypothesis or the riskiest assumptions: + failed products, closed competitors, regulatory refusals. Research as in stage 2 — same + tools, same marking, the same stopping rule; an unsourced claim is marked *assumption*. +4. **Flaws in stages 1 to 4** — each citing the line it objects to. + +These are the objections, written in section 5 with the challenger's name and date. Never +rewrite stages 1 to 4. + +## 6. Decide + +A framer session presents section 5 unchanged, then the riskiest assumptions and the value +hypothesis. The decider chooses: + +| Decision | What follows | +|---|---| +| **go** | The pull request that records the decision writes the front page's sentence (`README.md`) — what the product does, for whom, as the decider confirmed it — and nothing else of that page. The framing then writes the charter from this document (`framing.md`); the tests the decider keeps become spike deliverables of the first cycle | +| **clarify** | A new round on the open questions, and on the cheap tests the decider picks before any charter; `round` goes up, section 5 is kept under its round, and the changed sections are challenged again | +| **kill** | The document stays, with its reasons — the cheapest outcome of all | + +Section 6 records the reasons, and for a go, why each objection does not block it. Record +`decision` and `decided_on` in the front matter, then run the fitness functions. + +--- + +## Bounds + +A round is one or two working sessions. A second `clarify` is the decider's explicit choice, +recorded in section 6 — never a default. diff --git a/.agents/skills/documentation/SKILL.md b/.agents/skills/documentation/SKILL.md new file mode 100644 index 0000000..2f74950 --- /dev/null +++ b/.agents/skills/documentation/SKILL.md @@ -0,0 +1,94 @@ +--- +name: documentation +description: 'The project''s rules for writing a document: a diagram with its legend first, a few lines after it, a source for every outside claim, a date on every decision, and documents kept current or deleted. Load this playbook when you are touching: a document a human will read, a pull request''s description included: writing or changing one.' +--- + + + +# Playbook — Documentation + +> **Trigger.** Load this playbook when you are touching: a document a human will read, a +> pull request's description included: writing or changing one. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/documentation.md` +> — read them with this playbook. They add to it or tighten it. + +```mermaid +flowchart LR + Q{"Is there a structure,
a flow or a state
to show?"}:::ask + Q -->|yes| D["A diagram
with its legend"]:::first + Q -->|no| T["A table,
or three lines"]:::first + D --> L["A few lines:
what the diagram
cannot say"]:::then + T --> L + L --> S["Sources and dates"]:::then + S --> C{"Still true
after this change?"}:::ask + C -->|no| U["Bring it current
or delete it"]:::stop + + classDef ask fill:#374151,color:#fff + classDef first fill:#065f46,color:#fff + classDef then fill:#1e3a8a,color:#fff + classDef stop fill:#7c2d12,color:#fff +``` + +**Legend** — grey: what you ask yourself · green: what the reader sees first · blue: what +follows it · red: the document that no longer says what is true. + +--- + +## The standard — five rules, and no content + +1. **Shape first**: a diagram with its legend before the prose, wherever there is a structure, + a flow or a state to show. A reader who stops after the diagram has understood. +2. **A source for every claim about the outside world** — a market, a law, a tool's + behaviour, a number. +3. **A date on every decision**, and on every criterion that will judge it. +4. **Current, or deleted.** A stale page costs more than a missing one, because it is + believed. +5. **A fact has one home.** Its home is the file a check or a command reads — a module's + manifest for its responsibility, owner and criticality; the cycle for a deliverable's criteria, and its state once the cycle is closed — during it, the + hold and the delivery record, which `nstack plan` reads; + the charter for the decider. Every other document that needs the fact links to it, never + copies it: two copies agree on the day they are written, and only on that day. + +The framework asks for this form and writes none of the content: what the document says is +the project's. + +--- + +## Drawing the diagram + +| Situation | Action | Verification | +|---|---|---| +| Parts and what links them: modules, users, systems | Boxes and arrows, a dozen boxes at most | Someone reading the diagram alone can say what the document is about | +| Things that happen in an order | A sequence, left to right or top to bottom | Every step has one way in | +| Something that changes state | The states and what moves it from one to the next | No state is a dead end unless it is meant to be | +| A choice between paths | A decision tree, the question in the node | Every branch ends on an action | +| A colour or a shape is used | It means one thing, and the legend under the diagram says which | The legend names every colour used, and nothing else | +| The diagram is ready | Written as text in the file, in the notation the tooling profile names — never an image. A drawing of a screen is no diagram: it is an image, frozen (`framing.md` §2) | The pull request shows what changed in it | +| Nothing to show: one fact, a list, a comparison | No diagram. A table, or three lines | A diagram that decorates is removed | +| More than a dozen boxes | Two diagrams, one idea each | Each has its own legend | + +## After the diagram + +- **Say what the diagram cannot**: the why, the exception, the number. Never describe the + diagram in words. +- **A table for anything a reader will compare**; a list for anything they will tick. +- **The point first.** A reader who must scroll to find what was decided has been given a + story instead of a document. +- **Short.** A paragraph a reader skips is a paragraph to delete. + +## Which document, and when + +Each document of a project has the event that makes it writable; before it, its form stays +a form. The table is `.nstack/handbook/06-decisions.md` §10 — read that one section before writing a +document the project does not hold yet, and never fill a form with what nobody has decided. + +--- + +## Closing checklist + +- [ ] The diagram comes first, with its legend — or there is nothing to draw, and no diagram +- [ ] Every claim about the outside world names its source +- [ ] Every decision and every criterion carries its date +- [ ] Every document this change makes untrue is brought current in the same pull request diff --git a/.agents/skills/framing/SKILL.md b/.agents/skills/framing/SKILL.md new file mode 100644 index 0000000..8067410 --- /dev/null +++ b/.agents/skills/framing/SKILL.md @@ -0,0 +1,227 @@ +--- +name: framing +description: 'The project''s framing rules: interviewing the decider, writing the charter, planning a bounded cycle with its deliverables, acceptance criteria and appetite, handling new ideas, and closing a cycle at its end or at its circuit breaker. Load this playbook when you are touching: framing a project, planning or closing a cycle.' +--- + + + +# Playbook — Framing + +> **Trigger.** Load this playbook when you are touching: framing a project, planning or +> closing a cycle. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/framing.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## When framing is worth it + +A project is **unframed** until its charter is accepted: a stage, not a fault. Every rule +judges its changes except the three that bound work inside a cycle. Framing buys an +appetite, an end date, a circuit breaker and a decider — worth their price **when there is +something to bound**: several people, a deadline, a decider who is not the one typing. Say +so when you are asked to frame a project where none of the three is true; then frame it if +the decider still wants it. Never frame to make a check pass: no check asks for it. + +## Your posture + +You are the **framer**. You propose; the decider decides. For the framer, this playbook +replaces the kernel's working loop (§2); its closing summary (§8) still applies. + +| You do | You never do | +|---|---| +| Interview the decider, one subject at a time | Decide in their place, or fill a gap with an invention | +| Propose the field's convention by default, marked *(framer, to confirm)* with its source | Propose more than the need | +| List the open questions, blocking apart | Let a charter or a cycle be accepted with a blocking question open | +| Keep the first cycle small | Split into many modules on day one (`.nstack/handbook/02-modules.md` §3) | + +A proposal without a source is an open question, not a proposal. The documents you write +carry the project, not the conversation: every later session reads them, and reads nothing +else of what was said. + +--- + +## 1. Frame the project: the charter + +Start from what the decider gives you. When `docs/project/discovery.md` exists, its decision +must be **go**: the charter reuses its users, problem, constraints, success signals, no-gos +and risks, carries its unanswered questions into its own, and you ask only what it leaves +open. Otherwise — an idea alone — propose a discovery first (`discovery.md`); a specification +already challenged can be framed directly. Read the source entirely, then interview, one +subject at a time, asking only what you cannot infer: + +| Subject | Ask | The charter records | +|---|---|---| +| Users | Who uses it, in what situation, with what problem? | The users and their problem | +| Outcome | What must be true for the project to be finished? | Success criteria, measurable, dated — or relative to a named event, such as launch day, that a later framing dates | +| Constraints | Law, money, security, data, platforms, deadlines | The constraints | +| Risks | What could make it fail, or cause harm? | The risks, and the criticality they imply — what a failure of each module would cost, which the decider settles and `.nstack/handbook/05-workflow.md` §7 prices | +| Vocabulary | The domain's words, and what each one means | The vocabulary | +| Not this project | What it will deliberately not do | Out of scope | +| Outside the team | What has already been asked of, promised to, or received from someone outside the team — a client, a vendor, a partner — by any channel? When the discovery asked it, only what changed since; otherwise, in full | Nothing in the charter: each answer is an entry of the project's log issue (`06-decisions.md` §9) | + +A domain that moves money, handles personal data or acts on someone's behalf raises the +criticality of the modules concerned, and `security.md` applies from the first cycle — to +the code, and to the data a spike collects: who sees it, how long it is kept. Say so to the +decider. + +**Before proposing a criticality, read the rule** — the last paragraph of +`.nstack/handbook/05-workflow.md` §7: a module that holds a key, places an order, moves money or +touches someone's personal data is `critical`. Propose what the rule says, with what each +value costs; a lower value is the decider's to choose, and is written as a deviation with its +reason and the event that ends it. + +When no discovery came first, ask too **in which language the project writes**; the answer is +its first rule (`docs/project/rules/always.md`). + +**A constraint that binds how the work is done becomes a rule of the project**, proposed +with the charter: one line of `docs/project/rules/.md`, from +`.nstack/forms/rules.md` — the subject is the playbook it completes, `always` when +it applies to every task. It names its source in the charter and how it is checked. Never +write it into a playbook or the kernel: those are every project's, and the next update +would conflict on it. + +Write `docs/project/charter.md` from `.nstack/forms/charter.md`, with +`status: proposed` and the open questions at the end, then run the fitness functions. +"Finished" means the charter's goal is reached: framing stops; running what was built may go +on. + +## 2. Plan a cycle + +1. **Goal** — one sentence, the one outcome of this cycle. +2. **Deliverables** — a finite list, `D1`, `D2`…, each an outcome a user can observe — for a + spike, the question it answers for the decider. Each gets acceptance criteria, written + *given · when · then*; they become its test sheet (`verification.md`). + + **Two questions to ask of each one, before writing its criteria:** + - *Can the team finish it alone, inside this cycle?* If it waits on someone outside the + project — a reply, an opinion, a decision elsewhere — it is a **dependency with a date**, + not a deliverable. Name it in the risks and give it a date; the cycle does not hold it. + - *Is its product knowledge rather than code?* Then it is a **spike**, and its criteria say + **what will be recorded** and **the threshold it is read against** — never that the answer + comes out a particular way. **A refuted result is a delivered one.** "Five people were + asked, one acted, below the threshold of two" closes the deliverable; it does not fail it. + When its product is a **drawing** — the screens, the journey the user will see — the + drawing is committed under `docs/project/drawings/-/` with its date, + and frozen: what the decider accepts in it becomes criteria of the deliverable that + builds it, and once built, the product and its screenshots are the truth. A new round is + a new folder, never an update. + + A criterion nobody can meet is not met. It is answered with something that looks like proof, + and that answer is reviewed and merged like the rest. +3. **Unknowns** — a blocking unknown becomes a *spike* deliverable, whose output is + knowledge (`.nstack/handbook/05-workflow.md` §3). After a discovery's go, the tests the decider kept + are the first cycle's spikes. +4. **Modules** — name each deliverable's module; a spike run outside the code — a sign-up + form, interviews, a measure whose product is a record and not shipped code, even about one + module — has none (`module: null`): no merge carries it, so `nstack deliver` has nothing to read. Propose a new module only against the tree of + `.nstack/handbook/02-modules.md` §3: one module is often enough to start. +5. **Appetite** — ask the decider how many weeks they **want** to spend, not how long it + will take — in days for a cycle shorter than a week, such as an engagement whose date an outside + party sets (`appetite_days`), never rounded up to a week nobody agreed to. When the deliverables + do not fit, cut the scope; never stretch the appetite. +6. **Out of scope and later** — out of scope is not done even if time remains; *later* holds + the candidates for the next framing. + +Write `docs/project/cycles/NN-.md` from `.nstack/forms/cycle.md`, with +`status: proposed` and `end` = `start` + the appetite, then run the fitness functions. + +## 3. Hand over to the decider + +A cycle's *What needs a person* holds what only a person can do, each with its literal gesture: fill it +while framing, and keep it true. It is what `nstack plan` opens with. A request to someone outside +the team starts from the log issue's entries, and from the decider's answer to what has been asked, +promised or received outside since the last one — every cycle, not only the first: nothing already +asked is asked again, nothing is asked more broadly than before without saying why, and each new +request becomes an entry. One still awaiting a reply that a deliverable needs is a dependency with a date. + +Present the charter, the cycle, the open questions, what went to *later*, and what you are +unsure of — the cycle also as the board will show it: `nstack board --dry-run` previews the +milestone and the issues its acceptance would create, and what it would collide with, and makes +none; put the lines under *On acceptance of cycle …* in the framing pull request's description. The decider amends; the framer sets `status: accepted` — on the charter, then on the +cycle — in a pull request the decider approves, and that approval is their gesture; accepted after `start`, the cycle's `start` and `end` +move in the same pull request. **The next cycle, accepted while one runs**, stays `proposed` — one +accepted cycle at a time (C5) — and gains `accepted_on: `: `nstack plan` stops asking +for it while that cycle runs, and the running cycle's closure starts it (§5). The modules accepted there are created with the engine's +module scaffolding, declared user-facing when a user sees them. + +**Where the project's own rules waive approval** — an agent merging alone on an attested, +verified head, `doctor`'s G2 taken knowingly — nobody approves that pull request, and the +decider's word stands for the approval: quoted in the page it accepts (the charter, the cycle), +with its date and where it was said — a comment, a message, a meeting's note. The same holds +for a deliverable accepted below. Without that line, the acceptance is the agent's alone. + +**The pull request that accepts the charter writes the project's front page from it** — +`README.md`: a diagram of who uses the product and what it talks to, how to run what exists, +and the sentence when no discovery wrote it. Until then that page holds its sentence at most; +from then on the plan check refuses an accepted charter over a form left as it came +(`.nstack/handbook/06-decisions.md` §10, `documentation.md`). + +## 4. During the cycle + +- **A new idea** goes to *later*. It enters the cycle only if the decider re-frames: + swapping a deliverable out, adding one they judge fits what is left of the appetite — + the end date does not move — or closing the cycle early. An added deliverable takes its + criteria like the others, and its section says on whose word and on what it entered. +- **An urgent fix** outside the cycle — an incident, a production defect — goes in a pull + request with the `out-of-cycle` label and the line `Out of cycle: `. +- **A deliverable's state** is written in the cycle file at framing (`proposed`, then `ready`: + testable criteria, set by the framer, confirmed when the decider accepts the cycle), on a + re-framing (`deferred`, `dropped`), and at the closure (`accepted`, by + `nstack deliver --write-states`) — never during delivery, and never in a delivery's pull request. + In between, `nstack plan` reads it: *held* from its claim, *delivered* from its record + (`nstack deliver D --held '#'`, kernel §2 step 12, `.nstack/handbook/project.md`); + it asks the decider nothing. It is accepted when each of its criteria is held by a scenario of a merged sheet, or by an + answer in the acceptance issue the cycle names beside the state (`.nstack/handbook/05-workflow.md` + §7); a criterion only a person can try waits for that answer. A spike outside the code is held + by a decision record when it binds the project (*Decisions* below), otherwise by a line of the + log issue it was run under — the project's, or its module's —, which its section links: with no merge it has no record, and the closure + writes its `accepted` by hand beside the states `--write-states` wrote, citing that line. Where + approval is waived (§3), the decider's word is quoted once, at the closure, for the cycle. A rule + sees that a merge exists, not that a criterion holds: the closure reads the records before it + writes. + +## 5. The end of a cycle + +**Every deliverable delivered or accepted** — `nstack deliver --write-states`, and `nstack plan --prune` for the empty start branches a deferred deliverable left, then write the closure: what was delivered, which success +criteria moved, what was deferred, and **which documents the cycle brought current** — the +front page and the module map first, each with its pull request; set `status: closed`, +`outcome: completed`, `ended_on`. A next cycle carrying `accepted_on` is set `status: accepted` in the +same pull request; its `start` becomes the closure's day when it is not, and its `end` follows the appetite. +A success criterion the decider says moved is recorded under `success:` in the front matter, at +any closure — by its number in the charter, `met`, or `observing` with the day observation +started; the latest record is its state, and `nstack plan` counts the criteria met. +When a spike refutes what the charter rests on, present stopping the project too. + +**The end date reached first** — the circuit breaker: nothing is extended. Present the +three choices, with the state of every deliverable. Whichever is chosen, `nstack deliver --write-states` comes +first, while the cycle is still accepted: it is what brings the records into the cycle file. + +| The decider chooses | `status` | `outcome` | +|---|---|---| +| Ship what is delivered or accepted | `closed` | `shipped` | +| Frame a new cycle, with a new appetite | `stopped` | `reframed` | +| Stop the project | `stopped` | `stopped` | + +A next cycle carrying `accepted_on` starts here only on `shipped`, as on a completed closure. On `reframed` or +`stopped`, the word was given for another situation: it stays `proposed`, and `nstack plan` asks the decider again. + +The closure is where the next framing starts. When `nstack plan` says the charter's goal is +reached — every success criterion met —, present it: the decider says whether the project is +finished. + +## Decisions + +A decision lives in a record, never in the charter, the cycle or a conversation +(`.nstack/handbook/06-decisions.md`): one register of each kind at the project's root — +`docs/pdr/` for the product, `docs/adr/` for the technique — and `Scope: module ` when it +concerns one module. + +| When | Then | +|---|---| +| An accepted charter has to change — a constraint, a user, what the project is not | A **PDR** first, which the change cites; the charter is never rewritten in place (CI warns, C9) | +| The framing chooses a module, a stack, a contract | An **ADR**: the module's creation decision is one | +| A spike's result binds the project | A PDR or an ADR; otherwise a line in the project's log issue | +| A cycle's **closure** | Read every decision the plan names as due (C10): its criterion names this cycle, or a date in bold, `**YYYY-MM-DD**`, its end reached. The record gains one line under its criterion, *Read at 's closure, : met \| missed \| superseded*, and nothing else; a *missed* one is the decider's to answer, by a new record or the removal condition | diff --git a/.agents/skills/operations/SKILL.md b/.agents/skills/operations/SKILL.md new file mode 100644 index 0000000..5c13a96 --- /dev/null +++ b/.agents/skills/operations/SKILL.md @@ -0,0 +1,184 @@ +--- +name: operations +description: 'The project''s operations and reliability rules: timeouts, retries, structured logs, metrics, alerts, health checks, rollback and controlled degradation. Load this playbook when you are touching: logs, metrics, alerts, retries, timeouts, rollback, a deployment, a call to another system.' +--- + + + +# Playbook — Operations and reliability + +> **Trigger.** Load this playbook when you are touching: logs, metrics, alerts, retries, +> timeouts, rollback, a deployment, a call to another system. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/operations.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| OPS1 | **Never an automatic retry without analysing the side effects.** | +| OPS2 | **Every external call has an explicit timeout.** A call without one is an outage waiting to happen. | +| OPS3 | **No secret and no personal data in the logs.** | +| OPS4 | **An error quietly swallowed is a future incident.** | +| OPS5 | **A module in production with no way of knowing it is unwell is not ready.** | + +--- + +## 1. Retries — the classic trap + +```mermaid +flowchart TD + A["Considering a retry"] --> B{"Is the operation
idempotent?"} + B -->|No| C["DO NOT RETRY.
Make it idempotent first,
with an idempotency key"] + B -->|Yes| D{"Is the error
transient?"} + + D -->|"No: 4xx, validation,
authorisation"| E["DO NOT RETRY.
The result will be identical."] + D -->|"Yes: network, 5xx,
timeout"| F{"Exponential backoff
with jitter?"} + + F -->|No| G["DO NOT RETRY.
A synchronised retry turns
a local incident into a global outage"] + F -->|Yes| H{"Maximum count
and total budget
defined?"} + + H -->|No| G + H -->|Yes| I["Retry acceptable,
with a metric on the retry rate"] + + style C fill:#7c2d12,color:#fff + style E fill:#7c2d12,color:#fff + style G fill:#7c2d12,color:#fff + style I fill:#065f46,color:#fff +``` + +**Legend** — red: do not retry, and why · green: the only branch where a retry is safe. + +Three side effects to check every time: + +- **Duplication** — a retry on a non-idempotent operation applies the effect twice. +- **Amplification** — N clients retrying at the same time multiply the load on a service + already in trouble. +- **Masking** — a retry that succeeds hides a real degradation. The retry rate is + therefore a metric, not an implementation detail. + +--- + +## 2. Timeouts + +| Rule | Why | +|---|---| +| Every external call has an explicit timeout | A call without one blocks a thread indefinitely | +| The timeout is shorter upstream than downstream | Otherwise the caller gives up before the callee, and the work is lost | +| A total budget exists for the request | Prevents cascading timeouts from accumulating | +| The timeout is a configured value, not a buried constant | It will need adjusting in production | + +--- + +## 3. Logs + +| Do | Avoid | +|---|---| +| Structured, machine-readable | Concatenated strings nothing can parse | +| A correlation identifier propagated | Logs impossible to tie together | +| Useful context: what, where, which identifier | "Error" with no context | +| Consistent levels, actually respected | Everything at `info`, or everything at `error` | +| Masking sensitive data **at the source** | Masking at display time | + +A log that does not let you reconstruct what happened has only occupied disk space. +Control question: *at 3 a.m., does this log let me understand without reading the code?* + +--- + +## 4. Metrics and alerts + +| Type | Example | +|---|---| +| Traffic | Requests, messages processed | +| Errors | Error rate, by type | +| Latency | The distribution, not only the mean | +| Saturation | Queue, connections, memory | +| Business | What the module is supposed to produce | + +**The mean hides everything.** A healthy average latency can conceal 5 % of users waiting +ten seconds. Always look at the distribution. + +### Alerts + +| Rule | Reason | +|---|---| +| Alert on a **user-visible symptom**, not on a technical cause | Causes change, the symptom stays relevant | +| Every alert is **actionable** | An alert with nothing to do will be ignored | +| Every alert points to a **runbook** | Otherwise the knowledge sits in one person's head | +| An alert that fires with no action taken is **removed or fixed** | Noise destroys the value of every alert | + +--- + +## 5. Health checks + +| Type | Answers | Trap | +|---|---|---| +| *Liveness* | Should the process be restarted? | Must **not** depend on external dependencies — otherwise an external outage causes a restart loop | +| *Readiness* | Can it take traffic? | Must check the critical dependencies | +| *Startup* | Has it finished starting? | Avoids restarts during a slow initialisation | + +--- + +## 6. Deployment and rollback + +```mermaid +flowchart TD + A["Change ready"] --> B{"Compatible with
the previous version?"} + B -->|No| C["Split it: make it compatible
first, then switch over"] + B -->|Yes| D["Deploy"] + D --> E["Smoke tests"] + E --> F{"Green?"} + F -->|No| G["Immediate ROLLBACK"] + F -->|Yes| H["Verification through
observability:
errors · latency · business"] + H --> I{"As expected?"} + I -->|No| G + I -->|Yes| J["Done"] + + style G fill:#7c2d12,color:#fff + style J fill:#065f46,color:#fff + style C fill:#1f2937,color:#fff +``` + +**Legend** — red: roll back · green: done · dark grey: split the change instead. + +- **Rollback is tested**, not assumed. A rollback never executed probably does not work. +- **A deployment is not finished at deploy time**: it is finished when observability + confirms the expected behaviour. +- **Backward compatibility is mandatory**: during the deployment two versions coexist. An + incompatible change is split up (`.nstack/handbook/03-contracts.md`). + +--- + +## 7. Controlled degradation + +Decide **in advance** what happens when a dependency is unavailable: + +| Strategy | When | +|---|---| +| Fail cleanly | The feature makes no sense without the dependency | +| Serve a default value | An approximation beats nothing | +| Serve from a cache, even a stale one | Freshness matters less than availability | +| Disable the feature, keep the rest | The dependency is secondary | +| Queue for deferred processing | The operation can be asynchronous | + +The choice is explicit and tested. Without a prior decision, the default behaviour is +always the worst one: an opaque error at the worst possible moment. + +--- + +## 8. Closing checklist + +- [ ] Explicit timeouts on every external call +- [ ] Retries justified, idempotent, with backoff and a ceiling — or absent +- [ ] Logs structured, correlated, free of secrets and personal data +- [ ] Errors never swallowed quietly +- [ ] Metrics and alerts actionable, pointing at a runbook +- [ ] Health checks correct (liveness with no external dependencies) +- [ ] Backward compatibility verified +- [ ] Rollback documented and tested +- [ ] Behaviour on unavailability decided explicitly +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.agents/skills/pause-and-resume/SKILL.md b/.agents/skills/pause-and-resume/SKILL.md new file mode 100644 index 0000000..fd3fe6a --- /dev/null +++ b/.agents/skills/pause-and-resume/SKILL.md @@ -0,0 +1,90 @@ +--- +name: pause-and-resume +description: 'The project''s rules for ending and resuming a session: work committed and pushed before stopping, nothing left running, holds kept, a short resume note in .nstack/local/, and a restart that reads the note, renews its holds and runs nstack plan once. Load this playbook when you are touching: stopping, restarting, handing work over, or resuming a session.' +--- + + + +# Playbook — Pause and resume + +> **Trigger.** Load this playbook when you are touching: stopping, restarting, handing work over, +> or resuming a session. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/pause-and-resume.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## The rule: the repository holds the state, a note points into it + +```mermaid +flowchart LR + S["Stop
work pushed, tree clean"] --> N["Note
.nstack/local/resume.md"] + N -. restart .-> R["Resume
read the note, renew holds"] + R --> P["nstack plan, once"] --> G["the noted gesture"] + classDef state fill:#1f2937,color:#fff + class S,R state +``` + +*Legend: solid arrows are what you do in order; the dotted one is the session ending.* + +A session ends without warning: a restart, a full context, a person's evening. What it knew must +already be where the next one reads it — commits, pull requests, holds — and the next one must +not have to re-read the history to find it. A note of a few lines says where to look; it never +replaces what it points to. + +Your tool's own memory, a chat summary or a transcript are extras: useful to you, invisible to +another tool and to another person. The source is the repository and the forge. + +--- + +## Stop + +Before you stop, or when you are told the session will end: + +1. **Nothing only in the working tree.** Commit what is in progress, on its work branch, and push + it: the pushed branch shows it, and on GitHub the claim's draft pull request too when the work + is on its first branch. A commit or a push a hook refuses: fix its cause; what you cannot fix + before stopping stays as it is, and the note names it with the refusal — never `--no-verify`. +2. **Nothing running.** No background job, watcher or server left for the next session to find. +3. **Nothing left over.** Scratch clones, worktrees and local branches of your own that hold no + work are removed; a worktree that holds work is pushed first. Never the start branch your + claim made: `nstack deliver` removes it. +4. **Holds stay.** A deliverable you will resume stays held (`nstack plan` shows it). Past + `hold_days` without work, anyone may take it over: give back with `nstack unclaim` what you + will not resume by then. +5. **Write the note.** + +## The note + +`.nstack/local/resume.md` — one per clone, never committed (`.nstack/local/` is ignored). +Fifteen lines at most; over that, it repeats what the repository already says. Rewrite it +whole at each stop: it states the present, not a journal. + +```markdown +# Resume — 2026-11-24 18:40, session , for +- Merged since the last note: D30 (#41) +- Open: D31, pull request #44 — next: answer the verifier's finding on the empty state; mine +- Open: D32, branch d32-export, pushed, no pull request yet — next: the test sheet; mine +- Owed by others: the decider's approval of #42; the verifier's run of #44 +- Not pushed: (nothing) — or the commit, the files, and the hook's refusal +- Next id: D33 +- Relaunch: nstack agent run -- +``` + +Handing over to another session or person: give them the note's text with the hand-over, and +give the hold back (`nstack unclaim`) for them to claim. Never hand over a clone. + +## Resume + +1. **Read the note, and only the note.** Not the history, not the transcripts. No note: `git + status`, `git log` of your branches and `nstack plan` say the same, more slowly. +2. **Renew your holds** under this new session. In `nstack agent run`: + `nstack claim --person --session ` renews a hold your own agent + held. Outside it, a new session of yours takes its hold over, on your person's word: + `nstack claim --take-over --person --session ` + (`.nstack/handbook/project.md`, *Who holds a deliverable*). +3. **`nstack plan`, once**: what changed while you were away — merges, holds, what turned stale. + Where it disagrees with the note, the repository is right; the note was the past. +4. **Continue at the noted gesture.** A gesture owed by someone else is not yours to redo. diff --git a/.agents/skills/security/SKILL.md b/.agents/skills/security/SKILL.md new file mode 100644 index 0000000..4f7dec9 --- /dev/null +++ b/.agents/skills/security/SKILL.md @@ -0,0 +1,134 @@ +--- +name: security +description: 'The project''s security rules: authentication, authorisation, secrets, input validation, personal data, dependencies and high-risk actions. Load this playbook when you are touching: authentication, authorisation, secrets, personal data, external input, a new dependency.' +--- + + + +# Playbook — Security + +> **Trigger.** Load this playbook when you are touching: authentication, authorisation, +> secrets, personal data, external input, a new dependency. +> +> Format: `situation → action → verification`. Anything not verifiable here must go to +> human review. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/security.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| SEC1 | **No secret in the repository.** Not in clear text, not encoded, not "temporarily", not in a test, not in a comment. | +| SEC2 | **All external input is hostile** until explicitly validated. | +| SEC3 | **Least privilege by default** — including for CI and for agents. | +| SEC4 | **Deny by default** in authorisation: whatever is not explicitly allowed is forbidden. | +| SEC5 | **Never design your own** cryptographic, password-hashing or authentication mechanism. The established convention, always (Prior Art Gate). | + +If one of these rules has to be broken, this is no longer a development task: it is a +decision, and it goes through an ADR and human approval. + +--- + +## Authentication + +| Situation | Action | Verification | +|---|---|---| +| New entry point | Check it is covered by the existing mechanism, not a new one | Test: unauthenticated call → refused | +| Password storage | A slow, standard hashing algorithm, never a homemade one | Test on the algorithm used | +| Session or token | Expiry, revocation and rotation planned | Test: expired token → refused | +| Authentication error message | Never reveal whether the account exists | Test on the message content | + +--- + +## Authorisation + +This is the most frequent source of vulnerabilities, and the easiest to test. + +| Situation | Action | Verification | +|---|---|---| +| New endpoint or action | Decide explicitly who is allowed | Test per role: allowed, not allowed, not authenticated | +| Access to a resource by identifier | Check ownership, not only the role | Test: user A reaches B's resource → refused | +| List or search | Filter server-side, never client-side | Test: the response contains no one else's data | +| Privilege escalation possible | Treat it as a high-risk action | Test + logging + human review | + +> **The most common trap.** Hiding a button in the interface is not an authorisation. +> Every access rule exists server-side, and is tested there. + +--- + +## Secrets + +| Situation | Action | Verification | +|---|---|---| +| A secret is needed | Environment variable or vault — never the code | Automated detection in CI | +| Secret exposed, even briefly | **Rotate immediately.** Removing it from the commit is not enough | An incident, not a simple fix | +| Secret in a test | A fake value explicitly named as such | Diff review | +| Log containing a secret or a token | Mask at the source, not at display time | Test on the log content | + +--- + +## Input and data + +| Situation | Action | Verification | +|---|---|---| +| User input | Validate structure, type, bounds, format — then sanitise | Test with invalid, empty, overlong, malformed input | +| Query to a database | Parameterised queries, never concatenation | Injection test | +| Displaying supplied content | Escape at render time, appropriately for the context | XSS test | +| File upload | Type, size, extension, storage outside any executable area | Test with a hostile file | +| Personal data | Minimise, encrypt at rest when sensitive, log access | Review + data inventory | +| Application log | No personal data and no secret | Test on the log content | + +--- + +## Dependencies and supply chain + +| Situation | Action | Verification | +|---|---|---| +| New dependency | Niche filter (`.nstack/handbook/06-decisions.md` §3) + declared in the manifest | Review: undeclared dependency (to automate) | +| Reported vulnerability | Handle it by severity and real exposure, not by score alone | Automated analysis in CI | +| Unmaintained dependency | Open a *Technical debt* issue with the exit strategy | Dependency review | + +--- + +## Exposure and abuse + +| Situation | Action | +|---|---| +| Expensive public endpoint | Rate limiting, from the first version | +| Sensitive operation | Auditable logging: who, what, when, from where | +| Error returned to the client | A generic message; the detail goes to the logs | +| Internal resource | Not exposed by default; exposing it is a decision | + +--- + +## High-risk actions + +Changing permissions, accessing secrets, a change touching authentication, exposing a +new service, an irreversible migration. + +**Mandatory procedure — never a silent execution:** + +``` +1. name the risk and its blast radius +2. describe the state before / after +3. propose the safe procedure and the rollback +4. ask for explicit confirmation +``` + +--- + +## Closing checklist + +- [ ] No secret added, in any form +- [ ] Authorisation tested by role **and** by ownership +- [ ] Input validated and sanitised, with negative tests +- [ ] Logs free of secrets and personal data +- [ ] Error messages uninformative to an attacker +- [ ] New dependencies declared and filtered +- [ ] High-risk actions explicitly confirmed +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.agents/skills/tests/SKILL.md b/.agents/skills/tests/SKILL.md new file mode 100644 index 0000000..7408b9b --- /dev/null +++ b/.agents/skills/tests/SKILL.md @@ -0,0 +1,218 @@ +--- +name: tests +description: 'The project''s test strategy: choosing the test level, writing the oracle, edge cases, doubles and handling flaky tests. Load this playbook when you are touching: a non-trivial test strategy, a flaky test.' +--- + + + +# Playbook — Tests + +> **Trigger.** Load this playbook when you are touching: a non-trivial test strategy, a +> flaky test. +> +> For an ordinary task the kernel rule is enough: **write the oracle, watch it fail, +> implement**. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/tests.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## 1. Choosing the test level + +```mermaid +flowchart TD + A["Behaviour to verify"] --> B{"Is it a pure
business rule?"} + B -->|Yes| U["UNIT TEST
fast, numerous, edge cases"] + B -->|No| C{"Does it cross a
module boundary?"} + + C -->|Yes| CT["CONTRACT TEST
on both sides"] + C -->|No| D{"Does it depend on
real infrastructure?"} + + D -->|Yes| I["INTEGRATION TEST
targeted, minimal scope"] + D -->|No| E{"Is it a critical
user journey?"} + + E -->|Yes| E2["E2E — only when
genuinely critical"] + E -->|No| U + + style U fill:#065f46,color:#fff + style CT fill:#065f46,color:#fff + style E2 fill:#7c2d12,color:#fff +``` + +**Legend** — green: the levels to prefer · red: the level to use sparingly. + +Preference rule: **the lowest level that actually verifies the behaviour**. An E2E test +that could have been a unit test costs a hundred times more, breaks ten times more +often, and diagnoses ten times worse. + +A scenario replayable end to end belongs in the module's `e2e` command, and its evidence in +`.evidence/`: CI keeps it for the test sheet (`.nstack/handbook/05-workflow.md` §7) — where checks are +attested, the verifier's evidence branch (`verification.md`, *Evidence*). + +**What the run said.** `nstack e2e` gives the run a folder of its own, `$NSTACK_EVIDENCE` +(`/.evidence/e2e/`), keeps there the command's output — a traceback included — and then +reads the log files the run wrote there: + +- **Write there** the module's logs (`.log`, `.jsonl`) and screenshots; data that are not logs — + recordings, events — elsewhere. A page's uncaught errors and console errors reach a log there: + logged by the page itself through the application, or collected by a script the scenario + injects (`window.onerror`, `unhandledrejection`) — some drivers expose no console. +- **The audit** reads each line's level — JSON keys, `level=`, a level word leading the line, or + the module's `evidence.levels` expression. A warning or an error the module did not declare is + quoted with `file:line` and the declaration that would accept it: an error fails the run, a + warning fails from criticality `high` and is reported below. The first NapkinStack version that + brings the audit only reports; the project's next minor version judges. +- **Declare** what the scenarios provoke on purpose, in the manifest — a pattern, its level, the + scenario that provokes it (M12). The manifest is the one place the audit reads: a warning or + an error a scenario provokes is declared there, even when the scenario asserts it too. A module + that declares lines and whose run wrote no log into `$NSTACK_EVIDENCE` fails when judged — they + were checked against nothing. +- **Not run here.** A run that cannot run on this machine — no desktop, no sound server — says + why on its output and exits 77, the code Automake and Meson read as a skipped test: the run is + recorded *not run here*, what it logged is shown and nothing judged, and it passes. Exit 0 means + it ran; 77 for any other reason — some tools use it for a refused permission — reads as *not + run*, so a run that fails exits with another code. + +- **One run at a time, unless sealed.** What an end-to-end run drives — a sound server, a + display, a port — is the machine's, so `nstack e2e` runs one at a time on a machine, and a run + that waits says for whom, every minute. A module whose run shares nothing with another run + declares `evidence.sealed: true`: its run neither waits nor holds the machine. Declare it only + when each of these is true — two runs that share one of them see each other's state, and fail + for no reason of their own: + + | Not shared | How to check | + |---|---| + | Session and devices: display, sound server, session bus | its run starts them, headless, and passes their address to what it drives (`DISPLAY`, `PULSE_SERVER`, `DBUS_SESSION_BUS_ADDRESS` from `dbus-run-session`) | + | Ports | each server binds port 0 itself and reports the port it got; never a fixed number, nor one picked and released before the server binds it | + | Files: build output, temporary files, sockets, state, configuration | everything it writes goes under a folder of its own run — the build tool's output folder set per run (`CARGO_TARGET_DIR`, not `build-dir`), `TMPDIR`, `HOME` and `XDG_*_HOME` pointed there —, never a fixed path | + | Processes | its teardown stops what it started — a process group it created (`setsid`, `start_new_session`), or the PIDs it recorded for a daemon that detaches — never by name or executable path | + | Per-user kernel limits: file watchers (inotify instances and watches), process count | its run closes what it opens, and as many runs as the machine takes at once stay under the user's limits (`fs.inotify.max_user_instances`, `fs.inotify.max_user_watches`, `ulimit -u`, which counts threads too); a limit run out fails at once, naming it — no folder of its own run isolates these | + | Timings, whatever the load | it passes with the machine busy; a run that waits for a quiet machine is the opposite of sealed | + + The lock keeps unsealed runs apart, not sealed ones: a run that needs a quiet machine cannot get + one from the lock while sealed runs go beside it. + +```yaml +evidence: + provoked: + - pattern: "key refused" + level: warning + scenario: S3 + sealed: true # every row of the table above holds: runs beside any other +``` + +--- + +## 2. The oracle + +| Requirement | Why | +|---|---| +| Written **before** the implementation | Otherwise it is written to pass, not to verify | +| Watched **failing** first | A test never seen red may test nothing | +| Fails for the **right reason** | A compilation failure is not a test failure | +| Named after the **behaviour**, not the function | `refuses_an_order_without_stock`, not `test_create_order_2` | + +### When the oracle is impossible + +| Cause | Response | +|---|---| +| Subjective criterion | Restate it as an observable behaviour | +| Exploratory task | Requalify it as a *spike*: the deliverable is knowledge | +| Untestable area | Make it testable first, as a separate task | +| Vague need | Back to framing — it was not *Ready* | + +In every case: **do not generate while waiting.** + +--- + +## 3. What to test first + +``` +1. business rules 2. critical journeys 3. permissions +4. contracts 5. errors 6. edge cases +7. regressions that happened 8. high user impact +``` + +**Every regression fixed gets a test** that failed before the fix. That is the only +guarantee it will not come back quietly. + +**Do not aim at a coverage percentage.** Coverage tells you what is not tested; it never +tells you that what is tested is tested well. + +--- + +## 4. Edge cases to consider every time + +``` +empty · null · absent · zero · negative · very large · very long +special characters · unicode · leading and trailing whitespace +duplicate · concurrency · repeated call (idempotence) +dependency unavailable · timeout · partial response +authorisation refused · not authenticated · session expired +time zone · daylight saving · deadline date +``` + +--- + +## 5. Flaky tests + +A flaky test is an **engineering problem**, never a fact of life. Its real cost: it +teaches the team to ignore a CI failure. A single tolerated flaky test degrades the +value of the whole suite. + +```mermaid +flowchart TD + A["Flaky test detected"] --> B["Isolate it: quarantine,
do not delete"] + B --> C{"Cause?"} + C -->|"Real time"| D1["Inject the clock"] + C -->|"Execution order"| D2["Isolate state between tests"] + C -->|"Concurrency"| D3["Synchronise on the event,
never on a duration"] + C -->|"Network / external"| D4["Deterministic double"] + C -->|"Shared state"| D5["Reset for every test"] + C -->|"Undetermined"| E["The test proves nothing:
rewrite it or delete it"] + + D1 --> F["Out of quarantine"] + D2 --> F + D3 --> F + D4 --> F + D5 --> F + + style E fill:#7c2d12,color:#fff + style F fill:#065f46,color:#fff +``` + +**Legend** — green: back to a trustworthy suite · red: the test is not worth keeping. + +**Never "re-run until it passes".** A disabled test carries an issue and a date to pick +it back up; without that, it never comes back. + +Fixed waits (`sleep`) are the most widespread cause of flakiness: wait for an +**observable state**, never for a duration. + +--- + +## 6. Doubles + +| Double | Do not double | +|---|---| +| External services, network, clock, randomness | The business logic of the module under test | +| Slow or expensive dependencies | What the test is meant to verify | +| Other modules — through their **contract** | The database, in an integration test | + +> **Never double another module's behaviour by guessing.** You double its contract, and +> the contract test guarantees the contract matches reality. An invented double goes +> green while production breaks. + +--- + +## 7. Warning signals + +| Signal | Reading | +|---|---| +| A test breaks at every refactor with no behaviour change | It tests the implementation, not the behaviour | +| You have to start another module to test | Bad boundary (`.nstack/handbook/02-modules.md` §9) | +| The test is longer than the code it tests | The code is probably too coupled | +| Nobody understands what this test tests | Delete it or rewrite it; it protects nothing | +| The suite takes more than 10 minutes | It will be bypassed — making it fast is a priority task | diff --git a/.agents/skills/ux/SKILL.md b/.agents/skills/ux/SKILL.md new file mode 100644 index 0000000..248911a --- /dev/null +++ b/.agents/skills/ux/SKILL.md @@ -0,0 +1,136 @@ +--- +name: ux +description: 'The project''s UX/UI rules: the primacy of convention and of the design system, the eight states of an interface, error messages, accessibility, perceived performance and mobile behaviour. Load this playbook when you are touching: a surface visible to the user.' +--- + + + +# Playbook — UX/UI + +> **Trigger.** Load this playbook when you are touching: a surface visible to the user. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/ux.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Entry rule: convention wins + +This is the ground where the Prior Art Gate (`.nstack/handbook/06-decisions.md`) pays off most. + +> For an interface pattern, the value of the convention comes **precisely from the fact +> that the user already knows it**. An unrequested interface innovation is a learning +> cost imposed on every user for the satisfaction of a single designer. + +Before designing a component or a journey: + +1. does the project's design system already cover it? → use it, done. +2. otherwise, what is the established convention for this problem? → adopt it. +3. departing from it requires a named, observable user value. + +**Never create a component that already exists in the design system.** It is the most +common form of wheel reinvention, and the most expensive to undo. + +--- + +## The eight states of an interface + +A feature is not finished if one of these states has not been handled. It is the number +one cause of the gap between "it works on my machine" and "it is usable". + +```mermaid +flowchart LR + A["1 · Empty
first use"] --> B["2 · Loading"] + B --> C["3 · Nominal"] + C --> D["4 · Partial
incomplete data"] + D --> E["5 · Error
recoverable"] + E --> F["6 · Error
blocking"] + F --> G["7 · Empty after
a filter or search"] + G --> H["8 · Too much data
pagination, truncation"] + + style A fill:#1f2937,color:#fff + style E fill:#7c2d12,color:#fff + style F fill:#7c2d12,color:#fff +``` + +**Legend** — dark grey: the state every user sees first · red: the error states. + +States 1, 7 and 8 are the most systematically forgotten. Yet state 1 is the one **every** +user sees first. + +--- + +## Error messages + +| Do | Avoid | +|---|---| +| Say what happened, in the user's language | Showing a technical code alone | +| Say **what to do next** | "An error has occurred" | +| Preserve what the user had typed | Clearing the form | +| Distinguish an input error from a system failure | Treating both the same way | +| Stay discreet about the technical detail | Exposing a trace or an exploitable detail | + +An error message with no possible action is a dead end: the user can only start again +identically. + +--- + +## Accessibility + +Not negotiable as soon as there is an interface. Minimum checks: + +| Point | Test | +|---|---| +| Full keyboard navigation | Go through the whole feature without a mouse | +| Focus visible at all times | Tab from end to end | +| Sufficient contrast | Automated check | +| Images and icons that carry meaning | Text alternative | +| Forms | Associated labels, errors tied to the field | +| Information never carried by colour alone | Visual check | +| Consistent heading structure | Document inspection | +| Large enough touch targets | Test on a real mobile device | +| Dynamic region | Change announced to screen readers | + +Whatever can be automated is automated in CI. **The rest is tested with the keyboard**, +in a few minutes — the best effort-to-detection ratio in the field. + +--- + +## Perceived performance + +What matters is the **felt** time, not the measured time. + +| Situation | Handling | +|---|---| +| Action expected to be instant | Immediate visual feedback, before the server even answers | +| Short wait | A discreet indicator, no full blocking | +| Long wait | Real progress, and a cancellable action where possible | +| Content arriving in pieces | Reserve the space to avoid layout shifts | +| Optimistic action | Plan the rollback explicitly in case of failure | + +--- + +## Responsive and mobile + +The development machine is not representative. + +- Check at a narrow width, not only in a resized browser. +- Test touch interactions: no hover as the only trigger. +- Check the behaviour with the virtual keyboard open. +- Check over a slow connection. + +--- + +## Closing checklist + +- [ ] The 8 states handled, or explicitly out of scope +- [ ] Convention or design system respected; every deviation justified +- [ ] Error messages actionable +- [ ] Full keyboard navigation, focus visible +- [ ] Contrasts checked +- [ ] Tested at a real mobile width +- [ ] Visual feedback on every action +- [ ] No component reinvented +- [ ] The test sheet covers the 8 states, or states which are out of scope (`verification.md`) +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.agents/skills/verification/SKILL.md b/.agents/skills/verification/SKILL.md new file mode 100644 index 0000000..818b384 --- /dev/null +++ b/.agents/skills/verification/SKILL.md @@ -0,0 +1,145 @@ +--- +name: verification +description: 'The project''s rules for verifying a change: the verifier''s posture, running a test sheet against the running change, the evidence expected for each result, and what to report. Load this playbook when you are touching: verifying a change you did not write, filling in a test sheet.' +--- + + + +# Playbook — Verification + +> **Trigger.** Load this playbook when you are touching: verifying a change you did not +> write, filling in a test sheet. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/verification.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Your posture + +You are the **verifier**. You did not write this change, and you do not fix it. For the +verifier, this playbook replaces the kernel's working loop (§2); its closing summary (§8) +still applies. + +| You do | You never do | +|---|---| +| Start from the need, the acceptance criteria and the test sheet | Read the diff before running the sheet | +| Run every scenario against the running change | Fix the code, even one line | +| Bring back evidence for every result | Write "passed" without evidence | +| Report the gaps against the need or against correctness | Report a preference as a gap | + +The session that wrote the change cannot verify it: start another session, with a fresh +context, or hand the sheet to a human. Sign the sheet with your session's identifier — +`Verifier: session ` — or, as a person, `Verifier: @`. CI compares it with the +change's authors and refuses a match; each person named must have written the sheet into the +description or reviewed or commented on the pull request, under their own account. Writing the +sheet starts the check again; a review or a comment is read at the next run, which any edit of the +description starts. + +### Your own ground + +You verify on someone's machine, beside work that goes on. Leave it as you found it. + +- **A copy of your own**: a working tree checked out at the head, and build outputs of your + own. Check out the pull request's branch, one tracking it, or the head detached: a record made + on a branch of another name is another pull request's (`.nstack/handbook/05-workflow.md` §7). A tree another session edits, or outputs another branch built, give results that are + not this change's. Where a sandbox keeps `.git` read-only, a worktree cannot be added: a + `git clone --shared ` checked out at the head is that copy, `` + and build outputs both under your own cache (`$XDG_CACHE_HOME`, which `nstack agent run -- + claude` sets — for Cargo, `CARGO_TARGET_DIR` there), never the system's temporary folder, which a quota shares with + everyone on the machine. Both are deleted when you leave. +- **The machine's shared state** — a default device, a setting, a service, data others read — + is touched only as the scenario needs, and is put back after each run, also on failure. + What another program holds — a user's own running copy of the product, their files — is + never touched. +- **What you start, you stop, by its process number** — never by a name or a pattern, which + also matches what is not yours. When you leave, nothing of yours is left running. +- **The description is fetched again just before you write it**: the author may have edited + it since you read it, and your edit must keep theirs. + +--- + +## The procedure + +1. **Read the need** — the deliverable, its acceptance criteria, the test sheet in the + pull request's description. Nothing else yet. +2. **Start the change** — the module's `run` verb, or the environment named in + `.nstack/tooling-profile.md`. A module with no `run` verb — a library, a contract — has + nothing to start: its scenarios run through its tests, and you say so in your report. +3. **Run each scenario**, in order: + - *automated* — the module's `e2e` verb, or its `test` verb when it declares no `e2e`; + the evidence is the CI run on the head commit, or its artefact — where checks are attested, + the evidence branch below — for a change to a + visible surface, read the run's screenshots and logs (`.evidence/e2e/`, its `audit.json`) + and cite what they showed: never "rendering not seen" on a scenario passed. An audit + `not run` (exit 77) ran no scenario: each one it stood for is *not verified*, or run where + it can run; + - *explored* — drive the interface yourself, in a browser, an emulator or on a device, + with the tools of the tooling profile; capture the screen at the step that proves the + result; + - *human only* — do not run it; check that its reason is stated and, when the + deliverable's acceptance rests on it, that an acceptance issue asks it of a person. +4. **Record** each result in the sheet — `passed`, `failed — `, or + `not verified` — with its evidence and the short hash of the commit you tested; a `|` in a cell, + in a code span too, is written `\|`. What you + have to add goes on the line **`Verifier's remarks:`** under the table, never in a cell: a + scenario that passed by your own probe and not by the test it cites, a wording that claims + more than was exercised. A remark is not a result, and the approver reads it. After a + fix, an *automated* scenario is run again at the head and its Commit cell takes the head — + it is never confirmed; an *explored* one keeps its commit and is confirmed in + the `Confirmed` column with the head commit and what moved since — after a `;` when the cell holds an + earlier confirmation; at criticality + `critical`, every scenario is run again (`.nstack/handbook/05-workflow.md` §7). +5. **Only then read the diff**, to explain a failure — never to decide a result — and ask one + question of its tests: **is the entry point a real user calls exercised the way they call + it?** A suite that always passes what the user never passes is green on a path nobody takes. +6. **Report** the failures first — observed, expected, evidence — then any optional + remark, marked as such. + +### Mutants + +To show that a test pins what it claims, change the code it claims to pin and watch it fail — a +mutant. A mutant can make the code loop forever, so it is never run unbounded: + +- **The language's tool first**, rather than a loop of your own: `cargo-mutants` (Rust; `--file` + to aim it, `--timeout` to bound it), `mutmut` (Python), Stryker (JavaScript, TypeScript, C#, + Scala), PIT (Java). +- **By hand**, one mutant per run, each run under a time limit — `timeout 120 `; a timeout counts as killed: the mutant changed what the code does. +- **The source restored on every exit**, not only at the end — `trap 'git checkout -- ' + EXIT`, or mutate in a throwaway copy of your own (above). +- **Report the counts** — killed, survived, timed out — and each survivor with its line: a + survivor is a test that does not pin what it claims. + +--- + +## Evidence + +| Scenario | Evidence expected | +|---|---| +| An interface | A screenshot of the state that proves the result; a video for a sequence | +| A mobile interface | The screenshot of the emulator or the device, with its width or model | +| An API, a job, data | The command and its output, or the log lines | +| Accessibility | The keyboard path followed, and the automated report when there is one | + +Test data only: never a real user's data, never a secret on a screenshot (`security.md`). +Evidence lives where the whole team sees it — a CI artefact, or an image attached to the +pull request. **Where checks are attested**, no CI run keeps an artefact, and an agent's identity +cannot attach an image through the forge's API: the verifier commits the screenshots and videos +that prove a criterion on a branch of its own, `evidence/`, never on the change's +branch — its head stays the one verified (T4), and the verifier writes no commit of the change +(T2) — and links each file from the sheet at that branch's commit. Made-up data only, each file +read before it is pushed: a public repository keeps it for good, and no secret scanner reads an +image (`security.md`). The `check-added-large-files` hook bounds each file as it is committed; +the branch is deleted once the cycle is closed. + +A user-facing change covers the eight states of an interface (`ux.md`), or says which are +out of scope. A state missing from the sheet is a gap to report. + +--- + +## When the sheet itself is wrong + +A scenario that does not match the need, or a need no scenario covers: report it. An +expected result changes only with the decider's agreement, visibly in the sheet's history. diff --git a/.claude/skills/data-migration/SKILL.md b/.claude/skills/data-migration/SKILL.md new file mode 100644 index 0000000..07483cf --- /dev/null +++ b/.claude/skills/data-migration/SKILL.md @@ -0,0 +1,132 @@ +--- +name: data-migration +description: 'The project''s rules on data and migrations: schema expand/contract, backfill, data deletion, data ownership by module. Load this playbook when you are touching: a data schema, a migration, existing data.' +--- + + + +# Playbook — Data and migrations + +> **Trigger.** Load this playbook when you are touching: a data schema, a migration, +> existing data. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/data-migration.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| DM1 | **A migration is a production change**, not a code change. It falls under high-risk actions (kernel §5). | +| DM2 | **Each module owns its data.** No direct access to another module's database — you go through its contract. | +| DM3 | **Never rename or delete in place.** You add, you let both coexist, you migrate, you remove. | +| DM4 | **Every migration has a rollback plan**, or a written justification for not having one. | +| DM5 | **Never run a destructive migration without explicit confirmation.** | + +--- + +## 1. Expand / Contract applied to the schema + +The same logic as contracts (`.nstack/handbook/03-contracts.md`), for the same reason: the old and +the new code coexist during the deployment. + +```mermaid +flowchart TD + A["Need: rename a field
or change its type"] --> B["1 · EXPAND the schema
add the new field,
nullable, touching nothing"] + B --> C["2 · Double write
the code writes both"] + C --> D["3 · Backfill
fill in the existing rows,
in batches, idempotent, resumable"] + D --> E["4 · Switch reads
the code reads the new field"] + E --> F{"Stable in
production?"} + F -->|No| E2["Read from the
old field again"] --> D + F -->|Yes| G["5 · Stop writing
the old field"] + G --> H["6 · CONTRACT
drop the old field"] + + style B fill:#065f46,color:#fff + style D fill:#1f2937,color:#fff + style H fill:#7c2d12,color:#fff +``` + +**Legend** — green: the additive step, always safe · dark grey: the operational step · +red: the irreversible step, the one that gets forgotten. + +Each step is **a pull request deployable on its own**. At no point is the system in a +state where a rollback would break the data. + +Step 6 is the most forgotten. It carries a date and an owner, in a *Technical debt* +issue: no check reads a schema's dates, so the contraction is the project's to track. + +--- + +## 2. Before any migration + +| Question | If the answer is missing | +|---|---| +| How many rows are affected? | Measure before writing the migration | +| Does it lock a table? For how long? | Test on a representative volume | +| Does the old code still work afterwards? | It must, during the deployment | +| Does the new code work beforehand? | Same, the other way round | +| What happens to non-conforming data? | Count it, decide explicitly | +| How do you roll back? | Write the plan, or justify its absence | +| How will you know it went well? | Define the verification before starting | + +--- + +## 3. Backfill + +A backfill over a large volume is an operational procedure, not a script. + +- **In batches**, with a pause between batches — never process everything at once. +- **Idempotent**: re-runnable with no side effect. +- **Resumable**: remembers its progress, survives an interruption. +- **Observable**: progress, errors, estimated duration. +- **Interruptible**: it must be possible to stop it without corrupting the state. +- **Measured beforehand**: row count, estimated duration, impact on load. + +--- + +## 4. Deleting data + +This is irreversible. Mandatory procedure: + +``` +1. count exactly what will be deleted +2. check the selection criterion against a sample +3. back up or archive what is being deleted +4. run in dry-run mode first +5. ask for explicit confirmation, with the exact count +6. delete in batches, with a stopping point +7. verify afterwards +``` + +A deletion triggered by a retention rule is a product decision: it belongs to a PDR, not +to a technical task. + +--- + +## 5. Data ownership + +Implicit data sharing is the hardest form of coupling to undo, because it is invisible +in the code. + +| Situation | Handling | +|---|---| +| A module reads another's table | A violation — detected by a fitness function | +| Database shared between two modules | ADR required, with explicit ownership per table | +| Data duplicated across modules | Acceptable when a source of truth is designated and the synchronisation is contractual | +| A join across domains is needed | A signal of a bad boundary — do not work around it with direct access | + +--- + +## 6. Closing checklist + +- [ ] Migration tested on a representative volume +- [ ] Old and new code both work during the transition +- [ ] Backfill in batches, idempotent, resumable +- [ ] Rollback plan written, or its absence justified +- [ ] Post-migration verification defined **before** the run +- [ ] Contraction step planned, with a date and an owner +- [ ] Destructive action explicitly confirmed, with the exact count +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.claude/skills/discovery/SKILL.md b/.claude/skills/discovery/SKILL.md new file mode 100644 index 0000000..74757ee --- /dev/null +++ b/.claude/skills/discovery/SKILL.md @@ -0,0 +1,135 @@ +--- +name: discovery +description: 'The project''s discovery rules: turning an idea into a decision — intake, sourced market research, definition, the value hypothesis and no-gos, a challenge by another session (pre-mortem, four risks), then go, clarify or kill. Load this playbook when you are touching: an idea to test, a discovery to challenge or decide.' +--- + + + +# Playbook — Discovery + +> **Trigger.** Load this playbook when you are touching: an idea to test, a discovery to +> challenge or decide. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/discovery.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Your posture + +You run stages 1 to 4 as the **framer**, stage 5 only as the **challenger** — never both in +the same session. The decider decides, at stage 6. For the framer and the challenger, this +playbook replaces the kernel's working loop (§2); its closing summary (§8) still applies. + +| You do | You never do | +|---|---| +| Framer: ask one question at a time, only what you cannot infer | Agree to please; soften an objection | +| Give every market fact its source | State a fact you cannot source — write it as an assumption | +| Keep the document to what could change the decision | Fill a canvas, size a market, invent personas | +| End each round with a decision | Open a new direction before the round is decided | + +The engine's `discover` command created `docs/project/discovery.md`: one section per stage, +each ending with its open questions. When the decider cannot answer now, write the question +there — most decision-changing first — and go on; never answer it in their place. + +--- + +## 1. Intake + +Read the idea file entirely. Restate the idea in one paragraph — for whom, where, which +problem, what the product does — and ask the decider to correct it. Record the decider in +the front matter. Until the decider confirms the paragraph, mark it *unconfirmed*: the round +cannot be decided while it is. + +Ask, once, **in which language the project writes** — its documents, its code, its commit +messages. The idea file may be in one language and the framework's forms in another; nobody +notices until half the documents are in each. The answer is the project's first rule: one +line of `docs/project/rules/always.md`, written now, with the idea file left as it was given. + +Ask, once, **what has already been asked of, promised to, or received from someone outside the +team** — a client, a vendor, a partner — by mail, chat or meeting. A fresh session remembers none +of it, and an outside party asked twice, or asked differently, pays for it in patience. Each answer +is an entry of the project's log issue, opened now if there is none (`.nstack/handbook/06-decisions.md` +§9): who, what, when, by which channel — never a secret or a credential, and nothing the outside +party would not have public in a public repository's issue (`security.md`). + +## 2. Research + +With the research tools of `.nstack/tooling-profile.md` — or, when that row is empty, the tools +at hand, named in the document — look for: + +- what users do today instead, including nothing; +- the direct and indirect alternatives, their positioning and their price; +- the business models of the field; +- the legal and regulatory constraints, for the countries concerned. + +Each finding goes in the evidence table, with what it changes for the idea and its source. +Prefer the primary source; mark figures a company reports about itself, and claims seen only +in a search excerpt. A claim without a source goes to *Assumptions*. Stop when each of the +four points has at least one sourced finding, or an explicit "not found". + +**A legal or regulatory claim is read at its primary source — the text itself, the +regulator's page — or it is an assumption.** A summary of a law by someone who sells a +product under it is not a source, and a rule the design will rest on is the last thing to +take second-hand: say "not read" rather than mark it as seen elsewhere. + +## 3. Define + +With the decider: the users; their problem — quoted from users, saying who and how many, +since words reported by the decider alone are an assumption; the constraints — who runs it, +budget, platforms, regulation; and the success signals — what will be observed, and by when, +if the idea is right. If this stage changes the users or the model, revisit stage 2. + +## 4. Shape + +- **The value hypothesis** — why a user would switch from what they do today, in one or two + sentences, stated so that it can be proven wrong. Not a list of features. +- **A short press release**, dated launch day — a placeholder if none is set: the user, the + problem, the product, one quote, labelled as imagined. Record whether it convinces the + decider; if it does not, that is a finding. +- **No-gos** — what the product deliberately will not do: the decider's, and any the framer + proposes, marked *proposed*. + +## 5. Challenge — in another session + +A session that did not write stages 1 to 4, or a human; it starts once section 1 is +confirmed — otherwise it names the reading it challenges. The challenger does not interview +the decider: its questions go into its objections. It reads the idea file and the document, +then: + +1. **Pre-mortem** — the product launched a year ago and failed: the plausible reasons, each + tagged with its risk. +2. **The four risks** — *value*: will they use it, or buy it? *usability*: can they use it? + *feasibility*: can it be built with the means at hand? *viability*: does it hold for the + business — cost, law, operations? For each, the riskiest assumption and the cheapest test + that could refute it: what is done, for how long, and the result that refutes it — a + threshold proposed, for the decider to set. +3. **Counter-evidence** — what contradicts the value hypothesis or the riskiest assumptions: + failed products, closed competitors, regulatory refusals. Research as in stage 2 — same + tools, same marking, the same stopping rule; an unsourced claim is marked *assumption*. +4. **Flaws in stages 1 to 4** — each citing the line it objects to. + +These are the objections, written in section 5 with the challenger's name and date. Never +rewrite stages 1 to 4. + +## 6. Decide + +A framer session presents section 5 unchanged, then the riskiest assumptions and the value +hypothesis. The decider chooses: + +| Decision | What follows | +|---|---| +| **go** | The pull request that records the decision writes the front page's sentence (`README.md`) — what the product does, for whom, as the decider confirmed it — and nothing else of that page. The framing then writes the charter from this document (`framing.md`); the tests the decider keeps become spike deliverables of the first cycle | +| **clarify** | A new round on the open questions, and on the cheap tests the decider picks before any charter; `round` goes up, section 5 is kept under its round, and the changed sections are challenged again | +| **kill** | The document stays, with its reasons — the cheapest outcome of all | + +Section 6 records the reasons, and for a go, why each objection does not block it. Record +`decision` and `decided_on` in the front matter, then run the fitness functions. + +--- + +## Bounds + +A round is one or two working sessions. A second `clarify` is the decider's explicit choice, +recorded in section 6 — never a default. diff --git a/.claude/skills/documentation/SKILL.md b/.claude/skills/documentation/SKILL.md new file mode 100644 index 0000000..2f74950 --- /dev/null +++ b/.claude/skills/documentation/SKILL.md @@ -0,0 +1,94 @@ +--- +name: documentation +description: 'The project''s rules for writing a document: a diagram with its legend first, a few lines after it, a source for every outside claim, a date on every decision, and documents kept current or deleted. Load this playbook when you are touching: a document a human will read, a pull request''s description included: writing or changing one.' +--- + + + +# Playbook — Documentation + +> **Trigger.** Load this playbook when you are touching: a document a human will read, a +> pull request's description included: writing or changing one. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/documentation.md` +> — read them with this playbook. They add to it or tighten it. + +```mermaid +flowchart LR + Q{"Is there a structure,
a flow or a state
to show?"}:::ask + Q -->|yes| D["A diagram
with its legend"]:::first + Q -->|no| T["A table,
or three lines"]:::first + D --> L["A few lines:
what the diagram
cannot say"]:::then + T --> L + L --> S["Sources and dates"]:::then + S --> C{"Still true
after this change?"}:::ask + C -->|no| U["Bring it current
or delete it"]:::stop + + classDef ask fill:#374151,color:#fff + classDef first fill:#065f46,color:#fff + classDef then fill:#1e3a8a,color:#fff + classDef stop fill:#7c2d12,color:#fff +``` + +**Legend** — grey: what you ask yourself · green: what the reader sees first · blue: what +follows it · red: the document that no longer says what is true. + +--- + +## The standard — five rules, and no content + +1. **Shape first**: a diagram with its legend before the prose, wherever there is a structure, + a flow or a state to show. A reader who stops after the diagram has understood. +2. **A source for every claim about the outside world** — a market, a law, a tool's + behaviour, a number. +3. **A date on every decision**, and on every criterion that will judge it. +4. **Current, or deleted.** A stale page costs more than a missing one, because it is + believed. +5. **A fact has one home.** Its home is the file a check or a command reads — a module's + manifest for its responsibility, owner and criticality; the cycle for a deliverable's criteria, and its state once the cycle is closed — during it, the + hold and the delivery record, which `nstack plan` reads; + the charter for the decider. Every other document that needs the fact links to it, never + copies it: two copies agree on the day they are written, and only on that day. + +The framework asks for this form and writes none of the content: what the document says is +the project's. + +--- + +## Drawing the diagram + +| Situation | Action | Verification | +|---|---|---| +| Parts and what links them: modules, users, systems | Boxes and arrows, a dozen boxes at most | Someone reading the diagram alone can say what the document is about | +| Things that happen in an order | A sequence, left to right or top to bottom | Every step has one way in | +| Something that changes state | The states and what moves it from one to the next | No state is a dead end unless it is meant to be | +| A choice between paths | A decision tree, the question in the node | Every branch ends on an action | +| A colour or a shape is used | It means one thing, and the legend under the diagram says which | The legend names every colour used, and nothing else | +| The diagram is ready | Written as text in the file, in the notation the tooling profile names — never an image. A drawing of a screen is no diagram: it is an image, frozen (`framing.md` §2) | The pull request shows what changed in it | +| Nothing to show: one fact, a list, a comparison | No diagram. A table, or three lines | A diagram that decorates is removed | +| More than a dozen boxes | Two diagrams, one idea each | Each has its own legend | + +## After the diagram + +- **Say what the diagram cannot**: the why, the exception, the number. Never describe the + diagram in words. +- **A table for anything a reader will compare**; a list for anything they will tick. +- **The point first.** A reader who must scroll to find what was decided has been given a + story instead of a document. +- **Short.** A paragraph a reader skips is a paragraph to delete. + +## Which document, and when + +Each document of a project has the event that makes it writable; before it, its form stays +a form. The table is `.nstack/handbook/06-decisions.md` §10 — read that one section before writing a +document the project does not hold yet, and never fill a form with what nobody has decided. + +--- + +## Closing checklist + +- [ ] The diagram comes first, with its legend — or there is nothing to draw, and no diagram +- [ ] Every claim about the outside world names its source +- [ ] Every decision and every criterion carries its date +- [ ] Every document this change makes untrue is brought current in the same pull request diff --git a/.claude/skills/framing/SKILL.md b/.claude/skills/framing/SKILL.md new file mode 100644 index 0000000..8067410 --- /dev/null +++ b/.claude/skills/framing/SKILL.md @@ -0,0 +1,227 @@ +--- +name: framing +description: 'The project''s framing rules: interviewing the decider, writing the charter, planning a bounded cycle with its deliverables, acceptance criteria and appetite, handling new ideas, and closing a cycle at its end or at its circuit breaker. Load this playbook when you are touching: framing a project, planning or closing a cycle.' +--- + + + +# Playbook — Framing + +> **Trigger.** Load this playbook when you are touching: framing a project, planning or +> closing a cycle. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/framing.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## When framing is worth it + +A project is **unframed** until its charter is accepted: a stage, not a fault. Every rule +judges its changes except the three that bound work inside a cycle. Framing buys an +appetite, an end date, a circuit breaker and a decider — worth their price **when there is +something to bound**: several people, a deadline, a decider who is not the one typing. Say +so when you are asked to frame a project where none of the three is true; then frame it if +the decider still wants it. Never frame to make a check pass: no check asks for it. + +## Your posture + +You are the **framer**. You propose; the decider decides. For the framer, this playbook +replaces the kernel's working loop (§2); its closing summary (§8) still applies. + +| You do | You never do | +|---|---| +| Interview the decider, one subject at a time | Decide in their place, or fill a gap with an invention | +| Propose the field's convention by default, marked *(framer, to confirm)* with its source | Propose more than the need | +| List the open questions, blocking apart | Let a charter or a cycle be accepted with a blocking question open | +| Keep the first cycle small | Split into many modules on day one (`.nstack/handbook/02-modules.md` §3) | + +A proposal without a source is an open question, not a proposal. The documents you write +carry the project, not the conversation: every later session reads them, and reads nothing +else of what was said. + +--- + +## 1. Frame the project: the charter + +Start from what the decider gives you. When `docs/project/discovery.md` exists, its decision +must be **go**: the charter reuses its users, problem, constraints, success signals, no-gos +and risks, carries its unanswered questions into its own, and you ask only what it leaves +open. Otherwise — an idea alone — propose a discovery first (`discovery.md`); a specification +already challenged can be framed directly. Read the source entirely, then interview, one +subject at a time, asking only what you cannot infer: + +| Subject | Ask | The charter records | +|---|---|---| +| Users | Who uses it, in what situation, with what problem? | The users and their problem | +| Outcome | What must be true for the project to be finished? | Success criteria, measurable, dated — or relative to a named event, such as launch day, that a later framing dates | +| Constraints | Law, money, security, data, platforms, deadlines | The constraints | +| Risks | What could make it fail, or cause harm? | The risks, and the criticality they imply — what a failure of each module would cost, which the decider settles and `.nstack/handbook/05-workflow.md` §7 prices | +| Vocabulary | The domain's words, and what each one means | The vocabulary | +| Not this project | What it will deliberately not do | Out of scope | +| Outside the team | What has already been asked of, promised to, or received from someone outside the team — a client, a vendor, a partner — by any channel? When the discovery asked it, only what changed since; otherwise, in full | Nothing in the charter: each answer is an entry of the project's log issue (`06-decisions.md` §9) | + +A domain that moves money, handles personal data or acts on someone's behalf raises the +criticality of the modules concerned, and `security.md` applies from the first cycle — to +the code, and to the data a spike collects: who sees it, how long it is kept. Say so to the +decider. + +**Before proposing a criticality, read the rule** — the last paragraph of +`.nstack/handbook/05-workflow.md` §7: a module that holds a key, places an order, moves money or +touches someone's personal data is `critical`. Propose what the rule says, with what each +value costs; a lower value is the decider's to choose, and is written as a deviation with its +reason and the event that ends it. + +When no discovery came first, ask too **in which language the project writes**; the answer is +its first rule (`docs/project/rules/always.md`). + +**A constraint that binds how the work is done becomes a rule of the project**, proposed +with the charter: one line of `docs/project/rules/.md`, from +`.nstack/forms/rules.md` — the subject is the playbook it completes, `always` when +it applies to every task. It names its source in the charter and how it is checked. Never +write it into a playbook or the kernel: those are every project's, and the next update +would conflict on it. + +Write `docs/project/charter.md` from `.nstack/forms/charter.md`, with +`status: proposed` and the open questions at the end, then run the fitness functions. +"Finished" means the charter's goal is reached: framing stops; running what was built may go +on. + +## 2. Plan a cycle + +1. **Goal** — one sentence, the one outcome of this cycle. +2. **Deliverables** — a finite list, `D1`, `D2`…, each an outcome a user can observe — for a + spike, the question it answers for the decider. Each gets acceptance criteria, written + *given · when · then*; they become its test sheet (`verification.md`). + + **Two questions to ask of each one, before writing its criteria:** + - *Can the team finish it alone, inside this cycle?* If it waits on someone outside the + project — a reply, an opinion, a decision elsewhere — it is a **dependency with a date**, + not a deliverable. Name it in the risks and give it a date; the cycle does not hold it. + - *Is its product knowledge rather than code?* Then it is a **spike**, and its criteria say + **what will be recorded** and **the threshold it is read against** — never that the answer + comes out a particular way. **A refuted result is a delivered one.** "Five people were + asked, one acted, below the threshold of two" closes the deliverable; it does not fail it. + When its product is a **drawing** — the screens, the journey the user will see — the + drawing is committed under `docs/project/drawings/-/` with its date, + and frozen: what the decider accepts in it becomes criteria of the deliverable that + builds it, and once built, the product and its screenshots are the truth. A new round is + a new folder, never an update. + + A criterion nobody can meet is not met. It is answered with something that looks like proof, + and that answer is reviewed and merged like the rest. +3. **Unknowns** — a blocking unknown becomes a *spike* deliverable, whose output is + knowledge (`.nstack/handbook/05-workflow.md` §3). After a discovery's go, the tests the decider kept + are the first cycle's spikes. +4. **Modules** — name each deliverable's module; a spike run outside the code — a sign-up + form, interviews, a measure whose product is a record and not shipped code, even about one + module — has none (`module: null`): no merge carries it, so `nstack deliver` has nothing to read. Propose a new module only against the tree of + `.nstack/handbook/02-modules.md` §3: one module is often enough to start. +5. **Appetite** — ask the decider how many weeks they **want** to spend, not how long it + will take — in days for a cycle shorter than a week, such as an engagement whose date an outside + party sets (`appetite_days`), never rounded up to a week nobody agreed to. When the deliverables + do not fit, cut the scope; never stretch the appetite. +6. **Out of scope and later** — out of scope is not done even if time remains; *later* holds + the candidates for the next framing. + +Write `docs/project/cycles/NN-.md` from `.nstack/forms/cycle.md`, with +`status: proposed` and `end` = `start` + the appetite, then run the fitness functions. + +## 3. Hand over to the decider + +A cycle's *What needs a person* holds what only a person can do, each with its literal gesture: fill it +while framing, and keep it true. It is what `nstack plan` opens with. A request to someone outside +the team starts from the log issue's entries, and from the decider's answer to what has been asked, +promised or received outside since the last one — every cycle, not only the first: nothing already +asked is asked again, nothing is asked more broadly than before without saying why, and each new +request becomes an entry. One still awaiting a reply that a deliverable needs is a dependency with a date. + +Present the charter, the cycle, the open questions, what went to *later*, and what you are +unsure of — the cycle also as the board will show it: `nstack board --dry-run` previews the +milestone and the issues its acceptance would create, and what it would collide with, and makes +none; put the lines under *On acceptance of cycle …* in the framing pull request's description. The decider amends; the framer sets `status: accepted` — on the charter, then on the +cycle — in a pull request the decider approves, and that approval is their gesture; accepted after `start`, the cycle's `start` and `end` +move in the same pull request. **The next cycle, accepted while one runs**, stays `proposed` — one +accepted cycle at a time (C5) — and gains `accepted_on: `: `nstack plan` stops asking +for it while that cycle runs, and the running cycle's closure starts it (§5). The modules accepted there are created with the engine's +module scaffolding, declared user-facing when a user sees them. + +**Where the project's own rules waive approval** — an agent merging alone on an attested, +verified head, `doctor`'s G2 taken knowingly — nobody approves that pull request, and the +decider's word stands for the approval: quoted in the page it accepts (the charter, the cycle), +with its date and where it was said — a comment, a message, a meeting's note. The same holds +for a deliverable accepted below. Without that line, the acceptance is the agent's alone. + +**The pull request that accepts the charter writes the project's front page from it** — +`README.md`: a diagram of who uses the product and what it talks to, how to run what exists, +and the sentence when no discovery wrote it. Until then that page holds its sentence at most; +from then on the plan check refuses an accepted charter over a form left as it came +(`.nstack/handbook/06-decisions.md` §10, `documentation.md`). + +## 4. During the cycle + +- **A new idea** goes to *later*. It enters the cycle only if the decider re-frames: + swapping a deliverable out, adding one they judge fits what is left of the appetite — + the end date does not move — or closing the cycle early. An added deliverable takes its + criteria like the others, and its section says on whose word and on what it entered. +- **An urgent fix** outside the cycle — an incident, a production defect — goes in a pull + request with the `out-of-cycle` label and the line `Out of cycle: `. +- **A deliverable's state** is written in the cycle file at framing (`proposed`, then `ready`: + testable criteria, set by the framer, confirmed when the decider accepts the cycle), on a + re-framing (`deferred`, `dropped`), and at the closure (`accepted`, by + `nstack deliver --write-states`) — never during delivery, and never in a delivery's pull request. + In between, `nstack plan` reads it: *held* from its claim, *delivered* from its record + (`nstack deliver D --held '#'`, kernel §2 step 12, `.nstack/handbook/project.md`); + it asks the decider nothing. It is accepted when each of its criteria is held by a scenario of a merged sheet, or by an + answer in the acceptance issue the cycle names beside the state (`.nstack/handbook/05-workflow.md` + §7); a criterion only a person can try waits for that answer. A spike outside the code is held + by a decision record when it binds the project (*Decisions* below), otherwise by a line of the + log issue it was run under — the project's, or its module's —, which its section links: with no merge it has no record, and the closure + writes its `accepted` by hand beside the states `--write-states` wrote, citing that line. Where + approval is waived (§3), the decider's word is quoted once, at the closure, for the cycle. A rule + sees that a merge exists, not that a criterion holds: the closure reads the records before it + writes. + +## 5. The end of a cycle + +**Every deliverable delivered or accepted** — `nstack deliver --write-states`, and `nstack plan --prune` for the empty start branches a deferred deliverable left, then write the closure: what was delivered, which success +criteria moved, what was deferred, and **which documents the cycle brought current** — the +front page and the module map first, each with its pull request; set `status: closed`, +`outcome: completed`, `ended_on`. A next cycle carrying `accepted_on` is set `status: accepted` in the +same pull request; its `start` becomes the closure's day when it is not, and its `end` follows the appetite. +A success criterion the decider says moved is recorded under `success:` in the front matter, at +any closure — by its number in the charter, `met`, or `observing` with the day observation +started; the latest record is its state, and `nstack plan` counts the criteria met. +When a spike refutes what the charter rests on, present stopping the project too. + +**The end date reached first** — the circuit breaker: nothing is extended. Present the +three choices, with the state of every deliverable. Whichever is chosen, `nstack deliver --write-states` comes +first, while the cycle is still accepted: it is what brings the records into the cycle file. + +| The decider chooses | `status` | `outcome` | +|---|---|---| +| Ship what is delivered or accepted | `closed` | `shipped` | +| Frame a new cycle, with a new appetite | `stopped` | `reframed` | +| Stop the project | `stopped` | `stopped` | + +A next cycle carrying `accepted_on` starts here only on `shipped`, as on a completed closure. On `reframed` or +`stopped`, the word was given for another situation: it stays `proposed`, and `nstack plan` asks the decider again. + +The closure is where the next framing starts. When `nstack plan` says the charter's goal is +reached — every success criterion met —, present it: the decider says whether the project is +finished. + +## Decisions + +A decision lives in a record, never in the charter, the cycle or a conversation +(`.nstack/handbook/06-decisions.md`): one register of each kind at the project's root — +`docs/pdr/` for the product, `docs/adr/` for the technique — and `Scope: module ` when it +concerns one module. + +| When | Then | +|---|---| +| An accepted charter has to change — a constraint, a user, what the project is not | A **PDR** first, which the change cites; the charter is never rewritten in place (CI warns, C9) | +| The framing chooses a module, a stack, a contract | An **ADR**: the module's creation decision is one | +| A spike's result binds the project | A PDR or an ADR; otherwise a line in the project's log issue | +| A cycle's **closure** | Read every decision the plan names as due (C10): its criterion names this cycle, or a date in bold, `**YYYY-MM-DD**`, its end reached. The record gains one line under its criterion, *Read at 's closure, : met \| missed \| superseded*, and nothing else; a *missed* one is the decider's to answer, by a new record or the removal condition | diff --git a/.claude/skills/operations/SKILL.md b/.claude/skills/operations/SKILL.md new file mode 100644 index 0000000..5c13a96 --- /dev/null +++ b/.claude/skills/operations/SKILL.md @@ -0,0 +1,184 @@ +--- +name: operations +description: 'The project''s operations and reliability rules: timeouts, retries, structured logs, metrics, alerts, health checks, rollback and controlled degradation. Load this playbook when you are touching: logs, metrics, alerts, retries, timeouts, rollback, a deployment, a call to another system.' +--- + + + +# Playbook — Operations and reliability + +> **Trigger.** Load this playbook when you are touching: logs, metrics, alerts, retries, +> timeouts, rollback, a deployment, a call to another system. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/operations.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| OPS1 | **Never an automatic retry without analysing the side effects.** | +| OPS2 | **Every external call has an explicit timeout.** A call without one is an outage waiting to happen. | +| OPS3 | **No secret and no personal data in the logs.** | +| OPS4 | **An error quietly swallowed is a future incident.** | +| OPS5 | **A module in production with no way of knowing it is unwell is not ready.** | + +--- + +## 1. Retries — the classic trap + +```mermaid +flowchart TD + A["Considering a retry"] --> B{"Is the operation
idempotent?"} + B -->|No| C["DO NOT RETRY.
Make it idempotent first,
with an idempotency key"] + B -->|Yes| D{"Is the error
transient?"} + + D -->|"No: 4xx, validation,
authorisation"| E["DO NOT RETRY.
The result will be identical."] + D -->|"Yes: network, 5xx,
timeout"| F{"Exponential backoff
with jitter?"} + + F -->|No| G["DO NOT RETRY.
A synchronised retry turns
a local incident into a global outage"] + F -->|Yes| H{"Maximum count
and total budget
defined?"} + + H -->|No| G + H -->|Yes| I["Retry acceptable,
with a metric on the retry rate"] + + style C fill:#7c2d12,color:#fff + style E fill:#7c2d12,color:#fff + style G fill:#7c2d12,color:#fff + style I fill:#065f46,color:#fff +``` + +**Legend** — red: do not retry, and why · green: the only branch where a retry is safe. + +Three side effects to check every time: + +- **Duplication** — a retry on a non-idempotent operation applies the effect twice. +- **Amplification** — N clients retrying at the same time multiply the load on a service + already in trouble. +- **Masking** — a retry that succeeds hides a real degradation. The retry rate is + therefore a metric, not an implementation detail. + +--- + +## 2. Timeouts + +| Rule | Why | +|---|---| +| Every external call has an explicit timeout | A call without one blocks a thread indefinitely | +| The timeout is shorter upstream than downstream | Otherwise the caller gives up before the callee, and the work is lost | +| A total budget exists for the request | Prevents cascading timeouts from accumulating | +| The timeout is a configured value, not a buried constant | It will need adjusting in production | + +--- + +## 3. Logs + +| Do | Avoid | +|---|---| +| Structured, machine-readable | Concatenated strings nothing can parse | +| A correlation identifier propagated | Logs impossible to tie together | +| Useful context: what, where, which identifier | "Error" with no context | +| Consistent levels, actually respected | Everything at `info`, or everything at `error` | +| Masking sensitive data **at the source** | Masking at display time | + +A log that does not let you reconstruct what happened has only occupied disk space. +Control question: *at 3 a.m., does this log let me understand without reading the code?* + +--- + +## 4. Metrics and alerts + +| Type | Example | +|---|---| +| Traffic | Requests, messages processed | +| Errors | Error rate, by type | +| Latency | The distribution, not only the mean | +| Saturation | Queue, connections, memory | +| Business | What the module is supposed to produce | + +**The mean hides everything.** A healthy average latency can conceal 5 % of users waiting +ten seconds. Always look at the distribution. + +### Alerts + +| Rule | Reason | +|---|---| +| Alert on a **user-visible symptom**, not on a technical cause | Causes change, the symptom stays relevant | +| Every alert is **actionable** | An alert with nothing to do will be ignored | +| Every alert points to a **runbook** | Otherwise the knowledge sits in one person's head | +| An alert that fires with no action taken is **removed or fixed** | Noise destroys the value of every alert | + +--- + +## 5. Health checks + +| Type | Answers | Trap | +|---|---|---| +| *Liveness* | Should the process be restarted? | Must **not** depend on external dependencies — otherwise an external outage causes a restart loop | +| *Readiness* | Can it take traffic? | Must check the critical dependencies | +| *Startup* | Has it finished starting? | Avoids restarts during a slow initialisation | + +--- + +## 6. Deployment and rollback + +```mermaid +flowchart TD + A["Change ready"] --> B{"Compatible with
the previous version?"} + B -->|No| C["Split it: make it compatible
first, then switch over"] + B -->|Yes| D["Deploy"] + D --> E["Smoke tests"] + E --> F{"Green?"} + F -->|No| G["Immediate ROLLBACK"] + F -->|Yes| H["Verification through
observability:
errors · latency · business"] + H --> I{"As expected?"} + I -->|No| G + I -->|Yes| J["Done"] + + style G fill:#7c2d12,color:#fff + style J fill:#065f46,color:#fff + style C fill:#1f2937,color:#fff +``` + +**Legend** — red: roll back · green: done · dark grey: split the change instead. + +- **Rollback is tested**, not assumed. A rollback never executed probably does not work. +- **A deployment is not finished at deploy time**: it is finished when observability + confirms the expected behaviour. +- **Backward compatibility is mandatory**: during the deployment two versions coexist. An + incompatible change is split up (`.nstack/handbook/03-contracts.md`). + +--- + +## 7. Controlled degradation + +Decide **in advance** what happens when a dependency is unavailable: + +| Strategy | When | +|---|---| +| Fail cleanly | The feature makes no sense without the dependency | +| Serve a default value | An approximation beats nothing | +| Serve from a cache, even a stale one | Freshness matters less than availability | +| Disable the feature, keep the rest | The dependency is secondary | +| Queue for deferred processing | The operation can be asynchronous | + +The choice is explicit and tested. Without a prior decision, the default behaviour is +always the worst one: an opaque error at the worst possible moment. + +--- + +## 8. Closing checklist + +- [ ] Explicit timeouts on every external call +- [ ] Retries justified, idempotent, with backoff and a ceiling — or absent +- [ ] Logs structured, correlated, free of secrets and personal data +- [ ] Errors never swallowed quietly +- [ ] Metrics and alerts actionable, pointing at a runbook +- [ ] Health checks correct (liveness with no external dependencies) +- [ ] Backward compatibility verified +- [ ] Rollback documented and tested +- [ ] Behaviour on unavailability decided explicitly +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.claude/skills/pause-and-resume/SKILL.md b/.claude/skills/pause-and-resume/SKILL.md new file mode 100644 index 0000000..fd3fe6a --- /dev/null +++ b/.claude/skills/pause-and-resume/SKILL.md @@ -0,0 +1,90 @@ +--- +name: pause-and-resume +description: 'The project''s rules for ending and resuming a session: work committed and pushed before stopping, nothing left running, holds kept, a short resume note in .nstack/local/, and a restart that reads the note, renews its holds and runs nstack plan once. Load this playbook when you are touching: stopping, restarting, handing work over, or resuming a session.' +--- + + + +# Playbook — Pause and resume + +> **Trigger.** Load this playbook when you are touching: stopping, restarting, handing work over, +> or resuming a session. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/pause-and-resume.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## The rule: the repository holds the state, a note points into it + +```mermaid +flowchart LR + S["Stop
work pushed, tree clean"] --> N["Note
.nstack/local/resume.md"] + N -. restart .-> R["Resume
read the note, renew holds"] + R --> P["nstack plan, once"] --> G["the noted gesture"] + classDef state fill:#1f2937,color:#fff + class S,R state +``` + +*Legend: solid arrows are what you do in order; the dotted one is the session ending.* + +A session ends without warning: a restart, a full context, a person's evening. What it knew must +already be where the next one reads it — commits, pull requests, holds — and the next one must +not have to re-read the history to find it. A note of a few lines says where to look; it never +replaces what it points to. + +Your tool's own memory, a chat summary or a transcript are extras: useful to you, invisible to +another tool and to another person. The source is the repository and the forge. + +--- + +## Stop + +Before you stop, or when you are told the session will end: + +1. **Nothing only in the working tree.** Commit what is in progress, on its work branch, and push + it: the pushed branch shows it, and on GitHub the claim's draft pull request too when the work + is on its first branch. A commit or a push a hook refuses: fix its cause; what you cannot fix + before stopping stays as it is, and the note names it with the refusal — never `--no-verify`. +2. **Nothing running.** No background job, watcher or server left for the next session to find. +3. **Nothing left over.** Scratch clones, worktrees and local branches of your own that hold no + work are removed; a worktree that holds work is pushed first. Never the start branch your + claim made: `nstack deliver` removes it. +4. **Holds stay.** A deliverable you will resume stays held (`nstack plan` shows it). Past + `hold_days` without work, anyone may take it over: give back with `nstack unclaim` what you + will not resume by then. +5. **Write the note.** + +## The note + +`.nstack/local/resume.md` — one per clone, never committed (`.nstack/local/` is ignored). +Fifteen lines at most; over that, it repeats what the repository already says. Rewrite it +whole at each stop: it states the present, not a journal. + +```markdown +# Resume — 2026-11-24 18:40, session , for +- Merged since the last note: D30 (#41) +- Open: D31, pull request #44 — next: answer the verifier's finding on the empty state; mine +- Open: D32, branch d32-export, pushed, no pull request yet — next: the test sheet; mine +- Owed by others: the decider's approval of #42; the verifier's run of #44 +- Not pushed: (nothing) — or the commit, the files, and the hook's refusal +- Next id: D33 +- Relaunch: nstack agent run -- +``` + +Handing over to another session or person: give them the note's text with the hand-over, and +give the hold back (`nstack unclaim`) for them to claim. Never hand over a clone. + +## Resume + +1. **Read the note, and only the note.** Not the history, not the transcripts. No note: `git + status`, `git log` of your branches and `nstack plan` say the same, more slowly. +2. **Renew your holds** under this new session. In `nstack agent run`: + `nstack claim --person --session ` renews a hold your own agent + held. Outside it, a new session of yours takes its hold over, on your person's word: + `nstack claim --take-over --person --session ` + (`.nstack/handbook/project.md`, *Who holds a deliverable*). +3. **`nstack plan`, once**: what changed while you were away — merges, holds, what turned stale. + Where it disagrees with the note, the repository is right; the note was the past. +4. **Continue at the noted gesture.** A gesture owed by someone else is not yours to redo. diff --git a/.claude/skills/security/SKILL.md b/.claude/skills/security/SKILL.md new file mode 100644 index 0000000..4f7dec9 --- /dev/null +++ b/.claude/skills/security/SKILL.md @@ -0,0 +1,134 @@ +--- +name: security +description: 'The project''s security rules: authentication, authorisation, secrets, input validation, personal data, dependencies and high-risk actions. Load this playbook when you are touching: authentication, authorisation, secrets, personal data, external input, a new dependency.' +--- + + + +# Playbook — Security + +> **Trigger.** Load this playbook when you are touching: authentication, authorisation, +> secrets, personal data, external input, a new dependency. +> +> Format: `situation → action → verification`. Anything not verifiable here must go to +> human review. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/security.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Absolute rules + +| # | Rule | +|---|---| +| SEC1 | **No secret in the repository.** Not in clear text, not encoded, not "temporarily", not in a test, not in a comment. | +| SEC2 | **All external input is hostile** until explicitly validated. | +| SEC3 | **Least privilege by default** — including for CI and for agents. | +| SEC4 | **Deny by default** in authorisation: whatever is not explicitly allowed is forbidden. | +| SEC5 | **Never design your own** cryptographic, password-hashing or authentication mechanism. The established convention, always (Prior Art Gate). | + +If one of these rules has to be broken, this is no longer a development task: it is a +decision, and it goes through an ADR and human approval. + +--- + +## Authentication + +| Situation | Action | Verification | +|---|---|---| +| New entry point | Check it is covered by the existing mechanism, not a new one | Test: unauthenticated call → refused | +| Password storage | A slow, standard hashing algorithm, never a homemade one | Test on the algorithm used | +| Session or token | Expiry, revocation and rotation planned | Test: expired token → refused | +| Authentication error message | Never reveal whether the account exists | Test on the message content | + +--- + +## Authorisation + +This is the most frequent source of vulnerabilities, and the easiest to test. + +| Situation | Action | Verification | +|---|---|---| +| New endpoint or action | Decide explicitly who is allowed | Test per role: allowed, not allowed, not authenticated | +| Access to a resource by identifier | Check ownership, not only the role | Test: user A reaches B's resource → refused | +| List or search | Filter server-side, never client-side | Test: the response contains no one else's data | +| Privilege escalation possible | Treat it as a high-risk action | Test + logging + human review | + +> **The most common trap.** Hiding a button in the interface is not an authorisation. +> Every access rule exists server-side, and is tested there. + +--- + +## Secrets + +| Situation | Action | Verification | +|---|---|---| +| A secret is needed | Environment variable or vault — never the code | Automated detection in CI | +| Secret exposed, even briefly | **Rotate immediately.** Removing it from the commit is not enough | An incident, not a simple fix | +| Secret in a test | A fake value explicitly named as such | Diff review | +| Log containing a secret or a token | Mask at the source, not at display time | Test on the log content | + +--- + +## Input and data + +| Situation | Action | Verification | +|---|---|---| +| User input | Validate structure, type, bounds, format — then sanitise | Test with invalid, empty, overlong, malformed input | +| Query to a database | Parameterised queries, never concatenation | Injection test | +| Displaying supplied content | Escape at render time, appropriately for the context | XSS test | +| File upload | Type, size, extension, storage outside any executable area | Test with a hostile file | +| Personal data | Minimise, encrypt at rest when sensitive, log access | Review + data inventory | +| Application log | No personal data and no secret | Test on the log content | + +--- + +## Dependencies and supply chain + +| Situation | Action | Verification | +|---|---|---| +| New dependency | Niche filter (`.nstack/handbook/06-decisions.md` §3) + declared in the manifest | Review: undeclared dependency (to automate) | +| Reported vulnerability | Handle it by severity and real exposure, not by score alone | Automated analysis in CI | +| Unmaintained dependency | Open a *Technical debt* issue with the exit strategy | Dependency review | + +--- + +## Exposure and abuse + +| Situation | Action | +|---|---| +| Expensive public endpoint | Rate limiting, from the first version | +| Sensitive operation | Auditable logging: who, what, when, from where | +| Error returned to the client | A generic message; the detail goes to the logs | +| Internal resource | Not exposed by default; exposing it is a decision | + +--- + +## High-risk actions + +Changing permissions, accessing secrets, a change touching authentication, exposing a +new service, an irreversible migration. + +**Mandatory procedure — never a silent execution:** + +``` +1. name the risk and its blast radius +2. describe the state before / after +3. propose the safe procedure and the rollback +4. ask for explicit confirmation +``` + +--- + +## Closing checklist + +- [ ] No secret added, in any form +- [ ] Authorisation tested by role **and** by ownership +- [ ] Input validated and sanitised, with negative tests +- [ ] Logs free of secrets and personal data +- [ ] Error messages uninformative to an attacker +- [ ] New dependencies declared and filtered +- [ ] High-risk actions explicitly confirmed +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.claude/skills/tests/SKILL.md b/.claude/skills/tests/SKILL.md new file mode 100644 index 0000000..7408b9b --- /dev/null +++ b/.claude/skills/tests/SKILL.md @@ -0,0 +1,218 @@ +--- +name: tests +description: 'The project''s test strategy: choosing the test level, writing the oracle, edge cases, doubles and handling flaky tests. Load this playbook when you are touching: a non-trivial test strategy, a flaky test.' +--- + + + +# Playbook — Tests + +> **Trigger.** Load this playbook when you are touching: a non-trivial test strategy, a +> flaky test. +> +> For an ordinary task the kernel rule is enough: **write the oracle, watch it fail, +> implement**. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/tests.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## 1. Choosing the test level + +```mermaid +flowchart TD + A["Behaviour to verify"] --> B{"Is it a pure
business rule?"} + B -->|Yes| U["UNIT TEST
fast, numerous, edge cases"] + B -->|No| C{"Does it cross a
module boundary?"} + + C -->|Yes| CT["CONTRACT TEST
on both sides"] + C -->|No| D{"Does it depend on
real infrastructure?"} + + D -->|Yes| I["INTEGRATION TEST
targeted, minimal scope"] + D -->|No| E{"Is it a critical
user journey?"} + + E -->|Yes| E2["E2E — only when
genuinely critical"] + E -->|No| U + + style U fill:#065f46,color:#fff + style CT fill:#065f46,color:#fff + style E2 fill:#7c2d12,color:#fff +``` + +**Legend** — green: the levels to prefer · red: the level to use sparingly. + +Preference rule: **the lowest level that actually verifies the behaviour**. An E2E test +that could have been a unit test costs a hundred times more, breaks ten times more +often, and diagnoses ten times worse. + +A scenario replayable end to end belongs in the module's `e2e` command, and its evidence in +`.evidence/`: CI keeps it for the test sheet (`.nstack/handbook/05-workflow.md` §7) — where checks are +attested, the verifier's evidence branch (`verification.md`, *Evidence*). + +**What the run said.** `nstack e2e` gives the run a folder of its own, `$NSTACK_EVIDENCE` +(`/.evidence/e2e/`), keeps there the command's output — a traceback included — and then +reads the log files the run wrote there: + +- **Write there** the module's logs (`.log`, `.jsonl`) and screenshots; data that are not logs — + recordings, events — elsewhere. A page's uncaught errors and console errors reach a log there: + logged by the page itself through the application, or collected by a script the scenario + injects (`window.onerror`, `unhandledrejection`) — some drivers expose no console. +- **The audit** reads each line's level — JSON keys, `level=`, a level word leading the line, or + the module's `evidence.levels` expression. A warning or an error the module did not declare is + quoted with `file:line` and the declaration that would accept it: an error fails the run, a + warning fails from criticality `high` and is reported below. The first NapkinStack version that + brings the audit only reports; the project's next minor version judges. +- **Declare** what the scenarios provoke on purpose, in the manifest — a pattern, its level, the + scenario that provokes it (M12). The manifest is the one place the audit reads: a warning or + an error a scenario provokes is declared there, even when the scenario asserts it too. A module + that declares lines and whose run wrote no log into `$NSTACK_EVIDENCE` fails when judged — they + were checked against nothing. +- **Not run here.** A run that cannot run on this machine — no desktop, no sound server — says + why on its output and exits 77, the code Automake and Meson read as a skipped test: the run is + recorded *not run here*, what it logged is shown and nothing judged, and it passes. Exit 0 means + it ran; 77 for any other reason — some tools use it for a refused permission — reads as *not + run*, so a run that fails exits with another code. + +- **One run at a time, unless sealed.** What an end-to-end run drives — a sound server, a + display, a port — is the machine's, so `nstack e2e` runs one at a time on a machine, and a run + that waits says for whom, every minute. A module whose run shares nothing with another run + declares `evidence.sealed: true`: its run neither waits nor holds the machine. Declare it only + when each of these is true — two runs that share one of them see each other's state, and fail + for no reason of their own: + + | Not shared | How to check | + |---|---| + | Session and devices: display, sound server, session bus | its run starts them, headless, and passes their address to what it drives (`DISPLAY`, `PULSE_SERVER`, `DBUS_SESSION_BUS_ADDRESS` from `dbus-run-session`) | + | Ports | each server binds port 0 itself and reports the port it got; never a fixed number, nor one picked and released before the server binds it | + | Files: build output, temporary files, sockets, state, configuration | everything it writes goes under a folder of its own run — the build tool's output folder set per run (`CARGO_TARGET_DIR`, not `build-dir`), `TMPDIR`, `HOME` and `XDG_*_HOME` pointed there —, never a fixed path | + | Processes | its teardown stops what it started — a process group it created (`setsid`, `start_new_session`), or the PIDs it recorded for a daemon that detaches — never by name or executable path | + | Per-user kernel limits: file watchers (inotify instances and watches), process count | its run closes what it opens, and as many runs as the machine takes at once stay under the user's limits (`fs.inotify.max_user_instances`, `fs.inotify.max_user_watches`, `ulimit -u`, which counts threads too); a limit run out fails at once, naming it — no folder of its own run isolates these | + | Timings, whatever the load | it passes with the machine busy; a run that waits for a quiet machine is the opposite of sealed | + + The lock keeps unsealed runs apart, not sealed ones: a run that needs a quiet machine cannot get + one from the lock while sealed runs go beside it. + +```yaml +evidence: + provoked: + - pattern: "key refused" + level: warning + scenario: S3 + sealed: true # every row of the table above holds: runs beside any other +``` + +--- + +## 2. The oracle + +| Requirement | Why | +|---|---| +| Written **before** the implementation | Otherwise it is written to pass, not to verify | +| Watched **failing** first | A test never seen red may test nothing | +| Fails for the **right reason** | A compilation failure is not a test failure | +| Named after the **behaviour**, not the function | `refuses_an_order_without_stock`, not `test_create_order_2` | + +### When the oracle is impossible + +| Cause | Response | +|---|---| +| Subjective criterion | Restate it as an observable behaviour | +| Exploratory task | Requalify it as a *spike*: the deliverable is knowledge | +| Untestable area | Make it testable first, as a separate task | +| Vague need | Back to framing — it was not *Ready* | + +In every case: **do not generate while waiting.** + +--- + +## 3. What to test first + +``` +1. business rules 2. critical journeys 3. permissions +4. contracts 5. errors 6. edge cases +7. regressions that happened 8. high user impact +``` + +**Every regression fixed gets a test** that failed before the fix. That is the only +guarantee it will not come back quietly. + +**Do not aim at a coverage percentage.** Coverage tells you what is not tested; it never +tells you that what is tested is tested well. + +--- + +## 4. Edge cases to consider every time + +``` +empty · null · absent · zero · negative · very large · very long +special characters · unicode · leading and trailing whitespace +duplicate · concurrency · repeated call (idempotence) +dependency unavailable · timeout · partial response +authorisation refused · not authenticated · session expired +time zone · daylight saving · deadline date +``` + +--- + +## 5. Flaky tests + +A flaky test is an **engineering problem**, never a fact of life. Its real cost: it +teaches the team to ignore a CI failure. A single tolerated flaky test degrades the +value of the whole suite. + +```mermaid +flowchart TD + A["Flaky test detected"] --> B["Isolate it: quarantine,
do not delete"] + B --> C{"Cause?"} + C -->|"Real time"| D1["Inject the clock"] + C -->|"Execution order"| D2["Isolate state between tests"] + C -->|"Concurrency"| D3["Synchronise on the event,
never on a duration"] + C -->|"Network / external"| D4["Deterministic double"] + C -->|"Shared state"| D5["Reset for every test"] + C -->|"Undetermined"| E["The test proves nothing:
rewrite it or delete it"] + + D1 --> F["Out of quarantine"] + D2 --> F + D3 --> F + D4 --> F + D5 --> F + + style E fill:#7c2d12,color:#fff + style F fill:#065f46,color:#fff +``` + +**Legend** — green: back to a trustworthy suite · red: the test is not worth keeping. + +**Never "re-run until it passes".** A disabled test carries an issue and a date to pick +it back up; without that, it never comes back. + +Fixed waits (`sleep`) are the most widespread cause of flakiness: wait for an +**observable state**, never for a duration. + +--- + +## 6. Doubles + +| Double | Do not double | +|---|---| +| External services, network, clock, randomness | The business logic of the module under test | +| Slow or expensive dependencies | What the test is meant to verify | +| Other modules — through their **contract** | The database, in an integration test | + +> **Never double another module's behaviour by guessing.** You double its contract, and +> the contract test guarantees the contract matches reality. An invented double goes +> green while production breaks. + +--- + +## 7. Warning signals + +| Signal | Reading | +|---|---| +| A test breaks at every refactor with no behaviour change | It tests the implementation, not the behaviour | +| You have to start another module to test | Bad boundary (`.nstack/handbook/02-modules.md` §9) | +| The test is longer than the code it tests | The code is probably too coupled | +| Nobody understands what this test tests | Delete it or rewrite it; it protects nothing | +| The suite takes more than 10 minutes | It will be bypassed — making it fast is a priority task | diff --git a/.claude/skills/ux/SKILL.md b/.claude/skills/ux/SKILL.md new file mode 100644 index 0000000..248911a --- /dev/null +++ b/.claude/skills/ux/SKILL.md @@ -0,0 +1,136 @@ +--- +name: ux +description: 'The project''s UX/UI rules: the primacy of convention and of the design system, the eight states of an interface, error messages, accessibility, perceived performance and mobile behaviour. Load this playbook when you are touching: a surface visible to the user.' +--- + + + +# Playbook — UX/UI + +> **Trigger.** Load this playbook when you are touching: a surface visible to the user. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/ux.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Entry rule: convention wins + +This is the ground where the Prior Art Gate (`.nstack/handbook/06-decisions.md`) pays off most. + +> For an interface pattern, the value of the convention comes **precisely from the fact +> that the user already knows it**. An unrequested interface innovation is a learning +> cost imposed on every user for the satisfaction of a single designer. + +Before designing a component or a journey: + +1. does the project's design system already cover it? → use it, done. +2. otherwise, what is the established convention for this problem? → adopt it. +3. departing from it requires a named, observable user value. + +**Never create a component that already exists in the design system.** It is the most +common form of wheel reinvention, and the most expensive to undo. + +--- + +## The eight states of an interface + +A feature is not finished if one of these states has not been handled. It is the number +one cause of the gap between "it works on my machine" and "it is usable". + +```mermaid +flowchart LR + A["1 · Empty
first use"] --> B["2 · Loading"] + B --> C["3 · Nominal"] + C --> D["4 · Partial
incomplete data"] + D --> E["5 · Error
recoverable"] + E --> F["6 · Error
blocking"] + F --> G["7 · Empty after
a filter or search"] + G --> H["8 · Too much data
pagination, truncation"] + + style A fill:#1f2937,color:#fff + style E fill:#7c2d12,color:#fff + style F fill:#7c2d12,color:#fff +``` + +**Legend** — dark grey: the state every user sees first · red: the error states. + +States 1, 7 and 8 are the most systematically forgotten. Yet state 1 is the one **every** +user sees first. + +--- + +## Error messages + +| Do | Avoid | +|---|---| +| Say what happened, in the user's language | Showing a technical code alone | +| Say **what to do next** | "An error has occurred" | +| Preserve what the user had typed | Clearing the form | +| Distinguish an input error from a system failure | Treating both the same way | +| Stay discreet about the technical detail | Exposing a trace or an exploitable detail | + +An error message with no possible action is a dead end: the user can only start again +identically. + +--- + +## Accessibility + +Not negotiable as soon as there is an interface. Minimum checks: + +| Point | Test | +|---|---| +| Full keyboard navigation | Go through the whole feature without a mouse | +| Focus visible at all times | Tab from end to end | +| Sufficient contrast | Automated check | +| Images and icons that carry meaning | Text alternative | +| Forms | Associated labels, errors tied to the field | +| Information never carried by colour alone | Visual check | +| Consistent heading structure | Document inspection | +| Large enough touch targets | Test on a real mobile device | +| Dynamic region | Change announced to screen readers | + +Whatever can be automated is automated in CI. **The rest is tested with the keyboard**, +in a few minutes — the best effort-to-detection ratio in the field. + +--- + +## Perceived performance + +What matters is the **felt** time, not the measured time. + +| Situation | Handling | +|---|---| +| Action expected to be instant | Immediate visual feedback, before the server even answers | +| Short wait | A discreet indicator, no full blocking | +| Long wait | Real progress, and a cancellable action where possible | +| Content arriving in pieces | Reserve the space to avoid layout shifts | +| Optimistic action | Plan the rollback explicitly in case of failure | + +--- + +## Responsive and mobile + +The development machine is not representative. + +- Check at a narrow width, not only in a resized browser. +- Test touch interactions: no hover as the only trigger. +- Check the behaviour with the virtual keyboard open. +- Check over a slow connection. + +--- + +## Closing checklist + +- [ ] The 8 states handled, or explicitly out of scope +- [ ] Convention or design system respected; every deviation justified +- [ ] Error messages actionable +- [ ] Full keyboard navigation, focus visible +- [ ] Contrasts checked +- [ ] Tested at a real mobile width +- [ ] Visual feedback on every action +- [ ] No component reinvented +- [ ] The test sheet covers the 8 states, or states which are out of scope (`verification.md`) +- [ ] Whatever could not be verified appears under `NOT VERIFIED` in the summary diff --git a/.claude/skills/verification/SKILL.md b/.claude/skills/verification/SKILL.md new file mode 100644 index 0000000..818b384 --- /dev/null +++ b/.claude/skills/verification/SKILL.md @@ -0,0 +1,145 @@ +--- +name: verification +description: 'The project''s rules for verifying a change: the verifier''s posture, running a test sheet against the running change, the evidence expected for each result, and what to report. Load this playbook when you are touching: verifying a change you did not write, filling in a test sheet.' +--- + + + +# Playbook — Verification + +> **Trigger.** Load this playbook when you are touching: verifying a change you did not +> write, filling in a test sheet. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/verification.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Your posture + +You are the **verifier**. You did not write this change, and you do not fix it. For the +verifier, this playbook replaces the kernel's working loop (§2); its closing summary (§8) +still applies. + +| You do | You never do | +|---|---| +| Start from the need, the acceptance criteria and the test sheet | Read the diff before running the sheet | +| Run every scenario against the running change | Fix the code, even one line | +| Bring back evidence for every result | Write "passed" without evidence | +| Report the gaps against the need or against correctness | Report a preference as a gap | + +The session that wrote the change cannot verify it: start another session, with a fresh +context, or hand the sheet to a human. Sign the sheet with your session's identifier — +`Verifier: session ` — or, as a person, `Verifier: @`. CI compares it with the +change's authors and refuses a match; each person named must have written the sheet into the +description or reviewed or commented on the pull request, under their own account. Writing the +sheet starts the check again; a review or a comment is read at the next run, which any edit of the +description starts. + +### Your own ground + +You verify on someone's machine, beside work that goes on. Leave it as you found it. + +- **A copy of your own**: a working tree checked out at the head, and build outputs of your + own. Check out the pull request's branch, one tracking it, or the head detached: a record made + on a branch of another name is another pull request's (`.nstack/handbook/05-workflow.md` §7). A tree another session edits, or outputs another branch built, give results that are + not this change's. Where a sandbox keeps `.git` read-only, a worktree cannot be added: a + `git clone --shared ` checked out at the head is that copy, `` + and build outputs both under your own cache (`$XDG_CACHE_HOME`, which `nstack agent run -- + claude` sets — for Cargo, `CARGO_TARGET_DIR` there), never the system's temporary folder, which a quota shares with + everyone on the machine. Both are deleted when you leave. +- **The machine's shared state** — a default device, a setting, a service, data others read — + is touched only as the scenario needs, and is put back after each run, also on failure. + What another program holds — a user's own running copy of the product, their files — is + never touched. +- **What you start, you stop, by its process number** — never by a name or a pattern, which + also matches what is not yours. When you leave, nothing of yours is left running. +- **The description is fetched again just before you write it**: the author may have edited + it since you read it, and your edit must keep theirs. + +--- + +## The procedure + +1. **Read the need** — the deliverable, its acceptance criteria, the test sheet in the + pull request's description. Nothing else yet. +2. **Start the change** — the module's `run` verb, or the environment named in + `.nstack/tooling-profile.md`. A module with no `run` verb — a library, a contract — has + nothing to start: its scenarios run through its tests, and you say so in your report. +3. **Run each scenario**, in order: + - *automated* — the module's `e2e` verb, or its `test` verb when it declares no `e2e`; + the evidence is the CI run on the head commit, or its artefact — where checks are attested, + the evidence branch below — for a change to a + visible surface, read the run's screenshots and logs (`.evidence/e2e/`, its `audit.json`) + and cite what they showed: never "rendering not seen" on a scenario passed. An audit + `not run` (exit 77) ran no scenario: each one it stood for is *not verified*, or run where + it can run; + - *explored* — drive the interface yourself, in a browser, an emulator or on a device, + with the tools of the tooling profile; capture the screen at the step that proves the + result; + - *human only* — do not run it; check that its reason is stated and, when the + deliverable's acceptance rests on it, that an acceptance issue asks it of a person. +4. **Record** each result in the sheet — `passed`, `failed — `, or + `not verified` — with its evidence and the short hash of the commit you tested; a `|` in a cell, + in a code span too, is written `\|`. What you + have to add goes on the line **`Verifier's remarks:`** under the table, never in a cell: a + scenario that passed by your own probe and not by the test it cites, a wording that claims + more than was exercised. A remark is not a result, and the approver reads it. After a + fix, an *automated* scenario is run again at the head and its Commit cell takes the head — + it is never confirmed; an *explored* one keeps its commit and is confirmed in + the `Confirmed` column with the head commit and what moved since — after a `;` when the cell holds an + earlier confirmation; at criticality + `critical`, every scenario is run again (`.nstack/handbook/05-workflow.md` §7). +5. **Only then read the diff**, to explain a failure — never to decide a result — and ask one + question of its tests: **is the entry point a real user calls exercised the way they call + it?** A suite that always passes what the user never passes is green on a path nobody takes. +6. **Report** the failures first — observed, expected, evidence — then any optional + remark, marked as such. + +### Mutants + +To show that a test pins what it claims, change the code it claims to pin and watch it fail — a +mutant. A mutant can make the code loop forever, so it is never run unbounded: + +- **The language's tool first**, rather than a loop of your own: `cargo-mutants` (Rust; `--file` + to aim it, `--timeout` to bound it), `mutmut` (Python), Stryker (JavaScript, TypeScript, C#, + Scala), PIT (Java). +- **By hand**, one mutant per run, each run under a time limit — `timeout 120 `; a timeout counts as killed: the mutant changed what the code does. +- **The source restored on every exit**, not only at the end — `trap 'git checkout -- ' + EXIT`, or mutate in a throwaway copy of your own (above). +- **Report the counts** — killed, survived, timed out — and each survivor with its line: a + survivor is a test that does not pin what it claims. + +--- + +## Evidence + +| Scenario | Evidence expected | +|---|---| +| An interface | A screenshot of the state that proves the result; a video for a sequence | +| A mobile interface | The screenshot of the emulator or the device, with its width or model | +| An API, a job, data | The command and its output, or the log lines | +| Accessibility | The keyboard path followed, and the automated report when there is one | + +Test data only: never a real user's data, never a secret on a screenshot (`security.md`). +Evidence lives where the whole team sees it — a CI artefact, or an image attached to the +pull request. **Where checks are attested**, no CI run keeps an artefact, and an agent's identity +cannot attach an image through the forge's API: the verifier commits the screenshots and videos +that prove a criterion on a branch of its own, `evidence/`, never on the change's +branch — its head stays the one verified (T4), and the verifier writes no commit of the change +(T2) — and links each file from the sheet at that branch's commit. Made-up data only, each file +read before it is pushed: a public repository keeps it for good, and no secret scanner reads an +image (`security.md`). The `check-added-large-files` hook bounds each file as it is committed; +the branch is deleted once the cycle is closed. + +A user-facing change covers the eight states of an interface (`ux.md`), or says which are +out of scope. A state missing from the sheet is a gap to report. + +--- + +## When the sheet itself is wrong + +A scenario that does not match the need, or a need no scenario covers: report it. An +expected result changes only with the decider's agreement, visibly in the sheet's history. diff --git a/.copier-answers.yml b/.copier-answers.yml index e68b7c3..6c3b899 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,7 +1,17 @@ # The project creation answers and the NapkinStack version (_commit). -# Managed by Copier: changed by nstack update, never by hand. -_commit: v0.6.2 +# Lines starting with _ are Copier's: changed by nstack update, never by hand. +# The project's answers below — checks, approval, hold_days, agent_sockets, the review budget — are the decider's: +# `nstack config` lists them and lays a change on a branch, for a pull request a human approves; +# nstack update keeps them (.nstack/handbook/07-governance.md §7). +_commit: v0.34.11 _src_path: https://github.com/NapkinStack/engineering-os.git +agent_sockets: false +approval: human +checks: forge +forge: github github_repo: NapkinStack/flet +hold_days: 7 owner_team: NapkinStack/maintainers project_name: flet +review_budget_files: 15 +review_budget_lines: 400 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..01a2a72 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Generated by `nstack skills` from .nstack/playbooks/: committed, folded in review diffs, never edited. +.claude/skills/** linguist-generated=true +.agents/skills/** linguist-generated=true diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5b78839..3265ccb 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,21 +1,16 @@ -# Ties every change to an owner (docs/os/07-governance.md §7). +# Ties every change to an owner (.nstack/handbook/07-governance.md §7). # Updated automatically by nstack new-module. # Default owner: every path the rules below do not name. With the code owner review -# required, a human approval covers every file (docs/os/07-governance.md §7). +# required, a human approval covers every file (.nstack/handbook/07-governance.md §7). * @NapkinStack/maintainers # Foundation: any change to the OS itself goes through an ADR. /AGENTS.md @NapkinStack/maintainers -/playbooks/ @NapkinStack/maintainers -/docs/os/ @NapkinStack/maintainers /.nstack/ @NapkinStack/maintainers /.github/ @NapkinStack/maintainers /.copier-answers.yml @NapkinStack/maintainers -# Contracts: the most critical boundary in the system, never orphaned. -/contracts/ @NapkinStack/maintainers - # Modules — one line per module, added by the scaffolding. /modules/screening/ @NapkinStack/maintainers /modules/copying/ @NapkinStack/maintainers diff --git a/.github/ISSUE_TEMPLATE/01-feature.yml b/.github/ISSUE_TEMPLATE/01-feature.yml deleted file mode 100644 index 97040b2..0000000 --- a/.github/ISSUE_TEMPLATE/01-feature.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Feature -description: A new user capability -labels: ["feature"] -body: - - type: markdown - attributes: - value: | - This issue must be understandable by another human **or an agent** with no - spoken conversation. Otherwise it is not *Ready*. - - - type: input - id: module - attributes: - label: Target module - description: EXACTLY ONE. If the task touches two, split it (docs/os/02-modules.md §7). - placeholder: modules/billing - validations: { required: true } - - - type: input - id: deliverable - attributes: - label: Deliverable - description: >- - The deliverable of the current cycle this issue delivers (docs/project/cycles/). - Empty only for work outside the cycle. - placeholder: D1 - - - type: textarea - id: goal - attributes: - label: Goal - description: What the user must be able to do. One sentence. - validations: { required: true } - - - type: textarea - id: context - attributes: - label: Context - description: Why now. Link to the PDR or the ADR when the decision is taken. - validations: { required: true } - - - type: textarea - id: out-of-scope - attributes: - label: Out of scope - description: What is explicitly NOT done here. This is the section that prevents drift. - validations: { required: true } - - - type: textarea - id: acceptance - attributes: - label: Acceptance criteria - description: Testable — they are the task's oracle (docs/os/05-workflow.md §3). - value: | - - [ ] Given , when , then - - [ ] Given , when , then - validations: { required: true } - - - type: checkboxes - id: cases - attributes: - label: Cases to cover - options: - - label: Nominal journey - - label: Edge cases - - label: Invalid input - - label: Permissions - - label: Empty state / first use (when there is UI) - - label: External dependency error - - - type: dropdown - id: contracts - attributes: - label: Contracts - options: - - No contract affected - - Contract consumed (existing) - - Contract provided changed → a separate issue, expand/contract - validations: { required: true } - - - type: checkboxes - id: playbooks - attributes: - label: Playbooks to load - options: - - label: security.md — authn/authz, secrets, personal data, external input - - label: data-migration.md — schema or existing data - - label: ux.md — user-facing surface - - label: tests.md — a test strategy that is not obvious - - label: operations.md — logs, retries, timeouts, rollback - - - type: checkboxes - id: dor - attributes: - label: Definition of Ready - options: - - label: Goal understandable with no spoken exchange - required: true - - label: A single target module - required: true - - label: Scope and out of scope explicit - required: true - - label: Testable acceptance criteria - required: true - - label: Fits the review budget — otherwise split it now - required: true diff --git a/.github/ISSUE_TEMPLATE/01-request.yml b/.github/ISSUE_TEMPLATE/01-request.yml new file mode 100644 index 0000000..8929452 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01-request.yml @@ -0,0 +1,31 @@ +name: Request +description: Something asked for that no cycle plans yet +labels: ["request"] +body: + - type: markdown + attributes: + value: | + A request is **not work yet**. The next framing makes it a deliverable of a cycle, + or refuses it with a reason (.nstack/handbook/06-decisions.md §9). Work a cycle already + plans is described there, once — not here. + + - type: textarea + id: need + attributes: + label: Who asks, and what they cannot do today + description: One user, one situation. Not a solution. + validations: { required: true } + + - type: textarea + id: evidence + attributes: + label: Evidence + description: What shows the need is real, with its source. "Nobody asked" is an answer. + validations: { required: true } + + - type: textarea + id: cost-of-nothing + attributes: + label: What happens if nothing is done + description: And by when. Without it, the request cannot be weighed against the cycle's other work. + validations: { required: true } diff --git a/.github/ISSUE_TEMPLATE/02-bug.yml b/.github/ISSUE_TEMPLATE/02-bug.yml index 20f092b..89efafb 100644 --- a/.github/ISSUE_TEMPLATE/02-bug.yml +++ b/.github/ISSUE_TEMPLATE/02-bug.yml @@ -21,6 +21,15 @@ body: description: Minimal steps. If it is not reproducible, say so — that is information. validations: { required: true } + - type: input + id: brought + attributes: + label: Pull request that brought it + description: >- + The number of the merged pull request the defect came in with, or "unknown" — + what escaped is measured on it (.nstack/handbook/10-measurement.md). + validations: { required: true } + - type: input id: impact attributes: @@ -31,7 +40,7 @@ body: - type: checkboxes id: guardrail attributes: - label: Feedback loop (docs/os/10-measurement.md §4) + label: Feedback loop (.nstack/handbook/10-measurement.md §4) description: Fixing the bug is not enough — improve the system that let it through. options: - label: A test reproducing the bug will be added (it must fail BEFORE the fix) diff --git a/.github/ISSUE_TEMPLATE/03-architecture.yml b/.github/ISSUE_TEMPLATE/03-architecture.yml index 96c1006..1ff3a44 100644 --- a/.github/ISSUE_TEMPLATE/03-architecture.yml +++ b/.github/ISSUE_TEMPLATE/03-architecture.yml @@ -8,7 +8,7 @@ body: label: Signal observed description: | Which coupling signal triggered this issue? - (docs/os/02-modules.md §9) — recurring cross-module PRs, a cycle detected, + (.nstack/handbook/02-modules.md §9) — recurring cross-module PRs, a cycle detected, modules always deployed together, an agent unable to work through the contract… validations: { required: true } @@ -24,7 +24,7 @@ body: label: Prior art description: | How is this problem solved elsewhere? Minimum two references. - (docs/os/06-decisions.md §2) + (.nstack/handbook/06-decisions.md §2) validations: { required: true } - type: checkboxes diff --git a/.github/ISSUE_TEMPLATE/05-debt.yml b/.github/ISSUE_TEMPLATE/04-debt.yml similarity index 92% rename from .github/ISSUE_TEMPLATE/05-debt.yml rename to .github/ISSUE_TEMPLATE/04-debt.yml index dc129ce..31435a7 100644 --- a/.github/ISSUE_TEMPLATE/05-debt.yml +++ b/.github/ISSUE_TEMPLATE/04-debt.yml @@ -31,6 +31,6 @@ body: - type: checkboxes id: automatable attributes: - label: Automation backlog (docs/os/07-governance.md §9) + label: Automation backlog (.nstack/handbook/07-governance.md §9) options: - label: This debt comes from a rule living in the prompt that should be automated diff --git a/.github/ISSUE_TEMPLATE/04-spike.yml b/.github/ISSUE_TEMPLATE/04-spike.yml deleted file mode 100644 index 4afd89b..0000000 --- a/.github/ISSUE_TEMPLATE/04-spike.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Spike / Investigation -description: Resolve an uncertainty. The deliverable is knowledge, not code. -labels: ["spike"] -body: - - type: textarea - id: question - attributes: - label: Question to answer - description: A closed question. If it is open-ended, the spike will never finish. - validations: { required: true } - - - type: input - id: timebox - attributes: - label: Timebox - placeholder: "2 days" - validations: { required: true } - - - type: textarea - id: deliverable - attributes: - label: Expected deliverable - description: | - A documented answer, an ADR, a throwaway prototype. - The code produced here is NOT destined for production. - validations: { required: true } diff --git a/.github/ISSUE_TEMPLATE/05-acceptance.yml b/.github/ISSUE_TEMPLATE/05-acceptance.yml new file mode 100644 index 0000000..8d38060 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/05-acceptance.yml @@ -0,0 +1,54 @@ +name: Acceptance +description: A deliverable tried by a person — what to run, what was seen +labels: ["acceptance"] +body: + - type: markdown + attributes: + value: | + An acceptance **tracks** a deliverable; it does not describe it. The criteria are in + the cycle and are not copied here; the deliverable's state is never read from this issue: + `nstack deliver D --held '=#'` records what it answers, and the + closure writes the state into the cycle. This issue holds what a file holds badly: who runs what, on what, and + what they saw (.nstack/handbook/06-decisions.md §9). Each answer is a comment; a test + sheet cites it as its evidence. + + One issue is **one trial**: a person, a system, a set of steps. It is closed when each + step has its answer — met or not — by whoever ran it, or by the pull request that + records the last one. Closing it says nothing of the deliverable: what was not met is + fixed and tried again in another issue, or said in the cycle. + + - type: input + id: tracks + attributes: + label: What it tracks + description: The deliverable's identifier and its cycle's file — a pointer, not a copy. + placeholder: "D3 — docs/project/cycles/01-….md" + validations: { required: true } + + - type: input + id: who + attributes: + label: Who runs it, and on what + description: A person, and what no agent has — a device, a real call, a colleague's machine. + validations: { required: true } + + - type: textarea + id: run + attributes: + label: What to run + description: >- + One step per criterion a person must try, as a gesture to make — the command, the + action — and what it must show. A step answered is ticked, with the comment that + answers it. + value: | + - [ ] 1. — must show: + validations: { required: true } + + - type: textarea + id: elsewhere + attributes: + label: What is already held elsewhere + description: >- + The criteria a test sheet or a test already holds, each with its pull request. What + nobody holds yet is said too. + validations: { required: false } diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6689431..505d661 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,7 @@ Closes # - [ ] ⚠️ Cross-module — the `cross-module` label is required, justification below +expand/contract sequence, not a single PR (`.nstack/handbook/03-contracts.md`).> ## Deliverable @@ -22,16 +22,18 @@ Deliverable: D > outside the cycle — an incident, a production defect — carries the `out-of-cycle` label, > and replaces the line above with `Out of cycle: `. A pull request that changes no > module beyond its description — manifest, `AGENTS.md`, `README.md`, `docs/` — such as a -> framework update, is not delivery work: the line does not apply. +> framework update, is not delivery work: the line does not apply, unless the manifest moves +> the module's criticality or its user-visible surface. ## What it changes +says why. A change with a shape — a flow, who reads what, a before and an after — is drawn: +one Mermaid diagram with its legend, in place of the prose it shows; a change of words is not.> ## Oracle -> `docs/os/05-workflow.md` §3 +> `.nstack/handbook/05-workflow.md` §3 - [ ] The success criterion was written **before** the implementation - [ ] It was seen **failing**, for the right reason @@ -44,7 +46,7 @@ other: ## Review budget -> `docs/os/05-workflow.md` §4 +> `.nstack/handbook/05-workflow.md` §4 - Lines changed (excluding generated): - Files touched: @@ -59,7 +61,8 @@ other: - [ ] No contract affected - [ ] Contract consumed — the version is declared in the manifest - [ ] Contract changed, **additive** — contract tests green, and `nstack compat` proving it - once the version is consumed or stable + once the version is consumed or stable; a promise of its page reversed: + — no consumer relies on it, or the change is breaking - [ ] Contract changed, **breaking** — expand/contract step no. <1|2|3|4>, ADR linked, removal date set @@ -68,20 +71,20 @@ other: ## Definition of Done > Tick what is **applicable** for the module's criticality -> (`docs/os/05-workflow.md` §7). Never tick a box without having actually run it. +> (`.nstack/handbook/05-workflow.md` §7). Never tick a box without having actually run it. - [ ] Oracle green - [ ] Lint, format, types - [ ] Unit tests - [ ] Build -- [ ] Contract tests *(when there is a contract)* +- [ ] Contract tests - [ ] Fitness functions -- [ ] Integration tests *(per risk)* +- [ ] Integration tests - [ ] Security analysis -- [ ] Accessibility *(when there is UI)* -- [ ] E2E on critical journeys *(criticality high and above)* -- [ ] Observability added *(criticality high and above)* -- [ ] Rollback verified *(criticality critical)* +- [ ] Accessibility +- [ ] E2E on critical journeys +- [ ] Observability added +- [ ] Rollback verified - [ ] Affected documentation updated - [ ] Diff self-reviewed line by line @@ -89,25 +92,36 @@ other: ## Test sheet -> Required when the pull request changes a user-facing module, or one of criticality high -> or critical, beyond its description — manifest, `AGENTS.md`, `README.md`, `docs/` -> (`docs/os/05-workflow.md` §7). The scenarios come from the acceptance +> Required when the pull request changes a module the table of `.nstack/handbook/05-workflow.md` §7 +> asks a sheet of — a user-facing one from `standard` up, any one of criticality high or +> critical — beyond its description: manifest, `AGENTS.md`, `README.md`, `docs/` — or moves its +> criticality or its user-visible surface. The +> scenarios come from the acceptance > criteria and are written before the code; the results are filled in by a verifier who is -> not the author (`playbooks/verification.md`). Kind: automated · explored · human only — +> not the author (`.nstack/playbooks/verification.md`). Kind: automated · explored · human only — > reason. Result: passed · failed — what was observed · not verified. +> +> **Confirmed** is for a fix landed after the verification: an *automated* scenario is simply run +> again at the head and its **Commit** cell takes the head — nothing here; one *explored* by hand +> keeps its commit and gets the head commit here with what moved since, after a `;` when an earlier confirmation is there — except at criticality `critical`, where every scenario is run again. Leave +> it empty when nothing moved — a confirmation is not a round. -Verifier: <@handle, or session and the agent session's identifier> +Verifier: <@handle, or session and the agent session's identifier> — -| # | Given · when · then | Kind | Result | Evidence | Commit | -|---|---|---|---|---|---| -| S1 | | | | | | +| # | Given · when · then | Kind | Result | Evidence | Commit | Confirmed | +|---|---|---|---|---|---|---| +| S1 | | | | | | — | + +> A scenario that waits on a person is asked in an acceptance issue; its Evidence cell links the answer. + +Verifier's remarks: --- ## Summary > An imposed format. The last three sections are the most important and the most often -> skated over. (`docs/os/05-workflow.md` §8) +> skated over. (`.nstack/handbook/05-workflow.md` §8) **DONE** @@ -129,8 +143,8 @@ Verifier: <@handle, or session and the agent session's identifier> ## Signals to report - [ ] I had to look at another module's implementation → **a signal of a bad boundary** - (`docs/os/02-modules.md` §9) + (`.nstack/handbook/02-modules.md` §9) - [ ] A kernel or playbook rule got in my way for no good reason - [ ] A quality gate blocked without improving quality - [ ] A rule applied by hand would be worth automating - → the automation backlog (`docs/os/07-governance.md` §9) + → the automation backlog (`.nstack/handbook/07-governance.md` §9) diff --git a/.github/workflows/commits-on-main.yml b/.github/workflows/commits-on-main.yml index a74e7a6..7b95ba4 100644 --- a/.github/workflows/commits-on-main.yml +++ b/.github/workflows/commits-on-main.yml @@ -1,6 +1,6 @@ name: Commits on main -# What reached this branch outside a pull request, recorded (W1, PDR-0006). +# What reached this branch outside a pull request, recorded (rule W1, .nstack/handbook/RULES.md). # # This workflow RECORDS; it never refuses. What refuses a merge is the ruleset, and on a # repository whose plan cannot enforce one, nothing refuses at all — which is exactly when @@ -20,18 +20,19 @@ on: permissions: contents: read pull-requests: read + actions: read # the record's own last success, where the next run starts reading (a run that never started) jobs: landed: name: Commits on main - runs-on: ubuntu-latest + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: NapkinStack, the project version run: bash .nstack/install-engine.sh diff --git a/.github/workflows/governance.yml b/.github/workflows/governance.yml index f2a79ac..3aad4c8 100644 --- a/.github/workflows/governance.yml +++ b/.github/workflows/governance.yml @@ -2,9 +2,10 @@ name: Governance # Architecture fitness functions, pull request scope, hooks and secrets. # These checks are NOT BYPASSABLE: that is what separates a rule from a pious wish -# (docs/os/07-governance.md). +# (.nstack/handbook/07-governance.md). # -# To do once: Settings → Rules → Rulesets → require these checks on the main branch. +# To do once, by the repository's owner: nstack settings --apply requires these checks on the +# default branch (nstack doctor reads them back). # Without that, CI informs but guarantees nothing. # # Security, verified by zizmor: a read-only token, actions pinned by SHA and kept up to @@ -26,13 +27,13 @@ permissions: jobs: architecture: name: Fitness functions - runs-on: ubuntu-latest + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: NapkinStack, the project version run: bash .nstack/install-engine.sh @@ -43,7 +44,7 @@ jobs: scope: name: PR scope and review budget if: github.event_name == 'pull_request' - runs-on: ubuntu-latest + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: # fetch-depth: 0 fetches every branch: no authenticated git fetch to do. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -51,7 +52,7 @@ jobs: fetch-depth: 0 persist-credentials: false - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: NapkinStack, the project version run: bash .nstack/install-engine.sh @@ -64,14 +65,14 @@ jobs: hooks: name: Hooks and secrets - runs-on: ubuntu-latest + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -88,6 +89,19 @@ jobs: SKIP: gitleaks run: pre-commit run --all-files --show-diff-on-failure - # Rule S1: no secret in the repository. Output redacted, the logs are public. + # No secret in the repository (rule SEC1 of .nstack/playbooks/security.md). Output redacted, the logs are public. - name: Secrets in the whole git history run: pre-commit run gitleaks-history --hook-stage manual --all-files + + # A commit message and a pull request's description are pages anyone reads: the hook + # that refuses a link into a private assistant session reads them here, where it + # cannot be bypassed. Values from the context come through env (zizmor). + - name: No private session link in a message + env: + BASE: ${{ github.event.pull_request.base.sha || github.event.before }} + DESCRIPTION: ${{ github.event.pull_request.body }} + run: | + said="$RUNNER_TEMP/said.txt" + printf '%s\n' "$DESCRIPTION" > "$said" + if git cat-file -e "$BASE^{commit}" 2>/dev/null; then git log --format=%B "$BASE..HEAD" >> "$said"; fi + pre-commit run no-session-link --hook-stage commit-msg --commit-msg-filename "$said" diff --git a/.github/workflows/module-checks.yml b/.github/workflows/module-checks.yml index e8d1e30..4cadb5b 100644 --- a/.github/workflows/module-checks.yml +++ b/.github/workflows/module-checks.yml @@ -1,17 +1,18 @@ name: Modules # Runs the standard verbs on the changed modules only: nstack reads their commands -# from the module's MANIFEST.yaml, assuming no stack (P1). A module is a folder holding a +# from the module's MANIFEST.yaml, assuming no stack. A module is a folder holding a # MANIFEST.yaml, contracts/ included: nstack lists them, the workflow defines nothing. # The level of validation is proportionate to the criticality declared in the MANIFEST -# (docs/os/07-governance.md §6). +# (.nstack/handbook/07-governance.md §6). # -# `Module checks` is the required check: a matrix job carries each module's name, which no -# ruleset can require in advance, so this job fails whenever one of them failed. +# `Module checks` is the required check, and the only job: every changed module runs in it, one +# after another, through .nstack/check-modules.sh. Each job is billed at least a minute: one job +# costs what the modules' verbs take, where a job per module, a listing and a summary cost three. # # A change to a contract version also runs the checks of the module that provides it and of # every module that declares it in consumes: the contract tests of both sides, which is what -# docs/os/03-contracts.md section 5 promises. +# .nstack/handbook/03-contracts.md section 5 promises. # # Module names come from the paths the pull request changed: they are never inserted # into a script, only read from an environment variable. @@ -25,124 +26,38 @@ permissions: contents: read jobs: - discover: - name: Changed modules - runs-on: ubuntu-latest - outputs: - modules: ${{ steps.list.outputs.modules }} - any: ${{ steps.list.outputs.any }} - base: ${{ steps.list.outputs.base }} + checks: + name: Module checks + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: + # A job starts clean: what an earlier job left in the checkout — a build that failed + # half-way on a self-hosted runner — is removed before this one runs. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false + clean: true - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: NapkinStack, the project version run: bash .nstack/install-engine.sh - - id: list + # bootstrap, check, test, compat even after a failure, e2e, and clean on a self-hosted + # runner — module by module (.nstack/handbook/05-workflow.md §7, 09-platform.md §2). + - name: Every changed module env: BASE: ${{ github.event.pull_request.base.sha || github.event.before }} - run: | - if ! git rev-parse --verify --quiet "$BASE^{commit}" >/dev/null; then - if [ "$GITHUB_EVENT_NAME" = pull_request ]; then - echo "::error::Base $BASE of the pull request not found: its modules cannot be listed." \ - "Action: run the jobs again; the checkout fetches the whole history." - exit 1 - fi - # The first push of a branch has no previous commit: every file is new. - BASE=$(git rev-list --max-parents=0 HEAD | tail -1) - fi - MODS=$(nstack modules --root . --changed-since "$BASE" --with-contract-sides --json) - echo "modules=$MODS" >> "$GITHUB_OUTPUT" - echo "base=$BASE" >> "$GITHUB_OUTPUT" - if [ "$MODS" = '[]' ]; then echo "any=false" >> "$GITHUB_OUTPUT"; - else echo "any=true" >> "$GITHUB_OUTPUT"; fi - echo "Modules with a file changed: $MODS" - - validate: - name: ${{ matrix.module.name }} - needs: discover - if: needs.discover.outputs.any == 'true' - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - module: ${{ fromJson(needs.discover.outputs.modules) }} - env: - MODULE: ${{ matrix.module.name }} - FOLDER: ${{ matrix.module.folder }} - BASE: ${{ needs.discover.outputs.base }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 - - - name: NapkinStack, the project version - run: bash .nstack/install-engine.sh + run: bash .nstack/check-modules.sh - - name: Declared criticality - id: crit - run: | - LEVEL=$(yq '.module.criticality // "standard"' "$FOLDER/MANIFEST.yaml") - echo "level=$LEVEL" >> "$GITHUB_OUTPUT" - echo "Criticality: $LEVEL" - - - name: bootstrap - run: nstack bootstrap "$MODULE" - - # All levels — docs/os/05-workflow.md §7 - - name: check - run: nstack check "$MODULE" - - - name: test - run: nstack test "$MODULE" - - # A contract version someone relies on changes only with the merged proof (V1, - # docs/os/03-contracts.md §4). The step runs even when an earlier one failed: a pull - # request that breaks a frozen version AND a test would otherwise meet V1 a round trip - # later, once the tests are green (D46). - - name: compat - if: ${{ !cancelled() }} - run: nstack compat "$MODULE" --base "$BASE" - - # Levels high and critical — not wired up yet (D9) - - name: Integration tests - if: steps.crit.outputs.level == 'high' || steps.crit.outputs.level == 'critical' - run: | - echo "Not wired up: integration tests (D9)" - - # Optional verb: the module's end-to-end scenarios, when declared (docs/os/09-platform.md §2). - - name: e2e - run: nstack e2e "$MODULE" - - # The evidence the test sheet links to (docs/os/05-workflow.md §7), kept even on failure. + # The evidence the test sheet links to (.nstack/handbook/05-workflow.md §7), kept even on + # failure: one archive, a folder per module. - name: Evidence of the scenarios if: always() - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: evidence-${{ matrix.module.name }} - path: ${{ matrix.module.folder }}/.evidence/ + name: evidence + path: "**/.evidence/" include-hidden-files: true if-no-files-found: ignore retention-days: 30 - - checks: - name: Module checks - needs: [discover, validate] - if: always() - runs-on: ubuntu-latest - steps: - - name: Every changed module passed - env: - DISCOVERED: ${{ needs.discover.result }} - VALIDATED: ${{ needs.validate.result }} - run: | - echo "Changed modules: $DISCOVERED. Their checks: $VALIDATED." - [ "$DISCOVERED" = success ] && { [ "$VALIDATED" = success ] || [ "$VALIDATED" = skipped ]; } diff --git a/.github/workflows/plan-on-the-forge.yml b/.github/workflows/plan-on-the-forge.yml new file mode 100644 index 0000000..c05a647 --- /dev/null +++ b/.github/workflows/plan-on-the-forge.yml @@ -0,0 +1,55 @@ +name: Plan on the forge + +# The cycles and their deliverables, shown on GitHub as milestones and issues (`nstack board`). +# +# The cycle files are the plan; this workflow only SHOWS them, one way. An issue or a milestone +# edited by hand is put back at the next run, and the run says so: the plan is edited in +# docs/project/cycles/, in a pull request. Nothing here ever refuses anything — a forge that +# refuses a call is said in the run's summary, and the run succeeds. +# +# When: a merge to the default branch (the plan changed), once a day (a hold changed — a claim +# pushes a branch holding no file, so no workflow of it can start), and by hand — Run workflow +# here, never `nstack board` beside it: this workflow's runs wait for one another, a command run +# elsewhere does not, and two at once each make the same issue. Whatever triggered it, +# the run reads the default branch's tip: a re-run never shows an older plan. +# +# Rights: writing issues and milestones, reading pull requests and the code — asked by this job +# alone; the project's other automation stays read-only (rule G10). The holds are fetched with +# the job's token for that one command; the checkout keeps no credential. + +on: + push: + branches: [main] + schedule: + - cron: "17 5 * * *" + workflow_dispatch: + +permissions: {} + +concurrency: + group: plan-on-the-forge + cancel-in-progress: false + +jobs: + board: + name: Plan on the forge + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} + permissions: + contents: read + issues: write + pull-requests: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.repository.default_branch }} + persist-credentials: false + + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + + - name: NapkinStack, the project version + run: bash .nstack/install-engine.sh + + - name: The cycles, shown as milestones and issues + env: + GH_TOKEN: ${{ github.token }} + run: nstack board diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4605cee..7fafee6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,8 +1,12 @@ name: Pull request # The rules read from the pull request's description: the test sheet -# (docs/os/05-workflow.md §7) and the cycle (docs/project/README.md). Editing the -# description or a label re-evaluates them on the same head commit. +# (.nstack/handbook/05-workflow.md §7) and the cycle (.nstack/handbook/project.md). Editing the +# description or a label re-evaluates them on the same head commit. A review or a comment is a +# person's hand on the pull request when they are its named verifier (T2), read at the next run: +# never a trigger, since a review's failed run stays beside the later ones and blocks the merge, +# and an attested record, pushed as notes, is no event that could replace it (D218, #394): its +# event is its own status, `nstack / local checks`, when a ruleset requires it (D221, #399). # # The description is untrusted input: it reaches nstack through env:, never a script. @@ -11,19 +15,26 @@ on: types: [opened, edited, synchronize, reopened, labeled, unlabeled] permissions: - contents: read + contents: read # the head, and the attested record in the remote's notes (A1, A2) + pull-requests: read # whose hand is on the pull request: a person named verifier (T2); approvals (R1, R2) + +# Each event's run reads the description and the head as they were at that event: a later event +# of the same pull request cancels the earlier run, so the verdict shown is the last one's. +concurrency: + group: pull-request-${{ github.event.pull_request.number }} + cancel-in-progress: true jobs: description: name: Test sheet and cycle - runs-on: ubuntu-latest + runs-on: ${{ vars.NSTACK_RUNS_ON || 'ubuntu-latest' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - - uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: NapkinStack, the project version run: bash .nstack/install-engine.sh @@ -34,5 +45,7 @@ jobs: PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }} PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} - BASE_REF: ${{ github.base_ref }} + PR_NUMBER: ${{ github.event.pull_request.number }} + GH_TOKEN: ${{ github.token }} + BASE_REF: ${{ github.event.pull_request.base.ref }} run: nstack pr-check --root . --base "origin/$BASE_REF" diff --git a/.gitignore b/.gitignore index d10e752..731ad47 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,10 @@ coverage/ !.env.example .DS_Store -# Skills generated from playbooks/ — the source of truth is playbooks/ -.claude/skills/ +# The skills nstack generates from .nstack/playbooks/ are committed (.claude/skills/, .agents/skills/): +# an agent starting from a fresh clone needs them. Their source is .nstack/playbooks/. -# Evidence of the end-to-end scenarios: a CI artefact, never committed +# Evidence of the end-to-end scenarios: a CI artefact, or an evidence branch — never committed to a change .evidence/ # Editors and IDEs @@ -30,6 +30,9 @@ coverage/ # Local agent settings: machine-specific paths and permissions .claude/settings.local.json +# A clone's resume note (.nstack/playbooks/pause-and-resume.md): one per clone, never shared +.nstack/local/ + # Agent session and machine state: written by the tool as it runs, never by the project. # `.claude/settings.json` and `.claude/hooks/` are deliberately absent from this list — # project-level settings and hooks are shared with the team on purpose. What follows is @@ -58,4 +61,12 @@ Desktop.ini id_rsa* id_ed25519* .envrc -secrets.* +# Secret files by their data formats, never secrets.*: where git ignores case, as on macOS, +# that also left out source code such as Secrets.swift. +secrets.env +secrets.json +secrets.yaml +secrets.yml +secrets.toml +secrets.ini +secrets.txt diff --git a/.nstack/check-modules.sh b/.nstack/check-modules.sh new file mode 100755 index 0000000..302a23d --- /dev/null +++ b/.nstack/check-modules.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# The standard verbs of every changed module, one module after another, in the one CI job the +# project's ruleset requires: `Module checks` (.nstack/handbook/09-platform.md §2). +# +# nstack lists the modules with a file changed since BASE, and both sides of a contract version +# the change touches (.nstack/handbook/03-contracts.md §5). For each one: bootstrap, check, test; +# then compat, even after a failure, so that a broken frozen version is named in the same round +# (.nstack/handbook/03-contracts.md §4); then e2e, on a module still green; then clean, on a +# self-hosted runner only, even after a failure — a hosted machine is thrown away after the job. +# A module that fails does not stop the next one; the job fails at the end, naming them. +# +# The module names come from the paths the change touched: they reach the commands as variables, +# never as script text. The criticality is printed, never branched on: what a value requires is +# judged by the rules that read the matrix of .nstack/handbook/05-workflow.md §7. +set -uo pipefail + +BASE=${BASE:?the commit the change is compared with} +if ! git rev-parse --verify --quiet "$BASE^{commit}" >/dev/null; then + if [ "${GITHUB_EVENT_NAME:-}" = pull_request ]; then + echo "::error::Base $BASE of the pull request not found: its modules cannot be listed." \ + "Action: run the jobs again; the checkout fetches the whole history." + exit 1 + fi + BASE=$(git rev-list --max-parents=0 HEAD | tail -1) # a branch's first push: every file is new +fi + +LIST=$(nstack modules --root . --changed-since "$BASE" --with-contract-sides) || exit 1 +if [ -z "$LIST" ]; then + echo "No module with a file changed: nothing to check." + exit 0 +fi + +FAILED=() +while IFS=$'\t' read -r MODULE FOLDER <&3; do + echo "::group::$MODULE" + VALUE=$(sed -n "s/^ criticality: *['\"]\{0,1\}\([a-z]*\).*/\1/p" "$FOLDER/MANIFEST.yaml" | head -1) + echo "Criticality: ${VALUE:-undeclared}" + case "$VALUE" in + prototype|standard|high|critical) ;; + *) echo "Not a value the engine knows: judged as critical until M3 is satisfied." ;; + esac + GREEN=1 + { nstack bootstrap "$MODULE" && nstack check "$MODULE" && nstack test "$MODULE"; } || GREEN=0 + nstack compat "$MODULE" --base "$BASE" || GREEN=0 + if [ "$GREEN" = 1 ]; then nstack e2e "$MODULE" || GREEN=0; fi + if [ "${RUNNER_ENVIRONMENT:-}" = self-hosted ]; then nstack clean "$MODULE" || GREEN=0; fi + echo "::endgroup::" + [ "$GREEN" = 1 ] || FAILED+=("$MODULE") +done 3<<<"$LIST" + +if [ "${#FAILED[@]}" -gt 0 ]; then + echo "Module checks failed: ${FAILED[*]}. Each one's log group above names the verb and its output." + exit 1 +fi +echo "Every changed module passed." diff --git a/.nstack/fitness-before-push.sh b/.nstack/fitness-before-push.sh new file mode 100755 index 0000000..004cd55 --- /dev/null +++ b/.nstack/fitness-before-push.sh @@ -0,0 +1,130 @@ +#!/bin/sh +# Before a push, the fitness functions CI runs on every pull request: the pre-push hook of +# .pre-commit-config.yaml. Judged by an engine at the project's version or ahead of it, never +# behind: an older engine refuses what the project's version defines, and can pass what it +# refuses. An engine ahead is where an update starts. A project pinned to an unpublished commit +# (vX.Y.Z-N-g) is ahead of vX.Y.Z: an engine behind that is refused; one at it or ahead +# judges, and every run of nstack says what it is. A version this cannot read — no answers +# file, a pre-release — leaves the judging to the engine here, as before, and to CI. +# +# Plain sh, with sed and awk: the workstation's engine may predate this file. +# What nstack records beside the code — a hold's event (claim, unclaim, deliver) on +# refs/heads/nstack/hold/…, an attested record in refs/notes/nstack/… — moves no file of the +# project: a red default branch never stops it being recorded (#427). Every other hook still +# runs on it, and CI judges every pull request. +# In an agent's session (nstack agent run), nothing is pushed under another identity than the +# agent's own (#456): a commit git made up from the machine would publish its user and host name. +# Read: every commit of the local branches and tags, and of the ref pushed, that the remote does not +# hold yet — pre-commit names only the first ref of a push of several. What a fetch brought — the +# remote-tracking branches, the attested records fetched beside them, and what nstack claim fetched +# under refs/nstack-remote/ (the default branch, holds, work branches) — is the remote's already (#484). +# A merge of the forge's can still reach here through no such ref: a merge of main made in another +# clone and fetched into FETCH_HEAD, origin/main stale. Before refusing, the hook fetches the default +# branch of the remote it pushes to into refs/nstack-remote/base, as claim does, and counts again: +# a clean push fetches nothing; no remote-tracking branch of the person's moves, nor FETCH_HEAD. +if [ -n "${NSTACK_AGENT:-}" ]; then + MINE=$(git config --global user.email) + NAME=$(git config --global user.name) + if [ -z "$MINE" ] || [ -z "$NAME" ]; then + echo "FAIL [nstack] agent ${NSTACK_AGENT} declares no identity in its own git configuration: nothing is pushed." + echo " Action: nstack agent run ${NSTACK_AGENT} -- writes it; then amend the commits' author." + exit 1 + fi + FROM="" + case "${PRE_COMMIT_FROM_REF:-}" in ""|*[!0]*) FROM=${PRE_COMMIT_FROM_REF:-} ;; esac + foreign() { + git log --format='%ae%x09%ce%x09%an%x09%cn' --branches --tags ${PRE_COMMIT_TO_REF:+"$PRE_COMMIT_TO_REF"} \ + --not --remotes --glob='refs/nstack-remote/*' --glob='refs/notes/nstack-remote/*' ${FROM:+"$FROM"} 2>/dev/null | + awk -F '\t' -v me="$MINE" -v name="$NAME" '$1 != me || $2 != me || $3 != name || $4 != name' | wc -l | tr -d ' ' + } + COUNT=$(foreign) + FETCHED="" + if [ "${COUNT:-0}" -gt 0 ] && GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-ssh} -o BatchMode=yes" \ + git fetch --quiet --no-tags --no-write-fetch-head "${PRE_COMMIT_REMOTE_NAME:-origin}" \ + "+HEAD:refs/nstack-remote/base" /dev/null 2>&1; then + FETCHED=yes + COUNT=$(foreign) + fi + if [ "${COUNT:-0}" -gt 0 ]; then + echo "FAIL [nstack] ${COUNT} commit(s) the remote does not hold yet are not agent ${NSTACK_AGENT}'s identity" + echo " ($NAME <$MINE>) as author or committer: pushed, they would publish another — this machine's" + echo " user and host, or a person's name." + echo " Action: the agent's own commits under a made-up identity: git rebase --exec 'git commit --amend" + echo " --no-edit --reset-author' . Another's work brought here keeps its author: it is" + echo " pushed from that person's own session, never re-signed. Commits the remote already holds" + if [ -n "$FETCHED" ]; then + echo " (a merge made on the forge) are never re-signed either: this hook fetched the remote's" + echo " default branch already; a merge on another branch of the forge: git fetch, then push again." + else + echo " (a merge made on the forge) are never re-signed either: git fetch, then push again." + fi + echo " Why: .nstack/handbook/INSTALL.md, *The agent commits as the App*." + exit 1 + fi +fi +case "${PRE_COMMIT_REMOTE_BRANCH:-}" in + refs/heads/nstack/hold/*|refs/notes/nstack/*) echo "nstack's own record: no file of the project to judge."; exit 0 ;; +esac +# A commit naming an Agent-Session that git does not read as a trailer — above a blank line, apart +# from Co-Authored-By — names no session, and pr-check says so only after the push. The commit-msg +# hook refuses it at the commit, but git never runs that hook on a rebase or a cherry-pick (#521): +# the ref pushed is read here, for anyone — pre-commit names the first of several; CI's T2 reads the +# rest. What the remote holds already is not the push's (a forge's squash keeps each message above its +# co-authors); fetched first, as above, before refusing. A ref with no ancestor on the remote comes +# without TO_REF: its local branch is read. +TIP=${PRE_COMMIT_TO_REF:-${PRE_COMMIT_LOCAL_BRANCH:-HEAD}} +START="" +case "${PRE_COMMIT_FROM_REF:-}" in ""|*[!0]*) START=${PRE_COMMIT_FROM_REF:-} ;; esac +unread() { + git log --format=%H -i -E --grep='^agent-session[[:blank:]]*:' "$TIP" \ + --not --remotes --glob='refs/nstack-remote/*' ${START:+"$START"} 2>/dev/null | + while read -r commit; do + [ -n "$(git log -1 --format='%(trailers:key=Agent-Session,valueonly)' "$commit")" ] || + git log -1 --format=' %h %s' "$commit" + done +} +UNREAD=$(unread) +REFETCHED="" +if [ -n "$UNREAD" ] && GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-ssh} -o BatchMode=yes" \ + git fetch --quiet --no-tags --no-write-fetch-head "${PRE_COMMIT_REMOTE_NAME:-origin}" \ + "+HEAD:refs/nstack-remote/base" /dev/null 2>&1; then + REFETCHED=yes + UNREAD=$(unread) +fi +if [ -n "$UNREAD" ]; then + echo "FAIL [nstack] $(printf '%s\n' "$UNREAD" | wc -l | tr -d ' ') commit(s) name an Agent-Session git does not read as a trailer:" + printf '%s\n' "$UNREAD" + echo " Its line is not in the message's last paragraph: git reads no session, and pr-check refuses it." + echo " Action: put Agent-Session with Co-Authored-By and any other trailer, one block, no blank line" + echo " between them — git rebase -i , \`reword\` on each; on the last commit alone," + echo " git commit --amend. Why here: a rebase or a cherry-pick never runs the commit-msg hook that" + echo " refuses it at the commit." + if [ -n "$REFETCHED" ]; then + echo " A commit the remote holds — a merge made on the forge — is never rewritten: this hook fetched" + echo " the remote's default branch already; one of another branch of the forge: git fetch, then push again." + else + echo " A commit the remote holds — a merge made on the forge — is never rewritten: git fetch, then push again." + fi + exit 1 +fi + +command -v nstack >/dev/null 2>&1 || { echo "nstack is not installed: CI judges"; exit 0; } + +RECORDED=$([ -f .copier-answers.yml ] && tr -d '\r' < .copier-answers.yml | + sed -n "s/^_commit: *['\"]\{0,1\}\(v[0-9]*\.[0-9]*\.[0-9]*\(-[0-9]*-g[0-9a-f]*\)\{0,1\}\)['\"]\{0,1\} *$/\1/p") +WANTED=${RECORDED%%-*} +WANTED=${WANTED#v} +HERE=$(nstack --version | sed -n 's/^nstack \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p') +if [ -n "$WANTED" ] && [ -n "$HERE" ] && awk -v here="$HERE" -v wanted="$WANTED" 'BEGIN { + split(here, h, "."); split(wanted, w, ".") + for (i = 1; i <= 3; i++) { if (h[i] + 0 < w[i] + 0) exit 0; if (h[i] + 0 > w[i] + 0) exit 1 } + exit 1 }'; then + echo "FAIL [nstack] This workstation runs nstack $HERE; the project is on $RECORDED. Its rules are not" + echo " the project's: it would refuse what $RECORDED defines, and could pass what it refuses." + echo " Action: bash .nstack/install-engine.sh # the version the project records, then push again" + exit 1 +fi + +for check in manifests boundaries plan hygiene; do + nstack "$check" --root . || exit 1 +done diff --git a/docs/adr/_TEMPLATE.md b/.nstack/forms/adr.md similarity index 80% rename from docs/adr/_TEMPLATE.md rename to .nstack/forms/adr.md index a401ad8..e8bdadb 100644 --- a/docs/adr/_TEMPLATE.md +++ b/.nstack/forms/adr.md @@ -1,5 +1,7 @@ # ADR-XXXX — +> The framework's words: `.nstack/handbook/glossary.md`. + - **Status**: Proposed | Accepted | Superseded by ADR-YYYY | Abandoned - **Date**: YYYY-MM-DD - **Decision makers**: @@ -28,7 +30,7 @@ budget, deadline, compliance. Distinguish real constraints from preferences.> ## Prior art > **Mandatory section.** Minimum two named references. A missing section or a missing -> reference → refused in review, pending an automated check. (`docs/os/06-decisions.md` §2) +> reference → refused in review, pending an automated check. (`.nstack/handbook/06-decisions.md` §2) **Dominant convention of the field:** @@ -64,6 +66,8 @@ are not acceptable justifications.> ## Decision + + @@ -85,6 +89,12 @@ description: the argument that settled it.> What we do if it is not: + + --- ## Consequences @@ -96,7 +106,7 @@ What we do if it is not: **Impacts on other modules or contracts:** **Rule to automate:** +none is possible, explain why. `.nstack/handbook/07-governance.md` §2> --- diff --git a/docs/project/_CHARTER_TEMPLATE.md b/.nstack/forms/charter.md similarity index 68% rename from docs/project/_CHARTER_TEMPLATE.md rename to .nstack/forms/charter.md index 7a9188d..b932192 100644 --- a/docs/project/_CHARTER_TEMPLATE.md +++ b/.nstack/forms/charter.md @@ -7,11 +7,15 @@ success_criteria: # when the goal is reached: measurable, dated or r # Charter — -> Written once, at the first framing (`playbooks/framing.md`), copied to `charter.md`; +> The framework's words: `.nstack/handbook/glossary.md`. + +> Written once, at the first framing (`.nstack/playbooks/framing.md`), copied to `docs/project/charter.md`; > changed only through a PDR. Every agent session reads it. ## Users and their problem + + ## Success criteria @@ -40,4 +44,6 @@ success_criteria: # when the goal is reached: measurable, dated or r **Blocking:** -**Not blocking:** +Once it is accepted, this charter holds no open question: one that arrives goes to the +current cycle's questions, and an answer that changes the charter is a PDR, which the change +cites (`.nstack/playbooks/framing.md`, *Decisions*). diff --git a/.nstack/forms/cycle.md b/.nstack/forms/cycle.md new file mode 100644 index 0000000..2b3d8a0 --- /dev/null +++ b/.nstack/forms/cycle.md @@ -0,0 +1,76 @@ +--- +goal: "" +status: proposed # proposed | accepted | closed | stopped — the decider accepts +appetite_weeks: 2 # the time the decider WANTS to spend, not an estimate — appetite_days: N instead, never both, for a cycle shorter than a week +start: 2026-01-05 # YYYY-MM-DD +end: 2026-01-19 # start + appetite: the first day the cycle is over — the circuit breaker +# accepted_on: YYYY-MM-DD # accepted while another cycle runs: stays proposed, the running cycle's closure starts it; kept once accepted +deliverables: + - id: D1 + title: "" + module: "" # null for a spike run outside the code, or whose product is a record, not shipped code + state: proposed # proposed | ready (testable criteria) | in-progress (older, still read) | accepted (at the closure: nstack deliver --write-states) | deferred | dropped — held and delivered are read from records, never written + acceptance: # given · when · then, required from ready on: the test sheet starts here + - "Given , when , then " +# outcome: completed # closed: completed | shipped — stopped: reframed | stopped +# ended_on: YYYY-MM-DD +# success: # at the closure, the charter's success criteria this cycle moved, if any +# - criterion: 1 # its number in the charter's list, from 1 +# state: observing # met | observing — the latest closure's record is its state +# since: YYYY-MM-DD # observing: the day observation started +--- + +# Cycle NN — + +> The framework's words: `.nstack/handbook/glossary.md`. + +> Copied to `docs/project/cycles/NN-<slug>.md` at framing (`.nstack/playbooks/framing.md`). One accepted cycle at a +> time; no automatic extension. + +## Goal + +<Why this outcome, now.> + +## Deliverables + +One section per deliverable, under its identifier: a session reads the front matter and its +own deliverable's section, never the others. What binds goes here — order, dependencies, its +decisions and their links; what was tried, what it cost and what was refuted goes to the +project's log issue (`.nstack/handbook/06-decisions.md` §9). + +### D1 + +<What binds this deliverable that the front matter cannot hold.> + +## What needs a person + +<What only a person can do in this cycle: a trial, a word, a gesture. `nstack plan` opens with it and stops +showing a row once its deliverables are done: never delete one by hand. Everything else, agents carry. +At framing, delete the rows you do not need.> + +| Deliverable | Who | The literal gesture | +|---|---|---| +| <D1> | <who> | <the literal gesture> | + +## Out of scope + +<Not done in this cycle, even if time remains.> + +## Later + +<Candidates for the next framing: what framing left out, and ideas that came up during the +cycle.> + +## Open questions + +**Blocking:** <none left once the cycle is accepted> + +**Not blocking:** + +## Closure + +<Written at the end: what was delivered, which success criteria moved, what was deferred, +where the next framing starts.> + +**Documents brought current:** <the front page, the module map, a module's page — each with +its pull request; or "none", and why nothing a reader sees has changed> diff --git a/docs/project/_DISCOVERY_TEMPLATE.md b/.nstack/forms/discovery.md similarity index 95% rename from docs/project/_DISCOVERY_TEMPLATE.md rename to .nstack/forms/discovery.md index 4734528..e14df13 100644 --- a/docs/project/_DISCOVERY_TEMPLATE.md +++ b/.nstack/forms/discovery.md @@ -9,7 +9,9 @@ round: 1 # Discovery -> Started by the engine's `discover` command, run by your agent (`playbooks/discovery.md`). +> The framework's words: `.nstack/handbook/glossary.md`. + +> Started by the engine's `discover` command, run by your agent (`.nstack/playbooks/discovery.md`). > One document, a decision at the end of each round. ## 1. Intake diff --git a/docs/pdr/_TEMPLATE.md b/.nstack/forms/pdr.md similarity index 80% rename from docs/pdr/_TEMPLATE.md rename to .nstack/forms/pdr.md index 348e061..0c277c9 100644 --- a/docs/pdr/_TEMPLATE.md +++ b/.nstack/forms/pdr.md @@ -1,5 +1,7 @@ # PDR-XXXX — <short, user-oriented title> +> The framework's words: `.nstack/handbook/glossary.md`. + - **Status**: Proposed | Accepted | Superseded by PDR-YYYY | Abandoned - **Date**: YYYY-MM-DD - **Decision makers**: @@ -32,7 +34,7 @@ prevents gradual drift.> ## Prior art > **Mandatory section.** Minimum two named references. -> (`docs/os/06-decisions.md` §2) +> (`.nstack/handbook/06-decisions.md` §2) **How is this problem solved elsewhere?** @@ -67,6 +69,8 @@ knowing it.> ## Expected behaviour +<A diagram of the journey, with its legend, when there is more than one step. Otherwise delete this line.> + **Nominal journey:** **Edge cases and degraded states:** @@ -76,7 +80,7 @@ knowing it.> **Permissions:** <who can do what> **Acceptance criteria** *(testable — this is the task's oracle, -`docs/os/05-workflow.md` §3)*: +`.nstack/handbook/05-workflow.md` §3)*: - [ ] Given <context>, when <action>, then <observable result> - [ ] … @@ -88,7 +92,7 @@ knowing it.> > Fill this in only when the feature is genuinely complex: many actors, a state machine, > a permission matrix. Otherwise, delete this section. > -> It replaces the old FDR format (`docs/os/06-decisions.md` §4). +> It replaces the old FDR format (`.nstack/handbook/06-decisions.md` §4). **Actors:** **States and transitions:** @@ -109,6 +113,12 @@ How it is observed: <metric, user feedback, usage> If the criterion is not met: <adjust · supersede · remove> +<!-- Read at each cycle's closure that names it, or that reaches a date of this criterion: a + cycle by its file (03-the-window) or as "cycle 03", a date written in bold, **YYYY-MM-DD** + — a plain date, an amendment's or a reference's, is not read. The plan warns until a line + of its own says it (C10): +Read at <cycle>'s closure, <YYYY-MM-DD>: met | missed | superseded --> + --- ## Removal condition diff --git a/.nstack/forms/rules.md b/.nstack/forms/rules.md new file mode 100644 index 0000000..0d95740 --- /dev/null +++ b/.nstack/forms/rules.md @@ -0,0 +1,12 @@ +# Rules of this project — <subject: the name of a playbook, or "always"> + +> Copied to `docs/project/rules/<subject>.md` the day the project has a rule of its own on that +> subject: `security.md` is read with the security playbook, `always.md` with the charter, for +> every task. These rules add to what every project shares, or tighten it; they never repeat +> it. A rule that concerns one module only belongs in that module's `AGENTS.md`. + +<A diagram, with its legend, when the rules describe a flow or a boundary. Otherwise delete this line.> + +| # | Rule | Why | Checked by | +|---|---|---|---| +| 1 | <What must always happen, or never.> | <A constraint of the charter, a decision, an incident — with its date.> | <A test, a check, a review. "Nobody yet" is an answer, and a debt.> | diff --git a/docs/os/00-overview.md b/.nstack/handbook/00-overview.md similarity index 61% rename from docs/os/00-overview.md rename to .nstack/handbook/00-overview.md index 9295529..6a45cc0 100644 --- a/docs/os/00-overview.md +++ b/.nstack/handbook/00-overview.md @@ -28,7 +28,7 @@ flowchart TB K1["5 laws"] K2["Working loop"] K3["Stopping rules"] - K4["Uncertainty<br/>protocol"] + K4["Stop · Hold · Close"] end subgraph L1["PLAYBOOKS — loaded by trigger"] @@ -139,47 +139,65 @@ delivery: it lengthens the queue and degrades the quality of the review itself. ### What the framework cannot know: three levels of rules -| Level | Holds | Maintained by | -|---|---|---| -| **Framework** — identical in every project, received through updates | Postures, the five laws, the working loop, stopping rules, framing, the test discipline, templates, checks | The framework | -| **Project** | Users, problem, constraints, success criteria, cycles, the project's decisions, its tools | The foundation team and the decider: `docs/project/`, `docs/adr/`, `docs/pdr/`, `docs/tooling-profile.md` | -| **Module** | Its capability, commands, contracts, scenarios | Its owner: `MANIFEST.yaml`, local `AGENTS.md` | +```mermaid +flowchart LR + F["FRAMEWORK<br/>what every project shares<br/><i>No secret in the repository</i>"]:::fw + P["PROJECT<br/>what this project adds<br/><i>Health data never leaves the EU</i>"]:::pr + M["MODULE<br/>what this module adds<br/><i>The card number is never logged</i>"]:::mo + F -->|"completed by"| P -->|"completed by"| M + + classDef fw fill:#374151,color:#fff + classDef pr fill:#1e3a8a,color:#fff + classDef mo fill:#065f46,color:#fff +``` + +**Legend** — grey: received through updates, the same everywhere · blue: written by the +project, read by every session that works in it · green: written by a module's owner, read +only by who works in that module. In italics, one rule of each level on one subject, security. + +| Level | Holds | Written in | Maintained by | +|---|---|---|---| +| **Framework** — identical in every project | Postures, the five laws, the working loop, stopping rules, framing, the test discipline, templates, checks | The kernel and `.nstack/playbooks/` | The framework, through updates | +| **Project** | Users, problem, constraints, success criteria, cycles, its decisions, its tools — and **its own rules** on any subject a playbook covers | `docs/project/`, `docs/adr/`, `docs/pdr/`, `.nstack/tooling-profile.md` — its rules in `docs/project/rules/` | The foundation team and the decider | +| **Module** | Its capability, commands, contracts, scenarios, its invariants and its traps | `MANIFEST.yaml`, the module's `AGENTS.md` | Its owner | + +**A nearer level adds or tightens; it never repeats.** A project's rule on security is read +*with* the security playbook, not instead of it: `docs/project/rules/security.md`, loaded by +the same trigger. `docs/project/rules/always.md` holds the few that apply to every task. The +folder is empty at creation, and each file is born the day a constraint, a decision or an +incident gives it a first line — as early as a discovery's intake, where a project settles +the language it writes in. **The framework never names a stack, a tool or a business domain.** A project rule is written in a project document, never in the kernel or a playbook: the framework's files keep merging cleanly at every update. +### Method and seat: whose file it is + +Every file the framework writes into a project is one of two things, never both. + +| | Method | Seat | +|---|---|---| +| **Whose** | The framework's | The project's | +| **At creation** | Written whole | Written as a form: headings, and the place of a diagram | +| **At an update** | Merged | Never touched again — recreated only when missing; `SECURITY.md` rewritten when the forge changes, the project's text merged in | +| **Which** | Everything else: the kernel, the playbooks, this handbook, the templates, the checks | `README.md`, `SECURITY.md`, `modules/README.md`, `docs/adr/README.md`, `docs/pdr/README.md` | + +A file holding the framework's words *and* waiting for the project's belongs to nobody: the +project does not delete what looks official, and an update conflicts on what the project +wrote. So a seat carries no manual, and the manual sits in no seat. What each one holds, +when it becomes writable and what keeps it current: `06-decisions.md` §10. + --- ## 6. Glossary -These terms have a precise meaning in the OS. Using them differently creates ambiguity. - -| Term | Definition | -|---|---| -| **Module** | An autonomous unit of context and of parallelism: a developer or an agent must be able to understand it, change it, test it and validate it **without understanding the rest of the system**. It can be a package, an application, a service or a repository. | -| **Playbook** | A module of *instructions* for an agent, loaded on demand (`playbooks/`). Called a "playbook" rather than a "module" to avoid any confusion with the line above. | -| **Skeleton** | The project's shared files — kernel, playbooks, this handbook, CI, hooks, templates — generated by the engine; the project owns them and adapts them. | -| **Engine** | The versioned tool that generates the skeleton, updates it and runs the checks; named in `docs/tooling-profile.md`. | -| **Contract** | A versioned, tested interface between two modules: API, event, schema, message. The **only** channel of inter-module communication allowed. | -| **Manifest** | A declarative file at the root of every module: identity, owner, criticality, status, contracts provided and consumed, standard commands. The machine-readable source of truth. | -| **Oracle** | A task's *executable* success criterion, written and seen failing **before** generation: a test, a contract test, or a fitness function. | -| **Fitness function** | An automated test that fails when the architecture drifts (forbidden dependency, cycle, coupling, performance budget). Governance by rule rather than by inspection. | -| **Review budget** | An explicit ceiling per pull request (lines, files, modules touched) that forces the split **before** generation. | -| **Prior Art Gate** | The mandatory procedure before a structuring decision: identify the convention of the field, adopt it by default, deviate only against an observable user value. | -| **Expand / Contract** | The sequence of pull requests that lets a contract evolve between teams without temporal synchronisation. | -| **ADR / PDR** | Architecture / Product Decision Record. A durable trail of a structuring decision. | -| **Appetite** | The calendar time the decider chooses to spend on a cycle — not an estimate. It sets the cycle's end date. | -| **Charter** | The project's founding document: users, problem, constraints, success criteria, out of scope (`docs/project/charter.md`). | -| **Circuit breaker** | A cycle's end date: past it, delivery work stops and the decider chooses — ship, re-frame or stop. No automatic extension. | -| **Cycle** | A bounded unit of work: one goal, a finite list of deliverables, an appetite, an end. | -| **Deliverable** | An outcome a user can observe, with acceptance criteria, in one module. | -| **Discovery** | An idea tested before any charter: sourced evidence, a value hypothesis, a challenge by another session, then go, clarify or kill (`docs/project/discovery.md`). | -| **Posture** | What a participant does, and never does: framer, challenger, author, verifier, approver, decider, owner (`05-workflow.md` §10). | -| **Test sheet** | The scenarios of a change, written before the code and run by a verifier who is not the author, each with its evidence (`05-workflow.md` §7). | +The framework's words — who, the work, modules and contracts, rules, records — each in one plain +sentence, with where you meet it and an example: [`glossary.md`](glossary.md). A rule's code is +explained in [`RULES.md`](RULES.md). > **Note.** The **FDR** (Functional Design Record) format does not exist in this OS. It -> overlapped the PDR and an issue's acceptance criteria without adding distinct value. +> overlapped the PDR and a deliverable's acceptance criteria without adding distinct value. > For genuinely complex cases, it becomes an **optional section of the PDR**. > Justification: `06-decisions.md` § "Why only two formats". diff --git a/docs/os/01-principles.md b/.nstack/handbook/01-principles.md similarity index 100% rename from docs/os/01-principles.md rename to .nstack/handbook/01-principles.md diff --git a/docs/os/02-modules.md b/.nstack/handbook/02-modules.md similarity index 92% rename from docs/os/02-modules.md rename to .nstack/handbook/02-modules.md index 9bf2a63..4d993d1 100644 --- a/docs/os/02-modules.md +++ b/.nstack/handbook/02-modules.md @@ -29,7 +29,7 @@ started, tested, validated and shipped. flowchart TB subgraph P["PLATFORM — uniform, imposed, versioned"] direction LR - P1["Standard verbs<br/>bootstrap · check · test<br/>run · migrate · release"] + P1["Standard verbs<br/>one list: 09-platform.md §2"] P2["File envelope<br/>MANIFEST · AGENTS.md<br/>README · docs/ · tests/"] P3["Mandatory checks<br/>identical everywhere"] P4["Issue / PR templates<br/>DoR · DoD"] @@ -141,11 +141,15 @@ modules/<name>/ ├── README.md ← for humans: what it is for, how to start ├── docs/ │ ├── adr/ ← local technical decisions -│ └── runbook.md ← when the module is operated in production +│ └── runbook.md ← criticality high or critical (05-workflow.md §7) ├── src/ └── tests/ ``` +M9 refuses a module without `AGENTS.md`, `README.md` or, unless it is a prototype, `tests/`; +M8 asks for the runbook at criticality high or critical. The rest is where things go when +the module has them. + The contracts a module provides live in the project's `contracts/` module, one folder per contract and version (`03-contracts.md` §2), and its manifest points at them (`provides[].path`). @@ -165,7 +169,7 @@ This is the piece that makes multi-team work operational. A single declarative f readable by a human, by an agent **and by CI**. The manifest `nstack new-module` writes is the reference for the full format; -`contracts/MANIFEST.yaml` is the one every project already holds. It declares: +`contracts/MANIFEST.yaml`, written by the first contract, is another. It declares: - identity and responsibility in one sentence; - owner (a team, not an individual); @@ -189,7 +193,7 @@ flowchart LR MF --> U2["FITNESS FUNCTION<br/>declared graph vs real graph<br/>extracted from the code<br/>→ any gap is a violation"] - MF --> U3["COORDINATION<br/>a producer/consumer matrix<br/>is generated → you always<br/>know who breaks whom"] + MF --> U3["COORDINATION<br/>nstack modules names both sides<br/>of a contract → you always<br/>know who breaks whom"] U2 --> CI["CI: blocking check"] U3 --> CI @@ -269,8 +273,8 @@ violation becomes an architecture signal. visible, traced and counted. A module is touched when its behaviour changes: editing only its description — manifest, -`AGENTS.md`, `README.md`, `docs/` — touches none, and `contracts/` is a module like the -others. +`AGENTS.md`, `README.md`, `docs/` — touches none, unless the manifest moves its criticality or +its user-visible surface, and `contracts/` is a module like the others. | Exception | Handling | |---|---| @@ -325,6 +329,10 @@ forbidden paths. - business logic shared between distinct domains; - a shared database without a justifying ADR. +**Allowed, declared:** another module's release artefacts — what its `release` wrote in its +folder of `dist/` — read by the module that assembles what ships, which names it in +`assembles` (`09-platform.md` §2). Its artefacts, never its code. + **Allowed but worth watching:** shared technical primitives (logging, errors, utilities with no business logic). As soon as a business rule enters a shared package, two modules become inseparable. They live outside the module folders: a module never imports another diff --git a/docs/os/03-contracts.md b/.nstack/handbook/03-contracts.md similarity index 74% rename from docs/os/03-contracts.md rename to .nstack/handbook/03-contracts.md index 4166ec7..40f8c9a 100644 --- a/docs/os/03-contracts.md +++ b/.nstack/handbook/03-contracts.md @@ -21,6 +21,12 @@ cannot be orphaned. Like any module it therefore has an owner, a manifest, its own tests, its own rules of change, and a high criticality by default. +**It does not exist before the first contract.** A project with one module, or with modules +that do not talk to each other yet, has no boundary to write down. The command that creates +a contract creates the module the first time — manifest, owner, runbook — and a page for the +contract's first version; the module stays green on pages alone, and owes its `check` and +`test` commands the day a contract gains a schema or a test. + **Properties required of a contract:** | Property | Verification | @@ -80,6 +86,15 @@ from seconds to milliseconds, a nullable field that becomes always filled. Techn compatible, functionally breaking. These are the most expensive breakages because no diff tool detects them — only contract tests do. +**A comparator guards the consumers, not the shape.** It judges a version's schema: an +addition is compatible, and a wrong field inside that addition is too. What a version says +exactly — the event it emits, its fields' values — is held by the version's own tests. Nor +does it read the contract's page: a promise written there — "never says how loud" — can be +reversed by an addition it calls compatible. The diagram's first question decides it: a +consumer that relied on the promise makes the change breaking; when none does, it stays +additive and the page is corrected. A person catches it in review: the pull request's +Contracts section names the promise it changes. + --- ## 4. Expand / Contract @@ -122,10 +137,31 @@ sequenceDiagram | **3 — Migration** | Each consumer | Switches to v2, at its own pace | Manifest updated: version consumed | | **4 — Contract** | Producer | Removal of v1 | v1 consumers = 0, checked (B6) | +**The order holds for a version's name too.** B1 reads a version named in a consumer's files +as that version consumed, and B6 refuses a consumer declared before its producer: a consumer +that names v2 before step 1 is merged — even in a test that shows v2 refused — fails B1 in +every pull request, and cannot declare it. Write the name after step 1. + +**Declaring a version is not writing it.** Where a consumer must read a format before its +producer writes it — a file, a message, anything already stored — two modules still have an +order, in separate pull requests, within the four steps above: + +- first the producer declares v2 in its `provides`, the page beside it and v1's removal date + set, and goes on writing v1; +- then the consumer declares v2 beside v1, and reads both; +- last the producer writes v2. + +Each step passes B1 and B6 on its own: no consumer names a version before it is declared, and +nothing asks both manifests in one pull request. + +**A test that a consumer refuses a later version** names one that will never be declared — +`minutes/vnext` — never the next number. B1 reads any declared version a module names, refused or not: a +test naming `minutes/v3` fails the producer's declaration of v3, and costs the consumer a pull request of its own. + ### The three guardrails **① The deprecation date is a check.** From PR 1 onwards, v1 carries a removal date. A -check fails once the date has passed and consumers remain. Without it, you accumulate +check fails once the date has passed while the version is still provided (M6). Without it, you accumulate versions nobody dares remove. **② The contraction is mandatory.** Step 4 is the most often forgotten, and it is @@ -185,8 +221,9 @@ without a meeting. ## 6. Discovery and traceability -The producer/consumer matrix is **generated** from the manifests, never kept by hand. It -answers three questions no team should have to ask in a meeting: +Who provides and who consumes a contract is read from the manifests, never kept by hand: +`nstack modules --with-contract-sides` names both sides of a changed version, and B6 refuses a +version consumed and provided by nobody. Together they answer three questions no team should have to ask in a meeting: - Who consumes my contract, and in which version? - What does my module consume, and which versions are deprecated? diff --git a/docs/os/04-ai-context.md b/.nstack/handbook/04-ai-context.md similarity index 76% rename from docs/os/04-ai-context.md rename to .nstack/handbook/04-ai-context.md index ac765ad..8417b3a 100644 --- a/docs/os/04-ai-context.md +++ b/.nstack/handbook/04-ai-context.md @@ -25,21 +25,10 @@ organise deployment. flowchart TD T["Incoming task"] --> S{"Scope<br/>identifiable?"} S -->|No| S2["Clarify, or state<br/>an explicit assumption"] --> S - S -->|Yes| U["Load: the kernel<br/>+ the module's AGENTS.md and MANIFEST"] - - U --> N{"Playbooks<br/>triggered?"} - N -->|"authn · secrets · personal data"| N1["+ security.md"] - N -->|"schema · migration"| N2["+ data-migration.md"] - N -->|"user-facing surface"| N3["+ ux.md"] - N -->|"test strategy · flaky"| N4["+ tests.md"] - N -->|"logs · retries · rollback"| N5["+ operations.md"] - N -->|None| V - - N1 --> V["LOCAL inventory:<br/>code, tests, contracts, decisions"] - N2 --> V - N3 --> V - N4 --> V - N5 --> V + S -->|Yes| U["Load in the kernel's §4 order: charter, your cycle section,<br/>project rules, the module's MANIFEST and AGENTS.md"] + + U --> N["+ the playbooks the task triggers:<br/>the kernel's table, §4 — the only list"] + N --> V["LOCAL inventory:<br/>code, tests, contracts, decisions"] V --> W{"Does the change cross<br/>a boundary?"} W -->|No| X["Context frozen<br/>→ oracle, then implementation"] @@ -69,13 +58,16 @@ during implementation is the symptom of a failed framing, not of a useful discov ``` 1. kernel AGENTS.md always ~250 lines -2. the target module's MANIFEST always short -3. the module's local AGENTS.md always ~50-100 lines -4. triggered playbook(s) conditional 1 to 2 at most -5. relevant local code and tests targeted not the whole module -6. contracts consumed targeted the contract, not the implementation -7. ADR/PDR tied to the area changed when they exist -8. another module NEVER without an explicit crossing +2. the charter; of the current cycle, always docs/project/ — the cycle's front matter + its front matter and your section and your deliverable's section, not the rest +3. the project's own rules always always.md, then <x>.md with playbook <x> +4. the target module's MANIFEST always short +5. the module's local AGENTS.md always ~50-100 lines +6. triggered playbook(s) conditional 1 to 2 at most +7. relevant local code and tests targeted not the whole module +8. contracts consumed targeted the contract, not the implementation +9. ADR/PDR tied to the area changed when they exist +10. another module NEVER without an explicit crossing ``` Before exploring, an agent must be able to answer five questions. If one has no answer, @@ -87,6 +79,17 @@ the problem is the framing, not the context: - Which **decisions** (ADR/PDR) constrain this choice? - What is this task's **oracle**? +**What a command prints is context too.** Run a command in its quiet form when it has one, +and read a long output through what decides — the failures, the summary line. A failure is +read in full: nothing filters out the lines of the error being fixed. The tool that filters +is the workstation's, or one the project names in its rules (`docs/project/rules/`); the +framework requires none. + +**One session, one task.** A session keeps what its earlier tasks needed. When the task +changes — another deliverable, another module — it writes down what the next one needs, +where things stand and what is left, and a fresh session starts from that. A wide search runs +in a separate agent, and only its conclusion comes back (§5). + --- ## 4. Crossing a boundary diff --git a/.nstack/handbook/05-workflow.md b/.nstack/handbook/05-workflow.md new file mode 100644 index 0000000..4213654 --- /dev/null +++ b/.nstack/handbook/05-workflow.md @@ -0,0 +1,476 @@ +# 05 — Workflow + +## 1. The reversal + +The classic workflow is: *understand → code → test → review*. + +With an agent, that workflow collapses for a simple reason: the "code" step no longer +costs anything, so it saturates the steps after it. The project produces, faster, what +nobody has time to verify. + +The OS reverses two things: + +1. **The oracle before the generation.** The success criterion is executable and red + before the first line of code. +2. **The review budget at the entrance.** The size of the batch is constrained *before* + generating, not observed afterwards. + +--- + +## 2. The loop + +```mermaid +flowchart TD + A["Task"] --> B{"Trivial?"} + B -->|Yes| B1["Do it directly<br/>+ local validations"] --> M + + B -->|No| C["FRAME: intent, scope,<br/>out of scope, risks"] + C --> C2["SCOPE: identify THE module,<br/>load the bounded context"] + C2 --> C3["INVENTORY: what exists already,<br/>here and in established tools"] + C3 --> G{"Batch ≤ review<br/>budget?"} + G -->|No| G1["Split it<br/>and start again at framing"] --> C + G -->|Yes| D["ORACLE: write the executable<br/>success criterion — no wait:<br/>the plan goes in the pull request"] + D --> E{"Oracle<br/>executable?"} + E -->|No| E1["Do not generate.<br/>Make the criterion verifiable<br/>or send the framing back"] --> D + E -->|Yes| F["Oracle RED — commit"] + + F --> H["IMPLEMENT the<br/>minimal change"] + H --> I["VALIDATE: actually<br/>run the checks"] + I --> J{"Green?"} + J -->|No| J1{"3rd consecutive<br/>failure?"} + J1 -->|No| H + J1 -->|Yes| J2["STOP — report:<br/>assumption or framing is wrong"] + J -->|Yes| K["SELF-REVIEW the diff:<br/>scope, side effects, regressions"] + + K --> L["DOCUMENT the<br/>sources of truth affected"] + L --> S["SYNC: bring the branch current<br/>before its pull request"] + S --> M["SUMMARISE: done / verified /<br/>assumed / not verified / risks"] + M --> V["VERIFY: a verifier who is not the author<br/>runs the test sheet — when §7 requires one"] + V --> N["Human review + CI"] + N --> Z["CLOSE: once merged and each criterion held,<br/>nstack deliver; the branch is gone —<br/>forge, workstation, worktree"] + + style D fill:#1f2937,color:#fff + style F fill:#1f2937,color:#fff + style J2 fill:#7c2d12,color:#fff + style G1 fill:#7c2d12,color:#fff + style E1 fill:#7c2d12,color:#fff +``` + +**Legend** — dark grey: the oracle, written and seen red before any code · red: stop and +go back · the verification comes from someone other than the author. + +--- + +## 3. The oracle + +> The oracle is a task's **executable** success criterion, written and seen failing +> before the generation. + +Depending on the task it can be: a unit or integration test, a contract test, a fitness +function, a migration check, a performance budget, an accessibility test. + +### Why watch it fail first + +A test that has never been red proves nothing: it may pass because it tests nothing. That +is a particularly frequent failure mode with generated code, where test and +implementation are born together and agree on a shared mistake. + +### When the oracle is impossible + +This is not a marginal case, and it is not an excuse to skip the step. It is a diagnosis: + +| Cause | What to do | +|---|---| +| The acceptance criterion is subjective | Restate it as an observable behaviour | +| The task is exploratory | Requalify it as a *spike*: the deliverable is knowledge, not code. Its criteria name what is recorded and the threshold read against it, and **a refuted result is a delivered one**. A spike that measures a step through an imitation of what that step sends — a request, a file, a prompt — first shows the imitation sends the same, byte for byte, as the step does | +| It waits on someone outside the project | It is a dependency with a date, not a deliverable (`.nstack/playbooks/framing.md`) | +| The area is untestable | Make it testable first — that is a task in its own right | +| The need is vague | Back to framing; it was not *Ready* | + +In every case: **do not generate while waiting**. + +--- + +## 4. The review budget + +This is the most useful quality gate in the OS, because it applies **before** the +generation instead of observing the damage afterwards. + +> The project's real throughput is its verification throughput, not its generation +> throughput. + +The budget is an explicit ceiling, set for the project: its answers `review_budget_lines` and +`review_budget_files`, 400 lines and 15 files by default, read alike by CI and by `nstack attest`, +as the base branch holds them: a pull request never sets the budget it is measured by. The decider +changes them — `nstack config review_budget_lines 600` lays the change on a branch, for a pull +request a human approves; the pull requests after its merge are measured by it. `MAX_LINES` and +`MAX_FILES` in the environment override them for one run; the scope check says which source it took. The default follows SmartBear's study of 2,500 +reviews at Cisco (Cohen, *Best Kept Secrets of Peer Code Review*, 2006): past 200 to 400 lines in one +review, the rate at which a reviewer finds defects drops. A larger budget is the +decider's to choose, knowing that. Adjusting it per module, by criticality, is not automated: it +is in the automation backlog. It covers: + +| Dimension | Indicative ceiling | +|---|---| +| Lines changed (excluding generated and lock files) | ~400 | +| Files touched | ~15 | +| Modules touched | **1** | +| Contracts changed | 1, and a dedicated PR | + +These values are starting points to calibrate, not truths. The principle matters more +than the number: **the batch must be reviewable in one session of attention**. + +`nstack pr-scope` leaves out lock files and generated names (`*.generated.*`, `generated/`, the +skills), and every path the project's `.gitattributes` marks `linguist-generated` (any value but +`false`), which GitHub also folds in its diffs. A tool's output that no name gives away is declared there, as the licence notices a +dependency tool writes; the line that declares it is in the diff a reviewer reads. + +**Going over.** The check reports, it does not block automatically (except for modules +touched, where it does block). A justified overrun — code generation, a mechanical +migration, a mass rename — goes through an explicit label. What matters is that the +overrun is **visible and counted**: the rate of over-budget pull requests is a health +indicator (`10-measurement.md`). + +Never produce a huge pull request simply because the agent can generate a lot of code +quickly. + +**Bringing a branch current before its pull request.** Fetch the default branch and merge it +into yours as the last thing before opening the pull request — and again when the forge +shows a conflict while it waits. Whoever wrote the change settles its conflict in minutes; +whoever approves it finds it too late and has to guess. What is numbered in sequence — a +decision record, a row in a register — takes its number at that moment, not when the work +started: two branches that each took "the next one" on the same morning meet on the same +line. It narrows the window and does not close it: a pull request merged while yours waits +can still conflict with it, and the branch is brought current again by its author. + +**Splitting a change into pull requests that sit on one another.** Each is opened on the +branch of the one before, and each carries its own sheet when the module asks for one. Three +things the forge and the sheet do then, to know before the first merge: + +- merging the first **and deleting its branch** closes the next one, which was opened on it: + merge without deleting, point the next at the default branch, then delete; +- the next one's head moves when the default branch is merged into it, and a sheet is tied to + the commit tested. When that merge brings no file the branch did not already carry, the two + commits hold the same tree and the sheet stands; when it brings one, the automated scenarios + are run again at the new head — unless it changed nothing their modules read (§7); +- a **squash** merge writes the first one's work as a new commit, and the next branch still + carries the old ones: it conflicts with what it already holds. Note the merged branch's last + commit before the branch goes, move the next one onto the default branch, `git rebase --onto + <default> <that commit>`, and push it with `--force-with-lease`: a forced push dismisses an + approval it already had — where the plan has no ruleset to dismiss it, `pr-check` says it + (R1) (`07-governance.md` §7). + +**Up to date before merging** (G22). Two pull requests each green on its own base can turn the +default branch red together — one starts reading what the other starts providing —, so the +ruleset merges a branch only once it carries the default branch: what the checks judged is what +lands. Three habits keep that from costing the team: + +- **update at the last moment**: only the pull request about to merge — reviewed, green — takes + the default branch in; the others wait their turn untouched. One update per merge, not one per + open pull request each time another merges. Where stale approvals are dismissed (G13), the + approval comes after that update, not before it; +- **update by merging the default branch in, never by a rebase**: a rebase rewrites what was + approved; a merge adds one commit that brings the default branch, which the approver reads as + that, and `pr-check`'s R1 counts as covered when it carries nothing of its own. Where stale + approvals are dismissed (G13), GitHub asks the approval again after an update — measured: a + merge of the default branch whose tree equalled the approved head's still dismissed it —; the + approver then reads only what the default branch brought. Where an agent approves, the update is + the last push, and another identity than its pusher's approves it (G21). The squash keeps the + default branch's history one commit per pull request; +- **one merge at a time**, then the next pull request's turn: it takes the default branch in, its + checks run again — where they are attested, `nstack attest` on the updated head, whose status + the ruleset waits for, and which keeps a module's checks while nothing they read moved (§7) — + and it merges. + +**Once merged, a branch is gone.** A merged branch is history, not a place to work: left +there, it is one more name to read past, and one day somebody builds on it. The forge +deletes it at the merge when it is set to (`G16`, `07-governance.md` §7) — a guardrail worth +turning on, and not the whole of it. Whoever merges looks: a merge made from a tool, or from +a worktree, may report the merge and leave the branch; a setting nobody could read may be +off. And the forge knows nothing of a workstation: the local branch and the worktree it was +written in go too, and `git fetch --prune` drops the names of branches that no longer exist. +After a squash the local branch is not an ancestor of the default one, and git refuses to +delete it as unmerged: it is deleted once its pull request is seen merged, not before. A +branch whose pull request was closed without a merge, or that never had one, is not +cleaned up in passing: its author says whether anything on it is still wanted. + +--- + +## 5. The 3-failure circuit breaker + +An agent looping on a fix is almost always treating a framing problem as a code problem. +Without an explicit stopping point it digs — and it digs fast. + +```mermaid +flowchart TD + A["Checks red"] --> B["Attempt 1:<br/>fix the apparent cause"] + B --> C{"Green?"} + C -->|Yes| OK["Carry on"] + C -->|No| D["Attempt 2:<br/>question the diagnosis"] + D --> E{"Green?"} + E -->|Yes| OK + E -->|No| F["Attempt 3:<br/>question the assumption"] + F --> G{"Green?"} + G -->|Yes| OK + G -->|No| H["STOP"] + + H --> H1["Revert the speculative<br/>fixes that piled up"] + H1 --> H2["Report: what was tried,<br/>what is ruled out, which<br/>candidate assumptions remain"] + + style H fill:#7c2d12,color:#fff + style OK fill:#065f46,color:#fff +``` + +**Legend** — green: the loop exits normally · red: the stopping point, and what it +requires. + +The key point is `H1`: **revert the speculative fixes**. Three failed attempts leave +behind code added "to see" that no longer has a justification. Leaving it in place is the +quietest way to accumulate debt. + +--- + +## 6. Definition of Ready + +Do not start a significant task without: + +- [ ] a **deliverable of the current cycle**, ready (`docs/project/`), and held by you — + `nstack claim D<n>` — in a framed project; an unframed one has no cycle, and the seven + lines below are its whole definition of ready +- [ ] a goal understandable without a spoken conversation +- [ ] scope **and out of scope** +- [ ] the target module identified +- [ ] **testable** acceptance criteria +- [ ] known dependencies and contracts +- [ ] important constraints identified +- [ ] an acceptable level of risk + +If a piece of information is missing without being blocking: move ahead with an +**explicitly stated assumption**, which will surface in the closing summary. If it is +genuinely blocking: ask for clarification, once, precisely. + +Out of scope is often neglected although it is the most useful part: it is what prevents +gradual drift and opportunistic refactoring. + +--- + +## 7. Definition of Done + +A task is finished when the **applicable** validations have actually passed. Which ones apply +depends on the module's declared `criticality`. **This table is the only place that says +which** — nothing else in the framework holds a second version of it, and a check that +refuses a change reads it here. + +Each row says who judges it: + +- **machine** — a check in CI fails when it is missing. You cannot forget it, and you cannot + talk your way past it. +- **owed** — no check reads it. It is owed to a human, by name, and a row marked *owed* that + nobody does is a decision the project took in silence. + +The distinction is deliberate. A framework that claims CI verifies a UAT teaches its readers +to stop believing the rest of the table. **E2E is the honest case to look at**: a check can +read that a module declares an end-to-end command; it cannot read that the command runs +end-to-end scenarios rather than the unit suite under another name. A rule a one-line alias +satisfies teaches the alias, so that row is owed to a human. + +| Validation | Judged by | prototype | standard | high | critical | +|---|---|---|---|---|---| +| Oracle green | machine | ✔ | ✔ | ✔ | ✔ | +| Lint, format, types | machine | ✔ | ✔ | ✔ | ✔ | +| Unit tests | machine | ✔ | ✔ | ✔ | ✔ | +| Fitness functions | machine | ✔ | ✔ | ✔ | ✔ | +| A frozen contract version proved compatible (V1) | machine | if there is one | if there is one | if there is one | if there is one | +| Contract tests | owed | if there is a contract | if there is a contract | ✔ | ✔ | +| Test sheet run by a verifier, with evidence | machine | — | if user-facing | ✔ | ✔ | +| Runbook present | machine | — | — | ✔ | ✔ | +| Every scenario re-run at the head commit | machine | — | — | — | ✔ | +| Build | owed | ✔ | ✔ | ✔ | ✔ | +| Integration tests | owed | — | per risk | ✔ | ✔ | +| Security analysis | owed | — | ✔ | ✔ | ✔ | +| Affected documentation up to date | owed | — | ✔ | ✔ | ✔ | +| Accessibility | owed | — | if UI | if UI | ✔ | +| E2E on critical journeys | owed | — | — | ✔ | ✔ | +| Observability added | owed | — | — | ✔ | ✔ | +| Rollback verified | owed | — | — | per risk | ✔ | +| UAT | owed | — | — | as needed | ✔ | +| Post-deployment verification | owed | — | — | per risk | ✔ | + +**Human review is not in this table.** Who must approve a change is not a property of the +code's blast radius but of the project's exposure — how many people depend on it, and what +the forge is able to require, and of what the project answers. It lives in `07-governance.md` +§7: a human code owner — or, where the project answers `approval: agent`, another contributor's +agent for a `prototype` or `standard` module. + +**One round.** The framework asks for **one** sheet, run by **one** verifier who is not an +author. It never asks for a second adversarial round, and no check counts them. A project may +decide to spend more — on a module where it is worth it, recorded in its own ADR — and that is +the project's decision, never a requirement read out of this table. Rounds without a ceiling +are not free: **a late round introduces defects of its own**, in changes nobody had asked for. + +**What separates `high` from `critical`.** At `high` the sheet is required and the verifier is +independent. `critical` adds one machine row, the one that costs: **every scenario re-run at +the head commit** after the last fix — no confirmation stands in for a run. And the owed rows +that `high` leaves to judgement — rollback, UAT, post-deployment verification, accessibility — +become due. A module that holds a key, places an order, moves money or touches someone's +personal data is `critical`; one whose failure costs a day is `high`. + +> **Never write "tests passing" if the tests were not actually run.** It is the gravest +> violation in the system, because it corrupts the one thing everything else rests on. + +### The test sheet + +Reading a diff tells nobody whether the product behaves as needed; an agent reads code as +well as a human. So a pull request that changes a module the table above asks a sheet of — +one a user sees, from `standard` up, and any module of criticality `high` or `critical` — +carries a **test sheet** in its description. Editing +only a module's description — its manifest, `AGENTS.md`, `README.md`, `docs/` — changes no +behaviour and needs no sheet, a framework update included; a manifest that moves the module's +criticality or its user-visible surface does change the module. Both are read before and after +the change, and the stricter applies: + +| # | Given · when · then | Kind | Result | Evidence | Commit | Confirmed | +|---|---|---|---|---|---|---| +| S2 | Given an account, when the password is wrong, then a message says what to do and the email stays typed | automated | passed | the CI run's trace | `e4f5a6b` | — | +| S5 | Given a 375-pixel-wide phone, when the keyboard opens, then the button stays reachable | explored | passed | emulator screenshot | `a1b2c3d` | `e4f5a6b` — three fixes under src/, none on this path | +| S8 | Given a real mailbox, when a reset is asked, then the email arrives | human only — no test mailbox | not verified | — | — | — | + +- **Written before the code**, from the acceptance criteria: it is part of the oracle. +- **Run by a verifier who is not the author**: another agent session with a fresh + context, or a human (`.nstack/playbooks/verification.md`). The session that wrote the code + shares its misunderstandings. CI compares the verifier's name with the change's authors — + the pull request's, the commits' GitHub accounts (read from their noreply addresses; off GitHub + no other address names a person), and + the sessions their `Agent-Session` trailers name — and refuses a match: a declaration + checked against the history, not a proof of identity. Each person named must have a hand on + the pull request — an edit of its description, a review or a comment —: a name written over + the author's own results is refused. +- **No result without evidence**, tied to the commit tested. A new commit does not send the + whole sheet back: + - a commit whose files are exactly the head's **is** the head: a hash changed by a merge + that brought nothing sends no scenario back; + - an **automated** scenario is **run again** at the head — CI replays it when the module + declares `e2e`, so it costs nothing; its Commit cell takes the head commit. Where checks are + attested, it stands when nothing its modules read moved since its run: the records of its + commit and of the head hold the same `inputs` digest — the modules run, those they consume + from or assemble, the files outside the modules, `contracts/` and `platform/` included, the + project's records (`docs/project/`, `docs/adr/`, `docs/pdr/`) left out, the engine and the + person — and the run is at most 7 days old, the default branch moved by 20 commits at most. A + module that reads something it does not declare is the risk: declare it in `consumes` — a + record cannot be declared: a check never reads one —, and the default branch's own `Module + checks` run catches what was missed once it runs that module. A commit with no passing record + of its own is the case to know: `pr-check`'s T4 says so — `nstack attest` with that commit checked out, and + its rows stand without running them again —, as it says a digest that differs, with what + changed — a module consumed, a shared file; or, when no file did, the modules run or the + engine —, or a run past its bound. The forge's run, made at the push, comes before the head's record: where the + ruleset requires `nstack / local checks`, it leaves a row that waits only for the head's record to that status, and says so; + - one **explored** by hand keeps the commit its evidence was produced on, and the verifier + adds a **`Confirmed`** column on the head commit saying **what moved since and why it leaves + the result standing**. Reading three fixes is not the same work as driving six scenarios + again, and the sheet should not charge the second for the first. + - at criticality **`critical`**, nothing stands in for a run: every scenario goes again. + + A confirmation is not a round. A project that wants another adversarial round decides so + itself; the sheet never demands one because a fix landed. +- **Kinds**: *automated* — replayable, run by CI through the module's `e2e` command, or + through `test` for a module that declares no `e2e`; + *explored* — judged by driving the interface; *human only* — what no agent can run, with + the reason, listed apart for the approver. +- **A scenario that waits on a person** — a device, a real call, a colleague's machine — is + not asked in a conversation, which nobody finds again, nor left in a pull request held open + for days. It is asked in an **acceptance issue** (on GitHub, its form in `.github/ISSUE_TEMPLATE/`; + elsewhere an issue of the forge, or the team's tracker), assigned to + whoever runs it; their answer is a comment, and the sheet's Evidence cell links it. The same + issue serves a deliverable several pull requests deliver: it says which criterion each + sheet holds, and which nobody holds yet. It copies no criterion and sets no state — both + stay in the cycle (`06-decisions.md` §9). + + **One issue is one trial, and it is closed when answered.** A person, a system, a set of + steps: when each step has its answer, met or not, the issue is closed — by whoever ran it, + or by the pull request that records the last answer (`Closes #`). An issue left open + "until the deliverable is accepted" tracks nothing: a deliverable tried on three systems, + or delivered by two modules, has as many trials, each opened when there is something to + run. What a trial did not meet is fixed and tried again in another issue, or said in the + cycle; the deliverable's state is never read from an issue being open or closed. + +**`Confirmed` is optional**: a sheet no fix has disturbed never carries it. A later confirmation +joins an earlier one in the same cell, after a `;`, each clause starting with its commit: +`651e249 — <what moved>; deb508f — <what moved>` — a colon or a comma after the commit reads the +same; a refusal quotes the cell it read. The engine's pull +request check reads the sheet in CI: missing, unfilled, without evidence, verified before the +head and not confirmed on it, failed. Where checks are attested, each record also keeps the sheet's +rows as it read them, and the check compares the description with them: an **explored** row whose +Commit cell moved and whose evidence did not was never explored again, and fails — evidence names +its run (a link to that screenshot, video or trace), so a new run brings a new one. The commit it +moved from is the one the first record holding that evidence names: putting it back and confirming +the head passes, even after a record held the moved cell — and so does any ancestor of that +commit, where the row was explored before a record held it; a move to a commit that is not its +ancestor is said. A row a record +held and the sheet no longer shows is said, unless a line under the sheet says why it left — +`Removed: S3, S4 — <why>` —: whoever edits the sheet writes it, and the approver judges it. A rebase or a squash drops the records of the commits +it rewrites, and what they read with them. Only this pull request's records are read: each names +the pull request it was made for — its number where the forge gives it, and its branch, the one +the checkout tracks — so a branch started on another's never reads that one's sheet. Attest on the +pull request's branch, one tracking it, or detached; a branch of another name is another's. The approver decides on the sheet; where the project answers +`approval: agent`, the approver of a `prototype` or `standard` module may be the verifier itself, +an agent under another identity than the author's (`07-governance.md` §7). + +--- + +## 8. The closing summary + +An imposed format, always in this order: + +``` +DONE what was changed, one sentence per change +VERIFIED the checks actually run, with their result +ASSUMED the assumptions taken for lack of information +NOT VERIFIED what was not tested, and why +RISKS possible side effects, debt introduced, follow-ups needed +``` + +The last three sections are the most important and the most often skated over. A summary +with nothing to put under `ASSUMED` and `NOT VERIFIED` is almost always an incomplete +summary, not a perfect task. + +--- + +## 9. Rules for changing code + +**Before.** Understand the problem, look for what already exists, identify the local +conventions, the dependencies, the tests and the contracts concerned, assess the risks. + +**During.** Stay inside the scope. The minimal change. **No opportunistic refactoring.** +Keep the module's existing conventions, even where you would have written them +differently. Do not introduce unnecessary complexity. + +**After.** Inspect the diff line by line. Run the validations. Actively look for side +effects. Update the documents affected. + +### On refactoring + +Never refactor because the code "could be cleaner". A refactor must have a named reason: +removing coupling, reducing a measured complexity, enabling an identified evolution, +fixing an architectural violation, improving a measured performance, improving +testability, paying down documented debt. + +A significant refactor is **isolated from the functional change**, in its own pull +request. Mixing the two makes review impossible: the reviewer can no longer tell what +changes the behaviour from what preserves it. + +--- + +## 10. Postures + +One person or one agent can hold several postures in a small team — except that the author +never verifies its own work, and never approves it. + +| Posture | Held by | Mission | Never | Produces | +|---|---|---|---|---| +| **Framer** | An agent | Interview the decider; propose the charter, the cycle, the deliverables and their criteria, the modules | Decide; propose more than the need; split on day one without a reason | Proposals (`.nstack/playbooks/framing.md`) | +| **Author** | An agent | Deliver one deliverable, in one module, within its criteria | Widen the scope; verify or approve its own work | The pull request and its oracle | +| **Challenger** | An agent session other than the framer's, or a human | Attack a discovery: pre-mortem, the four risks, counter-evidence | Rewrite the document; soften an objection | Objections with their evidence (`.nstack/playbooks/discovery.md`) | +| **Verifier** | An agent session other than the author's, or a human | Run the test sheet against the change, before reading the diff | Fix the code; report a preference as a gap | Results and evidence (`.nstack/playbooks/verification.md`) | +| **Approver** | A human code owner — or, on `approval: agent`, another agent for a `prototype` or `standard` module | Decide the merge on the evidence | Approve without the sheet where one is required; approve what it pushed | The approval | +| **Decider** | The human who owns the project | Validate the charter, the cycle and its appetite; accept a change of scope; choose at the circuit breaker | Extend a cycle silently | Decisions recorded in `docs/project/` | +| **Owners** | The foundation team, a module's owner | Own the project's rules, or one module | Write a project rule into a framework file | The project's and the module's documents | diff --git a/docs/os/06-decisions.md b/.nstack/handbook/06-decisions.md similarity index 59% rename from docs/os/06-decisions.md rename to .nstack/handbook/06-decisions.md index a106895..893f1b9 100644 --- a/docs/os/06-decisions.md +++ b/.nstack/handbook/06-decisions.md @@ -135,6 +135,11 @@ A replaced decision is **superseded by a new decision**, never rewritten quietly history of abandoned decisions is often worth more than the current one: it explains why the apparently obvious does not work. +A record is a file of `docs/adr/`, named `NNNN-verb-phrase-title.md` — `0001-adopt-postgres.md` +— and listed in that folder's index, which the project keeps. There is one such folder, at the +project's root: a decision about one module says so in its `Scope` field, and no module keeps a +register of its own. + ### PDR — Product Decision Record For an important **product** decision: a user goal, an expected behaviour, a trade-off, a @@ -145,10 +150,13 @@ The PDR describes **what the product must do and why**, never its implementation Minimum content: the user problem · **prior art** · options · decision · a **dated success criterion** · a **removal condition** · impacts. +A record is a file of `docs/pdr/`, named `NNNN-user-oriented-title.md`, and listed in that +folder's index. + ### Why only two formats The **FDR** (Functional Design Record) format was removed. Between the PDR (the what and -the why) and the issue's acceptance criteria (the expected, testable behaviour), almost +the why) and the deliverable's acceptance criteria (the expected, testable behaviour), almost nothing was left to justify a third format — and one more format means one more place to look, one more to maintain, one more that will diverge. @@ -174,7 +182,11 @@ Every `BUILD` decision, every PDR, and every ADR that deviates from the conventi carries a sentence of this form: > *We will consider this was the right call if* **\<measurable observation\>** *is -> observed before* **\<date\>**. +> observed before* **\<YYYY-MM-DD\>**. + +The due date is written in bold, `**2027-01-31**`, and only it: a plain date in the criterion — +an amendment's, a reference's — is never read as one (C10). A criterion with no bold date and no +cycle named, whose plain date a closure reached, is reported so its due date is bolded, not lost. Without a date nobody ever comes back to check, and `docs/adr/` becomes a graveyard — which is worse than no documentation at all, because it inspires false confidence. @@ -209,8 +221,8 @@ flowchart TD AU --> REV["REVIEW AT THE DEADLINE"] AU2 --> REV REV --> REV1{"Success criterion<br/>met?"} - REV1 -->|Yes| CONF["Confirm<br/>+ a new deadline when relevant"] - REV1 -->|No| SUP["Supersede, correct<br/>or remove"] + REV1 -->|Yes| CONF["Met: confirmed<br/>+ a new deadline when relevant"] + REV1 -->|No| SUP["Missed: supersede,<br/>correct or remove"] style PA fill:#1f2937,color:#fff style AU fill:#065f46,color:#fff @@ -221,8 +233,10 @@ flowchart TD almost every project skips. The `REVIEW AT THE DEADLINE` step is the one missing from nearly every project. A light -ritual is enough: once a quarter, list the decisions whose criterion has come due, and -decide — confirmed, superseded, or the feature is removed. +ritual is enough: at each cycle's closure, `nstack plan` names the decisions whose criterion +has come due (C10, a warning); the closure's pull request gives each one line under its +criterion — met, missed, or superseded — approved with the closure. A missed one is the +decider's to answer, by a decision of its own: superseded, or the feature removed. --- @@ -266,7 +280,7 @@ denounces: a rule that is only text produces no behaviour. | A mandatory **Deviation** section as soon as the decision departs from the convention, with the user value and the observation criterion | A decision marked "deviation" without the section → red | | Every new dependency declares **adoption and exit strategy** in the manifest | Undeclared dependency → red | | `BUILD` decisions: a **dated success criterion** is mandatory | No date → red | -| A deadline passed without review | A CI warning, raised at the quarterly ritual | +| A deadline passed without review | A CI warning at each cycle's closure (C10) | As long as one of these checks is not automated, it happens in review and sits in the automation backlog (`07-governance.md` §9): writing "red" is not enough to make it true. @@ -287,16 +301,95 @@ Every important piece of information has one identifiable source, and only one. |---|---| | Product decision | PDR | | Technical decision | ADR | -| Expected behaviour of a feature | The issue's acceptance criteria | +| Expected behaviour of a feature | The deliverable's acceptance criteria | | Interface between modules | The versioned contract | | A module's identity and dependencies | MANIFEST | -| Work to be done | Issues / the project board | +| Planned work | The current cycle's deliverables, in `docs/project/cycles/` | +| A deliverable tried by a person | An acceptance issue: what to run and what was seen. It tracks the deliverable; the criteria stay in the cycle, its delivery in the record `nstack deliver` writes | +| A deliverable's delivery | Its record (`nstack deliver`), read by `nstack plan`, written into the cycle at the closure | +| Unplanned work | A typed issue: a defect, an architecture question, a debt, a request | +| What the project must remember | One named issue, the project's log — titled `Log`, opened by whoever writes its first entry; with no forge, `docs/project/log.md`: what was tried, what it cost, what was refused — and what was asked of, promised to, or received from someone outside the team, by any channel | +| How an agent's tool loads a playbook | The playbook; the skills are generated from it, committed, and checked against it (S3) | | Real behaviour | Code and tests | | Quality rules | Versioned CI | | Infrastructure | Versioned configuration | -| Security | `SECURITY.md` + automated checks | +| Security | `.nstack/playbooks/security.md` for the rules, the project's `SECURITY.md` for its policy, automated checks | | Operations | Runbooks | > **Never leave an important decision only inside a conversation with an AI.** A > conversation is not versioned, not reviewable, not enforceable, and not findable by > somebody arriving in six months. + +### What binds is reviewed; what tracks, and what arrives, is an issue + +A plan, a decision, a charter and a cycle are **files, reviewed in a pull request**: an issue +is edited in silence — no diff, no owner, no review — and a plan that can change without +review is not a plan of record. An issue carries what a file carries badly: a person's trial, +and whatever nobody planned. The state of the work is in the holds and the delivery records, +which `nstack plan` reads and the board only shows. Each form names one kind of unplanned work, and none of +them asks for a deliverable — work a cycle plans is described once, in the cycle. A request +is not work yet: the next framing makes it a deliverable, or refuses it with a reason. + +A project that tracks its unplanned work in another tool, or keeps everything in files, +breaks no rule here: it has chosen where, which is all this section asks. + +--- + +## 10. The project's documents + +The framework writes none of them. It gives each one a form, a moment, and a standard. + +```mermaid +flowchart LR + P0["Creation"]:::phase --> P1["Discovery<br/>decided: go"]:::phase --> P2["Charter<br/>accepted"]:::phase + P2 --> P3["A module holds<br/>its first code"]:::phase --> P4["Delivery"]:::phase --> P5["Cycle<br/>closed"]:::phase + P5 --> P4 + + P0 -.-> D0["Forms only:<br/>nothing can be<br/>written yet"]:::owed + P1 -.-> D1["Front page:<br/>its sentence"]:::machine + P2 -.-> D2["Front page: whole"]:::machine + P2 -.-> D2b["Security policy<br/>reviewed"]:::owed + P3 -.-> D3["Module map"]:::machine + P4 -.-> D4["The module's page<br/>and its runbook"]:::owed + P5 -.-> D5["The closure names<br/>what was brought<br/>current"]:::owed + + classDef phase fill:#1e3a8a,color:#fff + classDef machine fill:#065f46,color:#fff + classDef owed fill:#374151,color:#fff +``` + +**Legend** — blue: a moment of the project's life, read from the repository · green: a +document a check refuses to see left as its form once that moment has come (rule C8) · +grey: owed — asked of a human, read by no check. + +| Document | Says | Becomes writable when | Then kept current by | +|---|---|---|---| +| The idea and its discovery — `docs/project/inputs/`, `discovery.md` | The idea as given; evidence with its sources; the decision | The discovery starts | Each round, until decided | +| Front page, its sentence — `README.md` | What the product does, for whom | The discovery is decided **go** | — | +| Charter — `docs/project/charter.md` | Users, problem, constraints, success criteria | The framing | The decider alone (§4) | +| Front page, whole — `README.md` | What it is, how to run it, where its decisions live | The charter is **accepted** | Each cycle's closure | +| Security policy — `SECURITY.md` | How to report a vulnerability, who answers, how fast | Creation, as a default; reviewed when the charter is accepted — it says what data the product holds | A change of channel or of maintainers | +| The project's own rules — `docs/project/rules/` | What this project adds to a playbook, and how each rule is checked | The first decision that binds how the work is done — the language, at a discovery's intake; the charter's constraints, at its acceptance | The decision or the incident that adds a rule; a check that replaces one | +| The project's tools — `.nstack/tooling-profile.md` | Which tool serves which capability | A tool is chosen | The decision that replaces one | +| A cycle — `docs/project/cycles/` | One goal, its deliverables, its end date, its closure | The charter is accepted | The decider alone | +| Module map — `modules/README.md` | The modules, and the contracts between them | A module holds its **first file of code** | The pull request that creates, merges or retires a module | +| A module's `README.md` and runbook | What it is for, how to start it, how to operate it | The module is created | The pull request that changes its behaviour | +| What no module owns — `docs/architecture/`, `docs/runbooks/` | How the whole is deployed; what to do when the whole fails | A decision or an incident needs it: absent until then | The next decision, the next incident | +| A decision and its index — `docs/adr/`, `docs/pdr/` | A trade-off, with its dated criterion | It is taken | Never: a decision is superseded, and the index gains a line | + +**A form is not filled before its moment.** At creation nobody knows what the product is; +a sentence written then is invented. Each form waits for the event of its row, and a check +that asked for it earlier would be paid in counterfeit. + +**The standard** these documents are written to — shape first, a source, a date, current or +deleted, one home for each fact — is `.nstack/playbooks/documentation.md`: a playbook, because the handbook is never loaded +into an agent's context and agents write most of these documents. + +**What a machine reads, and what is owed.** Three moments are readable from the repository +and are checked: a front page without its sentence after a go, a front page still a form +under an accepted charter, a module map still a form once a module holds code. Whether a page is +*true* is not decidable: it is owed — "affected documentation up to date" in the Definition +of Done (`05-workflow.md` §7), and the cycle's closure, which names the documents it +brought current. + +This handbook is written to the same standard; that is where it comes from. diff --git a/.nstack/handbook/07-governance.md b/.nstack/handbook/07-governance.md new file mode 100644 index 0000000..945694c --- /dev/null +++ b/.nstack/handbook/07-governance.md @@ -0,0 +1,545 @@ +# 07 — Governance + +## 1. The principle + +> If a rule can be checked automatically, it must **not** depend on the vigilance of the +> AI or of the developer. + +This is the move from *governance by inspection* — somebody reviews and spots things — to +*governance by rule*: the system refuses the invalid state. + +Corollary: **an important rule checked only by human memory will drift.** Not maybe, not +if the team is careless. It will drift. + +--- + +## 2. Where does this rule live? + +This is the central arbitration of the OS and it must be made explicitly, for every new +rule. + +```mermaid +flowchart TD + A["New rule<br/>or convention"] --> B{"Mechanically<br/>checkable?"} + + B -->|Yes| C{"Cost of setting<br/>it up?"} + B -->|No| G{"Structural<br/>or situational?"} + + C -->|Low| D["CI: blocking check<br/>+ local hook for feedback"] + C -->|High| E{"Risk if<br/>violated?"} + + E -->|High| D + E -->|Low| F["Automation backlog<br/>+ a temporary rule in a playbook"] + + G -->|Structural| H["A boundary: repo, package,<br/>ownership, CODEOWNERS"] + G -->|Situational| I{"Does it apply to<br/>EVERY task?"} + + I -->|Yes| J["KERNEL<br/>strictly limited budget"] + I -->|No| K["PLAYBOOK<br/>loaded by trigger"] + + D --> L["REMOVE the rule from the prompt"] + H --> L + + style D fill:#065f46,color:#fff + style H fill:#065f46,color:#fff + style J fill:#1f2937,color:#fff + style L fill:#7c2d12,color:#fff +``` + +**Legend** — green: the deterministic destinations · dark grey: the expensive, +probabilistic one · red: the step everyone forgets. + +Node `L` is the most important and the most forgotten: **once automated, the rule leaves +the prompt**. Otherwise the kernel grows indefinitely and ends up costing, on every task, +more context than it protects. + +Node `H` also deserves attention: a rule that is not checkable but is structural is often +solved by **structure** rather than by text. "Do not import the other module's code" is a +weak rule; putting the two modules in distinct packages with declared dependencies makes +it unnecessary. + +**The tree says what kind of place; the level says whose.** Nodes `J` and `K` are the +framework's. A rule that is the project's alone takes the same path and lands one level +nearer (`00-overview.md` §5): + +| The tree ends on… | A rule every project shares | A rule of this project | A rule of one module | +|---|---|---|---| +| `J` — every task | The kernel | `docs/project/rules/always.md` | The module's `AGENTS.md` | +| `K` — by trigger | `.nstack/playbooks/<subject>.md` | `docs/project/rules/<subject>.md` | The module's `AGENTS.md` | +| `D` — a check | The framework's checks | The project's own CI | The module's `check` and `test` | + +Node `L` holds at every level: a project rule that a check now enforces leaves +`docs/project/rules/`. That is what the last column of that folder's form is for. + +--- + +## 3. Fitness functions + +> An important rule must not stay in the prompt; it must become an automated test that +> fails when the architecture drifts. + +This is the mechanism that turns this OS's principles into real constraints. + +```mermaid +flowchart LR + subgraph SRC["Sources — already present"] + S1["The modules'<br/>MANIFESTs"] + S2["The real graph extracted<br/>from the code"] + S3["Versioned<br/>contracts"] + S4["Build & runtime<br/>metrics"] + end + + subgraph FF["Fitness functions"] + F1["Dependencies:<br/>declared = real"] + F2["No cycles"] + F3["Layering respected"] + F4["No access to another<br/>module's database"] + F5["Contracts: compatibility<br/>and consumers"] + F6["Budgets: performance,<br/>size, time"] + F7["Lifecycle:<br/>statuses and dates"] + end + + S1 --> F1 + S2 --> F1 + S2 --> F2 + S2 --> F3 + S2 --> F4 + S3 --> F5 + S1 --> F7 + S4 --> F6 + + FF --> CI["CI — blocking"] + + style CI fill:#065f46,color:#fff + style FF fill:#1f2937,color:#fff +``` + +**Legend** — dark grey: the checks themselves · green: the blocking verdict. Layering (F3) and +budgets (F6) are the project's to build: the framework ships no check for them. + +### The basic fitness functions + +To put in place from the second module onwards, in order of return: + +| # | Function | Detects | +|---|---|---| +| 1 | Declared graph (manifest) = real graph (code) | A hidden dependency, a stray import | +| 2 | No circular dependency | Modules that have become inseparable | +| 3 | No direct access to another module's data | Coupling through the database | +| 4 | Backward compatibility of contracts | An unintentional breakage | +| 5 | Consumers of a deprecated version = 0 before removal | A deliberate breakage, badly sequenced | +| 6 | Consistency of lifecycle statuses | A frozen contract changed, a deprecated module reused | +| 7 | Deprecation dates not passed | Permanent intermediate states | +| 8 | One PR = one module | Boundary erosion | +| 9 | Complete module envelope (manifest, owner, tests) | An orphan module | +| 10 | Performance and size budgets | A silent regression — the project's to build: no check ships with the framework | + +The first six are cheap: they are computed from data already present (manifests, imports, +contract schemas). There is **no semantic analysis** — these are comparisons of graphs +and schemas. + +Beside them, the engine checks what a shared repository must not carry: a path rooted in one +person's home directory, in any tracked file (H1). It exists on no other machine and +publishes the layout of the one it was written on; an image's or a runner's home, a +folder software keeps its own files in — `~/.config`, or `~/Library` on a Mac — a +placeholder or a variable is the same everywhere. + +### Writing a fitness function + +A good fitness function is fast (it runs on every pull request), deterministic (no random +false positives), and **explanatory when it fails**. One that says only "architecture +violation" will be worked around; one that says "module A imports `B/internal/x.ts`, but +A's manifest does not declare B; use contract `b-api@v2`" will be respected. + +--- + +## 4. What to automate + +In decreasing order of return: + +``` +Immediately, at almost no cost + format · lint · type checking · secret detection · commit conventions + +From the 2nd module + unit tests · build · fitness functions 1 to 3 · one PR = one module + +From the 1st inter-team contract + schema validation · contract tests · compatibility · consumers + +From going to production + security analysis · dependencies/CVE · smoke tests · post-deployment verification + +When the volume justifies it + integration tests · targeted E2E · performance budgets · merge queue +``` + +**The critical checks run in CI.** Local hooks give fast feedback but are **never** the +only barrier: they are bypassable, disableable, and absent on a newcomer's machine. + +--- + +## 5. Quality gates + +A quality gate must be: **objective · understandable · reproducible · automated where +possible · useful**. + +The last criterion is the most often forgotten, and it is the one that kills buy-in. + +| Situation | Response | +|---|---| +| A gate blocks often without ever improving quality | Re-evaluate it or remove it | +| An important rule never respected | Automate it, remove it, or explicitly reconsider | +| A gate systematically bypassed by label | The problem is the gate, not the people | +| A gate so slow that people skip it | Make it fast, or move it later in the pipeline | + +> Avoid bureaucratic gates with no value. Every gate has a permanent cost paid by every +> pull request; it must earn its keep. + +**Never a silent bypass.** No `skip`, no `--no-verify`, no test disabled "temporarily", +no threshold lowered to make things pass. A necessary bypass goes through a visible label +and leaves a counted trace. + +--- + +## 6. Proportionate governance + +**Two things are read before any rule fires, and neither is declared by whoever is judged.** +The project's *stage* — unframed until its charter is accepted, framed after — decides +whether the rules that bound work inside a cycle — K1 to K3 and K5 — apply at all +(`.nstack/handbook/project.md`). The module's *criticality* decides which checks a change pays +for, in either stage. One never stands in for the other. + +The level of requirement depends on the **criticality declared in the manifest**, not on +a uniform rule. Never impose the ceremony of a critical system on a small module; never +treat a critical system like a prototype. + +**What each of the four values requires is written in exactly one place: the table of +`05-workflow.md` §7.** This section says why the axis exists and how a module changes value; +it does not repeat the requirements, because a second copy of a table is a second answer +waiting to contradict the first. + +```mermaid +flowchart LR + A["Module"] --> B{"Declared<br/>criticality"} + B --> P["prototype"]:::light + B --> S["standard"] + B --> H["high"] + B --> C["critical"]:::heavy + P --> T["05-workflow.md §7<br/>what each one requires"] + S --> T + H --> T + C --> T + + classDef light fill:#1f2937,color:#fff + classDef heavy fill:#7c2d12,color:#fff +``` + +**Legend** — dark grey: the lightest value · red: the heaviest · the table is the single +source of what they require. + +**The value answers one question**, and it is a question about consequence, not about effort: +*what does a failure of this module cost?* Nothing, because it is thrown away — a user's +patience — a day of work — or a key, an order, money, someone's personal data. That is a +product decision, so **the decider settles it**; an agent proposes it with its price and does +not choose alone. + +Criticality is declared in the manifest, so CI knows which checks to apply to which +module. It is not decided pull request by pull request, which would trigger the +discussion at the worst possible moment. + +**It is revisable**, by ADR: a module going to production changes value. Raising it takes +effect on the next run, with no migration; the checks the new value requires apply to the next +pull request that changes the module. + +--- + +## 7. The repository as an organ of governance + +The repository is not storage space: it is where rules become non-bypassable. Mechanisms +to use (GitHub wording, transposable elsewhere): + +| Mechanism | What it guarantees | +|---|---| +| Pull requests required | No direct change on the protected branch | +| Required checks | A red CI blocks the merge, without exception | +| CODEOWNERS | The right owner is asked automatically — a user, or a team written organisation/team; GitHub reads an organisation named alone as no owner at all | +| Rulesets / branch protection | The rules do not depend on goodwill | +| Issue forms | What nobody planned arrives with what is needed to judge it | +| PR template | The DoD is visible at review time | +| Labels | Exceptions are visible and counted | +| Protected environments | Deployment goes through an approval | +| Dependency / security automation | CVEs do not depend on manual watching | +| Branches up to date before merging (G22) — or a merge queue, where the forge offers one (organisation repositories) and the checks run on it | Two changes each green on its own base never turn main red together: what was checked is what lands. Updating a branch costs the cheap checks — attested, `nstack attest` on the updated head; a module's are kept while nothing they read moved. How to keep it cheap: `05-workflow.md`, *Up to date before merging* | +| A dedicated identity for agents | An agent never merges around the approval the project asks for | +| Rulesets with an empty bypass list | Nobody, administrators included, merges around a rule | +| Stale approvals dismissed on push | An approval covers the commits its approver read — where the plan has no ruleset, `pr-check` says each approval the head moved past (R1) | +| A default code owner — on `approval: agent`, a human owner where one must approve | The code owner review covers every path a human must approve | +| A record of what landed | Nothing reaches the protected branch in silence — it records, it never refuses | + +> **Critical rules must not be bypassable by an instruction given to the AI.** That is +> the ultimate test of governance: if asking an agent nicely is enough to get around it, +> the rule does not exist. + +**And when the forge cannot enforce any of it.** Every mechanism above depends on what the +repository's plan allows; on some, none of them is available, and nothing refuses a merge at +all. The diagnosis says so in one word — *unguarded* — and what remains is the last row: a +run that fails when a commit reached the protected branch outside a pull request. That is a +record, not a barrier, and it is worth exactly what a record is worth: the thing nobody would +otherwise have been told. Reading it as a guarantee is the mistake it exists to prevent. + +**Off GitHub**, this version reads none of the forge's settings and ships no CI there: `doctor` +lists what the forge should refuse, never reports it in place, and says the repository +*unguarded*; each change's checks are attested; the record of commits on main does not run. The +forge's own protections still hold — set them as `INSTALL.md` lists them — but nothing here +vouches for them. With no forge at all, nothing refuses a change but the team. + +**And when the forge cannot run the checks.** A runner down, the hosted minutes spent, a team +that works off the forge: the checks still run, where the team works. `nstack attest` runs the +CI's own checks — one list, bound to the workflows by a test — on a clean head, and records the +run on the commit in git (`refs/notes/nstack/checks`, pushed with the branch), shown — on GitHub only — +as `nstack / local checks`, a name no CI job has. Such a change is **attested**, never +*checked*: the record makes a claim traceable — who ran it, on which commit, with what output +— not true. Whether a record stands in for the forge's CI is the decider's word, the project's +answer `checks: attested` in `.copier-answers.yml`, changed in a pull request (`nstack config checks +attested` lays it on a branch); `pr-check` then +requires a complete, passed record of the head (A1, A2) — on the workstation and in the forge's +CI alike, which reads the record from the remote's notes with the job's token: an unattested head +is red there too. A record CI cannot read — no token, a remote that refuses — is said as a +warning, never called compliant in silence. Attesting again once the test sheet is filled keeps the +module checks the commit's record passed — they read the tree and the base, never the description — +when the base commit, the engine and the person are the same, and the engine is published or named +by a commit with no change of its own — tracked or not. The record says which run they come from +(`kept_from`), with that run's evidence; what the tree's ignored files, the environment or the tools +outside it hold is not compared: `nstack attest --again` runs them. They are also kept +across commits — a merge of the default branch that touched nothing they read: their modules, +those they consume from or assemble, `contracts/`, `platform/` and the files outside the modules but the +project's records (`docs/project/`, `docs/adr/`, `docs/pdr/`) — while the +digest of what they read is unchanged, for 7 days and 20 default-branch commits at most. A record +known to be unsound — two runs that shared what a run must not share, a tool found lying — is +voided: `nstack attest --void <commit> --reason "<why>"` adds a line naming who, why and every +run the commit's note holds. None of them is a record afterwards, nor kept from — on its commit, or +through another commit's record that kept from it —, and `pr-check` refuses a head whose record +is voided or keeps a check from a voided run, until it is attested again. The runs stay in the +note: evidence is never rewritten. A void travels as a record does, under the same identity +rule; the status on the forge turns to *voided* only with a token that may write it. Where the answer is `forge`, a record is +information, and on a guarded repository the forge's required checks stay the barrier — a +decider who wants the record to gate a protected branch requires its name at the forge. +Where the answer is `attested`, requiring it is what keeps a pull request moving: the record +holds the description's sheet, so it is made after its last edit, and notes start no run — the +pull request's last run, from before the record, would stay red. The status is the record's own +event: when the base branch's ruleset requires `nstack / local checks`, the pull request's run +leaves A1 and A2 to it, and says so — and T4 too, for an automated row that waits only for the +head's record: attest's own run keeps the row or fails it with the head's inputs digest. Posting it needs a token that may write commit statuses +(an agent's App made by `nstack agent add` has it; an older App gets Commit statuses: write in +its settings, accepted on its installation); without one, the record is said *not shown*, and +the merge waits. A required name is matched by any check of that name: where every record is an +agent's, the ruleset can pin the status's source to the agent's App. + +The record names who ran it, as git would sign a commit made in that checkout, and travels to the +remote with the notes: it never publishes an address the project's history does not already show. +A checkout whose identity is unknown there — a fresh clone falls back on the workstation's own, +often personal — is refused before any check runs; set the checkout's identity, or, for a first +record of a new contributor, `nstack attest --accept-identity`. GitHub's noreply address is always +accepted, and enough. A repository with no remote is never refused: nothing travels. + +**A dependency bot's pull request, where checks are attested.** Dependabot's — or Renovate's — +pull requests carry no record, and the bot takes commands only from people with push access: an +agent's App asking it to rebase is refused. Nothing is re-applied by hand. When the branch is +behind and the ruleset asks it to be up to date, a person's `@dependabot rebase` keeps the bot +maintaining it; otherwise the agent updates it on the forge +(`gh api --method PUT repos/<owner>/<repo>/pulls/<number>/update-branch`, which the App's pull +requests and contents write permissions allow, both given by `nstack agent add` — where the +update touches workflow files, the App also needs the workflows permission, `nstack agent add +--workflows`). The bot then stops maintaining that pull request: a conflict or a newer version is +a person's `@dependabot recreate`. The agent fetches the base and the head together and checks +the head out as it stands (`git fetch origin main pull/<number>/head:refs/remotes/origin/pr/<number> +&& git checkout --detach origin/pr/<number>`), then runs `nstack attest`: the record names who ran +the checks, never who wrote the commit, and each new head is attested again. The route covers +updates outside the modules; a bot's update inside one is delivery work like any other, with its +deliverable or the out-of-cycle label. + +**A record is published with the repository**: the notes are pushed, and every step's output +travels in them. `nstack attest` writes the checkout's root as `<root>` and the home folder as `~`, +whole folders only. Anything else a step prints travels as printed, and is the step's to keep out: +a host name, a token a test echoes, a user name in a path outside the home — `/tmp/pytest-of-<user>/` +in a failed test's output. The SHA-256 of each step is of its output as it ran, so it is not +recomputed from the record. A record an earlier +version pushed keeps its paths: notes are history, and rewriting them rewrites the evidence +`pr-check` reads. + +**A failed check says what failed, and keeps its output on the workstation.** Under the check's +FAIL line, `nstack attest` shows the last lines a module's own command wrote before it exited — a +test runner's summary names the test that failed — and the path of the check's whole output, in +the clone's git folder (`.git/nstack/attest/<commit>-<check>.log`, a worktree's own git folder in a +worktree), never in the tree and never pushed. A test that fails once and passes again is named there: quarantine it by that name +(`.nstack/playbooks/tests.md`). + +### Agents and approval + +A pull request's author cannot approve it. An agent working with a human's credentials +*is* that human: it can approve a colleague's pull request in their name, then merge. Four +settings close that door, and they only hold together: + +1. **The agent has its own identity** — on GitHub, an App installed on the repository (`nstack agent add <name>`: made and + installed in two clicks, with a clone that works as it and runs the project's hooks): tokens + that expire within the hour, never the Administration permission; elsewhere, a bot account + with the same limits. Its session reaches no human credential — no SSH key, token or + command-line login of a human: `nstack agent run` keeps the person's tokens, SSH agent and + git configuration out of its environment; a sandbox, a container or a dedicated system user + keeps it out of their files. The agent's tool still reads the person's own configuration — its + sandbox, hooks and permissions: for Claude Code, the command adds settings of the agent's own + that open the forge to its sandbox, nothing else. A person's hook that refuses `gh`, against + their own account, lets an agent's session through on one test only — its `gh` is the App's: + `[[ -n "${NSTACK_AGENT:-}" && "$(command -v gh)" == "$(dirname "$GH_CONFIG_DIR")/bin/gh" ]] && exit 0` + — the agent's `gh` folder sits beside its shim, wherever the agents' folder is. + Inside that sandbox the agent writes its clone, `.git/config` excepted, and a cache of its own + (`XDG_CACHE_HOME`; uv and pre-commit keep the person's); a build writing elsewhere, such as + Cargo's `~/.cargo`, needs the person to add that folder to their sandbox's `allowWrite`. It + branches without tracking and pushes plainly — `git switch -c d4-export origin/main`, then + `git push` — and needs no worktree, its clone being its own. Unix sockets + stay closed unless the project answers `agent_sockets: true` in `.copier-answers.yml`, read from + the default branch: an end-to-end test of audio or a display needs them, and a socket such as + `docker.sock` hands the agent the host. + Dispatching a workflow run needs Actions: write, which its App never has; changing a file under + `.github/workflows/` needs Workflows, which only `nstack agent add --workflows` grants. Both are + otherwise the person's gestures. The agent hands over the literal command (`gh workflow run <file> --ref <branch>`) and + never asks another session to make it — that would be one identity borrowing another's rights. +2. **The merge requires a human code owner's approval**, and `CODEOWNERS` starts with a + default owner: an App can approve, but it is never a code owner. On `approval: agent`, below, + the code owners file names a human only where one must approve. +3. **Nobody is on the rulesets' bypass list**, administrators included. +4. **An approval is dismissed when new commits are pushed**: otherwise a force-push after + the approval merges content its approver never read. Where the plan has no ruleset to + dismiss it, the forge still shows *approved*: `pr-check` says each approval the head moved + past (R1), and nobody merges on it until its approver has approved the head. + +The human who drove the agent may approve its pull request. A team that wants four eyes +adds "require approval of the most recent reviewable push", or a second reviewer. + +**Where another agent approves.** A project whose agents each work under an identity of +their own may answer `approval: agent` in `.copier-answers.yml` — the +decider's word, changed in a pull request a human approves: `nstack config approval agent` lays it on +a branch, the code owners file following it. A change to a `prototype` or `standard` +module is then approved by a human **or** by another agent — under an identity that is neither its +author's nor its last pusher's, whoever runs it; everything else still waits for a human code owner. +The forge does the sorting, path by path: + +- **The code owners file names a human** for the project's rules (`AGENTS.md`, `CONTRIBUTING.md`, + `SECURITY.md`, `.nstack/`, the forge's folder, the code owners file itself, the hooks' + configuration, `.copier-answers.yml`), its records (`docs/`) and every module neither + `prototype` nor `standard` — and **no default owner**: a path it does not name needs one + approval, an agent's counting. The code owners review stays required: nothing is lowered. + `nstack new-module` writes no line for a `prototype` or `standard` module; a module whose + criticality rises gets its line in the same pull request (`doctor`, L6). +- **The last pusher's approval does not count** (G21): an agent that pushed a fix to the change + it reviews no longer approves it. +- **The approving agent says, in its approval**, the session it ran in and what it is expert in + for the module. Where the module asks for a test sheet, it is the verifier who ran it; where + it asks none, it reviews the change on its oracle and its checks. +- **Independence is the identity's, not the person's.** Two agents one contributor runs — + each under its own App, in its own session, best on another model — approve each other's + changes as two contributors' agents would. What a second agent cannot do, nobody's can: approve + what a human must, or what it pushed. So the answer changes nothing until a second agent works + under an identity of its own; `doctor` says so while the history shows a single one. +- **Two agents never loop.** The reviewing agent approves or comments — never *request + changes*, a block only it can lift — and never pushes to the change it reviews: it names what + is wrong, the author fixes. One round (`05-workflow.md`): its findings once; then it confirms + the fixes and approves, or, still disagreeing, hands the change to a human. A second pass + raises nothing new but what the fixes broke. + +**Copilot's code review is not that agent.** GitHub lets its approval count toward the required +ones — generally available since 2026-10-28, off by default: *Settings › Copilot › Code review*, +*Allow Copilot approvals to count toward merge requirements*, which an organization may also +enforce for every repository. It runs no test sheet and names no session, so leave that toggle +off, and ask the organization's owner where it is enforced; where an approval of it is the only +one, `pr-check` says so (R2). Copilot is named in no code owners file, so on every path the file +names a code owner still approves — GitHub's documentation says nothing otherwise. + +**Where the forge cannot guard** — a private repository on a plan that enforces no ruleset — +neither answer is enforced: the code owners file only asks for reviews, and `doctor` says +*unguarded*. Who approves is then the team's rule, kept by the people, as every rule there is. + +Whether the answer holds is read on what escapes: a defect found within 30 days of a merge, +which the bug form ties to its pull request (`10-measurement.md`). GitHub counts an App's approval +toward the required ones once the App may write contents, never on a pull request it opened — as +reported in practice; a project's first cross-approved pull request is its own proof. + +### The approval is one gesture, not three + +Approving and merging are two different acts, and only the first is a judgement. With +**auto-merge** allowed on the repository, the author arms it on the pull request when opening +it (`gh pr merge <number> --auto --squash`), and the pull request merges itself the moment it +is approved and its required checks go green: nobody waits on the reviewer to come back and +press a button, and no agent is told to merge on their behalf. The barrier is untouched — the approval is still +required, still a human's or, under `approval: agent`, another agent's (above), still dismissed +when new commits are pushed, a merge of the default branch included (`05-workflow.md`). + +What it removes is the round trip: **the approval message that carries no judgement at +all**, and exists only to tell an agent that a merge could now happen. + +The approval itself can also be given from wherever the decision was made, under the +approver's own identity, rather than by walking to the browser: + +``` +gh pr review <number> --approve +``` + +One gesture. An approval given in the terminal and an approval given in the web interface +are the same act, recorded the same way, and dismissed the same way on the next push. + +--- + +## 8. The CI pipeline + +Conceptual order, from the fastest to the most expensive — useful feedback arrives early. + +```mermaid +flowchart TD + CH["Change"] --> F1["Format · Lint"] + F1 --> F2["Types"] + F2 --> F3["Unit tests"] + F3 --> F4["Build"] + F4 --> F5["Architecture<br/>fitness functions"] + F5 --> F6["Contracts:<br/>schema · compatibility"] + F6 --> F7["Security:<br/>secrets · dependencies · SAST"] + F7 --> F8["Integration tests"] + F8 --> F9["E2E · visual · accessibility<br/>per criticality"] + F9 --> AR["Artefact"] + AR --> DE["Deployment"] + DE --> SM["Smoke tests"] + SM --> OB["Verification through<br/>observability"] + + F1 -.->|"failure = immediate stop"| STOP["Feedback under 2 min"] + F5 -.->|"failure = architectural<br/>violation"| STOP2["A precise explanation<br/>+ the rule broken"] + + style F5 fill:#065f46,color:#fff + style F6 fill:#065f46,color:#fff + style STOP fill:#1f2937,color:#fff + style STOP2 fill:#1f2937,color:#fff +``` + +**Legend** — green: the architecture gates · dark grey: what a failure must give back. + +**Do not apply every step mechanically to every module.** The level of validation is +proportionate to the risk (§6). + +**Feedback time is a quality property.** A thirty-minute CI is a CI people work around, +launch at the end of the day, and whose results they ignore. Feedback time is a tracked +indicator (`10-measurement.md`). + +--- + +## 9. The automation backlog + +Every rule that *should* be automated but is not yet is identified debt, not a fact of +life. It sits in a dedicated backlog, with: + +- the rule and where it lives temporarily (a playbook, a local AGENTS.md); +- the risk if it is violated; +- the estimated cost of automating it; +- the trigger that will make it a priority. + +That backlog is reviewed on the same rhythm as the decision review (`06-decisions.md` +§6). It is the mechanism that stops the kernel growing: every rule added to the prompt +arrives with its planned exit date. diff --git a/docs/os/08-quality.md b/.nstack/handbook/08-quality.md similarity index 89% rename from docs/os/08-quality.md rename to .nstack/handbook/08-quality.md index f80808e..0e933ff 100644 --- a/docs/os/08-quality.md +++ b/.nstack/handbook/08-quality.md @@ -1,7 +1,7 @@ # 08 — Quality and risk > This document is the **reference**. The matching operational rules live in -> `playbooks/`, loaded on demand by an agent. +> `.nstack/playbooks/`, loaded on demand by an agent. --- @@ -122,12 +122,12 @@ It **does not replace** unit, integration, security or technical tests. A UAT us technical safety net is the symptom of an insufficient test suite — and it arrives too late and costs too much for that role. -It starts from the acceptance criteria of the PDR or the issue and from real user +It starts from the acceptance criteria of the PDR or the deliverable and from real user journeys, not from free exploration of the interface. The test sheet (`05-workflow.md` §7) is the everyday form of acceptance: the acceptance criteria turned into scenarios, run by someone other than the author, each with its -evidence. UAT remains for `critical` modules, on top of it. +evidence. UAT remains for `critical` modules on top of it, and for `high` ones as needed. --- @@ -153,14 +153,21 @@ rate limiting · isolation · backups · disaster recovery - The checks that can be automated are **built into the delivery cycle**, not run occasionally. -The operational detail is in `playbooks/security.md`, loaded as soon as a task touches +The operational detail is in `.nstack/playbooks/security.md`, loaded as soon as a task touches authentication, authorisation, secrets, personal data or external input. --- ## 7. Reliability and operations -A module destined for production must be **operable**. Depending on its criticality: +A module destined for production must be **operable**. This section says **what** operability +is made of; **when** each capability is required is read from the one table that answers that +question, `05-workflow.md` §7. Below `standard` — a `prototype` module, thrown away, that +nothing depends on — none of it is required. + +The rows below are **owed to a human**, except the runbook's presence, which M8 checks. They +are the detail behind the *Observability added*, *Runbook present* and *Rollback verified* +rows of the table, and where a cell here and the table differ, the table decides. | Capability | standard | high | critical | |---|---|---|---| @@ -175,14 +182,14 @@ A module destined for production must be **operable**. Depending on its critical | Idempotence | case by case | ✔ | ✔ | | SLI / SLO | — | as needed | ✔ | | Runbook | — | ✔ | ✔ | -| Tested rollback | — | ✔ | ✔ | +| Tested rollback | — | per risk | ✔ | | Controlled degradation | — | as needed | ✔ | > **Never add automatic retries without analysing the side effects.** A retry on a > non-idempotent operation duplicates. A retry without backoff turns a local incident > into a general outage. A retry that masks an error prevents it being detected. -Detail: `playbooks/operations.md`. +Detail: `.nstack/playbooks/operations.md`. --- @@ -210,7 +217,7 @@ integrity · security · observability The schema evolves through the same expand/contract logic as contracts (`03-contracts.md`): add, let both coexist, migrate, remove. Never rename in place. -Detail: `playbooks/data-migration.md`. +Detail: `.nstack/playbooks/data-migration.md`. --- diff --git a/docs/os/09-platform.md b/.nstack/handbook/09-platform.md similarity index 66% rename from docs/os/09-platform.md rename to .nstack/handbook/09-platform.md index 7478b55..11efad5 100644 --- a/docs/os/09-platform.md +++ b/.nstack/handbook/09-platform.md @@ -32,7 +32,7 @@ flowchart TB classDef module fill:#065f46,color:#fff ``` -**Legend** — blue: the engine, an external tool named in `docs/tooling-profile.md` · dark +**Legend** — blue: the engine, an external tool named in `.nstack/tooling-profile.md` · dark grey: the foundation, which the project owns and adapts · light grey: a `platform/` module, only when the project builds its own shared mechanisms · green: the teams' modules. Solid line: generation and rules; dotted: execution or use. @@ -56,19 +56,48 @@ section, with its own stack's commands. | `check` | All the fast validations: format, lint, types | In under 2 minutes | | `test` | The module's test suite | With no dependency on another module | | `run` | Start the module locally | With doubles for the dependencies | -| `e2e` | The module's end-to-end scenarios; evidence written to `.evidence/` | Against the running module, in CI | +| `e2e` | The module's end-to-end scenarios; logs and screenshots written to `$NSTACK_EVIDENCE` (`.evidence/e2e/`), read after the run; exit 77 when it cannot run here. One at a time on a machine: a second waits for the first, whichever project or command started it, and says for whom, again every minute; a module whose run is sealed (`evidence.sealed: true`) neither waits nor holds | Against the running module, in CI | +| `clean` | Remove what the module's commands left in its folder — build outputs | After its checks in CI on a self-hosted runner, even failed ones | | `compat` | Tell whether a change to a contract version is compatible: exit 0 when `$NSTACK_HEAD_PATH` accepts what `$NSTACK_BASE_PATH` did | On the module holding contracts, once one is consumed or stable | | `contracts` | Validate and generate the contract artefacts | On every contract change | | `migrate` | Apply the data migrations | When the module owns data | -| `release` | Produce the shippable artefact | Reproducibly | +| `release` | Produce the module's shippable artefacts into `$NSTACK_DIST` | Reproducibly, for the platform its arguments name | -The engine runs `bootstrap`, `check`, `test`, `run`, `e2e` and `compat`: it reads the command from +The engine runs `bootstrap`, `check`, `test`, `run`, `e2e`, `clean`, `compat` and `release`: it reads the command from the manifest and launches it from the module's folder, locally as in CI. `check` and `test` are mandatory as soon as the module holds anything beyond its description — its -manifest, `AGENTS.md`, `README.md`, `docs/`; `bootstrap` and `e2e` are optional. A new module +manifest, `AGENTS.md`, `README.md`, `docs/`; `bootstrap`, `e2e` and `clean` are optional. A new module holds only its description: its verbs report that there is nothing to run yet, and -`nstack fitness` asks for `check` and `test` with its first other file. `contracts`, -`migrate` and `release` are reserved names, to declare when a module needs them. +`nstack fitness` asks for `check` and `test` with its first other file. `contracts` and +`migrate` are reserved names, to declare when a module needs them. + +What a module's checks need from the CI machine — a kernel setting, a system package — is its +`bootstrap`'s, which `Module checks` runs before `check` and `test`: the manifest is the +project's, and `nstack update` keeps it. Never a step added to the framework's workflow, which +the next update rewrites, nor one asked of every project for one module's need. Guard it to CI +(`GITHUB_ACTIONS`) so that a developer's machine is left as it is. + +**What ships is assembled from artefacts, never from another module's folder.** `nstack +release <module>` runs the module's `release` with `NSTACK_DIST` naming its own folder of the +project's `dist/` — emptied first, outside every module, never committed — and passes what +follows the module's name to its command: the platform, the target, the variant — a binary, a +mobile build, a web bundle, an installer, whatever the stack ships. A module that makes what a +user installs from other modules' artefacts declares them in its manifest, `assembles: +[<module>, …]`, and reads them in their folders (`$NSTACK_DIST/../<module>/`); `nstack +release` with no module runs each after what it assembles, and fails on a module declaring +none only when that module is named. One target for every module — a platform, an +architecture — is set in the environment they all inherit (`TARGET=… nstack release`); a module +needing several targets of another's makes them all in that one's release, since each release +empties its folder and names what it removed. So does a project shipping one package per system from one +checkout — a `.deb` and an `.rpm`: one release makes both, or the first is moved out of `dist/` before +the second is made. Reading another module's artefacts without declaring it fails (`B9`), as a +path into its folder does (`B2`); `assembles` names modules by their folder, as the verbs do. + +**A job leaves nothing behind.** GitHub's hosted runners are thrown away after each job; a +self-hosted one is not. The module checks start on a clean checkout, and each module ends +with its `clean`, even after a failure — so a module whose commands write build outputs declares how +to remove them, and keeps them inside its own folder, where both reach them. What the +machine accumulates outside any checkout — images, logs — is its owner's to clean. **Why this is the foundation of multi-team work.** A developer or an agent arriving on an unknown module does not have to discover whether to run `npm`, `make`, `cargo`, `pytest` @@ -87,50 +116,44 @@ a bad boundary (`02-modules.md` §9). project/ │ ├── AGENTS.md # the OS kernel -├── README.md +├── README.md # the product's front page: a form at creation, then the project's ├── CONTRIBUTING.md ├── SECURITY.md │ -├── docs/ -│ ├── os/ # this documentation -│ ├── architecture/ # overview, system diagrams -│ ├── project/ # the discovery, the charter and the cycles: what the framework cannot know +├── docs/ # the project's own, and nothing else +│ ├── project/ # the discovery, the charter, the cycles, the project's rules │ ├── adr/ # cross-cutting technical decisions │ ├── pdr/ # product decisions -│ ├── runbooks/ # cross-cutting operations -│ └── tooling-profile.md # mapping capabilities → the tools of the moment -│ -├── playbooks/ # AI instruction modules, loaded on demand -│ ├── discovery.md -│ ├── framing.md -│ ├── security.md -│ ├── tests.md -│ ├── verification.md -│ ├── data-migration.md -│ ├── ux.md -│ └── operations.md -│ -├── contracts/ # ← a module in its own right, dedicated owner -│ ├── MANIFEST.yaml -│ ├── <contract>/ -│ │ ├── v1/ -│ │ └── v2/ -│ └── tests/ +│ ├── architecture/ # how the whole is deployed — created by the first decision that needs it +│ └── runbooks/ # what to do when the whole fails — created by the first incident │ ├── modules/ # empty at creation │ ├── <module-a>/ │ │ ├── MANIFEST.yaml │ │ ├── AGENTS.md │ │ ├── README.md -│ │ ├── docs/adr/ │ │ ├── src/ │ │ └── tests/ │ └── <module-b>/ │ └── … │ -└── .github/ - ├── ISSUE_TEMPLATE/ - ├── workflows/ +├── contracts/ # ← a module in its own right, dedicated owner; created by the first contract +│ ├── MANIFEST.yaml +│ ├── <contract>/ +│ │ ├── v1/ +│ │ └── v2/ +│ └── tests/ +│ +├── .nstack/ # the framework's one folder: everything in it arrives by update +│ ├── playbooks/ # AI instruction modules, loaded on demand +│ ├── forms/ # what a command or a playbook copies: charter, cycle, decision, rules +│ ├── handbook/ # this documentation, INSTALL.md and RULES.md +│ ├── tooling-profile.md # mapping capabilities → the tools of the moment +│ └── skills.yaml # playbooks exposed as skills +│ +└── .github/ # on GitHub; elsewhere CODEOWNERS at the root, and the + ├── ISSUE_TEMPLATE/ # pull request form where the forge reads it + ├── workflows/ # (.nstack/handbook/INSTALL.md) ├── CODEOWNERS └── pull_request_template.md ``` @@ -154,7 +177,7 @@ flowchart TD B --> C1["MANIFEST pre-filled<br/>owner organisation/team"]:::generated B --> C2["AGENTS.md and README<br/>with the expected sections"]:::generated B --> C3["No command yet: green<br/>until its first code"]:::generated - B --> C4["CODEOWNERS updated"]:::generated + B --> C4["CODEOWNERS updated<br/>unless another agent approves it"]:::generated B --> C5["Runbook<br/>when criticality is high or critical"]:::generated B --> C6["Fitness functions and CI<br/>active from the first commit"]:::generated C3 --> E["The team declares its stack's<br/>check and test, then codes"]:::human @@ -190,13 +213,15 @@ usefully without a spoken conversation.** The expected path: ``` -0. read the charter and the current cycle → who it is for, what is being delivered now +0. read the charter, and of the current cycle its front matter and your deliverable's section + → who it is for, what is being delivered now 1. read the module's MANIFEST → what it is for, who owns it, what it consumes 2. read the local AGENTS.md → specific conventions and traps 3. run bootstrap then check → a working environment, validations green 4. read the contracts consumed → what it can rely on 5. read the module's ADRs → why it is the way it is -6. pick up a Ready issue → scope and criteria already explicit +6. take a ready deliverable → nstack claim D<n>: scope and criteria already explicit, + held so that nobody else delivers it ``` If one of these steps requires asking somebody, that is a defect of the system, not of @@ -220,7 +245,7 @@ playbooks, runs the verbs and proposes changes, which CI accepts or refuses exac would from any other contributor. The OS therefore declares **capabilities**, and a *tooling profile* -(`docs/tooling-profile.md`) maps them onto the tools of the moment. Changing tool then +(`.nstack/tooling-profile.md`) maps them onto the tools of the moment. Changing tool then happens without touching the OS. | Capability | What it is for | @@ -230,7 +255,7 @@ happens without touching the OS. | Access to official sources | Versions, APIs, real constraints | | Running commands and tests | Making the oracle actually executable | | Git, issue and pull request interaction | Traceability and small batches | -| Agent identity | Changes arrive under the agent's own name, behind a human approval | +| Agent identity | Changes arrive under the agent's own name, behind the approval the project asks for | | UI inspection and screenshots | UX validation beyond "it compiles" | | Driving a browser or an emulator | Explored scenarios of a test sheet, with their evidence | | Security analysis | Integrated automated checks | @@ -262,7 +287,8 @@ What the skeleton and its engine provide from day one: another module's data, contract compatibility and consumers, lifecycle statuses and dates, one pull request one module, the module envelope; - CI with the checks of the `standard` level; -- CODEOWNERS, and the checklist of forge settings, which the engine verifies read-only; +- CODEOWNERS, and the checklist of forge settings, which the engine verifies read-only (`doctor`) and + applies under the owner's own credential (`settings --apply`); - module creation; - new skeleton versions, offered as a reviewed pull request and merged with the project's adaptations. diff --git a/docs/os/10-measurement.md b/.nstack/handbook/10-measurement.md similarity index 93% rename from docs/os/10-measurement.md rename to .nstack/handbook/10-measurement.md index 5a051c8..df92921 100644 --- a/docs/os/10-measurement.md +++ b/.nstack/handbook/10-measurement.md @@ -86,11 +86,12 @@ How many cycles ended at their end date rather than with every deliverable accep occasional one is healthy: the appetite held. Every one: the appetites or the deliverables are wrong — frame smaller. -### Findings beyond the verifier +### Escaped defects -On every pull request carrying a test sheet, what the approver found that the verifier had -missed. It is the measurement that may one day let a verifier agent's approval count, -module by module (`07-governance.md` §7). +The share of merged pull requests a defect found within 30 days of their merge names — the bug +form asks for the pull request that brought it. Read per module, and per answer to who approves +(`approval: human` or `agent`, `07-governance.md` §7): it is what tells whether an agent's +approval holds where the project lets it count. ### Overdue contractions @@ -173,7 +174,7 @@ Three meetings are enough. All of them produce a decision, never a mere observat | Ritual | Frequency | Content | Output | |---|---|---|---| | **Boundary review** | Monthly | Cross-module PRs, fitness function violations, overdue contractions | *Architecture* issues, or nothing | -| **Decision review** | Quarterly | ADRs/PDRs whose criterion has come due | Confirmed · superseded · feature removed | +| **Decision review** | At each cycle's closure | ADRs/PDRs whose criterion has come due, as C10 names them | A reading line: met · missed · superseded; a missed one, a decision of its own | | **Automation backlog review** | Quarterly | Rules still living in the prompt | Automate · remove · renew with a deadline | The last two can be held together: they address the same subject from two sides — what diff --git a/.nstack/handbook/INSTALL.md b/.nstack/handbook/INSTALL.md new file mode 100644 index 0000000..090bbe8 --- /dev/null +++ b/.nstack/handbook/INSTALL.md @@ -0,0 +1,469 @@ +# Installing and updating the foundation + +> **This project was created by `nstack init`**, the command of the NapkinStack engineering +> framework. This page is the manual for the foundation: what to install, what to set on the +> forge, how a new version arrives. The method itself is the rest of `.nstack/handbook/`; the project's +> own front page is its `README.md`, and nothing here belongs on it. + +```mermaid +flowchart LR + I["nstack init<br/>project created and committed"]:::cmd --> G["GitHub repository<br/>checklist applied"]:::team + G --> D["nstack doctor<br/>workstation and settings"]:::cmd + D --> X["nstack discover idea.md<br/>then the discovery, with your agent"]:::cmd + X --> F["Framing with your agent<br/>charter + first cycle"]:::team + F --> M["nstack new-module<br/>first module"]:::cmd + M --> W["Work in pull requests<br/>CI: fitness, hooks, secrets, sheet, cycle"]:::team + W --> U["nstack update<br/>new version, reviewed branch"]:::cmd + U --> W + + classDef cmd fill:#1f2937,color:#fff + classDef team fill:#065f46,color:#fff +``` + +**Legend** — grey: an `nstack` command · green: the work of the team and its agent. +CI decides as soon as the rulesets require it: what does not pass does not merge (see +"Prerequisites"). + +## Prerequisites + +- **Workstation**: uv and git; read access to GitHub (the NapkinStack skeleton) and to + PyPI. +- **GitHub repository.** Workflows inform; only rulesets and push protection block. What + each case allows: + +| Setting | Public repository | Private, Free plan | Private, Team or Pro | +|---|---|---|---| +| Rulesets: PR, review, CODEOWNERS, required checks | Yes | **No: nothing blocks the merge** | Yes | +| Secret scanning and push protection | Yes | No | Paid Secret Protection option | +| Private vulnerability reporting | Yes | Does not exist | Does not exist | +| CI minutes | Unlimited | 2 000 per month | Per the plan | + +`nstack doctor` reads these settings and answers in one word. **Guarded**: the forge refuses +what the checklist asks it to refuse. **Unguarded**: nothing here refuses a merge — and it +keeps apart what your plan forbids, which you can do nothing about, from what is simply not +in place yet. A project that has done everything its plan allows is reported as compliant, +and still told that it is unguarded: the checks below keep telling the truth, and none of +them stops a merge on their own. + +Whatever the plan allows, the project receives one more workflow, **Commits on main**: it +fails when a commit reached `main` outside a pull request, and names it. It records; it does +not refuse — on a repository where nothing can refuse, it is the only thing that will ever +mention such a commit, and where a ruleset does refuse, it catches a bypass. + +**Where the CI runs.** Every job runs on GitHub's hosted Ubuntu unless the repository +variable `NSTACK_RUNS_ON` names another runner label — a self-hosted runner, for a private +repository whose hosted minutes are spent: `gh variable set NSTACK_RUNS_ON --body +<label>`. Such a runner needs `git` on its path, and whatever each module's commands need — +its toolchain, its system libraries — which hosted Ubuntu mostly preinstalls; the workflows +install uv themselves. A runner stopped leaves every run queued until it returns. Removing +the variable sends new runs to hosted runners; queued ones keep the label they asked for, and +are cancelled, then run again, by whoever holds **Actions: write** — never the agent's App, +which has no other use for it. What a +pull request costs there or on hosted minutes: about five jobs across the workflows for a +change to one module, each billed at least a minute, plus what the module's own commands take. Never on a public repository: there, a pull request from a +fork would run its code on that machine — and hosted minutes are unlimited anyway. + +## Installation + +```bash +# 1. Tooling at the project's NapkinStack version, as CI installs it (prerequisite: uv) +bash .nstack/install-engine.sh + +# 2. Hooks, once per clone +pre-commit install + +# 3. Frame the project with your agent (nstack discover, .nstack/playbooks/framing.md), then create the first module +nstack new-module billing acme/billing standard + +# 4. Check that the guardrails answer +nstack fitness +``` + +That version is the one in `.copier-answers.yml`; it only changes through `nstack update`, +in a reviewed pull request. A release comes from the registry; a commit, from the framework's +repository, and every run then says an unpublished framework judges it. + +## Receiving a new version of NapkinStack + +```bash +uv tool install "napkinstack==X.Y.Z" --refresh-package napkinstack --with-executables-from pre-commit # the version you want; the index read afresh +git switch main # an update starts from the default branch +nstack update # branch nstack/update-vX.Y.Z, merged and committed +git push -u origin nstack/update-vX.Y.Z # then the PR, validated by CI +``` + +A version published minutes ago may not be served yet: PyPI's CDN can list the previous ones for a +few minutes, and `--refresh-package` clears only uv's own cache. *No version of napkinstack==X.Y.Z* +right after a release means wait a few minutes, then run the same command again. +*Executable already exists: pre-commit* means the engine was installed another way — from its +sources, say: `bash .nstack/install-engine.sh` deletes a link the removed engine left pointing +nowhere and installs the version the project records; a `pre-commit` of another installation it +never touches. Then run the `uv tool install` line above again for X.Y.Z. + +An agent passes its session — `nstack update --session <its identifier>` — and the commit +carries the trailer every commit of an agent carries (`AGENTS.md`, *Identity*). In an agent's run +(`nstack agent run`), `update` without it refuses before it writes anything. + +**When: at a cycle's boundary** — close the cycle, take the update, then accept the next one. +Upgrading mid-cycle changes the judge while a cycle is being judged. + +**Everyone else, once that pull request is merged**, installs the same version — the first +command above. Until then every `nstack` command says, before anything else, that the +workstation is behind the project. + +The merge keeps the project's adaptations and never touches the modules' code. A conflict +stays marked in the file, uncommitted: the team decides, and both the hook and CI reject +any remaining marker. + +## When the framework is wrong + +A message that misleads, a check that misjudges, a page that contradicts a command: it is not +worked around here, it is fixed where it lives — and this project is the proof. + +```mermaid +flowchart LR + D["A defect met<br/>in this project"]:::pr --> C["The framework's sources,<br/>cloned beside the project"]:::fw + C --> T["A failing test,<br/>then the fix"]:::fw + T --> J["This project, judged<br/>by the sources"]:::pr + J --> P["A pull request<br/>to the framework"]:::fw + P -.->|"while it is reviewed"| R["nstack update --ref<br/>the fix's commit"]:::pr + P -->|"merged"| U["nstack update --ref<br/>the merged commit, then the release"]:::pr + + classDef pr fill:#065f46,color:#fff + classDef fw fill:#1e3a8a,color:#fff +``` + +**Legend** — green: in this project · blue: in the framework's repository · dotted: if the +project needs the fix before its merge. + +```bash +git clone <the framework's repository> ../framework # its address: _src_path in .copier-answers.yml +uv run --project ../framework nstack fitness --root . # this project, judged by the sources +``` + +Any command runs that way, with nothing installed. The rest is the framework's own page: +its `CONTRIBUTING.md` says how a fix is tested, proposed and reviewed. While it is reviewed, +`nstack update --ref <commit>` lets this project run on the fix: CI installs that commit, and +every run says an unpublished framework judged it. Once it is merged, the pin moves — to the +commit the framework's default branch received, which the squash made, or to the first release +that carries it. `nstack doctor` says when the pinned commit is on no branch any more. + +**A private project stays private.** The framework's repository is public: what is reported +there describes the defect, never the project — no name, no domain, no content. + +## To do once on GitHub — otherwise nothing is guaranteed + +Workflows **inform**; it is the rulesets that **block**. Without this step the whole +edifice rests on goodwill, which the OS forbids (`.nstack/handbook/07-governance.md`). + +Settings → Rules → Rulesets → on the main branch (private repository: Team or Pro plan): + +- [ ] Pull request required: no direct push to main +- [ ] At least 1 approving review +- [ ] Code owner review required +- [ ] Stale approvals dismissed when new commits are pushed +- [ ] Required checks: `Fitness functions`, `PR scope and review budget`, `Hooks and secrets`, `Test sheet and cycle`, `Module checks` +- [ ] Bypass list empty: nobody merges around the rules, administrators included +- [ ] Main branch cannot be deleted +- [ ] Main branch history cannot be rewritten: no force push +- [ ] The most recent push approved by someone other than its pusher (approval: agent) +- [ ] Branches up to date before merging: the checks judged what will land, main included + +GitHub offers a check to require only once it has run: open a first pull request, then +select them. + +Settings → Rules → Rulesets → a second ruleset, on the branches `nstack/hold/**/*` — where +deliverables are held (`.nstack/handbook/project.md`, *Who holds a deliverable*). Not +`nstack/hold/**`: in a ruleset, `**` stops at a slash, and a hold is two levels down. A hold's +branch is its record, kept after its cycle. Nobody on its bypass list: + +- [ ] Hold branches `nstack/hold/**/*` cannot be force-pushed nor deleted + +Settings → Advanced Security (private repository: the Secret Protection option): + +- [ ] Secret Protection and push protection +- [ ] Private vulnerability reporting, public repository (the `SECURITY.md` channel) + +Settings → Actions → General: + +- [ ] Allowed actions: GitHub's own, plus `astral-sh/setup-uv` +- [ ] SHA-pinned actions required +- [ ] Workflow approval for every outside contributor, public repository +- [ ] Workflow token read-only; Actions neither creates nor approves pull requests + +Settings → General → Default branch: + +- [ ] Default branch `main`: the branch every workflow and ruleset here watches + +Settings → General → Pull Requests — three that need no paid plan and no Administration +permission, so they hold on any repository. Auto-merge is armed on each pull request by its +author, when it is opened: + +- [ ] Auto-merge available: a pull request armed for it merges itself once approved and green +- [ ] Squash the only merge method: one pull request, one commit on main +- [ ] Head branch deleted on merge: a merged branch is history, not a place to work + +Issues → Labels: + +- [ ] Labels `cross-module`, `over-budget`, `out-of-cycle`, `request`, `bug`, `architecture`, `debt` and `acceptance` — the first three make the exceptions + visible **and countable** (`.nstack/handbook/10-measurement.md` §3); the other five are + the ones the issue templates put on an issue, which GitHub drops without a word when the + label does not exist + +A GitHub App per agent, installed on this repository — **the identity your agents work under** +(`.nstack/handbook/07-governance.md` §7). One command, in your own terminal beside your browser, +and two clicks at the forge — *Create GitHub App*, then *Install* on this repository: + +```bash +nstack agent add scout # scout: your agent's name on this workstation +nstack agent run scout -- claude # then, every time: your agent, in its clone, as the App +``` + +It makes the App from a manifest, keeps its key in a folder of the agent's own +(`~/.config/nstack/agents/scout/`, readable by you alone; on Windows under `%APPDATA%`, as your account's permissions there allow), and clones the project beside this one, +`<project>-scout`, configured to commit and push as the App, with tokens minted per call for +this repository alone and valid one hour. `nstack agent run` starts the agent there without +your tokens, your SSH agent or your git configuration — and refuses to start it while your +`~/.netrc` holds a login for the forge, which git would hand over whatever its configuration. It is not a sandbox: an agent that +looks for your files can still read them — a container or a system user of its own closes that. +It says so as it starts, in a few lines on the error output — the agent's own output is untouched. + +**The agent commits as the App, in any repository.** Its identity is written in its own git +configuration, the one `nstack agent run` hands git, with `user.useConfigOnly`: a second clone +the agent makes commits as the App too, and a repository with no identity refuses the commit — +git never makes one up from this machine's user and host name, which a push would publish. In +the project's clone, the pre-push hook refuses a commit whose author or committer is not the +agent's. `nstack agent status` says an agent whose configuration lacks it; `nstack agent run` +writes it for an agent made before. + +**Your agent tool's configuration is still yours.** The tool you start — Claude Code, another — +reads its own configuration from your home (`~/.claude` for Claude Code): your sandbox, your +hooks, your permissions apply to the agent too. For Claude Code, `nstack agent run <name> -- claude` +adds `--settings` with a file of the agent's own: when your sandbox is on, it lets the agent reach +the forge — on github.com, the host of a run's logs too — and write its `gh` folder, and sets `GIT_HTTP_PROXY_AUTHMETHOD=basic` for git behind the +sandbox's proxy — nothing more; it never turns the sandbox off, and settings your organisation +manages still win over it. So that the agent builds and tests there, it also opens a cache of the +agent's own (`~/.config/nstack/agents/scout/cache`, its `XDG_CACHE_HOME`) — uv and pre-commit keep +your warm caches, `UV_CACHE_DIR` and `PRE_COMMIT_HOME`, since the sandbox opens no package index; +builds that write elsewhere, such as Cargo's `~/.cargo`, need that folder in your sandbox's +`allowWrite` — and sets the clone so +that `git switch -c <branch> origin/main` and a plain `git push` never write `.git/config`, which +the sandbox protects. The sandbox also protects `.claude/skills/` — an agent never rewrites its own +instructions —, so git could not write the committed skills there: the clone leaves that folder out +of its working tree (a sparse checkout: still in every commit), and the agent gets the default +branch's skills from a folder of its own (`--add-dir`), refreshed at each run. A sandbox outside +that clone puts mount points over the paths it protects, `.claude/skills/` among them: the tree is +then not the commit, and `nstack attest` refuses it and names them — a record is made outside the +sandbox, by the person in a terminal of their own, outside the agent's session, or by the decider. Unix sockets — audio, display, the session bus — stay closed unless the +project answers `agent_sockets: true` (`.nstack/handbook/07-governance.md` §7 says the risk). +Given your own `--settings`, it adds none and says so. A hook of yours that refuses `gh` — against your own +account — lets an agent's session through only when its `gh` is the App's +(`.nstack/handbook/07-governance.md` §7 has the test). The agent checks who it is with +`nstack agent status`; in a project, the same command lists that project's agents, and +`--all` every project's on the workstation — shown only when asked, since one workstation may +serve several clients. +When you cannot create an App for this repository's owner, `--mine` makes it on your account and +asks the owner to approve its installation. What the App gets — set by the command, and read +by no check afterwards: + +- [ ] Permissions: Contents, Pull requests and Issues read and write; Commit statuses write, + for the attested record's status; Actions and Checks read; Workflows write only when + agents maintain CI (`--workflows`); never Administration +- [ ] No webhook; private, unless `--mine` +- [ ] Its private key stored outside any repository; in CI, the CI's secrets +- [ ] The agent's session reaches no human credential: `nstack agent run` keeps them out of its + environment; keeping it out of your files is a sandbox's work +- [ ] Its commits carry the App's identity, never one git makes up from the machine — `nstack agent status` +- [ ] On `approval: agent`, one App per agent: an App never approves what it pushed + +Rather than click through these pages, print the calls that close the distance and run them +yourself — the command reads the repository, writes nothing, and never plans to lower a +setting or to rewrite a ruleset: + +```bash +nstack settings +``` + +Or have it make them, in one gesture of yours, under your own credential. Never your agent's: a +credential that administers a repository can always give itself the right to push, so this +gesture stays a person's — it refuses a GitHub App's token, an agent's session and CI, shows +the plan and the account it would act as, and makes nothing until you confirm at the keyboard. +Run it in your own terminal. The credential, in this order: + +- **a token in `GH_TOKEN`** (or `GITHUB_TOKEN`), when one is set — portable, no `gh` needed: + fine-grained, limited to the repository, Administration: write and Issues: write, valid one day. + Without a credential, the command prints GitHub's form for it, filled in; you pick the repository there. +- **otherwise your `gh` login**, as `gh` itself would use it — its token, scope `repo`, is + enough. With two accounts logged in, `gh` uses the active one: `gh auth switch` first, and + check the account the plan names. + +```bash +nstack settings --apply # your gh login: the plan, your yes, each change, then nstack doctor + +read -rs GH_TOKEN && export GH_TOKEN # or a token: paste it, neither shown nor kept +nstack settings --apply +unset GH_TOKEN # then revoke the token at the forge +``` + +Then check, read-only: + +```bash +nstack doctor +``` + +`nstack doctor` exits 0 when everything is read and in place, 1 when a setting is missing, +and 2 when nothing read is missing but something could not be read. + +`nstack doctor` is also where a project learns that a newer version of NapkinStack is +published: one line, with its notes and the way to take it — information, never a gap. The +registry is asked one other question: `nstack update` says when the version it lays is not +on PyPI yet, since the project's CI installs it from there and stays red until it is. Minutes +after a release, PyPI's index may not list it yet: `install-engine.sh` asks again for about two +minutes and a half, said, before it fails. + +`nstack doctor` reads the token from `GH_TOKEN`, otherwise `GITHUB_TOKEN`: a fine-grained +token, limited to the repository, with the **Administration: read** permission — and +**Actions: read**, to be told of a workflow failing run after run on the default branch, which +no required check shows — and, on a private repository, **Contents: read**, to read GitHub's own +validation of the code owners file: an owner GitHub does not know, such as an organisation named +alone, leaves the paths it names with no owner. Without a token, the GitHub part stays "not verified", never compliant. +It never reads your `gh` login by itself; to have it read with that login, for one run: +`GH_TOKEN=$(gh auth token) nstack doctor`. + +--- + +## What is in this repository + +| Path | Role | Who reads it | +|---|---|---| +| `AGENTS.md` | **The kernel**: the rules loaded for every task | Agents, every time | +| `modules/` | The code — one unit of parallelism per folder | Humans and agents, scoped | +| `contracts/` | The **only** channel between modules. Created by the first contract, not before | Producers and consumers | +| `docs/project/` | **The discovery, the charter and the cycles**: who it is for, what is delivered now. Born with the first of them | Everyone, agents first | +| `.nstack/` | **The framework's one folder.** Everything in it arrives by update; nothing outside it does, but the kernel and what the forge reads at the root | The foundation team | +| `.nstack/playbooks/` | Rules loaded **by trigger** (security, data, UX…) | Agents, when triggered | +| `.nstack/forms/` | The forms a command or a playbook copies: charter, cycle, decision, rules | Agents and commands | +| `.nstack/handbook/` | **The handbook**: the why behind every rule | Humans, once | +| `docs/adr/`, `docs/pdr/` | The decisions taken, with their success criterion | Everyone, on demand | +| `.copier-answers.yml` | The NapkinStack version and the creation answers | The `_` lines: `nstack update`, never by hand. The answers: the decider, with `nstack config`, in a pull request | +| `.github/` | What makes the rules non-bypassable | GitHub | + +> **`.nstack/handbook/` is never loaded into an agent's context.** It is the human reference. +> What an agent loads, and in which order, is said once: the kernel's §4. That is the whole +> difference between a handbook and an operating system. + +--- + +## The commands + +```bash +nstack --help # lists the commands +nstack fitness # manifests + boundaries + skills + plan + hygiene — before every commit +nstack discover <idea-file> # starts a discovery, for your agent +nstack plan # what needs a person first; then the discovery, the charter and the cycles (docs/project/), the decisions due at a closure, the project across its cycles, who holds what; --prune removes the empty start branches it names +nstack claim D<n> --session <s> --person @<you> # takes a deliverable before its first change; nstack unclaim gives it back + # --take-over: a stale hold, or your own from another agent's session or outside nstack agent run; your agent restarted renews without it +nstack deliver D<n> --held '#<pr>' --session <s> # records a merged deliverable delivered, and removes its empty start branch; --write-states at the closure +nstack agent add <name> [--clone <dir>] · nstack agent run <name> -- <command> # an agent's own App and clone; add is a person's +nstack agent status # who this agent is — its App, repository, clone, gh and hooks; for a person, this project's agents +nstack board [--dry-run] # the cycles shown on GitHub as milestones and issues — CI runs it on every merge; --dry-run previews a proposed cycle; by hand, Run workflow, never beside it +nstack skills # generates the agents' skills from the playbooks +nstack doctor # the workstation and the forge's settings, read-only +nstack settings # the calls that would bring the forge's settings to the checklist; --apply: yours makes them +nstack new-module <name> <owner> <criticality> [--user-facing] # --user-facing: a user sees it, which decides a test sheet +nstack new-contract <name> # a contract, and the first time the module that holds them all +nstack check [module] # the module's commands.check; default: every module +nstack test [module] # commands.test, likewise +nstack bootstrap [module] # commands.bootstrap, when declared +nstack run <module> # local start, when commands.run is declared +nstack e2e [module] # end-to-end scenarios, when commands.e2e is declared — one run at a time on a machine, unless sealed +nstack clean [module] # removes a module's build outputs, when commands.clean is declared +nstack release [module] # a module's artefacts into dist/<module>, when commands.release is declared +nstack pr-check --body-file <file> [--labels a,b] # test sheet and cycle, as CI reads them from the pull request + # with a token and one open pull request at the head, its own labels are read +nstack attest --body-file <file> [--labels a,b] # the CI's checks run here, recorded on the commit; labels as pr-check takes them + # module checks kept while what they read is unchanged, 7 days at most (--again runs them) +nstack attest --void <commit> --reason "<why>" # a record known unsound: never kept from again, the head attested again + # --accept-identity: a first record under an identity the history does not show yet +nstack pr-scope --base <base> # one pull request = one module, within the review budget, as CI reads it +nstack landed [--span <before>..<after>] # what reached this branch outside a pull request, recorded +nstack modules --changed-since <base> # the modules with a file changed, as CI lists them +nstack modules --changed-since <base> --with-contract-sides # ... and both sides of a changed contract +nstack compat [module] --base <base> # a contract version consumed or stable: the merged proof +nstack update [--ref <tag>] # brings the project to another version of NapkinStack; --forge moves it to another forge +nstack config [<setting> [<value>]] # the decider's settings: lists them, reads one, lays a change on a branch for review +# check, test and run of a module: the `commands` section of its MANIFEST.yaml +``` + +Every module exposes the **same verbs**, whatever its technology. That is what lets +someone move between modules without relearning anything (`.nstack/handbook/09-platform.md` §2). + +--- + +## Agent skills + +The playbooks are exposed as skills, so that loading them on demand becomes the runtime's +job rather than a kernel instruction. One `SKILL.md` per playbook, in the open Agent Skills +format, written where each tool looks: `.claude/skills/` for Claude Code, `.agents/skills/` for +Codex and the other tools that read that layout. A tool that reads both may list a skill twice: +the same bytes, so either one loads the same playbook. + +```bash +nstack skills # generates .claude/skills/ and .agents/skills/ from .nstack/playbooks/ +nstack skills --check # checks they are in sync (runs in CI) +``` + +**`.nstack/playbooks/` stays the source of truth.** The skills are generated from it, never +edited by hand — you change the playbook, run `nstack skills`, and commit both. They are +**committed**, as a lockfile is: an agent starting from a fresh clone — a cloud agent, a new +contributor's — has them. `nstack init` commits them with the project, `nstack update` in its own +commit; `.gitattributes` marks them generated, so the forge folds them in a review, and the +review budget does not count them. A playbook with no entry in `.nstack/skills.yaml` +fails CI; a skill that drifted from its playbook, or was edited by hand, fails it too (S3). +Inside an agent's sandbox, `.claude/skills/` cannot be written: an agent that changes a playbook +regenerates `.agents/skills/` alone, and a person runs `nstack skills` and commits the rest — S3 +says it until then. A change to the agents' instructions passes a person's hands. + +This indirection has a reason: a tool is an **adapter**, never a foundation +(`.nstack/tooling-profile.md`). If the rules existed only as skills, the OS would stop +working with any other agent — and the trigger table of kernel §4 is there for exactly +that case. + +Enforcement, on the other hand, **never moves down into a plugin**. An agent-side hook is +fast feedback, not a guarantee: the blocking checks stay in CI +(`.nstack/handbook/07-governance.md` §4). + +--- + +## The three rules to remember + +1. **One PR = one module.** A change touching two goes through an expand/contract + sequence on the contract (`.nstack/handbook/03-contracts.md` §4). +2. **The oracle before the code.** The success criterion is executable and red before the + first generated line (`.nstack/handbook/05-workflow.md` §3). +3. **Convention is the default choice.** It needs no justification; every deviation is + justified by an observable user value (`.nstack/handbook/06-decisions.md` §2). + +--- + +## What is not provided — and why + +No stack: no language, no application framework, no database. The OS imposes a **selection +method** and a decision trail, not a list of technologies (`.nstack/handbook/06-decisions.md` §7). + +A new module therefore declares no command: it is green while it holds only its +description, and `nstack fitness` asks for `check` and `test` with its first file of code. +Wiring them, and `run`, onto your own tooling is your job. The **names** never change, the +**content** is yours. + +## What is left to wire after the installation + +- [ ] The `check` and `test` commands of every module, in its `MANIFEST.yaml` +- [ ] The contract format chosen, and the contract tests and the comparator behind + `commands.compat` that go with it +- [ ] The review budget (400 lines / 15 files are a starting point): `nstack config review_budget_lines <n>` + and `review_budget_files <n>`, if yours differs +- [ ] Re-read the `description` fields in `.nstack/skills.yaml` — they are what triggers + the skills, and they must speak your domain's vocabulary +- [ ] The `e2e` command of every user-facing module, and the tools that drive a browser or + an emulator, in `.nstack/tooling-profile.md` diff --git a/.nstack/handbook/README.md b/.nstack/handbook/README.md new file mode 100644 index 0000000..f79abda --- /dev/null +++ b/.nstack/handbook/README.md @@ -0,0 +1,109 @@ +# AI Engineering OS + +A system of rules, boundaries, contracts, documentation and deterministic guardrails that +lets **several teams and their AI agents develop in parallel** without generation speed +blowing up complexity. + +--- + +## The problem this OS solves + +Agents make writing code nearly free. Three costs do not come down: + +1. **Understanding** — somebody still has to know what the system does. +2. **Verification** — somebody still has to review and validate. +3. **Coordination** — several teams have to move without blocking each other. + +A generation accelerator plugged into a system without boundaries does not produce a +faster project: it produces an unreadable project faster. + +This OS therefore treats **cognitive load**, **review capacity** and **inter-team +coupling** as the project's three scarce resources, and organises everything else around +preserving them. + +--- + +## The five structuring ideas + +| # | Idea | Practical consequence | +|---|------|----------------------| +| 1 | **The prompt is a transit zone, not a residence** | Every automatable rule moves down into CI and leaves the prompt | +| 2 | **The module is the unit of parallelism** | One PR = one module; two modules know each other only through a contract | +| 3 | **The oracle before the generation** | The criterion is made executable before the first line is written | +| 4 | **Convention is the default choice** | It needs no justification; every deviation does | +| 5 | **No stack is imposed** | The OS imposes a selection method, not a list of technologies | + +--- + +## Navigation map + +### What to read, depending on who you are + +| You are… | Read, in order | +|-----------|---------------------| +| **An AI agent** | `AGENTS.md` (kernel) + the module's local `AGENTS.md` + the triggered playbooks | +| **A new developer** | `00-overview.md` → `02-modules.md` → `05-workflow.md` | +| **A tech lead / architect** | `00-overview.md` → `02` → `03` → `07` | +| **The decider** | `project.md` (what needs a person, the closure) → `06-decisions.md` | +| **Joining, with an agent** | `CONTRIBUTING.md` → `glossary.md` → `project.md` → `05-workflow.md` | +| **Whoever creates the project** | `INSTALL.md`, then `09-platform.md` | + +### Project contents + +``` +. +├── README.md The product's front page: the project writes it +├── AGENTS.md ← THE KERNEL: resident, loaded for every task +├── CONTRIBUTING.md, SECURITY.md +│ +├── docs/ ← THE PROJECT'S: nothing here is the framework's +│ ├── project/ Discovery, charter, cycles, the project's own rules — born with the first of them +│ ├── adr/, pdr/ Decisions, and their index +│ └── architecture/, runbooks/ Absent until a decision or an incident needs them +├── modules/ The code: one unit of parallelism per folder +├── contracts/ The only channel between modules — created by the first contract +│ +├── .nstack/ ← THE FRAMEWORK'S: its one folder, received through updates +│ ├── playbooks/ Instruction modules loaded on demand +│ ├── forms/ The forms the commands and the playbooks copy: charter, cycle, decision… +│ ├── tooling-profile.md Capabilities → the tools of the moment +│ └── handbook/ ← this handbook +│ ├── README.md you are here +│ ├── INSTALL.md The foundation's manual: install, forge settings, updates; *The commands*: every `nstack` verb +│ ├── RULES.md Every code a check prints, and where its reason is written +│ ├── project.md What docs/project/ holds, and the two stages of a project +│ ├── 00-overview.md OS architecture, the 4 layers +│ ├── glossary.md the framework's words, plainly, with examples +│ ├── 01-principles.md Non-negotiable principles and anti-patterns +│ ├── 02-modules.md Boundaries, manifest, lifecycle, one PR = one module +│ ├── 03-contracts.md Versioning, expand/contract, contract tests +│ ├── 04-ai-context.md Context firewall, context budget, crossing over +│ ├── 05-workflow.md Verification-first loop, DoR/DoD, review budget +│ ├── 06-decisions.md ADR/PDR, Prior Art Gate, dated success criteria +│ ├── 07-governance.md Where a rule lives, fitness functions, CI, quality gates +│ ├── 08-quality.md Tests, security, reliability, data, UX, QA, UAT +│ ├── 09-platform.md Standard verbs, layout, tooling, onboarding +│ └── 10-measurement.md Metrics, feedback loop, decision review +└── .github/ CI, CODEOWNERS, issue and pull request templates — on GitHub; + elsewhere CODEOWNERS at the root, the form where the forge reads it +``` + +--- + +## How to read these documents + +The documents in `.nstack/handbook/` are **the reference**: they explain, justify and detail. They +are **not** meant to be loaded into an agent's context. + +What an agent loads, and in which order, is said once: the kernel's §4. + +If you need to put a rule in the kernel, re-read `07-governance.md` § "Where does this +rule live?" first. The answer is very often "in CI", not "in the prompt". + +--- + +## Status + +This OS is subject to its own rules: it evolves in small steps, its structuring changes +get an ADR, and every rule it contains is a candidate for automation. See +`10-measurement.md` § "Improving the OS itself". diff --git a/.nstack/handbook/RULES.md b/.nstack/handbook/RULES.md new file mode 100644 index 0000000..0cd3fd1 --- /dev/null +++ b/.nstack/handbook/RULES.md @@ -0,0 +1,192 @@ +# The rules a check names + +Every refusal starts with a code between brackets — `FAIL [K1]`. This page says what each code +refuses and where its reason is written. It defines nothing: the reasons are in the pages it +points at, and the checks are the engine's. A command's own name between brackets — +`FAIL [deliver]`, `FAIL [agent]` — is that command refusing what it was asked: its message says +why, and the action. `[hold]` is `nstack claim`, `nstack unclaim` and `nstack plan --prune` (`project.md`, *Who holds a +deliverable*); `[nstack]` the engine's install and the pre-push hook (`INSTALL.md`; an agent's +identity: *The agent commits as the App*); `[labels]` the labels the pull request check reads. + +```mermaid +flowchart LR + W["Workstation<br/>and forge settings"]:::place --> L["L · G"]:::rule + C["Every commit<br/>and every CI run"]:::place --> F["M · B · S · C · H"]:::rule + P["A pull request"]:::place --> R["P · T · K · V · A · R · C9"]:::rule + D["The default branch"]:::place --> X["W"]:::rule + + classDef place fill:#374151,color:#fff + classDef rule fill:#1e3a8a,color:#fff +``` + +**Legend** — grey: where a check runs · blue: the families of rules judged there. A letter is +a family, a number a rule; a retired rule's number is never reused. + +## M — a module's manifest + +| Code | Refuses | Why | +|---|---|---| +| `M1` | A module without its manifest | `02-modules.md` §5 | +| `M2` | A required field missing, or still holding its template's words | `02-modules.md` §5 | +| `M3` | An unknown lifecycle or criticality value | `02-modules.md` §6 | +| `M4` | *(warning)* A responsibility that takes two sentences, or joins two capabilities | `02-modules.md` §3 | +| `M5` | A deprecated module with no removal date, or past it | `02-modules.md` §6 | +| `M6` | A deprecated contract with no removal date, or past it | `03-contracts.md` §4 | +| `M7` | A module holding code and declaring no `check` and `test` | `09-platform.md` §2 | +| `M8` | A module of criticality high or critical without a runbook | `05-workflow.md` §7 | +| `M9` | A module missing `AGENTS.md`, `README.md`, or `tests/` unless it is a prototype | `02-modules.md` §4 | +| `M10` | A module that does not say whether a user sees it | `05-workflow.md` §7 | +| `M11` | `assembles` naming no module of the project, the module itself, or releases that wait for each other | `09-platform.md` §2 | +| `M12` | An `evidence` declaration that checks nothing: an unknown key; a pattern that is not text, does not compile or matches an empty line; no level or no scenario; `levels` without a group named `level`; a `sealed` that is not true or false | `.nstack/playbooks/tests.md` §1 | +| `M13` | On `approval: agent`, a path a human must approve — a module neither `prototype` nor `standard`, the project's rules, its records, its answers — that the code owners file ends on no owner, or a default owner | `07-governance.md` §7 | + +## B — the boundaries between modules + +| Code | Refuses | Why | +|---|---|---| +| `B1` | A contract read without being declared | `03-contracts.md` §1 | +| `B2` | A reference to another module's code | `02-modules.md` §8 | +| `B3` | A circular dependency between modules | `02-modules.md` §8 | +| `B4` | *(warning)* A contract declared consumed and never read | `02-modules.md` §5 | +| `B5` | Direct access to another module's data | `08-quality.md` §8 | +| `B6` | A consumed contract nobody provides in that version | `03-contracts.md` §4, §6 | +| `B7` | A provided contract whose document does not exist | `03-contracts.md` §2 | +| `B8` | *(warning)* A contract consumed from a deprecated module | `02-modules.md` §6 | +| `B9` | Another module's release artefacts read without assembling it | `09-platform.md` §2 | + +## S — the playbooks and their skills + +| Code | Refuses | Why | +|---|---|---| +| `S1` | A playbook with no entry in the skills configuration | `INSTALL.md`, "Agent skills" | +| `S2` | An entry pointing at a playbook that does not exist, or with no description | `INSTALL.md`, "Agent skills" | +| `S3` | Generated skills that no longer match their playbooks | `INSTALL.md`, "Agent skills" | +| `S4` | A skill whose name or description breaks the skills specification | `INSTALL.md`, "Agent skills" | + +## C — the discovery, the charter and the cycles + +| Code | Refuses | Why | +|---|---|---| +| `C1` | A framing document whose front matter cannot be read | `.nstack/handbook/project.md` | +| `C2` | A charter with an unknown status, no single decider or no success criterion | `.nstack/handbook/project.md` | +| `C3` | A cycle with no goal, no appetite, an end that is not its start plus its appetite, or an `accepted_on` that is not a date | `.nstack/handbook/project.md` | +| `C4` | A deliverable with no id, title or state — or ready, in progress or accepted without acceptance criteria | `05-workflow.md` §6; `.nstack/handbook/project.md`, *What CI checks* | +| `C5` | Two accepted cycles, or an accepted cycle under a charter that is not | `.nstack/handbook/project.md` | +| `C6` | A closed or stopped cycle with no outcome or no end date; a success criterion recorded outside a closure, twice in one, outside the charter's filled criteria, in an unknown state, or observed with no day | `.nstack/handbook/project.md` | +| `C7` | A discovery decided with no decider, date or challenger — or a charter with no go before it | `.nstack/handbook/project.md` | +| `C8` | A document left as its form once its moment has come: the front page's sentence at a go, the whole front page at an accepted charter, the module map once a module holds code | `06-decisions.md` §10 | +| `C9` | *(warning)* An accepted charter changed by a pull request that carries no decision record | `06-decisions.md` §4 | +| `C10` | *(warning)* An accepted decision record due at a closure — its criterion names the cycle, or a date in bold, `**YYYY-MM-DD**`, its end reached — with no reading line; a criterion with neither, holding a plain date its end reached, is told to bold its due date | `06-decisions.md` §6 | + +## H — hygiene + +| Code | Refuses | Why | +|---|---|---| +| `H1` | A path rooted in one person's home directory, in any tracked file | `07-governance.md` §3 | + +## P — the scope of a pull request + +| Code | Refuses | Why | +|---|---|---| +| `P1` | A pull request that changes two modules | `02-modules.md` §7 | +| `P2` | *(warning)* A pull request beyond the review budget | `05-workflow.md` §4 | + +## T — the test sheet + +| Code | Refuses | Why | +|---|---|---| +| `T1` | A change that owes a test sheet and carries none | `05-workflow.md` §7, *The test sheet* | +| `T2` | A sheet with no verifier, a verifier who is an author, a person named verifier with no hand on the pull request — no edit of its description, no review, no comment —, a row left empty, or a row with more cells than its header | `05-workflow.md` §7, *The test sheet* | +| `T3` | A scenario passed with no evidence, or no commit it was verified on | `05-workflow.md` §7, *The test sheet* | +| `T4` | Evidence older than the head commit | `05-workflow.md` §7, *The test sheet* | +| `T5` | A scenario failed, or left not verified with no `human only — <reason>` | `05-workflow.md` §7, *The test sheet* | + +## A — checks attested on a workstation + +Where the project's answer `checks` is `attested` (`.copier-answers.yml`), the checks of a +pull request run on a workstation through `nstack attest`, which records the run on the commit +in git; elsewhere a record is shown, and the forge's CI judges. + +| Code | Refuses | Why | +|---|---|---| +| `A1` | In a project whose checks are attested, a head commit with no record — read from the remote's notes, in CI too | `07-governance.md` §7 | +| `A2` | A record of the head that misses a check the CI runs, or holds a failed one | `07-governance.md` §7 | + +## R — the approvals a pull request carries + +On GitHub, read from the pull request by `nstack pr-check` on the forge's run. Where the forge +dismisses stale approvals on push, R1 never has one to say; R2 reads any repository. + +| Code | Refuses | Why | +|---|---|---| +| `R1` | *(warning)* An approval given on an earlier commit than the head, when commits other than the base branch's followed it — a merge that carries content of its own included —: the approver has not read them. A review starts no run, so it is said, as an annotation on the check, never failed. Unread, it is said | `07-governance.md` §7 | +| `R2` | *(warning)* Every approval is Copilot's code review: GitHub counts it toward the required approvals where the repository allows it — a setting its API does not show —, yet it ran no test sheet and names no session. Said, never failed | `07-governance.md` §7 | + +## K — the cycle a change belongs to + +These rules bound work inside a cycle. A project with no accepted charter is **unframed**: +it has no cycle, K1 to K3 and K5 say nothing there, and every other rule applies. + +| Code | Refuses | Why | +|---|---|---| +| `K1` | In a framed project, delivery work with no accepted cycle | `.nstack/handbook/project.md`, *What CI checks* | +| `K2` | Delivery work from the cycle's end date — its first day over: the circuit breaker | `.nstack/handbook/project.md`, *What CI checks* | +| `K3` | Delivery work that names no ready or in-progress deliverable | `.nstack/handbook/project.md`, *What CI checks* | +| `K4` | The out-of-cycle label with no justification | `.nstack/handbook/project.md`, *What CI checks* | +| `K5` | Delivery work for a deliverable someone else holds — from none of the hold's sessions (a merge counts), nor its person's account | `.nstack/handbook/project.md`, *Who holds a deliverable* | + +## V — a contract version someone relies on + +| Code | Refuses | Why | +|---|---|---| +| `V1` | A frozen contract version changed without the compatibility proof — and, as a *(warning)*, contracts consumed while the contracts module declares no comparator | `03-contracts.md` §4 | + +## W — what reached the default branch + +| Code | Records, never refuses | Why | +|---|---|---| +| `W1` | A commit that arrived outside a pull request — read from the last commit the record recorded, so that a run that never started is caught up; a merge whose link to its pull request the forge lost is read from the pull request its subject names, when that one merged it | `07-governance.md` §7 | + +## L — the workstation + +| Code | Reports as a gap | Why | +|---|---|---| +| `L1` | An engine that is not the project's version, or is not a published one — and a pinned commit the framework's default branch no longer holds | `INSTALL.md` | +| `L2` | git or the hook runner missing | `INSTALL.md` | +| `L3` | Hooks not installed in this clone | `INSTALL.md` | +| `L6` | Code owners that do not start with a default owner — on `approval: agent`, that name no human for the project's rules and each module neither `prototype` nor `standard` — and, where no forge reads the file, said | `07-governance.md` §7 | +| `L7` | A project created from a path on one machine | `INSTALL.md` | +| `L8` | Off GitHub, `checks: forge`: no CI is shipped there, so nothing would run the checks | `INSTALL.md` | +| `L9` | A `forge` answer the project's files were not written for — changed by hand; `nstack update --forge` changes it. A remote on another known forge is said, never a gap | `INSTALL.md` | +| `L10` | On GitHub, a line of the code owners file naming an owner GitHub does not know — an organisation by its bare name, a deleted user, a team without access — read from GitHub's own validation of the default branch's file. Unread, it is said, never counted | `07-governance.md` §7 | + +## G — the forge's settings + +The twenty-two lines of GitHub's checklist (`INSTALL.md`, on GitHub). Read on +GitHub only: off it, `doctor` lists what the forge should refuse, reads none of it, and says the +repository *unguarded*; `W1` does not run. + +| Code | Reports as a gap | Why | +|---|---|---| +| `G1` | A direct push to the default branch is possible | `07-governance.md` §7 | +| `G2` | No approving review is required | `07-governance.md` §7 | +| `G3` | No code owner review is required | `07-governance.md` §7 | +| `G4` | A check of the list is not required | `07-governance.md` §8 | +| `G5` | No secret scanning, or no push protection | `08-quality.md` §6 | +| `G6` | No private vulnerability reporting, on a public repository | `SECURITY.md` | +| `G7` | Actions allowed beyond the list | `07-governance.md` §7 | +| `G8` | Actions not pinned to a commit | `07-governance.md` §7 | +| `G9` | A workflow runs for an outside contributor without approval, on a public repository | `07-governance.md` §7 | +| `G10` | A workflow token that writes, or that approves pull requests | `07-governance.md` §7 | +| `G11` | A label missing: one of the three exceptions, or one a shipped issue template puts on an issue | `10-measurement.md` §3 | +| `G12` | Somebody on the bypass list | `07-governance.md` §7 | +| `G13` | An approval that survives a new commit | `07-governance.md` §7 | +| `G14` | Auto-merge not available | `07-governance.md` §7 | +| `G15` | A merge method other than squash | `07-governance.md` §7 | +| `G16` | Merged branches kept | `07-governance.md` §7 | +| `G17` | The main branch can be deleted | `07-governance.md` §7 | +| `G18` | The main branch's history can be rewritten by a force push | `07-governance.md` §7 | +| `G19` | A default branch other than `main`, which no workflow watches | `07-governance.md` §7 | +| `G20` | A hold of a deliverable that can be force-pushed or deleted: the one way past its refusal | `project.md`, *Who holds a deliverable* | +| `G21` | Where another agent approves, the one who pushed last approving what they pushed | `07-governance.md` §7 | +| `G22` | A branch merged without being up to date with main: two changes green apart, red together | `07-governance.md` §7 | diff --git a/.nstack/handbook/glossary.md b/.nstack/handbook/glossary.md new file mode 100644 index 0000000..dbab411 --- /dev/null +++ b/.nstack/handbook/glossary.md @@ -0,0 +1,93 @@ +# Glossary + +The words of this framework, in plain terms: what each means, where you meet it, and an +example. A rule's code — `T5`, `K3`, `P1` — is explained in [`RULES.md`](RULES.md), one line +each. A word of your product's domain belongs to your charter, not here. + +An agent speaking to a person uses these words, and explains one the first time it uses it. + +--- + +## Who + +| Term | What it means | Where you meet it | Example | +|---|---|---|---| +| **Decider** | The person who owns the project: accepts the charter and the cycles, reads the closure, and chooses at a cycle's end | `decider:` in the charter; every pull request that needs a human word | "The decider accepted D29 after trying it on their laptop." | +| **Framer** | An agent that proposes the charter, a cycle and its deliverables; it never decides | The framing playbook | "The framer proposed three deliverables; the decider kept two." | +| **Challenger** | Another agent session, or a person, that attacks a discovery before anyone builds on it | `challenger:` in a discovery | "The challenger found the market already had a free tool." | +| **Author** | The agent that writes a change — one deliverable, in one module | A pull request's commits | "The author fixed the parser and its test." | +| **Verifier** | A session or a person who is not the author and runs the change's test sheet | `Verifier:` in a pull request's description | "The verifier ran S2 again and saw it fail on the head." | +| **Approver** | A human code owner who approves a pull request on the forge, on its evidence — or, where the project answers `approval: agent`, another agent under an identity of its own, for a `prototype` or `standard` module | The forge's *Approve* | "The approver read the sheet, then approved." | +| **Owner** | The team or person a module, or the project's rules, belong to | `owner:` in a manifest; `CODEOWNERS` | "The billing module's owner is acme/billing." | +| **Posture** | Which of the roles above someone holds for a task; the author never verifies or approves its own work | `05-workflow.md` §10 | "One agent was the framer on Monday and the author on Tuesday." | +| **Session** | One run of an agent, named by an identifier its commits carry as `Agent-Session` | A commit's trailer; `Verifier: session …` | "Agent-Session: billing-d12-parser" | + +## The work + +| Term | What it means | Where you meet it | Example | +|---|---|---|---| +| **Discovery** | An idea tested before anything is built: evidence, a hypothesis, a challenge, then a decision | `docs/project/discovery.md` | "The discovery of an export tool ended in kill." | +| **go · clarify · kill** | A discovery's decision: build it, ask more, or drop it | `decision:` in a discovery | "go, with a smaller first cycle." | +| **Charter** | The project's founding page: users, problem, constraints, success criteria, what is out | `docs/project/charter.md` | "The charter says: used at every meeting for two weeks." | +| **Framed · unframed** | A project with an accepted charter is framed and its work is bounded by cycles; before that it is unframed — a stage, not a fault | The first lines of `pr-check` and `plan` | "Unframed: the cycle rules say nothing yet." | +| **Cycle** | A bounded stretch of work: one goal, a few deliverables, an appetite, an end date | `docs/project/cycles/` | "Cycle 03, the window, from 17/10 to 07/11." | +| **Appetite** | How long the decider wants to spend on a cycle — a choice, not an estimate | `appetite_weeks:` in a cycle — `appetite_days:` for one shorter than a week | "An appetite of three weeks." | +| **Circuit breaker** | A cycle's end date: past it, the work stops and the decider chooses to ship, reframe or stop | `end:` in a cycle; rule K2 | "The circuit breaker fell; the last deliverable was deferred." | +| **Deliverable** | Something a user can observe, with acceptance criteria, in one module | `D<n>` in a cycle | "D18: a user reads one meeting's minutes beside its transcript." | +| **proposed · ready · in-progress · delivered · accepted · deferred · dropped** | A deliverable's states: drafted, testable and waiting, being built (an older written state, still read), delivered — computed from an `nstack deliver` record, never written — accepted, written at the closure from the records (`nstack deliver --write-states`), moved to later, abandoned | `state:` of a deliverable | "D26 is ready: its criteria can be tested." | +| **met · observing** | A success criterion's states, recorded at a cycle's closure: reached; being observed since a day, for a criterion that holds over time. One never recorded is not yet met | `success:` of a closed or stopped cycle | "Criterion 1 is observed since 8 November: two weeks to go." | +| **Reading · met · missed · superseded** | A decision record's success criterion read at a cycle's closure, when the criterion names the cycle or a date in bold (`**YYYY-MM-DD**`) its end reached; written in one line under the criterion, never by rewriting the record | `Read at <cycle>'s closure, <date>: …` in a PDR or an ADR; rule C10 | "The engine decision was read at 03-the-window's closure: missed — a new record supersedes it." | +| **Hold · stale** | A deliverable taken by one contributor and their agent before its first change, so that nobody else delivers it; stale when nobody has worked on it for the project's `hold_days`, and then anyone may take it over. A hold lasts its cycle: its branch stays, the hold's record | `nstack claim`, `nstack plan`; rule K5 | "D30 is held by @alice since Monday; D31 is free." | +| **proposed · accepted · closed · stopped** | A cycle's states, and a charter's first two. A next cycle the decider accepted while one runs stays proposed with the day of their word, and the running cycle's closure accepts it | `status:` of a cycle or the charter; `accepted_on:` | "Cycle 02 closed with two deliverables accepted." | +| **Oracle** | The executable success criterion of a task, written and seen failing before the change | The *Oracle* section of a pull request | "The oracle: a test that a refused key says why." | +| **Test sheet** | The scenarios of a change, written before the code and run by a verifier, each with its evidence | *Test sheet* in a pull request's description | "Three scenarios, all passed on the head." | +| **Scenario** | One row of a test sheet: given, when, then — **automated**, **explored** by hand, or **human only** | A test sheet's rows | "S5, explored: the button stays reachable on a phone." | +| **Evidence** | What shows a scenario's result: a run, a log, a screenshot, with the commit it was produced on | The *Evidence* and *Commit* columns | "The CI run's trace, at e4f5a6b." | +| **Acceptance** | A person trying a deliverable themselves, and saying what they saw | An issue labelled `acceptance` | +| **What needs a person** | A cycle's table of what only a person can do — a trial, a word, a gesture; `nstack plan` opens with it as *Needs you*, or says *Nothing needs you* only when certain | `## What needs a person` in a cycle; `nstack plan` | "Needs you (1): D38 — run the installer on a Mac." | +| **Closure** | A cycle's end, written by the framer and approved by the decider: the states written from the records, the outcome, the success criteria moved | `## Closure` of a cycle; `outcome:` | "Closed, completed: 12 of 12 accepted." | "Acceptance on Ubuntu: installed from one package." | + +## Modules and contracts + +| Term | What it means | Where you meet it | Example | +|---|---|---|---| +| **Module** | A part of the system that can be understood, changed, tested and validated without the rest | `modules/<name>/` with its manifest | "The capture module records; it knows nothing of minutes." | +| **Manifest** | A module's identity card: owner, criticality, contracts provided and consumed, commands | `MANIFEST.yaml` | "The manifest says the module consumes transcript v1." | +| **Contract** | A versioned interface between two modules — the only way they talk | `contracts/<name>/v<n>/` | "recording v1: the events the recorder prints." | +| **Provides · consumes** | A module that publishes a contract version, and one that relies on it | `provides:` and `consumes:` in manifests | "The shell consumes summarising v1, which summary provides." | +| **Expand / contract** | The sequence of pull requests that changes a contract without breaking its consumers | `03-contracts.md` §4 | "Add v2, move the consumers, then remove v1." | +| **Criticality** | What a module's failure costs, as the decider settles it; it sets what each change of the module must show | `criticality:` in a manifest | "Capture is critical: a lost recording is lost for good." | +| **prototype · standard · high · critical** | The criticality values: a failure costs nothing (thrown away), a user's patience, a day of work, or a key, an order, money, personal data | `criticality:` in a manifest; `05-workflow.md` §7 | "From high, a runbook is required." | +| **User-facing** | A module a user sees; from standard up, its changes need a test sheet | `user_facing:` in a manifest | "The window is user-facing." | +| **Lifecycle** | A module's stage, from its first idea to its removal | `lifecycle:` in a manifest | "export is proposed: nothing built yet." | +| **proposed · active · maintenance · deprecated · retired** | The lifecycle values: planned, in use and changing, kept but no longer extended, being removed by a date, gone | `lifecycle:` in a manifest; `02-modules.md` §6 | "deprecated, removal_date 2027-01-31." | + +## Rules and checks + +| Term | What it means | Where you meet it | Example | +|---|---|---|---| +| **A rule's code** | A letter for a family and a number, naming one rule the engine applies; each is one line of `RULES.md` | `FAIL [T1]`, `WARNING [K3]` in a command's output | "T1: a change owes a test sheet and carries none." | +| **Fitness function** | An automated check that fails when the architecture drifts — a forbidden dependency, a boundary crossed | `nstack fitness`; families M, B, S, C, H | "B2 refused a read into another module's folder." | +| **Review budget** | The most a pull request may change — lines, files — so that a person can review it | `nstack pr-scope`; rule P2 | "412 lines of 400: over budget." | +| **cross-module · over-budget · out-of-cycle** | The labels that allow an exception — several modules, a large change, work outside the cycle — each with its reason, and counted | A pull request's labels | "out-of-cycle: a production incident." | +| **Forge** | Where the project's changes are merged: GitHub, GitLab, Forgejo, Gitea, another, or none. Off GitHub no setting is read and no CI is shipped: the checks are attested, the repository said unguarded | `forge` in `.copier-answers.yml`, changed by `nstack update --forge` | "On GitLab: the checks attested, the repository unguarded." | +| **Guarded · unguarded** | Whether the forge can refuse a merge that breaks the rules; on some plans nothing can | `nstack doctor` | "Private on a free plan: unguarded." | +| **Checked · attested** | A change's checks ran on the forge's CI, or on a workstation and were recorded on the commit | `Checks :` in `pr-check`; `nstack attest` | "Attested on a workstation, 5 of 5." | +| **Published · unpublished** | Whether the engine judging a project is a released version or a local copy | The first line of every judging command | "Judged by an UNPUBLISHED NapkinStack — a local checkout." | +| **Sources** | A contributor's engine: a local checkout of the framework that holds the project's version, ahead of what CI installs — said by `doctor`, not a gap | `SOURCES [L1]` in `nstack doctor` | "Sources at v0.11.0-3: ahead of the project's v0.11.0." | +| **Prior art gate** | Before a structuring decision: find how the field does it, adopt that unless a user gains from another way | The *Prior art* section of an ADR or a PDR | "Copier, because the field already uses it." | + +## Records and files + +| Term | What it means | Where you meet it | Example | +|---|---|---|---| +| **ADR · PDR** | A record of a technical decision (architecture) or a product decision, kept for whoever comes later | `docs/adr/`, `docs/pdr/` | "A PDR says why the export was dropped." | +| **Kernel** | The short instructions every agent session reads first | `AGENTS.md` at the root | "The kernel says: never verify your own work." | +| **Playbook** | Instructions an agent loads for one kind of task | `.nstack/playbooks/` | "The verification playbook." | +| **Skill** | A playbook as the agent's tool loads it, generated from it | `.claude/skills/`, `.agents/skills/`, `nstack skills` | "The skills are regenerated, never edited." | +| **Handbook** | The framework's manual, kept in the project | `.nstack/handbook/` | "07-governance.md says when the forge cannot guard." | +| **Form** | A blank page to copy and fill — a charter, a cycle, an ADR | `.nstack/forms/` | "The cycle form, copied at framing." | +| **Seat** | A file whose content is the project's own; an update never writes into it | `README.md`, the decision indexes | "The README is a seat: the update leaves it." | +| **Skeleton** | The framework's files a project receives and owns — kernel, playbooks, handbook, CI, hooks, forms | `nstack init`, `nstack update` | "The update merged the skeleton's new handbook page." | +| **Engine** | The versioned tool that creates and updates projects and runs the checks | `nstack`, its version on every judging run | "nstack 0.10.0." | +| **Answers** | The project's choices recorded at creation, with the framework's version; the decider's settings among them, listed and changed by `nstack config` | `.copier-answers.yml` | "checks: forge." | diff --git a/.nstack/handbook/project.md b/.nstack/handbook/project.md new file mode 100644 index 0000000..9a5b995 --- /dev/null +++ b/.nstack/handbook/project.md @@ -0,0 +1,231 @@ +# The project's own folder — `docs/project/` + +It holds what the framework cannot know about this project: who it is for, when it is finished, +and what is being delivered now. Every agent session reads the charter and the current +cycle before working (`AGENTS.md` §4). + +| File | Holds | Written by | Accepted by | +|---|---|---|---| +| `discovery.md` | An idea tested: evidence, value hypothesis, challenge, decision | The framer, then the challenger (`.nstack/playbooks/discovery.md`) | The decider | +| `charter.md` | Users, problem, constraints, risks, success criteria, out of scope | The framer (`.nstack/playbooks/framing.md`) | The decider | +| `cycles/NN-<slug>.md` | One goal, a finite list of deliverables, an appetite, an end date, the closure | The framer | The decider | +| `rules/<subject>.md`, `rules/always.md` | The project's own rules, read with the playbook of the same name; absent until the project has one | Whoever meets the constraint, the decision or the incident | The foundation team | +| `.nstack/forms/` — `discovery.md`, `charter.md`, `cycle.md`, `rules.md` | The forms these files are copied from; they are the framework's and live in its folder | — | — | +| `handover.md` | **Start here after a break**: where the work stands, what is in flight, and how to work in this repository | The framer, at each interruption | — | + +```mermaid +flowchart LR + P["proposed"]:::draft -->|"the decider accepts"| A["accepted<br/>running from start"]:::run + A -->|"every deliverable delivered or accepted"| C["closed<br/>completed"]:::ok + A -->|"end date reached"| B{"Circuit breaker<br/>the decider chooses"}:::stop + B -->|"ship what is delivered or accepted"| S["closed<br/>shipped"]:::ok + B -->|"new cycle"| R["stopped<br/>reframed"]:::stop + B -->|"stop the project"| X["stopped<br/>stopped"]:::stop + + classDef draft fill:#374151,color:#fff + classDef run fill:#1e3a8a,color:#fff + classDef ok fill:#065f46,color:#fff + classDef stop fill:#7c2d12,color:#fff +``` + +**Legend** — grey: a proposal · blue: the cycle in progress · green: an accepted end · +red: the circuit breaker and what it can lead to. + +## Framed, or unframed + +```mermaid +flowchart LR + U["UNFRAMED<br/>no accepted charter"]:::un -->|"the decider accepts<br/>the charter"| F["FRAMED<br/>cycles bound the work"]:::fr + U -.-> RU["Every rule applies<br/>except the cycle's"]:::note + F -.-> RF["Every rule applies"]:::note + + classDef un fill:#374151,color:#fff + classDef fr fill:#1e3a8a,color:#fff + classDef note fill:#065f46,color:#fff +``` + +**Legend** — grey: a project that has framed nothing yet, a stage and not a fault · blue: +a project whose charter is accepted · green: what judges a change in each. + +The stage is read from this folder, never declared, and every run that judges names it. An +unframed project is held to its boundaries, its contracts, the scope of its pull requests, +the test sheet and the hooks; only the rules that bound work inside a cycle — K1 to K3 and K5 — are silent, +since there is no cycle. **Framing is worth its price when there is something to bound** — +several people, a deadline, a decider who is not the one typing. It is one-way: once the +charter is accepted, a project between two cycles is framed, and is told which cycle is +missing. + +## What CI checks + +| Check | When | Rules | +|---|---|---| +| The plan, a fitness function | Every push | Formats; one accepted cycle at a time, under an accepted charter; `end` = `start` + the appetite; acceptance criteria once a deliverable is ready; closures recorded; a discovery decided with its decider and date, a charter only after a go. A charter, a cycle or a deliverable still holding the template's words is refused. A decision record due at a closure and not yet read is warned of, never refused (C10) | +| The pull request check | Every pull request changing a module beyond its description — manifest, `AGENTS.md`, `README.md`, `docs/`, unless the manifest moves its criticality or its user-visible surface; not a framework update — **once the charter is accepted** | An accepted cycle; not past its end date; a ready or in-progress deliverable named — and, when someone holds it, delivered by its holder — or the `out-of-cycle` label with its justification. An accepted charter changed with no decision record is warned of (C9) | + +## A cycle's progress + +`nstack plan` opens with what needs a person — `Needs you (n):`, one line each: a charter or a cycle waiting for +the decider's word — a next cycle accepted while one runs (`accepted_on`) waits for its closure, not for them —, a cycle at its end or with nothing left to deliver, and each open row of the cycle's *What needs a +person*. A row closes when its deliverables are accepted, deferred or dropped. A delivery record closes it only when +the row names nothing but ids and its gesture cites what the record cites; a row saying more (`D66, trial`) waits for +the person: a delivery proves a merge, never a person's answer. *Nothing needs you* is said only when certain; a +cycle with no such section, or checks that fail, gives `Needs you: cannot say`. It reads the repository: a pull request waiting for a human approver is not in it yet. +A decision whose criterion is due stays a warning below: an agent reads it, and only a missed one comes to a person. + +Read, never kept: `nstack plan` computes the progress from the accepted cycle's front matter and says it in +one line, then who holds each deliverable. + +``` +Cycle 03-the-window: 10 of 14 accepted · 2 in progress · 2 ready · day 5 of 21, 17 left (ends 2026-11-07) +Holds in 03-the-window: 3 held, of which 0 stale (from origin; stale after 7 days without work): +``` + +Nobody writes progress down during a cycle. Once a deliverable's work is merged and each criterion holds, +the agent records it, with no pull request and nothing under `docs/`, and the plan computes `delivered`: + +```bash +nstack deliver D30 --held '#412' --session alice-d30 # every criterion held by that pull request +nstack deliver D30 --held '1=#412' --held '2=#415' --session alice-d30 # criterion by criterion; an acceptance issue the cycle names counts +nstack deliver D30 --held '1=#412' --held '1=#413' --held '2=#415' --session alice-d30 # a criterion held by two: each kept +``` + +It is refused with no merge of the deliverable on the default branch since the cycle started, with a criterion +unanswered, or with an answer that is no merge of it, nor the acceptance issue the cycle names for it. Carried from +an earlier cycle, its merges there, only that issue answers. A session on the hold, its person or the decider records it, a stale hold +being taken over first. A delivered deliverable is not held, never goes stale, cannot be taken, and its issue +closes; its recorder or the decider withdraws a record found wrong with `nstack unclaim`, and once a merge it names or every merge is seen reverted it reads as back in work; a revert that names nothing it undoes is not seen. +The rule sees that a merge exists, never that a criterion is really met: the closure's reading is what +catches a false record. Below the holds, `nstack plan` names what is merged and not recorded, read from commit +titles, no approval checked. At the closure, `nstack deliver --write-states` writes each recorded deliverable as `accepted` in the cycle file, +for the closure's one pull request: its approval is the acceptance (`.nstack/playbooks/framing.md` §5). + +*Accepted* counts what the decider accepted; a `dropped` deliverable counts in nothing. From its +end date — the first day the cycle is over — the line says the circuit breaker fell and the +decider chooses, and the pull request check refuses delivery work (K2). The project's own +success — the charter's criteria — is recorded at a cycle's closure, and said with the project +below. An agent reporting +progress gives this line, so that one figure circulates. + +### On the forge + +The same plan, where a person already looks: after every merge to the default branch, and once a +day — so that a new holder shows within a day —, the workflow *Plan on the forge* runs `nstack board`. Each cycle the decider accepted, +closed or stopped is a **milestone** — titled by the cycle file's heading, due on its end date, +its description carrying the line above, counts only — and each deliverable an **issue** in it: its acceptance +criteria as a checklist, its module and state, who holds it, the pull requests that name it. +An issue closes as *completed* when the deliverable is delivered or accepted, as *not planned* when it is +dropped, deferred, or left unfinished by a closed cycle. + +Nothing is maintained by hand and nothing on the forge is the plan: an issue or a milestone edited +there is put back at the next run, and the run says it updated it — it cannot tell an edit by +hand from the plan moving: the plan is edited in the cycle files, in a pull request. The display +finds its own objects by a marker in their body; an issue or a milestone a person made is never +touched, and a person's milestone already holding a cycle's title is said, not overwritten. What cannot be shown — no token, a refusal, holds unreadable — is said in the +run's summary, never a failed merge. The first run on a project creates an issue per deliverable, +and the repository's watchers get a notification for each. + +## The project across its cycles + +There is no backlog to measure the project against: framing bounds one cycle at a time, and +what it leaves out waits in that cycle's *Later*. `nstack plan` says the project as it stands, +read from this folder and kept nowhere else — the charter's success criteria, every cycle in one +line, and what the latest cycle left for the next framing: + +``` +Project: 0 of 3 success criteria met · criterion 1 observed since 2026-10-17 · 3 cycles: 1 accepted, 1 closed, 1 stopped + 01-first-meeting stopped (reframed) on 2026-10-13 · 1 of 7 accepted · 6 deferred + 02-the-audio closed (completed) on 2026-10-17 · 9 of 9 accepted + 03-the-window in progress, ends 2026-11-07 · 18 of 20 accepted · 2 in progress + Later in 03-the-window, for the next framing: 9 candidates +``` + +**The project's progress is its charter's success criteria.** A closure records the ones the +decider says it moved, in the cycle's front matter — the charter itself changes only through a +decision: + +```yaml +success: + - criterion: 1 # its number in the charter's list, from 1 + state: observing # met | observing + since: 2026-10-17 # observing: the day observation started +``` + +A criterion's state is its latest record, in the order of the cycles; one never recorded is not +yet met. Numbers follow the charter's list; a criterion still holding the form's words is +listed, never counted. When every criterion is met, the line says the charter's goal is reached, +and the decider says whether the project is finished. A record outside a closure, twice in one, +on a number the charter does not fill, in an unknown state, or observing with no day is refused +(C6). + +Each cycle is counted as its own line above counts it. Deliverables are never added up across +cycles: one deferred by a cycle is often framed again in the next, and a total would count it +twice. *Later* is the running cycle's, or between two cycles the last one ended — where the next +framing starts; its candidates are counted when the section is a list, one item each, and prose is +said as prose. A status or an outcome the plan's rules refuse is said as unknown, and a date they refuse is left +out: none is printed raw. The view is `nstack plan`'s alone — `nstack fitness` and CI keep to the cycle in progress. + +## Who holds a deliverable + +With several contributors, a deliverable is **held** before its first change, so that two of +them never deliver it twice: + +```bash +nstack claim D30 --person @alice --session <session> # held; its first work branch d30-… made, unless one exists +nstack plan # who holds what, since when; what is stale +nstack unclaim D30 --session <session> # given back: by its holder's session (its person read from the hold), the decider, anyone once stale; a record: who made it, the decider +nstack claim D30 --take-over --person @alice # a hold nobody worked on for hold_days, or your own person's other session +nstack claim '#14' --person @alice --session <session> # an issue no cycle plans — a bug, a flaky test: held the same way, work on issue-14-… +``` + +The hold works the same on any forge, and on none. On GitHub, with a token, the claim also opens a +draft pull request from its first work branch, where people look; on another forge nothing is shown +there, the claim says so, and `nstack plan` is where the hold is seen. + +An issue is held as a deliverable is, in a framed project or not: the forge's assignee says who +works on it and refuses nobody, the hold does. `nstack plan` lists the issues held. Quote `'#14'` +— `#` starts a shell comment — or write `14`. Its work merged, its holder gives it back +(`nstack unclaim '#14'`): an issue's hold does not end with a cycle. + +Two agents one person runs are two holders: a session renews only a hold it is on, or one its +own agent put there. Another agent's session of that person, or any session outside `nstack +agent run`, is refused like anyone else, and takes the hold with `--take-over` when the person +says so, stale or not; a person with no `--session` renews their own. An agent restarted under a new session is the same holder: in +`nstack agent run`, when its own App's identity committed every event that put a session on the +hold, `nstack claim D30 --person @alice --session <it>` renews it, says so and records the session +it leaves, and `nstack unclaim D30 --person @alice --session <it>` gives it back. Two live sessions +of one agent are therefore one holder. A renewed +hold with no work branch left gets its first one again, unless the deliverable is merged. + +An empty branch its claim started for another title of the same id — an earlier cycle's `D30` — +is never this deliverable's work: the claim makes its own beside it. + +When a deliverable's work went on other branches, the empty branch its claim started — one empty +commit — is the framework's own: `nstack deliver` removes it with the delivery, here and on the +remote, unless a push since gave it work. `nstack plan` names those left — the default branch +records the deliverable's delivery (its `Deliverable:` line, or its id in parentheses in a +subject), it is no longer `ready` or `in-progress`, or it belongs to another cycle — and +`nstack plan --prune` removes them all, the decider's one command for what no delivery meets. + +The hold is a branch of the shared remote, `nstack/hold/<cycle>/D30`, whose commits are its +events; the remote takes the first of two claims and refuses the second. The cycle a claim reads +is the one on that remote's default branch, whatever this checkout holds. A remote that is +somebody's clone — a `git clone --shared` of a working clone — is refused: a hold pushed there is +nobody else's. A local hub, bare or a working tree cloned from nowhere, stays a shared remote. A hold's last work is +its newest event or commit on a branch `d30-…`; with none for `hold_days` (an answer of the +project, 7 by default) it is **stale**, and anyone may take it over — recorded, with whom it was +taken from; the previous work is kept. The pull request check refuses delivery work for a +deliverable someone else holds (K5): its commits name none of the hold's sessions, and no +author, committer or opener is its person; nobody holds it, it asks nothing. A holder working +from a new session takes it first, on the person's word — `nstack claim D30 --take-over --person @alice --session <it>` —, +or, an agent restarted under its own identity, renews it with `nstack claim D30 --person @alice --session <it>`. The +previous session's work goes on with the new one: its commits — a merge of the default branch into +the former branch is enough — name the new session, and K5 reads it there. A hold says who is +accountable; it proves nobody's identity. + +**A hold lasts its cycle.** Once the cycle is closed or stopped, nothing it guarded can be delivered, and +a deliverable framed again is held afresh, on a branch of the new cycle. `nstack unclaim` says such a +hold ended rather than refusing it. Its branch is never deleted — the ruleset forbids it: it is the +hold's record, and the cycle in its name tells a finished hold from a live one. + +The charter changes only through a PDR (`.nstack/handbook/06-decisions.md` §4). A cycle is never +extended: past its end date, delivery work stops until the decider records a decision. diff --git a/.nstack/install-engine.sh b/.nstack/install-engine.sh index 5f7f506..4097c11 100755 --- a/.nstack/install-engine.sh +++ b/.nstack/install-engine.sh @@ -1,31 +1,86 @@ #!/usr/bin/env bash -# Installs the NapkinStack engine this project records, for CI (PDR-0005). +# Installs the NapkinStack engine this project records, in CI and on a workstation +# (.nstack/handbook/INSTALL.md). # -# A published version (_commit: vX.Y.Z) comes from PyPI, the only published channel -# (ADR-0002). Anything else comes from the framework's repository at that commit, and is +# A published version (_commit: vX.Y.Z) comes from PyPI, the only published channel. +# Anything else comes from the framework's repository at that commit, and is # announced: nstack then says, on every run that judges, that its rules are unpublished. # A ref that cannot be fetched fails here; no published version is ever used in its place. set -euo pipefail -VERSION=$(yq '._commit' .copier-answers.yml) +# Two lines of the answers file, read with sed alone: a runner may hold any YAML tool, or none. +answer() { sed -n "s/^$1: *['\"]\{0,1\}\([^'\"]*\)['\"]\{0,1\} *$/\1/p" .copier-answers.yml; } +VERSION=$(answer _commit) +ERRORS=$(mktemp) +trap 'rm -f "$ERRORS"' EXIT + +# uv tool install, said on stderr as uv said it. D249 (#453): uv removes the former engine before it +# links the new one's executables, and refuses one the bin folder already holds. A link that points +# nowhere — the engine's own, just removed — is deleted, which loses nothing, and the same command +# runs again, uv still guarding every other executable; never --force. A link to anything that +# exists belongs to another installation: nothing is touched, and the command to run is named. +engine_install() { + local round taken bin link + for round in 1 2 3 4; do + if uv tool install "$@" 2>"$ERRORS"; then cat "$ERRORS" >&2; return 0; fi + cat "$ERRORS" >&2 + taken=$(sed -n 's/^error: Executable already exists: \([^ ]*\).*/\1/p' "$ERRORS" | head -n 1) + [ -n "$taken" ] || return 1 + bin=$(uv tool dir --bin) || return 1 + link="$bin/$taken" + if [ -L "$link" ] && [ ! -e "$link" ]; then + echo "[nstack] $taken pointed at an engine uv removed ($link): that link deleted, installed again." + rm -f "$link" + continue + fi + echo "FAIL [nstack] $taken already belongs to another installation ($link): it is not overwritten," + echo " and the engine uv removed is not installed until you choose." + echo " Action: if the engine's own $taken is the one wanted, run this once:" + echo " uv tool install $(printf '%q ' "$@")--force" + exit 1 + done + return 1 +} if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - exec uv tool install "napkinstack==${VERSION#v}" --with-executables-from pre-commit + # --refresh-package: a runner that outlives its jobs keeps uv's cache, and a page of the + # registry read before a release would say this version does not exist. + # Minutes after a release, PyPI's index may not list the version its project page shows: a + # version not listed is asked again, a few times, said; any other failure fails at once. + for ATTEMPT in 1 2 3 4 5 6; do + if engine_install "napkinstack==${VERSION#v}" --refresh-package napkinstack --with-executables-from pre-commit; then + exit 0 + fi + grep -q "no version of napkinstack" "$ERRORS" && [ "$ATTEMPT" -lt 6 ] || break + echo "[nstack] napkinstack ${VERSION#v} not listed yet by PyPI's index (attempt $ATTEMPT of 6): asked again in 30 s." + sleep 30 + done + if grep -q "no version of napkinstack" "$ERRORS"; then + # D201: an update made by an engine run from its sources is ahead of the release + echo "FAIL [nstack] napkinstack ${VERSION#v} could not be installed from PyPI: not published yet — its release" + echo " may await approval — or the registry did not answer." + echo " Action: run this check again once https://pypi.org/project/napkinstack/${VERSION#v}/ answers." + else + echo "FAIL [nstack] napkinstack ${VERSION#v} could not be installed: uv said why, above." + echo " Action: fix what uv said, then run this script again." + fi + exit 1 fi -SOURCE=$(yq '._src_path' .copier-answers.yml) +SOURCE=$(answer _src_path) case "$SOURCE" in # Copier's remote forms, as nstack doctor L7 reads them https://*|ssh://*) ;; gh:*) SOURCE="https://github.com/${SOURCE#gh:}" ;; gl:*) SOURCE="https://gitlab.com/${SOURCE#gl:}" ;; git@*:*) HOST=${SOURCE#git@}; SOURCE="ssh://git@${HOST%%:*}/${HOST#*:}" ;; *) echo "FAIL [nstack] framework source '$SOURCE' is a path on one machine: CI cannot fetch it." - echo " Action: nstack update from the framework's repository (PDR-0005)." + echo " Action: nstack update from the framework's repository." exit 1 ;; esac REF=${VERSION##*-g} # Copier records an unpublished commit as git describe: vX.Y.Z-N-g<sha> -echo "::warning::UNPUBLISHED NapkinStack: ${SOURCE}@${REF} judges this run (PDR-0005)" -uv tool install "napkinstack @ git+${SOURCE}@${REF}" --with-executables-from pre-commit || { - echo "FAIL [nstack] framework ref '$REF' not found at $SOURCE: no published version is used in its place." - echo " Action: pin an existing commit with nstack update --ref, or a published vX.Y.Z (PDR-0005)." +echo "::warning::UNPUBLISHED NapkinStack: ${SOURCE}@${REF} judges this run" +engine_install "napkinstack @ git+${SOURCE}@${REF}" --with-executables-from pre-commit || { + echo "FAIL [nstack] framework ref '$REF' could not be installed from $SOURCE — uv said why, above: no" + echo " published version is used in its place." + echo " Action: pin an existing commit with nstack update --ref, or a published vX.Y.Z." exit 1 } diff --git a/playbooks/data-migration.md b/.nstack/playbooks/data-migration.md similarity index 78% rename from playbooks/data-migration.md rename to .nstack/playbooks/data-migration.md index 324a510..5ed258f 100644 --- a/playbooks/data-migration.md +++ b/.nstack/playbooks/data-migration.md @@ -1,7 +1,10 @@ # Playbook — Data and migrations -> **Trigger.** Load this playbook when the task touches: a data schema, a migration, the -> deletion or transformation of existing data, data ownership. +> **Trigger.** Load this playbook when you are touching: a data schema, a migration, +> existing data. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/data-migration.md` +> — read them with this playbook. They add to it or tighten it. --- @@ -9,17 +12,17 @@ | # | Rule | |---|---| -| D1 | **A migration is a production change**, not a code change. It falls under high-risk actions (kernel §5). | -| D2 | **Each module owns its data.** No direct access to another module's database — you go through its contract. | -| D3 | **Never rename or delete in place.** You add, you let both coexist, you migrate, you remove. | -| D4 | **Every migration has a rollback plan**, or a written justification for not having one. | -| D5 | **Never run a destructive migration without explicit confirmation.** | +| DM1 | **A migration is a production change**, not a code change. It falls under high-risk actions (kernel §5). | +| DM2 | **Each module owns its data.** No direct access to another module's database — you go through its contract. | +| DM3 | **Never rename or delete in place.** You add, you let both coexist, you migrate, you remove. | +| DM4 | **Every migration has a rollback plan**, or a written justification for not having one. | +| DM5 | **Never run a destructive migration without explicit confirmation.** | --- ## 1. Expand / Contract applied to the schema -The same logic as contracts (`docs/os/03-contracts.md`), for the same reason: the old and +The same logic as contracts (`.nstack/handbook/03-contracts.md`), for the same reason: the old and the new code coexist during the deployment. ```mermaid @@ -44,8 +47,8 @@ red: the irreversible step, the one that gets forgotten. Each step is **a pull request deployable on its own**. At no point is the system in a state where a rollback would break the data. -Step 6 is the most forgotten. As with contracts: it carries a date, and a check fails -once that date has passed. +Step 6 is the most forgotten. It carries a date and an owner, in a *Technical debt* +issue: no check reads a schema's dates, so the contraction is the project's to track. --- diff --git a/playbooks/discovery.md b/.nstack/playbooks/discovery.md similarity index 71% rename from playbooks/discovery.md rename to .nstack/playbooks/discovery.md index 9a91a90..1665da2 100644 --- a/playbooks/discovery.md +++ b/.nstack/playbooks/discovery.md @@ -1,8 +1,10 @@ # Playbook — Discovery -> **Trigger.** Load this playbook when a project starts from an idea — a few lines, notes, -> a wish — before any charter: to test the idea, compare it with what exists, challenge it, -> and reach a decision. +> **Trigger.** Load this playbook when you are touching: an idea to test, a discovery to +> challenge or decide. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/discovery.md` +> — read them with this playbook. They add to it or tighten it. --- @@ -32,9 +34,21 @@ problem, what the product does — and ask the decider to correct it. Record the the front matter. Until the decider confirms the paragraph, mark it *unconfirmed*: the round cannot be decided while it is. +Ask, once, **in which language the project writes** — its documents, its code, its commit +messages. The idea file may be in one language and the framework's forms in another; nobody +notices until half the documents are in each. The answer is the project's first rule: one +line of `docs/project/rules/always.md`, written now, with the idea file left as it was given. + +Ask, once, **what has already been asked of, promised to, or received from someone outside the +team** — a client, a vendor, a partner — by mail, chat or meeting. A fresh session remembers none +of it, and an outside party asked twice, or asked differently, pays for it in patience. Each answer +is an entry of the project's log issue, opened now if there is none (`.nstack/handbook/06-decisions.md` +§9): who, what, when, by which channel — never a secret or a credential, and nothing the outside +party would not have public in a public repository's issue (`security.md`). + ## 2. Research -With the research tools of `docs/tooling-profile.md` — or, when that row is empty, the tools +With the research tools of `.nstack/tooling-profile.md` — or, when that row is empty, the tools at hand, named in the document — look for: - what users do today instead, including nothing; @@ -47,6 +61,11 @@ Prefer the primary source; mark figures a company reports about itself, and clai in a search excerpt. A claim without a source goes to *Assumptions*. Stop when each of the four points has at least one sourced finding, or an explicit "not found". +**A legal or regulatory claim is read at its primary source — the text itself, the +regulator's page — or it is an assumption.** A summary of a law by someone who sells a +product under it is not a source, and a rule the design will rest on is the last thing to +take second-hand: say "not read" rather than mark it as seen elsewhere. + ## 3. Define With the decider: the users; their problem — quoted from users, saying who and how many, @@ -93,7 +112,7 @@ hypothesis. The decider chooses: | Decision | What follows | |---|---| -| **go** | The framing writes the charter from this document (`framing.md`); the tests the decider keeps become spike deliverables of the first cycle | +| **go** | The pull request that records the decision writes the front page's sentence (`README.md`) — what the product does, for whom, as the decider confirmed it — and nothing else of that page. The framing then writes the charter from this document (`framing.md`); the tests the decider keeps become spike deliverables of the first cycle | | **clarify** | A new round on the open questions, and on the cheap tests the decider picks before any charter; `round` goes up, section 5 is kept under its round, and the changed sections are challenged again | | **kill** | The document stays, with its reasons — the cheapest outcome of all | diff --git a/.nstack/playbooks/documentation.md b/.nstack/playbooks/documentation.md new file mode 100644 index 0000000..9b90d62 --- /dev/null +++ b/.nstack/playbooks/documentation.md @@ -0,0 +1,86 @@ +# Playbook — Documentation + +> **Trigger.** Load this playbook when you are touching: a document a human will read, a +> pull request's description included: writing or changing one. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/documentation.md` +> — read them with this playbook. They add to it or tighten it. + +```mermaid +flowchart LR + Q{"Is there a structure,<br/>a flow or a state<br/>to show?"}:::ask + Q -->|yes| D["A diagram<br/>with its legend"]:::first + Q -->|no| T["A table,<br/>or three lines"]:::first + D --> L["A few lines:<br/>what the diagram<br/>cannot say"]:::then + T --> L + L --> S["Sources and dates"]:::then + S --> C{"Still true<br/>after this change?"}:::ask + C -->|no| U["Bring it current<br/>or delete it"]:::stop + + classDef ask fill:#374151,color:#fff + classDef first fill:#065f46,color:#fff + classDef then fill:#1e3a8a,color:#fff + classDef stop fill:#7c2d12,color:#fff +``` + +**Legend** — grey: what you ask yourself · green: what the reader sees first · blue: what +follows it · red: the document that no longer says what is true. + +--- + +## The standard — five rules, and no content + +1. **Shape first**: a diagram with its legend before the prose, wherever there is a structure, + a flow or a state to show. A reader who stops after the diagram has understood. +2. **A source for every claim about the outside world** — a market, a law, a tool's + behaviour, a number. +3. **A date on every decision**, and on every criterion that will judge it. +4. **Current, or deleted.** A stale page costs more than a missing one, because it is + believed. +5. **A fact has one home.** Its home is the file a check or a command reads — a module's + manifest for its responsibility, owner and criticality; the cycle for a deliverable's criteria, and its state once the cycle is closed — during it, the + hold and the delivery record, which `nstack plan` reads; + the charter for the decider. Every other document that needs the fact links to it, never + copies it: two copies agree on the day they are written, and only on that day. + +The framework asks for this form and writes none of the content: what the document says is +the project's. + +--- + +## Drawing the diagram + +| Situation | Action | Verification | +|---|---|---| +| Parts and what links them: modules, users, systems | Boxes and arrows, a dozen boxes at most | Someone reading the diagram alone can say what the document is about | +| Things that happen in an order | A sequence, left to right or top to bottom | Every step has one way in | +| Something that changes state | The states and what moves it from one to the next | No state is a dead end unless it is meant to be | +| A choice between paths | A decision tree, the question in the node | Every branch ends on an action | +| A colour or a shape is used | It means one thing, and the legend under the diagram says which | The legend names every colour used, and nothing else | +| The diagram is ready | Written as text in the file, in the notation the tooling profile names — never an image. A drawing of a screen is no diagram: it is an image, frozen (`framing.md` §2) | The pull request shows what changed in it | +| Nothing to show: one fact, a list, a comparison | No diagram. A table, or three lines | A diagram that decorates is removed | +| More than a dozen boxes | Two diagrams, one idea each | Each has its own legend | + +## After the diagram + +- **Say what the diagram cannot**: the why, the exception, the number. Never describe the + diagram in words. +- **A table for anything a reader will compare**; a list for anything they will tick. +- **The point first.** A reader who must scroll to find what was decided has been given a + story instead of a document. +- **Short.** A paragraph a reader skips is a paragraph to delete. + +## Which document, and when + +Each document of a project has the event that makes it writable; before it, its form stays +a form. The table is `.nstack/handbook/06-decisions.md` §10 — read that one section before writing a +document the project does not hold yet, and never fill a form with what nobody has decided. + +--- + +## Closing checklist + +- [ ] The diagram comes first, with its legend — or there is nothing to draw, and no diagram +- [ ] Every claim about the outside world names its source +- [ ] Every decision and every criterion carries its date +- [ ] Every document this change makes untrue is brought current in the same pull request diff --git a/.nstack/playbooks/framing.md b/.nstack/playbooks/framing.md new file mode 100644 index 0000000..fc3fe39 --- /dev/null +++ b/.nstack/playbooks/framing.md @@ -0,0 +1,219 @@ +# Playbook — Framing + +> **Trigger.** Load this playbook when you are touching: framing a project, planning or +> closing a cycle. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/framing.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## When framing is worth it + +A project is **unframed** until its charter is accepted: a stage, not a fault. Every rule +judges its changes except the three that bound work inside a cycle. Framing buys an +appetite, an end date, a circuit breaker and a decider — worth their price **when there is +something to bound**: several people, a deadline, a decider who is not the one typing. Say +so when you are asked to frame a project where none of the three is true; then frame it if +the decider still wants it. Never frame to make a check pass: no check asks for it. + +## Your posture + +You are the **framer**. You propose; the decider decides. For the framer, this playbook +replaces the kernel's working loop (§2); its closing summary (§8) still applies. + +| You do | You never do | +|---|---| +| Interview the decider, one subject at a time | Decide in their place, or fill a gap with an invention | +| Propose the field's convention by default, marked *(framer, to confirm)* with its source | Propose more than the need | +| List the open questions, blocking apart | Let a charter or a cycle be accepted with a blocking question open | +| Keep the first cycle small | Split into many modules on day one (`.nstack/handbook/02-modules.md` §3) | + +A proposal without a source is an open question, not a proposal. The documents you write +carry the project, not the conversation: every later session reads them, and reads nothing +else of what was said. + +--- + +## 1. Frame the project: the charter + +Start from what the decider gives you. When `docs/project/discovery.md` exists, its decision +must be **go**: the charter reuses its users, problem, constraints, success signals, no-gos +and risks, carries its unanswered questions into its own, and you ask only what it leaves +open. Otherwise — an idea alone — propose a discovery first (`discovery.md`); a specification +already challenged can be framed directly. Read the source entirely, then interview, one +subject at a time, asking only what you cannot infer: + +| Subject | Ask | The charter records | +|---|---|---| +| Users | Who uses it, in what situation, with what problem? | The users and their problem | +| Outcome | What must be true for the project to be finished? | Success criteria, measurable, dated — or relative to a named event, such as launch day, that a later framing dates | +| Constraints | Law, money, security, data, platforms, deadlines | The constraints | +| Risks | What could make it fail, or cause harm? | The risks, and the criticality they imply — what a failure of each module would cost, which the decider settles and `.nstack/handbook/05-workflow.md` §7 prices | +| Vocabulary | The domain's words, and what each one means | The vocabulary | +| Not this project | What it will deliberately not do | Out of scope | +| Outside the team | What has already been asked of, promised to, or received from someone outside the team — a client, a vendor, a partner — by any channel? When the discovery asked it, only what changed since; otherwise, in full | Nothing in the charter: each answer is an entry of the project's log issue (`06-decisions.md` §9) | + +A domain that moves money, handles personal data or acts on someone's behalf raises the +criticality of the modules concerned, and `security.md` applies from the first cycle — to +the code, and to the data a spike collects: who sees it, how long it is kept. Say so to the +decider. + +**Before proposing a criticality, read the rule** — the last paragraph of +`.nstack/handbook/05-workflow.md` §7: a module that holds a key, places an order, moves money or +touches someone's personal data is `critical`. Propose what the rule says, with what each +value costs; a lower value is the decider's to choose, and is written as a deviation with its +reason and the event that ends it. + +When no discovery came first, ask too **in which language the project writes**; the answer is +its first rule (`docs/project/rules/always.md`). + +**A constraint that binds how the work is done becomes a rule of the project**, proposed +with the charter: one line of `docs/project/rules/<subject>.md`, from +`.nstack/forms/rules.md` — the subject is the playbook it completes, `always` when +it applies to every task. It names its source in the charter and how it is checked. Never +write it into a playbook or the kernel: those are every project's, and the next update +would conflict on it. + +Write `docs/project/charter.md` from `.nstack/forms/charter.md`, with +`status: proposed` and the open questions at the end, then run the fitness functions. +"Finished" means the charter's goal is reached: framing stops; running what was built may go +on. + +## 2. Plan a cycle + +1. **Goal** — one sentence, the one outcome of this cycle. +2. **Deliverables** — a finite list, `D1`, `D2`…, each an outcome a user can observe — for a + spike, the question it answers for the decider. Each gets acceptance criteria, written + *given · when · then*; they become its test sheet (`verification.md`). + + **Two questions to ask of each one, before writing its criteria:** + - *Can the team finish it alone, inside this cycle?* If it waits on someone outside the + project — a reply, an opinion, a decision elsewhere — it is a **dependency with a date**, + not a deliverable. Name it in the risks and give it a date; the cycle does not hold it. + - *Is its product knowledge rather than code?* Then it is a **spike**, and its criteria say + **what will be recorded** and **the threshold it is read against** — never that the answer + comes out a particular way. **A refuted result is a delivered one.** "Five people were + asked, one acted, below the threshold of two" closes the deliverable; it does not fail it. + When its product is a **drawing** — the screens, the journey the user will see — the + drawing is committed under `docs/project/drawings/<deliverable>-<name>/` with its date, + and frozen: what the decider accepts in it becomes criteria of the deliverable that + builds it, and once built, the product and its screenshots are the truth. A new round is + a new folder, never an update. + + A criterion nobody can meet is not met. It is answered with something that looks like proof, + and that answer is reviewed and merged like the rest. +3. **Unknowns** — a blocking unknown becomes a *spike* deliverable, whose output is + knowledge (`.nstack/handbook/05-workflow.md` §3). After a discovery's go, the tests the decider kept + are the first cycle's spikes. +4. **Modules** — name each deliverable's module; a spike run outside the code — a sign-up + form, interviews, a measure whose product is a record and not shipped code, even about one + module — has none (`module: null`): no merge carries it, so `nstack deliver` has nothing to read. Propose a new module only against the tree of + `.nstack/handbook/02-modules.md` §3: one module is often enough to start. +5. **Appetite** — ask the decider how many weeks they **want** to spend, not how long it + will take — in days for a cycle shorter than a week, such as an engagement whose date an outside + party sets (`appetite_days`), never rounded up to a week nobody agreed to. When the deliverables + do not fit, cut the scope; never stretch the appetite. +6. **Out of scope and later** — out of scope is not done even if time remains; *later* holds + the candidates for the next framing. + +Write `docs/project/cycles/NN-<slug>.md` from `.nstack/forms/cycle.md`, with +`status: proposed` and `end` = `start` + the appetite, then run the fitness functions. + +## 3. Hand over to the decider + +A cycle's *What needs a person* holds what only a person can do, each with its literal gesture: fill it +while framing, and keep it true. It is what `nstack plan` opens with. A request to someone outside +the team starts from the log issue's entries, and from the decider's answer to what has been asked, +promised or received outside since the last one — every cycle, not only the first: nothing already +asked is asked again, nothing is asked more broadly than before without saying why, and each new +request becomes an entry. One still awaiting a reply that a deliverable needs is a dependency with a date. + +Present the charter, the cycle, the open questions, what went to *later*, and what you are +unsure of — the cycle also as the board will show it: `nstack board --dry-run` previews the +milestone and the issues its acceptance would create, and what it would collide with, and makes +none; put the lines under *On acceptance of cycle …* in the framing pull request's description. The decider amends; the framer sets `status: accepted` — on the charter, then on the +cycle — in a pull request the decider approves, and that approval is their gesture; accepted after `start`, the cycle's `start` and `end` +move in the same pull request. **The next cycle, accepted while one runs**, stays `proposed` — one +accepted cycle at a time (C5) — and gains `accepted_on: <the day of the word>`: `nstack plan` stops asking +for it while that cycle runs, and the running cycle's closure starts it (§5). The modules accepted there are created with the engine's +module scaffolding, declared user-facing when a user sees them. + +**Where the project's own rules waive approval** — an agent merging alone on an attested, +verified head, `doctor`'s G2 taken knowingly — nobody approves that pull request, and the +decider's word stands for the approval: quoted in the page it accepts (the charter, the cycle), +with its date and where it was said — a comment, a message, a meeting's note. The same holds +for a deliverable accepted below. Without that line, the acceptance is the agent's alone. + +**The pull request that accepts the charter writes the project's front page from it** — +`README.md`: a diagram of who uses the product and what it talks to, how to run what exists, +and the sentence when no discovery wrote it. Until then that page holds its sentence at most; +from then on the plan check refuses an accepted charter over a form left as it came +(`.nstack/handbook/06-decisions.md` §10, `documentation.md`). + +## 4. During the cycle + +- **A new idea** goes to *later*. It enters the cycle only if the decider re-frames: + swapping a deliverable out, adding one they judge fits what is left of the appetite — + the end date does not move — or closing the cycle early. An added deliverable takes its + criteria like the others, and its section says on whose word and on what it entered. +- **An urgent fix** outside the cycle — an incident, a production defect — goes in a pull + request with the `out-of-cycle` label and the line `Out of cycle: <reason>`. +- **A deliverable's state** is written in the cycle file at framing (`proposed`, then `ready`: + testable criteria, set by the framer, confirmed when the decider accepts the cycle), on a + re-framing (`deferred`, `dropped`), and at the closure (`accepted`, by + `nstack deliver --write-states`) — never during delivery, and never in a delivery's pull request. + In between, `nstack plan` reads it: *held* from its claim, *delivered* from its record + (`nstack deliver D<n> --held '#<pull request>'`, kernel §2 step 12, `.nstack/handbook/project.md`); + it asks the decider nothing. It is accepted when each of its criteria is held by a scenario of a merged sheet, or by an + answer in the acceptance issue the cycle names beside the state (`.nstack/handbook/05-workflow.md` + §7); a criterion only a person can try waits for that answer. A spike outside the code is held + by a decision record when it binds the project (*Decisions* below), otherwise by a line of the + log issue it was run under — the project's, or its module's —, which its section links: with no merge it has no record, and the closure + writes its `accepted` by hand beside the states `--write-states` wrote, citing that line. Where + approval is waived (§3), the decider's word is quoted once, at the closure, for the cycle. A rule + sees that a merge exists, not that a criterion holds: the closure reads the records before it + writes. + +## 5. The end of a cycle + +**Every deliverable delivered or accepted** — `nstack deliver --write-states`, and `nstack plan --prune` for the empty start branches a deferred deliverable left, then write the closure: what was delivered, which success +criteria moved, what was deferred, and **which documents the cycle brought current** — the +front page and the module map first, each with its pull request; set `status: closed`, +`outcome: completed`, `ended_on`. A next cycle carrying `accepted_on` is set `status: accepted` in the +same pull request; its `start` becomes the closure's day when it is not, and its `end` follows the appetite. +A success criterion the decider says moved is recorded under `success:` in the front matter, at +any closure — by its number in the charter, `met`, or `observing` with the day observation +started; the latest record is its state, and `nstack plan` counts the criteria met. +When a spike refutes what the charter rests on, present stopping the project too. + +**The end date reached first** — the circuit breaker: nothing is extended. Present the +three choices, with the state of every deliverable. Whichever is chosen, `nstack deliver --write-states` comes +first, while the cycle is still accepted: it is what brings the records into the cycle file. + +| The decider chooses | `status` | `outcome` | +|---|---|---| +| Ship what is delivered or accepted | `closed` | `shipped` | +| Frame a new cycle, with a new appetite | `stopped` | `reframed` | +| Stop the project | `stopped` | `stopped` | + +A next cycle carrying `accepted_on` starts here only on `shipped`, as on a completed closure. On `reframed` or +`stopped`, the word was given for another situation: it stays `proposed`, and `nstack plan` asks the decider again. + +The closure is where the next framing starts. When `nstack plan` says the charter's goal is +reached — every success criterion met —, present it: the decider says whether the project is +finished. + +## Decisions + +A decision lives in a record, never in the charter, the cycle or a conversation +(`.nstack/handbook/06-decisions.md`): one register of each kind at the project's root — +`docs/pdr/` for the product, `docs/adr/` for the technique — and `Scope: module <name>` when it +concerns one module. + +| When | Then | +|---|---| +| An accepted charter has to change — a constraint, a user, what the project is not | A **PDR** first, which the change cites; the charter is never rewritten in place (CI warns, C9) | +| The framing chooses a module, a stack, a contract | An **ADR**: the module's creation decision is one | +| A spike's result binds the project | A PDR or an ADR; otherwise a line in the project's log issue | +| A cycle's **closure** | Read every decision the plan names as due (C10): its criterion names this cycle, or a date in bold, `**YYYY-MM-DD**`, its end reached. The record gains one line under its criterion, *Read at <cycle>'s closure, <date>: met \| missed \| superseded*, and nothing else; a *missed* one is the decider's to answer, by a new record or the removal condition | diff --git a/playbooks/operations.md b/.nstack/playbooks/operations.md similarity index 88% rename from playbooks/operations.md rename to .nstack/playbooks/operations.md index 0980024..a83dcf1 100644 --- a/playbooks/operations.md +++ b/.nstack/playbooks/operations.md @@ -1,7 +1,10 @@ # Playbook — Operations and reliability -> **Trigger.** Load this playbook when the task touches: logs, metrics, alerts, retries, -> timeouts, rollback, health checks, deployment, or any call to an external dependency. +> **Trigger.** Load this playbook when you are touching: logs, metrics, alerts, retries, +> timeouts, rollback, a deployment, a call to another system. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/operations.md` +> — read them with this playbook. They add to it or tighten it. --- @@ -9,11 +12,11 @@ | # | Rule | |---|---| -| E1 | **Never an automatic retry without analysing the side effects.** | -| E2 | **Every external call has an explicit timeout.** A call without one is an outage waiting to happen. | -| E3 | **No secret and no personal data in the logs.** | -| E4 | **An error quietly swallowed is a future incident.** | -| E5 | **A module in production with no way of knowing it is unwell is not ready.** | +| OPS1 | **Never an automatic retry without analysing the side effects.** | +| OPS2 | **Every external call has an explicit timeout.** A call without one is an outage waiting to happen. | +| OPS3 | **No secret and no personal data in the logs.** | +| OPS4 | **An error quietly swallowed is a future incident.** | +| OPS5 | **A module in production with no way of knowing it is unwell is not ready.** | --- @@ -138,7 +141,7 @@ flowchart TD - **A deployment is not finished at deploy time**: it is finished when observability confirms the expected behaviour. - **Backward compatibility is mandatory**: during the deployment two versions coexist. An - incompatible change is split up (`docs/os/03-contracts.md`). + incompatible change is split up (`.nstack/handbook/03-contracts.md`). --- diff --git a/.nstack/playbooks/pause-and-resume.md b/.nstack/playbooks/pause-and-resume.md new file mode 100644 index 0000000..29b3474 --- /dev/null +++ b/.nstack/playbooks/pause-and-resume.md @@ -0,0 +1,82 @@ +# Playbook — Pause and resume + +> **Trigger.** Load this playbook when you are touching: stopping, restarting, handing work over, +> or resuming a session. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/pause-and-resume.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## The rule: the repository holds the state, a note points into it + +```mermaid +flowchart LR + S["Stop<br/>work pushed, tree clean"] --> N["Note<br/>.nstack/local/resume.md"] + N -. restart .-> R["Resume<br/>read the note, renew holds"] + R --> P["nstack plan, once"] --> G["the noted gesture"] + classDef state fill:#1f2937,color:#fff + class S,R state +``` + +*Legend: solid arrows are what you do in order; the dotted one is the session ending.* + +A session ends without warning: a restart, a full context, a person's evening. What it knew must +already be where the next one reads it — commits, pull requests, holds — and the next one must +not have to re-read the history to find it. A note of a few lines says where to look; it never +replaces what it points to. + +Your tool's own memory, a chat summary or a transcript are extras: useful to you, invisible to +another tool and to another person. The source is the repository and the forge. + +--- + +## Stop + +Before you stop, or when you are told the session will end: + +1. **Nothing only in the working tree.** Commit what is in progress, on its work branch, and push + it: the pushed branch shows it, and on GitHub the claim's draft pull request too when the work + is on its first branch. A commit or a push a hook refuses: fix its cause; what you cannot fix + before stopping stays as it is, and the note names it with the refusal — never `--no-verify`. +2. **Nothing running.** No background job, watcher or server left for the next session to find. +3. **Nothing left over.** Scratch clones, worktrees and local branches of your own that hold no + work are removed; a worktree that holds work is pushed first. Never the start branch your + claim made: `nstack deliver` removes it. +4. **Holds stay.** A deliverable you will resume stays held (`nstack plan` shows it). Past + `hold_days` without work, anyone may take it over: give back with `nstack unclaim` what you + will not resume by then. +5. **Write the note.** + +## The note + +`.nstack/local/resume.md` — one per clone, never committed (`.nstack/local/` is ignored). +Fifteen lines at most; over that, it repeats what the repository already says. Rewrite it +whole at each stop: it states the present, not a journal. + +```markdown +# Resume — 2026-11-24 18:40, session <id>, for <person> +- Merged since the last note: D30 (#41) +- Open: D31, pull request #44 — next: answer the verifier's finding on the empty state; mine +- Open: D32, branch d32-export, pushed, no pull request yet — next: the test sheet; mine +- Owed by others: the decider's approval of #42; the verifier's run of #44 +- Not pushed: (nothing) — or the commit, the files, and the hook's refusal +- Next id: D33 +- Relaunch: nstack agent run <agent> -- <tool> +``` + +Handing over to another session or person: give them the note's text with the hand-over, and +give the hold back (`nstack unclaim`) for them to claim. Never hand over a clone. + +## Resume + +1. **Read the note, and only the note.** Not the history, not the transcripts. No note: `git + status`, `git log` of your branches and `nstack plan` say the same, more slowly. +2. **Renew your holds** under this new session. In `nstack agent run`: + `nstack claim <id> --person <person> --session <this session>` renews a hold your own agent + held. Outside it, a new session of yours takes its hold over, on your person's word: + `nstack claim <id> --take-over --person <person> --session <this session>` + (`.nstack/handbook/project.md`, *Who holds a deliverable*). +3. **`nstack plan`, once**: what changed while you were away — merges, holds, what turned stale. + Where it disagrees with the note, the repository is right; the note was the past. +4. **Continue at the noted gesture.** A gesture owed by someone else is not yours to redo. diff --git a/playbooks/security.md b/.nstack/playbooks/security.md similarity index 81% rename from playbooks/security.md rename to .nstack/playbooks/security.md index 3d02e93..03df211 100644 --- a/playbooks/security.md +++ b/.nstack/playbooks/security.md @@ -1,11 +1,13 @@ # Playbook — Security -> **Trigger.** Load this playbook when the task touches: authentication, authorisation, -> secrets, personal or sensitive data, external input, file upload, network exposure, -> dependencies. +> **Trigger.** Load this playbook when you are touching: authentication, authorisation, +> secrets, personal data, external input, a new dependency. > > Format: `situation → action → verification`. Anything not verifiable here must go to > human review. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/security.md` +> — read them with this playbook. They add to it or tighten it. --- @@ -13,11 +15,11 @@ | # | Rule | |---|---| -| S1 | **No secret in the repository.** Not in clear text, not encoded, not "temporarily", not in a test, not in a comment. | -| S2 | **All external input is hostile** until explicitly validated. | -| S3 | **Least privilege by default** — including for CI and for agents. | -| S4 | **Deny by default** in authorisation: whatever is not explicitly allowed is forbidden. | -| S5 | **Never design your own** cryptographic, password-hashing or authentication mechanism. The established convention, always (Prior Art Gate). | +| SEC1 | **No secret in the repository.** Not in clear text, not encoded, not "temporarily", not in a test, not in a comment. | +| SEC2 | **All external input is hostile** until explicitly validated. | +| SEC3 | **Least privilege by default** — including for CI and for agents. | +| SEC4 | **Deny by default** in authorisation: whatever is not explicitly allowed is forbidden. | +| SEC5 | **Never design your own** cryptographic, password-hashing or authentication mechanism. The established convention, always (Prior Art Gate). | If one of these rules has to be broken, this is no longer a development task: it is a decision, and it goes through an ADR and human approval. @@ -79,7 +81,7 @@ This is the most frequent source of vulnerabilities, and the easiest to test. | Situation | Action | Verification | |---|---|---| -| New dependency | Niche filter (`docs/os/06-decisions.md` §3) + declared in the manifest | Review: undeclared dependency (to automate) | +| New dependency | Niche filter (`.nstack/handbook/06-decisions.md` §3) + declared in the manifest | Review: undeclared dependency (to automate) | | Reported vulnerability | Handle it by severity and real exposure, not by score alone | Automated analysis in CI | | Unmaintained dependency | Open a *Technical debt* issue with the exit strategy | Dependency review | diff --git a/playbooks/tests.md b/.nstack/playbooks/tests.md similarity index 51% rename from playbooks/tests.md rename to .nstack/playbooks/tests.md index fd60358..86714d6 100644 --- a/playbooks/tests.md +++ b/.nstack/playbooks/tests.md @@ -1,11 +1,13 @@ # Playbook — Tests -> **Trigger.** Load this playbook when the test strategy is not obvious: an untested -> area, a flaky test, a behaviour that is hard to isolate, doubt about the right test -> level. +> **Trigger.** Load this playbook when you are touching: a non-trivial test strategy, a +> flaky test. > > For an ordinary task the kernel rule is enough: **write the oracle, watch it fail, > implement**. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/tests.md` +> — read them with this playbook. They add to it or tighten it. --- @@ -38,7 +40,60 @@ that could have been a unit test costs a hundred times more, breaks ten times mo often, and diagnoses ten times worse. A scenario replayable end to end belongs in the module's `e2e` command, and its evidence in -`.evidence/`: CI keeps it for the test sheet (`docs/os/05-workflow.md` §7). +`.evidence/`: CI keeps it for the test sheet (`.nstack/handbook/05-workflow.md` §7) — where checks are +attested, the verifier's evidence branch (`verification.md`, *Evidence*). + +**What the run said.** `nstack e2e` gives the run a folder of its own, `$NSTACK_EVIDENCE` +(`<module>/.evidence/e2e/`), keeps there the command's output — a traceback included — and then +reads the log files the run wrote there: + +- **Write there** the module's logs (`.log`, `.jsonl`) and screenshots; data that are not logs — + recordings, events — elsewhere. A page's uncaught errors and console errors reach a log there: + logged by the page itself through the application, or collected by a script the scenario + injects (`window.onerror`, `unhandledrejection`) — some drivers expose no console. +- **The audit** reads each line's level — JSON keys, `level=`, a level word leading the line, or + the module's `evidence.levels` expression. A warning or an error the module did not declare is + quoted with `file:line` and the declaration that would accept it: an error fails the run, a + warning fails from criticality `high` and is reported below. The first NapkinStack version that + brings the audit only reports; the project's next minor version judges. +- **Declare** what the scenarios provoke on purpose, in the manifest — a pattern, its level, the + scenario that provokes it (M12). The manifest is the one place the audit reads: a warning or + an error a scenario provokes is declared there, even when the scenario asserts it too. A module + that declares lines and whose run wrote no log into `$NSTACK_EVIDENCE` fails when judged — they + were checked against nothing. +- **Not run here.** A run that cannot run on this machine — no desktop, no sound server — says + why on its output and exits 77, the code Automake and Meson read as a skipped test: the run is + recorded *not run here*, what it logged is shown and nothing judged, and it passes. Exit 0 means + it ran; 77 for any other reason — some tools use it for a refused permission — reads as *not + run*, so a run that fails exits with another code. + +- **One run at a time, unless sealed.** What an end-to-end run drives — a sound server, a + display, a port — is the machine's, so `nstack e2e` runs one at a time on a machine, and a run + that waits says for whom, every minute. A module whose run shares nothing with another run + declares `evidence.sealed: true`: its run neither waits nor holds the machine. Declare it only + when each of these is true — two runs that share one of them see each other's state, and fail + for no reason of their own: + + | Not shared | How to check | + |---|---| + | Session and devices: display, sound server, session bus | its run starts them, headless, and passes their address to what it drives (`DISPLAY`, `PULSE_SERVER`, `DBUS_SESSION_BUS_ADDRESS` from `dbus-run-session`) | + | Ports | each server binds port 0 itself and reports the port it got; never a fixed number, nor one picked and released before the server binds it | + | Files: build output, temporary files, sockets, state, configuration | everything it writes goes under a folder of its own run — the build tool's output folder set per run (`CARGO_TARGET_DIR`, not `build-dir`), `TMPDIR`, `HOME` and `XDG_*_HOME` pointed there —, never a fixed path | + | Processes | its teardown stops what it started — a process group it created (`setsid`, `start_new_session`), or the PIDs it recorded for a daemon that detaches — never by name or executable path | + | Per-user kernel limits: file watchers (inotify instances and watches), process count | its run closes what it opens, and as many runs as the machine takes at once stay under the user's limits (`fs.inotify.max_user_instances`, `fs.inotify.max_user_watches`, `ulimit -u`, which counts threads too); a limit run out fails at once, naming it — no folder of its own run isolates these | + | Timings, whatever the load | it passes with the machine busy; a run that waits for a quiet machine is the opposite of sealed | + + The lock keeps unsealed runs apart, not sealed ones: a run that needs a quiet machine cannot get + one from the lock while sealed runs go beside it. + +```yaml +evidence: + provoked: + - pattern: "key refused" + level: warning + scenario: S3 + sealed: true # every row of the table above holds: runs beside any other +``` --- @@ -149,7 +204,7 @@ Fixed waits (`sleep`) are the most widespread cause of flakiness: wait for an | Signal | Reading | |---|---| | A test breaks at every refactor with no behaviour change | It tests the implementation, not the behaviour | -| You have to start another module to test | Bad boundary (`docs/os/02-modules.md` §9) | +| You have to start another module to test | Bad boundary (`.nstack/handbook/02-modules.md` §9) | | The test is longer than the code it tests | The code is probably too coupled | | Nobody understands what this test tests | Delete it or rewrite it; it protects nothing | | The suite takes more than 10 minutes | It will be bypassed — making it fast is a priority task | diff --git a/playbooks/ux.md b/.nstack/playbooks/ux.md similarity index 92% rename from playbooks/ux.md rename to .nstack/playbooks/ux.md index 6dae5ec..42fe991 100644 --- a/playbooks/ux.md +++ b/.nstack/playbooks/ux.md @@ -1,13 +1,15 @@ # Playbook — UX/UI -> **Trigger.** Load this playbook as soon as the task touches a surface visible to the -> user. +> **Trigger.** Load this playbook when you are touching: a surface visible to the user. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/ux.md` +> — read them with this playbook. They add to it or tighten it. --- ## Entry rule: convention wins -This is the ground where the Prior Art Gate (`docs/os/06-decisions.md`) pays off most. +This is the ground where the Prior Art Gate (`.nstack/handbook/06-decisions.md`) pays off most. > For an interface pattern, the value of the convention comes **precisely from the fact > that the user already knows it**. An unrequested interface innovation is a learning diff --git a/.nstack/playbooks/verification.md b/.nstack/playbooks/verification.md new file mode 100644 index 0000000..5a287a8 --- /dev/null +++ b/.nstack/playbooks/verification.md @@ -0,0 +1,137 @@ +# Playbook — Verification + +> **Trigger.** Load this playbook when you are touching: verifying a change you did not +> write, filling in a test sheet. +> +> **This project's own rules** on the subject, when it has any: `docs/project/rules/verification.md` +> — read them with this playbook. They add to it or tighten it. + +--- + +## Your posture + +You are the **verifier**. You did not write this change, and you do not fix it. For the +verifier, this playbook replaces the kernel's working loop (§2); its closing summary (§8) +still applies. + +| You do | You never do | +|---|---| +| Start from the need, the acceptance criteria and the test sheet | Read the diff before running the sheet | +| Run every scenario against the running change | Fix the code, even one line | +| Bring back evidence for every result | Write "passed" without evidence | +| Report the gaps against the need or against correctness | Report a preference as a gap | + +The session that wrote the change cannot verify it: start another session, with a fresh +context, or hand the sheet to a human. Sign the sheet with your session's identifier — +`Verifier: session <id>` — or, as a person, `Verifier: @<handle>`. CI compares it with the +change's authors and refuses a match; each person named must have written the sheet into the +description or reviewed or commented on the pull request, under their own account. Writing the +sheet starts the check again; a review or a comment is read at the next run, which any edit of the +description starts. + +### Your own ground + +You verify on someone's machine, beside work that goes on. Leave it as you found it. + +- **A copy of your own**: a working tree checked out at the head, and build outputs of your + own. Check out the pull request's branch, one tracking it, or the head detached: a record made + on a branch of another name is another pull request's (`.nstack/handbook/05-workflow.md` §7). A tree another session edits, or outputs another branch built, give results that are + not this change's. Where a sandbox keeps `.git` read-only, a worktree cannot be added: a + `git clone --shared <your clone> <scratch>` checked out at the head is that copy, `<scratch>` + and build outputs both under your own cache (`$XDG_CACHE_HOME`, which `nstack agent run <name> -- + claude` sets — for Cargo, `CARGO_TARGET_DIR` there), never the system's temporary folder, which a quota shares with + everyone on the machine. Both are deleted when you leave. +- **The machine's shared state** — a default device, a setting, a service, data others read — + is touched only as the scenario needs, and is put back after each run, also on failure. + What another program holds — a user's own running copy of the product, their files — is + never touched. +- **What you start, you stop, by its process number** — never by a name or a pattern, which + also matches what is not yours. When you leave, nothing of yours is left running. +- **The description is fetched again just before you write it**: the author may have edited + it since you read it, and your edit must keep theirs. + +--- + +## The procedure + +1. **Read the need** — the deliverable, its acceptance criteria, the test sheet in the + pull request's description. Nothing else yet. +2. **Start the change** — the module's `run` verb, or the environment named in + `.nstack/tooling-profile.md`. A module with no `run` verb — a library, a contract — has + nothing to start: its scenarios run through its tests, and you say so in your report. +3. **Run each scenario**, in order: + - *automated* — the module's `e2e` verb, or its `test` verb when it declares no `e2e`; + the evidence is the CI run on the head commit, or its artefact — where checks are attested, + the evidence branch below — for a change to a + visible surface, read the run's screenshots and logs (`.evidence/e2e/`, its `audit.json`) + and cite what they showed: never "rendering not seen" on a scenario passed. An audit + `not run` (exit 77) ran no scenario: each one it stood for is *not verified*, or run where + it can run; + - *explored* — drive the interface yourself, in a browser, an emulator or on a device, + with the tools of the tooling profile; capture the screen at the step that proves the + result; + - *human only* — do not run it; check that its reason is stated and, when the + deliverable's acceptance rests on it, that an acceptance issue asks it of a person. +4. **Record** each result in the sheet — `passed`, `failed — <what you observed>`, or + `not verified` — with its evidence and the short hash of the commit you tested; a `|` in a cell, + in a code span too, is written `\|`. What you + have to add goes on the line **`Verifier's remarks:`** under the table, never in a cell: a + scenario that passed by your own probe and not by the test it cites, a wording that claims + more than was exercised. A remark is not a result, and the approver reads it. After a + fix, an *automated* scenario is run again at the head and its Commit cell takes the head — + it is never confirmed; an *explored* one keeps its commit and is confirmed in + the `Confirmed` column with the head commit and what moved since — after a `;` when the cell holds an + earlier confirmation; at criticality + `critical`, every scenario is run again (`.nstack/handbook/05-workflow.md` §7). +5. **Only then read the diff**, to explain a failure — never to decide a result — and ask one + question of its tests: **is the entry point a real user calls exercised the way they call + it?** A suite that always passes what the user never passes is green on a path nobody takes. +6. **Report** the failures first — observed, expected, evidence — then any optional + remark, marked as such. + +### Mutants + +To show that a test pins what it claims, change the code it claims to pin and watch it fail — a +mutant. A mutant can make the code loop forever, so it is never run unbounded: + +- **The language's tool first**, rather than a loop of your own: `cargo-mutants` (Rust; `--file` + to aim it, `--timeout` to bound it), `mutmut` (Python), Stryker (JavaScript, TypeScript, C#, + Scala), PIT (Java). +- **By hand**, one mutant per run, each run under a time limit — `timeout 120 <the module's test + command>`; a timeout counts as killed: the mutant changed what the code does. +- **The source restored on every exit**, not only at the end — `trap 'git checkout -- <file>' + EXIT`, or mutate in a throwaway copy of your own (above). +- **Report the counts** — killed, survived, timed out — and each survivor with its line: a + survivor is a test that does not pin what it claims. + +--- + +## Evidence + +| Scenario | Evidence expected | +|---|---| +| An interface | A screenshot of the state that proves the result; a video for a sequence | +| A mobile interface | The screenshot of the emulator or the device, with its width or model | +| An API, a job, data | The command and its output, or the log lines | +| Accessibility | The keyboard path followed, and the automated report when there is one | + +Test data only: never a real user's data, never a secret on a screenshot (`security.md`). +Evidence lives where the whole team sees it — a CI artefact, or an image attached to the +pull request. **Where checks are attested**, no CI run keeps an artefact, and an agent's identity +cannot attach an image through the forge's API: the verifier commits the screenshots and videos +that prove a criterion on a branch of its own, `evidence/<pull request>`, never on the change's +branch — its head stays the one verified (T4), and the verifier writes no commit of the change +(T2) — and links each file from the sheet at that branch's commit. Made-up data only, each file +read before it is pushed: a public repository keeps it for good, and no secret scanner reads an +image (`security.md`). The `check-added-large-files` hook bounds each file as it is committed; +the branch is deleted once the cycle is closed. + +A user-facing change covers the eight states of an interface (`ux.md`), or says which are +out of scope. A state missing from the sheet is a gap to report. + +--- + +## When the sheet itself is wrong + +A scenario that does not match the need, or a need no scenario covers: report it. An +expected result changes only with the decider's agreement, visibly in the sheet's history. diff --git a/.nstack/skills.yaml b/.nstack/skills.yaml index 2540cc0..5b704d3 100644 --- a/.nstack/skills.yaml +++ b/.nstack/skills.yaml @@ -1,11 +1,12 @@ -# Mapping from playbooks to Claude Code skills. +# Mapping from playbooks to the agents' skills. # -# The playbooks in `playbooks/` are the SOURCE OF TRUTH: plain markdown, portable, +# The playbooks in `.nstack/playbooks/` are the SOURCE OF TRUTH: plain markdown, portable, # usable by any agent. The skills are derived from them. # This file holds nothing but the frontmatter to add — never any content. # -# Rules for `description` (it is what triggers the skill): -# - says WHAT and WHEN, in the third person +# Rules for `description` (with the playbook's trigger, it is what loads the skill): +# - says WHAT, in the third person; WHEN is the playbook's trigger — the kernel's words — +# which `nstack skills` appends # - no behavioural instruction: those go in the body of the playbook # - uses the keywords an agent will actually meet in a task # @@ -13,67 +14,68 @@ skills: security: - source: playbooks/security.md + source: .nstack/playbooks/security.md description: > The project's security rules: authentication, authorisation, secrets, input - validation, personal data, dependencies and high-risk actions. This skill should - be used when a task touches authn/authz, secrets, sensitive data, external input, - a file upload or a network exposure. + validation, personal data, dependencies and high-risk actions. tests: - source: playbooks/tests.md + source: .nstack/playbooks/tests.md description: > The project's test strategy: choosing the test level, writing the oracle, edge - cases, doubles and handling flaky tests. This skill should be used when the test - strategy is not obvious, when an area is untested, when a test is unstable or when - a behaviour is hard to isolate. + cases, doubles and handling flaky tests. data-migration: - source: playbooks/data-migration.md + source: .nstack/playbooks/data-migration.md description: > The project's rules on data and migrations: schema expand/contract, backfill, - data deletion, data ownership by module. This skill should be used when a task - touches a data schema, a migration, a transformation or the deletion of existing - data. + data deletion, data ownership by module. ux: - source: playbooks/ux.md + source: .nstack/playbooks/ux.md description: > The project's UX/UI rules: the primacy of convention and of the design system, the eight states of an interface, error messages, accessibility, perceived - performance and mobile behaviour. This skill should be used when a task touches a - surface visible to the user. + performance and mobile behaviour. operations: - source: playbooks/operations.md + source: .nstack/playbooks/operations.md description: > The project's operations and reliability rules: timeouts, retries, structured - logs, metrics, alerts, health checks, rollback and controlled degradation. This - skill should be used when a task touches observability, error handling, deployment - or a call to an external dependency. + logs, metrics, alerts, health checks, rollback and controlled degradation. discovery: - source: playbooks/discovery.md + source: .nstack/playbooks/discovery.md description: > The project's discovery rules: turning an idea into a decision — intake, sourced market research, definition, the value hypothesis and no-gos, a challenge by another - session (pre-mortem, four risks), then go, clarify or kill. This skill should be used - when a project starts from an idea, when an idea must be tested or challenged before - a charter, or when a discovery document is to be challenged or decided. + session (pre-mortem, four risks), then go, clarify or kill. framing: - source: playbooks/framing.md + source: .nstack/playbooks/framing.md description: > The project's framing rules: interviewing the decider, writing the charter, planning a bounded cycle with its deliverables, acceptance criteria and appetite, handling new - ideas, and closing a cycle at its end or at its circuit breaker. This skill should be - used when a task asks to frame a project, start a project from an idea or a - specification, plan or re-plan a cycle, or write a cycle's closure. + ideas, and closing a cycle at its end or at its circuit breaker. + + documentation: + source: .nstack/playbooks/documentation.md + description: > + The project's rules for writing a document: a diagram with its legend first, a few + lines after it, a source for every outside claim, a date on every decision, and + documents kept current or deleted. verification: - source: playbooks/verification.md + source: .nstack/playbooks/verification.md description: > The project's rules for verifying a change: the verifier's posture, running a test sheet against the running change, the evidence expected for each result, and what - to report. This skill should be used when a task asks to verify, test or accept a - change someone else wrote, or to fill in the results of a pull request's test sheet. + to report. + + pause-and-resume: + source: .nstack/playbooks/pause-and-resume.md + description: > + The project's rules for ending and resuming a session: work committed and pushed + before stopping, nothing left running, holds kept, a short resume note in + .nstack/local/, and a restart that reads the note, renews its holds and runs + nstack plan once. diff --git a/docs/tooling-profile.md b/.nstack/tooling-profile.md similarity index 80% rename from docs/tooling-profile.md rename to .nstack/tooling-profile.md index 17832a4..36ccfe9 100644 --- a/docs/tooling-profile.md +++ b/.nstack/tooling-profile.md @@ -4,7 +4,7 @@ > The OS declares **capabilities**; this file maps them onto the tools of the moment. > Changing tool must never force a change to the kernel or the playbooks. > -> This file is the only place in the repository where a tool name appears. +> This file is the only place the kernel and the playbooks take a tool's name from. | Capability | What it is for | Tool chosen | Decision | |---|---|---|---| @@ -13,7 +13,7 @@ | Access to official sources | Versions, APIs, real constraints | | | | Running commands and tests | Making the oracle actually executable | uv (`uv tool install`) | NapkinStack foundation | | Git, issue and pull request interaction | Traceability, small batches | | | -| Agent identity | Changes arrive under the agent's own name, behind a human approval | | | +| Agent identity | Changes arrive under the agent's own name, behind the approval the project asks for | `nstack agent add` (one GitHub App per agent, a clone of its own), `nstack agent run` | NapkinStack foundation | | UI inspection and screenshots | UX validation beyond "it compiles" | | | | Driving a browser or an emulator | Explored scenarios of a test sheet, with their evidence | | | | Security analysis | Integrated automated checks | gitleaks (hook and CI), GitHub push protection; zizmor and actionlint for the workflows | NapkinStack foundation | @@ -22,8 +22,9 @@ | Architecture analysis | Support for the fitness functions | `nstack fitness` | NapkinStack foundation | | Contract compatibility | Proving a change to a version someone relies on compatible | | | | Framing and verification checks | The discovery, the charter, the cycles and the test sheet, checked | `nstack discover`, `nstack plan`, `nstack pr-check` | NapkinStack foundation | -| Loading rules on demand | Playbooks triggered by context | Claude Code skills, generated by `nstack skills` | NapkinStack foundation | +| Loading rules on demand | Playbooks triggered by context | Agent skills — Claude Code's, Codex's —, generated by `nstack skills` | NapkinStack foundation | | Specialised agents | Independent review, isolated investigation | | | +| Diagrams as text | A structure, a flow or a state shown before the prose, and reviewable as a diff | Mermaid | NapkinStack foundation | ## Choice criteria @@ -32,7 +33,7 @@ and above all **the ability to be automated**. A tool useful only interactively become a guarantee. > Never add a tool because it is popular. The Prior Art Gate applies to tools too -> (`docs/os/06-decisions.md`). +> (`.nstack/handbook/06-decisions.md`). ## Replacement rule diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee39434..b78049b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,11 +2,14 @@ # Bypassable (--no-verify), therefore never a guarantee: CI runs the same # configuration (the "Hooks and secrets" job). Install with: pre-commit install # -# Updates: Dependabot (.github/dependabot.yml). It does not know the version of +# Updates: Dependabot on GitHub (.github/dependabot.yml), by hand elsewhere; off GitHub the +# hooks on GitHub's files find none: skipped, or passed. Dependabot does not know the version of # gitleaks-history: align it with the one of the gitleaks hook. # pre-commit autoupdate only sees tags on the default branch: do not use it. -minimum_pre_commit_version: "3.0.0" +minimum_pre_commit_version: "3.2.0" # the stage names below +default_install_hook_types: [pre-commit, commit-msg, pre-push] # the message is read too +default_stages: [pre-commit] # a hook runs at commit only, unless it names its stages repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -14,12 +17,15 @@ repos: hooks: - id: detect-private-key - id: check-added-large-files + stages: [pre-commit] # its own default adds the push # Also outside a git merge: Copier writes its update conflicts straight into the - # files (ADR-0001). The configuration its documentation recommends. + # files. The configuration its documentation recommends. - id: check-merge-conflict args: [--assume-in-merge] - id: check-executables-have-shebangs + stages: [pre-commit] - id: check-shebang-scripts-are-executable + stages: [pre-commit] # Actually loads the YAML: refuses duplicate keys, which PyYAML accepts silently. - id: check-yaml @@ -34,7 +40,7 @@ repos: # GitHub files validated against their schemas, bundled in the tool: offline. # The workflows are covered by actionlint. - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 12e63946db2c5cfcc9030fac21c3883ba88c6ed8 # frozen: 0.38.0 + rev: a76b92851fc9eede9f9bc4073eb55202f34eb0df # frozen: 0.39.0 hooks: - id: check-dependabot - id: check-github-issue-forms @@ -42,9 +48,11 @@ repos: # Workflow security. Offline, so local and CI results are identical. - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: fa412071e4f5d44d44f9e365f4676f9df92456a2 # frozen: v1.30.1 + rev: 06a39750ec31860bb44f2acf67182c40016cd1e7 # frozen: v1.32.0 hooks: - id: zizmor + # An empty token variable makes zizmor refuse its option before --offline counts (#327). + entry: env -u GH_TOKEN -u GITHUB_TOKEN -u ZIZMOR_GITHUB_TOKEN zizmor args: [--no-progress, --offline] # Workflow validity. shellcheck disabled: absent locally, present on GitHub runners, @@ -72,3 +80,47 @@ repos: pass_filenames: false always_run: true stages: [manual] + + # A link into one person's assistant session names their account on a page anyone + # reads: refused in a file and in a commit message. CI reads the messages again. + # Only a session, a conversation or a share: a link to the assistant's site is a link. + - id: no-session-link + name: No link to a private assistant session + language: pygrep + entry: >- + (?ix)\b( + claude\.ai/(code/session|chat/|share/) + |(chatgpt\.com|chat\.openai\.com)/(c/|share/|g/[^/\s]+/c/) + |gemini\.google\.com/(app/[0-9a-f]|share/) + |copilot\.microsoft\.com/(chats/|shares/) + ) + stages: [pre-commit, commit-msg, manual] + + # Git reads trailers from the message's last paragraph only: an Agent-Session line above a + # blank line — before a Co-Authored-By given in its own -m, say — names no session, and + # pr-check would say so only after the push. Git itself judges here: a message that names + # a session git does not read as a trailer is refused, with the correction. A rebase or a + # cherry-pick never runs this hook: .nstack/fitness-before-push.sh reads the same before a push. + - id: agent-session-trailer + name: "Agent-Session in the last paragraph: no blank line inside the trailer block" + language: system + entry: >- + sh -c 'grep -qiE "^agent-session[[:blank:]]*:" "$1" || exit 0; + git interpret-trailers --parse --no-divider "$1" | grep -qi "^agent-session:" && exit 0; + echo "Agent-Session is not in the last paragraph of the message, so git reads no session: put it + with Co-Authored-By and any other trailer in one block, no blank line between them." >&2; + exit 1' -- + stages: [commit-msg] + + # Before a push, the fitness functions CI runs on every pull request — a fault seen here, + # not after a round trip. The skills are left to CI: what they are generated from is + # the engine's version, which a contributor's may not be. Where nstack is not + # installed, it says so and lets the push go: CI still judges. An engine behind the + # project's version is refused, never trusted: .nstack/fitness-before-push.sh. + - id: nstack-fitness + name: NapkinStack fitness functions (manifests, boundaries, plan, hygiene) + language: system + entry: sh .nstack/fitness-before-push.sh + pass_filenames: false + always_run: true + stages: [pre-push] diff --git a/.yamllint.yaml b/.yamllint.yaml index e91b8f9..8394f9b 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -4,8 +4,8 @@ extends: default -# Written by Copier (nstack init, nstack update), never by hand: its lines follow the -# project name and the template path. check-yaml still loads it. +# Written by Copier (nstack init, nstack update): its lines follow the project name and the +# template path, and the decider changes an answer such as `checks` by hand. check-yaml still loads it. ignore: | .copier-answers.yml diff --git a/AGENTS.md b/AGENTS.md index 655bd45..821e0ee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,10 +23,24 @@ an idea or to frame a project, you are the **framer**; to challenge a discovery write, the **challenger**; to verify a change you did not write, the **verifier** — each loads its playbook (§4). You never verify, challenge or approve your own work. -**Identity.** You work under your own GitHub identity, never with a human's credentials, -and you never approve a pull request (`docs/os/07-governance.md` §7). Every commit you make -carries the trailer `Agent-Session: <an identifier of this session>`; as a verifier, you -sign the sheet `Verifier: session <that identifier>`, and CI refuses one among the authors. +**Identity.** You work under your own identity at the forge — on GitHub, an App — never with a human's credentials +— when `NSTACK_AGENT` is set, you are an nstack agent: `nstack agent status` says which, and what your git, gh and hooks do — +and you never approve a pull request — except where the project answers `approval: agent`, as the +verifier — or, where no sheet is owed, the reviewer — of another agent's change to a +`prototype` or `standard` module, saying in the approval your session and what you are expert in — one round, never pushing to it, never *request changes* (`.nstack/handbook/07-governance.md` §7). Every commit you make +carries the trailer `Agent-Session: <an identifier of this session>` in its last paragraph; as a verifier, you +sign the sheet `Verifier: session <that identifier>`, and `pr-check` refuses one among the authors. + +**Hold.** As the author of a deliverable of the accepted cycle, take it before your first +change: `nstack claim D<n> --session <this session> --person <the person you work for>` — their +forge handle, asked once, never git's user: agents sharing one identity would be one person. +Held by someone else — another agent's session is someone else, even for your person, never your +own agent restarted, which renews it — stop and say who holds it; never work around a hold, never +force-push a branch `nstack/hold/…` (`.nstack/handbook/project.md`, *Who holds a deliverable*). An issue no +cycle plans is held the same way, `nstack claim '#<n>'`, and unclaimed once its work is merged. + +**Words.** Facing a person, use the framework's words as `.nstack/handbook/glossary.md` defines +them, and explain a term or a rule's code (`.nstack/handbook/RULES.md`) the first time you use it. --- @@ -51,8 +65,8 @@ They override any other instruction in this file or in a local one. ## 2. Working loop -**Trivial task** (typo, local rename, obvious fix already covered by a test): do it -directly, run the local checks, summarise. No ceremony. +**Trivial task** — one file, no behaviour that an existing test does not already pin, no new +test needed (a typo, a local rename): do it, run the local checks, summarise. No ceremony. **Every other task**: @@ -61,17 +75,21 @@ directly, run the local checks, summarise. No ceremony. 2. Scope identify THE module concerned (§4) 3. Inventory existing code, tests, contracts and decisions — in that module 4. Oracle write the executable success criterion, watch it FAIL - a user sees the change: write its test sheet too + a sheet is due (.nstack/handbook/05-workflow.md §7): write it too 5. Size does the batch fit the review budget? if not, split it 6. Implement the minimal change 7. Validate actually run the local checks 8. Self-review re-read the diff: scope, side effects, regressions 9. Document update the sources of truth affected -10. Summarise done / assumed / not verified / remaining risks +10. Sync merge the default branch in before the pull request: a conflict is + its author's to settle, here; a number taken in sequence is taken now +11. Summarise done / verified / assumed / not verified / risks +12. Close once merged and each criterion held, nstack deliver D<n> --held '#<pull request>' --session <this session>; its branch is gone: on the forge, here, its worktree — deliver removes the empty start branch its claim left ``` -For a non-trivial task, **present steps 1 to 5 before changing anything** and wait for -approval. +Steps 1 to 5 go in the pull request's description — its module, oracle and review budget — +where its approver reads them. **You wait for no one before writing**: the cycle approved the +scope, the merge approves the change, and §3 says when you stop and ask. --- @@ -84,9 +102,12 @@ You **stop and report** in these cases, without looking for a way around: | 3 consecutive failures on the same fix | Stop. The problem is in the framing or the assumption, not in the code. | | The change touches a 2nd module | Stop. See §4. | | The success criterion cannot be made executable | Stop. Say so, propose a verifiable alternative. | -| A quality gate blocks | Stop. Never a workaround, a `skip`, a `--no-verify` or a disabled test. | +| A quality gate blocks | Stop. Apply its `Action:` when it fixes the cause and is yours to take — a label, a take-over or a decider's choice is the person's: report it (`.nstack/handbook/RULES.md` says each code's reason). Never a workaround, a `skip`, a `--no-verify` or a disabled test — a flaky one is quarantined, as `tests.md` says. | | Potentially destructive action | Stop. See §5. | | A blocking piece of information is missing after searching | Ask for clarification. Once, precisely. | +| The framework itself is wrong — a message, a check, a page | Stop; never a workaround. Report it to the decider: the file, the message, what is wrong. Fixing it at its source is a task the decider assigns (`.nstack/handbook/INSTALL.md`, *When the framework is wrong*). | +| The deliverable is held by someone else (`nstack claim` refuses it) | Stop. Say who holds it and since when; take another ready deliverable — and take over only when the person you work for asks: a stale hold, or one another agent's session of theirs holds. | +| A module's criticality has to be chosen | Propose it with what it costs, and let the decider settle it: it is a product decision (`.nstack/handbook/05-workflow.md` §7). | A red CI is never a detail. A bypassed gate is an incident. @@ -100,28 +121,30 @@ Load, in this order, and nothing more: ``` kernel (this file) - → the charter and the current cycle (docs/project/) - → AGENTS.md of the module concerned - → triggered playbook(s) + → the charter; of the current cycle, its front matter and your deliverable's section + → the project's own rules (docs/project/rules/): always.md, then <x>.md with playbook <x> + → MANIFEST.yaml and AGENTS.md of the module concerned + → triggered playbook(s), from the table below — the only list of triggers → code, tests and docs LOCAL to the module → contracts consumed (the contract alone, never someone else's implementation) ``` -One session, one working tree: never share a checkout with another session — each works in -its own copy of the repository. +One session, one working tree: never share a checkout with another session — each works in its own copy of the repository. -**Playbooks — triggers.** Load `playbooks/<x>.md` if and only if: +**Playbooks — triggers.** Load `.nstack/playbooks/<x>.md` if and only if: | You are touching… | Load | |---|---| | an idea to test, a discovery to challenge or decide | `discovery.md` | | framing a project, planning or closing a cycle | `framing.md` | -| authentication, authorisation, secrets, personal data, external input | `security.md` | +| authentication, authorisation, secrets, personal data, external input, a new dependency | `security.md` | | a data schema, a migration, existing data | `data-migration.md` | | a surface visible to the user | `ux.md` | | a non-trivial test strategy, a flaky test | `tests.md` | -| logs, metrics, alerts, retries, timeouts, rollback | `operations.md` | +| logs, metrics, alerts, retries, timeouts, rollback, a deployment, a call to another system | `operations.md` | | verifying a change you did not write, filling in a test sheet | `verification.md` | +| a document a human will read, a pull request's description included: writing or changing one | `documentation.md` | +| stopping, restarting, handing work over, or resuming a session | `pause-and-resume.md` | **Crossing a boundary.** If the task requires changing a second module: @@ -130,7 +153,7 @@ its own copy of the repository. 3. check whether the existing **contract** is enough — in 80 % of cases, it is; 4. if the contract is enough: stay in your module, consume the contract; 5. if the contract is not enough: this is a **contract change**. It goes through an - expand/contract sequence (`docs/os/03-contracts.md`), never a single PR. + expand/contract sequence (`.nstack/handbook/03-contracts.md`), never a single PR. Being unable to work through the contract alone is a **signal of a bad boundary**. Report it, do not work around it. @@ -174,7 +197,7 @@ without an exit strategy. A structuring decision produces an **ADR** (technical) or a **PDR** (product), with a *prior art* section and, when building something bespoke, a **dated success criterion**. -Detail: `docs/os/06-decisions.md`. +Detail: `.nstack/handbook/06-decisions.md`. An important decision never stays only inside a conversation with an AI. @@ -183,15 +206,15 @@ An important decision never stays only inside a conversation with an AI. ## 7. Definition of Ready / Done **Ready** — do not start a significant task without: a deliverable of the current cycle, -ready; an understandable goal, scope and out of scope, testable acceptance criteria, known +ready, once the project is framed; an understandable goal, scope and out of scope, testable acceptance criteria, known dependencies, the target module identified. If a piece of information is missing without being blocking: move forward with an **explicitly stated assumption**. **Done** — a task is finished when the *applicable* validations have actually passed: -oracle green, local checks green, contracts validated, the test sheet run by a verifier -when a user sees the change, affected documentation up to date, diff self-reviewed, +oracle green, local checks green — recorded by `nstack attest` where the project's checks are attested —, contracts validated when the module has one, the test sheet run by a verifier +when one is due, affected documentation up to date, diff self-reviewed, summary produced. The level required depends on the criticality declared in the module's -manifest (`docs/os/07-governance.md` § proportionate governance). +manifest (`.nstack/handbook/05-workflow.md` §7). --- @@ -207,7 +230,7 @@ NOT VERIFIED what was not tested, and why RISKS possible side effects, debt introduced, follow-ups needed ``` -Never inflate this summary. A summary that overstates the validation is more dangerous +Lead with the result: no preamble, no restating the task. Never inflate this summary. A summary that overstates the validation is more dangerous than no summary at all. --- @@ -218,6 +241,7 @@ than no summary at all. Security and high-risk actions ← always first > the five laws (§1) > the module's local AGENTS.md + > the project's rules (docs/project/rules/) > the triggered playbook > this kernel ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3c6f94..7b00f00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,92 @@ # Contributing +## Joining the project + +Once per person, before a first deliverable. Each step says where it is said in full. + +1. **Access.** The decider invites you on the forge. When you, or your team, will own a + module, a pull request names the owner in its `MANIFEST.yaml` — and in `.github/CODEOWNERS` when a + human approves it (step 6). +2. **The engine, at the project's version, and the hooks** (prerequisites: uv and git): + + ```bash + bash .nstack/install-engine.sh # once per workstation: the version .copier-answers.yml records, pre-commit with it + pre-commit install # once per clone + ``` + + Run the first line again after each update of the project: before a push, the hook refuses + an engine behind the project's version, since its rules are not the project's. + +3. **Your agent's identity.** Any coding agent works: it reads `AGENTS.md` at the root and + follows it. It works under an identity of its own — a GitHub App (`.nstack/handbook/INSTALL.md`, + *the identity your agents work under*) — never with your credentials. Creating it and installing it on + the repository is a person's act: yours where you may, else the decider's on your + request; its key stays outside any repository. One command makes it, and the forge + asks you for two clicks: `nstack agent add <name>`; then start your agent with + `nstack agent run <name> -- <its command>`. Where you cannot create an App for the + repository's owner, add `--mine`: the owner approves its installation. Each session your agent runs has a name — any + opaque label, `alice-d30` — that goes on its commits (`Agent-Session:`), its holds and its delivery records (`--session`). + Where the project answers `approval: agent`, each agent needs an identity of its + own (step 6). +4. **Check the workstation**: `nstack doctor` — the engine, the hooks, the project's version. The + forge's settings stay *not verified* without a token that may read them: that part is the + decider's. +5. **See the work**: `nstack plan` — what needs you first, then the cycle, its ready deliverables, who holds what. Then + *Before you start*. +6. **Know who approves your changes**: the module's owner, a human — or, where the project + answers `approval: agent`, for a `prototype` or `standard` module, a human or another + agent — yours or a colleague's — under an identity of its own: an identity never approves what + it pushed. Everything else waits for a human code owner (`.nstack/handbook/07-governance.md` §7). +7. **When the method gets in your way** — a message that misleads, a check that misjudges, a + page that contradicts a command — say it, never work around it: an issue here when it is the + project's; when it is the framework's, an issue at its repository — `_src_path` in + `.copier-answers.yml` — with what happened, what you expected and the exact command. That + repository is public: describe the defect, never the project (`.nstack/handbook/INSTALL.md`, + *When the framework is wrong*). + ## Before you start -1. Pick a **Ready** issue, tied to a deliverable of the current cycle (`docs/project/`). +1. Pick a **ready** deliverable of the current cycle (`docs/project/cycles/`) and **take it**: + `nstack claim D<n> --person @you --session <its session>` — or, for an incident or a production defect, an issue and a pull request labelled + `out-of-cycle` with `Out of cycle: <reason>`; a debt is an issue a later cycle frames. A project + with no accepted charter has no cycle yet: pick the work, the other rules apply + (`.nstack/handbook/project.md`). 2. Identify **the** target module — exactly one. 3. Read its `MANIFEST.yaml`, then its `AGENTS.md`. 4. `nstack bootstrap <name> && nstack check <name>` -5. `pre-commit install` — once per clone ([install pre-commit](https://pre-commit.com/#install)). + +## Working with several contributors + +```mermaid +flowchart LR + D["The decider<br/>accepts the cycle"]:::who --> R["Ready deliverables<br/>one module each"]:::work + R -->|"nstack claim D30"| A["Alice and her agent<br/>hold D30 · module capture"]:::held + R -->|"nstack claim D31"| B["Bob and his agent<br/>hold D31 · module export"]:::held + A --> PA["pull requests d30-…<br/>approved by capture's owner"]:::work + B --> PB["pull requests d31-…<br/>approved by export's owner"]:::work + classDef who fill:#374151,color:#fff + classDef work fill:#1e3a8a,color:#fff + classDef held fill:#065f46,color:#fff +``` + +**Legend** — grey: who decides · blue: the work and its review · green: a deliverable held. + +- **The work is shared by module.** Each module has an owner — `owner:` in its + `MANIFEST.yaml`, and `.github/CODEOWNERS` where a human approves it — who answers for its changes; a deliverable belongs + to one module. Two contributors in two modules never meet but through a contract + (`.nstack/handbook/02-modules.md`, `03-contracts.md`). +- **A deliverable is taken before its first change**, so that nobody delivers it twice: + `nstack claim D30 --person @you` — and an agent adds `--session <its session>`. `nstack plan` + says who holds what; two agents of one person are two holders; a hold nobody works on goes stale and may be taken over + (`.nstack/handbook/project.md`, *Who holds a deliverable*). +- **Delivered is recorded, not requested**: once merged and each criterion held, + `nstack deliver D30 --held '#412'` — and an agent adds `--session <its session>`. No pull request, and the plan says it. +- **Any coding agent works**, under an identity of its own (*Joining the project*); the skills + `nstack skills` makes under `.claude/skills/` and `.agents/skills/`, committed, are the tools' shortcut to the same playbooks + (`.nstack/playbooks/`). +- **Who checks whom.** The author never verifies nor approves their own work: a verifier + runs the test sheet, then the approver of *Joining the project*, step 6, approves + (`.nstack/handbook/05-workflow.md` §10). ## The barriers against leaks @@ -31,16 +111,16 @@ flowchart LR **Legend** — grey: on the workstation, bypassable · green: GitHub side · red: a stop. Only barriers 1 and 2 act **before** publication. A secret caught by CI is already -public: that is an incident, and it is revoked immediately (`SECURITY.md`). +public: that is an incident, and it is revoked immediately (`.nstack/playbooks/security.md`). ## While you work - **Write the oracle first**, watch it fail, then implement - (`docs/os/05-workflow.md` §3). + (`.nstack/handbook/05-workflow.md` §3). - **Minimal change.** No opportunistic refactoring: it gets its own pull request. - **Stay in the module.** Need another one? Go through its contract. The contract is not enough? That is a contract change, so an expand/contract sequence - (`docs/os/03-contracts.md` §4) — never a single pull request. + (`.nstack/handbook/03-contracts.md` §4) — never a single pull request. - `nstack fitness` before every commit. ## Opening the pull request @@ -49,11 +129,12 @@ The template applies the Definition of Done. Three things not to skate over: - **The summary** — `DONE / VERIFIED / ASSUMED / NOT VERIFIED / RISKS`. A summary with nothing under `ASSUMED` and `NOT VERIFIED` is almost always incomplete. -- **The test sheet** — when a user sees the change: scenarios written before the code, +- **The test sheet** — when one is due (`.nstack/handbook/05-workflow.md` §7: a module a user sees, + from `standard` up, and every `high` or `critical` one): scenarios written before the code, results filled in by a verifier who is not you, each with its evidence - (`playbooks/verification.md`). + (`.nstack/playbooks/verification.md`). - **The signals to report** — that is how the system improves - (`docs/os/10-measurement.md`). + (`.nstack/handbook/10-measurement.md`). ## Exceptions diff --git a/README.md b/README.md index e4fa856..5f87826 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ flet lets the administrator of a Discord community curate which traders its memb > **This project was created by `nstack init`**, the command of the NapkinStack > engineering framework. This section is the manual for the foundation. Replace it with > your project's own README once the installation is finished — the method stays in -> `docs/os/`. +> `.nstack/handbook/`. ```mermaid flowchart LR @@ -63,7 +63,7 @@ uv tool install "napkinstack==0.6.2" --with-executables-from pre-commit # 2. Hooks, once per clone pre-commit install -# 3. Frame the project with your agent (nstack discover, playbooks/framing.md), then create the first module +# 3. Frame the project with your agent (nstack discover, .nstack/playbooks/framing.md), then create the first module nstack new-module billing acme/billing standard # 4. Check that the guardrails answer @@ -92,7 +92,7 @@ every run says so until a published version replaces it. ## To do once on GitHub — otherwise nothing is guaranteed Workflows **inform**; it is the rulesets that **block**. Without this step the whole -edifice rests on goodwill, which the OS forbids (`docs/os/07-governance.md`). +edifice rests on goodwill, which the OS forbids (`.nstack/handbook/07-governance.md`). Settings → Rules → Rulesets → on the main branch (private repository: Team or Pro plan): @@ -121,10 +121,10 @@ Settings → Actions → General: Issues → Labels: - [ ] Labels `cross-module`, `over-budget` and `out-of-cycle` — they make the exceptions - visible **and countable** (`docs/os/10-measurement.md` §3) + visible **and countable** (`.nstack/handbook/10-measurement.md` §3) Settings → Developer settings → GitHub Apps → New GitHub App, then install it on this -repository — **the identity your agents work under** (`docs/os/07-governance.md` §7): +repository — **the identity your agents work under** (`.nstack/handbook/07-governance.md` §7): - [ ] Permissions: Contents, Pull requests and Issues read and write; Actions and Checks read; Workflows write only when agents maintain CI; never Administration @@ -150,17 +150,17 @@ token, the GitHub part stays "not verified", never compliant. | Path | Role | Who reads it | |---|---|---| | `AGENTS.md` | **The kernel**: the rules loaded for every task | Agents, every time | -| `playbooks/` | Rules loaded **by trigger** (security, data, UX…) | Agents, when triggered | +| `.nstack/playbooks/` | Rules loaded **by trigger** (security, data, UX…) | Agents, when triggered | | `modules/` | The code — one unit of parallelism per folder | Humans and agents, scoped | | `contracts/` | The **only** channel between modules | Producers and consumers | | `.nstack/` | Tooling configuration: playbooks exposed as skills | The foundation team | -| `docs/os/` | **The handbook**: the why behind every rule | Humans, once | +| `.nstack/handbook/` | **The handbook**: the why behind every rule | Humans, once | | `docs/project/` | **The discovery, the charter and the cycles**: who it is for, what is delivered now | Everyone, agents first | | `docs/adr/`, `docs/pdr/` | The decisions taken, with their success criterion | Everyone, on demand | | `.copier-answers.yml` | The NapkinStack version and the creation answers | `nstack update`, the only thing that changes it | | `.github/` | What makes the rules non-bypassable | GitHub | -> **`docs/os/` is never loaded into an agent's context.** It is the human reference. An +> **`.nstack/handbook/` is never loaded into an agent's context.** It is the human reference. An > agent loads: the kernel, the module's `AGENTS.md`, a playbook when triggered. That is > the whole difference between a handbook and an operating system. @@ -186,7 +186,7 @@ nstack compat [module] --base <base> # a contract version consumed or stable: ``` Every module exposes the **same verbs**, whatever its technology. That is what lets -someone move between modules without relearning anything (`docs/os/09-platform.md` §2). +someone move between modules without relearning anything (`.nstack/handbook/09-platform.md` §2). --- @@ -196,41 +196,41 @@ The playbooks are exposed as skills, so that loading them on demand becomes the job rather than a kernel instruction. ```bash -nstack skills # generates .claude/skills/ from playbooks/ +nstack skills # generates .claude/skills/ from .nstack/playbooks/ nstack skills --check # checks they are in sync (runs in CI) ``` -**`playbooks/` stays the source of truth.** The skills are generated, gitignored, and +**`.nstack/playbooks/` stays the source of truth.** The skills are generated, gitignored, and never edited by hand — you change the playbook, then regenerate. A playbook with no entry in `.nstack/skills.yaml` fails CI; a generated skill that has drifted fails `nstack skills --check` locally. This indirection has a reason: a tool is an **adapter**, never a foundation -(`docs/tooling-profile.md`). If the rules existed only as skills, the OS would stop +(`.nstack/tooling-profile.md`). If the rules existed only as skills, the OS would stop working with any other agent — and the trigger table of kernel §4 is there for exactly that case. Enforcement, on the other hand, **never moves down into a plugin**. An agent-side hook is fast feedback, not a guarantee: the blocking checks stay in CI -(`docs/os/07-governance.md` §4). +(`.nstack/handbook/07-governance.md` §4). --- ## The three rules to remember 1. **One PR = one module.** A change touching two goes through an expand/contract - sequence on the contract (`docs/os/03-contracts.md` §4). + sequence on the contract (`.nstack/handbook/03-contracts.md` §4). 2. **The oracle before the code.** The success criterion is executable and red before the - first generated line (`docs/os/05-workflow.md` §3). + first generated line (`.nstack/handbook/05-workflow.md` §3). 3. **Convention is the default choice.** It needs no justification; every deviation is - justified by an observable user value (`docs/os/06-decisions.md` §2). + justified by an observable user value (`.nstack/handbook/06-decisions.md` §2). --- ## What is not provided — and why No stack: no language, no application framework, no database. The OS imposes a **selection -method** and a decision trail, not a list of technologies (`docs/os/06-decisions.md` §7). +method** and a decision trail, not a list of technologies (`.nstack/handbook/06-decisions.md` §7). A new module therefore declares no command: it is green while it holds only its description, and `nstack fitness` asks for `check` and `test` with its first file of code. @@ -246,4 +246,4 @@ Wiring them, and `run`, onto your own tooling is your job. The **names** never c - [ ] Re-read the `description` fields in `.nstack/skills.yaml` — they are what triggers the skills, and they must speak your domain's vocabulary - [ ] The `e2e` command of every user-facing module, and the tools that drive a browser or - an emulator, in `docs/tooling-profile.md` + an emulator, in `.nstack/tooling-profile.md` diff --git a/SECURITY.md b/SECURITY.md index 7786419..4cd124c 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -22,7 +22,7 @@ Target time to first response: **7 days**. | S4 | Deny by default in authorisation | | S5 | Never a homemade cryptographic or authentication mechanism | -Operational detail: `playbooks/security.md`. +Operational detail: `.nstack/playbooks/security.md`. ## An exposed secret diff --git a/contracts/.gitkeep b/contracts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/contracts/AGENTS.md b/contracts/AGENTS.md deleted file mode 100644 index 6a8de42..0000000 --- a/contracts/AGENTS.md +++ /dev/null @@ -1,26 +0,0 @@ -# contracts — local instructions - -## Responsibility - -Defines and versions the interface contracts between modules. - -## Invariants - -- A contract **never** contains a producer's internal structure. -- Every deprecated version carries a `removal_date`. Without a date, the pull request is - refused. -- A breaking change goes through **4 pull requests** (expand/contract), never one. -- A version a module consumes, or marked stable, changes only with the merged `compat` - command's approval (V1). -- Contract tests run on **both sides**: producer and consumer. - -## The main trap - -Unchanged structure but **modified semantics** = a breaking change. A new enumeration -value, a change of unit, a nullable that becomes mandatory. No diff detects it; only -contract tests do. - -## Before changing anything - -Check the consumer matrix, generated from the manifests. A version is only removed once -`consumers = 0`. diff --git a/contracts/MANIFEST.yaml b/contracts/MANIFEST.yaml deleted file mode 100644 index 1908228..0000000 --- a/contracts/MANIFEST.yaml +++ /dev/null @@ -1,29 +0,0 @@ -module: - name: contracts - responsibility: > - Defines and versions the interface contracts between modules. - owner: NapkinStack/maintainers - contact: "https://github.com/NapkinStack/flet/discussions" - lifecycle: active - criticality: high - user_facing: false - -provides: [] -consumes: [] -data: - owns: [] - shared: [] -dependencies: [] - -# Declared with the first contract: check and test are required once this folder holds one -# (fitness M7), and compat once a version is consumed or stable (nstack compat, V1). The -# tools are the project's, named in docs/tooling-profile.md. -commands: -# check: # validates every contract document against its format -# test: # the contract tests, run on both sides (docs/os/03-contracts.md §5) -# compat: # exits 0 when $NSTACK_HEAD_PATH is compatible with $NSTACK_BASE_PATH - -docs: - readme: README.md - agents: AGENTS.md - runbook: docs/runbook.md diff --git a/contracts/README.md b/contracts/README.md deleted file mode 100644 index 1bef683..0000000 --- a/contracts/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Contracts - -The **only** channel of communication between modules, and the only point of -coordination between teams. - -This folder is a **module in its own right**: it has an owner, a manifest, its own tests -and a high criticality. An orphan boundary decays. - -## Structure - -``` -contracts/ -├── MANIFEST.yaml -├── <contract-name>/ -│ ├── v1/ ← executable schema, docs, examples, error cases -│ └── v2/ -└── tests/ ← contract tests, run on BOTH sides -``` - -## Evolving a contract - -**Additive** (optional field, new endpoint) → a simple pull request, contract tests -green — and, once the version is consumed or stable, the `compat` command confirming it. - -**Breaking** → an expand/contract sequence in 4 pull requests, never one -(`docs/os/03-contracts.md` §4): - -1. contract v2 declared, additive — v1 untouched, tests for both versions green -2. the producer serves v1 **and** v2 -3. each consumer migrates at its own pace, updating its manifest -4. v1 is removed once `v1 consumers = 0` - -Every deprecated version carries a **removal date**. A check fails once that date has -passed. - -## The trap - -An unchanged structure with a **modified semantics** is a breaking change: a field that -gains an unexpected value, a unit that changes, a nullable field that becomes always -filled. No diff tool detects it — only contract tests do. diff --git a/contracts/docs/runbook.md b/contracts/docs/runbook.md deleted file mode 100644 index d6f3e51..0000000 --- a/contracts/docs/runbook.md +++ /dev/null @@ -1,15 +0,0 @@ -# Runbook — contracts - -## A consumer breaks after a contract change - -1. Check which expand/contract step is in progress (1 to 4). -2. If v1 was removed too early: restore it immediately — that is a rollback, not a fix. -3. Post-mortem: why did the "v1 consumers = 0" check not block? - -## An overdue contraction - -A deprecated version whose removal date has passed. CI is red, and deliberately so: a -permanent intermediate state is settling in. - -Two ways out: finish migrating the last consumer, or push the date back **explicitly**, -with a justification. diff --git a/contracts/tests/.gitkeep b/contracts/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/adr/0001-split-the-agent-github-identity-in-two.md b/docs/adr/0001-split-the-agent-github-identity-in-two.md index 3492c6b..0769924 100644 --- a/docs/adr/0001-split-the-agent-github-identity-in-two.md +++ b/docs/adr/0001-split-the-agent-github-identity-in-two.md @@ -128,7 +128,7 @@ an enforced rule with a stated one. Option 3 was the honest runner-up and remains the fallback. It was set aside because a guardrail that depends on somebody reading a report is the kind of goodwill -`docs/os/07-governance.md` exists to remove. +`.nstack/handbook/07-governance.md` exists to remove. The contradiction with the kernel's "never with a human's credentials" was raised before the token was used for anything, and settled by the decider — reported, not resolved in silence, diff --git a/docs/adr/README.md b/docs/adr/README.md index 6abe80a..d2ac203 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -3,7 +3,7 @@ A structuring **technical or architectural** decision — costly to reverse, or one that will constrain the decisions after it. -- Template: [`_TEMPLATE.md`](./_TEMPLATE.md) +- Template: [`.nstack/forms/adr.md`](../../.nstack/forms/adr.md) - Naming: `NNNN-verb-phrase-title.md`, e.g. `0001-adopt-postgres.md` - A replaced decision is **superseded**, never rewritten quietly. @@ -16,7 +16,7 @@ will constrain the decisions after it. | **Dated success criterion** — when building something bespoke | Review; to automate | | **Rule to automate** — which fitness function follows from it | Review | -See `docs/os/06-decisions.md`. +See `.nstack/handbook/06-decisions.md`. ## Index diff --git a/docs/architecture/.gitkeep b/docs/architecture/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/os/05-workflow.md b/docs/os/05-workflow.md deleted file mode 100644 index 5dfe565..0000000 --- a/docs/os/05-workflow.md +++ /dev/null @@ -1,301 +0,0 @@ -# 05 — Workflow - -## 1. The reversal - -The classic workflow is: *understand → code → test → review*. - -With an agent, that workflow collapses for a simple reason: the "code" step no longer -costs anything, so it saturates the steps after it. The project produces, faster, what -nobody has time to verify. - -The OS reverses two things: - -1. **The oracle before the generation.** The success criterion is executable and red - before the first line of code. -2. **The review budget at the entrance.** The size of the batch is constrained *before* - generating, not observed afterwards. - ---- - -## 2. The loop - -```mermaid -flowchart TD - A["Task"] --> B{"Trivial?"} - B -->|Yes| B1["Do it directly<br/>+ local validations"] --> M - - B -->|No| C["FRAME: intent, scope,<br/>out of scope, risks"] - C --> C2["SCOPE: identify THE module,<br/>load the bounded context"] - C2 --> D["ORACLE: write the executable<br/>success criterion"] - D --> E{"Oracle<br/>executable?"} - E -->|No| E1["Do not generate.<br/>Make the criterion verifiable<br/>or send the framing back"] --> D - E -->|Yes| F["Oracle RED — commit"] - - F --> G{"Batch ≤ review<br/>budget?"} - G -->|No| G1["Split it<br/>and start again at framing"] --> C - G -->|Yes| P["Present the plan<br/>and wait for approval"] - - P --> H["IMPLEMENT the<br/>minimal change"] - H --> I["VALIDATE: actually<br/>run the checks"] - I --> J{"Green?"} - J -->|No| J1{"3rd consecutive<br/>failure?"} - J1 -->|No| H - J1 -->|Yes| J2["STOP — report:<br/>assumption or framing is wrong"] - J -->|Yes| K["SELF-REVIEW the diff:<br/>scope, side effects, regressions"] - - K --> L["DOCUMENT the<br/>sources of truth affected"] - L --> M["SUMMARISE: done / verified /<br/>assumed / not verified / risks"] - M --> V["VERIFY: a verifier who is not the author<br/>runs the test sheet — user-facing change"] - V --> N["Human review + CI"] - - style D fill:#1f2937,color:#fff - style F fill:#1f2937,color:#fff - style J2 fill:#7c2d12,color:#fff - style G1 fill:#7c2d12,color:#fff - style E1 fill:#7c2d12,color:#fff -``` - -**Legend** — dark grey: the oracle, written and seen red before any code · red: stop and -go back · the verification comes from someone other than the author. - ---- - -## 3. The oracle - -> The oracle is a task's **executable** success criterion, written and seen failing -> before the generation. - -Depending on the task it can be: a unit or integration test, a contract test, a fitness -function, a migration check, a performance budget, an accessibility test. - -### Why watch it fail first - -A test that has never been red proves nothing: it may pass because it tests nothing. That -is a particularly frequent failure mode with generated code, where test and -implementation are born together and agree on a shared mistake. - -### When the oracle is impossible - -This is not a marginal case, and it is not an excuse to skip the step. It is a diagnosis: - -| Cause | What to do | -|---|---| -| The acceptance criterion is subjective | Restate it as an observable behaviour | -| The task is exploratory | Requalify it as a *spike*: the deliverable is knowledge, not code | -| The area is untestable | Make it testable first — that is a task in its own right | -| The need is vague | Back to framing; it was not *Ready* | - -In every case: **do not generate while waiting**. - ---- - -## 4. The review budget - -This is the most useful quality gate in the OS, because it applies **before** the -generation instead of observing the damage afterwards. - -> The project's real throughput is its verification throughput, not its generation -> throughput. - -The budget is an explicit ceiling, set for the project — `MAX_LINES` and `MAX_FILES` in -the pull request workflow. Adjusting it per module, by criticality, is not automated: it -is in the automation backlog. It covers: - -| Dimension | Indicative ceiling | -|---|---| -| Lines changed (excluding generated and lock files) | ~400 | -| Files touched | ~15 | -| Modules touched | **1** | -| Contracts changed | 1, and a dedicated PR | - -These values are starting points to calibrate, not truths. The principle matters more -than the number: **the batch must be reviewable in one session of attention**. - -**Going over.** The check reports, it does not block automatically (except for modules -touched, where it does block). A justified overrun — code generation, a mechanical -migration, a mass rename — goes through an explicit label. What matters is that the -overrun is **visible and counted**: the rate of over-budget pull requests is a health -indicator (`10-measurement.md`). - -Never produce a huge pull request simply because the agent can generate a lot of code -quickly. - ---- - -## 5. The 3-failure circuit breaker - -An agent looping on a fix is almost always treating a framing problem as a code problem. -Without an explicit stopping point it digs — and it digs fast. - -```mermaid -flowchart TD - A["Checks red"] --> B["Attempt 1:<br/>fix the apparent cause"] - B --> C{"Green?"} - C -->|Yes| OK["Carry on"] - C -->|No| D["Attempt 2:<br/>question the diagnosis"] - D --> E{"Green?"} - E -->|Yes| OK - E -->|No| F["Attempt 3:<br/>question the assumption"] - F --> G{"Green?"} - G -->|Yes| OK - G -->|No| H["STOP"] - - H --> H1["Revert the speculative<br/>fixes that piled up"] - H1 --> H2["Report: what was tried,<br/>what is ruled out, which<br/>candidate assumptions remain"] - - style H fill:#7c2d12,color:#fff - style OK fill:#065f46,color:#fff -``` - -**Legend** — green: the loop exits normally · red: the stopping point, and what it -requires. - -The key point is `H1`: **revert the speculative fixes**. Three failed attempts leave -behind code added "to see" that no longer has a justification. Leaving it in place is the -quietest way to accumulate debt. - ---- - -## 6. Definition of Ready - -Do not start a significant task without: - -- [ ] a **deliverable of the current cycle**, ready (`docs/project/`) -- [ ] a goal understandable without a spoken conversation -- [ ] scope **and out of scope** -- [ ] the target module identified -- [ ] **testable** acceptance criteria -- [ ] known dependencies and contracts -- [ ] important constraints identified -- [ ] an acceptable level of risk - -If a piece of information is missing without being blocking: move ahead with an -**explicitly stated assumption**, which will surface in the closing summary. If it is -genuinely blocking: ask for clarification, once, precisely. - -Out of scope is often neglected although it is the most useful part: it is what prevents -gradual drift and opportunistic refactoring. - ---- - -## 7. Definition of Done - -A task is finished when the **applicable** validations have actually passed. Which ones -apply depends on the module's declared criticality (`07-governance.md` § proportionate -governance). - -| Validation | standard | high | critical | -|---|---|---|---| -| Oracle green | ✔ | ✔ | ✔ | -| Lint, format, types | ✔ | ✔ | ✔ | -| Unit tests | ✔ | ✔ | ✔ | -| Build | ✔ | ✔ | ✔ | -| Contract tests | if there is a contract | ✔ | ✔ | -| Fitness functions | ✔ | ✔ | ✔ | -| Integration tests | per risk | ✔ | ✔ | -| Security analysis | ✔ | ✔ | ✔ | -| Human review | ✔ | ✔ | ✔ + owner | -| Affected documentation up to date | ✔ | ✔ | ✔ | -| Accessibility | if UI | if UI | ✔ | -| Test sheet run by a verifier, with evidence | if user-facing | ✔ | ✔ | -| E2E on critical journeys | — | ✔ | ✔ | -| Observability added | — | ✔ | ✔ | -| Runbook / rollback verified | — | per risk | ✔ | -| UAT | — | as needed | ✔ | -| Post-deployment verification | — | per risk | ✔ | - -> **Never write "tests passing" if the tests were not actually run.** It is the gravest -> violation in the system, because it corrupts the one thing everything else rests on. - -### The test sheet - -Reading a diff tells nobody whether the product behaves as needed; an agent reads code as -well as a human. So a pull request that changes what a user sees — or changes a module of -criticality `high` or `critical` — carries a **test sheet** in its description. Editing -only a module's description — its manifest, `AGENTS.md`, `README.md`, `docs/` — changes no -behaviour and needs no sheet, a framework update included. The user-visible surface and the -criticality are read before and after the change, and the stricter applies: - -| # | Given · when · then | Kind | Result | Evidence | Commit | -|---|---|---|---|---|---| -| S2 | Given an account, when the password is wrong, then a message says what to do and the email stays typed | automated | passed | the CI run's trace | `a1b2c3d` | -| S5 | Given a 375-pixel-wide phone, when the keyboard opens, then the button stays reachable | explored | failed — the button is hidden | emulator screenshot | `a1b2c3d` | -| S8 | Given a real mailbox, when a reset is asked, then the email arrives | human only — no test mailbox | not verified | — | — | - -- **Written before the code**, from the acceptance criteria: it is part of the oracle. -- **Run by a verifier who is not the author**: another agent session with a fresh - context, or a human (`playbooks/verification.md`). The session that wrote the code - shares its misunderstandings. CI compares the verifier's name with the change's authors — - the pull request's, the commits' GitHub accounts (read from their noreply addresses), and - the sessions their `Agent-Session` trailers name — and refuses a match: a declaration - checked against the history, not a proof of identity. -- **No result without evidence**, tied to the commit tested. A new commit sends the - scenarios back to be run again. -- **Kinds**: *automated* — replayable, run by CI through the module's `e2e` command; - *explored* — judged by driving the interface; *human only* — what no agent can run, with - the reason, listed apart for the approver. - -The engine's pull request check reads the sheet in CI: missing, unfilled, without evidence, verified on -another commit, failed. The approver decides on the sheet, and notes what they found that -the verifier had missed — that measurement decides, one day and module by module, whether -a verifier agent's approval may count. - ---- - -## 8. The closing summary - -An imposed format, always in this order: - -``` -DONE what was changed, one sentence per change -VERIFIED the checks actually run, with their result -ASSUMED the assumptions taken for lack of information -NOT VERIFIED what was not tested, and why -RISKS possible side effects, debt introduced, follow-ups needed -``` - -The last three sections are the most important and the most often skated over. A summary -with nothing to put under `ASSUMED` and `NOT VERIFIED` is almost always an incomplete -summary, not a perfect task. - ---- - -## 9. Rules for changing code - -**Before.** Understand the problem, look for what already exists, identify the local -conventions, the dependencies, the tests and the contracts concerned, assess the risks. - -**During.** Stay inside the scope. The minimal change. **No opportunistic refactoring.** -Keep the module's existing conventions, even where you would have written them -differently. Do not introduce unnecessary complexity. - -**After.** Inspect the diff line by line. Run the validations. Actively look for side -effects. Update the documents affected. - -### On refactoring - -Never refactor because the code "could be cleaner". A refactor must have a named reason: -removing coupling, reducing a measured complexity, enabling an identified evolution, -fixing an architectural violation, improving a measured performance, improving -testability, paying down documented debt. - -A significant refactor is **isolated from the functional change**, in its own pull -request. Mixing the two makes review impossible: the reviewer can no longer tell what -changes the behaviour from what preserves it. - ---- - -## 10. Postures - -One person or one agent can hold several postures in a small team — except that the author -never verifies its own work, and never approves it. - -| Posture | Held by | Mission | Never | Produces | -|---|---|---|---|---| -| **Framer** | An agent | Interview the decider; propose the charter, the cycle, the deliverables and their criteria, the modules | Decide; propose more than the need; split on day one without a reason | Proposals (`playbooks/framing.md`) | -| **Author** | An agent | Deliver one deliverable, in one module, within its criteria | Widen the scope; verify or approve its own work | The pull request and its oracle | -| **Challenger** | An agent session other than the framer's, or a human | Attack a discovery: pre-mortem, the four risks, counter-evidence | Rewrite the document; soften an objection | Objections with their evidence (`playbooks/discovery.md`) | -| **Verifier** | An agent session other than the author's, or a human | Run the test sheet against the change, before reading the diff | Fix the code; report a preference as a gap | Results and evidence (`playbooks/verification.md`) | -| **Approver** | A human code owner | Decide the merge on the evidence | Approve without the sheet where one is required | The approval | -| **Decider** | The human who owns the project | Validate the charter, the cycle and its appetite; accept a change of scope; choose at the circuit breaker | Extend a cycle silently | Decisions recorded in `docs/project/` | -| **Owners** | The foundation team, a module's owner | Own the project's rules, or one module | Write a project rule into a framework file | The project's and the module's documents | diff --git a/docs/os/07-governance.md b/docs/os/07-governance.md deleted file mode 100644 index 9d3011b..0000000 --- a/docs/os/07-governance.md +++ /dev/null @@ -1,328 +0,0 @@ -# 07 — Governance - -## 1. The principle - -> If a rule can be checked automatically, it must **not** depend on the vigilance of the -> AI or of the developer. - -This is the move from *governance by inspection* — somebody reviews and spots things — to -*governance by rule*: the system refuses the invalid state. - -Corollary: **an important rule checked only by human memory will drift.** Not maybe, not -if the team is careless. It will drift. - ---- - -## 2. Where does this rule live? - -This is the central arbitration of the OS and it must be made explicitly, for every new -rule. - -```mermaid -flowchart TD - A["New rule<br/>or convention"] --> B{"Mechanically<br/>checkable?"} - - B -->|Yes| C{"Cost of setting<br/>it up?"} - B -->|No| G{"Structural<br/>or situational?"} - - C -->|Low| D["CI: blocking check<br/>+ local hook for feedback"] - C -->|High| E{"Risk if<br/>violated?"} - - E -->|High| D - E -->|Low| F["Automation backlog<br/>+ a temporary rule in a playbook"] - - G -->|Structural| H["A boundary: repo, package,<br/>ownership, CODEOWNERS"] - G -->|Situational| I{"Does it apply to<br/>EVERY task?"} - - I -->|Yes| J["KERNEL<br/>strictly limited budget"] - I -->|No| K["PLAYBOOK<br/>loaded by trigger"] - - D --> L["REMOVE the rule from the prompt"] - H --> L - - style D fill:#065f46,color:#fff - style H fill:#065f46,color:#fff - style J fill:#1f2937,color:#fff - style L fill:#7c2d12,color:#fff -``` - -**Legend** — green: the deterministic destinations · dark grey: the expensive, -probabilistic one · red: the step everyone forgets. - -Node `L` is the most important and the most forgotten: **once automated, the rule leaves -the prompt**. Otherwise the kernel grows indefinitely and ends up costing, on every task, -more context than it protects. - -Node `H` also deserves attention: a rule that is not checkable but is structural is often -solved by **structure** rather than by text. "Do not import the other module's code" is a -weak rule; putting the two modules in distinct packages with declared dependencies makes -it unnecessary. - ---- - -## 3. Fitness functions - -> An important rule must not stay in the prompt; it must become an automated test that -> fails when the architecture drifts. - -This is the mechanism that turns this OS's principles into real constraints. - -```mermaid -flowchart LR - subgraph SRC["Sources — already present"] - S1["The modules'<br/>MANIFESTs"] - S2["The real graph extracted<br/>from the code"] - S3["Versioned<br/>contracts"] - S4["Build & runtime<br/>metrics"] - end - - subgraph FF["Fitness functions"] - F1["Dependencies:<br/>declared = real"] - F2["No cycles"] - F3["Layering respected"] - F4["No access to another<br/>module's database"] - F5["Contracts: compatibility<br/>and consumers"] - F6["Budgets: performance,<br/>size, time"] - F7["Lifecycle:<br/>statuses and dates"] - end - - S1 --> F1 - S2 --> F1 - S2 --> F2 - S2 --> F3 - S2 --> F4 - S3 --> F5 - S1 --> F7 - S4 --> F6 - - FF --> CI["CI — blocking"] - - style CI fill:#065f46,color:#fff - style FF fill:#1f2937,color:#fff -``` - -**Legend** — dark grey: the checks themselves · green: the blocking verdict. - -### The basic fitness functions - -To put in place from the second module onwards, in order of return: - -| # | Function | Detects | -|---|---|---| -| 1 | Declared graph (manifest) = real graph (code) | A hidden dependency, a stray import | -| 2 | No circular dependency | Modules that have become inseparable | -| 3 | No direct access to another module's data | Coupling through the database | -| 4 | Backward compatibility of contracts | An unintentional breakage | -| 5 | Consumers of a deprecated version = 0 before removal | A deliberate breakage, badly sequenced | -| 6 | Consistency of lifecycle statuses | A frozen contract changed, a deprecated module reused | -| 7 | Deprecation dates not passed | Permanent intermediate states | -| 8 | One PR = one module | Boundary erosion | -| 9 | Complete module envelope (manifest, owner, tests) | An orphan module | -| 10 | Performance and size budgets | A silent regression | - -The first six are cheap: they are computed from data already present (manifests, imports, -contract schemas). There is **no semantic analysis** — these are comparisons of graphs -and schemas. - -Beside them, the engine checks what a shared repository must not carry: a path rooted in one -person's home directory, in any tracked file (H1). It exists on no other machine and -publishes the layout of the one it was written on; an image's or a runner's home, a -placeholder or a variable is the same everywhere. - -### Writing a fitness function - -A good fitness function is fast (it runs on every pull request), deterministic (no random -false positives), and **explanatory when it fails**. One that says only "architecture -violation" will be worked around; one that says "module A imports `B/internal/x.ts`, but -A's manifest does not declare B; use contract `b-api@v2`" will be respected. - ---- - -## 4. What to automate - -In decreasing order of return: - -``` -Immediately, at almost no cost - format · lint · type checking · secret detection · commit conventions - -From the 2nd module - unit tests · build · fitness functions 1 to 3 · one PR = one module - -From the 1st inter-team contract - schema validation · contract tests · compatibility · consumers - -From going to production - security analysis · dependencies/CVE · smoke tests · post-deployment verification - -When the volume justifies it - integration tests · targeted E2E · performance budgets · merge queue -``` - -**The critical checks run in CI.** Local hooks give fast feedback but are **never** the -only barrier: they are bypassable, disableable, and absent on a newcomer's machine. - ---- - -## 5. Quality gates - -A quality gate must be: **objective · understandable · reproducible · automated where -possible · useful**. - -The last criterion is the most often forgotten, and it is the one that kills buy-in. - -| Situation | Response | -|---|---| -| A gate blocks often without ever improving quality | Re-evaluate it or remove it | -| An important rule never respected | Automate it, remove it, or explicitly reconsider | -| A gate systematically bypassed by label | The problem is the gate, not the people | -| A gate so slow that people skip it | Make it fast, or move it later in the pipeline | - -> Avoid bureaucratic gates with no value. Every gate has a permanent cost paid by every -> pull request; it must earn its keep. - -**Never a silent bypass.** No `skip`, no `--no-verify`, no test disabled "temporarily", -no threshold lowered to make things pass. A necessary bypass goes through a visible label -and leaves a counted trace. - ---- - -## 6. Proportionate governance - -The level of requirement depends on the **criticality declared in the manifest**, not on -a uniform rule. Never impose the ceremony of a critical system on a small module; never -treat a critical system like a prototype. - -```mermaid -flowchart TD - A["Module"] --> B{"Declared<br/>criticality"} - - B -->|"prototype / internal"| P["MINIMAL<br/>lint · types · unit tests<br/>manifest · owner"] - B -->|"standard"| S["STRUCTURED<br/>+ validated contracts · fitness functions<br/>+ structuring ADRs · review"] - B -->|"high"| E["REINFORCED<br/>+ integration · critical E2E<br/>+ observability · security · runbook"] - B -->|"critical / sensitive"| C["MAXIMAL<br/>+ review by the owner · UAT<br/>+ verified rollback · post-deployment<br/>+ compliance requirements"] - - style P fill:#1f2937,color:#fff - style C fill:#7c2d12,color:#fff -``` - -**Legend** — dark grey: the lightest level · red: the heaviest. - -Criticality is declared in the manifest, so CI knows which checks to apply to which -module. It is not decided pull request by pull request, which would trigger the -discussion at the worst possible moment. - -**It is revisable**, by ADR: a module going to production changes level. - ---- - -## 7. The repository as an organ of governance - -The repository is not storage space: it is where rules become non-bypassable. Mechanisms -to use (GitHub wording, transposable elsewhere): - -| Mechanism | What it guarantees | -|---|---| -| Pull requests required | No direct change on the protected branch | -| Required checks | A red CI blocks the merge, without exception | -| CODEOWNERS | The right owner is asked automatically | -| Rulesets / branch protection | The rules do not depend on goodwill | -| Issue forms | The DoR is structurally filled in | -| PR template | The DoD is visible at review time | -| Labels | Exceptions are visible and counted | -| Protected environments | Deployment goes through an approval | -| Dependency / security automation | CVEs do not depend on manual watching | -| Merge queue | Avoids merges that break each other | -| A dedicated identity for agents | An agent neither approves nor merges around a human approval | -| Rulesets with an empty bypass list | Nobody, administrators included, merges around a rule | -| Stale approvals dismissed on push | An approval covers the commits its approver read | -| A default code owner | The code owner review covers every path | -| A record of what landed | Nothing reaches the protected branch in silence — it records, it never refuses | - -> **Critical rules must not be bypassable by an instruction given to the AI.** That is -> the ultimate test of governance: if asking an agent nicely is enough to get around it, -> the rule does not exist. - -**And when the forge cannot enforce any of it.** Every mechanism above depends on what the -repository's plan allows; on some, none of them is available, and nothing refuses a merge at -all. The diagnosis says so in one word — *unguarded* — and what remains is the last row: a -run that fails when a commit reached the protected branch outside a pull request. That is a -record, not a barrier, and it is worth exactly what a record is worth: the thing nobody would -otherwise have been told. Reading it as a guarantee is the mistake it exists to prevent. - -### Agents and approval - -A pull request's author cannot approve it. An agent working with a human's credentials -*is* that human: it can approve a colleague's pull request in their name, then merge. Four -settings close that door, and they only hold together: - -1. **The agent has its own identity** — a GitHub App installed on the repository: tokens - that expire within the hour, never the Administration permission. Its session reaches - no human credential — no SSH key, token or command-line login of a human — through a - sandbox, a container or a dedicated system user. -2. **The merge requires a human code owner's approval**, and `CODEOWNERS` starts with a - default owner: an App can approve, but it is never a code owner. -3. **Nobody is on the rulesets' bypass list**, administrators included. -4. **An approval is dismissed when new commits are pushed**: otherwise a force-push after - the approval merges content its approver never read. - -The human who drove the agent may approve its pull request. A team that wants four eyes -adds "require approval of the most recent reviewable push", or a second reviewer. An -agent's approval does not count toward merging until the test sheets show, module by -module, that an independent verifier finds what a human would (`05-workflow.md` §7). - ---- - -## 8. The CI pipeline - -Conceptual order, from the fastest to the most expensive — useful feedback arrives early. - -```mermaid -flowchart TD - CH["Change"] --> F1["Format · Lint"] - F1 --> F2["Types"] - F2 --> F3["Unit tests"] - F3 --> F4["Build"] - F4 --> F5["Architecture<br/>fitness functions"] - F5 --> F6["Contracts:<br/>schema · compatibility"] - F6 --> F7["Security:<br/>secrets · dependencies · SAST"] - F7 --> F8["Integration tests"] - F8 --> F9["E2E · visual · accessibility<br/>per criticality"] - F9 --> AR["Artefact"] - AR --> DE["Deployment"] - DE --> SM["Smoke tests"] - SM --> OB["Verification through<br/>observability"] - - F1 -.->|"failure = immediate stop"| STOP["Feedback under 2 min"] - F5 -.->|"failure = architectural<br/>violation"| STOP2["A precise explanation<br/>+ the rule broken"] - - style F5 fill:#065f46,color:#fff - style F6 fill:#065f46,color:#fff - style STOP fill:#1f2937,color:#fff - style STOP2 fill:#1f2937,color:#fff -``` - -**Legend** — green: the architecture gates · dark grey: what a failure must give back. - -**Do not apply every step mechanically to every module.** The level of validation is -proportionate to the risk (§6). - -**Feedback time is a quality property.** A thirty-minute CI is a CI people work around, -launch at the end of the day, and whose results they ignore. Feedback time is a tracked -indicator (`10-measurement.md`). - ---- - -## 9. The automation backlog - -Every rule that *should* be automated but is not yet is identified debt, not a fact of -life. It sits in a dedicated backlog, with: - -- the rule and where it lives temporarily (a playbook, a local AGENTS.md); -- the risk if it is violated; -- the estimated cost of automating it; -- the trigger that will make it a priority. - -That backlog is reviewed on the same rhythm as the decision review (`06-decisions.md` -§6). It is the mechanism that stops the kernel growing: every rule added to the prompt -arrives with its planned exit date. diff --git a/docs/os/README.md b/docs/os/README.md deleted file mode 100644 index 3d1acb4..0000000 --- a/docs/os/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# AI Engineering OS - -A system of rules, boundaries, contracts, documentation and deterministic guardrails that -lets **several teams and their AI agents develop in parallel** without generation speed -blowing up complexity. - ---- - -## The problem this OS solves - -Agents make writing code nearly free. Three costs do not come down: - -1. **Understanding** — somebody still has to know what the system does. -2. **Verification** — somebody still has to review and validate. -3. **Coordination** — several teams have to move without blocking each other. - -A generation accelerator plugged into a system without boundaries does not produce a -faster project: it produces an unreadable project faster. - -This OS therefore treats **cognitive load**, **review capacity** and **inter-team -coupling** as the project's three scarce resources, and organises everything else around -preserving them. - ---- - -## The five structuring ideas - -| # | Idea | Practical consequence | -|---|------|----------------------| -| 1 | **The prompt is a transit zone, not a residence** | Every automatable rule moves down into CI and leaves the prompt | -| 2 | **The module is the unit of parallelism** | One PR = one module; two modules know each other only through a contract | -| 3 | **The oracle before the generation** | The criterion is made executable before the first line is written | -| 4 | **Convention is the default choice** | It needs no justification; every deviation does | -| 5 | **No stack is imposed** | The OS imposes a selection method, not a list of technologies | - ---- - -## Navigation map - -### What to read, depending on who you are - -| You are… | Read, in order | -|-----------|---------------------| -| **An AI agent** | `AGENTS.md` (kernel) + the module's local `AGENTS.md` + the triggered playbooks | -| **A new developer** | `00-overview.md` → `02-modules.md` → `05-workflow.md` | -| **A tech lead / architect** | `00-overview.md` → `02` → `03` → `07` | -| **A product owner** | `00-overview.md` → `06-decisions.md` | -| **Whoever creates the project** | The project's `README.md`, then `09-platform.md` | - -### Project contents - -``` -. -├── README.md How to use the project -├── AGENTS.md ← THE KERNEL: resident, loaded for every task -├── CONTRIBUTING.md, SECURITY.md -│ -├── docs/ -│ ├── os/ ← this handbook -│ │ ├── README.md you are here -│ │ ├── 00-overview.md OS architecture, the 4 layers, glossary -│ │ ├── 01-principles.md Non-negotiable principles and anti-patterns -│ │ ├── 02-modules.md Boundaries, manifest, lifecycle, one PR = one module -│ │ ├── 03-contracts.md Versioning, expand/contract, contract tests -│ │ ├── 04-ai-context.md Context firewall, context budget, crossing over -│ │ ├── 05-workflow.md Verification-first loop, DoR/DoD, review budget -│ │ ├── 06-decisions.md ADR/PDR, Prior Art Gate, dated success criteria -│ │ ├── 07-governance.md Where a rule lives, fitness functions, CI, quality gates -│ │ ├── 08-quality.md Tests, security, reliability, data, UX, QA, UAT -│ │ ├── 09-platform.md Standard verbs, layout, tooling, onboarding -│ │ └── 10-measurement.md Metrics, feedback loop, decision review -│ ├── tooling-profile.md Capabilities → the tools of the moment -│ ├── adr/, pdr/ Decisions, and their _TEMPLATE.md models -│ └── architecture/, runbooks/ -│ -├── playbooks/ ← instruction modules loaded on demand -├── modules/ The code: one unit of parallelism per folder -├── contracts/ The only channel between modules -└── .github/ CI, CODEOWNERS, issue and pull request templates -``` - ---- - -## How to read these documents - -The documents in `docs/` are **the reference**: they explain, justify and detail. They -are **not** meant to be loaded into an agent's context. - -What an agent loads is: - -- `AGENTS.md` (the kernel, always); -- the `AGENTS.md` of the module concerned (always); -- one or more `playbooks/` (only when triggered). - -If you need to put a rule in the kernel, re-read `07-governance.md` § "Where does this -rule live?" first. The answer is very often "in CI", not "in the prompt". - ---- - -## Status - -This OS is subject to its own rules: it evolves in small steps, its structuring changes -get an ADR, and every rule it contains is a candidate for automation. See -`10-measurement.md` § "Improving the OS". diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index 03df5ee..dd9f40a 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -311,7 +311,7 @@ The module's `README.md` had already restated the criterion this way, as `*(nothing on stdout)*` | **3**. The verifier's finding was not about the behaviour, which it had confirmed on twelve separate shapes of unreadable input: it was that **an expected result had been changed in a README, by the author, without the decider agreeing to it visibly** -(`playbooks/verification.md`). The reading was right and the route was wrong, so the decision +(`.nstack/playbooks/verification.md`). The reading was right and the route was wrong, so the decision is recorded where decisions live, and the README now follows the PDR rather than amending it. ### What it does not change diff --git a/docs/pdr/README.md b/docs/pdr/README.md index bbbc6e7..5afa3b4 100644 --- a/docs/pdr/README.md +++ b/docs/pdr/README.md @@ -5,7 +5,7 @@ structuring business rule, a UX or business decision. The PDR describes **what the product must do and why**, never its implementation. -- Template: [`_TEMPLATE.md`](./_TEMPLATE.md) +- Template: [`.nstack/forms/pdr.md`](../../.nstack/forms/pdr.md) - Naming: `NNNN-user-oriented-title.md` ## Mandatory sections @@ -18,7 +18,7 @@ The PDR describes **what the product must do and why**, never its implementation > The **FDR** format does not exist in this OS. For genuinely complex features, the > *Detailed functional design* section of the PDR is enough -> (`docs/os/06-decisions.md` §4). +> (`.nstack/handbook/06-decisions.md` §4). ## Index diff --git a/docs/project/README.md b/docs/project/README.md deleted file mode 100644 index 86290f5..0000000 --- a/docs/project/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Project - -What the framework cannot know about this project: who it is for, when it is finished, -and what is being delivered now. Every agent session reads the charter and the current -cycle before working (`AGENTS.md` §4). - -| File | Holds | Written by | Accepted by | -|---|---|---|---| -| `discovery.md` | An idea tested: evidence, value hypothesis, challenge, decision | The framer, then the challenger (`playbooks/discovery.md`) | The decider | -| `charter.md` | Users, problem, constraints, risks, success criteria, out of scope | The framer (`playbooks/framing.md`) | The decider | -| `cycles/NN-<slug>.md` | One goal, a finite list of deliverables, an appetite, an end date, the closure | The framer | The decider | -| `handover.md` | **Start here after a break**: where the work stands, what is in flight, and how to work in this repository | The framer, at each interruption | — | -| `_DISCOVERY_TEMPLATE.md`, `_CHARTER_TEMPLATE.md`, `cycles/_TEMPLATE.md` | The templates | — | — | - -```mermaid -flowchart LR - P["proposed"]:::draft -->|"the decider accepts"| A["accepted<br/>running from start"]:::run - A -->|"every deliverable accepted"| C["closed<br/>completed"]:::ok - A -->|"end date reached"| B{"Circuit breaker<br/>the decider chooses"}:::stop - B -->|"ship what is accepted"| S["closed<br/>shipped"]:::ok - B -->|"new cycle"| R["stopped<br/>reframed"]:::stop - B -->|"stop the project"| X["stopped<br/>stopped"]:::stop - - classDef draft fill:#374151,color:#fff - classDef run fill:#1e3a8a,color:#fff - classDef ok fill:#065f46,color:#fff - classDef stop fill:#7c2d12,color:#fff -``` - -**Legend** — grey: a proposal · blue: the cycle in progress · green: an accepted end · -red: the circuit breaker and what it can lead to. - -## What CI checks - -| Check | When | Rules | -|---|---|---| -| The plan, a fitness function | Every push | Formats; one accepted cycle at a time, under an accepted charter; `end` = `start` + the appetite; acceptance criteria once a deliverable is ready; closures recorded; a discovery decided with its decider and date, a charter only after a go. A charter, a cycle or a deliverable still holding the template's words is refused | -| The pull request check | Every pull request changing a module beyond its description — manifest, `AGENTS.md`, `README.md`, `docs/`; not a framework update | An accepted cycle; not past its end date; a ready or in-progress deliverable named — or the `out-of-cycle` label with its justification | - -The charter changes only through a PDR (`docs/os/06-decisions.md` §4). A cycle is never -extended: past its end date, delivery work stops until the decider records a decision. diff --git a/docs/project/charter.md b/docs/project/charter.md index 5516173..73a674c 100644 --- a/docs/project/charter.md +++ b/docs/project/charter.md @@ -8,7 +8,7 @@ success_criteria: # Charter — flet -> Written once, at the first framing (`playbooks/framing.md`). Changed only through a PDR. +> Written once, at the first framing (`.nstack/playbooks/framing.md`). Changed only through a PDR. > Every agent session reads it. > > It reuses `docs/project/discovery.md`, decided **go** on 2026-09-21 after three rounds and diff --git a/docs/project/cycles/_TEMPLATE.md b/docs/project/cycles/_TEMPLATE.md deleted file mode 100644 index 802a49f..0000000 --- a/docs/project/cycles/_TEMPLATE.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -goal: "<One sentence: the outcome of this cycle>" -status: proposed # proposed | accepted | closed | stopped — the decider accepts -appetite_weeks: 2 # the time the decider WANTS to spend, not an estimate -start: 2026-01-05 # YYYY-MM-DD -end: 2026-01-19 # start + appetite: the first day the cycle is over — the circuit breaker -deliverables: - - id: D1 - title: "<An outcome a user can observe; for a spike, the question it answers>" - module: "<module name>" # null for a spike run outside the code - state: proposed # proposed | ready (testable criteria) | in-progress | accepted | deferred | dropped - acceptance: # given · when · then, required from ready on: the test sheet starts here - - "Given <context>, when <action>, then <observable result>" -# outcome: completed # closed: completed | shipped — stopped: reframed | stopped -# ended_on: YYYY-MM-DD ---- - -# Cycle NN — <title> - -> Copied to `NN-<slug>.md` at framing (`playbooks/framing.md`). One accepted cycle at a -> time; no automatic extension. - -## Goal - -<Why this outcome, now.> - -## Deliverables - -<Notes the front matter cannot hold: order, dependencies.> - -## Out of scope - -<Not done in this cycle, even if time remains.> - -## Later - -<Candidates for the next framing: what framing left out, and ideas that came up during the -cycle.> - -## Open questions - -**Blocking:** <none left once the cycle is accepted> - -**Not blocking:** - -## Closure - -<Written at the end: what was delivered, which success criteria moved, what was deferred, -where the next framing starts.> diff --git a/docs/project/discovery.md b/docs/project/discovery.md index d1f5b8a..e2226d8 100644 --- a/docs/project/discovery.md +++ b/docs/project/discovery.md @@ -9,7 +9,7 @@ round: 3 # Discovery -> Started by the engine's `discover` command, run by your agent (`playbooks/discovery.md`). +> Started by the engine's `discover` command, run by your agent (`.nstack/playbooks/discovery.md`). > One document, a decision at the end of each round. ## 1. Intake @@ -45,7 +45,7 @@ the platform takes its commission. A later one may let members vote on the list. ## 2. Research -> `docs/tooling-profile.md` has no tool in the "Reliable documentary research" row, so this +> `.nstack/tooling-profile.md` has no tool in the "Reliable documentary research" row, so this > round used the tools at hand: the agent's web search and page fetch. Marked below: > *primary* — read on the source's own site; *reported* — a figure a company states about > itself; *excerpt* — seen only in a search result, the primary source not read. @@ -419,7 +419,7 @@ to 4 · 2026-09-20 > Nothing in this section has been edited since it was written. > Section 1 is confirmed (line 17), so this challenge is against the document as written. -> `docs/tooling-profile.md` declares no research tool, so — as in stage 2 — this round used +> `.nstack/tooling-profile.md` declares no research tool, so — as in stage 2 — this round used > the tools at hand: the agent's web search and page fetch, named at each finding. Same > marking: *primary* — read on the source's own site; *reported* — a figure a company > states about itself; *excerpt* — seen only in a search result; *assumption* — unsourced. @@ -672,7 +672,7 @@ session did not write any of the round-2 material and had no access to the sessi > Inserting this subsection shifts every line of the round-2 entries that follow it; resolve a > citation against that commit, not against the current file. Nothing above is edited. > -> **Tools.** `docs/tooling-profile.md` still declares no research tool, so this round used the +> **Tools.** `.nstack/tooling-profile.md` still declares no research tool, so this round used the > tools at hand, named at each finding: the agent's web search and page fetch, and — for the > numbers — direct HTTP reads of `stats-data.hyperliquid.xyz`, `api.hyperliquid.xyz` and > `api.llama.fi` from this sandbox, all read-only, no keys, no orders, no money. diff --git a/docs/runbooks/.gitkeep b/docs/runbooks/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/modules/.gitkeep b/modules/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/modules/README.md b/modules/README.md index 3cf16f5..096c7c1 100644 --- a/modules/README.md +++ b/modules/README.md @@ -23,7 +23,7 @@ boundary, the rejected alternatives). ## Before splitting A module represents a **coherent capability**, not a table or a handful of endpoints. See -the decision tree in `docs/os/02-modules.md` §3. +the decision tree in `.nstack/handbook/02-modules.md` §3. Do not split if: the capability is not coherent, the module cannot be tested on its own, no owner is identifiable, or its rate of change is the same as the rest with no other diff --git a/modules/copying/MANIFEST.yaml b/modules/copying/MANIFEST.yaml index f916e89..db449db 100644 --- a/modules/copying/MANIFEST.yaml +++ b/modules/copying/MANIFEST.yaml @@ -13,14 +13,14 @@ module: owner: "NapkinStack/maintainers" # a GitHub team, organisation/team; a user only without an organisation contact: "@NapkinStack/maintainers" - # proposed | active | maintenance | deprecated | retired (docs/os/02-modules.md §6) + # proposed | active | maintenance | deprecated | retired (.nstack/handbook/02-modules.md §6) lifecycle: proposed - # prototype | standard | high | critical (docs/os/07-governance.md §6) + # prototype | standard | high | critical (.nstack/handbook/07-governance.md §6) criticality: "critical" # Does a user see this module? true requires a test sheet on its pull requests - # (docs/os/05-workflow.md §7). + # (.nstack/handbook/05-workflow.md §7). user_facing: true # The module's name in the code, when it differs from the folder (package, namespace). @@ -54,7 +54,7 @@ data: shared: [] # any exception requires a named ADR # Significant external dependencies. -# Each one declares its exit strategy (docs/os/06-decisions.md §3). +# Each one declares its exit strategy (.nstack/handbook/06-decisions.md §3). dependencies: - name: hyperliquid-python-sdk purpose: signs trading actions as the member's agent; the venue's official SDK @@ -70,7 +70,7 @@ dependencies: # exit_strategy: # Standard verbs: the same names everywhere, running this module's stack commands -# (docs/os/09-platform.md §2). `nstack <verb> <module>` runs them from this folder. +# (.nstack/handbook/09-platform.md §2). `nstack <verb> <module>` runs them from this folder. # No stack is imposed. check and test are required once the module holds more than its # description (fitness M7): declare them before its first file of code. commands: diff --git a/modules/copying/docs/runbook.md b/modules/copying/docs/runbook.md index 2d7a70e..91d267d 100644 --- a/modules/copying/docs/runbook.md +++ b/modules/copying/docs/runbook.md @@ -1,6 +1,6 @@ # Runbook - copying -> Required for criticality=critical (docs/os/08-quality.md §7). +> Required for criticality=critical (.nstack/handbook/08-quality.md §7). > An empty runbook fails CI. Fill it in before going to production. ## Alerts and responses diff --git a/modules/screening/MANIFEST.yaml b/modules/screening/MANIFEST.yaml index cec9a9f..457ec81 100644 --- a/modules/screening/MANIFEST.yaml +++ b/modules/screening/MANIFEST.yaml @@ -13,14 +13,14 @@ module: owner: "NapkinStack/maintainers" # a GitHub team, organisation/team; a user only without an organisation contact: "@NapkinStack/maintainers" - # proposed | active | maintenance | deprecated | retired (docs/os/02-modules.md §6) + # proposed | active | maintenance | deprecated | retired (.nstack/handbook/02-modules.md §6) lifecycle: proposed - # prototype | standard | high | critical (docs/os/07-governance.md §6) + # prototype | standard | high | critical (.nstack/handbook/07-governance.md §6) criticality: "high" # Does a user see this module? true requires a test sheet on its pull requests - # (docs/os/05-workflow.md §7). + # (.nstack/handbook/05-workflow.md §7). user_facing: true # The module's name in the code, when it differs from the folder (package, namespace). @@ -54,7 +54,7 @@ data: shared: [] # any exception requires a named ADR # Significant external dependencies. -# Each one declares its exit strategy (docs/os/06-decisions.md §3). +# Each one declares its exit strategy (.nstack/handbook/06-decisions.md §3). dependencies: [] # - name: # purpose: @@ -62,7 +62,7 @@ dependencies: [] # exit_strategy: # Standard verbs: the same names everywhere, running this module's stack commands -# (docs/os/09-platform.md §2). `nstack <verb> <module>` runs them from this folder. +# (.nstack/handbook/09-platform.md §2). `nstack <verb> <module>` runs them from this folder. # No stack is imposed. check and test are required once the module holds more than its # description (fitness M7): declare them before its first file of code. commands: diff --git a/modules/screening/docs/adr/0002-python-and-a-client-that-cannot-sign.md b/modules/screening/docs/adr/0002-python-and-a-client-that-cannot-sign.md index 67b5237..6450b23 100644 --- a/modules/screening/docs/adr/0002-python-and-a-client-that-cannot-sign.md +++ b/modules/screening/docs/adr/0002-python-and-a-client-that-cannot-sign.md @@ -27,7 +27,7 @@ What does this module run on, and what does it use to reach the venue? ## Constraints -- The project's toolchain is already **uv**, declared in `docs/tooling-profile.md` as the +- The project's toolchain is already **uv**, declared in `.nstack/tooling-profile.md` as the foundation's way of running commands and tests. A second package manager would be a second thing to install on the Hetzner box and in CI. - `nstack` itself requires Python ≥ 3.12, so a Python runtime is present wherever this project diff --git a/modules/screening/docs/runbook.md b/modules/screening/docs/runbook.md index bf030f6..3ca5f35 100644 --- a/modules/screening/docs/runbook.md +++ b/modules/screening/docs/runbook.md @@ -1,6 +1,6 @@ # Runbook - screening -> Required for criticality=high (docs/os/08-quality.md §7). +> Required for criticality=high (.nstack/handbook/08-quality.md §7). > An empty runbook fails CI. Fill it in before going to production. ## Alerts and responses diff --git a/playbooks/framing.md b/playbooks/framing.md deleted file mode 100644 index bab277f..0000000 --- a/playbooks/framing.md +++ /dev/null @@ -1,110 +0,0 @@ -# Playbook — Framing - -> **Trigger.** Load this playbook when you are asked to frame a project, to plan its next -> cycle, to re-frame the current one, or to write a cycle's closure. - ---- - -## Your posture - -You are the **framer**. You propose; the decider decides. For the framer, this playbook -replaces the kernel's working loop (§2); its closing summary (§8) still applies. - -| You do | You never do | -|---|---| -| Interview the decider, one subject at a time | Decide in their place, or fill a gap with an invention | -| Propose the field's convention by default, marked *(framer, to confirm)* with its source | Propose more than the need | -| List the open questions, blocking apart | Let a charter or a cycle be accepted with a blocking question open | -| Keep the first cycle small | Split into many modules on day one (`docs/os/02-modules.md` §3) | - -A proposal without a source is an open question, not a proposal. The documents you write -carry the project, not the conversation: every later session reads them, and reads nothing -else of what was said. - ---- - -## 1. Frame the project: the charter - -Start from what the decider gives you. When `docs/project/discovery.md` exists, its decision -must be **go**: the charter reuses its users, problem, constraints, success signals, no-gos -and risks, carries its unanswered questions into its own, and you ask only what it leaves -open. Otherwise — an idea alone — propose a discovery first (`discovery.md`); a specification -already challenged can be framed directly. Read the source entirely, then interview, one -subject at a time, asking only what you cannot infer: - -| Subject | Ask | The charter records | -|---|---|---| -| Users | Who uses it, in what situation, with what problem? | The users and their problem | -| Outcome | What must be true for the project to be finished? | Success criteria, measurable, dated — or relative to a named event, such as launch day, that a later framing dates | -| Constraints | Law, money, security, data, platforms, deadlines | The constraints | -| Risks | What could make it fail, or cause harm? | The risks, and the criticality they imply (`docs/os/07-governance.md` §6) | -| Vocabulary | The domain's words, and what each one means | The vocabulary | -| Not this project | What it will deliberately not do | Out of scope | - -A domain that moves money, handles personal data or acts on someone's behalf raises the -criticality of the modules concerned, and `security.md` applies from the first cycle — to -the code, and to the data a spike collects: who sees it, how long it is kept. Say so to the -decider. - -Write `docs/project/charter.md` from `docs/project/_CHARTER_TEMPLATE.md`, with -`status: proposed` and the open questions at the end, then run the fitness functions. -"Finished" means the charter's goal is reached: framing stops; running what was built may go -on. - -## 2. Plan a cycle - -1. **Goal** — one sentence, the one outcome of this cycle. -2. **Deliverables** — a finite list, `D1`, `D2`…, each an outcome a user can observe — for a - spike, the question it answers for the decider. Each gets acceptance criteria, written - *given · when · then*; they become its test sheet (`verification.md`). -3. **Unknowns** — a blocking unknown becomes a *spike* deliverable, whose output is - knowledge (`docs/os/05-workflow.md` §3). After a discovery's go, the tests the decider kept - are the first cycle's spikes. A spike's criteria name what is recorded and the threshold it - is read against; a refuted result is still a delivered one. -4. **Modules** — name each deliverable's module; a spike run outside the code — a sign-up - form, interviews — has none (`module: null`). Propose a new module only against the tree of - `docs/os/02-modules.md` §3: one module is often enough to start. -5. **Appetite** — ask the decider how many weeks they **want** to spend, not how long it - will take. When the deliverables do not fit, cut the scope; never stretch the appetite. -6. **Out of scope and later** — out of scope is not done even if time remains; *later* holds - the candidates for the next framing. - -Write `docs/project/cycles/NN-<slug>.md` from `docs/project/cycles/_TEMPLATE.md`, with -`status: proposed` and `end` = `start` + the appetite, then run the fitness functions. - -## 3. Hand over to the decider - -Present the charter, the cycle, the open questions, what went to *later*, and what you are -unsure of. The decider amends, then sets `status: accepted` — on the charter, then on the -cycle — in a pull request they approve; accepted after `start`, the cycle's `start` and `end` -move in the same pull request. The modules accepted there are created with the engine's -module scaffolding, declared user-facing when a user sees them. - -## 4. During the cycle - -- **A new idea** goes to *later*. It enters the cycle only if the decider re-frames: - swapping a deliverable out, or closing the cycle early. -- **An urgent fix** outside the cycle — an incident, a production defect — goes in a pull - request with the `out-of-cycle` label and the line `Out of cycle: <reason>`. -- **A deliverable** moves `proposed` → `ready` (testable acceptance criteria, set by the - framer, confirmed when the decider accepts the cycle) → `in-progress` → `accepted`: its - test sheet run and its pull request approved — or, for a spike outside the code, its result - recorded in the cycle and approved by the decider. - -## 5. The end of a cycle - -**Every deliverable accepted** — write the closure: what was delivered, which success -criteria moved, what was deferred; set `status: closed`, `outcome: completed`, `ended_on`. -When a spike refutes what the charter rests on, present stopping the project too. - -**The end date reached first** — the circuit breaker: nothing is extended. Present the -three choices, with the state of every deliverable: - -| The decider chooses | `status` | `outcome` | -|---|---|---| -| Ship what is accepted | `closed` | `shipped` | -| Frame a new cycle, with a new appetite | `stopped` | `reframed` | -| Stop the project | `stopped` | `stopped` | - -The closure is where the next framing starts. When the charter's success criteria are met, -the project is finished: say so to the decider. diff --git a/playbooks/verification.md b/playbooks/verification.md deleted file mode 100644 index 581c0ba..0000000 --- a/playbooks/verification.md +++ /dev/null @@ -1,70 +0,0 @@ -# Playbook — Verification - -> **Trigger.** Load this playbook when you are asked to verify a change you did not write, -> or to fill in the results of a test sheet. - ---- - -## Your posture - -You are the **verifier**. You did not write this change, and you do not fix it. For the -verifier, this playbook replaces the kernel's working loop (§2); its closing summary (§8) -still applies. - -| You do | You never do | -|---|---| -| Start from the need, the acceptance criteria and the test sheet | Read the diff before running the sheet | -| Run every scenario against the running change | Fix the code, even one line | -| Bring back evidence for every result | Write "passed" without evidence | -| Report the gaps against the need or against correctness | Report a preference as a gap | - -The session that wrote the change cannot verify it: start another session, with a fresh -context, or hand the sheet to a human. Sign the sheet with your session's identifier — -`Verifier: session <id>` — or, as a person, `Verifier: @<handle>`. CI compares it with the -change's authors and refuses a match. - ---- - -## The procedure - -1. **Read the need** — the deliverable, its acceptance criteria, the test sheet in the - pull request's description. Nothing else yet. -2. **Start the change** — the module's `run` verb, or the environment named in - `docs/tooling-profile.md`. -3. **Run each scenario**, in order: - - *automated* — the module's `e2e` verb; the evidence is the CI run on the head commit, - or its artefact; - - *explored* — drive the interface yourself, in a browser, an emulator or on a device, - with the tools of the tooling profile; capture the screen at the step that proves the - result; - - *human only* — do not run it; check that its reason is stated. -4. **Record** each result in the sheet — `passed`, `failed — <what you observed>`, or - `not verified` — with its evidence and the short hash of the commit you tested. -5. **Only then read the diff**, to explain a failure — never to decide a result. -6. **Report** the failures first — observed, expected, evidence — then any optional - remark, marked as such. - ---- - -## Evidence - -| Scenario | Evidence expected | -|---|---| -| An interface | A screenshot of the state that proves the result; a video for a sequence | -| A mobile interface | The screenshot of the emulator or the device, with its width or model | -| An API, a job, data | The command and its output, or the log lines | -| Accessibility | The keyboard path followed, and the automated report when there is one | - -Test data only: never a real user's data, never a secret on a screenshot (`security.md`). -Evidence lives where the whole team sees it — a CI artefact, or an image attached to the -pull request. - -A user-facing change covers the eight states of an interface (`ux.md`), or says which are -out of scope. A state missing from the sheet is a gap to report. - ---- - -## When the sheet itself is wrong - -A scenario that does not match the need, or a need no scenario covers: report it. An -expected result changes only with the decider's agreement, visibly in the sheet's history.