From bee18afba0962254d998b8b41c9693378ec0b48c Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 21 Oct 2026 05:02:05 -0500 Subject: [PATCH 1/4] docs: deepen research-workflow router skill --- .agents/skills/research-workflow/SKILL.md | 102 +++++++++++++----- .../references/merge-and-restart.md | 90 ++++++++++++++++ .../research-workflow/references/routing.md | 67 ++++++++++++ .../references/tool-fallbacks.md | 21 ++++ .../references/worker-brief.md | 45 ++++++++ 5 files changed, 298 insertions(+), 27 deletions(-) create mode 100644 .agents/skills/research-workflow/references/merge-and-restart.md create mode 100644 .agents/skills/research-workflow/references/routing.md create mode 100644 .agents/skills/research-workflow/references/tool-fallbacks.md create mode 100644 .agents/skills/research-workflow/references/worker-brief.md diff --git a/.agents/skills/research-workflow/SKILL.md b/.agents/skills/research-workflow/SKILL.md index 8fbd824df5..d194f78219 100644 --- a/.agents/skills/research-workflow/SKILL.md +++ b/.agents/skills/research-workflow/SKILL.md @@ -1,49 +1,97 @@ --- name: research-workflow -description: Discover the current stage of a research collection, inspect readiness, and dispatch the next lifecycle stage or worker. Use when resuming work on a request, finding what is unblocked, or checking package status. +description: Route a research package (doc/_research_/) through the research-to-delivery workflow. Reads machine state with the workflow tool, finds each concept's stage, dispatches the stage skill to parallel worker subagents, verifies and merges their PRs, restarts stalled workers and stops where the user asked. Use when asked to run, resume, continue or check a research workflow or package, to find what is ready, running or blocked, to take a request from intake through research, design, planning or implementation, or to run the next stage for every ready concept. It never writes the content itself; for one stage's own work load that stage's skill (request-intake, research-prepare, concept-research, notes-reconcile, issue-handoff, design-orchestrate, feature-plan, implementation-orchestrate). --- -# Research Workflow Router +# Research workflow (router) -This skill inspects collection state and routes work to the appropriate lifecycle skill. Detailed contracts live in [/planning/workflow/README.md](/planning/workflow/README.md). +Moves a research package from S0 (intake) to S8 (implement). It reads machine state, decides what runs next, dispatches one stage skill per unit of work to parallel workers and lands their PRs. The stage contract is in [stages.md](/planning/workflow/stages.md), and the dispatch and merge rules are in [collaboration.md](/planning/workflow/collaboration.md) and [ordering.md](/planning/workflow/ordering.md). The router is an orchestrator. It writes only merge commits, the generated views, lease and log entries, and issue/PR bookkeeping. It never writes concept, research, design, plan or code content. -## Procedure +## Set up -1. **Locate Collection & Read Status**: +```sh +source /home/user/.local/share/plaza-tools/git-env.sh # the profile's git_env +rw() { python3 -I scripts/research_workflow.py "$@"; } # run from the repository root +PKG=doc/_research_ # the package folder +LOG="$(git rev-parse --git-common-dir)/agent-work/${PKG##*/}-router"; mkdir -p "$LOG" +``` + +Each log line is `router : ` and is appended to `$LOG/router.md`. If a command below fails with `invalid choice` or an unknown flag, read [references/tool-fallbacks.md](references/tool-fallbacks.md). + +## Steps + +1. **Find the package and the stopping point.** `rw check --repo-root .` lists every package. If the user handed over new input and there is no package for it yet, the next stage is S0 (see the S0 rule in [references/routing.md](references/routing.md)). Take the stopping point from the user's words using the phrase list in `references/routing.md`. If the user didn't state one, finish the current stage for every ready concept, then stop. + Done when `$LOG/router.md` has a `start` line naming the package path and the stop stage. + +2. **Read state.** Run: ```sh - python3 scripts/research_workflow.py status --package + rw status --package "$PKG" --live # per concept: stage, run status (derived from git and GitHub), issues, PRs + rw ready --package "$PKG" # ready set and waves; excludes running, leased and claimed concepts + rw check --package "$PKG" --remote-notes ``` - Check the current stage (`intake`, `prepare`, `research`, `reconcile`, `handoff`, `design`, `plan`, `implement`). + Run status `pushed`, `pr-open` and `merged` come from `--live`. Never take them from a worker's own claim. + Done when you have, for every concept, its stage, its run status, its ready-or-blocked state with the blocking ids, and its pending notes. + +3. **Choose one action per concept.** Map stage and run status to an action with the table in `references/routing.md`. The action is one of dispatch, verify-and-merge, monitor, restart, wait (name the blocker), ask the human (batched), or done. Concepts past the stop stage are left alone. Apply the barriers listed there: S3 waits for every S2 to merge, and `type: hint` concepts never go to S2. A conflict between concepts goes to the decision protocol in [decisions.md](/planning/workflow/decisions.md), not to you. + Done when every concept has exactly one action, written as one log line. -2. **Compute Ready Frontier**: +4. **Dispatch ready work in parallel.** Concepts are dispatched in `ready` order, and the number running at once never exceeds the profile's `max_parallel_writers` (5 by default). For each one: ```sh - python3 scripts/research_workflow.py ready --package + rw lease acquire --package "$PKG" --stage S1 --resource C003 --owner prepare-c003-7f2a --purpose "S1 research-prepare" ``` - Inspect unblocked concepts and active concurrency constraints. + Then fill in [references/worker-brief.md](references/worker-brief.md) and launch every worker in the same turn as a background subagent. Pass paths and URLs, not summaries. Size each unit to one fresh session. If a unit won't fit, split it before dispatching. + Done when every dispatched concept has a lease, its brief is in `$LOG/.md`, and its subagent is running, with nothing over the cap. + +5. **Verify and merge finished workers.** When a worker reports, run the triple check in [references/merge-and-restart.md](references/merge-and-restart.md). The remote branch, the PR head and the SHA the worker reported must all be equal. The worker must also have finished, and the PR must be mergeable and green. Then merge with `gh pr merge --merge --match-head-commit ` and confirm with `git merge-base --is-ancestor origin/main`. A PR that is behind or conflicting goes back to its worker. Never fix a worker's branch yourself. + Done when every reported PR is either merged and confirmed as an ancestor, or returned to its worker with the reason logged. + +6. **Restart stalled workers and sweep orphans.** A stalled worker has no log line for 20 minutes, no live lease (`rw lease list --package "$PKG"`) and no open PR. Restart it on the same branch with its original brief: merge, never reset. A branch with commits ahead of main and no PR is an orphan. Use the commands in `references/merge-and-restart.md`. + Done when no stalled worker and no orphan branch is left without an action. + +7. **Refresh the generated views.** After a wave merges, run `rw render --package "$PKG"` on a fresh router branch (`research//router-`) and run `rw check --package "$PKG"`. Open that PR and merge it the same way. Workers leave the shared run table to you, which keeps their PRs from conflicting. + Done when the run table in `design.md` on `main` matches `rw status --package "$PKG" --live`. + +8. **Continue or stop.** If the stop stage is reached, or nothing is ready or running, stop and report. Otherwise go back to step 2. Wait for subagent completion notices instead of polling in a sleep loop. + Done when the turn report below lists every concept's stage and run status. + +## Single-concept shortcut + +A package with one concept keeps the full layout (no special case in [records.md](/planning/workflow/records.md)) but skips the ceremony: + +- one worker runs S1 and then S2 in the same session if it fits; +- S3 is just the check `rw check --package "$PKG" --require-resolved`; +- no waves are planned, and the run table has one row. + +Details are in `references/routing.md`. + +## Parallelism and ownership + +There is one worker per concept per stage, each in its own worktree and branch with a pushed empty branch, and up to the cap at once. Every file has one writer. Wide files (`main.md`, `design.md`, indexes, `AGENTS.md`) change only through PRs, and `changes.md` changes by appending a single line. Notes and receipts are new files. The full rules are in [collaboration.md](/planning/workflow/collaboration.md) (rules 1 to 10); this skill does not restate them. Questions for the human are batched, ranked by effect, and each one has a default ([decisions.md](/planning/workflow/decisions.md)). Work continues on the defaults. + +## Should load / should not load + +- Load for: resuming or continuing a package; "what's ready / blocked / running"; running the next stage across concepts; taking a request through to a named stage; merging worker PRs; restarting stalled workers. +- Don't load for these, which belong to the named skill: new raw input with no package yet (`request-intake`); one concept's preliminary research (`research-prepare`); one concept's full research (`concept-research`); notes and receipts (`notes-reconcile`); writing issues (`issue-handoff`); running a design or implementation wave (`design-orchestrate`, `implementation-orchestrate`); general web research with no package. -3. **Dispatch to Stage Skill**: - - Stage `intake` -> call `request-intake` if not yet prepared. - - Stage `prepare` -> call `research-prepare` per ready concept. - - Stage `research` -> call `concept-research` per ready concept. - - Stage `reconcile` -> call `notes-reconcile` per concept. - - Stage `handoff` -> call `issue-handoff` to create parent/fan-out issues. - - Stage `design` -> call `design-orchestrate` to coordinate research PRs and decisions. - - Stage `plan` -> call `feature-plan` to create granular implementation plans. - - Stage `implement` -> call `implementation-orchestrate` across ready frontiers. +## References -4. **Report Progress**: - Print the ready frontier, active leases, and next action. +- [references/routing.md](references/routing.md): read in steps 1 and 3 (stop phrases, stage-to-skill table, actions, barriers, hints, nesting). +- [references/worker-brief.md](references/worker-brief.md): read in step 4, before every dispatch. +- [references/merge-and-restart.md](references/merge-and-restart.md): read in steps 5 and 6. +- [references/tool-fallbacks.md](references/tool-fallbacks.md): read only when a command named here is missing. -## Turn Report +## Turn report End every turn with: -- Done: -- Verified: output> -- Remaining: -- Questions (non-blocking): default> -- Blocked on user: +``` +Done: +Verified: result>, e.g. rw status --package ... --live -> C001..C014 at S1 merged +Remaining: +Questions (non-blocking): default in use>, or none +Blocked on user: , or none +``` diff --git a/.agents/skills/research-workflow/references/merge-and-restart.md b/.agents/skills/research-workflow/references/merge-and-restart.md new file mode 100644 index 0000000000..0f2f83c5a4 --- /dev/null +++ b/.agents/skills/research-workflow/references/merge-and-restart.md @@ -0,0 +1,90 @@ +# Merging, restarting and sweeping + +Read this in steps 5 and 6 of the router. The rule itself is collaboration rule 7 in [collaboration.md](../../../../planning/workflow/collaboration.md). This file has the commands. + +## Merge a finished worker (SHA triple check) + +Merge only after the worker's final message has arrived (its subagent finished and its log ends with `end`). + +```sh +BRANCH=research//s1-c003; PR=; REPORTED= +git fetch -q origin +REMOTE=$(git ls-remote origin "refs/heads/$BRANCH" | cut -f1) +HEAD_SHA=$(gh pr view "$PR" --json headRefOid --jq .headRefOid) +[ "$REMOTE" = "$HEAD_SHA" ] && [ "$HEAD_SHA" = "$REPORTED" ] && echo "triple match" || echo "MISMATCH" +gh pr view "$PR" --json mergeable,mergeStateStatus,isDraft,baseRefName +gh pr checks "$PR" +git diff --name-only "origin/main...$REPORTED" # only paths the brief let the worker write +``` + +Merge only when all of these hold: + +- the line prints `triple match`; +- `mergeable` is `MERGEABLE`; +- `isDraft` is false; +- the base is the trunk; +- the required checks pass; +- the diff stays inside the worker's owned paths. + +Then: + +```sh +gh pr merge "$PR" --merge --match-head-commit "$REPORTED" +git fetch -q origin && git merge-base --is-ancestor "$REPORTED" origin/main && echo landed +``` + +Afterwards, log `router merge: # ` and release the lease if the worker didn't: `rw lease release --package "$PKG" --stage --resource `. + +When a check fails, act as follows. Never push to the worker's branch yourself. + +- **Mismatch:** the worker pushed after reporting, or the report is wrong. Ask the worker (resume its session) for its current SHA. +- **`BEHIND` or `DIRTY`:** send it back with "merge origin/main, resolve conflicts in your own files, push, report the new SHA". +- **Red checks:** send it back with the failing check's name and log URL. + +After a merge, the branch is deleted (auto-delete is on). Any follow-up for that concept and stage uses a new branch, such as `research//s1-c003-2`. + +## Detect a stalled worker + +```sh +D="$(git rev-parse --git-common-dir)/agent-work/${PKG##*/}-" +tail -n 1 "$D/.md" # last line and its UTC time +rw lease list --package "$PKG" # live leases and their expiry +gh pr list --head "$BRANCH" --state open --json number,url +``` + +A worker counts as stalled only when all three are true: + +- its last log line is more than 20 minutes old; +- it holds no live lease; +- it has no open PR. + +If it has an open PR but has stopped, treat it as finished and verify the PR. If it holds a live lease, it is still working. + +## Restart on the same branch + +If the harness can resume the worker's session, resume it. Otherwise, dispatch a new subagent with the original brief (it is in `$LOG/.md`) plus: + +``` +Resume: branch already exists on origin and may have commits. + git fetch -q origin && git worktree add (or reuse the existing worktree) + git merge --no-edit origin/main (never reset, never rebase) +Read your log /.md to see what was done; continue from the first unfinished step. +``` + +Before dispatching, acquire the lease again under the new worker's name. Then log `router restart: -> on `. + +## Sweep orphan branches + +```sh +git fetch -q --prune origin +for ref in $(git for-each-ref --format='%(refname:strip=3)' "refs/remotes/origin/research//"); do + ahead=$(git rev-list --count "origin/main..origin/$ref") + prs=$(gh pr list --head "$ref" --state all --json number --jq length) + [ "$ahead" -gt 0 ] && [ "$prs" -eq 0 ] && echo "orphan: $ref ($ahead commits ahead, no PR)" +done +``` + +Handle each orphan in one of two ways: + +- If its unit is not done anywhere else, restart its worker on it (above), so it opens the PR. +- If the unit was redone on another branch, log `router abandoned: superseded by ` and leave the branch in place. Never delete it. diff --git a/.agents/skills/research-workflow/references/routing.md b/.agents/skills/research-workflow/references/routing.md new file mode 100644 index 0000000000..268b73bd51 --- /dev/null +++ b/.agents/skills/research-workflow/references/routing.md @@ -0,0 +1,67 @@ +# Routing tables + +Read this in steps 1 and 3 of the router. The stage contract, including what each stage produces, is in [stages.md](../../../../planning/workflow/stages.md). This file only maps state to an action. + +## Stopping point from the user's words + +Pick the furthest stage the user asked for. The words are examples, not an exhaustive list: + +- "capture", "write it down", "intake only", "store it", "set up the package" stop after **S0**. +- "prepare", "preliminary research", "research issues", "get it ready for research" stop after **S1**. +- "research it", "full research", "definitive docs" stop after **S3** (S2 and reconcile). +- "hand off", "make the issues", "fan out" stop after **S5**. +- "design it", "make the decisions" stop after **S6**. +- "plan it", "feature plan", "tickets" stop after **S7**. +- "build", "implement", "ship", "all the way" stop after **S8**. +- Nothing stated: finish the stage the package is at for every ready concept, then stop. Add the question "Continue to S? -> default: yes, on the next run". + +A "don't do X yet" in the request is a stopping point too. The stop stage you chose and the words it came from go in the router log. + +## S0: there is no package yet + +Intake is one worker. Dispatch it with the input's path or URL, never the text. If the input exists only in this conversation, no worker can see its bytes. In that case, load `request-intake` and run S0 in this session (it is the one exception to "never write content"), then return to routing. + +## Stage to skill + +| Stage | Skill | Unit | Dispatch when | +| ----- | --------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------- | +| S0 | `request-intake` | the input | no package holds this input's sha256 | +| S1 | `research-prepare` | concept | S0 merged | +| S2 | `concept-research` | concept | S1 merged and `type` is not `hint` | +| S3 | `notes-reconcile` | concept | every concept's S2 merged (notes can arrive until then) and `check --remote-notes` shows none in flight | +| S4 | `issue-handoff` mode `parent` | concept | S3 merged and `check --require-resolved` passes for it | +| S5 | `issue-handoff` mode `fanout`, then `orchestration` | parent issue | S4 issue exists | +| S6 | `design-orchestrate` | orchestration issue | S5 orchestration issue exists | +| S7 | `feature-plan` | design | S6 design merged and its human-review list published | +| S8 | `implementation-orchestrate` | feature plan | S7 plan merged with its issues | + +## Run status to action + +The run status is the one for the concept's current stage, as `rw status --live` reports it: + +- `not-started`, concept in the ready set, stage within the stop point: **dispatch** the stage's skill. +- `not-started`, not in the ready set: **wait**. Log the `requires` ids that block it, or the `shares-files-with` partner that is running. +- `claimed` or `running`: **monitor**. Check its log's last line and its lease. If either is stale, it is a restart candidate. +- `pushed` (commits on the branch, no PR): **monitor** while the worker is alive. If it ended without a PR, **restart**. +- `pr-open`: **verify-and-merge** once the worker has reported. Before that, monitor. +- `merged`: if the stage is `validated` or needs no validation, the concept moves to the next stage. Back to the top of this list. +- `blocked`: read the reason in its PR or log. On a human question, **ask** (batched). On another concept, **wait**. +- `abandoned`: if the branch has commits, **restart** on it. If it has none, **dispatch** fresh. + +## Barriers and special cases + +- **S3 barrier.** Reconcile starts only after every concept's S2 has merged, because a late S2 can still send notes. A concept with no incoming notes can skip ahead once `rw check --package "$PKG" --require-resolved` passes. +- **Hints.** A `type: hint` concept gets S1, which prepares the questions that would resolve it, and then waits. It moves only when a note or a human answer changes its type. Its questions join the batched human list. +- **Soft edges.** A `recommended-after` concept may start early only if a worker would otherwise sit idle. Its brief must then state the `rework_if_early` cost ([ordering.md](../../../../planning/workflow/ordering.md)). +- **Contingent concepts** (`optional-if`) are dispatched only once their `trigger` is met. +- **Nested orchestrators.** S6 and S8 run their own workers. If the harness lets subagents spawn subagents, dispatch one orchestrator subagent per unit. If it doesn't, load the orchestrator skill in this session and run its loop yourself. +- **Decisions.** The router never picks between conflicting results. It routes them to the decision protocol in [decisions.md](../../../../planning/workflow/decisions.md), and work continues on the preliminary choice. + +## Single-concept shortcut + +One concept still gets the full package layout. Its stages run like this: + +- **S1 and S2:** one worker, one branch per stage. If the concept fits in one session, the same session can run S2 right after S1 has merged. +- **S3:** a check only. Run `rw check --package "$PKG" --require-resolved`. There is nobody to send or receive notes. +- **S4 and S5:** as normal. The parent issue is still needed for the zero-context handoff. +- **Waves:** none. The run table has one row. diff --git a/.agents/skills/research-workflow/references/tool-fallbacks.md b/.agents/skills/research-workflow/references/tool-fallbacks.md new file mode 100644 index 0000000000..035dfc9411 --- /dev/null +++ b/.agents/skills/research-workflow/references/tool-fallbacks.md @@ -0,0 +1,21 @@ +# When a workflow command is missing + +Read this only when `python3 -I scripts/research_workflow.py ` fails with `invalid choice` or an unknown flag. That means the tool on your base branch is older than the command set these skills rely on (the workflow docs in [planning/workflow/](../../../../planning/workflow/README.md) describe it). In that case: + +- record `tool behind skill: ` in your turn report under Questions, with the default "used the fallback below"; +- use the fallback below; +- don't edit the tool unless you own it. + +- **`status --live`**: run `rw status --package "$PKG"` for stage and status. Derive the run status yourself: + - `git ls-remote origin 'refs/heads/research//*'` shows pushed branches; + - `gh pr list --state all --search " in:body" --json number,headRefName,headRefOid,state,url` shows PRs; + - `git merge-base --is-ancestor origin/main` shows what has merged. +- **`ready` without waves**: use the plain `ready` output, then drop concepts that hold a lease or have a running worker. +- **`lease acquire|release|list`**: use the `mkdir` lock in collaboration rule 5 ([collaboration.md](../../../../planning/workflow/collaboration.md)): `mkdir "$D/locks/.lock"`, then write `owner` as ` `. An existing directory means someone else holds the lock. +- **`item add|set-status`**: edit the items list in `main.md` by hand, following the trail grammar in [records.md](../../../../planning/workflow/records.md), and allocate the next free child number under the parent. Then add one `changes.md` line. +- **`ids`**: `grep -o 'C[0-9]\{3\}\(\.[0-9]\+\)*' "$PKG/main.md" | sort -uV`. +- **`render`**: leave the generated views as they are and note it in the turn report. Never hand-edit text between `workflow:view` markers. +- **`verify-transcript --against`**: `cmp "$SRC" "$PKG/transcript.txt" && sha256sum "$SRC" "$PKG/transcript.txt"`. +- **`init --preview-segments`**: the older tool works by line. Run `nl -ba "$SRC"` and write `source_lines: [[start, end]]` ranges in the outline instead of `segments`. The test fixture `outline()` in `scripts/tests/test_research_workflow.py` is the example. +- **`check --remote-notes`**: `git fetch -q origin`, then `git log --name-only --format= origin/main..origin/ -- "$PKG/notes/"` for each research branch. +- **`check --changed-since `**: `rw check --package "$PKG"`, which checks the whole package. diff --git a/.agents/skills/research-workflow/references/worker-brief.md b/.agents/skills/research-workflow/references/worker-brief.md new file mode 100644 index 0000000000..b5f7333aaf --- /dev/null +++ b/.agents/skills/research-workflow/references/worker-brief.md @@ -0,0 +1,45 @@ +# Worker brief + +Read this before every dispatch. A worker starts with no context, so the brief has to carry everything it needs. Fill in every `<...>`. Pass paths, URLs and SHAs. Never paste summaries of documents the worker can read itself (collaboration rule 9). + +Names: `--<4 hex>`, for example `prepare-c003-7f2a`. Branch: `research//-`, for example `research/docs-pipeline/s1-c003`. Worktree: `/research---`. + +``` +Name: Role: worker for () +Objective: +Load the skill: .agents/skills//SKILL.md, and follow its steps in order. + +Repository: Base: origin/ +Branch: Worktree: (create it, push the empty branch first) +Package: Concept file: /concepts/.md +Main reference section: /main.md# Transcript segments: +Issues and PRs so far: + +Owns (writes): ; notes it sends (notes/__to__*); receipts for notes addressed to + ; its own items in main.md via `rw item`; one changes.md line per change; its log file. +Must not touch: other concept files, other concepts' items, generated views (`rw render` is the + router's), AGENTS.md, doc/README.md, anything outside unless listed above. +Rules: planning/workflow/collaboration.md (all ten rules). No stash, no rebase, no force push, + no reset, no sudo; stage explicit paths; merge origin/ into the branch before opening the PR. +Lease: held for you as by the router. Renew it with the same `rw lease acquire` command + before 20 minutes pass, and release it with `rw lease release` when you finish. +Coordination log: /agent-work/-/.md + Append lines " : ". Write "start" first, a heartbeat at least every 10 minutes, + "push " after every push, and "end" last. + +Done when: --changed-since origin/ exits 0"> +Stop as blocked when: a prerequisite is missing, a file you must change is owned by someone else, or a + check fails for a reason outside your files. Push what you have, say exactly what blocks you, stop. +Return: branch, PR URL, last pushed SHA, verified commands with their real output, what you did not + verify, questions with the default you used, changes needed in files you don't own (as `rw note` + files or handoff text). +``` + +Before relying on a worker's report, check: + +- the files it wrote, with `git diff --name-only origin/main...`; +- the claims you will repeat, by re-running one or two of its commands. + +A report is a secondary source. From 466e2baed6b492342560b71dea8c869740acc347 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 21 Oct 2026 15:02:04 -0500 Subject: [PATCH 2/4] docs: deepen request-intake skill (references in progress) --- .agents/skills/request-intake/SKILL.md | 151 +++++++++++++++--- .../request-intake/references/exact-bytes.md | 32 ++++ .../references/reading-messy-input.md | 50 ++++++ 3 files changed, 212 insertions(+), 21 deletions(-) create mode 100644 .agents/skills/request-intake/references/exact-bytes.md create mode 100644 .agents/skills/request-intake/references/reading-messy-input.md diff --git a/.agents/skills/request-intake/SKILL.md b/.agents/skills/request-intake/SKILL.md index f4263c784d..0d476bc22f 100644 --- a/.agents/skills/request-intake/SKILL.md +++ b/.agents/skills/request-intake/SKILL.md @@ -1,40 +1,149 @@ --- name: request-intake -description: Store raw transcripts byte-for-byte, verify SHA-256 integrity, segment ideas, and scaffold initial research collections. Use when capturing a new request, prompt, or noisy voice transcription. +description: Capture a request, from one sentence to a multipage rambling or speech-to-text transcript, as a research package (stage S0). Stores the exact bytes with the workflow tool's init, maps every sentence segment to a concept or the global bucket G, keeps hints, contradictions and changes of mind, records garbled words in a reading register, explores the repo for context and overlap with parallel read-only subagents, pre-creates one stub per concept and lands main.md, design.md and changes.md as a docs-only PR. Use when the user hands over new ideas, a brain dump, a voice note or a long request to turn into research and design docs, or says capture, intake or start a research package. Stops after intake unless told to continue. For a package that already exists, load research-workflow instead. --- -# Request Intake (Stage 0) +# Request intake (S0) -Scaffold a sealed, evidence-preserving research collection from raw user input. Specifications live in [/planning/workflow/stages.md](/planning/workflow/stages.md) and [/planning/workflow/records.md](/planning/workflow/records.md). +This skill turns one request into a research package. The request can be anything from a sentence to a multipage voice transcript full of typos. The package holds: -## Procedure +- the exact transcript; +- a manifest; +- the main reference; +- the meta design; +- a change log; +- one stub per concept. -1. **Save Raw Input**: - Save the exact input bytes without normalization or whitespace changes to a temporary file `/tmp/raw-input.txt`. +One agent runs intake. Intake keeps everything; refining, merging and rejecting come at S2 and later. The layout and formats are in [records.md](/planning/workflow/records.md), the stages in [stages.md](/planning/workflow/stages.md), and the vocabulary (types, relations, priority, horizon) in [DEPENDENCIES.md](/planning/DEPENDENCIES.md). -2. **Compute Checksum**: - Compute `sha256sum /tmp/raw-input.txt` to verify byte preservation. +## Set up -3. **Draft Concept Outline**: - Inspect the input and map every nonblank section to concepts (`C001`, `C002`, ...), recording source line ranges. Include a "Garbled Input Reading Register" if phonetic or speech-to-text artifacts are present. +```sh +source /home/user/.local/share/plaza-tools/git-env.sh # the profile's git_env +SLUG=; TS=$(date -u +%Y-%m-%dT%H:%M:%SZ); PKG="doc/${TS//:/-}_research_$SLUG" +git fetch -q origin +git worktree add -b "research/$SLUG/s0-intake" "/home/user/work/wt/research-$SLUG-s0-intake" origin/main +cd "/home/user/work/wt/research-$SLUG-s0-intake" && git push -u origin "research/$SLUG/s0-intake" +rw() { python3 -I scripts/research_workflow.py "$@"; } +WORK="$(git rev-parse --git-common-dir)/agent-work/${PKG##*/}-S0"; mkdir -p "$WORK" # scratch, never committed +``` -4. **Scaffold Package**: +If a command fails with `invalid choice` or an unknown flag, read [tool-fallbacks.md](../research-workflow/references/tool-fallbacks.md). + +## Steps + +1. **Get the exact bytes without retyping.** Use the source as it was delivered, chosen with [references/exact-bytes.md](references/exact-bytes.md): a file path, an attachment, an issue body, a pipe or the harness's own record of the message. Set `SRC` to that file and `SHA=$(sha256sum "$SRC" | cut -d' ' -f1)`. If the user or the source supplied a hash, it is the expected hash. Scan the input for secrets (keys, tokens, passwords). This repository is public. + Done when `SRC` holds the delivered bytes, the source is described in one line, any expected hash is noted, and the secret scan is clean. A hit makes you Blocked on user. + +2. **Preview the segments.** Run `rw init --input "$SRC" --slug "$SLUG" --preview-segments > "$WORK/segments.txt"`. Segments are sentences: the tool splits after `.`, `?` and `!`, and at every newline. + Done when `segments.txt` lists `T001` to `Tn` and `git status --short` shows the preview wrote nothing to the repository. + +3. **Read everything and record what it says.** Read every segment, following [references/reading-messy-input.md](references/reading-messy-input.md). For long input it splits the work across parallel read-only range readers. Write `$WORK/reading.md` with these lists, each entry citing segment ids: + - candidate concepts; + - directives about how to work (these go to `G`); + - hints; + - contradictions; + - changes of mind; + - repeats; + - garbled tokens; + - ideas the user missed or only implied. + Done when every segment id appears in `reading.md` at least once. + +4. **Explore the context in parallel (read-only).** In one turn, launch the explore subagents in [references/explore-briefs.md](references/explore-briefs.md): + - code and config; + - docs and architecture; + - issues and PRs; + - one more for each large area the topics touch. + + Each returns `file:line` evidence per topic, plus an overlap list of existing docs, issues or PRs that already cover a topic, contradict it, or would be edited by it. Before using a report, re-run two of its claims. + Done when every candidate concept has evidence or a "nothing found (searched: ...)" line, and the overlap list is merged into `reading.md`. + +5. **Write the outline.** Write `$WORK/outline.json` using the schema and example in [references/outline.md](references/outline.md): + - Make one concept per document to create (`kind: new`) or existing file to edit (`kind: edit`, with `targets`). + - Give every segment to a concept or to `G`. Overlap between concepts is allowed. + - A hinted idea gets `type: hint`. + - Keep both sides of a contradiction or change of mind, with `contradicts` or `supersedes`. + - Put garbled tokens in the reading register. + - Add missed or half-formed ideas to `suggestions[]`, each starting `Inference:`. + - Take priority, horizon, goal and `enables` from the user's words, else `unspecified`. + Done when every idea in a multi-idea segment is claimed by a concept, by `G` or by a suggestion (the idea-level check in `references/outline.md`). + +6. **Create the package.** ```sh - python3 scripts/research_workflow.py init --input /tmp/raw-input.txt --slug --outline --expect-sha256 + rw init --input "$SRC" --slug "$SLUG" --timestamp "$TS" --outline "$WORK/outline.json" \ + --expect-sha256 "$SHA" --source "" --visibility public + rw verify-transcript --package "$PKG" --against "$SRC" ``` -5. **Verify Package**: + - Add `--encoding ` only for input that isn't UTF-8. + - `init` refuses bytes that are already captured. Hand that package to `research-workflow` instead. Use `--allow-duplicate` only if the user asks for a second capture. + - Uncovered segments make `init` fail and write nothing. Fix the outline and rerun. + + Done when `init` exits 0 and `verify-transcript` reports a match. + +7. **Complete the main reference and the meta design.** Go through [references/package-checklist.md](references/package-checklist.md). In `main.md`, make sure it has: + - the file list (every stub and every target); + - the introduction; + - `G`; + - the reading register; + - each concept's preliminary thoughts as hierarchical items; + - empty Issues and PRs placeholders. + + Add any missing item with `rw item add --package "$PKG" --parent C001 --text "..."`. In `design.md`, make sure it has: + - the first-pass review order with reasons; + - the waves from `rw ready --package "$PKG"`; + - the line "run one agent per concept" where nothing blocks; + - the run table from `rw render --package "$PKG"`. + + Done when every checklist line holds and `rw ids --package "$PKG"` lists items for every concept that has thoughts. + +8. **Validate.** Commit first (`git add -- "$PKG" && git commit -m "docs: capture $SLUG request"`), then run: + ```sh - python3 scripts/research_workflow.py check --package doc/ + rw check --package "$PKG" && rw check --repo-root . + prettier --check "$PKG"/*.md "$PKG"/concepts/*.md && biome format "$PKG"/package.json + rw render --package "$PKG" && git diff --exit-code -- "$PKG" # views are current and stable ``` -## Turn Report + Then give `main.md` to a fresh zero-context reader subagent with the prompt in `references/package-checklist.md`. Fix every gap it finds in the package, or list it under Questions. + Done when every command exits 0 and each of the reader's questions is answered in the package or listed. + +9. **Land as a docs-only PR.** + 1. `git fetch -q origin && git merge --no-edit origin/main`, then push. + 2. `gh pr create --base main --title "docs: capture request" --body-file "$WORK/pr.md"`, with the body from the checklist. + 3. `git diff --name-only origin/main...HEAD` must list only `$PKG/**`. + 4. If you are a dispatched worker, stop here; the router merges. + 5. If you are running standalone, wait for green checks, then `gh pr merge --merge --match-head-commit "$(git rev-parse HEAD)"`, then `git merge-base --is-ancestor origin/main`. + + Done when the PR is open (worker), or merged with the ancestor check passing (standalone). + +10. **Stop at intake.** Continue only if the user asked for more, in which case load `research-workflow` with the package path. + Done when the turn report names the package, the PR and the next stage (S1, one `research-prepare` agent per ready concept). + +## Parallelism and ownership + +Intake has one writer: you own the whole package until its PR merges. The range readers and explore subagents are read-only and return reports; they write nothing. Once the PR merges, each concept file belongs to the worker of its current stage. From then on, `main.md` and `design.md` change only through PRs, and `changes.md` only by appending a single line. The rules are in [collaboration.md](/planning/workflow/collaboration.md); this skill does not restate them. + +## Should load / should not load + +- Load for: a new request, brain dump, voice note or transcript to capture; "start a research package"; "store this exactly and break it into docs"; making the main reference, the meta design and the concept stubs for new input. +- Don't load for: an existing package (`research-workflow`); preparing one concept (`research-prepare`); deep research (`concept-research`); transcribing audio; polishing dictated prose; questioning the user about a plan (`grilling`); turning a spec into tickets (`feature-plan`). + +## References + +- [references/exact-bytes.md](references/exact-bytes.md): read in step 1. +- [references/reading-messy-input.md](references/reading-messy-input.md): read in step 3, and again whenever the input is long, garbled or self-contradicting. +- [references/explore-briefs.md](references/explore-briefs.md): read in step 4. `research-prepare` uses it too. +- [references/outline.md](references/outline.md): read in step 5. +- [references/package-checklist.md](references/package-checklist.md): read in steps 7 to 9. -End every turn with: +## Turn report -- Done: -- Verified: -- Remaining: -- Questions (non-blocking): default> -- Blocked on user: +``` +Done: +Verified: ok; verify-transcript -> match sha256 ; prettier --check -> ok> +Remaining: +Questions (non-blocking): default used>, or none +Blocked on user: , or none +``` diff --git a/.agents/skills/request-intake/references/exact-bytes.md b/.agents/skills/request-intake/references/exact-bytes.md new file mode 100644 index 0000000000..2409972dd8 --- /dev/null +++ b/.agents/skills/request-intake/references/exact-bytes.md @@ -0,0 +1,32 @@ +# Getting the exact bytes + +Read this in step 1. The transcript has to be the bytes as the user delivered them, with no harness prefix, no added trailing newline and no tidying. A model that types text back out is retyping it, even inside a tool call, and retyping drifts. So copy bytes with programs and type nothing yourself. + +## Pick the source, best first + +1. **A file the user named or attached.** Set `SRC=`. Done. +2. **An issue, PR or comment body.** Note that `gh ... --jq .body` adds a newline, so write the field with Python instead: + ```sh + gh api repos///issues/ | python3 -I -c 'import json,sys; sys.stdout.write(json.load(sys.stdin)["body"])' > "$WORK/input.txt" + SRC="$WORK/input.txt" + ``` +3. **Output of another program** (clipboard, export, speech-to-text tool): pipe it straight into a file, e.g. `wl-paste --no-newline > "$WORK/input.txt"`. +4. **A message that exists only in this conversation.** Look for the harness's own record of it, such as a session export or a transcript log under the harness's data directory, and extract the message field with a script, as in 2. +5. **Nothing else works.** Write the text once with the file-writing tool. Then: + - pass `--source "retyped by agent from chat; bytes not verified"`; + - add a Question: "send the original file or its sha256 -> proceeding with the retyped copy". + + Don't present a retyped copy as exact. + +## Hashes and provenance + +- `--expect-sha256` takes the hash the user, the issue or an earlier copy gave. A mismatch means you have different bytes, so stop: Blocked on user, showing both hashes. +- A copy kept elsewhere (another repository, a note with a prefix like `in code pull then do this : `) is a different byte string. Record where it lives in `--source`, and don't make it the transcript unless the user says so. +- After `init`, `rw verify-transcript --package "$PKG" --against "$SRC"` proves the stored file equals the source. + +## Privacy + +The repository is public. Before committing: + +- **Secrets:** scan for API keys, tokens, passwords and private keys (the repository's secret scanner, or `grep -nEi 'api[_-]?key|secret|token|passw' "$SRC"`, then read each hit). Any real secret means Blocked on user. Never commit it, not even redacted, unless the user tells you how. +- **Other people's private material** (names with contact details, private repository content): ask before committing. Your default is to keep the transcript out of this repository and record only its hash and where it lives (`--visibility private`). diff --git a/.agents/skills/request-intake/references/reading-messy-input.md b/.agents/skills/request-intake/references/reading-messy-input.md new file mode 100644 index 0000000000..09971a9725 --- /dev/null +++ b/.agents/skills/request-intake/references/reading-messy-input.md @@ -0,0 +1,50 @@ +# Reading long, rambling or garbled input + +Read this in step 3. The aim is to lose nothing. Every idea, hint, constraint and change of mind ends up somewhere a later stage will see it. Judging whether an idea is good is for S2 and later. + +## Passes + +Read the whole input once before writing anything. Then make these passes over `segments.txt`, each writing to `$WORK/reading.md` with segment ids: + +1. **Topics.** What would someone look up on its own? Each topic is a candidate concept. +2. **Directives.** How the user wants the work done: parallelism, PRs, branch rules, what to skip, where to stop. These go to `G` and also to every concept they constrain. +3. **Deliverables.** The files, documents, skills and issues the user expects to exist. Each one becomes a concept `target` (`kind: new`) or an edit of an existing file (`kind: edit`). +4. **Hints and gaps.** Ideas the user only gestured at ("the calendar thing, not going to explain it again"), and steps the user said they may have missed ("I may have missed steps"). Add the obvious missing pieces as `Inference:` suggestions. +5. **Contradictions and changes of mind.** Keep both statements. "Daily is fine, never hourly" after "hourly backups" is a change of mind. Unless the user set a different rule, the later statement is the working reading and the earlier one is kept with `supersedes`. If the user did set a rule ("later one wins, keep both"), record it in `G`. +6. **Repeats.** The same idea said twice is one concept citing both segments. Differences between the two tellings become thoughts. +7. **Garbled tokens.** Speech-to-text homophones, dropped words, stray symbols, typos. Each one goes in the register (below). + +## How many concepts + +- A sentence or a one-topic paragraph is **one concept**. It still gets the full package; there is no special layout. +- Make **one concept per document to create or file to edit**, or per topic a reader would research from different sources than its neighbours. +- **Split** when two parts would be researched from different sources, land in different files, or could be decided independently. +- **Merge** when two parts can't be researched or decided apart. +- Typical counts: one page gives 3 to 8 concepts; a multipage ramble gives 10 to 20. Above about 25, group the concepts with `part-of` relations under a few themes rather than dropping detail. +- A segment holding several ideas goes to every concept it feeds. Each concept's `summary` says which part it takes. + +## Long input: parallel range readers + +Above about 400 segments, or 60k characters, split the reading. Launch read-only subagents in one turn, each on a range of about 150 segments overlapping its neighbours by 5. Each one returns the seven lists above, with segment ids, and no prose summary. You merge and de-duplicate their lists. Then read every range boundary yourself, and spot-check three claims per reader against the text. You alone write the outline. + +## Reading register (garbled input) + +The transcript stays exact. Readings live only in the register in `main.md` ("Reading of garbled input") and in summaries labelled as inference. Each entry has these fields: + +- the segment id; +- the exact token; +- the reading adopted; +- why; +- confidence (`high`, `medium` or `low`); +- the alternative readings considered. + +Examples, all inference, from the request that started this workflow (`doc/2026-10-19T06-09-02Z_research_research-intake-to-implementation/transcript.txt`): + +- `**§**` in "build the next many future **§**" is read as "features" (medium). The sentence lists things to implement, defer or reject. +- "zeta files" is read as "meta files" (high). The same sentence describes "to_from" files, which the request elsewhere calls meta files. +- "file_theyr file" is read as "file_their file", a directed note named after sender and receiver (high). +- "separate server agents" is read as "separate subagents" (medium). The alternative is "separate server-side agents". +- "minimal other contacts" is read as "minimal other context" (high). +- "ale skills" is read as "all skills" (medium). The alternative is "make skills". + +A token whose reading would change what gets built (a product name, a number, a negation) also goes in the turn report as a Question with the default reading. From 45a94578cb448ad16b55a63d49e412b7b14e11c0 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 21 Oct 2026 15:02:54 -0500 Subject: [PATCH 3/4] docs: add request-intake references --- .../references/explore-briefs.md | 41 ++++++++++ .../request-intake/references/outline.md | 79 +++++++++++++++++++ .../references/package-checklist.md | 61 ++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 .agents/skills/request-intake/references/explore-briefs.md create mode 100644 .agents/skills/request-intake/references/outline.md create mode 100644 .agents/skills/request-intake/references/package-checklist.md diff --git a/.agents/skills/request-intake/references/explore-briefs.md b/.agents/skills/request-intake/references/explore-briefs.md new file mode 100644 index 0000000000..61fea34d15 --- /dev/null +++ b/.agents/skills/request-intake/references/explore-briefs.md @@ -0,0 +1,41 @@ +# Explore briefs (read-only context subagents) + +Read this in step 4 of `request-intake` and in step 4 of `research-prepare`. Launch all briefs in one turn, so the explorers run in parallel. Explorers write no files. Their final message is the report. + +## Common brief + +``` +Name: explore--<4 hex> Role: read-only explorer +Objective: for each topic below, find what already exists in this repository and its issue tracker. +Repository: at origin/main (). Issue repository: . +Topics: +Area: > +Writes: nothing. No files anywhere; use pipes and shell variables. +Allowed commands: git grep -n, git log --oneline -- , git show, ls, rg, + gh issue list --state all --search, gh pr list --state all --search, gh issue view, gh pr view. +Done when: every topic has evidence or "nothing found" with the searches you ran. +Return, per topic: + Topic: + Evidence: - : — what it shows (exact quote of at most 25 words if quoting) + Overlap: - — covers | contradicts | would be edited by | duplicates — one line + Targets: - , if any + Searched: , +``` + +## Areas + +- **Code and config:** source trees, scripts, CI workflows, flake and module layout touched by the topics. +- **Docs and architecture:** + - `doc/` (dated records), `planning/` (workflow, roadmaps, plans, designs); + - `AGENTS.md`, `CLAUDE.md`, READMEs; + - `.agents/skills/` and `.opencode/skills/` (a topic may already be a skill). +- **Issues and PRs:** open and closed issues and PRs whose title or body covers a topic. Include earlier research packages (`doc/*_research_*`) with overlapping concepts. +- **Named area:** one more explorer for each large subproject the topics touch (for example `pkgs/id`, `infra/`). That explorer reads the subproject's own `AGENTS.md` first. + +## Using the reports + +Before you rely on a report, re-run two of its claims. Then merge the overlaps into `reading.md`: + +- An existing file a concept would change makes that concept `kind: edit`, with the file as a target. +- An existing issue or PR that covers a concept goes in that concept's thoughts ("Overlap: #123 already tracks ..."). The concept is kept, never dropped. Whether to merge them is decided at S2. +- A contradiction between the request and an existing doc becomes a thought on the concept, citing both the segment and the `path:line`. diff --git a/.agents/skills/request-intake/references/outline.md b/.agents/skills/request-intake/references/outline.md new file mode 100644 index 0000000000..34eeb48915 --- /dev/null +++ b/.agents/skills/request-intake/references/outline.md @@ -0,0 +1,79 @@ +# Outline schema + +Read this in step 5. `init --outline` reads this JSON. The field meanings are in [records.md](../../../../planning/workflow/records.md), and the vocabulary for `type`, relation kinds, `priority` and `horizon` is in [DEPENDENCIES.md](../../../../planning/DEPENDENCIES.md). If `init` rejects a key, follow its one-line error. The tool's `--help` has the final say. + +## Example (illustrative ids) + +```json +{ + "title": "Research-to-delivery workflow", + "introduction": "What the user asked for, in two to five plain sentences.", + "global": { + "segments": ["T001", "T060-T066"], + "summary": "How to work: parallel agents, PRs for wide files, keep everything at early stages." + }, + "garbled": [ + { + "segment": "T071", + "token": "**§**", + "reading": "features", + "why": "The sentence lists things to implement, defer or reject.", + "confidence": "medium", + "alternatives": ["sections"] + } + ], + "concepts": [ + { + "title": "Exact transcript storage", + "slug": "transcript-storage", + "type": "topic", + "kind": "new", + "targets": ["planning/workflow/records.md"], + "segments": ["T002-T003"], + "summary": "Store the request byte for byte and link everything to it.", + "thoughts": ["Speech-to-text input arrives as very long lines; segment by sentence."], + "suggestions": ["Inference: record where the bytes came from, so a second copy can be told apart."], + "priority": "crucial", + "horizon": "now", + "goal": "No idea from the request is ever lost.", + "enables": ["main-reference"], + "relations": [{ "kind": "enables", "to": "main-reference", "reason": "Excerpts link to the transcript." }] + } + ] +} +``` + +## Field rules + +- **`segments`** take ids or ranges (`"T010"`, `"T010-T014"`) from `segments.txt`. + - Every non-blank segment must be in at least one concept or in `global`; `init` fails otherwise. + - `global` is the reserved bucket `G`: directives and constraints about how to work. +- **`type`** is one of: + - `topic`; + - `hint`: the user gestured at it, so it is never ready for research until a note or a human answer changes its type; + - `constraint`; + - `directive`. +- **`kind` and `targets`**: + - `new` concepts list the paths they will create. + - `edit` concepts list the existing files they will change, which the explorers found. + - Don't create target files at intake. Stubs live only in `concepts/`. +- **Relations** have the form `{kind, to, reason}`: + - `to` is a concept `slug`, because the tool allocates `C001` ids and agents never pick ids. + - `recommended-after` adds `rework_if_early` (what breaks if it runs first). + - `optional-if` adds `trigger`. + - Use `contradicts` or `supersedes` for contradictions and changes of mind between concepts. + - Inside one concept, keep both statements as thoughts that cite their segments, for example "T040 supersedes T012 (change of mind; later wins by default)". +- **Thoughts** become the concept's preliminary items (`C001.1`, `C001.2`, ...). Write one statement each, and cite segments where they apply. +- **Suggestions** start with `Inference:`. They hold ideas the user missed or only implied that the corpus should consider, and they are never presented as the user's words. +- **Priority and horizon** come from the user's words (`crucial`, `recommended`, `contingent`; `now`, `next`, `later`, `ideas`). Otherwise use `unspecified`. A `contingent` concept states its trigger in `relations` (`optional-if`). +- **Titles and slugs** are a single line. Slugs are lowercase kebab case. + +## Idea-level check (before step 6) + +`init` checks coverage per segment. You check it per idea: + +1. List every segment that holds more than one idea. Long speech-to-text sentences usually do. +2. For each idea in such a segment, name the concept, `G` entry or suggestion that claims it. +3. Then read the outline's titles against `reading.md`. Every topic, directive, hint, contradiction and repeat in `reading.md` has a home. + +Write the result as a short list at the end of `$WORK/reading.md`. Step 5 is done when no idea lacks a home. diff --git a/.agents/skills/request-intake/references/package-checklist.md b/.agents/skills/request-intake/references/package-checklist.md new file mode 100644 index 0000000000..984b5866cf --- /dev/null +++ b/.agents/skills/request-intake/references/package-checklist.md @@ -0,0 +1,61 @@ +# Package checklist, zero-context reader, PR body + +Read this in steps 7 to 9. Section order and generated-view markers are in [records.md](../../../../planning/workflow/records.md). This file lists what must be true after intake. + +## `main.md` + +- [ ] The title and an introduction (2 to 5 sentences): what was asked, how much input there was (segments, characters), and where intake stopped. +- [ ] The transcript link with its sha256, and the one-line source. +- [ ] A file list with every concept stub and every target, each marked `new` or `edit`. +- [ ] A `G` section listing the global directives with their segment ids. +- [ ] "Reading of garbled input": one entry per token, or "none found". +- [ ] One section per concept, containing: + - the generated view; + - a summary; + - preliminary thoughts as hierarchical items (`C001.1` ...); + - inference-labelled suggestions; + - an empty "Issues and PRs" placeholder. +- [ ] An "Issues and PRs" section at the bottom, empty but present. Later stages list every issue and PR there with the concept or item it refers to. + +## `design.md` + +- [ ] A first-pass review order. Each concept gets a one-line reason (foundations first, then what most others `require`). +- [ ] Waves from `rw ready --package "$PKG"`. Where nothing blocks, say so plainly: "run one agent per concept; all can start now". +- [ ] The generated run table (`rw render`). At intake, every row reads `not-started` for S1. +- [ ] An empty "Initial research stages" section, which S5 fills. + +## `changes.md`, stubs, manifest + +- [ ] `changes.md` has the intake line. +- [ ] Each stub in `concepts/` has the state block, links to its `main.md` section and to the transcript, and its exact excerpts at the top. +- [ ] `package.json` has `transcript.sha256` equal to `$SHA`, the source line, the visibility and the segment list. +- [ ] The package contains no other files: no notes, receipts or decisions yet; they are created lazily. + +## Zero-context reader prompt + +Send this to a fresh subagent that is given no other context: + +``` +You know nothing except the file /main.md and the files it links to. Do not use other context. +Return: 1) the goal, your role, and the first three actions you would take if handed this package; +2) every question you would need answered before starting, most blocking first; +3) claims you could not find support for in the package; 4) links that do not resolve; +5) places where two readings lead to different work. Be short and concrete. +``` + +## PR body (`$WORK/pr.md`) + +``` +## What +Research package : segments, concepts, G with directives. Docs only. +## Why +Captures so research can start per concept. +## Evidence +- rw verify-transcript --package --against -> +- rw check --package -> +- prettier --check ... -> +## Not verified + +## Next +S1: one research-prepare agent per concept; ready now: . +``` From b3361512b237c5df361d76d5dd2cd1fc58784cf5 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 21 Oct 2026 15:04:19 -0500 Subject: [PATCH 4/4] docs: deepen research-prepare skill --- .agents/skills/research-prepare/SKILL.md | 150 +++++++++++++++--- .../references/prepare-sections.md | 77 +++++++++ .../references/research-issue.md | 60 +++++++ 3 files changed, 266 insertions(+), 21 deletions(-) create mode 100644 .agents/skills/research-prepare/references/prepare-sections.md create mode 100644 .agents/skills/research-prepare/references/research-issue.md diff --git a/.agents/skills/research-prepare/SKILL.md b/.agents/skills/research-prepare/SKILL.md index 6154b10371..4c26c5363b 100644 --- a/.agents/skills/research-prepare/SKILL.md +++ b/.agents/skills/research-prepare/SKILL.md @@ -1,35 +1,143 @@ --- name: research-prepare -description: Map codebase, doc, and architecture context for an individual concept and draft research questions and trigger issues. Use before launching deep factual concept research. +description: Prepare one concept of a research package for its full research (stage S1). Boots a worker branch, pulls the concept's exact transcript excerpts to the top of its file, maps related code, docs, issues and PRs with file:line evidence, does light web research, writes research questions and facets, sends notes to other concepts and opens an idempotent Research trigger issue and a PR. Use when a concept stub from intake needs preliminary research, a research brief, a repo map or its Research issue, or when research-workflow dispatches S1 for a concept. Not the full research, which is concept-research (S2). --- -# Research Prepare (Stage 1) +# Research prepare (S1) -Prepare the contextual foundation and exploration brief for a single concept before launching deep research. Detailed rules live in [/planning/workflow/stages.md](/planning/workflow/stages.md). +Prepares one concept so the agent who picks up its Research issue can do the full research with almost no other context. There is one agent per concept, and many run in parallel. This is not the full research: S1 makes no recommendation, takes no decision and does no design. That is `concept-research` (S2). The stage contract is in [stages.md](/planning/workflow/stages.md), and the concept file format is in [records.md](/planning/workflow/records.md). -## Procedure +## Inputs -1. **Verify Concept Assignment**: - Read the concept document in `concepts/CXXX-.md` and its associated transcript excerpts. +These come from the worker brief, or from the user: -2. **Explore Codebase & Prior Art**: - Explore related modules under `pkgs/`, existing documentation under `doc/`, and historical architecture decisions to position the concept. +- `PKG`, the package folder; +- `C`, the concept id (for example `C003`), and its concept file; +- the branch, `research//s1-`; +- the issue repository (the profile's `issue_repository`). -3. **Formulate Research Questions**: - Draft specific, checkable research questions covering feasibility, prior art, failure modes, and integration seams. Update the concept file under `## Research Angles`. +If you were not dispatched by `research-workflow`, check that nobody else is preparing this concept: run `rw status --package "$PKG" --live`, which shows no run, lease or PR for `C` at S1. -4. **Draft Trigger Issue**: - Use template [/planning/workflow/templates/issue-parent.md](/planning/workflow/templates/issue-parent.md) to draft the research trigger issue. +## Steps -5. **Commit & Report**: - Commit changes to the concept file on the worker branch and report readiness for deep research. +1. **Boot.** -## Turn Report + ```sh + source /home/user/.local/share/plaza-tools/git-env.sh + git fetch -q origin && git worktree add -b "$BRANCH" "$WT" origin/main && cd "$WT" && git push -u origin "$BRANCH" + rw() { python3 -I scripts/research_workflow.py "$@"; } + D="$(git rev-parse --git-common-dir)/agent-work/${PKG##*/}-S1"; mkdir -p "$D"; L="$D/$NAME.md" + echo "$NAME $(date -u +%FT%TZ) start: S1 $C" >> "$L" + rw lease acquire --package "$PKG" --stage S1 --resource "$C" --owner "$NAME" --purpose "S1 research-prepare" + ``` -End every turn with: + Renew the lease with the same command before 20 minutes pass, and append a heartbeat line at least every 10 minutes. The rest of the boot rule is collaboration rule 3. If a command is missing, read [tool-fallbacks.md](../research-workflow/references/tool-fallbacks.md). + Done when `git ls-remote origin "$BRANCH"` prints a SHA, the log has `start`, and `rw lease list --package "$PKG"` shows your lease. -- Done: -- Verified: -- Remaining: -- Questions (non-blocking): default> -- Blocked on user: +2. **Read the assignment.** Read: + - the concept file and its state block (`type`, `kind`, `targets`, `segments`, `relations`); + - its section in `main.md`; + - the `G` section; + - the reading register; + - the segments in `package.json`. + + For `type: hint`, follow the hint path in [references/prepare-sections.md](references/prepare-sections.md). + Done when your log has a three-line statement of the concept's goal, its targets and its segments. + +3. **Put the exact excerpts at the top.** The stub already has intake's excerpts. Add every other segment that bears on this concept: `G` directives that constrain it, and segments held by other concepts that mention it. Most relevant goes first. Generate each block with the snippet in `references/prepare-sections.md`, never by typing it. Add those segment ids to your own state block. + Done when `rw check --package "$PKG"` passes (it compares every excerpt with the transcript) and every segment in your state block has an excerpt. + +4. **Map the repository.** For each target and its neighbours, cover: + - code and config; + - docs and decisions in `doc/` and `planning/`; + - roadmap rows; + - skills; + - issues and PRs (`git grep -n`, `git log --oneline -- `, `gh issue list --state all --search`, `gh pr list --state all --search`). + + For a wide concept, launch up to three read-only explorers in one turn with the briefs in [explore-briefs.md](../request-intake/references/explore-briefs.md). Write `## Repo map`. + Done when every target is mapped with `file:line`, or marked "new file; nearest existing: ", and each overlapping issue or PR is listed. + +5. **Do light web research.** Find up to about five primary sources that frame the questions: official docs or specs, and one or two projects that do the same thing. For each, record the URL as the tool returned it, its date, and one line on what it bears on. Follow the web-retrieval fallback in `AGENTS.md`. No synthesis and no verdict. + Done when `## Leads for research` lists each source, or says "none needed: ". + +6. **Write the research questions and facets.** + - `## Research questions`: each question can be answered, names what its answer would decide, and says where to look first. Together they cover feasibility, prior art, alternatives, use cases, failure modes, integration seams, cost, and what the concept enables. + - `## Facets`: the separable aspects that S2 researches and that S5 later fans out into child issues. Give each a scope line and the questions it covers. + + Record any statement you found to be more nuanced: `rw item add --package "$PKG" --parent C003.2 --text "..."` adds a child item, and `rw item set-status --package "$PKG" --id C003.2 --status clarified --stage S1 --text "..."` updates its status. Use these on your own items only. + Done when every question names its decision and its first source, and every facet maps to at least one question. + +7. **Send notes; never edit another concept.** Some findings affect another concept: an overlap, a shared target, a contradiction, or a dependency that wasn't declared. For each, write the body to `$D/note-.md`, then run `rw note --package "$PKG" --from "$C" --to C005 --input "$D/note-C005.md"`. Relations that start from your concept go in your own state block. + Done when every cross-concept finding is a note file, or a line in your file saying why it needs none. + +8. **Commit and open the PR.** In your state block: + - set `stage` to `S1`; + - append `{at, stage, status, note, ref}` to `history`; + - append one line to `changes.md`. + + Then commit with explicit paths (`git add -- `), run `git fetch -q origin && git merge --no-edit origin/main`, and validate: + + ```sh + rw check --package "$PKG" --changed-since origin/main + prettier --check + ``` + + Push, then run `gh pr create --base main --title "docs: prepare $C for research"`. + Done when the PR is open and `git diff --name-only origin/main...HEAD` lists only files you own. + +9. **Open the Research trigger issue (idempotent).** Search for the marker first, using the commands in [references/research-issue.md](references/research-issue.md). Reuse a matching issue; otherwise create it from the body there. The body links: + - the concept file and the `main.md` section on `main`; + - the transcript segments; + - this PR. + + Add `{number, url, stage: "S1", state: "open"}` to `issues` in your state block, commit, and push. + Done when exactly one issue carries the `(package, C, S1)` marker and your state block lists it. + +10. **Finish.** Then: + - append `push <sha>` to the log; + - check that the PR head = `git ls-remote origin "$BRANCH"` = `git rev-parse HEAD`; + - run `rw lease release --package "$PKG" --stage S1 --resource "$C"`; + - append `end` to the log. + + Done when all four are true and the final message has the turn report. + +## Boundaries (this is not the full research) + +- Don't write answers, comparisons, recommendations or decisions. +- Don't create target files. +- Don't edit another concept's file or items, or the generated views. + +If a question is easy to answer, leave the answer as a lead for S2. If the concept is too large for one S2 session, say so in your file and add a `part-of` split proposal as a note to the router. Don't split it yourself. + +## Parallelism and ownership + +You own only: + +- your concept file; +- your outgoing notes; +- receipts for notes sent to you; +- your own items in `main.md`; +- one `changes.md` line per change; +- your log. + +Other prepare workers run at the same time on other concepts. Wide files change only through your PR. The shared run table is the router's (`rw render`). The full rules are in [collaboration.md](/planning/workflow/collaboration.md). + +## Should load / should not load + +- Load for: preparing one concept for research (excerpts, repo map, questions, facets); opening a concept's Research trigger issue; being dispatched as an S1 worker. +- Don't load for: the full research of a concept (`concept-research`); capturing new input (`request-intake`); finding what's ready or dispatching waves (`research-workflow`); processing received notes (`notes-reconcile`); parent or child handoff issues (`issue-handoff`); general research with no package. + +## References + +- [references/prepare-sections.md](references/prepare-sections.md): read in steps 2, 3 and 6 (section order, excerpt snippet, good questions and facets, the hint path). +- [references/research-issue.md](references/research-issue.md): read in step 9. + +## Turn report + +``` +Done: <C, sections written, n excerpts, n questions, n facets, n notes sent, issue URL, PR URL> +Verified: <rw check ... -> ok; triple SHA match <sha>; issue marker search -> 1 result> +Remaining: <S2 concept-research for C via the issue; notes awaiting receipts> +Questions (non-blocking): <question -> default used>, or none +Blocked on user: <only for a hint that needs the user's missing context>, or none +``` diff --git a/.agents/skills/research-prepare/references/prepare-sections.md b/.agents/skills/research-prepare/references/prepare-sections.md new file mode 100644 index 0000000000..ba98d7628a --- /dev/null +++ b/.agents/skills/research-prepare/references/prepare-sections.md @@ -0,0 +1,77 @@ +# Concept file after S1 + +Read this in steps 2, 3 and 6. The state block and excerpt formats are owned by [records.md](../../../../planning/workflow/records.md). This file gives the section order and examples. + +## Section order + +1. Title, then the ` ```workflow-state ` block (single writer: you). +2. Links: main reference section, transcript, Research issue (once it exists). +3. `## Relevant transcript excerpts`: every exact excerpt, most relevant first. +4. `## Normalized purpose`: intake's summary. Keep it as written. Add refinements as items, never as rewrites. +5. `## Initial thoughts` and `## Inferred suggestions`: from intake, kept. +6. `## Repo map`: `path:line`, what it is, what it tells the research. +7. `## Leads for research`: sources with URL, date and one line each. +8. `## Research questions` +9. `## Facets` +10. `## Notes sent`: one line per note file. +11. `## Stage results`: one line for S1 (date, PR, issue). Later stages add theirs. + +## Excerpt snippet (never type an excerpt) + +This prints one excerpt block for a segment range. The block is a link line, a blank line, then a fence longer than any backtick run inside. + +```sh +python3 -I - "$PKG" T007 T009 <<'PY' +import json, re, sys, pathlib +pkg, first, last = pathlib.Path(sys.argv[1]), sys.argv[2], sys.argv[3] +meta = json.loads((pkg / "package.json").read_text()) +raw = (pkg / meta["transcript"]["path"]).read_bytes() +text = raw.decode(meta["transcript"].get("encoding", "utf-8")) +seg = {s["id"]: s for s in meta["segments"]} +body = text[seg[first]["start"]:seg[last]["end"]] +fence = "`" * max(3, 1 + max((len(r) for r in re.findall(r"`+", body)), default=0)) +label = first if first == last else f"{first}-{last}" +print(f"[Transcript {label}](../transcript.txt)\n\n{fence}workflow-excerpt {label}\n{body}\n{fence}") +PY +``` + +Paste its output into the file. `rw check` then proves the excerpt is exact. If the tool has a command that writes excerpts, use that instead. + +## Good research questions + +Each question can be answered, names what its answer decides, and says where to look first. + +- Weak: "How should notes work?" +- Good: "Can two workers create receipts for the same note at once without a lock, and does `O_EXCL` on the target filesystem guarantee it? Decides whether receipts need a lease. First source: the `open(2)` man page, then `scripts/research_workflow.py` `resolve-note`." + +Across the set, cover: + +- feasibility; +- prior art and similar projects; +- alternatives (at least two per real choice); +- use cases and user anecdotes; +- failure modes and their mitigations; +- integration seams with the repository map; +- cost and effort; +- what the concept enables for others (`enables`). + +## Facets + +A facet is a part of the concept that could be researched in its own session and handed off as its own issue at S5. Write each one like this: + +``` +- **<facet name>**: <scope in one line>. Questions: Q2, Q5. Why separate: <different sources | different files | independent decision>. +``` + +A concept usually has 2 to 6 facets. More than about 8 means the concept should be split. Send that proposal as a note to the router, and don't split it yourself. + +## Hint path (`type: hint`) + +The user only gestured at this idea. Prepare what is needed to resolve it: + +- the hinting excerpts; +- what the hint could mean (inference-labelled readings); +- what in the repository or earlier packages might hold the missing context (`git log --grep`, older `doc/*_research_*`, issues); +- the exact questions for the user, each with a default reading. + +The Research issue says "blocked on: user context for hint" and lists those questions. The concept stays `type: hint`, and S2 doesn't start until a note or a human answer changes its type. diff --git a/.agents/skills/research-prepare/references/research-issue.md b/.agents/skills/research-prepare/references/research-issue.md new file mode 100644 index 0000000000..45957e5b72 --- /dev/null +++ b/.agents/skills/research-prepare/references/research-issue.md @@ -0,0 +1,60 @@ +# Research trigger issue + +Read this in step 9. One open issue starts the full research (S2) for one concept. An agent with no other context must be able to take its URL and do the work. The issue templates are in [templates/](../../../../planning/workflow/templates/issue-parent.md). If a dedicated research template exists there, start from it. Either way, the body must have every section below. + +## Find before you create (idempotent) + +Retries must never create a second issue. Search by the title's package id, then match the body marker: + +```sh +REPO=<issue_repository>; PID=${PKG##*/} +gh issue list --repo "$REPO" --state all --limit 200 --search "$PID in:title,body" \ + --json number,url,state,body \ + --jq ".[] | select(.body | test(\"workflow:issue\")) | select(.body | contains(\"$PID\")) | select(.body | test(\"\\\"concept\\\": ?\\\"$C\\\"\")) | select(.body | test(\"\\\"stage\\\": ?\\\"S1\\\"\")) | {number,url,state}" +``` + +- One open match: reuse it. Edit its body only if yours adds something, using `gh issue edit <n> --body-file`. +- One closed match: reopen it only if this is a deliberate redo, and say why in a comment. +- No match: create it. Use existing labels only; `gh label list --repo "$REPO"` shows them. + +```sh +gh issue create --repo "$REPO" --title "Research: <concept title> ($PID·$C)" --body-file "$D/issue-$C.md" +``` + +Then repeat the search, which must return exactly one issue. + +## Body + +``` +## Goal +Full research for <C> <title>: the definitive concept document, covering every facet below. + +## Links +- Package main reference: <repo URL>/blob/main/<PKG>/main.md#<anchor> +- Concept file (owned by the S2 worker): <repo URL>/blob/main/<PKG>/concepts/<file> +- Transcript segments: <T ids>, exact text at the top of the concept file +- S1 preparation PR: <PR URL> + +## Current state (evidence) +<3-6 lines: what exists, from the repo map, with path:line; overlapping issues/PRs> + +## Research questions and facets +<copy the question ids and one-line facet list; the full text is in the concept file> + +## Owned outputs +The concept file (sole writer); notes to other concepts via `rw note`; receipts for notes sent to <C>. + +## Acceptance evidence +Every question answered or marked open with a reason; every source with its URL; `rw check --package <PKG>` passes; PR open into main. + +## Prerequisites +Blocked by: <requires ids/issues, or none>. Parallel-safe with: <concepts with no shared targets>. + +## First step +Load `.agents/skills/concept-research/SKILL.md` and follow it, starting from the concept file's Research questions. + +## Done contract +Outcome: <the definitive document>. Verified by: <the checks above>. Boundaries: no design or plan; other concepts change only by notes. Stop as blocked if a prerequisite is unmerged or a needed file has another owner; push and say what blocks. + +<!-- workflow:issue {"package":"<PID>","concept":"<C>","stage":"S1"} --> +```