Skip to content

fix: runner correctness bugs, cleanup, tests, and architecture docs - #25

Merged
TerrorSquad merged 4 commits into
mainfrom
fix/runner-bugs-and-cleanup
Jul 17, 2026
Merged

fix: runner correctness bugs, cleanup, tests, and architecture docs#25
TerrorSquad merged 4 commits into
mainfrom
fix/runner-bugs-and-cleanup

Conversation

@TerrorSquad

Copy link
Copy Markdown
Owner

Follow-up to the docs work: an actual code + test review of the runner, with fixes.

Bugs fixed

  • pre-push silently ignored run flags. RunHookWithOptions passed an empty RunOptions{} down the pre-push path, so forge run pre-push --tool/--skip-tool/--group/--check/--no-cache/--verbose all did nothing. Opts are now threaded through. (regression test added)
  • stage_outputs staged files from failed tools. Both the sequential and parallel runners git added stage_outputs regardless of tool exit status — unlike restage, which already guards on success. Now both stage only on success. (regression test added)

Cleanup

  • parseAllowedGroups replaced a bufio.Scanner + custom split func with a one-line strings.Split.
  • Removed the dead when tool field (decoded but read nowhere; the strict decoder was accepting a no-op key).

Tests

  • New review_fixes_test.go covering the two fixes and HOOKS_ONLY parsing.
  • Runner package coverage 58% → 62%.

Docs

  • docs/architecture.md: request-pipeline Mermaid diagram + package map + key invariants.
  • Documented the previously-undocumented .git-hooks.env / .env auto-loading.

Verification

  • go build, go vet, gofmt -l clean; full go test ./... passes.

🤖 Generated with Claude Code

TerrorSquad and others added 3 commits July 17, 2026 22:02
Two correctness fixes found in review:

- The pre-push path passed an empty RunOptions{} to runHookCfg, silently
  ignoring --tool/--skip-tool/--group/--check/--no-cache/--verbose on
  `forge run pre-push`. Thread the caller's opts through.
- stage_outputs were `git add`ed even when the tool failed, unlike restage
  which already guards on success. Both runners now stage only on success.

Adds regression tests for both.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- parseAllowedGroups used a bufio.Scanner with a custom split function to
  do what strings.Split does in one line.
- The tool `when` field was decoded but never read anywhere; remove it so
  the strict decoder no longer accepts a no-op key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- docs/architecture.md: request-pipeline Mermaid diagram + package map
- document the .git-hooks.env / .env auto-loading behavior (was undocumented)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@TerrorSquad TerrorSquad left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of the diff. Fixes verified correct (pre-push now threads opts; both runners guard stage_outputs on err == nil, matching restage). One consistency gap from the when removal:

Embedded JSON schema still declares when (internal/forge/schema/forge.schema.json:161)

The struct field is gone and the strict decoder now rejects when, but the schema still advertises it — and describes it as functional ("Conditional expression controlling when this tool runs"), which it never was. An editor using the schema would suggest a key that fails forge validate. Removing it from the schema too.

Everything else checks out: --all-files is still rejected for non-pre-commit before opts are threaded, parseAllowedGroups behavior is preserved (test added), and the full suite passes.

The struct field was removed; the embedded JSON schema still advertised
`when` (as a functional field it never was). Drop it so editor
autocomplete can't suggest a key that fails validation. Addresses review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TerrorSquad
TerrorSquad merged commit 8bed5cf into main Jul 17, 2026
1 check passed
@TerrorSquad
TerrorSquad deleted the fix/runner-bugs-and-cleanup branch July 17, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant