Skip to content

Record, read and clean up prose workflow state in Go #886

Description

@tbhb-agent

Problem

Slice 01 of #327 under #588 makes workflow evidence available to Go before any caller changes. The existing state and baseline operations are at packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:155 and packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:242; diff and cleanup are at packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:339 and packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:384.

Acceptance criteria

  1. AC1: Baseline creation returns 0, reports the target's state path and retains the original document.
  2. AC2: A second baseline for an active target returns 2 with cleanup guidance.
  3. AC3: Two different targets receive distinct state directories.
  4. AC4: An operation supplied with another target returns 2 with the target-mismatch diagnostic.
  5. AC5: An invalid state path created by the unchanged shell returns 2 with the invalid-state diagnostic.
  6. AC6: A changed target produces the original unified diff and status 0.
  7. AC7: Cleanup removes only the named workflow, including an accepted legacy state.
  8. AC8: Non-functional: state-only edits do not make target-only verification fail.
  9. AC9: Non-functional: native state coverage passes on macOS, Linux and Windows.
  10. AC10: Given workflow state created by the Go commands, the unchanged shell's baseline-dependent operations (verify, diff, cleanup) accept it and act on that workflow's evidence, with the same results as for shell-created state.

Scope and non-goals

Go state, baseline, diff and cleanup under agentrepo prose check-suppressions. Non-goal: sanction suffix, verification findings, caller switches, test retirement or any frozen-file relocation. No new shell logic. Canonical sources generate the packages and deployments; generated copies are never edited by hand. No edits to shared libraries, guard scripts, merge scripts, ownership rules, workflow files or harness configuration.

Approach

Reuse the existing agentrepo tree. Keep target identity, state layout and compatibility with old-created evidence. Before coding, run the unchanged shell for dirty/staged/untracked/ignored and non-ASCII targets, read-only Git metadata, missing originals and legacy evidence; record results rather than assuming canonicalization behavior.

Observed oracle: baseline DRAFT.md returned 0/state; a duplicate returned 2/active-workflow cleanup guidance; OTHER.md got a different state. Verify with OTHER.md against DRAFT.md state returned 2/target mismatch; invalid state returned 2. Diff printed -first draft/+second draft and exited 0. Cleaning the second state left the first; cleanup of an absolute legacy state succeeded. Run-note edits remained compatible with silent target-only verification.

Dependencies

No build/merge blocker: additive Go only. Consume #321's applicable context contract without implementing its library here. #753 is rollout-only protection, required before #891 switches enforcement; #333/#544 are also rollout-only installation prerequisites.

Size

M. Existing shared suppression implementation: 263 scc code lines; this slice owns state, baseline, diff and cleanup, not a second copy of all 263 lines. Counts use scc 4.1.0; generated package/deployment output and token metadata are excluded, while source, tests, fixtures and frozen copies count. One PR with fewer than 800 changed code lines and at most 2,000 prose lines. No unbuilt Go size is claimed: measure the actual staged diff before publication and split again if the cap is exceeded.

