From fec4be0c8d64bd2afdce3c35141488879eeae604 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 21 Oct 2026 20:03:01 -0500 Subject: [PATCH 1/7] docs(repo): add workflow vocabulary and full record formats --- planning/workflow/records.md | 352 +++++++++++++++++++++++++++----- planning/workflow/vocabulary.md | 109 ++++++++++ 2 files changed, 409 insertions(+), 52 deletions(-) create mode 100644 planning/workflow/vocabulary.md diff --git a/planning/workflow/records.md b/planning/workflow/records.md index f22688d605..27f0aedc3c 100644 --- a/planning/workflow/records.md +++ b/planning/workflow/records.md @@ -1,76 +1,324 @@ -# Workflow Records & Document Structure +# Workflow records -This document specifies the internal file layout, marker syntax, state blocks, and formatting rules for research collections. +The files a research package holds, who writes each one, and their exact formats. Values come from [vocabulary.md](vocabulary.md). Who may write what, and how, is ruled by [collaboration.md](collaboration.md). This page describes the target format. Where the tool on `main` writes something else, the difference is listed under [Tool status](#tool-status). -## 1. Research Collection Layout (`doc/_research_/`) +## Package layout -Each research collection is housed in a dedicated directory under the configured `requests_root`: +A package is a folder `doc/_research_/` under the profile's `requests_root`. The tool treats a folder as a package only if its name matches `^\d{4}-\d\d-\d\dT\d\d-\d\d-\d\dZ_research_[a-z0-9]+(-[a-z0-9]+)*$` and it contains `package.json`. ```text doc/_research_/ -├── transcript.txt # Exact immutable source bytes (protected from formatters) -├── package.json # Collection manifest (transcript metadata, segment list) -├── main.md # Main reference document (overview, concept sections, issue index) -├── design.md # Meta design (review order, waves, run status table, S5 stages) -├── changes.md # Append-only change log (merge=union) -├── concepts/ -│ ├── C001-.md # Owned concept document (contains concept state block) -│ └── C002-.md -├── notes/ # Directed cross-agent notes (created lazily) -│ └── C001__to__C002__.md -├── receipts/ # Note resolution receipts (created atomically by receivers) -│ └── C001__to__C002__.md -└── decisions/ # Structured decision records (created at S6) - └── D001-.md + transcript.txt exact request bytes; never edited + package.json manifest; written once at intake + main.md main reference + design.md meta design + changes.md add-only change log + human-review.md generated at S6 from decisions/ + concepts/C001-.md one per concept + notes/C001__to__C002__.md + receipts/.md + receipts/C002__scan__.md + decisions/D001-.md ``` -## 2. Formatting Stability & Parser Immunity +| Path | Writer | Changes how | +| ---------------------- | ----------------------------------------------------------- | ---------------------------------------------------- | +| `transcript.txt` | intake, once | never | +| `package.json` | intake, once | never | +| `main.md`, `design.md` | anyone, through a PR | authored parts by PR; views by `render` | +| `changes.md` | anyone | one appended line, `merge=union` | +| `human-review.md` | `render` | regenerated, never edited | +| `concepts/C001-*.md` | the concept's current stage owner | edited by its owner only | +| `notes/*.md` | the sender, once | never; a reply is a new note | +| `receipts/*.md` | the receiver, or the reconciler on its behalf, once | never | +| `decisions/D001-*.md` | the S6 orchestrator files it; the holder of its lease edits | status changes only, under the `decision-D001` lease | -To prevent code formatters (`treefmt`, `prettier`, `biome`) from corrupting machine-readable metadata: +`notes/`, `receipts/` and `decisions/` are created when the first file needs them. A single concept gets the same layout with one concept file. There is no special case. -- **State Blocks**: Stored within fenced code blocks or delimited comments: +Files outside the package that the workflow changes (`AGENTS.md`, `doc/README.md`, `planning/plans/README.md`, roadmaps) are wide files: they change only through a PR. - ```markdown - +## Transcript - { - "version": 1, - "id": "2026-10-19T06-09-02Z_research_intake", - "stage": "intake", - "status": "prepared" +`transcript.txt` holds the request exactly as received: no prefix added by a harness, no trimming, no newline added at the end. `.gitattributes` marks it `-text`, `.editorconfig` turns off whitespace and newline fixes for it, `just strip-whitespace` skips it, and the CI path filter watches it. + +`package.json` records the transcript as: + +```json +{ + "bytes": 16566, + "encoding": "utf-8", + "expected_sha256": "e250cfa2…", + "path": "transcript.txt", + "sha256": "e250cfa2…", + "source": "free text: where the bytes came from", + "visibility": "public" +} +``` + +- `sha256` is computed over the stored bytes. `expected_sha256` is optional; when given, intake refuses a mismatch. `verify-transcript --against ` compares the stored bytes with another copy. +- `encoding` defaults to `utf-8`. Input that does not decode is refused unless `--encoding` names the encoding, which is then recorded. +- `visibility` is `public` or `private`. This repo is public. Private material is not committed here: store it where it may live (for example the private notebook) and keep only its hash and a pointer, with `visibility: private`. +- `init` refuses a second package with the same `sha256` unless `--allow-duplicate` is given. + +## Segments and coverage + +Segmentation is deterministic and by sentence. Split after `.`, `?` or `!` when whitespace follows, and at every newline. A segment starts at its first non-whitespace code point and ends after its last one. Whitespace between segments belongs to none, and whitespace-only pieces get no ID. IDs are `T001`, `T002`, ... in order. + +`package.json` lists them as `"segments": [{"end": 120, "id": "T001", "start": 0}, ...]`, with `start` and `end` as code-point offsets into the decoded text (end exclusive). `init --preview-segments` prints them so the intake agent can write the outline. + +Coverage: every segment is assigned to at least one concept (the concept's `segments`) or to the global bucket `G` (`package.json` `global_segments`). Overlap between concepts is allowed. The intake outline lists, per concept, `title`, `slug`, `type`, `segments`, `summary`, `thoughts`, `suggestions` (each labelled inference), `priority`, `horizon`, `goal`, `enables` and `relations`. A `hint` concept may cite no segment, but its summary must say what it was inferred from. + +Titles and slugs reject control characters and newlines. + +## Concept file + +`concepts/C001-.md` starts with the title, then the state block directly after it: + +````markdown +# C001: Exact transcript storage + +```workflow-state +{ + "disposition": "proposed", + "enables": ["C004"], + "goal": "No request is ever lost or altered", + "history": [ + { + "at": "2026-10-19T06:09:02Z", + "disposition": "proposed", + "note": "Created at intake.", + "ref": "", + "stage": "S0", + "status": "created" + } + ], + "horizon": "now", + "id": "C001", + "issues": [], + "kind": "new", + "priority": "crucial", + "prs": [], + "relations": [], + "segments": ["T001-T004", "T010"], + "slug": "exact-transcript-storage", + "stage": "S1", + "status": "created", + "targets": ["scripts/research_workflow.py"], + "title": "Exact transcript storage", + "type": "topic" +} +``` +```` + +- The block is JSON with 2-space indentation, sorted keys and a final newline. Its fence info string is `workflow-state`, which prettier leaves alone. Never wrap state in an HTML comment. +- `issues` and `prs` entries are `{"number", "stage", "state", "url"}`. `state` is the last recorded GitHub state (`open`, `closed`, `merged`); `status --live` reads the real one. +- `relations` entries are `{"kind", "reason", "to"}`, plus `rework_if_early` for `recommended-after`, `trigger` for `optional-if`, and an optional `stage` for `requires` ([DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds)). `to` is a concept or item ID in this package, or a repo path or issue URL outside it. +- `history` is append-only. Each entry records the state after a change: `at`, `stage`, `status`, `disposition`, `note` (why), `ref` (commit, PR, issue or path), and `trigger` when the disposition becomes `deferred`. An entry that sets `deferred` or `rejected` must have a non-empty `note`. +- Only the concept's current owner writes the file. The owner may keep supporting material in a sibling folder `concepts/C001-/`, under the same rule. + +The rest of the file is authored Markdown. The sections each stage must fill are listed in [stages.md](stages.md); the [concept template](templates/concept.md) lays them out. + +## Excerpts + +An excerpt quotes transcript segments exactly. It is a link line, a blank line, then a fenced block whose info string is `workflow-excerpt` and the segment range: + +````markdown +[T007-T009](../transcript.txt#L12-L14) + +```workflow-excerpt T007-T009 +The exact text from the start of T007 to the end of T009. +``` +```` + +- The block holds the decoded text from the start of the first segment to the end of the last, with one normalisation: spaces and tabs at the end of each line are removed and `\r\n` becomes `\n`. The repo's whitespace stripper would remove them anyway; the transcript itself keeps them. +- The fence is exactly one backtick longer than the longest backtick run inside the text, and at least three. Prettier rewrites any other length. +- Line anchors count `\n` only, as GitHub and editors do. +- `check` recomputes each excerpt from `package.json` and the transcript, and fails if it differs. + +## Generated views + +`main.md`, `design.md` and `human-review.md` contain generated sections. Each sits between two markers, with a blank line inside each: + +```markdown + + +- **C001** S2 · `running` · [#412](https://github.com/developing-today/code/pull/412) + + +``` + +- `render` rewrites everything between the markers. Never edit a view by hand. If two PRs conflict inside a view, take either side and run `render` again. +- Generated Markdown uses only headings, `-` bullets, `**bold**`, backticks, links and blank lines. No tables, no `*emphasis*`. Output must pass `prettier --check` unchanged. + +View names: + +- `main.md`: `files` (every package file and every repo file the concepts create or edit), `global` (segments in `G`), `concept-C001` (one per concept: stage, status, disposition, run status, priority, horizon, goal, enables, relations, issues and PRs with their state), `issues-and-prs` (every issue and PR in the package, each naming the concept or item it belongs to). +- `design.md`: `review-order` (first-pass order to review the concepts), `waves` (output of `ready`), `run-table` (run status per concept and stage), `research-stages` (from S5 on: every issue per concept, with a short description, priority order and wave). +- `human-review.md`: `human-review` (see [decisions.md](decisions.md#human-review)). + +## Main reference + +`main.md` holds, in order: the title and an introduction; the `files` view; links to the transcript, `design.md` and `changes.md`; the section "Reading of garbled input"; the `global` view; one section per concept; the `issues-and-prs` view. + +"Reading of garbled input" lists each suspicious token with its segment, the reading adopted and why, labelled as inference. Example: `- § (T145): read as "features". Inference: the sentence lists things to implement.` The transcript stays exact; readings live only here and in concept summaries. + +Each concept section is a heading `## C001: `, the `concept-C001` view, authored preliminary thoughts, and the items list. + +## Items and status trails + +Items are hierarchical statements under a concept section in `main.md`. Each is one list line; a child sits directly below its parent, indented by two spaces. + +```markdown +- **C001.2** `clarified` · S2 · 2026-10-21T10:00:00Z — More nuanced than first thought; see C001.2.1. ← `created` · S0 · 2026-10-19T06:09:02Z — Agents write cross-file changes as to/from note files. + - **C001.2.1** `created` · S2 · 2026-10-21T10:00:00Z — The nuance, written directly below the item it refines. +``` + +Grammar of one line: + +```text +line = indent "- **" id "** " entry *( " ← " entry ) +entry = "`" status "` · " stage " · " timestamp " — " text +``` + +- The newest entry is first. The oldest entry keeps the original text, which is never deleted or edited. +- `status` is a statement status, `stage` is `S0` to `S8`, and `text` must not contain `←`. A `superseded` or `clarified` entry names the item that replaces or refines it. +- `item add --package <dir> --parent C001.2 --text <text>` allocates the next ID and places the line directly below its parent's subtree. `item set-status --package <dir> --item C001.2 --status clarified --text <text>` prepends an entry. Both append a line to `changes.md`. +- `check` validates the grammar, that each parent exists, that IDs are unique, the vocabulary, and the timestamps. + +## Change log + +`changes.md` starts with `# Changes`, a blank line, a link to `main.md` and a blank line. After that, each line is one change: + +```text +- 2026-10-21T10:00:00Z | S3 | C002 | Incorporated note C001__to__C002__4f1c… into Research. +``` + +The fields are timestamp, stage (or `router`), subject (a concept, item or decision ID, `G`, or `package`) and a short text. `.gitattributes` sets `merge=union` for it, so two branches that each add a line merge cleanly. Lines are never edited or deleted, because a union merge would keep both versions. Their order follows merges, not time; sort by timestamp to read them in order. GitHub's merge button may not apply the union driver, which is one reason to merge the base locally first ([collaboration.md](collaboration.md#the-rules)). + +## Notes + +A note asks another concept's owner for a change or tells them something. It is a new file `notes/C001__to__C002__<uuid>.md`, written once by the sender with `note --package <dir> --from C001 --to C002 --input <file>`: + +````markdown +# Note C001 to C002 + +```workflow-note +{ + "about": ["C002.3"], + "at": "2026-10-21T10:00:00Z", + "body_sha256": "…", + "from": "C001", + "id": "C001__to__C002__4f1c…", + "to": "C002" +} +``` + +The body: what to change and why, with links. +```` + +- The body is everything after the blank line that follows the closing fence. `body_sha256` is the hash of its UTF-8 bytes. `note` formats the body with prettier (when present) before hashing, so the pre-commit formatter cannot break the hash. +- `about` is optional and lists the receiver's items the note concerns. +- A note is immutable. A reply is a new note in the other direction. `note` validates only what it writes, so a problem elsewhere in the package cannot block a sender. +- Merge note-only PRs quickly: they add one new file and cannot conflict. + +## Receipts + +A receipt records how the receiver handled one note. It is `receipts/<note-id>.md`, created once with `resolve-note --package <dir> --note notes/<note-id>.md --disposition <d> --target <path#anchor> --reason <text>`: + +````markdown +# Receipt for C001__to__C002__4f1c… + +```workflow-receipt +{ + "at": "2026-10-21T11:00:00Z", + "by": "c002-research", + "disposition": "incorporated", + "note": "notes/C001__to__C002__4f1c….md", + "reason": "Added the transport comparison the note asked for.", + "target": "concepts/C002-transport.md#research" +} +``` +```` + +- `by` is the receiver's agent name, or the reconciler's name followed by `for C002` when it acts on the receiver's behalf. +- `target` is a link inside the package to where the note's content went, or where the answer is. +- The file is created with `O_EXCL`, so two writers cannot both resolve one note. `resolve-note` accepts only `notes/*.md` files with a valid note block. + +A scan record proves which refs reconcile looked at. It is `receipts/C002__scan__<UTC>.md`, written by the receiver at the end of S3: + +````markdown +# Note scan for C002 + +```workflow-scan +{ + "at": "2026-10-21T11:05:00Z", + "by": "c002-reconcile", + "concept": "C002", + "pending": [], + "refs": { + "origin/main": "4063f248…", + "origin/wf/research-pipeline-c001-s2": "9a1b…" } +} +``` +```` - <!-- /workflow:state --> - ``` +`check --remote-notes` produces the `refs` and `pending` lists: it scans every `origin/*` ref for notes addressed to the concept that are not on the current branch. A note that arrives after the scan is provably late and reopens S3 for its receiver. - Prettier preserves JSON syntax inside these blocks. +## Decisions -- **Source Excerpts**: Placed inside dedicated excerpt blocks with a double newline following the header comment: +`decisions/D001-<slug>.md` holds one decision. The machine block comes directly after the title: - ````markdown - <!-- workflow:excerpt C001 1 5 --> +````markdown +# D001: Where live leases are stored - [Transcript lines 1-5](../transcript.txt#L1-L5) +```workflow-decision +{ + "affects": ["C009", "C010.2"], + "challenge": {"at": "", "by": "", "result": ""}, + "evidence": ["T051"], + "id": "D001", + "reversal_cost": "low: move the directory and update the profile key", + "reversed_by": "", + "source": "agent-preliminary", + "status": "preliminary", + "supersedes": [] +} +``` +```` - ```text - Exact excerpt text preserved byte-for-byte. - ``` - ```` +The prose sections are Question, Options (each steelmanned), Choice, Rationale, Reversal (what changes if a human picks another option), and History (one line per status change). Field meanings, who may set which value, and the review flow are in [decisions.md](decisions.md). - ``` +## Issues + +Every issue the workflow creates has a title of the form `<Prefix>: <subject> (<slug>·C001)`. Prefixes: `Research:` (S1), `Handoff:` (S4), `Design:` (S5 facet and orchestration issues), `Plan:` (S6), `Implement:` (S7 step and orchestration issues). Facet issues name the item instead, `(<slug>·C001.3)`. + +The body ends with a marker line: + +```markdown +<!-- workflow:issue {"concept":"C001","item":"","package":"2026-10-19T06-09-02Z_research_research-intake-to-implementation","stage":"S1"} --> +``` - ``` +- Before creating an issue, search the repository for its marker so a retry never makes a duplicate. +- Use existing labels only. +- The body is self-contained: goal; links to the package, the concept's section in `main.md`, the concept file and its transcript segments; current state with evidence; owned outputs; acceptance evidence; prerequisites (blocked-by); parallel-safe-with; what to do first; and a done contract (outcome, how it is verified, boundaries, and when to stop and report blocked). The [issue templates](templates/) lay these out. +- Record each issue in the concept's `issues` list with the stage that created it. -- **Transcript Protection**: `transcript.txt` is marked `-text` in `.gitattributes` and excluded from trailing whitespace fixers in `root.just`. +## Tool status -## 3. Identification & Traceability +What `scripts/research_workflow.py` on `main` at `4063f248` (2026-10-20) does differently from this page. Wave 2 (the `tool-items` and `tool-live` work packages) is building most of the missing commands; check `--help` before relying on one. -- **Segments (`T001`, `T002`, ...)**: Punctuation and sentence-bounded units of the raw transcript, assigned sequentially at intake. -- **Concepts (`C001`, `C002`, ...)**: Major topics or requirements extracted from the transcript. -- **Hierarchical Items (`C001.1`, `C001.2.1`, ...)**: Granular statements, findings, and design requirements that evolve over time. -- **Status Trails**: When an item is clarified, superseded, or retracted, the new status is prepended with a UTC timestamp and originating stage, preserving historical provenance: - ```markdown - - **C001.2** `clarified` · S2 · 2026-10-21T10:00:00Z — Refined interpretation. ← `created` · S0 · 2026-10-19T06:09:02Z - - **C001.2.1** `created` · S2 · 2026-10-21T10:00:00Z — Specific child detail. - ``` -- **Garbled Input Register**: Ambiguous phonetic words or speech-to-text artifacts are documented in a dedicated register in `main.md` (e.g. `Karen` -> `Cairn`, `§` -> `features`), keeping interpretations explicit and audit-traceable. +- State: all state is one package-level JSON block in `main.md`, wrapped in `<!-- workflow:state -->` comments, with `concepts`, `tasks` and `events` arrays. Prettier de-indents it (see the existing package's `main.md`). There is no `package.json` and no per-concept `workflow-state` block. +- Excerpts: line-based. The outline uses `source_lines`, the marker is `<!-- workflow:excerpt C001 1 5 -->` with a `text` fence, and line numbers come from Python `splitlines()` (which also splits at U+2028 and form feeds). There are no `T` segments and no `--preview-segments`. +- Coverage: by non-blank line, not by segment. There is no `G` bucket and no `hint` type; every concept needs source lines. +- Single concept: the concept is written into `main.md` with an inline change log, instead of a concept file and `changes.md`. +- Notes: the marker is `<!-- workflow:note -->`, the body is hashed without a formatter pass, and `note` runs a full package check first. +- Receipts: `resolve-note` appends a `## Note disposition` section to the receiver's concept file (a second writer) and guards with an `O_EXCL` lock file `notes/.<id>.resolved`. `deferred` is not accepted. There are no scan records. +- Vocabulary: `status`, `priority`, `criticality` and `horizon` are free text. Completion uses a synonym set (`done`, `completed`, `researched`, ...). The relation kinds `supersedes`, `contradicts` and `part-of` are rejected. +- Scheduling: `ready` and `status` read the working tree, not `origin/<trunk>`. There are no waves, `shares-files-with` is ignored, and there are no leases or live join. +- Commands missing: `render`, `item add`, `item set-status`, `ids`, `lease acquire|release|list`, `verify-transcript`, `status --live`, `check --changed-since`, `check --remote-notes`, `check --run-validation`, `check --profile-only`, and the `init` flags `--preview-segments`, `--source`, `--encoding` and `--visibility`. +- Encoding: non-UTF-8 input is always refused; there is no `--encoding`. +- Discovery: besides the name pattern, any folder whose `main.md` has a state block counts as a package. +- Change log lines are `- <UTC> | intake | prepared | <text>` (stage name and package status, no subject). +- Decisions, `human-review.md`, generated views and issue markers have no tool support. Skills create issues and search markers with `gh`. +- CI runs `check` over the whole tree on every PR, not only the changed packages. diff --git a/planning/workflow/vocabulary.md b/planning/workflow/vocabulary.md new file mode 100644 index 0000000000..7a0f532e81 --- /dev/null +++ b/planning/workflow/vocabulary.md @@ -0,0 +1,109 @@ +# Workflow vocabulary + +Every enumerated value and identifier the workflow uses, defined once. Records that carry these values are described in [records.md](records.md). `check` rejects values outside these lists; see [Tool status](records.md#tool-status) for what it validates today. + +Relation kinds and priority tiers are listed here so the full set is in one place, but their meaning and use are defined in [DEPENDENCIES.md](../DEPENDENCIES.md). Horizons are the repo roadmap horizons from [planning/README.md](../README.md#roadmap). + +## Stages + +| Stage | Name | Skill | +| ----- | --------- | ------------------------------------------------- | +| S0 | intake | `request-intake` | +| S1 | prepare | `research-prepare` | +| S2 | research | `concept-research` | +| S3 | reconcile | `notes-reconcile` | +| S4 | handoff | `issue-handoff` (mode `parent`) | +| S5 | fanout | `issue-handoff` (modes `fanout`, `orchestration`) | +| S6 | design | `design-orchestrate` | +| S7 | plan | `feature-plan` | +| S8 | implement | `implementation-orchestrate` | +| any | router | `research-workflow` (dispatches; owns no stage) | + +A concept's `stage` is the stage it is in now: the work of that stage is not finished. It moves to the next stage when the exit criteria in [stages.md](stages.md) are met. Records written by the router use `router` where a stage is expected. + +## Statement status (`status`) + +What we know about a statement: a concept or an item. + +- `created`: recorded from the transcript or by a stage. Not yet checked. +- `clarified`: refined by a later stage without changing the intent. The detail usually sits in a child item directly below. +- `confirmed`: checked against code, a cited source or a human answer. The trail text says which. +- `superseded`: replaced by a newer item, concept or decision. The trail text names it. +- `retracted`: withdrawn because it was wrong, misheard or is no longer wanted. + +`superseded` and `retracted` are terminal. The record keeps them, but they are excluded from default reading ([retention](../DOCUMENTATION_ARCHITECTURE.md#retention)). + +## Disposition (`disposition`) + +What happens to the thing a concept describes. + +- `proposed`: recorded, not yet evaluated. Never read as in force. +- `accepted`: chosen for design and planning. +- `planned`: a feature plan with steps and issues exists. +- `in-progress`: at least one implementation PR is open or merged. +- `implemented`: every plan step has merged and been validated. +- `deferred`: postponed. Requires a reason and a revisit trigger. +- `rejected`: decided against. Requires a reason. +- `superseded`: replaced by another concept or package. Names it. + +Roadmap rows in `planning/roadmaps/` use their own status list. They map as follows: `idea` and `proposed` to `proposed`, `shaped` to `accepted`, `planned` to `planned`, `in-progress` to `in-progress`, `shipped` to `implemented`, `dropped` to `rejected`. A `deferred` concept keeps its roadmap row under Later or Ideas. + +## Run status + +Where the work for one concept at one stage stands. `status --live` computes it; nobody writes it by hand. The first rule that matches wins. + +1. `abandoned`: the concept history records that this stage's work was stopped on purpose, with a reason. The branch stays. +2. `validated`: the PR merged and the stage's exit criteria were checked afterwards, recorded in history. +3. `merged`: the PR merged and its head SHA is an ancestor of the trunk (git and GitHub). +4. `pr-open`: an open PR exists for the stage branch (GitHub). +5. `pushed`: the stage branch on origin has commits that are not in the trunk, and there is no PR (git). Treat it as an orphan if it lasts. +6. `running`: a lease is held and the worker's log has a heartbeat younger than 20 minutes (live directory). +7. `claimed`: a lease is held and there is no heartbeat yet (live directory). +8. `blocked`: a `requires` target has not finished, or the history records a blocking reason. +9. `not-started`: none of the above. + +`pushed`, `pr-open` and `merged` come only from git and GitHub, never from a worker's report. The live directory is described in [collaboration.md](collaboration.md#live-coordination). + +## Note receipt disposition + +How a receiver handled a note: `incorporated`, `acknowledged`, `declined`, `deferred`, `superseded`. Each needs a target and a reason ([records.md](records.md#receipts)). + +## Decision source and status + +- Source: `stated`, `inferred`, `agent-preliminary`, `human-confirmed`. +- Status: `preliminary`, `confirmed`, `reversed`. + +Meanings and promotion rules: [decisions.md](decisions.md#source-and-status). + +## Concept type and kind + +- Type: `topic` (a subject to research), `hint` (an idea only hinted at; not ready for research until a note or a human answer changes its type), `constraint` (a limit the result must respect), `directive` (an instruction about the work itself). +- Kind: `new` (the concept creates files) or `edit` (it changes existing files). `targets` lists the paths either way. + +## Relation kinds + +`requires`, `recommended-after`, `shares-files-with`, `conflicts-with`, `enables`, `optional-if`, `supersedes`, `contradicts`, `part-of`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds). + +## Priority + +`crucial`, `recommended`, `contingent`, `unspecified`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#priority-tiers). + +## Horizon + +`now`, `next`, `later`, `ideas`, `unspecified`. These are the roadmap horizons in [planning/README.md](../README.md#roadmap). Horizon says when; priority says how much it matters. + +## Identifiers + +Tools allocate identifiers. Agents never choose one. + +- Package: the folder name `<UTC>_research_<slug>`, for example `2026-10-19T06-09-02Z_research_research-intake-to-implementation`. `<UTC>` is `YYYY-MM-DDTHH-MM-SSZ`; `<slug>` is lowercase kebab case. +- Segment: `T001`, `T002`, ... in transcript order. A range is `T007-T009`. +- Concept: `C001`, `C002`, ... Allocated by `init`, and later by `ids` when a concept is added. +- Item: `C001.2`, `C001.2.1`, ... Allocated by `item add`, never renumbered. Items in the global bucket are `G.1`, `G.1.2`, ... +- Global bucket: `G`. Holds the process directives and constraints the user gave about how to work. +- Note: the file stem `C001__to__C002__<uuid>`, where `<uuid>` is 32 lowercase hex digits. Allocated by `note`. +- Scan record: the file stem `C002__scan__<UTC>`. Written by reconcile. +- Decision: `D001`, `D002`, ... Allocated by `ids`, never reused. +- Branch: `wf/<slug>-c002-s2` for concept C002 at stage S2 of package `<slug>`, and `wf/<slug>-c002.3-s6` for a facet. A follow-up after a merge adds `-2`, `-3`. +- Agent name: lowercase kebab case, unique within a run. Used in leases, logs and receipts. +- Timestamp: UTC to the second, `2026-10-21T10:00:00Z`. In file and folder names, colons become hyphens: `2026-10-21T10-00-00Z`. From 72ab4e14030d04880666f2923dc716cf6f5d94bd Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Wed, 21 Oct 2026 20:06:00 -0500 Subject: [PATCH 2/7] docs(repo): align workflow records with the merged items tool and templates --- planning/workflow/records.md | 164 +++++++++++++++----------------- planning/workflow/vocabulary.md | 13 ++- 2 files changed, 81 insertions(+), 96 deletions(-) diff --git a/planning/workflow/records.md b/planning/workflow/records.md index 27f0aedc3c..6865a47d64 100644 --- a/planning/workflow/records.md +++ b/planning/workflow/records.md @@ -1,6 +1,6 @@ # Workflow records -The files a research package holds, who writes each one, and their exact formats. Values come from [vocabulary.md](vocabulary.md). Who may write what, and how, is ruled by [collaboration.md](collaboration.md). This page describes the target format. Where the tool on `main` writes something else, the difference is listed under [Tool status](#tool-status). +The files a research package holds, who writes each one, and their exact formats. Values come from [vocabulary.md](vocabulary.md). Who may write what, and how, is ruled by [collaboration.md](collaboration.md). This page describes the target format. Where the tool on `main` writes something else, the difference is listed under [Tool status](#tool-status). The [templates](templates/README.md) show each file filled in. ## Package layout @@ -17,21 +17,20 @@ doc/<UTC>_research_<slug>/ concepts/C001-<slug>.md one per concept notes/C001__to__C002__<uuid>.md receipts/<note-id>.md - receipts/C002__scan__<UTC>.md decisions/D001-<slug>.md ``` -| Path | Writer | Changes how | -| ---------------------- | ----------------------------------------------------------- | ---------------------------------------------------- | -| `transcript.txt` | intake, once | never | -| `package.json` | intake, once | never | -| `main.md`, `design.md` | anyone, through a PR | authored parts by PR; views by `render` | -| `changes.md` | anyone | one appended line, `merge=union` | -| `human-review.md` | `render` | regenerated, never edited | -| `concepts/C001-*.md` | the concept's current stage owner | edited by its owner only | -| `notes/*.md` | the sender, once | never; a reply is a new note | -| `receipts/*.md` | the receiver, or the reconciler on its behalf, once | never | -| `decisions/D001-*.md` | the S6 orchestrator files it; the holder of its lease edits | status changes only, under the `decision-D001` lease | +| Path | Writer | Changes how | +| ---------------------- | --------------------------------------------------- | -------------------------------------------- | +| `transcript.txt` | intake, once | never | +| `package.json` | intake, once | never | +| `main.md`, `design.md` | anyone, through a PR | authored parts by PR; views only by `render` | +| `changes.md` | anyone | one appended line, `merge=union` | +| `human-review.md` | `render` | regenerated, never edited | +| `concepts/C001-*.md` | the concept's current stage owner | edited by its owner only | +| `notes/*.md` | the sender, once | never; a reply is a new note | +| `receipts/*.md` | the receiver, or the reconciler on its behalf, once | never | +| `decisions/D001-*.md` | an S6 worker, once; later the holder of its lease | status changes and dated lines only | `notes/`, `receipts/` and `decisions/` are created when the first file needs them. A single concept gets the same layout with one concept file. There is no special case. @@ -85,9 +84,8 @@ Titles and slugs reject control characters and newlines. "history": [ { "at": "2026-10-19T06:09:02Z", - "disposition": "proposed", "note": "Created at intake.", - "ref": "", + "ref": "transcript.txt", "stage": "S0", "status": "created" } @@ -101,7 +99,7 @@ Titles and slugs reject control characters and newlines. "relations": [], "segments": ["T001-T004", "T010"], "slug": "exact-transcript-storage", - "stage": "S1", + "stage": "S0", "status": "created", "targets": ["scripts/research_workflow.py"], "title": "Exact transcript storage", @@ -111,12 +109,13 @@ Titles and slugs reject control characters and newlines. ```` - The block is JSON with 2-space indentation, sorted keys and a final newline. Its fence info string is `workflow-state`, which prettier leaves alone. Never wrap state in an HTML comment. -- `issues` and `prs` entries are `{"number", "stage", "state", "url"}`. `state` is the last recorded GitHub state (`open`, `closed`, `merged`); `status --live` reads the real one. -- `relations` entries are `{"kind", "reason", "to"}`, plus `rework_if_early` for `recommended-after`, `trigger` for `optional-if`, and an optional `stage` for `requires` ([DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds)). `to` is a concept or item ID in this package, or a repo path or issue URL outside it. -- `history` is append-only. Each entry records the state after a change: `at`, `stage`, `status`, `disposition`, `note` (why), `ref` (commit, PR, issue or path), and `trigger` when the disposition becomes `deferred`. An entry that sets `deferred` or `rejected` must have a non-empty `note`. +- `stage` is the latest stage that has started on the concept. The worker of a stage sets it in its first commit and appends a history entry. +- `issues` and `prs` entries are `{"number", "url", "stage", "state"}`, plus optional `title`, `item` (the item the issue or PR is for) and `reason` (why it was implemented, declined or changed). `state` is the last recorded GitHub state (`open`, `closed`, `merged`); `status --live` reads the real one. +- `relations` entries are `{"kind", "to", "reason"}`, plus `rework_if_early` for `recommended-after`, `trigger` for `optional-if`, and an optional `stage` for `requires` ([DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds)). `to` is a concept or item ID in this package, or a repo path or issue URL outside it. +- `history` is append-only, newest last. Each entry has `at`, `stage`, `status`, `note` (why) and `ref` (commit, PR, issue or path), plus `disposition` when the disposition changes and `trigger` when it becomes `deferred`. An entry that sets `deferred` or `rejected` must have a non-empty `note`. - Only the concept's current owner writes the file. The owner may keep supporting material in a sibling folder `concepts/C001-<slug>/`, under the same rule. -The rest of the file is authored Markdown. The sections each stage must fill are listed in [stages.md](stages.md); the [concept template](templates/concept.md) lays them out. +The rest of the file is authored Markdown. The sections each stage must fill are listed in [stages.md](stages.md). ## Excerpts @@ -140,29 +139,33 @@ The exact text from the start of T007 to the end of T009. `main.md`, `design.md` and `human-review.md` contain generated sections. Each sits between two markers, with a blank line inside each: ```markdown -<!-- workflow:view run-table --> +<!-- workflow:view run-status --> -- **C001** S2 · `running` · [#412](https://github.com/developing-today/code/pull/412) +- **C001** [Exact transcript storage](main.md#c001): S0 `validated` · S1 `running` · S2–S8 `not-started` -<!-- /workflow:view run-table --> +<!-- /workflow:view run-status --> ``` -- `render` rewrites everything between the markers. Never edit a view by hand. If two PRs conflict inside a view, take either side and run `render` again. +- `render --package <dir>` rewrites everything between the markers, and inserts a missing view under its heading. Never edit a view by hand. If two PRs conflict inside a view, take either side and run `render` again. +- Once a package has views, `check` fails when one is stale, missing, or has a name `render` does not know. - Generated Markdown uses only headings, `-` bullets, `**bold**`, backticks, links and blank lines. No tables, no `*emphasis*`. Output must pass `prettier --check` unchanged. -View names: +Views `render` writes: -- `main.md`: `files` (every package file and every repo file the concepts create or edit), `global` (segments in `G`), `concept-C001` (one per concept: stage, status, disposition, run status, priority, horizon, goal, enables, relations, issues and PRs with their state), `issues-and-prs` (every issue and PR in the package, each naming the concept or item it belongs to). -- `design.md`: `review-order` (first-pass order to review the concepts), `waves` (output of `ready`), `run-table` (run status per concept and stage), `research-stages` (from S5 on: every issue per concept, with a short description, priority order and wave). -- `human-review.md`: `human-review` (see [decisions.md](decisions.md#human-review)). +- `main.md`, `concept-C001`: one per concept, in its section. State (status, stage, disposition, priority, horizon), goal, item counts by status, relations in and out, and its issues and PRs with stage and state. +- `main.md`, `issues-and-prs`: every issue and PR in the package, grouped under the concept it belongs to, naming the item when there is one. +- `design.md`, `waves`: the output of `ready` (done, running, wave 1, wave 2, ...), with each `recommended-after` cost shown under the wave that pays it. +- `design.md`, `run-status`: the run status of each concept at each stage. + +Views planned but not rendered yet (do not add their markers until `render` writes them, because `check` rejects unknown names): `files` and `global` in `main.md`, `review-order` and `research-stages` in `design.md`, and `human-review` in `human-review.md`. ## Main reference -`main.md` holds, in order: the title and an introduction; the `files` view; links to the transcript, `design.md` and `changes.md`; the section "Reading of garbled input"; the `global` view; one section per concept; the `issues-and-prs` view. +`main.md` holds, in order: the title and an introduction; the list of package files and of every repo file the concepts create or edit; links to the transcript, `design.md` and `changes.md`; the section "Reading of garbled input"; the segments in `G`; one section per concept; the section "Issues and PRs" with its view. "Reading of garbled input" lists each suspicious token with its segment, the reading adopted and why, labelled as inference. Example: `- § (T145): read as "features". Inference: the sentence lists things to implement.` The transcript stays exact; readings live only here and in concept summaries. -Each concept section is a heading `## C001: <title>`, the `concept-C001` view, authored preliminary thoughts, and the items list. +Each concept section is a heading `## C001: <title>` (with an `<a id="c001"></a>` anchor line before it), the `concept-C001` view, authored preliminary thoughts, and the items list. ## Items and status trails @@ -177,23 +180,27 @@ Grammar of one line: ```text line = indent "- **" id "** " entry *( " ← " entry ) -entry = "`" status "` · " stage " · " timestamp " — " text +entry = "`" status "` · " stage " · " timestamp [ " — " text ] ``` -- The newest entry is first. The oldest entry keeps the original text, which is never deleted or edited. -- `status` is a statement status, `stage` is `S0` to `S8`, and `text` must not contain `←`. A `superseded` or `clarified` entry names the item that replaces or refines it. -- `item add --package <dir> --parent C001.2 --text <text>` allocates the next ID and places the line directly below its parent's subtree. `item set-status --package <dir> --item C001.2 --status clarified --text <text>` prepends an entry. Both append a line to `changes.md`. -- `check` validates the grammar, that each parent exists, that IDs are unique, the vocabulary, and the timestamps. +- The newest entry is first, and timestamps never increase from left to right. The newest entry must have text. The oldest entry keeps the original text, which is never deleted or edited. +- `status` is a statement status and `stage` is `S0` to `S8`. +- `item add --package <dir> --parent <C001 or C001.2> --stage S2 --text <text>` allocates the next free ID under the parent and inserts the line: a first top-level item goes directly below the concept view, any other item goes after its last sibling's subtree. `--status` (default `created`) and `--at` are optional. +- `item set-status --package <dir> --id C001.2 --status clarified --stage S2 --note <text> [--see C001.2.1]` prepends an entry whose text is the note followed by `see <ids>`. `superseded` requires `--see`. An item never goes back to `created`. +- Both commands refresh the concept's view and append a line to `changes.md`. +- `check` validates the grammar, that each parent exists, that IDs are unique, the vocabulary and the timestamp order. ## Change log `changes.md` starts with `# Changes`, a blank line, a link to `main.md` and a blank line. After that, each line is one change: ```text -- 2026-10-21T10:00:00Z | S3 | C002 | Incorporated note C001__to__C002__4f1c… into Research. +- 2026-10-21T10:00:00Z | S2 | clarified | C001.2 created → clarified: More nuanced than first thought; see C001.2.1. ``` -The fields are timestamp, stage (or `router`), subject (a concept, item or decision ID, `G`, or `package`) and a short text. `.gitattributes` sets `merge=union` for it, so two branches that each add a line merge cleanly. Lines are never edited or deleted, because a union merge would keep both versions. Their order follows merges, not time; sort by timestamp to read them in order. GitHub's merge button may not apply the union driver, which is one reason to merge the base locally first ([collaboration.md](collaboration.md#the-rules)). +The fields are timestamp, stage, the status the change set (a statement status, disposition or run status) and the text, which starts with the IDs it concerns. A line written by hand ends with `, by <writer> (<path, PR or commit>)`. `item add` and `item set-status` write their own lines; add one by hand only for a change no command records. + +`.gitattributes` sets `merge=union` for `changes.md`, so two branches that each add a line merge cleanly. Lines are never edited or deleted, because a union merge would keep both versions. Their order follows merges, not time; sort by timestamp to read them in order. GitHub's merge button may not apply the union driver, which is one reason to merge the base locally first ([collaboration.md](collaboration.md#the-rules)). ## Notes @@ -204,7 +211,6 @@ A note asks another concept's owner for a change or tells them something. It is ```workflow-note { - "about": ["C002.3"], "at": "2026-10-21T10:00:00Z", "body_sha256": "…", "from": "C001", @@ -217,7 +223,6 @@ The body: what to change and why, with links. ```` - The body is everything after the blank line that follows the closing fence. `body_sha256` is the hash of its UTF-8 bytes. `note` formats the body with prettier (when present) before hashing, so the pre-commit formatter cannot break the hash. -- `about` is optional and lists the receiver's items the note concerns. - A note is immutable. A reply is a new note in the other direction. `note` validates only what it writes, so a problem elsewhere in the package cannot block a sender. - Merge note-only PRs quickly: they add one new file and cannot conflict. @@ -231,10 +236,14 @@ A receipt records how the receiver handled one note. It is `receipts/<note-id>.m ```workflow-receipt { "at": "2026-10-21T11:00:00Z", - "by": "c002-research", + "by": "c002-reconcile", "disposition": "incorporated", "note": "notes/C001__to__C002__4f1c….md", "reason": "Added the transport comparison the note asked for.", + "scanned": [ + { "ref": "origin/main", "sha": "cf6c4f90…" }, + { "ref": "origin/wf/research-pipeline-c001-s2", "sha": "9a1b…" } + ], "target": "concepts/C002-transport.md#research" } ``` @@ -242,52 +251,27 @@ A receipt records how the receiver handled one note. It is `receipts/<note-id>.m - `by` is the receiver's agent name, or the reconciler's name followed by `for C002` when it acts on the receiver's behalf. - `target` is a link inside the package to where the note's content went, or where the answer is. +- `scanned` lists every ref and SHA that `check --remote-notes` looked at before the receipt was written. A concept that received no notes records the same scan in the `note` of its S3 history entry, with the trunk SHA as `ref`. A note dated after the scan is provably late and reopens S3 for its receiver. - The file is created with `O_EXCL`, so two writers cannot both resolve one note. `resolve-note` accepts only `notes/*.md` files with a valid note block. -A scan record proves which refs reconcile looked at. It is `receipts/C002__scan__<UTC>.md`, written by the receiver at the end of S3: - -````markdown -# Note scan for C002 - -```workflow-scan -{ - "at": "2026-10-21T11:05:00Z", - "by": "c002-reconcile", - "concept": "C002", - "pending": [], - "refs": { - "origin/main": "4063f248…", - "origin/wf/research-pipeline-c001-s2": "9a1b…" - } -} -``` -```` - -`check --remote-notes` produces the `refs` and `pending` lists: it scans every `origin/*` ref for notes addressed to the concept that are not on the current branch. A note that arrives after the scan is provably late and reopens S3 for its receiver. - ## Decisions -`decisions/D001-<slug>.md` holds one decision. The machine block comes directly after the title: +`decisions/D001-<slug>.md` holds one decision. Its header is a field list directly after the title, so `git grep` and a simple parser both read it: -````markdown +```markdown # D001: Where live leases are stored -```workflow-decision -{ - "affects": ["C009", "C010.2"], - "challenge": {"at": "", "by": "", "result": ""}, - "evidence": ["T051"], - "id": "D001", - "reversal_cost": "low: move the directory and update the profile key", - "reversed_by": "", - "source": "agent-preliminary", - "status": "preliminary", - "supersedes": [] -} +- Status: preliminary +- Source: agent-preliminary +- Date: 2026-10-21T12:00:00Z +- Affects: C009, C010.2 +- Reversal cost: low — move the directory and update the profile key +- Decided by: s6-reviewer-2 (https://github.com/developing-today/code/pull/530) ``` -```` -The prose sections are Question, Options (each steelmanned), Choice, Rationale, Reversal (what changes if a human picks another option), and History (one line per status change). Field meanings, who may set which value, and the review flow are in [decisions.md](decisions.md). +- `Source: stated` and `Source: human-confirmed` carry their evidence in parentheses: segment IDs (`stated (T051)`) or the URL of the human's message. +- The sections are Question, Options (each with a steelman and the case against), Choice, Rationale and Human review. Status changes, the challenge pass and reversals each add a dated line under Choice; nothing is deleted. +- Field meanings, who may set which value, and the review flow are in [decisions.md](decisions.md). ## Issues @@ -301,24 +285,26 @@ The body ends with a marker line: - Before creating an issue, search the repository for its marker so a retry never makes a duplicate. - Use existing labels only. -- The body is self-contained: goal; links to the package, the concept's section in `main.md`, the concept file and its transcript segments; current state with evidence; owned outputs; acceptance evidence; prerequisites (blocked-by); parallel-safe-with; what to do first; and a done contract (outcome, how it is verified, boundaries, and when to stop and report blocked). The [issue templates](templates/) lay these out. +- The body is self-contained: goal; links to the package, the concept's section in `main.md`, the concept file and its transcript segments; current state with evidence; owned outputs; acceptance evidence; prerequisites (blocked-by); parallel-safe-with; what to do first; and a done contract (outcome, how it is verified, boundaries, and when to stop and report blocked). The [issue templates](templates/README.md) lay these out. - Record each issue in the concept's `issues` list with the stage that created it. ## Tool status -What `scripts/research_workflow.py` on `main` at `4063f248` (2026-10-20) does differently from this page. Wave 2 (the `tool-items` and `tool-live` work packages) is building most of the missing commands; check `--help` before relying on one. +What `scripts/research_workflow.py` and `scripts/research_workflow_items.py` on `main` at `cf6c4f90` (2026-10-21) do differently from this page. Work package `tool-live` is building the live commands; check `--help` before relying on one. -- State: all state is one package-level JSON block in `main.md`, wrapped in `<!-- workflow:state -->` comments, with `concepts`, `tasks` and `events` arrays. Prettier de-indents it (see the existing package's `main.md`). There is no `package.json` and no per-concept `workflow-state` block. -- Excerpts: line-based. The outline uses `source_lines`, the marker is `<!-- workflow:excerpt C001 1 5 -->` with a `text` fence, and line numbers come from Python `splitlines()` (which also splits at U+2028 and form feeds). There are no `T` segments and no `--preview-segments`. -- Coverage: by non-blank line, not by segment. There is no `G` bucket and no `hint` type; every concept needs source lines. +- State: all state is one package-level JSON block in `main.md`, wrapped in `<!-- workflow:state -->` comments, with `concepts`, `dependencies`, `issues`, `prs`, `tasks` and `events` arrays. Prettier de-indents it (see the existing package's `main.md`). There is no `package.json` and no per-concept `workflow-state` block; relations are `dependencies` entries `{from, to, kind, reason}`. +- Run status: recorded as `tasks` entries `{concept, stage, status}` in that block; `check` rejects `pushed`, `pr-open` and `merged` there. `render` shows S0 as `validated`. +- Excerpts: line-based. The outline uses `source_lines`, the marker is `<!-- workflow:excerpt C001 1 5 -->` with a `text` fence, and line numbers come from Python `splitlines()` (which also splits at U+2028 and form feeds). There are no `T` segments and no `--preview-segments`; `ids` lists segments only when a `package.json` exists. +- Coverage: by non-blank line, not by segment. There is no `G` bucket, no `G.1` items and no `hint` type; every concept needs source lines. - Single concept: the concept is written into `main.md` with an inline change log, instead of a concept file and `changes.md`. - Notes: the marker is `<!-- workflow:note -->`, the body is hashed without a formatter pass, and `note` runs a full package check first. -- Receipts: `resolve-note` appends a `## Note disposition` section to the receiver's concept file (a second writer) and guards with an `O_EXCL` lock file `notes/.<id>.resolved`. `deferred` is not accepted. There are no scan records. -- Vocabulary: `status`, `priority`, `criticality` and `horizon` are free text. Completion uses a synonym set (`done`, `completed`, `researched`, ...). The relation kinds `supersedes`, `contradicts` and `part-of` are rejected. -- Scheduling: `ready` and `status` read the working tree, not `origin/<trunk>`. There are no waves, `shares-files-with` is ignored, and there are no leases or live join. -- Commands missing: `render`, `item add`, `item set-status`, `ids`, `lease acquire|release|list`, `verify-transcript`, `status --live`, `check --changed-since`, `check --remote-notes`, `check --run-validation`, `check --profile-only`, and the `init` flags `--preview-segments`, `--source`, `--encoding` and `--visibility`. -- Encoding: non-UTF-8 input is always refused; there is no `--encoding`. +- Receipts: `resolve-note` appends a `## Note disposition` section to the receiver's concept file (a second writer) and guards with an `O_EXCL` lock file `notes/.<id>.resolved`. `deferred` is not accepted and nothing records `scanned`. +- Vocabulary: item statuses and stages are validated. Concept `status`, `priority`, `criticality` and `horizon` are free text, and completion uses a synonym set (`done`, `completed`, `researched`, ...). The relation kinds `supersedes`, `contradicts` and `part-of` are rejected. +- Scheduling: `ready` and `status` read the working tree, not `origin/<trunk>`. The `waves` view honours `requires` and `shares-files-with`; there are no leases and no live join. +- IDs: `ids` lists concept, item, segment, note and decision IDs but does not allocate decision IDs. +- Commands missing: `lease acquire|release|list`, `verify-transcript`, `status --live`, `check --changed-since`, `check --remote-notes`, `check --run-validation`, `check --profile-only`, and the `init` flags `--preview-segments`, `--source`, `--encoding` and `--visibility`. +- Encoding: non-UTF-8 input is always refused. - Discovery: besides the name pattern, any folder whose `main.md` has a state block counts as a package. -- Change log lines are `- <UTC> | intake | prepared | <text>` (stage name and package status, no subject). -- Decisions, `human-review.md`, generated views and issue markers have no tool support. Skills create issues and search markers with `gh`. +- `init` writes its change-log line as `- <UTC> | intake | prepared | <text>`, with a stage name instead of `S0`. +- Decisions and `human-review.md` have no tool support. Skills create issues and search markers with `gh`. - CI runs `check` over the whole tree on every PR, not only the changed packages. diff --git a/planning/workflow/vocabulary.md b/planning/workflow/vocabulary.md index 7a0f532e81..a08313ad09 100644 --- a/planning/workflow/vocabulary.md +++ b/planning/workflow/vocabulary.md @@ -19,7 +19,7 @@ Relation kinds and priority tiers are listed here so the full set is in one plac | S8 | implement | `implementation-orchestrate` | | any | router | `research-workflow` (dispatches; owns no stage) | -A concept's `stage` is the stage it is in now: the work of that stage is not finished. It moves to the next stage when the exit criteria in [stages.md](stages.md) are met. Records written by the router use `router` where a stage is expected. +A concept's `stage` is the latest stage that has started on it. The worker of that stage sets it in its first commit; the stage is finished when its exit criteria in [stages.md](stages.md) are met. ## Statement status (`status`) @@ -50,7 +50,7 @@ Roadmap rows in `planning/roadmaps/` use their own status list. They map as foll ## Run status -Where the work for one concept at one stage stands. `status --live` computes it; nobody writes it by hand. The first rule that matches wins. +Where the work for one concept at one stage stands. `claimed`, `running`, `validated`, `blocked` and `abandoned` are recorded by the orchestrator or router ([records.md](records.md#tool-status) says where today); `claimed` and `running` move to the live directory once leases exist. `pushed`, `pr-open` and `merged` are never recorded: `status --live` derives them. When several apply, the first match in this list wins. 1. `abandoned`: the concept history records that this stage's work was stopped on purpose, with a reason. The branch stays. 2. `validated`: the PR merged and the stage's exit criteria were checked afterwards, recorded in history. @@ -62,7 +62,7 @@ Where the work for one concept at one stage stands. `status --live` computes it; 8. `blocked`: a `requires` target has not finished, or the history records a blocking reason. 9. `not-started`: none of the above. -`pushed`, `pr-open` and `merged` come only from git and GitHub, never from a worker's report. The live directory is described in [collaboration.md](collaboration.md#live-coordination). +A worker's own report never sets a run status. The live directory is described in [collaboration.md](collaboration.md#live-coordination). ## Note receipt disposition @@ -94,16 +94,15 @@ Meanings and promotion rules: [decisions.md](decisions.md#source-and-status). ## Identifiers -Tools allocate identifiers. Agents never choose one. +Identifiers come from the tool, never from an agent's guess. `init`, `item add` and `note` allocate them. For a concept or decision added later, take the next free number from `ids` while holding the package's `ids` lease ([collaboration.md](collaboration.md#live-coordination)). - Package: the folder name `<UTC>_research_<slug>`, for example `2026-10-19T06-09-02Z_research_research-intake-to-implementation`. `<UTC>` is `YYYY-MM-DDTHH-MM-SSZ`; `<slug>` is lowercase kebab case. - Segment: `T001`, `T002`, ... in transcript order. A range is `T007-T009`. -- Concept: `C001`, `C002`, ... Allocated by `init`, and later by `ids` when a concept is added. +- Concept: `C001`, `C002`, ... Allocated by `init`. - Item: `C001.2`, `C001.2.1`, ... Allocated by `item add`, never renumbered. Items in the global bucket are `G.1`, `G.1.2`, ... - Global bucket: `G`. Holds the process directives and constraints the user gave about how to work. - Note: the file stem `C001__to__C002__<uuid>`, where `<uuid>` is 32 lowercase hex digits. Allocated by `note`. -- Scan record: the file stem `C002__scan__<UTC>`. Written by reconcile. -- Decision: `D001`, `D002`, ... Allocated by `ids`, never reused. +- Decision: `D001`, `D002`, ... Never reused, even after a reversal. - Branch: `wf/<slug>-c002-s2` for concept C002 at stage S2 of package `<slug>`, and `wf/<slug>-c002.3-s6` for a facet. A follow-up after a merge adds `-2`, `-3`. - Agent name: lowercase kebab case, unique within a run. Used in leases, logs and receipts. - Timestamp: UTC to the second, `2026-10-21T10:00:00Z`. In file and folder names, colons become hyphens: `2026-10-21T10-00-00Z`. From f594f390b5d3e7ca798cee2e9ee1927e52720da1 Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Thu, 22 Oct 2026 01:01:16 -0500 Subject: [PATCH 3/7] docs(repo): rewrite workflow stages with checkable exit criteria stages.md: inputs, outputs, parallelism and exit criteria per stage, the router, and the single-concept path. records.md and vocabulary.md: point the relation and priority links at the numbered headings in DEPENDENCIES.md. --- planning/workflow/records.md | 2 +- planning/workflow/stages.md | 157 ++++++++++++++++++++++++++------ planning/workflow/vocabulary.md | 4 +- 3 files changed, 130 insertions(+), 33 deletions(-) diff --git a/planning/workflow/records.md b/planning/workflow/records.md index 6865a47d64..e00b1d583e 100644 --- a/planning/workflow/records.md +++ b/planning/workflow/records.md @@ -111,7 +111,7 @@ Titles and slugs reject control characters and newlines. - The block is JSON with 2-space indentation, sorted keys and a final newline. Its fence info string is `workflow-state`, which prettier leaves alone. Never wrap state in an HTML comment. - `stage` is the latest stage that has started on the concept. The worker of a stage sets it in its first commit and appends a history entry. - `issues` and `prs` entries are `{"number", "url", "stage", "state"}`, plus optional `title`, `item` (the item the issue or PR is for) and `reason` (why it was implemented, declined or changed). `state` is the last recorded GitHub state (`open`, `closed`, `merged`); `status --live` reads the real one. -- `relations` entries are `{"kind", "to", "reason"}`, plus `rework_if_early` for `recommended-after`, `trigger` for `optional-if`, and an optional `stage` for `requires` ([DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds)). `to` is a concept or item ID in this package, or a repo path or issue URL outside it. +- `relations` entries are `{"kind", "to", "reason"}`, plus `rework_if_early` for `recommended-after`, `trigger` for `optional-if`, and an optional `stage` for `requires` ([DEPENDENCIES.md](../DEPENDENCIES.md#1-dependency-relations)). `to` is a concept or item ID in this package, or a repo path or issue URL outside it. - `history` is append-only, newest last. Each entry has `at`, `stage`, `status`, `note` (why) and `ref` (commit, PR, issue or path), plus `disposition` when the disposition changes and `trigger` when it becomes `deferred`. An entry that sets `deferred` or `rejected` must have a non-empty `note`. - Only the concept's current owner writes the file. The owner may keep supporting material in a sibling folder `concepts/C001-<slug>/`, under the same rule. diff --git a/planning/workflow/stages.md b/planning/workflow/stages.md index 54204b265a..208f63b1be 100644 --- a/planning/workflow/stages.md +++ b/planning/workflow/stages.md @@ -1,35 +1,132 @@ -# Workflow Lifecycle Stages +# Workflow stages -The workflow breaks down work into nine distinct lifecycle stages plus a top-level router. Each stage has defined entry criteria, parallel execution rules, and measurable deliverables. +What each stage takes in, produces and must prove before the next one starts. Stage names, skills and every status value are in [vocabulary.md](vocabulary.md); file formats in [records.md](records.md); the rules every writer follows in [collaboration.md](collaboration.md). Exit criteria name the command that checks them. A command not built yet is listed in [Tool status](records.md#tool-status); until it exists, the stage owner checks the criterion by hand and says so in the PR. ```text -S0: Intake ──> S1: Prepare ──> S2: Research ──> S3: Reconcile - │ -S7: Plan <── S6: Design <── S5: Fanout <── S4: Handoff - │ - └──> S8: Implement +S0 intake → S1 prepare → S2 research → S3 reconcile → S4 handoff → S5 fanout → S6 design → S7 plan → S8 implement + └──────── one agent per concept, all concepts in parallel ────────┘ └ orchestrator + workers ┘ ``` -## Stage Catalog - -| Stage | Name | Skill | Concurrency | Deliverable | -| ---------- | ------------- | ------------------------------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **S0** | **Intake** | `request-intake` | Single agent | Exact sealed transcript (`transcript.txt`), manifest (`package.json`), main reference (`main.md`), initial review order (`design.md`), change log (`changes.md`), and concept stubs (`concepts/C001-<slug>.md`). | -| **S1** | **Prepare** | `research-prepare` | 1 agent per concept | Codebase, doc, and architecture mapping for the concept, research questions, and trigger issue drafting. | -| **S2** | **Research** | `concept-research` | 1 agent per concept | Deep factual research, alternative steelmanning, use-case evaluation, risks with mitigations and fallbacks. | -| **S3** | **Reconcile** | `notes-reconcile` | 1 agent per concept | All incoming directed notes processed, receipts recorded, and concept documents synced. | -| **S4** | **Handoff** | `issue-handoff` (mode: parent) | 1 agent per concept | Self-contained parent GitHub issue defining the scope, goals, and acceptance criteria for investigating and designing the concept. | -| **S5** | **Fanout** | `issue-handoff` (mode: fanout) | 1 agent per parent issue | Granular facet child issues, initial research stages section populated in `design.md`, and an orchestration issue for dispatch. | -| **S6** | **Design** | `design-orchestrate` | 1 orchestrator + N workers | Detailed design records (`doc/<UTC>_design_<slug>/`), decision records (`decisions/D001-<slug>.md`), minimal human-review list, and plan issues. | -| **S7** | **Plan** | `feature-plan` | 1 agent per design | Implementation plan in `planning/plans/<slug>.md` with numbered steps, automated test criteria, stack map, and task issues. | -| **S8** | **Implement** | `implementation-orchestrate` | 1 orchestrator + N workers | Autonomous execution of ready issues across git worktrees, verified merge-commit PRs, final review, and handoff. | -| **Router** | **Workflow** | `research-workflow` | Single agent | Automatic phase discovery from machine state, readiness inspection, and worker dispatch. | - -## Orchestrator vs. Worker Separation - -Orchestrator agents (`research-workflow`, `design-orchestrate`, `implementation-orchestrate`) are strictly coordinators: - -- They inspect git and issue state to compute the unblocked ready frontier. -- They boot worker subagents into dedicated worktrees. -- They monitor publication, verify reported SHAs, and execute merge commits. -- They never implement features, write code, or draft research prose directly. +## When to use the workflow + +Use it when a request covers several topics, is long or garbled, or will lead to many issues. A request that is one clear change goes straight to an issue and a PR. One design question gets a design record under [doc/DOCUMENTATION_PROTOCOL.md](../../doc/DOCUMENTATION_PROTOCOL.md). If a stage's input would not fit one fresh session, split it into more concepts or facets before starting ([collaboration.md](collaboration.md#the-rules), rule 8). + +## Every stage + +- The owner works in its own worktree and branch, pushes the empty branch first and opens a PR after its first commit ([collaboration.md](collaboration.md#the-rules)). +- In its first commit the owner sets the concept's `stage` and appends a history entry ([records.md](records.md#concept-file)). +- "Merged" in an exit criterion means the PR merged and its head SHA is an ancestor of the trunk. +- Each stage keeps everything earlier stages wrote. It refines items with `item set-status` and `item add`; it never deletes text. +- The worker ends with the turn report: branch, PR URL, last pushed SHA, what is verified, what is not. + +## S0 intake + +- Skill: `request-intake`. Parallelism: one agent. Read-only helpers may propose outline parts; only the intake agent writes. +- Input: the request bytes as received, with their source, an expected SHA-256 when one is known, and whether they may be public. +- Output: the package (`transcript.txt`, `package.json`, `main.md`, `design.md`, `changes.md`, one concept file per concept) with every concept at `S0`, status `created`, disposition `proposed`. `main.md` has the introduction, preliminary thoughts per concept, the garbled-input register and the views. Ideas the request only hints at become `hint` concepts or items labelled inference; nothing is dropped at this stage. +- Owner: the intake agent owns the whole package folder until its PR merges. Afterwards each concept file belongs to the owner of its next stage, and `main.md` and `design.md` are wide files. +- Exit criteria: + - `check --package <dir>` passes: the transcript hash matches `package.json` (and `expected_sha256`), every segment is covered by a concept or `G`, every excerpt is exact, every value is in the vocabulary, and the views are current. + - The intake PR is merged. +- Next: the router starts S1 for every concept `ready` returns. `hint` concepts wait until a note or a human answer changes their type. + +## S1 prepare + +- Skill: `research-prepare`. Parallelism: one agent per concept, all ready concepts at once up to the cap. +- Input: the concept file, its section in `main.md`, the transcript segments it cites, and the repo. +- Output, in the concept file only: "Current repository state" (the code, docs and designs the concept touches, as links), "Research questions" (numbered, each answerable), more excerpts if the concept needs other segments, and readings of garbled tokens it relies on. Outside the file: the issue `Research: <concept> (<slug>·C001)` with its marker, self-contained so a zero-context agent can run S2 from its URL. Changes it wants in another concept go out as notes. +- Exit criteria: + - The two sections are filled; `check` finds no placeholder text in them. + - The research issue exists, its marker is found by a search, and it is in the concept's `issues` with stage `S1`. + - The PR is merged. +- Next: the merged PR and the open research issue. The router dispatches S2, or anyone can pick up the issue. + +## S2 research + +- Skill: `concept-research`. Parallelism: one agent per concept. +- Input: the research issue URL. +- Output, in the concept file: "Research" (the request restated, feasibility, options with a steelman each, prior art, example projects, user reports, risks with mitigations, an answer or an open reason for every research question), "Sources" (every link used, as returned by the tool that fetched it), and the concept's "Change log". Items are refined with `item add` and `item set-status` through a PR to `main.md`. Notes go to other concepts as soon as they are known, in note-only PRs. +- Exit criteria: + - Every research question has an answer or an open reason; "Research" and "Sources" are not empty. + - Every note this concept sent is on the trunk or in an open PR. + - The PR is merged. +- Next: S3 for this concept. The same agent may run it in the same session when it fits. + +## S3 reconcile + +- Skill: `notes-reconcile`. Parallelism: one agent per concept. +- Input: every note addressed to the concept, on the trunk and on every `origin/*` ref (`check --remote-notes`). +- Output: one receipt per note, the concept file updated where notes were incorporated, and the "Notes" section listing each note and its disposition. The scanned refs and SHAs are recorded ([records.md](records.md#receipts)). +- Exit criteria: + - `check --package <dir> --require-resolved` passes. + - `check --remote-notes` reports nothing pending for this concept. + - The PR is merged. +- Next: S4. A note that arrives later reopens S3 for its receiver; if S4 or later already ran, the reconcile owner updates the affected issues. + +## S4 handoff + +- Skill: `issue-handoff`, mode `parent`. Parallelism: one agent per concept. +- Input: the reconciled concept file. +- Output: the issue `Handoff: <concept> (<slug>·C001)`. It asks for the concept to be investigated and planned, in part or whole, lists the facets to research with a short description each, and links everything a zero-context agent needs. The concept's `issues` gains it. +- Exit criteria: the issue exists with its marker and every body section [records.md](records.md#issues) requires; the PR that records it is merged. +- Next: the open parent issue. An agent with no other context runs S5 from its URL. + +## S5 fanout + +- Skill: `issue-handoff`, mode `fanout`, then mode `orchestration`. Parallelism: one agent per parent issue. +- Input: the parent issue URL. +- Output: one `Design:` child issue per facet, each a full handoff with blocked-by and parallel-safe-with, and each facet recorded as an item (`C001.3`) so the issue can name it. Then the orchestration issue `Design: orchestrate <concept> (<slug>·C001)`, listing the children in priority order and in waves ([ordering.md](ordering.md)). The design's "initial research stages" in `design.md` list every issue for the concept with a short description and its order. +- Exit criteria: every facet in the parent issue links to its child issue; every child and the orchestration issue have markers; the concept's `issues` lists them with stage `S5`; the PR is merged. +- Next: the open orchestration issue starts S6. + +## S6 design + +- Skill: `design-orchestrate`. Parallelism: one orchestrator, plus one worker per child issue up to the cap, plus read-only reviewer, critic and investigator subagents. +- Input: the orchestration issue URL. +- Output: a design record folder `doc/<UTC>_design_<slug>/` per concept (each facet worker owns one file in it; one consolidation worker writes the main document); decision records in the package; `human-review.md`; the issue `Plan: <concept> (<slug>·C001)`. The concept's disposition becomes `accepted`, `deferred` or `rejected`. +- Owner: workers write; the orchestrator only merges, files the decision records the reviewers return, and keeps issues and state current ([collaboration.md](collaboration.md#the-rules), rule 7). +- Exit criteria: + - Every child issue is closed by a merged PR. + - Every `conflicts-with` pair in scope has a decision record, and the challenge pass has run on every decision ([decisions.md](decisions.md)). + - `human-review.md` is current and the plan issue exists. +- Next: the open plan issue starts S7. Preliminary decisions do not block it; a human reversal later triggers scoped rework. + +## S7 plan + +- Skill: `feature-plan`. Parallelism: one agent per design. +- Input: the plan issue URL, the design record and its decisions. +- Output: `planning/plans/<slug>.md` from the [plan template](../templates/plan.md), with granular steps in waves ([ordering.md](ordering.md#plans)); one `Implement:` issue per step whose blocked-by matches the plan; the orchestration issue `Implement: orchestrate <concept> (<slug>·C001)`; a row in the plan catalog. Disposition becomes `planned`. +- Exit criteria: + - Every step has an issue with a marker, and each issue's blocked-by equals the step's `requires`. + - No two steps in one wave share a file; shared names and interfaces are pinned in the plan before wave 1. + - Every `stated` or `human-confirmed` decision and every accepted item of the concept is cited by at least one step ([decisions.md](decisions.md#coverage)). + - The PR is merged. +- Next: the open implementation orchestration issue starts S8. + +## S8 implement + +- Skill: `implementation-orchestrate`. Parallelism: one orchestrator plus one worker per ready step, up to the cap. +- Input: the orchestration issue URL and the plan. +- Output: merged PRs, the plan's progress kept current, the concept's disposition `implemented`, and its roadmap row moved to Done. +- Exit criteria: + - Every step issue is closed by a merged PR. + - The profile's `validation_commands` pass on the trunk after the last merge. + - One fresh-context review ran after integration; its findings are fixed or filed as issues. +- Next: none. A package is finished when every concept is `implemented`, `deferred`, `rejected` or `superseded`. + +## Router + +- Skill: `research-workflow`. Parallelism: one. +- Input: a package path, or nothing (it finds packages under `requests_root`). +- Output: dispatch decisions only. It runs `status --live` and `ready`, starts the stage skill for each ready concept up to the cap, restarts stalled workers, and reports what is blocked and why. It writes no content. +- Exit criteria: every ready concept has a running worker, or nothing is ready and the report names each blocker. +- Next: run it again when a PR merges, a worker ends, or a heartbeat lapses. + +## A single concept + +The layout does not change: one concept file, the same views. The path is shorter in sessions, not in records: + +- S1, S2 and S3 may run in one session by one agent. With no sibling concepts, S3 is the remote-notes scan, recorded in the S3 history entry. +- S4 and S5 may run in one session. +- `design.md` has one wave and needs no review order. +- S6 to S8 do not shrink: their size follows the number of facets and steps, not concepts. diff --git a/planning/workflow/vocabulary.md b/planning/workflow/vocabulary.md index a08313ad09..4876d25e96 100644 --- a/planning/workflow/vocabulary.md +++ b/planning/workflow/vocabulary.md @@ -82,11 +82,11 @@ Meanings and promotion rules: [decisions.md](decisions.md#source-and-status). ## Relation kinds -`requires`, `recommended-after`, `shares-files-with`, `conflicts-with`, `enables`, `optional-if`, `supersedes`, `contradicts`, `part-of`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#relation-kinds). +`requires`, `recommended-after`, `shares-files-with`, `conflicts-with`, `enables`, `optional-if`, `supersedes`, `contradicts`, `part-of`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#1-dependency-relations). ## Priority -`crucial`, `recommended`, `contingent`, `unspecified`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#priority-tiers). +`crucial`, `recommended`, `contingent`, `unspecified`. Defined in [DEPENDENCIES.md](../DEPENDENCIES.md#2-priority-tiers). ## Horizon From 461bf6c4b8e106c7df566b2780bc27435d8836d9 Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Thu, 22 Oct 2026 01:06:29 -0500 Subject: [PATCH 4/7] docs(repo): rewrite collaboration rules, live coordination and failure scenarios --- planning/workflow/collaboration.md | 93 ++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/planning/workflow/collaboration.md b/planning/workflow/collaboration.md index e2c6031a6c..3b8279a4da 100644 --- a/planning/workflow/collaboration.md +++ b/planning/workflow/collaboration.md @@ -1,32 +1,61 @@ -# Multi-Agent Collaboration Protocol - -This document defines the 10 binding collaboration rules for orchestrators and worker subagents operating across parallel git worktrees. - -## The 10 Collaboration Rules - -1. **One Writer Per File**: Every document, concept file, outgoing note, and receipt has exactly one owning writer at a time. Wide shared files (`main.md`, `design.md`, `AGENTS.md`, `doc/README.md`, catalogs) must only be modified via pull requests under active mutex leases. -2. **Add-Only Records**: Cross-agent communication must use new files (`notes/`, `receipts/`, `decisions/`) or union-merged lines (`changes.md`). Never append directly to the end of a shared file owned by another agent. -3. **Worktree Boot Protocol**: Every parallel worker must execute in a dedicated worktree on a dedicated branch branched from the declared integration baseline. - - Sourcing the local git environment: `source /home/user/.local/share/plaza-tools/git-env.sh`. - - Disabling automatic garbage collection: `git config --worktree gc.auto 0`. - - Pushing an empty branch to origin immediately upon creation to reserve the ref: `git push -u origin <branch>`. - - Making the first commit and opening a PR before proceeding with extensive changes. - - Guardrails: strictly no `git stash` (use WIP commits), no `git reset --hard`, no rebase, no force-push, no `sudo git`, and stage explicit paths only (`git add -- <paths>`). -4. **Dead Branch on Merge**: Because repository settings automatically delete head branches upon merge, merged branches are immediately considered dead. Post-merge follow-up work must be performed on a newly branched ref (e.g. `<branch>-2`). -5. **Live Coordination & Atomic Leases**: Non-committed live coordination data lives in `$(git rev-parse --git-common-dir)/agent-work/<package>-<stage>/`: - - Mutex locks use atomic directories: `mkdir locks/<resource>.lock/` containing an `owner` file (`<name> <acquired> <expires> <purpose>`) with a 20-minute expiry and atomic rename-based takeover. - - Append-only heartbeat logs: `<name>.md` with lines `<name> <UTC> <kind>: <text>`, beginning with `start` and ending with `end`. -6. **Worker Completion Report**: Every worker subagent must terminate with a structured report containing: - - Branch name and open PR URL. - - Exact last pushed commit SHA (`git rev-parse HEAD`). - - Verified automated test commands and output. - - List of unverified assumptions or open questions. -7. **Orchestrator Merge Gate**: An orchestrator merges a worker's PR only when: - - The remote ref (`git ls-remote origin <branch>`) matches the open PR's head SHA and matches the worker's reported last SHA. - - The worker subagent is confirmed idle/finished. - - Required status checks are green. - - Merging uses a merge commit (`--no-ff`), followed by verification that the commit is an ancestor of the base (`git merge-base --is-ancestor`). - - Stalled workers (no heartbeat for 20 minutes, no active lease, no open PR) are restarted with their original brief on the same branch. -8. **Ready Frontier Dispatch**: A concept is ready to dispatch only when all of its hard prerequisites (`requires`) are fully merged, no active lease exists, and no open PR or remote branch is currently working on it. Maximum concurrency is capped by `max_parallel_writers` (default: 5). -9. **Context Pointers Over Pasted Summaries**: Orchestrators communicate with subagents using file paths, commit SHAs, and issue URLs. They avoid pasting large text transcripts or intermediate summaries into prompts. -10. **Green on Own Base**: Every PR must pass all required checks against its own base. CI checks validate only the packages modified by the PR; global whole-tree audits run on scheduled workflows. +# Collaboration + +How parallel agents share one repository without losing work. The skills cite these rules by number ("collaboration rule 7") instead of restating them. File formats are in [records.md](records.md), values in [vocabulary.md](vocabulary.md), and the base branch, git environment and cap in the profile ([profile.md](profile.md)). + +## The rules + +1. **One writer per file.** A concept file, its outgoing notes, its receipts and a live log each have one writer at a time; [records.md](records.md#package-layout) says who. Wide files (`main.md`, `design.md`, `AGENTS.md`, `doc/README.md`, catalogs, roadmaps) change only through a PR from your own branch. +2. **Add-only records.** What several agents add to is a set of new files (notes, receipts, decisions) or one line each in the union-merged `changes.md`. Never append to the end of a shared file by hand. +3. **Worker boot.** Every writer starts in its own worktree and branch: + + ```sh + source /home/user/.local/share/plaza-tools/git-env.sh # commits fail without it + git fetch -q origin + git worktree add -b <branch> <worktree_root>/<name> origin/<base> + cd <worktree_root>/<name> && git push -u origin <branch> + ``` + + - Push the empty branch before editing, so the name is taken. Open the PR after the first commit; GitHub refuses a PR with no diff. + - Never `git stash` (all worktrees share one stash; use a WIP commit), `gc` or `prune`, `sudo`, force push, rebase, or `git add .` (stage explicit paths). Merge commits only. + - Merge `origin/<base>` into your branch, and push, before opening the PR and again before it lands. Conflicts are then resolved in your worktree, and `changes.md` merges with git's union driver, which GitHub's merge button may skip. + +4. **A merged branch is dead.** GitHub deletes it on merge. Follow-up work goes on a new branch (`-2`, `-3`) and a new PR. Never base a PR on a branch that will be deleted first: target the trunk, or an `integration/` branch that merges last. +5. **Live state stays outside git.** Leases, heartbeats and push SHAs go in the live directory ([Live coordination](#live-coordination)). Facts that must last (notes, receipts, decisions, history) go in git. +6. **Final message.** Every worker ends with its branch, PR URL, last pushed SHA, what it verified (commands and real output) and what it did not. +7. **Orchestrators only merge.** Workers write content. The orchestrator merges, files the decision records reviewers return, and keeps issues and state current. It never pushes to a worker's branch; it sends the worker back. + - Merge a worker PR only when the worker has finished (its log ends with `end`), the SHA triple check holds (`git ls-remote origin <branch>` = PR head = reported SHA), and the PR is mergeable, not a draft, based on the trunk, green, and inside the worker's owned paths. Afterwards confirm `git merge-base --is-ancestor <sha> origin/<trunk>`. + - Restart rule: a worker with no log line for 20 minutes, no live lease and no open PR is stalled. Restart it with its original brief on the same branch, merging what is there, never resetting. + - A branch with commits ahead of the trunk and no PR is an orphan. Restart its worker, or log it abandoned; never delete it. + - Commands: [merge-and-restart.md](../../.agents/skills/research-workflow/references/merge-and-restart.md). +8. **Dispatch only what is ready, within the cap.** A unit starts only when `ready` lists it: every `requires` target merged, no live lease, no open PR or pushed branch for it ([ordering.md](ordering.md#waves)). At most `max_parallel_writers` writers run at once (profile; 5). Read-only reviewers hold no worktree or lease and do not count. Each unit gets one fresh session; size it to fit one, and split it if it would not. +9. **Paths, not summaries.** Pass file paths, SHAs and issue and PR URLs between agents. Never paste a summary of something the receiver can read itself. +10. **Every PR is green on its own base.** A failure counts as pre-existing only if the base's latest run shows it. CI is meant to check only the packages a PR changes, with a scheduled job for the whole tree; today it checks the whole tree on every PR ([Tool status](records.md#tool-status)). + +## Live coordination + +Leases and heartbeats change every few minutes and every worktree must see them at once, so they live in the git common directory, which all worktrees of a clone share. Nothing here is committed and nothing here is the record. + +- **Directory.** `$(git rev-parse --git-common-dir)/agent-work/<package>-<stage>/` per stage, `agent-work/<package>/` for package-wide locks, and `agent-work/<package>-router/` for the router. If the common directory is not writable, use the profile key `agent_work_dir`. +- **Locks.** `locks/<resource>.lock/`, created with `mkdir`, which fails when the directory exists, so exactly one writer gets it. It holds a file `owner` with one line `<name> <acquired> <expires> <purpose>`, times in UTC. + - A lease lasts 20 minutes. The holder renews it before then by rewriting `<expires>`, and removes the directory when done. + - Anyone may take over an expired lease: rename the directory to `<resource>.lock.stale-<UTC>` (only one rename succeeds), then create it again. + - Resources: `<C001>` for a concept at its stage, taken before the worker is dispatched; package-wide `ids` while allocating a concept or decision ID; package-wide `file-<path>` for a wide file, with each `/` written as `__`. + - Until `lease acquire|release|list` exists ([Tool status](records.md#tool-status)), make the directory and write `owner` by hand. +- **Heartbeat logs.** `<name>.md`, one per writer, appended only by that writer. Each line is `<name> <UTC> <kind>: <text>`. + - Worker kinds: `start` first, `heartbeat` at least every 10 minutes, `push <sha>` after every push, `end` last. + - Router kinds: `dispatch`, `merge`, `restart`, `abandoned`. The router keeps each worker's brief in its own directory as `<worker>.md`, so a restart can reuse it. + +## Failure scenarios + +Each was found in a review of the first version of this workflow; the prevention is the rule or mechanism above that stops it. + +- **Every status change edits one shared state block, so parallel PRs always conflict.** Per-concept state blocks with one writer, generated views, and `changes.md` lines (rules 1, 2). The tool on `main` still uses one block ([Tool status](records.md#tool-status)). +- **`ready` lists concepts that are already running, so work is dispatched twice.** `ready` reads the trunk and skips leased and running units; dispatch takes the lease first (rule 8). +- **A worker commits after its PR merged, or reports done without pushing.** Final message with the last pushed SHA, the SHA triple check, dead merged branches, and the orphan sweep (rules 4, 6, 7). +- **Auto-delete strands PRs stacked on a branch that merges first.** Target the trunk or an `integration/` branch that merges last (rule 4). +- **Notes on unmerged branches are invisible, so reconcile reports everything resolved.** `check --remote-notes` scans every `origin/*` ref, note-only PRs merge fast, receipts record the scanned SHAs, and a later note reopens S3 ([records.md](records.md#receipts)). +- **Claims exist only in git, so two orchestrators take the same unit or file.** `mkdir` leases, including `file-<path>` locks for wide files (rule 5). +- **The shared stash, a missing git environment, or `gc` breaks worktree isolation.** The boot block and its prohibitions (rule 3). +- **Whole-tree validation couples unrelated workers, so red becomes normal.** Green on its own base, changed-package checks, and the pre-existing failure rule (rule 10). +- **Appends at the end of wide files conflict on every parallel PR.** Per-concept sections, one file per entry, and `merge=union` only for line lists (rules 1, 2). +- **No machine-readable stage or liveness, so the orchestrator stalls or starts implementing.** Enumerated run statuses derived from git and GitHub ([vocabulary.md](vocabulary.md#run-status)), heartbeats, the restart rule, and orchestrators that only merge (rules 5, 7). From 0cabcdf7c88dea6bbadc5582892662728410c993 Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Thu, 22 Oct 2026 01:06:54 -0500 Subject: [PATCH 5/7] docs(repo): rewrite decision sources, coverage, disagreement and human review --- planning/workflow/decisions.md | 96 ++++++++++++---------------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/planning/workflow/decisions.md b/planning/workflow/decisions.md index b285ef9111..493394fc17 100644 --- a/planning/workflow/decisions.md +++ b/planning/workflow/decisions.md @@ -1,79 +1,47 @@ -# Decision Protocol & Human Review +# Decisions -This document defines how technical disagreements, trade-offs, and architecture decisions are evaluated, recorded, and escalated during research and design. +How a choice is recorded, who may confirm it, how disagreements are settled without stopping work, and what a human is asked. The record format is in [records.md](records.md#decisions) and the [decision template](templates/decision.md). -## 1. Decision Records (`decisions/D001-<slug>.md`) +## Source and status -Every architectural choice, technology selection, or contested trade-off is recorded as an explicit decision document: +Source says where a decision came from: -```markdown -# D001: Structured Storage Engine Selection +- `stated`: the transcript says it. Cite the segments: `stated (T051)`. +- `inferred`: it follows from what is stated or from the repository's existing rules. The rationale names what it follows from. +- `agent-preliminary`: an agent chose it so work could continue. +- `human-confirmed`: a human approved it. Cite the URL of their message. -- Status: preliminary | confirmed | reversed -- Source: stated | inferred | agent-preliminary | human-confirmed -- Date: 2026-10-19T06:09:02Z -- Affects: C001, C004 -- Reversal cost: High (requires database migration) +Status says whether it is settled: -## Question +- `preliminary`: in force and open to change. `inferred` and `agent-preliminary` decisions start here. +- `confirmed`: settled. `stated` and `human-confirmed` decisions are confirmed. +- `reversed`: no longer in force. A dated line under Choice says what replaced it. -What storage backend should index world state events? +Only a human confirms an `agent-preliminary` decision. No agent, reviewer or later stage sets `human-confirmed`, however strong the evidence; an agent may record a human's confirmation or reversal by citing their message. Agents may change a preliminary choice (after the challenge pass, for example) by adding a dated line under Choice. -## Options Considered +## Coverage -### Option A: SQLite via Rusqlite +- Every decision has a stable ID, `D001`, `D002`, ..., taken from `ids` under the package's `ids` lease ([collaboration.md](collaboration.md#live-coordination)). An ID is never reused, even after a reversal. +- Every downstream artifact cites by ID the decisions it depends on: design sections, plan steps, issues and PR descriptions. The decision's `Affects` field lists the concepts and items it touches. +- A plan cites every `stated` or `human-confirmed` decision in at least one step ([S7](stages.md#s7-plan)). +- When a decision is reversed, `git grep -l D007` lists exactly what must be reworked. Rework is one issue per affected artifact, citing the reversal; nothing else is touched. -- Steelman: Zero-dependency, embedded, robust file locking, mature ecosystem. -- Downsides: Concurrency limits on multi-writer setups. +## Disagreement -### Option B: PostgreSQL / Neon +Two workers with conflicting results, or a `conflicts-with` pair in scope at S6, go through these steps. No one waits for a human. -- Steelman: Full network concurrency, branching support, scalable analytics. -- Downsides: External network dependency, operational overhead. +1. The orchestrator does not decide. It gives the merged material from both sides to three fresh, read-only subagents in parallel, using the prompts in [templates/prompts/](templates/prompts/): the [reviewer](templates/prompts/reviewer.md) checks the facts, the [critic](templates/prompts/critic.md) attacks each side's reasoning, and the [investigator](templates/prompts/investigator.md) looks for options nobody considered. +2. They decide everything the evidence settles, taking the option best practice would choose when in doubt, and list as toss-ups only choices that are genuinely balanced and costly to reverse. +3. The orchestrator files each decision as a record with `Source: agent-preliminary` and `Status: preliminary`. Work continues on the preliminary choice at once; toss-ups go to [human review](#human-review). +4. Challenge pass: before S6 closes, one fresh subagent with the [challenge-pass prompt](templates/prompts/challenge-pass.md) asks of every decision whether its options were too narrow. Each decision it flags is reopened with the investigator prompt, and the outcome is a dated line under Choice. -## Choice & Rationale +## Human review -Option A (SQLite). The platform requires self-contained offline execution; network DB introduces unnecessary latency for local nodes. +`human-review.md` ([template](templates/human-review.md)) is regenerated from the decision records whenever one changes. -## Consequential Human Review Items - -None; standard embedded default. -``` - -## 2. Source Attribution & Promotion Rules - -- **`stated`**: Explicitly commanded by the user in the transcript. -- **`inferred`**: Deduced logically from stated requirements or existing codebase patterns. -- **`agent-preliminary`**: Decided autonomously by a subagent or reviewer to avoid stalling progress. -- **`human-confirmed`**: Explicitly approved by the human maintainer. - -**Promotion Invariant**: Downstream automated agents may never promote an `agent-preliminary` decision to `human-confirmed`. Only explicit human interaction updates this field. - -## 3. Disagreement Protocol - -When two concept researchers or subagents arrive at conflicting recommendations or mutually exclusive designs: - -1. **Do Not Stall**: The orchestrator does not halt work waiting for user arbitration. -2. **Launch Reviewer & Critic Subagents**: The orchestrator dispatches read-only reviewer and critic subagents (using `planning/workflow/templates/prompts/reviewer.md` and `critic.md`), providing the full merged context from both workers. -3. **Analyze and Decide**: The critic identifies obvious decisions where one option clearly aligns with repository invariants. The orchestrator adopts the most standard, reversible option as `agent-preliminary`. -4. **Log Consequential Items**: If the decision represents an irreversible architectural fork with meaningful trade-offs, it is recorded in `human-review.md`. Work proceeds on the preliminary assumption. - -## 4. The Challenge Pass - -Before concluding Stage 6 (Design), the orchestrator launches a fresh-context investigator subagent to inspect all decisions. The investigator specifically checks: - -- Were the options framed too narrowly? -- Was an obvious third alternative missed? -- Were the downsides of the chosen option understated? - -If a decision is found to have been artificially constrained, it is reopened with an investigator subagent before final plan handoff. - -## 5. Traceable Reversal - -Because every decision record lists the concepts and files it affects (`Affects: C001, C004`), if a human maintainer reverses a decision (e.g. changing D001 from SQLite to PostgreSQL): - -```sh -git grep -l "D001" -``` - -immediately identifies the exact set of documents, plans, and code files that require rework, avoiding uncoordinated drift. +- Minimal: list only preliminary decisions whose options are genuinely balanced and whose wrong choice would be costly to reverse. Obvious decisions are made and recorded, not listed. "None" is a valid list. +- Batched: one list for the package, never questions one at a time. +- Ranked by effect, most consequential first. +- Defaults: each item names the choice already in effect, the alternatives and the cost of reversing. +- Never re-ask what the transcript states or a `stated` or `human-confirmed` decision already answers. +- Nothing waits on the answers. A reversal starts rework scoped as in [Coverage](#coverage). From 90c94ffde7c9f4abeb8eb5a954321a59acc322bc Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Thu, 22 Oct 2026 01:07:38 -0500 Subject: [PATCH 6/7] docs(repo): rewrite ordering edges, waves and plan step format --- planning/workflow/ordering.md | 76 +++++++++++++++-------------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/planning/workflow/ordering.md b/planning/workflow/ordering.md index fec31b8bfa..0992779fa1 100644 --- a/planning/workflow/ordering.md +++ b/planning/workflow/ordering.md @@ -1,58 +1,48 @@ -# Scheduling, Ordering & Frontier Dispatch +# Ordering -This document details how dependency graphs are evaluated into execution waves and how the ready frontier is computed for autonomous workers. +How relations between concepts and steps become waves of parallel work, and how a plan writes them down. Who may dispatch, and how many at once, is collaboration rule 8 ([collaboration.md](collaboration.md#the-rules)). -## 1. Graph Semantics +## Edges -The workflow graph model uses typed edges from `planning/DEPENDENCIES.md` to establish execution order: +Relation kinds and priority tiers are defined in [DEPENDENCIES.md](../DEPENDENCIES.md#1-dependency-relations). Scheduling uses them like this: -- **`requires` (Hard Blocker)**: Defines the topological sort order. A concept or step with unsatisfied `requires` edges cannot be dispatched under any circumstances. -- **`recommended-after` (Soft Sequencing)**: Recommends that source follow target to minimize rework. If workers are idle and target is still in progress, source may proceed, provided its task brief explicitly states the assumptions it is making. -- **`shares-files-with` (Mutual Exclusion)**: Two tasks that modify the same files are assigned to different waves or locked under a shared mutex so they never run concurrently in separate worktrees. +- `requires`: a hard blocker. The source is not ready until the target has merged, or reached the `stage` the relation names. Cycles are rejected. +- `recommended-after`: a soft edge. The source goes one wave after the target, but may start early when writers are idle. Its `rework_if_early` text says what may need redoing, and the worker's brief states the assumption it runs on. +- `shares-files-with`: never in the same wave. +- `conflicts-with`: settled by the decision protocol ([decisions.md](decisions.md#disagreement)) before either side is planned. +- `optional-if`: scheduled only once its `trigger` holds. +- The other kinds do not change the order. -## 2. Wave Scheduling +## Waves -Orchestrators group work into waves: +`ready` turns the edges into waves: -```text -Wave 0: Shared Contracts & Foundations - ├── C001: Data model & type definitions - └── C002: Core schema migration - │ -Wave 1: Parallel Feature Implementations [P] - ├── C003: Ingest pipeline worker - ├── C004: HTTP presentation presenter - └── C005: Event stream subscriber - │ -Wave 2: Integration & Verification - └── C006: End-to-end integration test & validation -``` - -- **Wave 0 (Foundations)**: Shared types, schema, and API contracts must be merged first. -- **Wave 1 (Parallel Builders)**: Independent features run simultaneously across parallel worktrees. Each step is marked `[P]` in implementation plans. -- **Wave 2 (Integration)**: Final verification and cross-cutting documentation. - -## 3. Ready Frontier Calculation - -At any given point during execution, the orchestrator computes the **Ready Frontier** using `scripts/research_workflow.py ready`: +1. Drop units that are finished at their stage, and units that are claimed or running ([run status](vocabulary.md#run-status)). +2. Wave 1 is every remaining unit whose `requires` targets have merged on `origin/<trunk>`. Later waves follow `requires` in topological order. +3. Two units in one wave that share files are split; the later one moves to the next wave. A `recommended-after` source moves one wave past its target. The `waves` view shows each such cost under the wave that pays it ([records.md](records.md#generated-views)). +4. The router dispatches wave 1 up to the cap, taking each unit's lease first and skipping any unit whose lease is held. -1. **Exclude Completed Concepts**: Concepts with status in `COMPLETE` (`done`, `completed`, `merged`, `validated`) are removed. -2. **Exclude Active Concepts**: Concepts with status in `ACTIVE` (`running`, `active`, `in-progress`) are removed to prevent duplicate dispatch. -3. **Filter by Prerequisites**: A concept is ready if and only if all of its `requires` dependencies have reached `COMPLETE` status. -4. **Partition by Concurrency Fences**: If two ready concepts share a `shares-files-with` edge, only one is scheduled in the immediate wave; the other waits for the next wave. -5. **Lease Guard**: Before dispatching, the orchestrator acquires a live lease in `agent-work/<pkg>-<stage>/locks/concept-<id>.lock`. If a lease already exists on disk, dispatch is skipped. +Shared names, types and interfaces are pinned before wave 1 starts, in the plan or by a first step that every parallel step requires, so parallel workers build against one contract. Read-only reviewers are not scheduled; they run whenever needed. Today `ready` reads the working tree and knows no leases ([Tool status](records.md#tool-status)). -## 4. Implementation Plan Output Format +## Plans -When generating an implementation plan in Stage 7 (`feature-plan`), steps are formatted with explicit parallel markers: +A plan ([template](../templates/plan.md)) groups its steps by wave. Each step is one PR and one `Implement:` issue, and carries these fields: ```markdown -### Phase 1: Core Surface Presenters +### Wave 2 -- [ ] **1.1.1** [P] Define presenter traits in `src/presenter.rs`. (Done when: `cargo test --lib presenter` passes). -- [ ] **1.1.2** [P] Implement terminal ANSI screen renderer in `src/terminal.rs`. (Requires: 1.1.1; Done when: unit tests pass). -- [ ] **1.1.3** [P] Implement web canvas presenter in `web/src/screen.ts`. (Requires: 1.1.1; Done when: vitest passes). -- [ ] **1.1.4** Integration presenter parity check. (Requires: 1.1.2, 1.1.3; Done when: parity suite passes). +3. **[P] Web canvas presenter.** Implement the presenter in `web/src/screen.ts`. + - Tier: recommended. Goal: the web view shows what the terminal shows. Enables: 5, C006. + - Requires: 1. After: 2, rework if early: the shared escape table may change. + - Files: `web/src/screen.ts`. Cites: D002, C004.3. + - Done when: `vitest run screen` passes. ``` -`[P]` explicitly tells the implementation orchestrator which tasks can be fanned out across parallel worktrees simultaneously. +- `Requires:` hard blockers, by step number. The step's issue has exactly these as blocked-by, and a step is never in the same wave as one it requires. +- `After:` soft edges, each with what may need redoing if the step starts before its target finishes. +- `[P]`: the step may run in parallel with the other `[P]` steps in its wave; they share no files and none requires another. A step without `[P]` runs alone in its wave, such as an integration or migration step. +- `Tier:` `crucial`, `recommended` or `contingent`. Crucial steps are dispatched first in a wave. A contingent step names the trigger that schedules it and does not start before the trigger holds. +- `Goal:` what is true after the step that is not true before. `Enables:` the later steps and concepts it unlocks, so a reviewer can see why it exists and what stalls if it slips. +- `Files:` every path the step writes. Two steps in one wave never share one. +- `Cites:` the decisions and items the step implements ([decisions.md](decisions.md#coverage)). +- `Done when:` a check that a test or CI job runs. From 7c5b50c4c4c1740c8f86bbadcfc0306ce654e4e3 Mon Sep 17 00:00:00 2001 From: Drewry Pope <drewrypope@gmail.com> Date: Thu, 22 Oct 2026 01:07:45 -0500 Subject: [PATCH 7/7] docs(repo): link terminal statuses to the existing immutability section --- planning/workflow/vocabulary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planning/workflow/vocabulary.md b/planning/workflow/vocabulary.md index 4876d25e96..d2e9ff29fc 100644 --- a/planning/workflow/vocabulary.md +++ b/planning/workflow/vocabulary.md @@ -31,7 +31,7 @@ What we know about a statement: a concept or an item. - `superseded`: replaced by a newer item, concept or decision. The trail text names it. - `retracted`: withdrawn because it was wrong, misheard or is no longer wanted. -`superseded` and `retracted` are terminal. The record keeps them, but they are excluded from default reading ([retention](../DOCUMENTATION_ARCHITECTURE.md#retention)). +`superseded` and `retracted` are terminal. The record keeps them, but they are excluded from default reading ([immutability](../DOCUMENTATION_ARCHITECTURE.md#4-immutability-vs-maintained-documents)). ## Disposition (`disposition`)