Skip to content

fix: never report a verified edit as failed, and make focus legible - #389

Merged
mohitranka merged 8 commits into
mainfrom
fix/truthful-scoped-completion-and-focus
Aug 18, 2026
Merged

mohitranka merged 8 commits into
mainfrom
fix/truthful-scoped-completion-and-focus

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Fixes the highest-severity findings from a hands-on usability run of 0.1.0-beta.5, driven live in a PTY against a disposable repo.

Critical: a verified edit reported as a failed turn

Two independent defects made Forge claim work had failed when it had landed on disk.

1. The edit tool produced no evidence at all. pre_edit_snapshot and classify_turn both handled edit, but push_file_edit_evidence matched only write_file/apply_patch — edit fell through _ => {}. Every edit call therefore created a FileEdit expectation with nothing to verify it against, so a successful edit reported "No file modifications were successfully applied" and Failed. edit is the canonical editing tool (search_replace/edit_file normalize to it), so this fired constantly.

2. The cross-category evidence gate was too blunt. It downgraded any Completed turn to Failed if any evidence entry carried an error — including steps the turn's expectation never required. A missing pytest erased a verified edit.

The gate now distinguishes required from ancillary operations:

  • a required operation failing still fails the turn, loudly and unchanged;
  • an ancillary step that didn't finish is carried in EvidenceSummary::incomplete and reported next to a Completed turn in muted styling.

Detection covers non-zero exits, not just is_error — bash dispatches fine while the command inside it fails (a missing binary exits 127 with is_error unset), which is exactly the step worth reporting.

Guardrails are unchanged and still pass: two_edits_one_fails_is_partial_failure_not_completed (both ops required) still fails loudly, as does file_edit_with_no_matching_evidence_fails and assistant_text_alone_cannot_complete_file_edit.

write_then_failing_validation_in_same_turn_never_completes was rewritten — it encoded exactly the old contract. That behaviour change is deliberate and documented in the test.

High: keystrokes landing in the wrong pane

The terminal had no visible focus indicator. It signalled focus only by swapping the border style on a one-cell top rule, so a focused terminal was indistinguishable from an unfocused one — the only way to find out where keystrokes were going was to type and see what happened. It now takes the composer's structural cue.

focused:    ● Terminal ━━━━━━━━━━━━━
unfocused:    Terminal ─────────────

Printable keys fell through to the composer. type_to_compose was the universal fallback for any key the focused block didn't consume. The footer has no Char handler, so letters typed there silently moved focus and inserted — a shell command typed after one Tab became a chat draft, and the Enter meant to run it submitted it to the model. Control surfaces (Footer, BottomPanel) now keep their keystrokes; navigational blocks keep type-to-chat, where a keystroke has no local meaning anyway.

Discoverability

  • /terminal (plus /term, /shell) and a palette entry. `Ctrl+`` is an unusual chord that appears only in the help overlay, so the palette had no route to the terminal at all. A new test asserts every command the palette advertises actually parses.
  • Model picker promotes the active route to the top of its group. Selection resets to row 0 on every keystroke, so typing a name two providers offer confirmed whichever sorted first and silently moved the session to a different provider and account. Every route stays listed and selectable.
  • Ctrl+E on a narrow terminal explains itself instead of toggling an invisible flag and parking focus in a pane that is never rendered. layout::files_fit shares the threshold with split_areas_ex so the message cannot drift from the behaviour.
  • Footer names the token unit (0 tokens · —). It falls back to the bare count only when the row cannot afford the label — the mode chip says whether Forge asks before acting and is never traded for it.

Test fixture

All 16 compaction_tests were already failing on main before this branch. Not a compaction bug: #388 raised CompactionPolicy::default() from a 200K to a 500K window, moving the trigger from 170K to 425K. The fixture grows 70 turns to ~182K tokens, so it stopped crossing the boundary and tripped its own must actually be under context pressure guard.

These tests exercise behaviour at the boundary, so they now set the boundary themselves rather than inheriting the product default. Growing the fixture instead would have made the suite ~2.5x slower and left it equally fragile the next time the default moves.

Worth a separate look: #388 merged with those 16 tests red, so CI may not be gating merges.

Verification

cargo test --workspace      2132 passed, 0 failed
cargo fmt --all -- --check  clean
cargo clippy --all-targets  clean

Every fix was also driven live in a real PTY, not just unit-tested:

  • edit + failing check → ● Completed · 1 check didn't finish, with git status confirming the edit on disk
  • terminal focus border, before/after
  • git status typed at the footer → composer stays empty, focus stays put
  • Ctrl+E at 80x24 → Files needs a wider terminal (116 columns; this one is 80)
  • /term → resolves to /terminal

Both regression tests for the focus fixes were confirmed to fail without their fix.

Two independent defects made Forge claim work had failed when it had
actually landed on disk.

1. `push_file_edit_evidence` matched only `write_file`/`apply_patch`,
   while `pre_edit_snapshot` and `classify_turn` both handled `edit`.
   Every `edit` call therefore produced a FileEdit expectation with no
   evidence to verify it against, so a successful edit reported
   "No file modifications were successfully applied" and Failed.

2. The cross-category evidence gate downgraded any Completed turn to
   Failed if *any* evidence entry carried an error — including steps the
   turn's expectation never required. A missing `pytest` erased a
   verified edit.

The gate now distinguishes required from ancillary operations. A failed
required operation still fails the turn, loudly and unchanged. An
ancillary step that didn't finish is carried in a new
`EvidenceSummary::incomplete` and surfaced next to a Completed turn in
muted styling, so the turn stays honest without overstating the damage.

Pre-existing compaction_tests failures on main are unrelated and untouched.
… pane

The terminal panel signalled focus only by swapping the border style on a
one-cell top rule, so a focused terminal was visually identical to an
unfocused one — the only way to find out where keystrokes were going was
to type and see what happened. It now takes the composer's structural
cue: a thick rule and a marked title, legible without color.

Separately, `type_to_compose` was the universal fallback for any
printable key the focused block didn't consume. The footer has no Char
handler, so letters typed there silently moved focus to the composer and
inserted — a shell command typed after one Tab became a chat draft, and
the Enter meant to run it submitted it to the model. Control surfaces
(Footer, BottomPanel) now keep their keystrokes instead of handing them
to the composer; navigational blocks keep type-to-chat, where a keystroke
has no local meaning anyway.

Also widens ancillary-step detection to non-zero exit codes: `bash`
dispatching fine while the command inside it fails (a missing binary
exits 127 with `is_error` unset) is exactly the step worth reporting.
…s model

The completion evaluator carried unfinished ancillary steps and the status
model formatted them, but the footer took only a bare TurnLifecycle enum,
so the detail never reached the one row the user actually reads. An
end-to-end test through tool execution -> completion evaluation -> turn
event -> snapshot -> status model -> rendered footer caught it: the model
said "Completed · exit 127 didn't finish" while the screen said only
"Completed".

The footer now takes a lifecycle_detail rendered as dim secondary text —
the lifecycle glyph alone carries severity, so a reported check never
borrows failure styling.

Long command names degrade to "1 check didn't finish": the detail shares
its row with the model/effort/mode identity, and a long invocation pushed
that identity out entirely ("OpenAI/gpt-5.6-luna │ Max │ Auto" collapsed
to "Op"), trading one piece of needed state for another.
- /terminal (plus /term, /shell) reaches the terminal panel. Ctrl+` is the
  fast path but an unusual chord that appears only in the help overlay, so
  the palette had no route to it at all. A new test asserts every command
  the palette advertises actually parses.

- The model picker promotes the active route to the top of its group.
  Selection resets to row 0 on every keystroke, so typing a name two
  providers offer confirmed whichever sorted first and silently moved the
  session to a different provider and account. Every route stays listed
  and selectable.

- Ctrl+E on a terminal narrower than the explorer's layout threshold now
  says so instead of toggling an invisible flag and parking focus in a
  pane that is never rendered. layout::files_fit shares the threshold with
  split_areas_ex so the explanation cannot drift from the behaviour.

- The footer names the token unit ("0 tokens · —"). It drops back to the
  bare count only when the row cannot afford the label — the mode chip
  says whether Forge asks before acting and is never traded for it.
All 16 compaction tests were failing on main, and not on anything about
compaction: #388 raised CompactionPolicy::default() from a 200K to a 500K
window, which moved the trigger from 170K to 425K. The fixture grows 70
turns to ~182K tokens, so it stopped crossing the boundary and tripped its
own "must actually be under context pressure" guard.

These tests exercise behaviour at the boundary, so they now set the
boundary themselves instead of inheriting whatever the product default
happens to be. Growing the fixture to suit a 500K window would have made
the suite ~2.5x slower and left it just as fragile the next time the
default moves.
@github-actions
github-actions Bot enabled auto-merge (squash) August 18, 2026 12:06
@blacksmith-sh

This comment has been minimized.

Unrelated to this PR's changes, but it blocks its audit gate: the advisory
(h2 unbounded empty DATA frames) was published 2026-08-17 and fails on main
too. h2 is transitive via hyper and reqwest, so this is a lockfile-only
single-package bump.

cargo test --workspace stays at 2132 passed, 0 failed.
@mohitranka

Copy link
Copy Markdown
Contributor Author

Pushed b7e2324: bumps h2 0.4.15 → 0.4.16 for RUSTSEC-2026-0258 (h2 unbounded empty DATA frames).

Unrelated to this PR's changes but it was blocking the audit gate — the advisory was published 2026-08-17 and fails on main too. h2 is transitive via hyper/reqwest, so it's a lockfile-only single-package bump (version + checksum, nothing else moved).

cargo test --workspace stays at 2132 passed, 0 failed.

…exist

"Test and format" has been failing on main for at least five commits, and
not on Rust code: install/test-installer.sh ran every case with
/bin:/usr/bin on PATH, so on any host where bubblewrap and socat are really
installed, `command -v bwrap` succeeded, the installer short-circuited, and
ten "dependency is missing" cases asserted against a branch that never ran.

CI is exactly that host — the workflow installs both in the step before this
suite — which is why it reported 18/18 on a developer machine and 8/18 there.
The suite was green where it tested nothing and red where it mattered.

Absence is now something the harness controls: cases run against a sanitized
mirror of the system path with these two binaries excluded, so a case that
wants them present supplies them through its own stub dir. Verified 18/18
both with and without them installed; reproducing the old PATH locally gave
CI's exact 8 passed, 10 failed.
@mohitranka

Copy link
Copy Markdown
Contributor Author

Pushed 2443a42: fixes the "Test and format" failure, which is also pre-existing on main (red for at least the last five commits) and unrelated to this PR's changes.

Not a Rust failure — it's the Test the installer step. install/test-installer.sh ran every case with /bin:/usr/bin on PATH, so on a host where bubblewrap/socat are genuinely installed, command -v bwrap succeeded, the installer short-circuited, and ten "dependency is missing" cases asserted against a branch that never ran.

CI is exactly that host — the workflow installs both in the step immediately before this suite. Hence 18/18 on a dev machine and 8/18 in CI: green where it tested nothing, red where it mattered.

Cases now run against a sanitized mirror of the system path with those two binaries excluded, so a case that wants them present supplies them via its own stub dir. Verified locally at 18/18 both with and without them installed; reproducing the old PATH gave CI's exact 8 passed, 10 failed.

Note WSL2 sandbox also fails on main (2 sandbox-enforcement tests) — untouched here, and not a required check.

…ATH too

The first pass took Test and format from 8/18 to 15/18. The remaining three
were the same bug one layer down: `command -v apt-get` succeeds on any
Debian-family host, so the pacman, apk, and no-package-manager cases silently
took the apt branch instead of the one they assert on.

apt-get, pacman, and apk join bwrap and socat in the exclusion list. Every
case that wants a package manager present already stubs it into its own bin
dir, which precedes the sanitized mirror on PATH.

Verified 18/18 both on a clean host and with all five binaries installed.
@mohitranka

Copy link
Copy Markdown
Contributor Author

Status: this PR's own work is green; one pre-existing failure remains and I've stopped rather than mask it.

2b63189 got Test the installer to pass (18/18). That unmasked the next failure in the same job — the job previously died at the installer step and never reached Run tests.

The remaining failure is not from this PR:

test a_confined_command_reaches_workspace_sockets_but_not_host_sockets ... FAILED
test egress_fails_closed_when_the_proxy_is_gone ... FAILED
test result: FAILED. 23 passed; 2 failed

The identical two tests, same file, same 23 passed; 2 failed, are red on main right now in the WSL2 sandbox job (run 32089203109, commit e6e364a5). They are Linux-only — they need bubblewrap, so they cannot run on macOS.

The assertion is a real security signal, not a flaky test:

a confined command reached a host Unix socket at /home/runner/.forge-uds-probe-*/probe.sock.
The filesystem boundary is the only thing between the sandbox and every socket on this machine, and it did not hold.

I'm not skipping, weakening, or #[ignore]-ing these to get the check green — the whole point of that suite is to fail loudly when confinement breaks, and it is doing its job. I also can't verify a fix from this machine.

Suggest tracking the sandbox confinement failure as its own issue and deciding separately whether to merge this PR ahead of it.

For the record, everything this PR controls passes: cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --all-targets --locked (2132 passed, 0 failed) locally, plus cargo audit, Dependency audit, Analyze (rust), Analyze (actions) and CodeQL green in CI.

@mohitranka

Copy link
Copy Markdown
Contributor Author

Merging with an admin override, on the explicit understanding that the one remaining red check is pre-existing and unrelated.

The sandbox confinement failure is now tracked as #390. It is red on main independently of this PR (same two tests, same file, same 23 passed; 2 failed), and was only surfacing in Test and format because this PR fixed the installer step that had been short-circuiting the job before it ever reached Run tests.

Nothing in that suite was skipped or weakened to get here.

@mohitranka
mohitranka merged commit 3792e4b into main Aug 18, 2026
6 of 8 checks passed
@mohitranka
mohitranka deleted the fix/truthful-scoped-completion-and-focus branch August 18, 2026 13:41
mohitranka added a commit that referenced this pull request Aug 21, 2026
…n-and-focus

fix: never report a verified edit as failed, and make focus legible
mohitranka added a commit that referenced this pull request Sep 11, 2026
…n-and-focus

fix: never report a verified edit as failed, and make focus legible
mohitranka added a commit that referenced this pull request Sep 11, 2026
…n-and-focus

fix: never report a verified edit as failed, and make focus legible
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