Verify plan

  • AC1, AC2, AC3, AC4, AC5, AC7: go test ./internal/agentrepo -run '^TestProseState' -count=1 -v compares status, both streams and evidence against shell fixtures. Named TestProseState subcases cover Baseline (AC1: baseline an existing target, assert exit 0, stdout reporting its state path and a byte-identical original in that state), DuplicateBaseline (AC2: baseline the same active target again, assert exit 2 and the shell's cleanup guidance), DistinctTargets (AC3: baseline two different targets, assert distinct state directories), TargetMismatch (AC4: supply the other target to verify and diff, assert exit 2 and the shell's target-mismatch diagnostic), InvalidShellCreatedState (AC5: fixtures detailed beside AC6 below) and CleanupIsolation (AC7: create two workflows, clean one, assert only the named state is removed and the other is intact; repeat with an accepted legacy state as the cleaned workflow).
  • AC8: go test ./internal/agentrepo -run '^TestProseStateWorkflowStateOnlyEdits$' -count=1 -v will create a baseline, edit only a workflow run-note under .fix-prose/, leave the target unchanged and confirm target-only verification still returns 0 with empty stdout and stderr. This checks the workflow-state exclusion from the shell digest at packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:228.
  • AC5, AC6: TestProseState/InvalidShellCreatedState, run by the state command above, starts with unchanged-shell-created state and tests malformed state paths, copies under a wrong root and a mismatched supplied target. Run Go and the unchanged shell on the same fixtures; assert exit 2, matching stdout and the shell's exact stderr diagnostic for each fixture: check-suppressions: invalid workflow state: <state> for malformed paths and wrong roots, and check-suppressions: state belongs to <expected>, not <supplied> for target mismatch. go test ./internal/agentrepo -run '^TestProseDiff' -count=1 -v covers named subcases ChangedTarget (AC6: change the target after baseline, assert the original unified diff and exit 0), UnchangedTarget (empty diff, exit 0) and MissingOriginal (exit 2 and the shell's missing-original diagnostic), comparing both streams and normalizing only roots and timestamps. Diff also consumes valid shell-created state from both the current .fix-prose/run.* and legacy <git-dir>/fix-prose/run.* roots accepted at packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:102-103,167-173. Apply exact dictionary sanctions in Go #888 adds the sanction suffix separately.
  • AC10: go test ./internal/agentrepo -run '^TestProseStateGoCreatedShellOperations$' -count=1 -v uses paired Go-created and shell-created baselines for the same initial target bytes. Its named subcases VerifyUnchanged (unchanged target: shell verify exits 0 with empty stdout and stderr), DiffChanged (edit the target: shell diff exits 0 and prints the unified diff against each state's retained original) and CleanupIsolation (shell cleanup removes that workflow while preserving a second workflow) compare exit status, both streams and filesystem effects between the paired fixtures, normalizing only roots and timestamps. Run these shell-comparison cases in the Unix environments named under AC9. Cover the current .fix-prose/run.* root only, since Go never creates legacy state.
  • AC9: run all three native test entry points, TestProseState (including its named subcases above), TestProseStateWorkflowStateOnlyEdits and TestProseDiff, on macOS, Linux and Windows and require passing native state assertions on each platform. Use recorded shell fixtures for native assertions where the shell is unavailable; run live shell comparisons, including AC10, on macOS and Linux and record those environments separately.

At the merged head, record each AC command and result, native platform execution and any skips. Required checks must pass without weakening gates. Obtain independent review of the exact head and record findings dispositions; use signed commits with Assisted-by trailers and the provenance:agent-assisted label. Match documentation to behavior, scan issue/PR text before any later publication, and record the final merge commit and closing reference. This draft authorizes no publication.

Risks

Changed state identity could clean another workflow or admit overlapping writers. Undo: revert this unused Go addition; original entry files and active evidence remain intact.

Operator authority

None

Activity

  1. tbhb-agent commented on Oct 27, 2026

    @tbhb-agent
    ContributorAuthor

    Refinement: READY — Record, read and clean up prose workflow state in Go
    Model: gpt-6-astra

    Child 01 Record, read and clean up prose workflow state in Go

    Verdict: READY

    Checked: The round 1 placement prescription is removed. internal/agentrepo/command.go:85 is now evidence only; the command interface and registration protection remain requirements. State identity, legacy acceptance, duplicate-target refusal, diff and cleanup remain consistent with packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh:155. Verification covers every AC. The 650-code-line estimate remains bounded.

    Gaps: None.

    Split: None required.

    Definition of done

    The definition of done for this issue (Feature). Tick each item and give its evidence.

    • D1 The author verified each AC on the merged head, and the Verification section of the pull request cites each AC ID with its evidence: the command and its result, or a link.
    • D2 An independent reviewer approved the exact merged head, and the author resolved each finding or filed it as a follow-up.
    • D3 The required checks pass on that head, and any loosened gate has the owner's approval of that exact head.
    • D4 The leak scans come back clean: gitleaks, devtools' check-leaks.sh with the repository's private-strings list, and the leak review of each post.
    • D5 The author signed each commit, the squash included.
    • D6 The docs match the change (README, docs/, CHANGELOG or help text), or the Verification section says "No doc impact" and why.
    • D7 The commits and the squash have Assisted-by trailers, and the pull request has the provenance:agent-assisted label.
    • D8 The pull request stays within the size limits, or the owner approved its exact head over the hard limit.
    • D9 The author files follow-ups and deferred findings as issues with at least a Problem and numbered AC and lists them under the Related section of the pull request. Any work left in the code links its issue.
    • D10 The merge closes the issue through a closing reference and the board shows Done. The final Status: comment names the merge commit.
    • devtools-1 mise run check is green, and so are the coverage floors mise run cover-go-check and mise run cover-py-check, which check doesn't run.
    • devtools-2 A change to skill sources under packages/agents/source/ commits what mise run generate-skills, then mise run skill-tokens, then apm install rewrite, in that order, and check-generated-skills (part of lint) passes.
    • devtools-3 A consumer-visible change (the vendored payload, a skill, a reusable workflow, a task or a pin) has its consumer steps in docs/agent-skills-migration.md or the adoption docs, or the PR's Verification says "No consumer impact" and why.

    Round: 2 of 3

  2. tbhb-agent commented on Nov 1, 2026

    @tbhb-agent
    ContributorAuthor

    Refinement: READY — Prose workflow state parity is testable

    Checked

    Origin identifies tbhb-dev/devtools; origin/main is c34b35dd259370c6dfb2f3e254285a8fc73c4daf. The draft’s invalid-state fixture compares Go and unchanged-shell results for malformed paths and wrong roots, including the exit status and diagnostic. That closes the prior AC5 gap. AC2, AC4, AC6, and AC10 also pair their stated outcomes with fixtures that check the expected status, output, or filesystem effect.

    The approach follows #588’s Go-port direction and adds no shell logic. The named shell path, packages/agents/source/skills/fix-prose/shared/scripts/check-suppressions.sh, is not owner-tier. No named path is CODEOWNERS, an agent-skills configuration or review policy, harness configuration, or a workflow/action path.

    #753 is open and is already linked as blocked by. #321, #333, and #544 are open; the draft describes them as context or rollout prerequisites, not blockers to this slice. The M size estimate and PR caps support one PR.

    Gaps

    None.

    Split

    None required.

    Definition of done

    Planning coverage only: checked boxes mean the ACs and Verify plan cover the item; they do not mean work is complete.

    • D1 Verify each AC at the merged head and record its command and result. Evidence: the plan requires recording each AC command and result.
    • D2 Independent review approves the exact head, with findings dispositions recorded. Evidence: the plan requires exact-head review and recorded dispositions.
    • D3 Required checks pass without weakening gates. Evidence: the plan requires passing checks without weakening gates.
    • D4 Required leak scans are clean and each post receives per-post leak review. Evidence: the plan mentions scanning text before later publication, but not the required scans and reviews.
    • D5 Every commit is signed. Evidence: the plan requires signed commits.
    • D6 Documentation matches behavior. Evidence: the plan requires matching documentation to behavior.
    • D7 Commits include Assisted-by trailers and the PR has the provenance:agent-assisted label. Evidence: the plan names both.
    • D8 The PR stays within the size limits. Evidence: the plan sets caps and requires measuring the staged diff and splitting if needed.
    • D9 Follow-ups are filed as issues and listed under Related. Evidence: the plan does not require this.
    • D10 The merge closes the issue, the board shows Done, and a final Status: comment names the merge commit. Evidence: the plan mentions a closing reference and merge commit, but not the board state or final comment.

    Round: 3 of 3

  3. moved this from Backlog to In progress in devtoolson Nov 1, 2026
  4. added 2 commits that reference this issue on Nov 1, 2026
    c38ff5f
    fe76797
  5. moved this from In progress to Done in devtoolson Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinement:readyPassed the Definition of Ready; may be picked up

    Fields

    Priority

    None yet

    Work type

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions