diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index bc23de80..1cd4377a 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -12,7 +12,7 @@ "name": "fathom", "source": "./", "description": "Two agent skills, scaffold and execute, that carry a tracker issue from requirements to an open code review, on GitHub or any other forge with an adapter. Works with Asana or Linear, runs on Claude Code and Kiro, tracks tasks in beads or a committed markdown checklist, and resumes from repository state.", - "version": "2.1.0", + "version": "2.2.0", "author": { "name": "crod951" }, diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 7813b6c4..83906470 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "fathom", - "version": "2.1.0", + "version": "2.2.0", "description": "Fathom provides the execute and scaffold skills for driving Asana or Linear tracker issues from requirements to an open code review, on GitHub or any other forge with an adapter. Agent-portable skills for Claude Code and Kiro with resumable, task-tracked implementation runs.", "author": { "name": "crod951", diff --git a/README.md b/README.md index a9665c47..90bb04a1 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ When the installer asks which skills to take, take all of them; `fathom-shared` ## Available Plugins -### fathom (v2.1.0) +### fathom (v2.2.0) Fathom provides two agent skills, execute and scaffold, that carry a tracker issue from requirements to an open code review, on GitHub or any other forge with an adapter. It works with Asana or Linear as your issue tracker, and both skills run unchanged on Claude Code and Kiro. diff --git a/docs/plans/2026-08-07-fathom-stacked-reviews-design.md b/docs/plans/2026-08-07-fathom-stacked-reviews-design.md new file mode 100644 index 00000000..e24ef5c3 --- /dev/null +++ b/docs/plans/2026-08-07-fathom-stacked-reviews-design.md @@ -0,0 +1,288 @@ +# Fathom stacked reviews design + +Date: 2026-08-07 + +## Problem + +Fathom's `execute` skill drives one tracker issue to exactly one code review. +The breakdown at `execute/SKILL.md:73-97` plans three to seven sub-issues and commits one change per task, then `execute/SKILL.md:99-117` opens a single review covering all of them. + +For a large issue that produces a review that is too big to review well. +The units of work are already sequential and independently verifiable, so they could reach reviewers as a stack of smaller reviews instead. + +The forge contract anticipated this. +`forges.md:54` declares a `stackedReviews` capability with values `retarget`, `declared-dependency`, and `none`, and `forges.md:59-60` records that it is declared but drives no behavior, precisely so that adding it later would not mean revisiting every adapter file. +This design gives that capability its behavior. + +Two forge models are already documented and both must work. +On a `retarget` forge such as GitHub, stacking is branch retargeting, and the forge retargets a dependent review automatically when its upstream merges. +On a `declared-dependency` forge, stacking is an explicit dependency plus a manually scoped commit range, with no automatic rebase. +On a `none` forge there is no forge-level stacking at all, but chaining the branches in git is still useful, so the agent targets the previous bundle's branch and declares the relationship in prose. + +## Goals + +Let one issue produce a short stack of dependent reviews when the work is large enough to warrant it. +Keep the existing single-review behavior as the default for every repository, forge, and issue that does not opt in, where opting in means writing `stacking: propose` into the repository's profile. +Make the split a decision the user can see, override, and pin, rather than something the agent does silently. + +## Non-goals + +No change to the `scaffold` skill. +Bundling is decided at `execute` time, after the sub-issues exist. + +No size estimation before the breakdown. +The threshold reads the breakdown that already exists at step 8, rather than adding a second and less accurate estimator for the same question. + +No stacks in the manual tier. +No new forge operation beyond one optional argument. + +## Design + +### 1. The bundle + +A bundle is a contiguous run of the sub-issue dependency chain that `execute/SKILL.md:76` already builds. +Bundles inherit the chain's ordering rather than inventing an ordering of their own. +Each bundle maps to one branch and one review. + +A bundle boundary may fall only where the planned units up to that point form a self-contained change: the units after the boundary build on the units before it and not the reverse, and the earlier units together deliver something that stands on its own rather than half of one thing. +When no such point exists there is no valid split, and the run proceeds as a single review. + +This criterion is deliberately about the plan rather than about the repository. +The decision happens at breakdown time, before any of the work is written, so the agent cannot build the repository at a candidate boundary or run that bundle's tests: neither exists yet. +An earlier version of this design asked for exactly that, and it was undecidable at the only moment it could be applied. + +So the agent is predicting reviewability, not verifying it, and two things catch a wrong prediction. +The confirmation stop shows the proposed boundaries to the user before anything is built, which is the cheap correction. +The per-bundle finish routine then reconciles and runs that bundle's tests for real, and its existing stop-and-hold fires when they fail, which is the expensive one. +A boundary that looked self-contained in the plan and turns out not to be is therefore caught before its review opens, rather than silently shipped. + +### 2. When a split is proposed + +Both conditions must hold before the agent proposes a split at all: + +- the breakdown produced five or more sub-issues, and +- at least one valid cut point exists. + +At most three bundles, and every bundle holds at least two sub-issues. +Both constraints apply together, so a five sub-issue breakdown can produce at most two bundles and a six sub-issue breakdown is the smallest that can produce three. +The cap is deliberate. +Sub-issues are sized commit-sized rather than review-sized, so one review per sub-issue would turn an ordinary issue into a stack of five to seven tiny reviews, and multiple reviews are a real cost for some teams and workflows. +An explicit user request may exceed the cap; the heuristic never does. + +The manual tier does not propose a split. +A tier-3 forge (`forges.md:123-126`) cannot create reviews, so a three-bundle stack would become three separate sets of instructions for a human to follow by hand. +In tier 3 the agent says the split was not offered and why. +Tier 1 and tier 2 both propose. + +This makes the `none` behavior in section 10 reachable only through a tier-1 repo-local adapter at `.fathom/forge.md` that creates real reviews but has no stacking model of its own. +No bundled adapter reaches it, because `generic-git.md` is the only bundled adapter declaring `none` and it is exactly what the manual tier runs on. + +### 3. The split proposal stop + +The stop fires at step 8, after the breakdown exists and before any task, commit, or review is created. +It shows the proposed bundles, which sub-issues fall in each, and the resolved forge's stacking behavior. + +It goes on the skip list in `approval.md`, not the never-skip list. +It fires before any commit or review exists, so being wrong destroys nothing and misdirects nothing. +Bundle 1's branch does exist by then, because step 7 creates it before step 8 runs, but that branch is the one a single-review run needs anyway, so declining the split wastes nothing and leaves nothing to clean up. +That is the shape of every existing skip-list item, and unlike every never-skip item it destroys nothing and misdirects nothing. +In `ask` mode the run waits for an answer; in `auto` mode it applies the split and reports it. + +`approval.md:69` requires every new stop to be classified explicitly, so this classification is recorded there alongside the existing entries. + +### 4. The profile field + +`.fathom/config.md` gains `stacking`, with two values. + +`propose` means the agent may propose a split, with the approval mode deciding whether that is a question or a report. +`never` makes single-review behavior permanent for the repository, in the same spirit as `forge: none`. + +`never` is the default, so an absent field means the repository never splits an issue and a repository opts in by writing `stacking: propose`. +A `propose` default would silently change behavior for every existing repository, most sharply for one running `approval: auto`, where the split is applied and reported rather than asked about, so its next large issue would arrive as a stack without anyone having asked for stacking. +An opt-in feature must not do that, which is what makes `never` the only default consistent with the goal above of preserving single-review behavior for every repository that does not opt in. + +The field has two values rather than three on purpose. +An `ask` or `auto` value here would duplicate the `approval` field two lines above it in the same file, and two fields that can disagree about the same question is a defect waiting to be filed. + +### 5. Branch naming + +Bundle 1 keeps today's name unchanged, for example `feat/ONC-5-add-webhooks`. +Bundles 2 and 3 append their index: `feat/ONC-5-add-webhooks-2` and `-3`. + +The pattern is predictable and matchable, which is what lets a resumed run find the stack it already built. + +### 6. Ordering is enforced in data + +The split is decided before any task is created, not after. +The bundling proposal and its confirmation happen once the sub-issues are planned and before the `createTask` calls, so every task is created with its final deps in a single pass. + +This ordering is load-bearing rather than tidy. +`createTask` takes `deps` at creation, and the memory contract has exactly six operations with no way to add a dependency to a task that already exists. +Deciding the split after the tasks exist would leave the chain unbuildable, which would silently reinstate the out-of-order hazard this section exists to close. + +When a split is confirmed, every task takes a dependency on its predecessor, so the whole issue becomes one sequential chain across bundles as well as within them. + +`claimNext` returns the first open task whose deps are all closed, so a single chain means it structurally cannot hand out a later bundle's task while any earlier task is still open. +The implementation loop therefore needs no bundle-ordering logic of its own. + +A boundary-only edge, from the first task of bundle k+1 to the last task of bundle k, is not sufficient and was rejected for that reason. +`execute/SKILL.md:76` sets `deps` so tasks chain sequentially "whenever order matters", which leaves tasks with no deps at all legal. +Such a task sitting anywhere in bundle k+1 other than its first position has all of its deps trivially closed, so `claimNext` would hand it out while bundle k was still open, and the branch chain would then be built on unfinished work. + +Requiring the full chain is not a patch on that hole. +It makes the design's own premise explicit: section 1 defines a bundle as a contiguous run of the dependency chain, and if tasks are parallel-claimable there is no chain to cut into contiguous runs in the first place. +Full sequential chaining applies only when a split is confirmed; an ordinary single-review run keeps today's conditional chaining unchanged. + +### 7. Durable record + +Bundle membership is written at step 8 to exactly one place, the plan document's `Bundles` section. +It records, for each bundle, its index, the sub-issue refs and task ids it contains, and its branch name. +One record is deliberate: a second copy elsewhere under `.fathom/` would be a second version of the same fact, and two records of one fact can disagree. + +This is required rather than optional. +`execute/SKILL.md:22` states that every run begins by reading durable state from the repository and the tracker, never from memory of a previous run. +A resumed run recovers the whole stack from this record. + +### 8. Reviews open incrementally + +Step 11 splits into a per-bundle finish routine and a smaller issue-level close. + +The per-bundle routine runs when the last task of bundle k closes: + +1. Reconcile bundle k's task count against the commits on branch k, and stop hard on a mismatch, as the single-review flow does today. +2. Call `resolveBase`. Bundle 1's base is the resolved base branch; bundle k's base is branch k-1. +3. Push branch k, unless the adapter declares `pushesForYou`. +4. Call `openReview`, then `publishReview`. +5. Record `- Review: (bundle k/N)` beneath that bundle's line in the plan document's `Bundles` section, which is the one place bundle records live. +6. When another bundle remains, create branch k+1 from branch k and continue the implementation loop. When bundle k was the last one, fall through to the issue-level close instead. + +The issue-level close runs once, after the last bundle. +It closes the parent task, posts the completion comment listing all N reviews, and commits the run's task state onto branch N, which is the stack tip. + +The `inReview` phase is applied once, when the first bundle's review publishes, and is not re-applied per bundle. +The issue genuinely is in review from that moment. + +Opening incrementally rather than at the end avoids retroactive history surgery. +Building each bundle on the correct branch from the start is free, whereas committing everything to one branch and later cherry-picking commit ranges onto a chain of branches is the failure-prone path. +The bundle boundary is known at claim time, and `execute/SKILL.md:97` guarantees one commit per task, so no reconstruction is needed. + +Opening incrementally also preserves the one-resumable-pass property stated in `execute/SKILL.md:20-21`. +Requiring one invocation per bundle would contradict it by design. + +A useful side effect: when bundle 2 hits an unfixable test failure, bundle 1's review is already open and reviewable. + +### 9. The closing keyword + +`execute/SKILL.md:107` puts `Closes ` in the review body for a Linear issue, or the task's URL for an Asana task. + +In a stack that closing keyword appears in the last bundle's review only. +Earlier bundles reference the issue without a closing keyword and carry two additional lines: `Part k of N`, and `Depends on `. + +Without this rule the first bundle's merge closes the issue while most of the work is still open. + +That rule alone is not sufficient, because it only governs the forge's own keyword integration. +The merge-closer GitHub Action closes an issue by matching the merged branch name against records under `.fathom/`, so it never reads the keyword at all, and every bundle's branch is recorded there. +Under it, merging any bundle in any order closes the issue, and the next sweep then reads that issue as already complete and does nothing, making the early close permanent and silent. + +So a stacked issue suppresses the merge-closer entirely and leaves closure to the sweep, which already waits for every bundle to report `merged`. +The run records a marker on the issue that tells the Action to take no action for it. + +One mechanism closes a stacked issue, not two that disagree. +The cost is real and is stated at handoff: on a repository that relies on the Action for closure, a stacked issue now needs a later sweep run to reach `done`, where a single-review issue still closes on merge without one. + +### 10. Forge contract change + +`openReview` gains one optional fifth argument, `dependsOn`, holding the previous bundle's review id. +The other four operations are unchanged, and no operation is added. + +Adapters key their behavior off their declared `stackedReviews` value: + +| `stackedReviews` | Behavior | +| --- | --- | +| `retarget` | Ignore `dependsOn`. The `base` argument does the work, and the forge retargets on upstream merge. | +| `declared-dependency` | Pass `dependsOn` to the forge's dependency mechanism and scope the commit range. | +| `none` | Ignore `dependsOn`. The `base` argument gives git-level chaining, and the body's `Depends on` line carries the rest. Reachable only from a tier-1 repo-local adapter, per section 2. | + +`forges.md:59-60` stops saying the capability is declared and unused. + +### 11. The rebase obligation + +After an upstream bundle merges, the remaining stack may need rebasing. + +The test is forge-agnostic rather than capability-keyed: check whether the merged content is an ancestor of each remaining stack branch, and rebase only when it is not. + +This is deliberately not keyed on `stackedReviews`. +A squash-merge on a `retarget` forge produces exactly the same problem as a merge on a `none` forge, because the squash commit is not an ancestor of the dependent branch and the dependent review then redisplays the upstream bundle's changes. +The ancestry check catches both cases with one rule, which is the evidence that it is the right check. + +Rebasing pushes with `--force-with-lease`, never a bare force push. + +### 12. The sweep + +The done-on-merge sweep (`execute/SKILL.md:56`) reads every `- Review:` line recorded for the issue rather than one, and calls `getReviewState` on each. + +- All bundles `merged`: move the issue to `done`, as today. +- Some merged and some open: do not close the issue. Report progress, for example `bundle 1/3 merged`, then run the ancestry check from section 11 and rebase the remaining branches bottom-up when needed. +- Any bundle `closed-unmerged`: fire the existing never-skip stop from `approval.md:48`, and name which bundles above it are now orphaned. Close nothing and rebase nothing. +- `reviewLookup: none`: the sweep is unavailable, exactly as today. + +### 13. Failure handling + +Three hold conditions are added, each matching existing precedent rather than introducing a new kind of stop. + +| Condition | Behavior | +| --- | --- | +| `--force-with-lease` rejected during a stack rebase | Stop and hold. Someone else's commits are on that branch, and force-pushing over them is the discarding-someone's-changes hazard that `approval.md:46` already names. | +| Rebase conflict while restacking | Stop and hold, naming the conflicting files, exactly as `execute/SKILL.md:72` does for a base-branch update conflict. | +| Unfixable test failure in bundle k | The existing stop, with an added reporting requirement: name which bundles have open reviews and which were never built. | + +### 14. Resume + +A re-invoked run recovers the stack from the record in `.fathom/`, matches existing branches by the naming pattern from section 5, and reads the recorded review ids. + +The existing rule at `execute/SKILL.md:108`, skip when a review already exists for the branch and reuse that one, becomes per-bundle. +A resumed run must never open a second review for a bundle that already has one. + +### 15. Tier drop mid-stack + +When a later run's `verifyForge()` fails, bundles whose reviews are already open stay as they are, and the remaining bundles are handed off manually per `forges.md:114-116`. + +Say this plainly at handoff, including the consequence already documented in `forges.md:149-158`: no later run will move the issue to `done` on its own, so closing it becomes a manual step. + +## Files touched + +All changes are prose in skill files. No code changes. + +- `skills/fathom-shared/forges.md`: the `dependsOn` argument, the per-capability behavior table, removal of the declared-and-unused paragraph, and the tier-3 no-stack rule. +- `skills/fathom-shared/forges/github.md`: stacking behavior for `retarget`, including the squash-merge caveat. +- `skills/fathom-shared/forges/generic-git.md`: stacking behavior for `none`. +- `skills/fathom-shared/forges/TEMPLATE.md`: guidance for an adapter author implementing `dependsOn`. +- `skills/fathom-shared/approval.md`: the split proposal on the skip list, and the `stacking: propose | never` profile field. +- `skills/fathom-shared/conventions.md`: bundle membership in the plan document, and per-bundle commit reconciliation. +- `skills/fathom-shared/memory.md`: the cross-bundle dependency edge, where the backends need it spelled out. +- `skills/execute/SKILL.md`: steps 7, 8, 10, and 11, plus the sweep in step 2. + +## Verification + +This repository has no unit tests, so verification is what it already runs: + +- `bin/scan-skills.sh` clean against `.skillspector-baseline.yaml`, with any new baseline entry carrying a written reason. +- `bin/sync-versions.sh` for version consistency. +- The `.github/workflows/skillspector.yml` CI workflow. + +Internal consistency is checked by reading the changed files together: every `execute/SKILL.md` step that references a review must be unambiguous about whether it means one review or one bundle's review. + +## Decisions and rationale + +| Decision | Alternative rejected | Why | +| --- | --- | --- | +| Bundles of sub-issues | One review per sub-issue | Sub-issues are sized commit-sized by `execute/SKILL.md:76`, so one review each produces a five to seven review stack of trivial reviews. | +| Single review stays the default | Stack whenever possible | Keeps every existing repository, forge, and tier behaving exactly as today unless something opts in. | +| Agent proposes, user confirms | Agent decides silently | The structural shape of a change's review is a judgment call with real cost to reviewers. | +| Skip-list stop | Never-skip stop | It fires before any branch, commit, or review exists, so being wrong costs nothing. | +| `stacking` with two values | `stacking` with `ask`, `auto`, and `never` | Three values would duplicate the `approval` field in the same profile and could disagree with it. | +| Incremental review opening | All reviews at the end | Opening at the end requires cherry-picking commit ranges onto a chain of branches after the fact. | +| Full sequential chain when stacked | A single edge at each bundle boundary | A boundary edge leaves a dep-free task inside a later bundle claimable while an earlier bundle is open, so it does not deliver the ordering it claims. | +| Ancestry check for rebase | Rebase keyed on `stackedReviews` | A squash-merge on a `retarget` forge has the same problem as a merge on a `none` forge, and one rule covers both. | +| All bundles merged closes the issue | Top of stack merged closes it | Cheaper, but wrong when someone merges out of order or squashes the stack by hand. | +| No stacks in tier 3 | Stacks with N manual handoffs | Three sets of hand-open-this instructions is worse than one review. | diff --git a/docs/plans/2026-08-07-fathom-stacked-reviews-plan.md b/docs/plans/2026-08-07-fathom-stacked-reviews-plan.md new file mode 100644 index 00000000..aac68684 --- /dev/null +++ b/docs/plans/2026-08-07-fathom-stacked-reviews-plan.md @@ -0,0 +1,964 @@ +# Fathom stacked reviews implementation plan + +## Status: completed historical record + +This document is a historical execution record of how the stacked-reviews change was implemented. +Every task in it has been completed. +It is a point-in-time record rather than current guidance, and it is deliberately left as it was written rather than rewritten to track later corrections. + +The skill files under `skills/` are authoritative wherever this document disagrees with them. +Several skill files have been corrected past what this plan describes, so a difference between the two means the skill file is right and this record is simply older. + +The current specification is `docs/plans/2026-08-07-fathom-stacked-reviews-design.md`. +Read that document, and the skill files themselves, for how the feature behaves today. + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Give the reserved `stackedReviews` forge capability real behavior, so one tracker issue can produce a short stack of dependent code reviews when its breakdown is large enough, with the split proposed at breakdown time. + +**Architecture:** Every change is prose in skill markdown files that an agent reads at runtime. There is no source code, no test framework, and no build. The contract files (`forges.md`, `approval.md`, `conventions.md`, `memory.md`) are edited before the adapter files that implement them and before `execute/SKILL.md`, which consumes all of them, so each task lands on top of vocabulary that already exists. + +**Tech Stack:** Markdown skill files under `skills/`. Verification is NVIDIA SkillSpector v2.5.0 via `bin/scan-skills.sh`, version propagation via `bin/sync-versions.sh`, and grep-based cross-file consistency checks. + +**Design document:** `docs/plans/2026-08-07-fathom-stacked-reviews-design.md` + +## Global constraints + +- Never use the em dash character. Use a plain hyphen instead. This applies to every file you touch. +- Put each full sentence on its own physical line in markdown prose. Preserve normal markdown structure otherwise. +- Never write `TODO`, `TBD`, or a placeholder into a skill file. These files are read by an agent at runtime, and a placeholder becomes agent behavior. +- Never stage with `git add -A`, `git add .`, or `git add --all`. Stage the exact paths the task changed. This is the repository's own rule, recorded in `skills/fathom-shared/conventions.md:12-14`. +- Commit subjects follow `type(scope): summary`, lowercase imperative, under 72 characters, no trailing period. Scope is `fathom`. +- Do not add a co-author trailer to any commit. +- Work on the branch `feat/stacked-reviews`, which already exists and already holds the design commit. +- The three values of `stackedReviews` are exactly `retarget`, `declared-dependency`, and `none`. Never invent a fourth. +- The two values of the new `stacking` profile field are exactly `propose` and `never`. +- The bundle cap is at most 3 bundles, each holding at least 2 sub-issues, proposed only when the breakdown has 5 or more sub-issues. + +## Verification model for this repository + +This repository has no unit tests and no test framework, so the ordinary write-a-failing-test cycle does not apply. Do not invent one. Each task below instead ends with two real checks and a commit: + +1. **Scanner check.** `bin/scan-skills.sh` runs NVIDIA SkillSpector against every skill and exits non-zero on any finding not suppressed in `.skillspector-baseline.yaml`. SkillSpector v2.5.0 is already installed at `~/.local/bin/skillspector` and matches the SHA pinned in `.github/workflows/skillspector.yml`. This checks for prompt-injection and unsafe-instruction patterns. It does **not** check that your prose is correct, which is why every task also has check 2. +2. **Consistency check.** A concrete `grep` whose expected output is stated in the step. These exist because the real failure mode for this change is two skill files disagreeing about the same rule, and no tool in this repository catches that. + +If `bin/scan-skills.sh` reports a new finding, do not add a baseline suppression to silence it without reading the finding first. A suppression requires a written reason in `.skillspector-baseline.yaml`, and the existing entries show the expected format. + +--- + +## Task 1: Correct the design document, then change the forge contract + +The design document has one ambiguity found while reading the adapter files, and it must be resolved before any adapter is written against it. + +The design says a `stackedReviews: none` forge stacks branches in git and declares the dependency in prose. It also says the manual tier never proposes a split. But `generic-git.md` is the only bundled adapter declaring `none`, and `forges.md:124` makes generic-git exactly what the manual tier runs on, so those two rules together mean the `none` path is unreachable through any bundled adapter. + +The `none` path is still correct and still needed, but only for a **tier-1 repo-local adapter** at `.fathom/forge.md` that creates real reviews and has no stacking model of its own. Making that explicit is the first step of this task. + +**Files:** +- Modify: `docs/plans/2026-08-07-fathom-stacked-reviews-design.md` (sections 2 and 10) +- Modify: `skills/fathom-shared/forges.md:53-60` (capability table row and the reserved paragraph) +- Modify: `skills/fathom-shared/forges.md:17` (the `openReview` contract row) +- Modify: `skills/fathom-shared/forges.md:105-129` (capability tiers, tier-3 rule) + +**Interfaces:** +- Produces: the argument name `dependsOn`, the phrase `stackedReviews`, and the three behavior rows that Task 2's adapter files implement verbatim. +- Produces: the tier-3 no-stack rule that Task 6 reads when deciding whether to propose a split. + +- [ ] **Step 1: Amend the design document's section 2** + +In `docs/plans/2026-08-07-fathom-stacked-reviews-design.md`, find the paragraph in section 3 (`When a split is proposed`) that begins "The manual tier does not propose a split." Append these two lines to that paragraph: + +```markdown +This makes the `none` behavior in section 10 reachable only through a tier-1 repo-local adapter at `.fathom/forge.md` that creates real reviews but has no stacking model of its own. +No bundled adapter reaches it, because `generic-git.md` is the only bundled adapter declaring `none` and it is exactly what the manual tier runs on. +``` + +- [ ] **Step 2: Amend the design document's section 10** + +In the same file, in section 10, replace the `none` row of the behavior table with this row: + +```markdown +| `none` | Ignore `dependsOn`. The `base` argument gives git-level chaining, and the body's `Depends on` line carries the rest. Reachable only from a tier-1 repo-local adapter, per section 2. | +``` + +- [ ] **Step 3: Change the `openReview` row in the contract table** + +In `skills/fathom-shared/forges.md`, line 17 currently reads: + +```markdown +| `openReview(branch, base, title, body)` | Create the review for a branch against a base. Return a stable review id and the review's URL - or, on a forge where no review can be created, the manual-handoff result defined below. | +``` + +Replace it with: + +```markdown +| `openReview(branch, base, title, body, dependsOn?)` | Create the review for a branch against a base. Return a stable review id and the review's URL - or, on a forge where no review can be created, the manual-handoff result defined below. `dependsOn` is optional and carries the review id this one is stacked on; it is absent for a standalone review and for the first bundle of a stack. | +``` + +- [ ] **Step 4: Replace the `stackedReviews` capability row** + +In the same file, line 54 currently reads: + +```markdown +| `stackedReviews` | `retarget` / `declared-dependency` / `none` | Reserved. No behavior depends on it yet. | +``` + +Replace it with: + +```markdown +| `stackedReviews` | `retarget` / `declared-dependency` / `none` | How this adapter expresses that one review is stacked on another, in `openReview`. | +``` + +- [ ] **Step 5: Replace the reserved paragraph with the behavior rules** + +In the same file, lines 59-60 currently read: + +```markdown +`stackedReviews` is declared and unused. +It is recorded now because the difference is real - `retarget` describes a forge where stacking is branch retargeting with automatic retarget when the upstream merges, and `declared-dependency` describes one where stacking is an explicit dependency plus a manually scoped commit range with no auto-rebase - and because adding a capability key later means revisiting every adapter file. +``` + +Replace both lines with: + +```markdown +`stackedReviews` decides what an adapter does with `openReview`'s optional `dependsOn` argument. + +| Value | What `openReview` does with `dependsOn` | +| --- | --- | +| `retarget` | Ignore it. Passing the previous bundle's branch as `base` is the whole mechanism, and the forge retargets the dependent review automatically when its upstream merges. | +| `declared-dependency` | Pass it to the forge's own dependency mechanism, and scope the review's commit range to this bundle's commits only. Nothing is retargeted automatically. | +| `none` | Ignore it. The `base` argument still chains the branches in git, and the calling skill writes the relationship into the review body in prose. | + +A `none` adapter is still stackable in the only sense that matters to a reader: the branches chain, each review shows one bundle's diff, and the body says what it depends on. +What it lacks is any forge-side record of the relationship, so nothing retargets and nothing warns when the stack is merged out of order. + +Only a repo-local adapter reaches the `none` row in practice. +The one bundled adapter that declares `none` is `generic-git.md`, which is what the manual tier runs on, and the manual tier never proposes a stack. +``` + +- [ ] **Step 6: Add the tier-3 no-stack rule** + +In the same file, in the `Capability tiers` section, find the paragraph beginning "**Tier 3, manual.**" and append this line to the end of that paragraph: + +```markdown +A stack is never proposed in this tier: with no review object to create, a three-bundle stack would become three separate sets of open-this-by-hand instructions, which is worse for the user than one review. +``` + +- [ ] **Step 7: Run the consistency check** + +Run: + +```bash +grep -n "declared and unused\|Reserved. No behavior" skills/fathom-shared/forges.md +``` + +Expected: no output, exit code 1. The reserved language is gone. + +Run: + +```bash +grep -c "dependsOn" skills/fathom-shared/forges.md +``` + +Expected: `3`. `grep -c` counts matching lines rather than occurrences, and Step 5's prose deliberately says "it" rather than repeating the argument name in each behavior row, so three lines carry it: the contract row, the sentence introducing the behavior table, and the table's own header. + +If this returns anything other than 3, report the number rather than dropping the check. A silently omitted verification is worse than a failed one. + +- [ ] **Step 8: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0, no non-suppressed findings. + +- [ ] **Step 9: Commit** + +```bash +git add docs/plans/2026-08-07-fathom-stacked-reviews-design.md skills/fathom-shared/forges.md +git commit -m "feat(fathom): give stackedReviews behavior in the forge contract" +``` + +--- + +## Task 2: Implement the capability in the three adapter files + +**Files:** +- Modify: `skills/fathom-shared/forges/github.md:21` and `:53-68` +- Modify: `skills/fathom-shared/forges/generic-git.md:20-26` and `:46` +- Modify: `skills/fathom-shared/forges/TEMPLATE.md:40` and `:71-83` + +**Interfaces:** +- Consumes: the `dependsOn` argument and the three-row behavior table from Task 1. +- Produces: the squash-merge caveat that Task 7's rebase rule cites. + +- [ ] **Step 1: Update the GitHub adapter's capability note** + +In `skills/fathom-shared/forges/github.md`, line 21 currently reads: + +```markdown +`stackedReviews` is `retarget` because GitHub stacking is branch retargeting, and GitHub retargets a dependent pull request automatically when its upstream merges. +``` + +Append these three lines directly after it: + +```markdown +That automatic retarget is real but partial, and the gap matters to the caller. +When the upstream pull request is **squash-merged**, the squash commit is not an ancestor of the dependent branch, so the dependent pull request retargets to the base and then redisplays the upstream bundle's changes as if they were new. +The dependent branch has to be rebased for its diff to be honest again, which is why the calling skill's rebase rule is keyed on commit ancestry rather than on this capability value. +``` + +- [ ] **Step 2: Update the GitHub adapter's `openReview` heading and body** + +In the same file, change the section heading on line 53 from: + +```markdown +## `openReview(branch, base, title, body)` +``` + +to: + +```markdown +## `openReview(branch, base, title, body, dependsOn?)` +``` + +Then, directly after the paragraph beginning "Return the pull request number as the review id", insert: + +```markdown +Ignore `dependsOn` when it is supplied. +`stackedReviews` is `retarget`, so passing the previous bundle's branch as `base` is the entire mechanism, and GitHub needs no separate dependency declaration. +Never encode the dependency a second way, such as by adding a label or an extra API call; the base branch already carries it and a second representation can disagree with the first. +``` + +- [ ] **Step 3: Update the generic-git adapter** + +In `skills/fathom-shared/forges/generic-git.md`, find the paragraph starting "`reviewLookup: none` is the consequential one." and insert this paragraph directly before it: + +```markdown +`stackedReviews: none` is never exercised through this adapter. +This adapter is what the manual tier runs on, and `../forges.md` states that the manual tier never proposes a stack, so `openReview` here is only ever called for a standalone review. +The value is declared truthfully rather than left absent, because a repo-local adapter author reading this file as the minimum viable example needs to see every capability filled in. +``` + +Then change the section heading on line 46 from: + +```markdown +## `openReview(branch, base, title, body)` +``` + +to: + +```markdown +## `openReview(branch, base, title, body, dependsOn?)` +``` + +Then append this line to the end of the paragraph beginning "There is no review to create": + +```markdown +`dependsOn` is ignored here for the same reason the id is absent: there is no review object to attach a dependency to. +``` + +- [ ] **Step 4: Update the adapter template's guidance** + +In `skills/fathom-shared/forges/TEMPLATE.md`, line 40 currently reads: + +```markdown +> `stackedReviews` - declared but currently unused. `retarget` if stacking means retargeting a branch; `declared-dependency` if it means declaring a dependency plus a commit range. +``` + +Replace it with: + +```markdown +> `stackedReviews` - how your forge expresses that one review is stacked on another, which decides what your `openReview` does with the optional `dependsOn` argument. `retarget` if stacking is just pointing a review at the previous branch, and your forge retargets automatically when the upstream merges. `declared-dependency` if stacking means declaring an explicit dependency and scoping the commit range yourself, with no automatic retarget. `none` if your forge has no stacking model at all, which is a fine answer: the calling skill still chains the branches in git and writes the relationship into the review body. +``` + +- [ ] **Step 5: Update the template's `openReview` section** + +In the same file, change the section heading on line 71 from: + +```markdown +## `openReview(branch, base, title, body)` +``` + +to: + +```markdown +## `openReview(branch, base, title, body, dependsOn?)` +``` + +Then, directly before the line reading `Return the review id and the review's URL.`, insert: + +```markdown +> **Say what you do with `dependsOn`, explicitly, even when the answer is nothing.** It arrives holding the review id this one is stacked on, and it is absent for a standalone review and for the first review in a stack. If you declared `retarget` or `none`, write "Ignore `dependsOn`" and say that the `base` argument carries the relationship. If you declared `declared-dependency`, give the exact command that records the dependency, and say how you scope the review to this bundle's commits only - a declared dependency with an unscoped range shows the upstream bundle's changes twice. +``` + +- [ ] **Step 6: Run the consistency check** + +Run: + +```bash +grep -rn "openReview(branch, base, title, body)" skills/ +``` + +Expected: no output, exit code 1. Every signature now carries `dependsOn?`. + +Run: + +```bash +grep -rln "dependsOn" skills/fathom-shared/forges/ +``` + +Expected: exactly three paths, `github.md`, `generic-git.md`, and `TEMPLATE.md`. + +- [ ] **Step 7: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 8: Commit** + +```bash +git add skills/fathom-shared/forges/github.md skills/fathom-shared/forges/generic-git.md skills/fathom-shared/forges/TEMPLATE.md +git commit -m "feat(fathom): implement dependsOn in the bundled forge adapters" +``` + +--- + +## Task 3: Add the split proposal to the approval contract + +**Files:** +- Modify: `skills/fathom-shared/approval.md:22-34` (the skip list) +- Modify: `skills/fathom-shared/approval.md:71-79` (recording it) + +**Interfaces:** +- Consumes: nothing from earlier tasks. +- Produces: the `stacking: propose | never` profile field name, and the classification that Task 6 cites when it fires the proposal stop. + +`approval.md:69` states that when a new stop is added, it must be explicitly placed in the skip list, the never-skip list, or the unconditional stops. This task performs that classification. + +- [ ] **Step 1: Add the skip-list entry** + +In `skills/fathom-shared/approval.md`, in the `What auto mode skips` section, append this entry to the end of the bullet list: + +```markdown +- The bundle-split proposal in `execute`. + Apply the proposed split and report the bundles rather than asking for confirmation first. + This belongs here rather than on the safety list because it fires before any branch, commit, or review exists, so a wrong answer costs nothing and is corrected by re-running with `stacking: never` or a different instruction. + It is skipped only when the profile's `stacking` field permits a split at all; `stacking: never` suppresses the split itself, in both modes, rather than suppressing the question. +``` + +- [ ] **Step 2: Add the profile field** + +In the same file, in the `Recording it` section, append these lines after the paragraph beginning "First-run setup asks for the mode": + +```markdown +A second field, `stacking`, sits alongside `approval` and answers a different question: whether `execute` may split one issue into a stack of dependent reviews at all. +It holds `propose` or `never`, and an absent field means `never`, so a repository opts into stacking by writing `stacking: propose`. + +`propose` means the agent may propose a split when the breakdown crosses the threshold in `execute`, with the `approval` field above deciding whether that proposal is a question or a report. +`never` means this repository always produces one review per issue, in both approval modes, in the same permanent way that `forge: none` makes the manual tier permanent. + +The field deliberately has two values rather than three. +An `ask` or `auto` value here would restate the `approval` field recorded a few lines above it in the same profile, and two fields that can disagree about the same question will eventually disagree. +``` + +- [ ] **Step 3: Run the consistency check** + +Run: + +```bash +grep -n "stacking" skills/fathom-shared/approval.md +``` + +Expected: exactly 3 matching lines, all using only the values `propose` and `never`. + +`grep -n` counts lines rather than occurrences, and the approved text carries the word on three of them: two in the skip-list entry and one in the profile-field paragraph. If you get a different number, report it rather than dropping the check. + +Run: + +```bash +grep -n "stacking: ask\|stacking: auto" skills/fathom-shared/approval.md +``` + +Expected: no output, exit code 1. The rejected three-value form appears nowhere. + +- [ ] **Step 4: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 5: Commit** + +```bash +git add skills/fathom-shared/approval.md +git commit -m "feat(fathom): classify the bundle-split stop and add the stacking field" +``` + +--- + +## Task 4: Extend the working conventions for bundles + +**Files:** +- Modify: `skills/fathom-shared/conventions.md:44-64` (the plan document) +- Modify: `skills/fathom-shared/conventions.md:78-85` (reconcile before finishing) + +**Interfaces:** +- Consumes: the bundle vocabulary established in Task 1. +- Produces: the `- Bundles:` plan-document section and the per-bundle reconciliation rule that Task 6 invokes. + +Do not touch the `Issue`, `Ref`, and `Branch` labels described at `conventions.md:51-56`. Those exact strings are matched by the merge-closer GitHub Action, and renaming or reformatting them makes the Action close nothing while still exiting successfully. + +- [ ] **Step 1: Add the bundles section to the plan document spec** + +In `skills/fathom-shared/conventions.md`, in the bullet list of plan document sections, insert this bullet directly after the `- **Tasks**` bullet: + +```markdown +- **Bundles** - present only when this issue was split into a stack, and omitted entirely otherwise. + One line per bundle, in stack order, each reading `- Bundle /: - `. + Add a `- Review: (bundle k/N)` line beneath a bundle once its review exists. + The suffix is redundant with the nesting on purpose: the sweep reads these lines individually, and a self-describing record survives being read out of its surrounding context. + This section is the durable record a resumed run reads to recover the stack, so write it when the split is confirmed rather than when the first review opens. +``` + +- [ ] **Step 2: Add the per-bundle reconciliation rule** + +In the same file, in the `Commit verification` section, find the paragraph beginning "Reconcile before finishing." and append these lines to the end of that section, directly before the paragraph beginning "This check guards a hazard": + +```markdown +When the issue was split into a stack, reconcile once per bundle rather than once per issue, and do it before that bundle's review opens rather than at the end of the run. +Count over the range from that bundle's own base to that bundle's head: the resolved base branch for bundle 1, and branch k-1 for bundle k. +Compare that count to the number of tasks closed for that bundle only. +A stack-wide count over the whole range would pass even when one bundle carried another bundle's commits, which is exactly the mistake the check exists to catch. +Stop on a mismatch the same way, and do not open that bundle's review. +``` + +- [ ] **Step 3: Add the review body rule** + +In the same file, append this new section at the end of the file, after `Progress reporting`: + +```markdown +## Review bodies in a stack + +When one issue produced a stack of reviews, the issue-closing reference goes in the last bundle's review body only. + +`execute` puts `Closes ` in the body for a Linear issue, or the task's URL for an Asana task, and both are read by the forge's tracker integration on merge. +Repeating either in every bundle means the first bundle's merge closes the issue while most of the work is still open and unreviewed. + +Every bundle's body carries two additional lines instead: + +- `Part of ` so a reviewer knows this diff is a slice rather than the whole change. +- `Depends on `, omitted for bundle 1, which depends on nothing. + +Earlier bundles still name the issue for context, as a plain link with no closing keyword. +The distinction is between referencing an issue and instructing the forge to close it, and only the last bundle does the second one. +``` + +- [ ] **Step 4: Run the consistency check** + +Run: + +```bash +grep -n "Issue: \|Ref: \|Branch: " skills/fathom-shared/conventions.md +``` + +Expected: the same output as before your edits, one line containing all three labels. If this changed, you altered the merge-closer contract and must revert that part. + +Run: + +```bash +grep -n "Part of \|Depends on \|Bundle /" skills/fathom-shared/conventions.md +``` + +Expected: 3 matching lines. + +- [ ] **Step 5: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 6: Commit** + +```bash +git add skills/fathom-shared/conventions.md +git commit -m "feat(fathom): add bundle records, reconciliation, and stack bodies" +``` + +--- + +## Task 5: Extend the memory contract for multiple reviews + +**Files:** +- Modify: `skills/fathom-shared/memory.md:14` (the `createTask` row) +- Modify: `skills/fathom-shared/memory.md:59-66` (the no-dual-truth section) + +**Interfaces:** +- Consumes: the `- Bundles:` plan-document section from Task 4. +- Produces: the cross-bundle dependency edge rule that Task 6 applies at breakdown. + +No new memory operation is added. `createTask` already accepts `deps`, which is all the cross-bundle edge needs. + +- [ ] **Step 1: Note the cross-bundle edge on `createTask`** + +In `skills/fathom-shared/memory.md`, append this sentence to the end of the `createTask` row's cell in the contract table, keeping it on the same table line: + +``` +When the issue was split into a stack, every task takes a dep on its predecessor so the whole issue forms one sequential chain across bundles as well as within them, which is what lets the backend itself enforce bundle order: a later bundle's task is never claimable while any earlier task is still open. A single edge at each bundle boundary would not achieve this, because a task carrying no deps at all has them trivially closed and stays claimable out of order. +``` + +- [ ] **Step 2: Update the record requirement for stacks** + +In the same file, line 65 currently reads: + +```markdown +Whichever backend is active, at least one file under `.fathom/` must record the issue's branch, its review id once one exists, and its tracker URL, because the merge sweep finds an issue by searching that directory, and a merge-closer running on the forge's own CI finds one the same way. +``` + +Append these lines directly after it: + +```markdown +A stacked issue has more than one branch and more than one review id, so it records one of each per bundle, in stack order, in the plan document's `Bundles` section described in `conventions.md`. +The single `Branch` line at the top of the plan document keeps naming bundle 1's branch and is never removed, because the merge-closer Action matches that exact label and knows nothing about stacks. +This is a record of structure rather than of status, so it does not violate the no-dual-truth rule above: task status still lives only in the resolved backend, and the sweep reads review ids from these lines the same way it reads the single-review one. +``` + +- [ ] **Step 3: Run the consistency check** + +Run: + +```bash +grep -n "Bundles" skills/fathom-shared/memory.md skills/fathom-shared/conventions.md +``` + +Expected: at least one line from each file, both naming the same `Bundles` section. + +Run: + +```bash +grep -c "^| \`" skills/fathom-shared/memory.md +``` + +Expected: `6`. The contract still has exactly six operations and you added none. + +- [ ] **Step 4: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 5: Commit** + +```bash +git add skills/fathom-shared/memory.md +git commit -m "feat(fathom): record stack structure and cross-bundle task deps" +``` + +--- + +## Task 6: Add bundling to the execute breakdown and branch steps + +**Files:** +- Modify: `skills/execute/SKILL.md:69-72` (step 7, branch creation) +- Modify: `skills/execute/SKILL.md:73-80` (step 8, breakdown) + +**Interfaces:** +- Consumes: the `stacking` field from Task 3, the `Bundles` plan section and cap from Task 4, the cross-bundle dep edge from Task 5, and the tier-3 no-stack rule from Task 1. +- Produces: the branch naming pattern `-` that Tasks 7 and 8 match against. + +Steps are renumbered nowhere. Insert into the existing numbered steps 7 and 8 without changing any step number, because `execute/SKILL.md` steps are referenced by number from other files in this repository. + +- [ ] **Step 1: Add the bundle branch naming rule to step 7** + +In `skills/execute/SKILL.md`, append these lines to the end of step 7, after the paragraph about conflicts: + +```markdown + These rules describe bundle 1's branch, which is the only branch a single-review run has. + When step 8 confirms a stack, later bundles take the same name with their index appended, so bundle 2 of `feat/ONC-5-add-webhooks` is `feat/ONC-5-add-webhooks-2`. + Create each of those from the previous bundle's branch at the moment that bundle starts, not up front: creating them all at breakdown time would leave empty branches behind whenever a run stops early. +``` + +- [ ] **Step 2: Add the bundling decision to step 8** + +In the same file, insert these bullets into step 8, directly after the bullet beginning "- When the issue already has children": + +```markdown + - Decide whether this issue produces one review or a stack, once the child tasks exist and before any dependency edge is added. + Read the profile's `stacking` field per `../fathom-shared/approval.md`; treat an absent field as `never`, and stop considering a split immediately when it reads `never`. + Do not consider a split when the resolved forge tier is the manual tier, and say once that the split was not offered because the tier cannot create reviews. + Otherwise propose a split only when both conditions hold: the breakdown has five or more sub-issues, and at least one valid cut point exists. + A cut point is valid only where the work up to it is independently mergeable, meaning the repository builds, that bundle's tests pass, and merging it alone would not break the base branch. + When no valid cut point exists, proceed as a single review and say so rather than forcing a boundary. + - Shape the bundles as contiguous runs of the sub-issue dependency chain, so bundles inherit its order rather than inventing one. + Produce at most three bundles, each holding at least two sub-issues; those two limits together mean five sub-issues yield at most two bundles, and six is the smallest breakdown that can yield three. + Exceed the cap only when the user asked for a specific larger split; never exceed it on the heuristic's own judgment. + - Present the proposed split before creating anything: the bundles, which sub-issues fall in each, and the resolved forge's `stackedReviews` value with what it means for this run. + This is a skip-list stop per `../fathom-shared/approval.md`, so `ask` mode waits for an answer and `auto` mode applies the split and reports it. + - When a split is confirmed, chain every task in the issue sequentially, so each task deps on its predecessor across bundle boundaries as well as within them, rather than only where order matters. + This is what makes `claimNext` structurally unable to hand out a later bundle's task while any earlier task is open, so the implementation loop needs no bundle-ordering logic of its own. + A single edge at each bundle boundary is not enough: a task carrying no deps has them trivially closed, so it stays claimable out of order and the branch chain would be built on unfinished work. + Apply full chaining only when a split is confirmed; a single-review run keeps the conditional chaining described above. + Then write the `Bundles` section of the plan document described in `conventions.md`, and commit it with the breakdown. +``` + +- [ ] **Step 3: Run the consistency check** + +Run: + +```bash +grep -nE "^[0-9]+\. " skills/execute/SKILL.md +``` + +Expected: steps numbered 1 through 12 with no gaps and no duplicates, exactly as before your edits. + +Use `grep -E` here, not plain `grep`. macOS ships BSD grep, whose basic regex does not honor `\?`, so a pattern written that way matches nothing at all and the check silently passes while proving nothing. + +Run: + +```bash +grep -n "stacking" skills/execute/SKILL.md +``` + +Expected: at least 1 line, referencing `../fathom-shared/approval.md`. + +- [ ] **Step 4: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 5: Commit** + +```bash +git add skills/execute/SKILL.md +git commit -m "feat(fathom): propose a bundle split during breakdown" +``` + +--- + +## Task 7: Split the finish step into a per-bundle routine + +**Files:** +- Modify: `skills/execute/SKILL.md:82-97` (step 10, the implementation loop) +- Modify: `skills/execute/SKILL.md:99-117` (step 11, finishing) + +**Interfaces:** +- Consumes: the branch naming pattern from Task 6, the per-bundle reconciliation and review-body rules from Task 4, and `dependsOn` from Task 1. +- Produces: the `(bundle k/N)` review record format that Task 8's sweep reads. + +Step 11 keeps its number and its single-review text. The stack behavior is added as a clearly scoped alternative within it, so a reader on a single-review run is never asked to follow stack rules. + +- [ ] **Step 1: Add the bundle boundary to the implementation loop** + +In `skills/execute/SKILL.md`, append this bullet to step 10's inner bullet list, directly after the bullet beginning "- Print the per-task progress line": + +```markdown + - When this issue was split into a stack and the closed task was the last one in its bundle, run the per-bundle finish routine in step 11 for that bundle before claiming again, then, when a later bundle remains, create the next bundle's branch from this one and continue the loop on it. + Do not wait until the loop drains to open any review: building each bundle on the correct branch from the start is what avoids having to cherry-pick commit ranges onto a chain of branches afterwards. +``` + +- [ ] **Step 2: Add the per-bundle routine to step 11** + +In the same file, insert this block into step 11, directly before the paragraph beginning "Finally, post a completion comment": + +```markdown + When this issue was split into a stack, the review-opening portion above is a per-bundle routine rather than a single closing action, and step 10 invokes it once per bundle as that bundle's last task closes. + For bundle k of N: + - Reconcile bundle k's closed tasks against the commits on its branch, over that bundle's own range, per the per-bundle rule in `conventions.md`; stop and do not open this bundle's review when they disagree. + - Call `resolveBase` on bundle 1's base, which is the resolved base branch, or on branch k-1 for every later bundle. + - Push branch k, unless the adapter declares `pushesForYou`, exactly as the single-review path does. + - Call `openReview` with branch k, that base, a title naming the bundle, and a body built per the stack rules in `conventions.md`: the closing reference only in bundle N, plus `Part k of N`, plus `Depends on` the previous bundle's review URL for every bundle after the first. + Pass the previous bundle's review id as `dependsOn` for every bundle after the first, and omit it for bundle 1. + - Call `publishReview` with the returned id. + - Record `- Review: (bundle k/N)` beneath that bundle's line in the plan document's `Bundles` section, since the sweep looks reviews up by id and needs every one of them. + - Apply `inReview` when bundle 1's review publishes, and never again for the later bundles; the issue is genuinely in review from that moment and re-applying a phase it already holds reports progress that did not happen. + Skip a bundle whose review already exists and reuse it, the same way the single-review path does, so a resumed run never opens a second review for a bundle that has one. + After bundle N's routine completes, skip the single-review path above entirely and continue into the closing actions below, which run once for the issue rather than once per bundle. +``` + +- [ ] **Step 2b: Scope the existing single-review path so a stacked run cannot fall into it** + +This is the other half of Step 2, and without it the two paths are not mutually exclusive. A stacked run reaches `claimNext` returning none after its last bundle's routine has already opened that bundle's review, and then executes the original text as well. + +In the same file, replace this line: + +```markdown +11. Once `claimNext` returns none remaining, finish the issue. +``` + +with: + +```markdown +11. Once `claimNext` returns none remaining, finish the issue. + This step has two mutually exclusive paths, and exactly one of them runs. + A single-review issue follows the single-review path immediately below, then the closing actions at the end of this step. + A stacked issue skips that path entirely and goes straight to the closing actions, because step 10 already opened every one of its reviews through the per-bundle routine further down. + Running the single-review path on a stacked issue would reconcile the whole issue against a single bundle's commit range, write a second review record in a format the sweep does not read, and move the issue to `inReview` a second time. + A stacked issue also never enters this step on its own: step 10 invokes the per-bundle routine directly, and bundle N's routine runs the closing actions once as it finishes. + So when the loop afterwards drains and `claimNext` returns none, this step has already completed for that issue, and nothing in it runs a second time. + + The single-review path, for an issue that was not split into a stack: +``` + +- [ ] **Step 3: Point the closing commit at the stack tip** + +In the same file, in step 11's final paragraph about the closing commit, append: + +```markdown + On a stacked issue this closing commit goes on branch N, the stack tip, because that branch contains every bundle's history and is the only one whose review shows the completed task state. +``` + +- [ ] **Step 4: Extend the hold report for partial stacks** + +In the same file, append this line to step 10's bullet beginning "- On a failure that cannot be fixed": + +```markdown + On a stacked issue, also name which bundles already have open reviews and which were never built, since some of the work is already in front of reviewers and the user needs to know which part held. +``` + +- [ ] **Step 5: Run the consistency check** + +Run: + +```bash +grep -n "bundle k/N" skills/execute/SKILL.md skills/fathom-shared/conventions.md +``` + +Expected: at least one line from each file, both using the identical `(bundle k/N)` format. + +Run: + +```bash +grep -nE "^[0-9]+\. " skills/execute/SKILL.md +``` + +Expected: steps 1 through 12 still present, in order, unrenumbered, with steps 9 through 12 at the end. + +Use `grep -E` here, not plain `grep`. macOS ships BSD grep, whose basic regex does not honor `\?`, so a pattern written that way matches nothing and the check silently passes while proving nothing. + +- [ ] **Step 6: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 7: Commit** + +```bash +git add skills/execute/SKILL.md +git commit -m "feat(fathom): open one review per bundle as each bundle completes" +``` + +--- + +## Task 8: Teach the sweep about stacks and restacking + +**Files:** +- Modify: `skills/execute/SKILL.md:56-61` (step 2, the done-on-merge sweep) + +**Interfaces:** +- Consumes: the `(bundle k/N)` record format from Task 7 and the squash-merge caveat from Task 2. +- Produces: nothing later tasks depend on. + +- [ ] **Step 1: Add the multi-review sweep rules** + +In `skills/execute/SKILL.md`, append these lines to the end of step 2: + +```markdown + An issue split into a stack has one recorded review per bundle rather than one in total, so call `getReviewState` on every recorded id before deciding anything about the issue. + A stack can satisfy more than one of the cases below at once, so check them in the order written and let the first one that applies decide the whole sweep. + In particular a stack can hold a merged bundle, an open bundle, and an abandoned one simultaneously, and the abandoned bundle wins: restacking the bundles above it would force-push a rebase onto work the user may be about to discard, which is exactly the unattended destruction that stop exists to prevent. + When any bundle reports `closed-unmerged`, apply the closed-without-merging path for that bundle, name which bundles above it in the stack are now orphaned by it, and neither close the issue nor restack anything; whether to retry, rescope, or drop the orphaned work is the user's judgment call. + This case is checked first and is terminal: no later case runs after it, however many other bundles merged or stayed open. + Otherwise move the issue to `done` when every bundle reports `merged`. + Otherwise, with some bundles merged and others still open, close nothing: report the partial progress, naming which bundles merged, then run the restack check below. + When the adapter declares `reviewLookup: none` the whole sweep is unavailable here as it already is for single reviews, so say so once and act on nothing. + + The restack check asks one forge-agnostic question: is the merged bundle's content an ancestor of each remaining stack branch? + Rebase a remaining branch onto its updated base only when the answer is no, and leave it alone when the answer is yes. + Ancestry is the right test rather than the adapter's `stackedReviews` value, because a squash-merge on a `retarget` forge leaves a dependent review redisplaying the merged bundle's changes exactly as an unretargeted `none` forge would, and one check covers both. + Rebase the remaining branches bottom-up, so each one lands on a base that is already correct. + Push a rebased branch with `--force-with-lease` and never with a bare force push. + When the lease is rejected, stop and hold: another commit reached that branch, and overwriting it discards someone's work, which is the hazard `../fathom-shared/approval.md` already refuses to take unattended. + When the rebase conflicts, stop and hold naming the conflicting files, exactly as a base-branch update conflict does in step 7. +``` + +- [ ] **Step 2: Add the mid-stack tier drop rule** + +In the same file, append this line to step 1, after the sentence about stating the resolved tier: + +```markdown + When a resumed run resolves the manual tier on an issue whose earlier bundles already have open reviews, leave those reviews alone and hand the remaining bundles off manually, saying that the tier changed between runs so the stack is now half automated and half manual. +``` + +- [ ] **Step 3: Run the consistency check** + +Run: + +```bash +grep -n "force-with-lease" skills/execute/SKILL.md +``` + +Expected: exactly 1 line, the one requiring the flag and forbidding a bare force push. +The sentence handling a rejected lease follows it and says "the lease is rejected" without repeating the flag name, so it does not match this pattern. +There must be no line permitting a bare `--force`. + +Also confirm by reading that the sentence immediately after it stops and holds when the lease is rejected. +That behavior is the point of the check, and a grep count alone cannot prove it. + +Run: + +```bash +grep -n "git push --force[^-]" skills/execute/SKILL.md +``` + +Expected: no output, exit code 1. + +- [ ] **Step 4: Run the scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0. + +- [ ] **Step 5: Commit** + +```bash +git add skills/execute/SKILL.md +git commit -m "feat(fathom): sweep every bundle and restack on ancestry" +``` + +--- + +## Task 9: Bump the version and run the full verification + +**Files:** +- Modify: `.claude-plugin/plugin.json` (the `version` field) +- Modify: `.claude-plugin/marketplace.json` and `README.md` (written by the sync script, not by hand) + +**Interfaces:** +- Consumes: every preceding task. +- Produces: nothing. + +- [ ] **Step 1: Bump the plugin version** + +In `.claude-plugin/plugin.json`, change: + +```json + "version": "2.1.0", +``` + +to: + +```json + "version": "2.2.0", +``` + +This is a minor bump because the change adds behavior and every existing repository, forge, and tier keeps behaving exactly as before unless it opts in. + +Do not edit `.claude-plugin/marketplace.json` or `README.md` by hand. `plugin.json` is the source of truth and the next step propagates it. + +- [ ] **Step 2: Propagate the version** + +Run: + +```bash +bin/sync-versions.sh +``` + +Expected: exit code 0, and `git status --short` now shows `.claude-plugin/marketplace.json` and `README.md` as modified. + +- [ ] **Step 3: Run the full scanner** + +Run: + +```bash +bin/scan-skills.sh +``` + +Expected: exit code 0, no non-suppressed findings across all three skills. + +- [ ] **Step 4: Run the whole-change consistency check** + +Run: + +```bash +grep -rn "declared and unused\|Reserved. No behavior\|openReview(branch, base, title, body)" skills/ +``` + +Expected: no output, exit code 1. No file still describes the capability as unused or the signature as four-argument. + +Run: + +```bash +grep -rn "—" skills/ docs/plans/2026-08-07-fathom-stacked-reviews-design.md +``` + +Expected: no output, exit code 1. No em dash was introduced. + +Do not add the plan file itself to this check. The plan contains this very grep command, so the literal character appears in it by necessity and would always match. + +Run: + +```bash +grep -rn "TODO\|TBD" skills/ +``` + +Expected: no output, exit code 1. + +- [ ] **Step 5: Read the changed files together** + +Open `skills/execute/SKILL.md`, `skills/fathom-shared/forges.md`, `skills/fathom-shared/conventions.md`, and `skills/fathom-shared/approval.md` side by side and confirm three things by reading, because no tool in this repository checks them: + +- Every place that says "the review" for a stacked issue is unambiguous about whether it means one bundle's review or all of them. +- The bundle cap (3 bundles, 2 sub-issues each, 5 sub-issue threshold) appears with identical numbers everywhere it appears. +- The `stacking` field is described identically in `approval.md` and `execute/SKILL.md`. + +Fix any disagreement in place before committing. + +- [ ] **Step 6: Commit** + +```bash +git add .claude-plugin/plugin.json .claude-plugin/marketplace.json README.md +git commit -m "chore(fathom): release 2.2.0 with stacked reviews" +``` + +--- + +## Self-review record + +**Spec coverage.** Every numbered section of the design document maps to a task: sections 1, 2, 3 and 4 to Tasks 3 and 6; section 5 to Task 6; sections 6 and 7 to Tasks 5 and 6; sections 8 and 9 to Tasks 4 and 7; section 10 to Tasks 1 and 2; sections 11, 12 and 13 to Task 8; section 14 to Task 7; section 15 to Task 8; the `Files touched` list to Tasks 1 through 8; and `Verification` to Task 9. + +**Spec gap found and fixed.** The design's `stackedReviews: none` behavior was unreachable through any bundled adapter, because the only bundled adapter declaring `none` is the one the manual tier runs on, and the manual tier never stacks. Task 1 Steps 1 and 2 amend the design document to scope that row to tier-1 repo-local adapters, and Task 2 Step 3 records the same fact in `generic-git.md`. + +**Naming consistency.** The argument is `dependsOn` in Tasks 1, 2 and 7. The record format is `(bundle k/N)` in Tasks 4, 7 and 8. The plan-document section is `Bundles` in Tasks 4, 5 and 6. The profile field is `stacking` with values `propose` and `never` in Tasks 3 and 6. The branch pattern is the base name with `-` appended in Tasks 6 and 7. diff --git a/skills/execute/SKILL.md b/skills/execute/SKILL.md index 9e6b5a20..f5e9ede2 100644 --- a/skills/execute/SKILL.md +++ b/skills/execute/SKILL.md @@ -53,12 +53,43 @@ If any of these files cannot be found and read, stop immediately and report whic This keeps preflight, the sweep, and the run itself on one tracker; verifying whatever the profile names while the invocation clearly targets the other tracker would sweep and verify the wrong one. Stop here, following that section's instructions, when the tracker's MCP does not verify. A forge that does not verify is not a stop: it selects a capability tier per `../fathom-shared/forges.md`. State the resolved tier before continuing, so the user knows up front whether this run will end in an opened review or a manual handoff. + When a resumed run resolves the manual tier on an issue whose earlier bundles already have open reviews, leave those reviews alone and hand the remaining bundles off manually, saying that the tier changed between runs so the stack is now half automated and half manual. + Say with it that no later run will move this issue to `done` on its own, because the manual tier cannot observe what happened to a review, so closing the issue is now a manual step. 2. Run the done-on-merge sweep for the resolved tracker; the mechanics are described in `../fathom-shared/trackers.md` and are tracker-agnostic, with each adapter file defining only its own closure action for the merged path. This sweep is itself tracker work, so it only runs once preflight has verified the MCP. When the invocation itself was a cleanup phrase, run only this sweep, report what it found, then stop; do not continue into the rest of this procedure. Treat any claim about a review's fate as a cleanup phrase, whether it says merged, closed, abandoned, landed, or shipped, and whether it names an issue or asks to clean up whatever is outstanding. Never act on the claim itself: confirm each referenced review's real state through `getReviewState` first, then apply the merged path or the closed-without-merging path accordingly, and say plainly when the confirmed state differs from what the user described. When the resolved forge declares `reviewLookup: none`, the claim cannot be confirmed at all. Say that plainly and act on nothing; do not close an issue on the strength of an unverifiable claim, since a wrong close is exactly what the confirmation step exists to prevent. + That same `reviewLookup: none` declaration makes the whole sweep unavailable, exactly as it already is for single reviews, so say so once and act on nothing. + Check it before the cases below rather than after them, since it decides whether `getReviewState` can be called at all. + An issue split into a stack has one recorded review per bundle rather than one in total, so collect every bundle's record first, then call `getReviewState` on every id collected before deciding anything about the issue. + Those records are not all reachable from the checkout this sweep runs in: each bundle's `- Review:` line is committed on that bundle's own branch, so a sweep running from the base branch checkout sees the records of the bundles that have merged and none of the records above them. + Collect the rest by fetching, per the collection rule in `../fathom-shared/trackers.md`: read the branch names from the plan document's `Bundles` section, fetch each of those branches, and read each fetched branch's own copy of the plan document, taking every `- Review:` line it carries rather than only the line for the bundle that branch belongs to. + Take them all because a recovery run records a bundle's outcome on whichever branch it was on, which is that bundle's own branch in the ordinary case and a different one when that bundle's branch is gone. + This is read-only git work that writes nothing, which is why the ids stay in the plan document rather than being mirrored into a second store the base branch could read directly; one record of a fact cannot disagree with itself. + A stack can satisfy more than one of the cases below at once, so check them in the order written and let the first one that applies decide the whole sweep. + In particular a stack can hold a merged bundle, an open bundle, and an abandoned one simultaneously, and the abandoned bundle wins: restacking the bundles above it would force-push a rebase onto work the user may be about to discard, which is exactly the unattended destruction that stop exists to prevent. + When any bundle reports `closed-unmerged`, apply the closed-without-merging path for that bundle, name which bundles above it in the stack are now orphaned by it, and neither close the issue nor restack anything; whether to retry, rescope, or drop the orphaned work is the user's judgment call. + This case is checked first and is terminal: no later case runs after it, however many other bundles merged or stayed open. + Otherwise, when any bundle reports `unknown`, or the collection above found no `- Review:` record for some bundle between 1 and N, change nothing about the issue and leave it for a later sweep: name the review ids that came back `unknown` and the bundles whose records are missing, close nothing, restack nothing, and report no progress for the issue. + `unknown` means the sweep did not learn that review's fate, not that the review is open or merged, so calling it any of those states is a claim about work that was never observed. + A missing record is the same kind of gap and is treated identically: the `Bundles` section says how many bundles this issue has, so N is known even when a record is not, and a stack judged on fewer records than N is judged on an incomplete set. + A bundle carrying only the `- Review: pending (bundle k/N)` marker described in `conventions.md`, or only the `- Review: none confirmed (bundle k/N)` line that records a user's confirmation that no review exists, counts as a missing record here rather than as a review: neither line names an id, so there is nothing for `getReviewState` to be called on and nothing is known about that bundle's fate. + With N of 3 and only two records collected, every case below would read a partly recorded three-bundle stack as a complete two-bundle one, and the first of them would move a half-merged issue to `done`. + So require a record for every bundle from 1 to N before evaluating any of the aggregate cases below, and take this case whenever that requirement is unmet. + This case sits below the `closed-unmerged` case, which closes nothing and restacks nothing whatever the undetermined or unrecorded bundles turn out to be, and above the three cases below, each of which judges the whole stack on all of its bundles at once and cannot do that with an undetermined or missing bundle among them. + Otherwise move the issue to `done` when every bundle reports `merged`. + Otherwise, with some bundles merged and others still open, close nothing: report the partial progress, naming which bundles merged, then run the restack check below. + Otherwise every bundle is still open, with none merged, none abandoned, and none undetermined, so the stack is simply still in review: say that, close nothing, and restack nothing, since no merge has moved any base. + + The restack check asks one forge-agnostic question: is the merged bundle's content an ancestor of each remaining stack branch? + Rebase a remaining branch onto its updated base only when the answer is no, and leave it alone when the answer is yes. + Ancestry is the right test rather than the adapter's `stackedReviews` value, because a squash-merge on a `retarget` forge leaves a dependent review redisplaying the merged bundle's changes exactly as an unretargeted `none` forge would, and one check covers both. + Rebase the remaining branches bottom-up, so each one lands on a base that is already correct. + Push a rebased branch with `--force-with-lease` and never with a bare force push. + When the lease is rejected, stop and hold: another commit reached that branch, and overwriting it discards someone's work, which is the hazard `../fathom-shared/approval.md` already refuses to take unattended. + When the rebase conflicts, stop and hold naming the conflicting files, exactly as a base-branch update conflict does in step 7. 3. Resolve which tracker owns this issue and which memory backend owns its task state, following `trackers.md` and `memory.md`. When the repo already contains beads state but the beads tooling is unavailable on this machine, stop and say so as memory.md directs; never substitute a different backend for a repo whose state lives in another one. Load the existing `.fathom/config.md` tracker profile, or run first-run setup when none exists; either way, run the tracker adapter's profile-load checks and honor any one-time offers they define. @@ -66,20 +97,80 @@ If any of these files cannot be found and read, stop immediately and report whic 5. Call `getIssue` for that ref and save its title, description, type, URL, and existing children for the rest of this run. When the issue is already in the `done` phase or marked complete, do not start work: say so, report what the sweep found for it, and ask whether to reopen it or pick a different issue. 6. Search the codebase and read the files that look relevant to this issue, noting existing patterns to follow during implementation. -7. Ensure a feature branch exists for this issue; when one must be created, prefix its name from the issue type (`feat/` for a feature, `fix/` for a bug, `chore/` for a chore, `docs/` for docs, `feat/` by default) followed by the issue ref and a short title slug; skip creation when a matching branch already exists. +7. Ensure the branch this run implements on exists, and continue on that one branch until step 10 says to move to the next bundle. + Decide which branch that is before creating anything: read this issue's plan document when one already exists, since a resumed run recovers the stack from durable state and never from memory of an earlier run. + When that document carries a `Bundles` section, this issue was already split: recover every bundle's index, branch, sub-issue refs, and recorded review id from it, and carry that recovered stack through the rest of this run, including step 10's loop and step 11's per-bundle routine. + The bundle in progress is the first one with no recorded review, because a bundle's review is recorded as its last task closes, so this run continues on that bundle's branch rather than on bundle 1's. + Continuing on bundle 1's branch instead would land a later bundle's commits in a review that is already open and published, which is the failure this recovery exists to prevent. + When every bundle already carries a recorded review, no bundle is in progress and the branch is bundle N's, the stack tip: every bundle's work is committed and reviewed, so all that can remain is the issue-level finalization, which step 11 puts on the tip branch anyway. + Do not create another branch and do not go back to an earlier bundle's branch in that case; this run is finishing the stack rather than building it. + The branch is bundle 1's whenever no plan document exists yet, which is a first run rather than a resumed one, and whenever the plan document carries no `Bundles` section, which is a single-review issue. + + Name a branch that must be created from the issue type (`feat/` for a feature, `fix/` for a bug, `chore/` for a chore, `docs/` for docs, `feat/` by default) followed by the issue ref and a short title slug; skip creation when a matching branch already exists. Resolve the base branch per the base-branch rules in `../fathom-shared/forges.md`, then fetch it and create the new branch from the fetched remote copy rather than from a local copy that may be behind, since branching from a stale local copy is the usual cause of conflicts at merge time. When the branch already exists and the base branch has moved on since, bring it up to date before implementing, and report that you did. When that update conflicts, stop and hold exactly as an unfixable test failure would: keep the work, leave the task in progress, report which files conflict, and let the user decide how to resolve them; never resolve a conflict by discarding either side's changes. + These rules describe bundle 1's branch, which is the only branch a single-review run has. + When step 8 confirms a stack, later bundles take the same name with their index appended, so bundle 2 of `feat/ONC-5-add-webhooks` is `feat/ONC-5-add-webhooks-2`. + Create each of those from the previous bundle's branch at the moment that bundle starts, not up front: creating them all at breakdown time would leave empty branches behind whenever a run stops early. + Give every one of them the same already-exists guard bundle 1 has: check out a bundle branch that already exists rather than creating it, and create it only when it is genuinely absent, since creating a branch name that already carries that bundle's commits either fails outright or resets the branch and discards them. + Genuinely absent means absent from the local repository and from the remote both, and it also means no run has ever built that bundle, which holds only when the bundle's entry in the `Bundles` section carries no `- Review:` line of any kind, the pending marker included. + When a bundle's entry carries one of those lines and its branch is absent from both, do not create the branch: some run already committed on it, and recreating the name from the branch below would produce an empty branch that silently drops that bundle's commits. + Stay on the highest bundle branch at or below that one that still exists, and let the run reach the per-bundle routine in step 11 for that bundle, which records what it can learn about that bundle's review and then holds on the missing branch. + Staying rather than stopping outright is what makes that record possible: the branch this run is on is a branch that exists, so a bookkeeping commit can be written and pushed on it, where branch k offers no write path at all. 8. Ensure the breakdown exists. - Skip the rest of this step when a breakdown already exists for this issue. - - Call `init` for the issue, then call `parentTask` for it. - - When the issue has no existing children, plan three to seven units of work, each sized so it can be implemented and verified on its own; for each one, call `createSubIssue` first, then call `createTask` with the newly created sub-issue's ref as `subIssueRef`, then write the returned task id back onto that sub-issue so the link reads both ways, since the task id does not exist until `createTask` returns, setting `deps` to the id of the task it builds on so tasks chain sequentially by default whenever order matters. - - When the issue already has children, call `listSubIssues` to adopt them instead of inventing a new breakdown; for each adopted sub-issue, still call `createTask`, passing that sub-issue's existing ref as `subIssueRef` and skipping `createSubIssue` since the sub-issue already exists, then write the returned task id back onto that sub-issue the same way, and setting `deps` the same way. + Every decision below is made once, at breakdown time, so a resumed run reads the split, the bundles, and their branches out of the plan document instead of deciding any of them again. + When that plan document carries a `Bundles` section, the stack step 7 recovered from it governs the rest of this run, and arriving here with such a section on disk but no recovered stack is the defect: go back to step 7 and recover it before implementing anything. + A resumed single-review issue has no `Bundles` section and so has nothing to recover; step 7 has already put it on its one branch. + - Plan the units of work before writing anything to the tracker or the memory backend. + When the issue has no existing children, plan three to seven units of work, each sized so it can be implemented and verified on its own, and hold that plan rather than creating anything from it yet. + When the issue already has children, call `listSubIssues` to adopt them instead of inventing a new breakdown, which reads the tracker without writing to it. + Either way the units are ordered, each building on the one before it, and that order is what the `deps` below and any bundle boundary follow. + - Decide whether this issue produces one review or a stack, from those planned units and before anything is written to the tracker. + Never consider a split when the resolved forge tier is the manual tier, whatever the breakdown looks like, since that tier cannot create a review at all. + Read the profile's `stacking` field per `../fathom-shared/approval.md`; treat an absent field as `never`, and stop considering a split immediately when it reads `never`, whether it was written or absent. + Otherwise propose a split only when both conditions hold: the breakdown has five or more units of work, and at least one valid cut point exists. + A cut point is valid only where the planned units up to it form a self-contained change: the units after it build on the units before it and not the reverse, and the earlier units together deliver something that stands on its own rather than half of one thing. + Judge that from the plan alone, because the plan is all there is to judge from at this moment: the decision is made at breakdown time, before any of the work is written, so there is no build to run and no tests to pass at a candidate boundary. + This is therefore a prediction about reviewability rather than a verified property of the repository, and two later steps catch a wrong prediction. + The confirmation stop below shows the proposed boundaries to the user before anything is built, which is the cheap correction. + The per-bundle finish routine in step 11 then reconciles that bundle and runs its tests for real, and its stop-and-hold fires when either disagrees, which is the expensive one. + A boundary that looked self-contained in the plan and turns out not to be is caught before that bundle's review opens rather than after it ships. + When no valid cut point exists, proceed as a single review and say so rather than forcing a boundary. + Both conditions are properties of the planned units rather than of anything on the tracker: the count comes from the plan, and a cut point's validity is a property of the work itself, which is what lets this whole decision run before a single sub-issue exists. + When the manual-tier guard above fired, say the split was not offered because the tier cannot create reviews only if the breakdown would otherwise have crossed the five-unit threshold; below that threshold no split was available in any tier, so explaining its absence would report a decision that was never live. + - When both of those conditions hold, shape the bundles as contiguous runs of the planned order established above, so bundles inherit that order rather than inventing one. + Produce at most three bundles, each holding at least two units; those two limits together mean five units yield at most two bundles, and six is the smallest breakdown that can yield three. + Exceed the cap only when the user asked for a specific larger split; never exceed it on the heuristic's own judgment. + - When both of those conditions hold, present the proposed split before anything is written to the tracker: the bundles, which units fall in each, and the resolved forge's `stackedReviews` value with what it means for this run. + This is a skip-list stop per `../fathom-shared/approval.md`, so `ask` mode waits for an answer and `auto` mode applies the split and reports it. + Placing it ahead of every write is what makes it safe to abandon: a user who walks away from the question, or declines outright, leaves no sub-issue on the tracker, no task in memory, and no task file on disk, so there is nothing half-built to reconcile. + - Call `init` for the issue, then call `parentTask` for it, once the split question is settled. + These are the first writes this step makes, which is why they sit below the proposal stop rather than above it; nothing between the plan and this point reads either of them. + - Create the sub-issues and their tasks next, passing each task's final `deps` to `createTask` itself, since that is the only operation in `../fathom-shared/memory.md` that takes `deps` and a chain cannot be added to tasks that already exist. + When no split was confirmed and the issue has no existing children, for each planned unit call `createSubIssue` first, then call `createTask` with the newly created sub-issue's ref as `subIssueRef`, then write the returned task id back onto that sub-issue so the link reads both ways, since the task id does not exist until `createTask` returns, setting `deps` to the id of the task it builds on so tasks chain sequentially by default whenever order matters. + When no split was confirmed and the issue already had children, for each adopted sub-issue still call `createTask`, passing that sub-issue's existing ref as `subIssueRef` and skipping `createSubIssue` since the sub-issue already exists, then write the returned task id back onto that sub-issue the same way, and setting `deps` the same way. + Those two are the single-review behavior exactly as it has always run, one sub-issue and its task at a time, so nothing watching the tracker sees a different sequence than before. + When a split was confirmed, take the same create-versus-adopt decision those two branches take: create a sub-issue for each planned unit when the issue has no existing children, and adopt the existing children when it has them, skipping `createSubIssue` for each adopted one exactly as the adopt branch above does. + A split never changes whether the sub-issues already exist, so an issue that arrived with children gets tasks created against those children and never a duplicate set alongside them. + Create them strictly one at a time in the planned order, from the first unit to the last, rather than in whatever order the bundle records suggest. + That order is what makes each task's predecessor id already exist when the next task needs it as a dep, and it also has every sub-issue ref created before the `Bundles` section that names them is written. + Chain every task in the issue sequentially on that path, so each task deps on its predecessor across bundle boundaries as well as within them, rather than only where order matters. + This is what makes `claimNext` structurally unable to hand out a later bundle's task while any earlier task is open, so the implementation loop needs no bundle-ordering logic of its own. + A single edge at each bundle boundary is not enough: a task carrying no deps has them trivially closed, so it stays claimable out of order and the branch chain would be built on unfinished work. - After every child task exists, add the parent's dependency edge on each child, so the parent cannot close before its children and "no open children" becomes a real signal rather than an assumption. - - Either way, write the plan document described in `conventions.md` and commit it with the breakdown. + - Whether the sub-issues were newly created or adopted, write the plan document described in `conventions.md` and commit it with the breakdown. + When a split was confirmed, that same document also carries the `Bundles` section recording each bundle's index, branch, and sub-issue refs, so write it now rather than when the first review opens, since it is what a resumed run reads to recover the stack. + Write the `- Merge-closer: suppressed` line described in `conventions.md` with it, since a stacked issue records every bundle's branch and the merge-closer Action would otherwise close the whole issue on whichever bundle merged first. - Write `.fathom/tasks/.md` only when the resolved backend is the checklist adapter, since that file holds checkbox statuses; with beads active the statuses live in beads and no file belongs there, as `memory.md` states. 9. Call `updateState` to move the issue to the `inProgress` phase. 10. Run the implementation loop until `claimNext` reports nothing claimable. + Before the first pass, when this issue was split into a stack, check the bundle step 7 recovered: when every task in that bundle is already closed and it still carries no recorded review, its per-bundle finish routine was interrupted, so run that routine from step 11 for that bundle now, and then, when a later bundle remains, move onto its branch under the already-exists guard in step 7, exactly as the end of a pass would. + Decide that from the durable record rather than from what is claimable: the closed tasks live in the memory backend and the recorded reviews live in the plan document, and both outlive the run that was interrupted. + Claiming without this check would hand out the next bundle's first task, since an interrupted routine leaves this bundle's tasks all closed while the next bundle's are still open, and that task would then be implemented on this bundle's branch and land in the wrong review. + A run interrupted later still, after every bundle's routine finished but before the issue's closing actions did, leaves nothing claimable at all and so makes no pass here; step 11 recovers that one. + Each pass through the loop does the following, in order. - Call `claimNext`, and record the claim in the memory backend's own format at claim time. - Move the claimed task's linked sub-issue to the `inProgress` phase, subject to the adapter's own rules for sub-issues; the Asana adapter degrades this to a no-op on subtasks, so read its subtask section rather than assuming a state change happens. @@ -93,12 +184,41 @@ If any of these files cannot be found and read, stop immediately and report whic - Close the task in the memory backend and move its sub-issue to `done`, again per the adapter's sub-issue rules, recording the close as it happens rather than summarizing at the end of the loop. A task is not closed until both its memory record and its sub-issue are closed; closing only the sub-issue leaves it claimable and `claimNext` will hand you the same task again. - Print the per-task progress line from `conventions.md`. + - When this issue was split into a stack and the closed task was the last one in its bundle, run the per-bundle finish routine in step 11 for that bundle before claiming again, then, when a later bundle remains, move onto the next bundle's branch under the already-exists guard in step 7, creating it from this one only when it is absent and checking it out when it is not, and continue the loop on it. + Do not wait until the loop drains to open any review: building each bundle on the correct branch from the start is what avoids having to cherry-pick commit ranges onto a chain of branches afterwards. - On a failure that cannot be fixed, stop and hold: keep the change, leave the task in progress, report the failure, and exit without continuing the loop. + On a stacked issue, also name which bundles already have open reviews and which were never built, since some of the work is already in front of reviewers and the user needs to know which part held. One commit per task, always, even when two tasks touch the same file. 11. Once `claimNext` returns none remaining, finish the issue. - Run the commit reconciliation from `conventions.md` and stop if the task and commit counts disagree. + Read this issue's plan document before anything else in this step and look for the `- Finalization: complete` line described in `conventions.md`. + That line is this issue's one durable record that its closing actions have run, the closing actions themselves are the only thing that writes it, and it is written by the last of them. + When it is present, this issue is already finished: say so, change nothing else in this step, and go to step 12. + The one exception is a line sitting on a commit that was never pushed; push that commit before reporting, since that push is itself the last of the closing actions and the only one that can still be missing while the line exists. + When the line is absent, run the rest of this step. + One recorded fact deciding this is what keeps a stacked issue from finalizing twice, in place of reasoning about which path invoked which routine. + + This step has two mutually exclusive paths, and exactly one of them runs. + A single-review issue follows the single-review path immediately below, then the closing actions at the end of this step. + A stacked issue skips that path entirely and goes straight to the closing actions, because step 10 already opened every one of its reviews through the per-bundle routine further down. + Running the single-review path on a stacked issue would reconcile the whole issue against a single bundle's commit range, write a second review record in a format the sweep does not read, and move the issue to `inReview` a second time. + On a stacked run that completes, step 10 invokes the per-bundle routine directly and bundle N's routine runs the closing actions as it finishes, so the finalization line is already written and pushed by the time the loop drains. + Re-entering this step then reads that line and stops at the check above, having changed nothing, so the closing actions run exactly once however the run reached them. + + A run interrupted before that line was written arrives here with it absent, and recovering such a run is the only reason a stacked issue ever runs this step's body. + Every task can be closed while the finalization that follows the last one is unfinished, and in that state nothing is claimable precisely when there is most left to do, so decide what remains from the durable record instead: the plan document's `Bundles` section says which bundles carry a recorded review, the memory backend says whether the parent task is still open, the tracker says the issue's phase and whether the completion comment is already on it, and branch N says whether the final closing commit exists and is pushed. + Then do only what that record shows is missing, and skip whatever it shows is already done, which is what makes arriving here twice produce the same result as arriving once. + Never call `openReview` for a bundle that already carries a recorded review; reuse it, exactly as the per-bundle routine's own guard says. + A bundle whose tasks are all closed and whose review is missing is recovered in step 10 rather than here, before any claiming, so by the time this step runs every bundle has its review. + Close the parent task only when the backend shows it open, apply `inReview` only when the tracker shows the issue in an earlier phase, post the completion comment only when `listComments` shows the issue does not already carry one, and make and push the final closing commit only when branch N does not already carry the completed task state. + When the resolved tracker cannot list comments, post the comment and say that it may be a duplicate, since a second completion comment is a cosmetic cost and a missing one loses the handoff entirely. + When the record shows every one of those already done, the previous run got all the way to the last closing action without recording it, so write the finalization line described below, commit and push it as bookkeeping, and say that the issue was already finished and only its record was missing. + That is the one thing such a run still owes: leaving the line unwritten would make every later run walk this recovery again. + + The single-review path, for an issue that was not split into a stack: + Commit any leftover uncommitted change that belongs to this issue's tasks, leaving unrelated working-tree edits alone rather than sweeping them into the review. + Then run the commit reconciliation from `conventions.md` and stop if the task and commit counts disagree, in that order, so the range it counts already carries every commit this issue's tasks produced. Close the parent task in the memory backend (a no-op for the checklist adapter, whose file is the parent record). Then open the review through the forge contract in `../fathom-shared/forges.md`, never by invoking a forge CLI directly from this procedure. @@ -113,9 +233,104 @@ If any of these files cannot be found and read, stop immediately and report whic When `openReview` returns the manual-handoff result instead of an id, there is no review object: skip `publishReview`, record no review id, print the handoff. Still apply `inReview`, and say plainly that no later run will move this issue to `done` on its own because the forge cannot be observed, so closing it is now a manual step. - Finally, post a completion comment on the issue, including the done-on-merge note from `asana.md` when the tracker is Asana, and commit and push the task-state files this run changed as a final closing commit so the branch carries the completed state, staging them by explicit path per the staging rules in `conventions.md`: the beads JSONL export and `metadata.json` when beads is the backend, and this issue's files under `.fathom/`; never sweep `.beads/` or `.fathom/` as directories, since the beads database and runtime files are intentionally ignored and must not ride into the review. + When this issue was split into a stack, the review-opening portion above is a per-bundle routine rather than a single closing action, and step 10 invokes it once per bundle as that bundle's last task closes. + For bundle k of N: + - Commit any leftover uncommitted change that belongs to this bundle's tasks, leaving unrelated working-tree edits alone rather than sweeping them into the review, exactly as the single-review path does before it opens its one review. + A change left uncommitted here is absent from bundle k's review and lands in bundle k+1's instead, which is worse than the single-review case rather than merely equivalent to it. + - Then reconcile bundle k's closed tasks against the commits on its branch, over that bundle's own range as it stands after the commit above, per the per-bundle rule in `conventions.md`; stop and do not open this bundle's review when they disagree. + These two run in this order because the leftover commit changes the very range the reconciliation counts. + Reconciling first would count a range still missing that commit, so a bundle with leftover work would come up short and stop the routine even though nothing was wrong; and where the count happened to match anyway, the leftover commit would land in the range afterwards and never be reconciled at all. + - Call `resolveBase` on bundle 1's base, which is the resolved base branch, or on branch k-1 for every later bundle. + - Write `- Review: pending (bundle k/N)` beneath that bundle's line in the plan document's `Bundles` section, and commit it on branch k, before calling `openReview` for this bundle. + Stage only the plan document, by explicit path, per the staging rules in `conventions.md`, list what is staged and confirm it carries only that one added marker line, and word it as bookkeeping rather than as a task: `chore(): mark bundle k review pending`, naming no task in the body. + That is the same kind of commit as the `- Review:` record below and `conventions.md` excludes it from task and commit reconciliation for the same reasons. + Make it before branch k reaches the remote, so that whichever push puts the branch there carries it: the push below on an ordinary adapter, or the push `openReview` owns under `pushesForYou`. + The marker means only that a run reached the point of calling `openReview` for that bundle: it is committed before the call, so the call may or may not have started and a review may or may not exist. + Its job is to force the next run to look the review up rather than to prove that any review was created. + Writing it ahead of the call is still the whole point, since once `openReview` has been entered a run that dies leaves no other trace that anything was tried at all. + - Push branch k, unless the adapter declares `pushesForYou`, exactly as the single-review path does. + - Call `openReview` with branch k, that base, a title naming the bundle, and a body built per the stack rules in `conventions.md`: the closing reference only in bundle N, plus `Part k of N`, plus `Depends on` the previous bundle's review URL for every bundle after the first. + Pass the previous bundle's review id as `dependsOn` for every bundle after the first, and omit it for bundle 1. + Those two are not two representations of one dependency: `dependsOn` is the contract's machine-readable argument, which an adapter with no dependency mechanism of its own ignores, while the `Depends on ` body line is prose for a human reviewer and carries no machine meaning, exactly as `conventions.md` and `../fathom-shared/forges/github.md` both state. + - Branch on what `openReview` returned before doing anything with it, since the manual-handoff result defined in `../fathom-shared/forges.md` is a typed outcome of that call and carries no review id. + When it is that result, there is no review object for this bundle: do not call `publishReview`, do not write a `- Review: ` record for it, and stop and report the handoff for bundle k rather than continuing to bundle k+1. + Writing a record from it would put an entry in the `Bundles` section with no id behind it, which the sweep reads as a review it can look up and cannot, and continuing would leave bundle k+1 with no id to pass as `dependsOn` and no URL for its `Depends on` line. + Remove the pending marker written above as part of stopping, committing that removal as the same kind of bookkeeping commit, since this result says outright that no review object was created and a marker left behind would hold every later run on a bundle that provably has none. + A stacked run should not normally reach this at all, because the manual tier never proposes a split, as `../fathom-shared/forges.md` states, and it is the only tier that hands a review off by hand. + So treat this branch as a guard against an adapter that returns the handoff result from a non-manual tier, rather than as a path a correct run is expected to take, and say that plainly when it fires. + - Call `publishReview` with the returned id. + - Replace that bundle's `- Review: pending (bundle k/N)` marker with `- Review: (bundle k/N)` in the plan document's `Bundles` section, since the sweep looks reviews up by id and needs every one of them. + - Commit and push that recorded line immediately, on branch k, before moving to bundle k+1's branch or doing anything else. + Stage only the plan document, by explicit path, per the staging rules in `conventions.md`, and word it as bookkeeping rather than as a task: `chore(): record bundle k review id`, naming no task in the body. + Then do what those same staging rules require before every commit: list what is staged and confirm every part of it belongs to the work at hand, which here is the one `- Review:` line that replaced the marker and nothing else. + Staging that document by path takes whatever else is already sitting in it, so when the staged diff carries an unrelated edit as well, unstage it rather than committing it and cleaning up later, and leave it in the working tree for the run's final closing commit to carry. + `conventions.md` excludes plan document and bookkeeping commits from task and commit reconciliation, and a commit shaped this way is one of them, so it cannot be miscounted as the commit that implemented a task. + Waiting for the run's final closing commit instead would leave bundle 1's review id uncommitted through bundles 2 and 3, where a sweep run from another clone cannot see it and an interrupted run leaves it on one machine's disk only. + - Apply `inReview` when bundle 1's review publishes, and never again for the later bundles; the issue is genuinely in review from that moment and re-applying a phase it already holds reports progress that did not happen. + A resumed run that reuses bundle 1's existing review publishes nothing, so apply `inReview` there instead, whenever the tracker still shows the issue in an earlier phase; read that phase from the tracker rather than assuming the interrupted run got as far as applying it. + That is a phase update and nothing more: reusing a review never reopens it and never calls `publishReview` on it again. + Later bundles keep this rule exactly as written and never apply the phase, whether their reviews were newly opened or reused. + Skip the `openReview` call for a bundle whose review already exists and reuse that review, the same way the single-review path does, so a resumed run never opens a second review for a bundle that has one. + Decide that from that bundle's entry in the `Bundles` section and from nothing else, since the pending marker above is written and committed before `openReview` is called and is therefore the only record that separates a bundle no run has tried to open a review for from a bundle where one may exist. + Exactly one of four cases holds for bundle k. + When the entry carries a full `- Review: (bundle k/N)` line, the review exists and is already recorded: reuse it, open nothing, change no record, and skip the lookup below entirely. + When the entry carries no line at all beneath it, no run has ever reached this bundle's `openReview` call, because the marker is committed before the call and no run reaches the call without it, so no review can exist for this bundle: write the marker as the routine above says, open the review, and skip the lookup below entirely. + That is the ordinary case on a first run through a stack, which is why a first run never stops here. + When the entry carries a `- Review: pending (bundle k/N)` marker and no id, a run reached the call and recorded no outcome, so the call may or may not have started and a review may or may not exist: work through the lookup below, and hold wherever it cannot settle the question. + When the entry carries a `- Review: none confirmed (bundle k/N)` line, the user has already confirmed for an earlier hold that no review exists for this bundle: replace that line with the pending marker as the routine above says, open the review, and skip the lookup below entirely. + Do not read the remote's branch list as evidence in any of these four cases, and never treat a branch the remote does not carry as proof that no review was opened from it. + A forge retains a review after its head branch is deleted, and nothing in the lifecycle rules prevents a bundle branch being deleted or reused before its `- Review:` record is durable, so branch absence cannot tell a bundle no run ever reached from one whose review was opened and whose branch later went away. + The pending marker records that a run got as far as the call instead, and it is the only evidence this procedure accepts on that question. + Branch k being gone is therefore a live possibility here rather than a hypothetical, and it changes what this bundle's routine may do. + When branch k is absent from both the local repository and the remote, run only the lookup below and the recording it calls for, then stop and hold for bundle k: skip the leftover-commit step, skip the reconciliation, and skip `openReview`, since all three read or write a branch that is not there. + The lookup itself still works, because a forge retains a review after its head branch is deleted, which is exactly why branch absence was ruled out as evidence above. + Say that branch k is missing, that bundle k's commits cannot be located from it, and that this run recorded what it learned about that bundle's review and changed nothing else. + Say what unblocks it, too: restore branch k from a clone, a reflog, or a branch above it that still carries those commits, or decide that bundle's work is gone and rebuild it. + Both are the user's judgment call rather than this procedure's, and recreating branch k from branch k-1 is never the remedy, since the name would come back empty and this bundle's commits would be silently absent from its review. + On the pending case, ask the forge with `findReviewByBranch` for branch k, which returns bounded candidate records carrying each review's id, its URL, and its base, as `../fathom-shared/forges.md` defines the operation, then keep only the candidates whose base is exactly the base `resolveBase` returned for this bundle. + Bundle branches chain, so a head branch can carry a review opened against a different base than this bundle now targets; matching on the exact head and base pair is what keeps this bundle's commits out of that review, and the base in the candidate record is what makes that match possible at all. + When exactly one candidate survives that filter, that review exists and belongs to this bundle, so back its id and URL into the record first, then call `getReviewState` on that id to decide whether this run may continue. + The state decides continuation and never whether the record may be written: the candidate came back from the forge keyed on this bundle's exact head and base, which makes the id true whatever the review's fate turns out to be, and a merged, closed, or undetermined review whose id goes unrecorded is exactly the bundle the sweep reads as missing a record forever. + Then read the state and act on it. + On `open`, carry on with the rest of this routine for bundle k, which is the ordinary recovery. + On `merged`, carry on the same way: the bundle's outcome is known and good, its review needs no reopening, and its id is now recorded, so the sweep can see that bundle merged. + On `closed-unmerged`, stop and hold after recording, naming bundle k and saying its review was abandoned, since whether to retry, rescope, or drop that work is the user's judgment exactly as it is in the sweep's own abandoned case. + On `unknown`, stop and hold after recording, since nothing was learned about that review's fate and building the next bundle on an outcome this run never observed is the guess this whole lookup exists to avoid. + Keep that candidate's URL alongside its id, since the backfill below records both and no other operation in the contract reports a review's URL. + When more than one survives, stop and hold naming them, since choosing between two candidate reviews by guess is the failure this pairing exists to prevent. + When no candidate matches at all, do not call `openReview`: stop and hold instead. + A lookup that comes back with nothing matching does not establish that nothing exists, because the list is bounded and can leave out a review that is really there, as `../fathom-shared/forges.md` states, and the pending marker is exactly the state an earlier run leaves behind when it was interrupted around its `openReview` call. + Say in the hold report that bundle k carries a pending marker, that a review may already exist for this bundle, that this run could not find one and cannot prove there is none, and that the user should confirm whether a review exists for that bundle before the run continues. + Say with it what unblocks the next run, since a hold with no stated remedy leaves the bundle blocked forever: when the user confirms that no review exists, replace bundle k's marker with a `- Review: none confirmed (bundle k/N)` line in the `Bundles` section, committed and pushed on the branch this run is on as the same bookkeeping commit the recording step below makes, and the next run opens that bundle's review rather than holding again. + When the user instead finds a review that does exist, record it as a full `- Review: (bundle k/N)` line the same way, and the next run reuses it. + Either confirmation belongs in the `Bundles` section, because that is where the next run reads it; a confirmation given only in conversation leaves the durable record unchanged and every later run holds identically. + When the resolved adapter omits `findReviewByBranch`, which `../fathom-shared/forges.md` says is legitimate, no lookup is possible at all: say once that the forge cannot be asked, then hold on exactly those same terms, since a pending marker with no id beside it says nothing about whether the call that followed it created a review. + Holding costs one confirmation on a run that was interrupted between marking bundle k pending and recording its review, while opening blindly costs a duplicate review that no record names and the sweep can never reconcile, so the hold is the cheaper of the two. + A matched candidate does not skip the two recording steps above it, whatever its state, and this is where a resumed run otherwise loses a bundle. + That bundle's entry carries the pending marker, since the marker is what brought this run into the lookup at all: replace it now with a real `- Review: (bundle k/N)` line built from the id and URL on the candidate record that matched, then commit it exactly as the recording step above does: stage only the plan document, by explicit path, verify the staged diff carries only that one replaced line before committing, and word it as the same bookkeeping commit. + Push it on the branch this run is on, before anything else, including before any hold the state above calls for, since a record that never leaves this clone closes none of the gaps below. + Then continue or hold as that state directs. + Without that backfill the review exists on the forge and nothing in the repository names it, so the sweep never learns its id, step 7 keeps reading that bundle as the one in progress, and the completeness rule in step 2 leaves the whole issue undecided forever. + Both recovery records, the backfilled `- Review: (bundle k/N)` line and the `- Review: none confirmed (bundle k/N)` line, go on the branch this run is on rather than on branch k, and that is what makes either of them writable at all. + Branch k may have been deleted or reused, which is the very possibility the pending marker exists to survive, so requiring the record on branch k would leave the recovery outcome undurable exactly when it matters and every later run would repeat this lookup and this hold. + The branch this run is on is always a branch step 7 resolved and confirmed to exist, so it is always a valid write target. + This costs the sweep nothing, because that branch is always one named in the `Bundles` section, and the sweep fetches every branch named there and reads each one's own copy of the plan document, as `../fathom-shared/trackers.md` and `conventions.md` both describe. + A record on any of those branches is therefore a record the sweep already reads, wherever in the chain that branch sits. + A bundle whose entry already carries its full `- Review:` line never reaches the lookup at all: its record is already durable, so it changes nothing and makes no commit. + A bundle with no line at all is unaffected by any of this and runs the routine above unchanged. + After bundle N's routine completes, close the parent task in the memory backend (a no-op for the checklist adapter, whose file is the parent record), which is the one action the single-review path takes that no bundle routine has taken yet. + Then skip the single-review path above entirely and continue into the closing actions below, which run once for the issue rather than once per bundle. + The parent task is closed exactly once either way: the single-review path closes it before opening its review, and a stacked issue closes it here, after the last bundle's review and before the issue's completion comment. + + Finally, post a completion comment on the issue, including the done-on-merge note from `asana.md` when the tracker is Asana, then write `- Finalization: complete` into this issue's plan document per `conventions.md`, and commit and push the task-state files this run changed as a final closing commit so the branch carries the completed state, staging them by explicit path per the staging rules in `conventions.md`: the beads JSONL export and `metadata.json` when beads is the backend, and this issue's files under `.fathom/`; never sweep `.beads/` or `.fathom/` as directories, since the beads database and runtime files are intentionally ignored and must not ride into the review. + Write that line last, after every other closing action has been taken, since it records that they were: a line written earlier would claim a finalization that had not happened and the check at the top of this step would then skip the rest of it forever. + It rides this same closing commit, so it becomes durable at the moment the completed task state does, and this commit is the only one that carries it on a run that reaches here normally. Push this closing commit with an ordinary `git push` of the branch even when the adapter declares `pushesForYou`, since that capability governs only the push that opens the review, as `../fathom-shared/forges.md` states; skipping it here would leave the completed task state in the local clone while the review reads as finished. -12. Report a final summary: the issue, the review URL when one was opened or the resolved tier when one was not, the tracker's current phase, and the task counts from `status()`. + On a stacked issue this closing commit goes on branch N, the stack tip, because that branch contains every bundle's history and is the only one whose review shows the completed task state. + Say plainly at handoff, when the issue was split, that its record carries `- Merge-closer: suppressed`, so the merge-closer Action will take no action for it however its bundles merge. + On a repository that relies on that Action for closure this is a real change: a stacked issue reaches `done` only when a later run's done-on-merge sweep sees every bundle merged, where a single-review issue still closes on merge without one. + The alternative is worse, since the Action matches branch names and every bundle records one, so the first bundle to merge would close the whole issue and the sweep would then read it as complete and never correct it. +12. Report a final summary: the issue, the review URL when one was opened, every bundle's review URL in order when the issue was split into a stack, or the resolved tier when no review was opened, the tracker's current phase, and the task counts from `status()`. ## Display overlay diff --git a/skills/fathom-shared/approval.md b/skills/fathom-shared/approval.md index b2329fe1..2bb69445 100644 --- a/skills/fathom-shared/approval.md +++ b/skills/fathom-shared/approval.md @@ -32,6 +32,12 @@ Skipping them changes how much the run interrupts you, not whether it is correct Resolve it by that precedence and report the choice rather than asking. - Any first-run setup question whose answer is unambiguous: one destination available, or tracker state names that match the three phases exactly. Record the answer, and note in the profile that it was auto-accepted rather than confirmed, so a wrong destination is traceable later. +- The bundle-split proposal in `execute`. + Apply the proposed split and report the bundles rather than asking for confirmation first. + This belongs here rather than on the safety list because it fires before any commit or review exists, so being wrong destroys nothing and misdirects nothing, which is the shape of every other item on this list. + Bundle 1's branch does exist by then, since step 7 creates it before step 8 runs, but that branch is the one a single-review run needs anyway, so declining the split wastes nothing and leaves nothing to clean up. + Being on this list is not a claim that an applied split is undone by a later run: in auto mode the split is already written into the breakdown by the time anyone reads the report, and the task dependency chain and the plan document's `Bundles` section persist until someone edits them. + It is skipped only when the profile's `stacking` field permits a split at all; `stacking: never`, and an absent field which means the same thing, suppress the split itself, in both modes, rather than suppressing the question. ## What auto mode never skips @@ -75,5 +81,18 @@ Because the profile is committed, teammates inherit the choice. Editing that field changes it permanently; an invocation phrase changes it for one run. When one skill hands off to the other, carry the resolved mode across so a per-run override is not lost at the boundary; say which mode the handed-off run is using. +A second field, `stacking`, sits alongside `approval` and answers a different question: whether `execute` may split one issue into a stack of dependent reviews at all. +It holds `propose` or `never`, and it defaults to `never` when the field is absent. + +`propose` means the agent may propose a split when the breakdown crosses the threshold in `execute`, with the `approval` field above deciding whether that proposal is a question or a report. +`never` means this repository always produces one review per issue, in both approval modes, in the same permanent way that `forge: none` makes the manual tier permanent. + +The default is `never` because stacking is opt-in, and a default of `propose` would not be. +An existing repository running in `auto` mode has a profile written before this field existed and has never asked for stacking, yet under a `propose` default its next large issue would be split into a stack and reported rather than asked about, changing that repository's behavior without anyone opting in. +A repository gets stacking only by writing `stacking: propose` into its profile, so every repository that has not written it keeps producing exactly one review per issue. + +The field deliberately has two values rather than three. +An `ask` or `auto` value here would restate the `approval` field recorded a few lines above it in the same profile, and two fields that can disagree about the same question will eventually disagree. + When auto mode auto-accepted a setup answer rather than having it confirmed, record that alongside the value, for example `default-destination: Prototypes (1209000000000001) # auto-accepted, only option`. A later reader needs to know which answers a human actually gave. diff --git a/skills/fathom-shared/conventions.md b/skills/fathom-shared/conventions.md index 533657df..a59e79ec 100644 --- a/skills/fathom-shared/conventions.md +++ b/skills/fathom-shared/conventions.md @@ -44,7 +44,9 @@ Name the task in the body so the commit ties back to task memory. ## The plan document During breakdown, write a human-readable plan for the issue at `.fathom/plans/.md`, and commit it with the breakdown. -This document is a reference artifact for people, never resume state; task status always lives in the resolved memory backend. +This document is a reference artifact for people, and it never carries task status; status always lives in the resolved memory backend, so nothing here is ever consulted to learn what is done. +It does carry structure, which is a different thing: the branch, the review ids, and the bundles of a stacked issue are recorded here, and a resumed run reads them back rather than remembering them from a previous invocation. +`memory.md` draws the same line, and it is what keeps this from being dual truth: structure is decided once and does not change as the work proceeds, while status changes with every task and lives in exactly one place. Include these sections: @@ -58,6 +60,41 @@ Include these sections: - **Codebase context** - the files, modules, and existing patterns this work touches, with paths. - **Implementation approach** - how the change will be made, including anything deliberately out of scope. - **Tasks** - the planned units of work with their sub-issue links. +- **Bundles** - present only when this issue was split into a stack, and omitted entirely otherwise. + One line per bundle, in stack order, each reading `- Bundle /: - `. + Add a `- Review: pending (bundle k/N)` marker beneath a bundle before its review is attempted, then replace that marker with a `- Review: (bundle k/N)` line once its review exists. + The suffix is redundant with the nesting on purpose: the sweep reads these lines individually, and a self-describing record survives being read out of its surrounding context. + The marker means only that a run reached the point of calling `openReview` for that bundle: it is committed before the call, so the call may or may not have started and a review may or may not exist. + Its job is to force the next run to look the review up rather than to prove that any review was created. + It names no id, so nothing can be looked up from the marker itself, and every reader collecting review ids treats a bundle carrying only the marker as carrying no record at all. + The done-on-merge sweep therefore counts such a bundle among the missing records and leaves the whole issue undecided, and `execute` holds on it rather than opening a review that may duplicate one. + What the marker separates is a bundle no run has ever tried to open a review for, which carries no line at all, from a bundle where a review may exist and no record names it, which carries the marker. + Branch absence cannot make that distinction, because a forge retains a review after its head branch is deleted, so a bundle branch deleted or reused before its record was durable leaves a review that no branch and no record names; that is why the marker is written ahead of the call rather than inferred afterwards. + When the lookup cannot settle whether a review exists, the run holds and reports the marker, and the user confirms whether one exists. + Record a confirmation that none exists by replacing that bundle's marker with a `- Review: none confirmed (bundle k/N)` line, committed and pushed on the branch that run is on as the same kind of bookkeeping commit, so the next run opens that bundle's review instead of holding again. + Every reader that treats the bare marker as no record treats a `none confirmed` line the same way, since neither names an id. + A hold that recorded nothing would stop every later run identically, which is why the confirmation lands in this section rather than staying in the conversation that produced it. + Each of those lines, the marker included, is committed and pushed as soon as it is written rather than riding the run's final closing commit, so that both the intent and the review id are durable and visible from another clone the moment each is written; `execute` describes exactly where in its per-bundle routine that happens. + Each one lands on whichever branch the run is on when it writes the line, which in the ordinary routine is that bundle's own branch. + A recovery is the exception, and deliberately so: a run recovering a bundle whose branch was deleted or reused records that bundle's outcome on the branch it is on instead, because that branch exists and is a write path while the bundle's own branch offers none. + Either way the record is reachable, since the collection below fetches every branch named in this section rather than only the highest one and takes every `- Review:` line each of them carries. + So a checkout of the base branch carries the records of the bundles that have already merged into it and none of the records above them, and reading only what that checkout holds would judge a three-bundle stack on one bundle's record. + The branch name on each `- Bundle` line is what makes the rest reachable: the done-on-merge sweep fetches every branch named in this section and reads that branch's own copy of this document to collect the `- Review:` lines it cannot see locally, as `trackers.md` describes. + Those branch names are therefore load-bearing for the sweep as well as for a resumed run, and a bundle line without one leaves that bundle's record unreachable. + Collecting the records this way is what keeps them in one place: the alternative is mirroring every review id into a second store that the sweep can read directly, and two records of the same fact can disagree, while a fetch is read-only git work that needs no write anywhere. + This section is the durable record a resumed run reads to recover the stack, so write it when the split is confirmed rather than when the first review opens. +- **Merge-closer** - present only when this issue was split into a stack, and omitted entirely otherwise. + One line reading `- Merge-closer: suppressed`, written when the split is confirmed, alongside the `Bundles` section. + The merge-closer Action matches a merged branch against the records under `.fathom/` and knows nothing about stacks, and every bundle's branch is recorded there, so without this line the first bundle to merge closes the whole issue while most of the work is still open and unreviewed. + That close is also permanent and silent, because the next sweep reads the issue as already complete and does nothing. + The Action reads this line and takes no action for the issue, which leaves closure to the sweep, and the sweep already waits for every bundle to report merged. + One mechanism closes a stacked issue rather than two that disagree. +- **Finalization** - one line reading `- Finalization: complete`, absent until every one of the issue's closing actions has run. + The last of those actions writes it, so it rides the run's final closing commit and becomes durable at the same moment the completed task state does. + This is the one durable record that an issue's one-time closing actions have happened, and `execute` consults it before finalizing and stops immediately when it is present. + A stacked issue needs that: its last bundle finalizes the issue directly as it finishes, and the implementation loop then drains and reaches the finalizing step again, so without one recorded fact to consult the closing actions can run twice. + This is not task status and does not belong in the memory backend, which knows which tasks are closed and nothing about whether the completion comment was posted or the closing commit pushed. + It is the same kind of line as `Merge-closer` above: a fact about this issue that another mechanism reads later. - **Testing strategy** - which tests will prove the work, and which existing tests could regress. - **Notes** - open questions, risks, and decisions taken during the run. @@ -76,12 +113,19 @@ Recording a real hash is impossible when no commit was made, so this converts a A progress line describes repository state, so never name a commit that does not exist in the log. Reconcile before finishing. -A task commit is one whose subject is scoped to this issue's ref and which implements a task; the breakdown commit, the plan document commit, and any task-state bookkeeping commit are not task commits. +A task commit is one whose subject is scoped to this issue's ref and which implements a task; the breakdown commit, every plan document commit including the per-bundle one that records a bundle's review id, and any task-state bookkeeping commit are not task commits. +Those bookkeeping commits are recognizable rather than a matter of judgment: each is typed `chore`, touches only records under `.fathom/`, and names no task, so none of them can be counted as the commit that implemented one. Count them over the range from the resolved base branch to the current head, not over all history, since a branch inherits its base's commits. Compare that count to the number of tasks closed for this issue. Check the recorded hashes as well: every hash recorded at close must name a commit inside that same range, and each closed task's hash must be distinct, which catches a mismatch that subject-line counting can misclassify. When the counts disagree, stop and report the discrepancy rather than opening a review: either a commit is missing, or tasks were combined into one commit, and both contradict the one-commit-per-task rule. +When the issue was split into a stack, reconcile once per bundle rather than once per issue, and do it before that bundle's review opens rather than at the end of the run. +Count over the range from that bundle's own base to that bundle's head: the resolved base branch for bundle 1, and branch k-1 for bundle k. +Compare that count to the number of tasks closed for that bundle only. +A stack-wide count over the whole range would pass even when one bundle carried another bundle's commits, which is exactly the mistake the check exists to catch. +Stop on a mismatch the same way, and do not open that bundle's review. + This check guards a hazard that is universal across forges rather than specific to any one of them: every forge reviews committed work only, so anything left staged or uncommitted is silently absent from the review, with no error raised anywhere. ## Review test plan @@ -100,3 +144,22 @@ When the project cannot run tests at all, say that plainly here rather than leav After each task closes, print one line so a long autonomous run stays legible: the task position in the queue, its id, the commit subject, the test result, and how many tasks remain. Report the resolved tracker and memory backend once at the start of the run, and state the backend explicitly whenever it differs from what other open issues in this repository are using. + +## Review bodies in a stack + +When one issue produced a stack of reviews, the issue-closing reference goes in the last bundle's review body only. + +`execute` puts `Closes ` in the body for a Linear issue, or the task's URL for an Asana task, and both are read by the forge's tracker integration on merge. +Repeating either in every bundle means the first bundle's merge closes the issue while most of the work is still open and unreviewed. + +Every bundle's body carries two additional lines instead: + +- `Part of ` so a reviewer knows this diff is a slice rather than the whole change. +- `Depends on `, omitted for bundle 1, which depends on nothing. + +`forges/github.md` forbids encoding a stack dependency a second way, and this body line is not that. +The `Depends on ` line in a review body is prose for a human reviewer and carries no machine meaning, so it is not a second representation of the dependency; the prohibition is on machine-readable representations such as a label or an extra API call. +The machine-readable representation is whatever the resolved forge declares: the `dependsOn` argument to `openReview` on a forge with a dependency mechanism of its own, and the base branch alone on a `retarget` forge, whose adapter ignores that argument. + +Earlier bundles still name the issue for context, as a plain link with no closing keyword. +The distinction is between referencing an issue and instructing the forge to close it, and only the last bundle does the second one. diff --git a/skills/fathom-shared/forges.md b/skills/fathom-shared/forges.md index 150dc3d5..246954ab 100644 --- a/skills/fathom-shared/forges.md +++ b/skills/fathom-shared/forges.md @@ -14,7 +14,7 @@ Adapter files implement each one against a specific forge's tools; treat the ope | --- | --- | | `verifyForge()` | Cheap read-only preflight check that the forge is reachable and authenticated; returns verified or unverified and nothing else. | | `resolveBase(branch)` | Confirm the named base branch exists on the remote and is a valid merge target. | -| `openReview(branch, base, title, body)` | Create the review for a branch against a base. Return a stable review id and the review's URL - or, on a forge where no review can be created, the manual-handoff result defined below. | +| `openReview(branch, base, title, body, dependsOn?)` | Create the review for a branch against a base. Return a stable review id and the review's URL - or, on a forge where no review can be created, the manual-handoff result defined below. `dependsOn` is optional and carries the review id this one is stacked on; it is absent for a standalone review and for the first bundle of a stack. | | `publishReview(id)` | Move a draft review to the notified-review state, where the forge distinguishes the two. A no-op everywhere else. | | `getReviewState(id)` | Return one of `open`, `merged`, `closed-unmerged`, or `unknown`, plus a merge timestamp when merged. | @@ -35,9 +35,24 @@ A branch name is not a review id. An adapter that cannot create reviews (see `generic-git.md`) returns this instead of an id, and it is a typed outcome of the contract rather than a failure. A caller receiving it must not call `publishReview`, must not record a review id, and must say plainly that opening the review is now the user's step. -One optional operation exists beyond the five, for legacy records only: `findReviewByBranch(branch)`, which resolves a review id from a head branch name where the forge can do that (`github.md` implements it with a bounded head-branch listing). +One optional operation exists beyond the five, for repairing incomplete records: `findReviewByBranch(branch)`, which finds the reviews opened from a head branch where the forge can do that (`github.md` implements it with a bounded head-branch listing). Adapters that cannot implement it simply omit it. -The sweep uses it solely to repair records written before review ids were recorded; when the resolved adapter omits it, such a record cannot be swept, and the sweep reports that once instead of guessing. + +**It returns a bounded list of candidate records, newest first, and each record carries three fields: the review id, the review's URL, and the base branch that review targets.** +It returns an empty list when the branch has no reviews, and it never returns a bare id. +A caller needs all three fields. +The id is what `getReviewState` and every later record are written against, the URL is what a `- Review:` line needs in order to name the review to a human, and the base is the only thing that tells apart two reviews sharing one head branch. +That last case is routine rather than exotic: bundle branches chain, so one head branch can carry a review opened against a base the caller no longer targets, and `getReviewState` reports a review's fate without reporting what it targets, so the base has to come from here or from nowhere. +The list is bounded, so treat it as a set of candidates rather than an exhaustive answer, and match within it rather than trusting it to hold exactly one review. +The bound cuts both ways, so a result carrying no matching candidate is not proof that no such review exists, and an empty list is not proof that the branch has no review at all: each says only that the operation saw none inside its window, which is a different claim from there being none. +Adapters bound this differently and a caller cannot see how, so no caller may read absence out of this operation, however the result comes back. +A caller may act on a match it finds here, since a returned record is a review that demonstrably exists. +A caller that would create something on the strength of absence must not use this result for that: it has to establish absence from evidence outside the operation, or stop and hold, and each caller below states which of those it does. + +It is used only where a review may exist while nothing in the repository records its id: the sweep repairs records written before review ids were recorded, and `execute` recovers a bundle whose review opened before its `- Review:` line was committed. +When the resolved adapter omits the operation entirely, no lookup is possible at all and such a record cannot be repaired. +Each caller says that once, names the record, and then takes the path its own procedure defines for an unrepairable record rather than guessing: the sweep leaves that issue undecided and closes nothing, per `trackers.md`, and `execute` opens a review for a bundle only where its own plan document records no attempt for that bundle at all, which is evidence of absence that owes nothing to this operation, and otherwise holds rather than risk opening a second review, per `execute/SKILL.md`. +Those two differ because the costs differ, and each file states its own; neither is licensed to invent the other's. ## Declared capabilities @@ -51,13 +66,24 @@ An absent capability means false. | `draftState` | true / false | Whether `publishReview` is meaningful, and when the `inReview` phase is applied. | | `pushesForYou` | true / false | Whether `openReview` owns the push, or the calling skill pushes the branch first. | | `reviewLookup` | `by-id` / `none` | Whether the done-on-merge sweep can run at all. | -| `stackedReviews` | `retarget` / `declared-dependency` / `none` | Reserved. No behavior depends on it yet. | +| `stackedReviews` | `retarget` / `declared-dependency` / `none` | How this adapter expresses that one review is stacked on another, in `openReview`. | Forges differ in kind, not only in command names, which is the same lesson `agents.md:23-31` already records for tracker MCP builds whose tool coverage varies. A capability that is false is a fact to design around, not a gap to work around. -`stackedReviews` is declared and unused. -It is recorded now because the difference is real - `retarget` describes a forge where stacking is branch retargeting with automatic retarget when the upstream merges, and `declared-dependency` describes one where stacking is an explicit dependency plus a manually scoped commit range with no auto-rebase - and because adding a capability key later means revisiting every adapter file. +`stackedReviews` decides what an adapter does with `openReview`'s optional `dependsOn` argument. + +| Value | What `openReview` does with `dependsOn` | +| --- | --- | +| `retarget` | Ignore it. Passing the previous bundle's branch as `base` is the whole mechanism, and the forge retargets the dependent review automatically when its upstream merges. | +| `declared-dependency` | Pass it to the forge's own dependency mechanism, and scope the review's commit range to this bundle's commits only. Nothing is retargeted automatically. | +| `none` | Ignore it. The `base` argument still chains the branches in git, and the calling skill writes the relationship into the review body in prose. | + +A `none` adapter is still stackable in the only sense that matters to a reader: the branches chain, each review shows one bundle's diff, and the body says what it depends on. +What it lacks is any forge-side record of the relationship, so nothing retargets and nothing warns when the stack is merged out of order. + +Only a repo-local adapter reaches the `none` row in practice. +The one bundled adapter that declares `none` is `generic-git.md`, which is what the manual tier runs on, and the manual tier never proposes a stack. ## Adapter resolution @@ -124,6 +150,7 @@ The best outcome is the committed adapter, because it is reviewable by the team No adapter, no candidate, the user declined the tier-2 offer, or the profile records `forge: none`. Push the branch, then print what a human needs in order to open the review by hand: the branch, the base, a suggested title, and a suggested body. `getReviewState` is unavailable, so the done-on-merge sweep does not run. +A stack is never proposed in this tier: with no review object to create, a three-bundle stack would become three separate sets of open-this-by-hand instructions, which is worse for the user than one review. `forge: none` is not a fourth tier. It is the manual tier made permanent, so a repository that will never have an automatable forge stops being offered one on every invocation. diff --git a/skills/fathom-shared/forges/TEMPLATE.md b/skills/fathom-shared/forges/TEMPLATE.md index c5b15364..25349156 100644 --- a/skills/fathom-shared/forges/TEMPLATE.md +++ b/skills/fathom-shared/forges/TEMPLATE.md @@ -37,7 +37,7 @@ Guidance is in `>` blockquotes throughout. Delete the blockquotes as you fill ea > > `reviewLookup` - `by-id` only if you can look up one review's state directly, from any clone, given the id `openReview` returned. If reviews can only be found by listing, or not found at all, this is `none`. > -> `stackedReviews` - declared but currently unused. `retarget` if stacking means retargeting a branch; `declared-dependency` if it means declaring a dependency plus a commit range. +> `stackedReviews` - how your forge expresses that one review is stacked on another, which decides what your `openReview` does with the optional `dependsOn` argument. `retarget` if stacking is just pointing a review at the previous branch, and your forge retargets automatically when the upstream merges. `declared-dependency` if stacking means declaring an explicit dependency and scoping the commit range yourself, with no automatic retarget. `none` if your forge has no stacking model at all, which is a fine answer: the calling skill still chains the branches in git and writes the relationship into the review body. ## Absolute boundary @@ -68,7 +68,7 @@ When it does not verify, report the fix: > `git ls-remote --exit-code --heads origin ` works on most forges and is a fine answer. Use something forge-specific only if your forge has merge targets that are not plain branches. -## `openReview(branch, base, title, body)` +## `openReview(branch, base, title, body, dependsOn?)` @@ -78,6 +78,8 @@ When it does not verify, report the fix: > > **Say how to extract the review id from the command's output**, exactly - which field, which format. This id is written to disk and looked up on later runs from possibly a different clone, so it must be stable. A branch name is not a review id. +> **Say what you do with `dependsOn`, explicitly, even when the answer is nothing.** It arrives holding the review id this one is stacked on, and it is absent for a standalone review and for the first review in a stack. If you declared `retarget` or `none`, write "Ignore `dependsOn`" and say that the `base` argument carries the relationship. If you declared `declared-dependency`, give the exact command that records the dependency, and say how you scope the review to this bundle's commits only - a declared dependency with an unscoped range shows the upstream bundle's changes twice. + Return the review id and the review's URL. diff --git a/skills/fathom-shared/forges/generic-git.md b/skills/fathom-shared/forges/generic-git.md index 1f4af58b..1b489b64 100644 --- a/skills/fathom-shared/forges/generic-git.md +++ b/skills/fathom-shared/forges/generic-git.md @@ -19,6 +19,10 @@ Work still gets committed, pushed, and handed to a human in a usable form; what | `reviewLookup` | `none` | | `stackedReviews` | `none` | +`stackedReviews: none` is never exercised through this adapter. +This adapter is what the manual tier runs on, and `../forges.md` states that the manual tier never proposes a stack, so `openReview` here is only ever called for a standalone review. +The value is declared truthfully rather than left absent, because a repo-local adapter author reading this file as the minimum viable example needs to see every capability filled in. + `reviewLookup: none` is the consequential one. It means the done-on-merge sweep cannot run in this repository, and every skill that would have swept must say so rather than reporting a clean sweep it never performed. @@ -43,7 +47,7 @@ The tier-2 probe already ran and either found nothing or was declined; re-probin Confirm the branch exists on the remote with `git ls-remote --exit-code --heads origin `. -## `openReview(branch, base, title, body)` +## `openReview(branch, base, title, body, dependsOn?)` This operation does not push. `pushesForYou` is false, so the branch has already been pushed by the caller before this runs, exactly as on any other adapter that declares false. @@ -57,6 +61,7 @@ Print what a human needs to open the review by hand: - The suggested body, in full, so it can be pasted rather than reconstructed. Return no review id. +`dependsOn` is ignored here for the same reason the id is absent: there is no review object to attach a dependency to. Say plainly, at this point, all three of these, since a partial statement is what leaves the user guessing: diff --git a/skills/fathom-shared/forges/github.md b/skills/fathom-shared/forges/github.md index 897f8efd..0ef0d991 100644 --- a/skills/fathom-shared/forges/github.md +++ b/skills/fathom-shared/forges/github.md @@ -19,6 +19,9 @@ Shared contracts outside this file say "review"; that difference is deliberate, `ciHooks` is true because GitHub Actions can run a merge-closer workflow in the user's repository; the tracker adapters' merge-closer offers are gated on this. `pushesForYou` is false because `gh pr create` does not push the branch, so the calling skill pushes first. `stackedReviews` is `retarget` because GitHub stacking is branch retargeting, and GitHub retargets a dependent pull request automatically when its upstream merges. +That automatic retarget is real but partial, and the gap matters to the caller. +When the upstream pull request is **squash-merged**, the squash commit is not an ancestor of the dependent branch, so the dependent pull request retargets to the base and then redisplays the upstream bundle's changes as if they were new. +The dependent branch has to be rebased for its diff to be honest again, which is why the calling skill's rebase rule is keyed on commit ancestry rather than on this capability value. ## Absolute boundary @@ -50,7 +53,7 @@ Delivering these instructions is a complete, useful action, not a fallback. Confirm the branch exists on the remote with `git ls-remote --exit-code --heads origin `. A base branch that exists only locally is not a valid merge target, because the pull request is created against the remote. -## `openReview(branch, base, title, body)` +## `openReview(branch, base, title, body, dependsOn?)` Push the branch first; `pushesForYou` is false, so the push is the caller's and this operation does not perform it. @@ -59,6 +62,11 @@ Skip creation when a pull request already exists for the branch, and return the Return the pull request number as the review id, and the pull request URL. The number is what `getReviewState` looks up, and it resolves from any clone without a listing call. +Ignore `dependsOn` when it is supplied. +`stackedReviews` is `retarget`, so passing the previous bundle's branch as `base` is the entire mechanism, and GitHub needs no separate dependency declaration. +Never encode the dependency a second way, such as by adding a label or an extra API call; the base branch already carries it and a second representation can disagree with the first. +The `Depends on ` line in a review body is prose for a human reviewer and carries no machine meaning, so it is not a second representation of the dependency; the prohibition is on machine-readable representations such as a label or an extra API call. +Nothing on GitHub reads that line, which is why the calling skill writes it into every bundle after the first while this operation still ignores `dependsOn`. Two body conventions matter on GitHub specifically, and the calling skill supplies them: @@ -91,10 +99,14 @@ Look up each recorded id directly. Do not list pull requests to find one. An earlier version of the sweep matched `gh pr list --state all --json headRefName,state,mergedAt` against recorded branch names, which silently skipped older branches whenever the listing hit its default cap of 30; per-id lookup removes that hazard entirely and is the reason the sweep is keyed on ids. -## `findReviewByBranch(branch)` - optional, legacy records only +## `findReviewByBranch(branch)` - optional, record repair only -Run `gh pr list --state all --head --json number --limit 10` and return the newest number, or nothing when the list is empty. +Run `gh pr list --state all --head --json number,url,baseRefName --limit 10`. -This is the one sanctioned listing call, and it exists only so the sweep can repair a record written before review ids were recorded. +Return one candidate record per pull request the listing returned, newest first, each carrying the pull request number as the review id, its URL, and `baseRefName` as its base. +Return an empty list when the listing is empty. +Never collapse the list to the newest entry here: a head branch can carry more than one pull request, and which of them the caller wants is the caller's question to answer from the base, per the contract in `../forges.md`. + +This is the one sanctioned listing call, and it exists only so an incomplete record can be repaired: the sweep repairs a record written before review ids were recorded, and `execute` recovers a bundle whose pull request opened before its `- Review:` line was committed. Scoping the list to one head branch keeps it bounded regardless of repository age, which is what the unscoped listing above could not guarantee. Never use it for records that already carry an id. diff --git a/skills/fathom-shared/memory.md b/skills/fathom-shared/memory.md index 5363e470..324ff791 100644 --- a/skills/fathom-shared/memory.md +++ b/skills/fathom-shared/memory.md @@ -11,7 +11,7 @@ Adapter files implement each one against a specific backend; treat the operation | Operation | Purpose | | --- | --- | | `init(issueRef)` | Prepare the backend for this issue's task set. | -| `createTask(title, description, subIssueRef, deps)` | Create a task, tag it with the issue ref so all tasks for one issue can be listed directly, record `subIssueRef` on the task, and return its task id. | +| `createTask(title, description, subIssueRef, deps)` | Create a task, tag it with the issue ref so all tasks for one issue can be listed directly, record `subIssueRef` on the task, and return its task id. This is the only operation here that takes `deps`, so the dependency edges between a split issue's child tasks are settled as those tasks are created and cannot be added to a task that already exists. Create the child tasks in planned order for that reason, so each task's predecessor id already exists when the next task needs it as a dep. The parent task's own dependency edges on its children are outside that guarantee and are added after the children exist, as the `parentTask` row below describes. When the issue was split into a stack, every task takes a dep on its predecessor so the whole issue forms one sequential chain across bundles as well as within them, which is what lets the backend itself enforce bundle order: a later bundle's task is never claimable while any earlier task is still open. A single edge at each bundle boundary would not achieve this, because a task carrying no deps at all has them trivially closed and stays claimable out of order. Whether the issue is split is therefore decided before the first `createTask` call, since a chain this contract cannot add afterwards has to be built as the tasks are created. | | `claimNext()` | Return and mark in-progress this issue's first open task whose deps are all closed; null when none remain. Scope every call to the issue being worked: a backend able to see other issues' tasks must filter to this one, or the loop will implement another issue's work on this branch and close the wrong sub-issue. When an interrupted run left one of this issue's tasks in progress, return that task to be resumed rather than claiming a new one. | | `close(taskId)` | Mark a task done. | | `status()` | Return this issue's open and done counts and its current in-progress task, scoped to the issue exactly as `claimNext` is. | @@ -63,3 +63,6 @@ The human-readable plan always lives in the plan document at `.fathom/plans/.md` holds the checkbox statuses for that issue, and the plan still lives in the plan document. Whichever backend is active, at least one file under `.fathom/` must record the issue's branch, its review id once one exists, and its tracker URL, because the merge sweep finds an issue by searching that directory, and a merge-closer running on the forge's own CI finds one the same way. +A stacked issue has more than one branch and more than one review id, so it records one branch per bundle at breakdown time and adds each review id once that bundle's review exists, in stack order, in the plan document's `Bundles` section described in `conventions.md`. +The single `Branch` line at the top of the plan document keeps naming bundle 1's branch and is never removed, because the merge-closer Action matches that exact label and knows nothing about stacks. +This is a record of structure rather than of status, so it does not violate the no-dual-truth rule above: task status still lives only in the resolved backend, and the sweep reads review ids from these lines the same way it reads the single-review one. diff --git a/skills/fathom-shared/trackers.md b/skills/fathom-shared/trackers.md index 121072e4..e62cf8d3 100644 --- a/skills/fathom-shared/trackers.md +++ b/skills/fathom-shared/trackers.md @@ -87,17 +87,70 @@ When it declares `none`, there is no way to observe what happened to a review, s Find the outstanding issues by searching `.fathom/` for recorded reviews. Search the whole directory rather than only `tasks/`: depending on the resolved memory backend the per-issue record may be a plan document under `plans/` with no checklist file at all, and narrowing the search to `tasks/` silently skips those issues. -For each issue the search finds, call `getReviewState` once with that issue's recorded review id and act on what it returns. +For each issue the search finds, read every review id recorded for it and call `getReviewState` on each one before deciding anything about that issue. +A single-review issue records one id; an issue split into a stack records one per bundle, in the plan document's `Bundles` section described in `conventions.md`. +Read the records rather than assuming a count: acting on the first id found would decide a stacked issue's fate from one bundle's result while the rest of its work was still open, which is the early close the `Merge-closer: suppressed` marker exists to prevent. +A stack's records are spread across its bundle branches rather than gathered in one place. +Each bundle's `- Review:` line is committed on that bundle's own branch as that bundle's review publishes, so a checkout of the base branch carries the records of the bundles that have merged into it and none of the records above them. +Collect the missing ones before judging anything: read the branch names from the plan document's `Bundles` section, fetch each of those branches, and read each fetched branch's own copy of the plan document, taking every `- Review:` line it carries rather than only the line for the bundle that branch belongs to. +Take them all because a run recovering a bundle whose branch was deleted or reused records that bundle's outcome on the branch it is on, which is a write path that exists, so that bundle's line can sit on a branch other than its own. +A bundle branch is created from the branch below it, so the highest one that still exists carries every record beneath it, and fetching all of them costs nothing beyond that. +Prefer this to mirroring the ids into a store the base branch can read directly, such as a tracker comment or a second file: fetching is read-only git work that needs no write anywhere and cannot drift, whereas a second record of the same fact is a second thing that can disagree with the plan document. +When no `- Review:` line for a bundle turns up on the current branch or on any branch this collection fetched, that bundle simply has no record, and case 2 below decides what happens then. + +An issue none of whose bundles have merged has no record on the base branch at all, since the plan document itself is committed on bundle 1's branch, so from a base checkout that issue is not found by the search above. +That is exactly how an unmerged single-review issue behaves, and it is correct: nothing has merged, so there is nothing to close. + Look each id up directly; never list a forge's reviews and match them locally. A listing has to be bounded, and any bound silently drops the oldest records once a repository has more reviews than the bound allows, which is a defect that grows quietly with the repository's age. Records written before review ids were recorded carry a branch name and no id. -For those, fall back to the optional `findReviewByBranch` operation defined in `forges.md`, and rewrite the record with the id once one is known, so the fallback path drains over time rather than becoming permanent. -When the resolved adapter does not implement that operation, the record cannot be swept: report that once, naming the record, rather than guessing or treating a branch name as a review id. - -When `getReviewState` returns `merged`, read the issue's current state before writing to the tracker. +For those, fall back to the optional `findReviewByBranch` operation defined in `forges.md`, which returns bounded candidate records carrying each review's id, its URL, and its base. +Treat such a record as resolved only when exactly one candidate comes back, since a legacy record names a branch and nothing else and so carries nothing to tell two candidates apart; two or more candidates leave it unresolved rather than presenting a choice to make. + +Resolution is not complete at the id. +Add the resolved id to that issue's set of review ids and call `getReviewState` on it, and do both before any of the ordered cases below are evaluated for that issue, so every case judges the issue on its whole set rather than on the subset that already carried ids. +Doing this after the cases, or not at all, would let the completeness requirement and the aggregate cases run against an incomplete set: an issue whose only unresolved record is the branch-only one would read as fully recorded, and case 3 would close it on the strength of the reviews that happened to have ids. +Then rewrite the record with the id, so the fallback path drains over time rather than becoming permanent. + +When resolution fails, and when the resolved adapter does not implement that operation at all, that record yields no id and no state: report that once, naming the record, rather than guessing or treating a branch name as a review id. +Leave the issue incomplete in that case, exactly as a missing `- Review:` record leaves it, so case 2 below blocks closure on it instead of the aggregate cases deciding the issue on partial data. + +Judge each issue on all of its results together, in the order below, letting the first case that applies decide that issue. +An issue can satisfy more than one case at once, and a stack holding a merged bundle, an open bundle, and an abandoned one routinely does. + +1. Any recorded review reports `closed-unmerged`. + Apply the closed-without-merging path below for that review, and, when the issue is a stack, name which bundles above it are now orphaned by it. + Close nothing for that issue, and do not read its merged reviews as progress toward closure. + This case is checked first and is terminal, however many of the issue's other reviews merged or stayed open, because whether to retry, rescope, or drop the orphaned work is the user's decision and nothing should be built on top of work that may be about to be discarded. +2. Any recorded review reports `unknown`, or some bundle between 1 and N has no `- Review:` record at all, or a branch-only record could not be resolved to a review id, and none reported `closed-unmerged`. + `getReviewState` returns `unknown` when it could not determine the review's fate, which is not a state the review is in but an answer the sweep did not get. + A missing record is the same kind of gap: the `Bundles` section says how many bundles the issue has, so N is known even when a record is not, and an issue judged on fewer records than N is judged on an incomplete set. + An unresolved branch-only record is that same gap in a third shape: the record is there, but nothing behind it can be looked up, so the review it stands for is exactly as unobserved as one whose record is missing. + With N of 3 and only two records collected, the cases below would read a partly recorded three-bundle stack as a complete two-bundle one, and case 3 would then close a half-merged issue. + So require a record for every bundle from 1 to N, and a `getReviewState` result for every one of those records, before evaluating cases 3, 4, and 5 at all, and take this case whenever that requirement is unmet. + Change nothing about the issue: close nothing, report nothing about its progress, and leave it exactly as it stands for a later sweep to decide. + Name the review ids that came back `unknown`, the bundles whose records are missing, and the branch-only records that could not be resolved, and say that this issue was left undecided because of them. + Never fold an `unknown` result, a missing record, or an unresolved branch-only record into `merged`, `open`, or "still entirely in review": each of those is a specific claim about work the sweep cannot actually see, and the later cases would otherwise absorb it and make that claim anyway. + This case sits below case 1 because a `closed-unmerged` result is a fact the sweep did observe, and its outcome does not depend on the undetermined or unrecorded ones: it closes nothing, restacks nothing, and hands the decision to the user, which is already the safest thing an incomplete picture could ask for. + It sits above every case below because those judge the issue on all of its results at once, and neither an undetermined result nor a missing one can carry its share of such a judgment. +3. Every recorded review reports `merged`. + Apply the merged path below. + For a single-review issue that is its one review, and for a stack it is every bundle, which is what keeps a stack from being closed by its first merge. +4. Some reviews merged and others still open. + Close nothing, and report the partial progress, naming which bundles merged. +5. None merged and none closed without merging. + The work is still entirely in review, so close nothing and say so plainly rather than reporting nothing at all. + Every result reaching this case is `open`, since an `unknown` one was already decided by case 2. + +Cases 2, 4, and 5 leave the issue's phase exactly where it is. +The branches a partially merged stack leaves behind may still need restacking, but that is git and forge work rather than tracker work, so it belongs to the skill running the sweep; this section decides only what is written to the tracker. + +On the merged path, read the issue's current state before writing to the tracker. When the issue is already complete, for example because a merge-closer Action or a native integration already closed it, do nothing further for that issue. Otherwise apply the mapped `done` state through `updateState`, plus any closure action the adapter defines for the merged path, before proceeding with the rest of the run. +An issue whose record carries `- Merge-closer: suppressed`, which is how a stacked issue is recorded per `conventions.md`, was deliberately left for this sweep to close: the Action takes no action for it, so the sweep is its only closure mechanism and reaching `done` requires a run of this sweep. +The state read above still applies to it unchanged, since a user may have closed such an issue by hand. That state read is the whole idempotency mechanism for the merged path. An issue that is already `done` produces no write on any later run, so nothing needs to be recorded anywhere and nothing needs to be pushed. @@ -218,6 +271,7 @@ forge: github # a bundled adapter name, "local" for .fathom/forge.md, o default-destination: Prototypes (1209000000000001) # add "# auto-accepted" when auto mode chose it base-branch: main approval: ask +stacking: propose # write this to let the repository split an issue into a stack; "never" or absent keeps it on one review per issue merge-closer: native # "none (forge has no hooks)" when the forge declares no ciHooks state-mapping: inProgress: section "In Progress" @@ -225,6 +279,10 @@ state-mapping: done: section "Done" + completed ``` +The `stacking` line is optional and is not one of the six setup questions above, so first-run setup neither asks for it nor writes it. +Write it only when the user asks for a repository-wide answer, and treat its absence as `never` exactly as `approval.md` states. +Leaving it out of setup therefore means a freshly set up repository produces one review per issue and never proposes a split, which is the opt-in behavior stacking is meant to have; a repository that wants stacking adds the line itself. + On every subsequent run, read the existing profile silently and use it without re-prompting. Re-run setup when a mapped state no longer exists in the tracker, or when the user explicitly asks to redo it. Re-run setup to resolve merge conflicts in `.fathom/config.md`; do not attempt to hand-merge the conflicting mapping. diff --git a/skills/fathom-shared/trackers/asana.md b/skills/fathom-shared/trackers/asana.md index 8d1958e5..189c020c 100644 --- a/skills/fathom-shared/trackers/asana.md +++ b/skills/fathom-shared/trackers/asana.md @@ -179,6 +179,28 @@ jobs: exit 1 fi + # A stacked issue records one branch per bundle, so any one bundle's + # merge reaches this Action while the rest of the work is still open. + # Such an issue records a suppression marker and is closed by fathom's + # own sweep once every bundle reports merged. Check every matching + # record rather than the one selected below: in checklist mode the + # marker lives in the plan document while the task file is preferred. + # Read the list the same way everything above does, through + # printf and a quoted read: an unquoted for loop word-splits and + # glob-expands the path, so one record named with a space or a + # bracket would silently fail the grep and close a stacked issue. + SUPPRESSED=$(printf '%s\n' "$MATCHES" | while IFS= read -r RECORD; do + [ -n "$RECORD" ] || continue + if grep -qE '^[[:space:]]*[-*]?[[:space:]]*(\*\*)?[Mm]erge-closer(\*\*)?[[:space:]]*[:-][[:space:]]*(\*\*)?[Ss]uppressed' "$RECORD"; then + printf '%s\n' "$RECORD" + break + fi + done) || true + if [ -n "$SUPPRESSED" ]; then + echo "$SUPPRESSED records merge-closer: suppressed, so this issue is a stack that closes only once every bundle merges. Taking no action for $BRANCH." + exit 0 + fi + # Prefer the task file when both exist; it also carries the review id. # Anchor the prefix rather than matching /tasks/ anywhere: grep -r # descends into dot-directories, so a repo left holding a nested diff --git a/skills/fathom-shared/trackers/linear.md b/skills/fathom-shared/trackers/linear.md index 7d46359b..abd78645 100644 --- a/skills/fathom-shared/trackers/linear.md +++ b/skills/fathom-shared/trackers/linear.md @@ -168,6 +168,28 @@ jobs: exit 1 fi + # A stacked issue records one branch per bundle, so any one bundle's + # merge reaches this Action while the rest of the work is still open. + # Such an issue records a suppression marker and is closed by fathom's + # own sweep once every bundle reports merged. Check every matching + # record rather than the one selected below: in checklist mode the + # marker lives in the plan document while the task file is preferred. + # Read the list the same way everything above does, through + # printf and a quoted read: an unquoted for loop word-splits and + # glob-expands the path, so one record named with a space or a + # bracket would silently fail the grep and close a stacked issue. + SUPPRESSED=$(printf '%s\n' "$MATCHES" | while IFS= read -r RECORD; do + [ -n "$RECORD" ] || continue + if grep -qE '^[[:space:]]*[-*]?[[:space:]]*(\*\*)?[Mm]erge-closer(\*\*)?[[:space:]]*[:-][[:space:]]*(\*\*)?[Ss]uppressed' "$RECORD"; then + printf '%s\n' "$RECORD" + break + fi + done) || true + if [ -n "$SUPPRESSED" ]; then + echo "$SUPPRESSED records merge-closer: suppressed, so this issue is a stack that closes only once every bundle merges. Taking no action for $BRANCH." + exit 0 + fi + # Prefer the task file when both exist; it also carries the review id. # Anchor the prefix rather than matching /tasks/ anywhere: grep -r # descends into dot-directories, so a repo left holding a nested