Skip to content

Make implicit state machines explicit across the codebase #267

Done
6 of 6 issues completed
Done

Description

@DocksDocks

Goal

Scan first-party code for lifecycles whose valid states and transitions are implicit. Make each confirmed machine explicit. Preserve observable behavior except for the stale cleanup checks described in #273. Record coverage and exclusions.

Yolo: the user delegated every decision except the merge to the agent.

Mode: plan-and-implement

Research

Use a state model when an event changes which operation is legal or which data must exist. Do not turn every Boolean, counter or ordered procedure into a state machine.

Owner Evidence and disposition
Bounded workers syncConcurrency.ts:19–41 keeps a stop flag and an independent failure map. Admission and draining are mutually exclusive; tidy and its report share the runner.
CLI engine logger.ts:77–169 coordinates exclusive output, release and queued writers. exec.ts:175–195 arbitrates close and timeout. Separate independent leases, resources and counters; do not collapse them into a single global phase.
Plan helper plan/commands.ts:187–196 prepares claims; plan/github.ts:725–745,836–842 compares and confirms them. latestCloser produces a dependent timestamp and closer. Existing phase labels and authority event variants are already explicit. Check interleaved reads in the fake GitHub server.
Talk transport and binding transport/listener.ts and extension.ts coordinate publishing, withdrawal and cleanup. Distinguish outstanding requests from registration identity. Keep existing protocol schemas and actual sources of truth.
Talk delivery and UI tool/delivery.ts:209–226,259–290 maintains a cursor while watches exist. tool/asks.ts:176–182 stores a heartbeat counter on ended rows. ui/command.ts:258–275 keeps active and outgoing view handles across asynchronous mounting. Existing message outcomes and acknowledgement tags already name their states.
Supporting code .agents/skills/verify/scripts/smokeScan.ts:65–92 pairs a final promise with a completion flag. hygiene.ts, verify-gate-core.ts and cli/scripts/build-talk.ts have token readers with data that applies only to certain phases. Inspect those readers and reusable harnesses before changing them.

Already explicit or not machines: workflow job dependencies in parity.yml and release-cli.yml; linear installer, update and release steps; the sync lock stack released in finally; independent plugin uninstall failures; static data, Markdown, goldens and third-party code. Regenerate derived files only from their sources. The last child must reconcile the tracked first-party file list against all six children, including findings not listed above. Record dispositions and paths in the issues, not a new permanent catalog.

Assign source coverage before implementation: #268 owns syncConcurrency.ts; #270 owns cli/src/plan and the fake GitHub harness; #269 owns the remaining cli/src. #271 owns cli/talk/transport and the binding/transport portion of extension.ts; #272 owns the rest of cli/talk, including UI event wiring. Each owns the tests for its behavior. #273 owns all remaining first-party inputs: cli/scripts, reusable test infrastructure, .agents, source extensions under SoT, root launchers, installers, workflows, and any unclassified path. Its final report indexes all dispositions by path and commit. At the start of each child, check its entire assigned group, not just known examples.

When later evidence finds a machine outside a started child's scope, do not reopen frozen steps or silently defer it. Create a new reviewed implementation child under #267, add its parent row, review the revised parent, and require that child's archive and refreshed proofs before closure. Repeat reconciliation if the default branch moves before closure.

Decision: split by owner and start with the worker pool. It has one implementation shared by two CLI paths and deterministic overlap tests. A single repository-wide change would join unrelated regressions and make them harder to revert. Local state models need no new dependency or common framework. Revert each child separately. To prevent the split from hiding omissions, the final child checks all tracked first-party executable inputs against the inventory.

Scoped correction from #273 code review. Asked: “without changing observable behavior”. A stop result may update a key or emit a reminder only while the checked record is still pending under that key. Discard stale positive and negative results. This suppresses duplicate reminders and preserves a replacement for its own check. Two fixture tests reproduced a duplicate and a lost replacement on f7a17633972baaf419dff7b99ffa329e9984bd99. P3 must replay those tests and a late positive for a replaced record on final main. Keep normal output and immediate creation notices unchanged. A global lock would serialize unrelated resources; a second child for the same check would separate the model from its invariant. Revert the correction through #273 if normal stop behavior regresses.

Tools: docks-kit 0.31.0, gh 2.103.3, git 2.53.0 (local version output). For typed phase-specific data, use the TypeScript narrowing handbook. Prefer the existing single source of state over adding a tag that can disagree with it.

Steps

# Id Task Files Depends Effect Status Done when
1 workers Model bounded worker admission and failure drain - - local done child #268 finished
2 engine Model terminal and child-process lifetimes - - local done child #269 finished
3 plan_io Model plan write claims and close observations - - local done child #270 finished
4 transport Model talk registration and transport lifetimes - - local done child #271 finished
5 interaction Model talk delivery and interactive flow lifetimes - 4 local done child #272 finished
6 tooling Model supporting tooling and reconcile the full inventory - 1, 2, 3, 4, 5 local done child #273 finished

Acceptance

ID Command Expected
P1 docks-kit plan show 267 Every child listed in Steps, initially #268–273 and including any additions, appears once and is finished. Open, missing or retired work fails.
P2 For each P1 child, run the three reads below, then gh pr view "$pr" --repo DocksDocks/docks-kit --json state,baseRefName,mergeCommit,headRefOid,body. Match Verification Results to the PR head, a merge into main, its closing keyword, and the current trusted landing archive record for that PR. Fail on missing evidence or multiple assigned actors.
P3 git fetch origin main then git rev-parse origin/main; use that output as revision. Run git ls-tree "$revision", descending each tree with git ls-tree "$revision:$directory" except docs/plans/finished. In a clean checkout of exactly revision, rerun every child's reproducible behavior checks and inspect every candidate at that revision. Record new results for this one revision, including cross-owner interactions, callers and test inputs. Each first-party executable input maps to an owner and disposition. New confirmed machines require a reviewed child and P2. Earlier results, unchanged filenames and abandoned PR branches are not final proof.

Pass conditions for P2 and P3: P2 requires passing behavior checks for every confirmed machine on its exact reviewed PR head. P3 requires every required rerun to pass on revision and every confirmed machine to be explicit in that tree. Missing, skipped, failed or stale evidence fails acceptance. A model lost after an earlier merge fails even when all behavior tests pass. For both new discoveries and regressions, land the repair in a reviewed child, verify its archive through P2, and repeat P3 on the new final revision. Do not close the parent until all three rows pass together.

P2 reads, with child set to the issue number and pr taken from the trusted archive line:

gh issue view "$child" --repo DocksDocks/docks-kit --json body
gh api graphql -F n="$child" -f query='query($n:Int!){repository(owner:"DocksDocks",name:"docks-kit"){issue(number:$n){assignedActors(first:2){nodes{... on Actor{login}}}}}}'
gh api graphql --paginate -F n="$child" -f query='query($n:Int!,$endCursor:String){repository(owner:"DocksDocks",name:"docks-kit"){issue(number:$n){comments(first:100,after:$endCursor){nodes{author{login} createdAt body} pageInfo{hasNextPage endCursor}}}}}'

Use the latest archive record from the sole actor in the current cycle, after any Reopened: comment by that actor. Preserve API order for equal timestamps, as trustedComments and archiveKind do. P3 needs only the final main tree; it does not fetch or compare historical PR heads.

Do not touch

Except for discarding stale stop results and the resulting kit patch version in #273, preserve external commands, wire formats, ordering, output and failure semantics. Do not change release policy, dependency versions or trusted user settings. Do not inventory frozen plan history or add a state machine library.

Open questions

Verification Results

Final main: 49f308a17a13c116bf4bfa0adf0289fe280b7da8. Its tree 0f1e8b9a7a44dca72f209611eb86c319a05417eb matches both the reviewed head and the protected CI merge.

Sub-issues

Sub-issues

6 of 6 Issues completed
Loading 6 sub-issues

Activity

  1. self-assigned this
    on Nov 30, 2026
  2. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Delegation grant: yolo: next up is a yolo issue for "scan this codebase for any implicit state machines and make it explicit"

  3. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 1

    Plan-review: repair

    • goal_fit - Research, final inventory decision; Steps transport and tooling; Acceptance P2–P3 - The only repository-wide reconciliation starts after the five earlier owners finish. Inference: if Model stateful tooling and complete the repository inventory #273 confirms that the route-claim lifecycle in cli/talk/transport/client.ts:432–455,479–497 needs a model, Make talk transport and binding lifetimes explicit #271 is already finished and Model stateful tooling and complete the repository inventory #273 owns supporting tooling. The plan can flag the omission but has no landing owner for it. The plan contract’s “Status, ownership, and frozen state” section does not let the final child absorb new scope after it starts. - Assign every first-party source group to an owner before that owner starts. Keep Model stateful tooling and complete the repository inventory #273 as the cross-check, and require any late confirmed work to land through a reviewed child before parent closure. - class: audit scheduled after its implementation owners finish
    • goal_fit - Steps 1–6, Done when; Acceptance P1–P2 - show reports finished from GitHub’s CLOSED and COMPLETED state, not from merge or archive proof (cli/src/plan/commands.ts:374–391, cli/src/plan/records.ts:592–603). A child can record passing checks before merge and then be closed manually as completed. P1 and P2 can both pass even though its code never landed. The parent archive checks child status, while the child archive verifies the merge into the default branch (cli/src/plan/commands.ts:878–888,924–966). - Keep P1 as the status check. Before archiving Make implicit state machines explicit across the codebase #267, require P2 to match each child’s verification to its successful child archive and merged pull request. - class: issue closure used as landing proof
    • goal_fit - Acceptance P2–P3 - git ls-files reads the current checkout’s index, and P2 reads historical verification records. If a later merge changes an already-audited file without renaming it, P3 still reports the same path and P2 still reports the earlier pass. Neither proves that the final code was audited or preserves behavior. Root AGENTS.md:73 says a relevant later edit invalidates the affected evidence. - Reconcile the inventory against a named commit on the merged default branch. Compare it with the commits each child verified, and refresh only the affected audit and behavior evidence before archiving. - class: completion evidence not tied to the landed revision
  4. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 2, delta

    Plan-review: repair

    • goal_fit - Acceptance P2 - gh issue view --comments prints only comments when output is captured, omitting the issue body where the plan contract records per-head verification. Even in a terminal, gh 2.103.3 displays assignees, not assignedActors, so it cannot establish the sole-assignee rule for an issue with a human and a bot assigned. P2 can see an archive comment without the evidence it needs to validate the author or the verified head - Read the issue body, all assigned actors, and timestamped comments explicitly. Match the verified head to the PR and require the latest valid archive record after any trusted reopen, as in cli/src/plan/reviews.ts:188–248. - class: acceptance command omits required proof fields
    • goal_fit - Research, source ownership; Acceptance P2–P3 - P3 compares each owned group against its own verified head. cli/src/engine-native/tidyReport.ts:104–125 calls Model the bounded worker pool’s failure drain #268’s worker pool and pairs its results with the original inputs. Inference: if Make CLI terminal and child-process lifetimes explicit #269 changes that caller after Model the bounded worker pool’s failure drain #268 verifies report behavior, Model the bounded worker pool’s failure drain #268’s owned files can still match its older head, and Make CLI terminal and child-process lifetimes explicit #269’s files can match its newer head. Neither comparison flags the stale Model the bounded worker pool’s failure drain #268 proof, even though AGENTS.md:73 requires refreshing evidence after a relevant edit - Compare each proof’s callers and test inputs against the head that produced it, regardless of ownership, or rerun the cross-owner behavior checks on the pinned revision. - class: completion evidence not tied to the landed revision
    • goal_fit - Acceptance P3 - git fetch origin main fetches main, not each PR head. After a squash merge and branch deletion, a fresh checkout can pass P2 and still lack the original $verifiedHead object, so P3’s diff cannot run - Fetch each recorded PR’s head ref and confirm that it matches the verified SHA before comparing trees. - class: required Git comparison base not fetched

    Previous findings:

    • Round-1 finding on Research, final inventory decision; Steps transport and tooling; Acceptance P2–P3: resolved - Research assigns coverage before work starts and gives late discoveries a reviewed child that must land before closure.
    • Round-1 finding on Steps 1–6, Done when; Acceptance P1–P2: resolved - P2 now requires a matching child archive and merged PR; finished issue status alone no longer suffices. The evidence retrieval defect is listed separately above.
    • Round-1 finding on Acceptance P2–P3: open - repeated above

    Manager response to round 1

    Repaired:

    • Round 1, late audit ownership: Research assigns each source group before implementation. New discoveries outside a started scope must land in reviewed children before closure.
    • Round 1, closure without landing proof: P1 and P2 require the verified head, the trusted archive record and the child's merged pull request into main, including future children.
    • Round 1, evidence tied only to paths: P3 pins the merged default-branch revision, compares each group against its verified head, and refreshes all affected evidence, including changed or newly discovered paths.

    Rejected: none.
    Redesigned: none.

  5. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 3, delta

    Plan-review: repair

    • goal_fit - Acceptance P2–P3 (lines 50–51) - P2 matches Verification Results to a head without requiring passing evidence for each confirmed machine. cli/src/plan/commands.ts:713–729 does not check those results when archiving a child. P3 then requires fresh results to be recorded, but does not say they must pass. Inference: if a later change breaks the input ordering asserted in cli/test/unit/engine-di.test.ts:22–49, P2 can still pass and recording the failed rerun satisfies P3 as written, despite the Goal requiring unchanged behavior. - Require passing behavior evidence for each confirmed machine at the PR head in P2, and make P3 fail if any required rerun is missing or fails on the pinned revision. - class: acceptance records results without requiring a pass
    • goal_fit - Goal and Acceptance P3 (lines 5 and 51) - P3 requires an owner and disposition for every input, but requires a reviewed child only for new confirmed machines. Inference: if a later change restores the original stop flag and failure map in cli/src/engine-native/syncConcurrency.ts:19–40, the worker pool remains owned and inventoried, and the drain test in cli/test/unit/engine-di.test.ts:74–96 can still pass because it checks behavior, not how the lifecycle is represented. P3 can therefore pass while a previously confirmed machine is implicit again. - Make P3 fail if any confirmed machine remains or becomes implicit on the pinned revision, and apply the reviewed-child and refreshed-proof rule to those regressions as well as new discoveries. - class: final audit does not require the implemented outcome

    Previous findings:

    • Round-2 finding on Acceptance P2: resolved - P2 now reads the issue body, assigned actors, and paginated timestamped comments explicitly, then selects the latest trusted archive record in the current cycle.
    • Round-2 finding on Research, source ownership; Acceptance P2–P3: resolved - P3 reruns the children's behavior checks and inspects cross-owner callers and test inputs on one pinned revision rather than reusing evidence based on owned paths.
    • Round-2 finding on Acceptance P3: resolved - P3 no longer compares against historical PR heads and needs only the pinned main tree.

    Manager response to round 2

    Repaired:

    • Round 2 P2: read the body, assigned actors and every page of timestamped comments explicitly. Filter to the current trusted archive cycle and compare the reviewed commit to the merged PR head.
    • Round 2 P3, cross-owner inputs: P3 now repeats behavioral verification across all children on one pinned final revision. No earlier pass substitutes for it.
    • Round 2 P3, missing historical git object: P3 reads the final main tree alone; P2 reads the reviewed identity from GitHub, not a local branch.

    Redesigned:

    • P3 no longer selects checks using per-owner diffs. That approach missed cross-owner callers and relied on local PR objects. Fresh audit and behavioral evidence on the final checkout cover both classes.

    Rejected: none.

  6. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 4, delta

    Plan-review: pass

    None.

    Previous findings:

    • Round-3 finding on Acceptance P2–P3 (lines 50–51): resolved - P2 requires passing behavior checks for every confirmed machine on its exact reviewed PR head. P3 requires all reruns to pass on the pinned final revision. Missing, skipped, failed, or stale evidence fails acceptance.
    • Round-3 finding on Goal and Acceptance P3 (lines 5 and 51): resolved - P3 fails if any confirmed machine is implicit on the pinned final revision, even when behavior tests pass. New discoveries and regressions require a reviewed child, P2 archive proof, and a fresh P3 run before closure.

    Manager response to round 3

    Repaired:

    • Round 3, P2/P3: the pass conditions now require passing behavior evidence on the reviewed PR head and passing verification on the exact final revision; missing or failed evidence fails acceptance.
    • Round 3, P3: the final audit fails if a confirmed machine is still implicit or has regressed. Both new and regressed findings must land through a reviewed child, then P2 and P3 repeat.

    Rejected: none.
    Redesigned: none.

  7. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 5

    Plan-review: repair

    • goal_fit - Goal, Research “Scoped correction from Model stateful tooling and complete the repository inventory #273 code review,” and Do not touch - The plan allows only duplicate suppression and retention after a stale negative, but its ownership rule also suppresses stale positives after replacement. In SoT/.omp/plugin/extensions/hygiene.ts:1946–1950,2254–2284, re-recording replaces the pending entry, while a positive result currently emits a reminder without checking that entry. Inference: if a stop observes a directory and waits for another check while the directory is replaced and re-recorded, the candidate emits the old reminder. The planned fix suppresses it and leaves the replacement pending. Neither of the two named outcomes covers that change - Apply the exception to stop results for records that are no longer pending. Keep normal stop output and immediate creation notices unchanged, and retain both reproduced cases in P3. - class: behavior-preservation promise contradicts the chosen ownership rule

    Manager response to round 4

    Repaired: none.

    Rejected: none.

    Redesigned: none.

  8. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 6, delta

    Plan-review: pass

    None.

    Previous findings:

    • Round-5 finding on Goal, Research “Scoped correction from Model stateful tooling and complete the repository inventory #273 code review,” and Do not touch: resolved - The parent now permits a stop result to update a key or emit a reminder only if the checked record is still pending under that key. P3 requires all three cases on final main: a duplicate reminder, a stale negative after replacement, and a stale positive after replacement. Normal output and immediate creation notices remain unchanged.

    Manager response to round 5

    Repaired: cover any stale result for a record no longer pending under its key. Require the late-positive replacement case in final P3.

    Rejected: none.

    Redesigned: use the ownership invariant as the scope boundary rather than a list of examples. It covers both signs and duplicate completion without widening the set of resources or commands.

  9. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Archived as parent: children #268, #269, #270, #271, #272, #273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions