Skip to content

Gather the prose writer's context in Go #890

Description

@tbhb-agent

Problem

Slice 05 of #327 ports the writer report at packages/agents/source/skills/write-prose-fix/shared/scripts/context.sh:25. Full findings, notes and numbered text must remain in the writer's context rather than the caller summary.

Acceptance criteria

  1. AC1: Outside Git or without workflow evidence, context emits the corresponding BLOCKED message and exits 0.
  2. AC2: A target mismatch emits the existing target-specific BLOCKED message and exits 0.
  3. AC3: Nonempty run-specific notes appear instead of legacy notes.
  4. AC4: When run notes are absent or empty, nonempty legacy notes appear.
  5. AC5: The valid report retains section order and numbered document text.
  6. AC6: Partial output from a failing lint command appears in findings with report status 0.
  7. AC7: A silent lint command produces the existing empty-output marker.
  8. AC8: When Vale is absent, both probe sections contain the existing unavailable notice.
  9. AC9: When Bash cannot start, findings contains one executor-unavailable BLOCKED line and later sections still follow.
  10. AC10: Non-functional: read-only fixtures leave the document and evidence unchanged.
  11. AC11: Non-functional: native context cases pass on macOS, Linux and Windows.
  12. AC12: For the missing-target, omitted-lint, command-terminator, Vale scope and replacement-count fixtures in Verify plan, the complete report matches the existing shell output and exit status, including BLOCKED, ERROR, UNSCOPED, Covered and Unknown explanations and counts of matching lines rather than occurrences.

Scope and non-goals

Add agentrepo prose context, retaining the command boundary at --, distinct state checks, scope explanations and replacement-line counting. Non-goal: editing prose, running replacements or writers, broader permissions, stronger state policy, caller switches or frozen-file changes. 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 #889's probe/executor helper while preserving the reports' different text and stopping rules. Use the concrete Verify plan fixtures to record omitted lint, missing file, empty notes, command terminator, valid/error scope probes and replacement counts against the shell before porting those branches. Do not substitute another template or count occurrences instead of lines.

Observed: outside Git and missing state returned BLOCKED/0; target mismatch named both documents and returned BLOCKED/0. A valid run printed numbered second draft and partial lint note despite a failing lint command, with report status 0. true produced (nothing). Notes printed current decision while legacy old decision existed; absent or empty run notes select the legacy notes through the shell fallback; the absent-notes run printed old decision. With Vale absent both final probe sections printed (vale not on PATH). Executor-start failure is the explicit new outcome from #889, not claimed frozen-shell parity.

Dependencies

Blocked on: #886
Blocked on: #889
Blocked on: #753

#886 supplies workflow evidence, #889 supplies the probe/executor helper, and #753 blocks this issue because its agentrepo subcommand registration path must be available for this command. #321 owns the shared launcher; #333/#544 are rollout-only prerequisites for #892. Keep these dependencies recorded in prose; changes to native dependency links wait on #655. This draft changes no native relationships.

Size

M. Existing context report: 101 scc code 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

Run go test ./internal/agentrepo -run '^TestProseContext' -count=1 -v for every fixture below. Compare complete stdout, stderr and exit status against the original shell for AC1 through AC8 and AC12; the planned fixtures are the contract to implement, not claims of completed tests. Baseline: a temporary Git repository, matching nonempty workflow target evidence for draft.md, document bytes first line\nsecond draft\n, no notes, an available Bash executor, lint command true, and Vale absent. Unless a row overrides them, retain these inputs. Shell-parity fixtures expect report status 0 and empty stderr; diagnostics from lint and Vale appear inside stdout. Capture full outputs to check exact text, blank lines, section order and line-number spacing.

For invocation checks, use a lint stub that appends one entry to a fixture-only call log and creates a fixture-only sentinel. An early refusal must leave both absent, proving lint never ran. Keep stub effects separate from the document and workflow evidence inventories.

  • AC1: fixtures outside-git, state-not-supplied, state-directory-missing, target-evidence-absent and target-evidence-empty use the named input, each with the lint sentinel stub supplied. Outside Git emits only Not a git repository. Report BLOCKED.; the other four emit only No fix-prose workflow state was supplied. Report BLOCKED and stop.. Each exits 0 with empty stderr and no lint call log or sentinel.
  • AC2: fixture target-mismatch supplies target draft.md and evidence whose first line is other.md; expect only Workflow state belongs to other.md, not draft.md. Report BLOCKED and stop., status 0, empty stderr and no lint call log or sentinel.
  • AC3: fixture run-notes-win supplies run notes current decision and legacy notes old decision; expect the caller-notes section containing only current decision, with no legacy text.
  • AC4: fixtures run-notes-absent and run-notes-empty respectively omit the run notes file and supply a zero-byte file, each with nonempty legacy notes old decision; both emit the caller-notes section containing old decision.
  • AC5: fixture ordered-numbered-report uses the baseline document and run notes current decision; expect sections in this order: target, caller notes, numbered document, findings, silence/coverage explanation, replacement explanation. Assert both document lines with the shell's five-column numbers and two-space separator.
  • AC6: fixture partial-failing-lint uses lint that prints partial stdout to stdout and partial stderr to stderr, then exits 7; expect both lines in findings in that order, no report stderr, later sections retained and report status 0.
  • AC7: fixture silent-lint uses executed true; expect (nothing) in findings, later sections retained and report status 0. The call-log variant records exactly one successful lint invocation, distinguishing execution from an executor-start failure.
  • AC8: fixture vale-unavailable excludes Vale from the controlled search path while retaining Git, Bash and other report prerequisites; expect (vale not on PATH) once in each of the last two sections.
  • AC9: fixture bash-start-unavailable retains Git and matching evidence but removes Bash from the supported executor search path; expect exactly one executor-unavailable BLOCKED line in findings, the later sections in their normal order, report status 0 and no lint call log or sentinel. This is the new helper outcome, not shell parity.
  • AC10: fixture read-only-artifacts runs the baseline and each notes variant with true and controlled read-only Vale stubs; compare before/after path inventories, file bytes and modes for the document, workflow evidence and legacy notes. Expect no changes. Record call-log/sentinel effects only in separate invocation fixtures; supplied lint commands retain their own side effects.
  • AC11: execute this same fixture suite natively on macOS, Linux and Windows, using supported Bash, including Git for Windows Bash on Windows. Record the actual native platform and shell-oracle environment, command, status and results for each; skips and cross-compilation do not satisfy the native criterion.
  • AC12: use every row of the following fixture matrix. All rows require exact full shell/Go output equality, empty report stderr and status 0, including the stated branch outcome. A controlled Vale stub distinguishes the scope invocation from the document-count invocation, verifies its arguments and captures scope stdin to assert the shell's exact known-bad control text. Scope-only rows give the count invocation no findings/status 0; count-only rows give the scope invocation one digit-led finding/status 1.
Fixture Exact input change Required report outcome
missing-target Evidence still names draft.md, but that document is absent; supply the lint sentinel stub. Target header followed by No such file. Report BLOCKED and stop.; no later sections, call log or sentinel.
omitted-lint Supply target and state with no lint words. Header says lint: (none given); findings say No lint command given. Report BLOCKED and stop.; both probe sections still follow.
command-terminator Supply lint words printf lint-before, then --, then printf ignored. Header and executed findings contain only the pre-terminator command and lint-before; ignored never appears.
scope-error Scope Vale prints scope failure to stderr and exits 2. ERROR names exit 2, explains that neither silence nor the probe measured the document, indents the diagnostic and ends with Report BLOCKED..
scope-unscoped-0 / scope-unscoped-1 Scope Vale emits no bytes and exits 0 or 1 respectively. UNSCOPED names draft.md, explains that no styles load and a clean run proves nothing, and says Report BLOCKED..
scope-covered-0 / scope-covered-1 Scope Vale emits 1: first\n2: second\nnotice\n and exits 0 or 1 respectively. Covered reports exactly 2 findings and explains that rules are live and silence would be real.
replacements-zero-0 / replacements-zero-1 Count Vale emits finding without correction\n and exits 0 or 1 respectively. 0 of the vale findings carry a replacement. with no replacement command.
replacements-lines-0 / replacements-lines-1 Count Vale emits 1: replace_with=a replace_with=b\n2: replace_with=c\n3: no correction\n and exits 0 or 1 respectively. 2 of the vale findings carry a replacement. followed by Clear them first with: and mise run fix-prose-replacements draft.md; two matching lines count as 2 despite three tokens.
replacements-error Count Vale prints count failure to stderr and exits 2. Unknown names exit 2, explains why a zero count would be wrong, and includes the indented diagnostic; no numeric replacement claim or replacement command.

At the merged head, cite every AC ID with its command and result in PR Verification, including native execution and any skips. Required checks must pass without weakening gates. Obtain independent approval of the exact merged head and record every finding's disposition. Pass repository leak scans and review and scan each issue/PR post before any later publication. Use signed commits with Assisted-by trailers and the provenance:agent-assisted label. Match documentation to behavior. Measure the final diff against the Size caps. File any follow-ups as issues and list them under Related in the PR. Close this issue through the merge, set its board Status to Done, and post a final Status: comment naming the merge commit and closing reference. This draft authorizes no publication.

Risks

Changing notes precedence can revive an old instruction, and altered replacement counts can promise nonexistent fixes. Undo: revert this additive command; the original context and its evidence remain.

Operator authority

None

Activity

  1. tbhb-agent commented on Oct 27, 2026

    @tbhb-agent
    ContributorAuthor

    Refinement: READY — Gather the prose writer's context in Go
    Model: gpt-6-astra

    Child 05 Gather the prose writer's context in Go

    Verdict: READY

    Checked: The round 1 gap is closed. AC6 consumes 04’s executor contract, distinguishes startup failure from empty command output, and specifies continuation into later sections. Verification includes actual supported-Bash execution with quoting and operators on every platform. Notes precedence, command assembly and probe reporting remain consistent with packages/agents/source/skills/write-prose-fix/shared/scripts/context.sh:36, packages/agents/source/skills/write-prose-fix/shared/scripts/context.sh:68 and packages/agents/source/skills/write-prose-fix/shared/scripts/context.sh:90. The 550-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 — Report outcomes and verification now cover the prior gaps

    Checked

    Gaps

    None.

    Split

    None required; the report and its fixtures fit the stated one-PR size limits.

    Definition of done

    Planning coverage only: checkmarks mean the draft’s ACs and Verify plan cover the item, not that work is complete.

    • D1 Verify every AC on the merged head and cite each AC’s command and result in PR Verification. Evidence: body-890-d1-20261031.md:73 requires merged-head verification with each AC ID, command, and result.
    • D2 Obtain independent review of the exact head and record each finding’s disposition. Evidence: body-890-d1-20261031.md:73 specifies both.
    • D3 Pass required checks without weakening gates. Evidence: body-890-d1-20261031.md:73 requires passing checks without weakening gates.
    • D4 Pass repository leak scans and review each post. Evidence: body-890-d1-20261031.md:73 requires repository leak scans and review of each issue/PR post.
    • D5 Sign every commit. Evidence: body-890-d1-20261031.md:73 requires signed commits.
    • D6 Match documentation to behavior. Evidence: body-890-d1-20261031.md:73 requires documentation to match behavior.
    • D7 Include Assisted-by trailers and the provenance:agent-assisted label. Evidence: body-890-d1-20261031.md:73 names both.
    • D8 Stay within PR size limits. Evidence: body-890-d1-20261031.md:40 sets code and prose caps; :73 requires measuring the final diff.
    • D9 File follow-ups and list them under Related. Evidence: body-890-d1-20261031.md:73 requires filing follow-ups as issues and listing them under Related.
    • D10 Close the issue, set the board to Done, and post a Status: comment naming the merge commit. Evidence: body-890-d1-20261031.md:73 specifies all three.

    Round: 2 of 3

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
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions