Skip to content

test: raise coverage on the governance, durable and config crates - #379

Merged
github-actions[bot] merged 3 commits into
mainfrom
test/coverage-raise
Aug 17, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
test/coverage-raise

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Adds 53 tests across three crates. Tests only — no production code changed.

Coverage was chosen by risk, not by chasing a percentage: cargo llvm-cov was deliberately not run (an instrumented build needs a second target dir and had previously exhausted the disk on this machine), so targets were picked by reading source.

What's covered

forge-governance/src/readonly.rs: 4 → 21 tests. The bulk of the work, and the highest-value target — ~780 lines of hand-rolled shell tokenizing and argv parsing that decides whether a model's shell call bypasses the human-in-the-loop approval gate, previously exercised by 4 tests. New cases are weighted at the reject paths: command substitution ($(...), backticks, ${...}) bare and double-quoted; control operators and redirects (;, newline/CRLF, &, >, >>, <, <(...)); pipe-to-non-limiter (| sh, | xargs rm, | tee); unbalanced quotes and dangling operators; quoted separators staying literal; wrapper commands (sudo/env/VAR=x) not being unwrapped; flag-table smuggling for ls, grep/rg, find/fd (-exec/-delete), cat, head/tail; and git subcommand/global-option handling.

forge-governance/src/acl.rs: 2 → 8 tests. Last-matching-rule-wins in both orders, non-matching rules not resetting state, and the mcp:* prefix wildcard — an ordering bug here would silently widen permissions.

forge-durable/src/lib.rs: 17 → 24 tests. All four latest_session_id() branches (previously untested entirely), ContextCompacted replay including partial/malformed payloads, and ModelRequest replay of prompt_wire_sha256 / cache_epoch / cache_transport.

forge-config/src/trust.rs: 5 → 17 and permissions.rs: 8 → 19. Trust store corruption failing closed, symlink resolution, theme-key preservation; permission scope-merge ordering, diagnostics, and round-trips. All hermetic — TempDir with explicit-path *_at() APIs, no dependence on the developer's real config.

Findings — pinned by tests, not fixed

No security bug was found. The read-only gate held under every bypass attempt constructed above; all end in either None (normal HITL path) or Redirect.

Two things worth a look, both deliberately left as-is:

  1. git branch --set-upstream-to=…, --unset-upstream and --edit-description classify as read-only. branch_is_readonly only screens the delete/rename/force family, and these are dash-leading so they pass the "no bare operand" check. Not exploitable — the rewrite targets the dedicated git tool, which is SideEffectClass::Write and re-validates every option against its own allowlist. But readonly.rs is labelling a config-mutating command as a read, one layer above a security boundary. See git_branch_upstream_flags_are_deferred_to_the_git_tool.
  2. append_allow_rule silently discards an unparseable existing permissions file (parse_permissions_toml(...).unwrap_or_default()), so a hand-edited-and-broken personal file loses its deny entries the next time the user picks "always allow". It fails toward an empty ruleset rather than a wider one, so it is safe — but it is lossy with no diagnostic. See append_allow_rule_discards_an_unparseable_existing_file.

Verification

cargo fmt --all -- --check clean, cargo clippy --all-targets clean, and forge-config (89), forge-governance (84), forge-durable (24) all green after rebasing onto 61621c5.

cargo test --workspace was also run. One run surfaced two failures — forge-connect::catalog::tests::refresh_models_dev_registry_uses_override_url and forge-tui::app::tests::workspace::files_visibility_persists_per_repository — which were investigated and found to be pre-existing flakes unrelated to this branch: both pass in isolation, a second full workspace run on this branch was clean, and there is no mechanism linking them to the added tests (the new forge-config tests are hermetic, and the forge-connect flake is an intra-binary EnvGuard race on process-global env vars that another test binary cannot influence). Flagging them as worth fixing separately.

@github-actions
github-actions Bot enabled auto-merge (squash) August 17, 2026 01:39
@github-actions
github-actions Bot merged commit f3a624b into main Aug 17, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
* test(governance): cover readonly shell classification and ACL ordering

* test(durable): cover latest_session_id, compaction replay, and cache-epoch metadata

* test(config): cover trust store edge cases and permission scope merging
mohitranka added a commit that referenced this pull request Sep 11, 2026
* test(governance): cover readonly shell classification and ACL ordering

* test(durable): cover latest_session_id, compaction replay, and cache-epoch metadata

* test(config): cover trust store edge cases and permission scope merging
mohitranka added a commit that referenced this pull request Sep 11, 2026
* test(governance): cover readonly shell classification and ACL ordering

* test(durable): cover latest_session_id, compaction replay, and cache-epoch metadata

* test(config): cover trust store edge cases and permission scope merging
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