Repository navigation
test: raise coverage on the governance, durable and config crates - #379
Merged
Merged
Conversation
This was referenced Aug 17, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds 53 tests across three crates. Tests only — no production code changed.
Coverage was chosen by risk, not by chasing a percentage:
cargo llvm-covwas 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 forls,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 themcp:*prefix wildcard — an ordering bug here would silently widen permissions.forge-durable/src/lib.rs: 17 → 24 tests. All fourlatest_session_id()branches (previously untested entirely),ContextCompactedreplay including partial/malformed payloads, andModelRequestreplay ofprompt_wire_sha256/cache_epoch/cache_transport.forge-config/src/trust.rs: 5 → 17 andpermissions.rs: 8 → 19. Trust store corruption failing closed, symlink resolution, theme-key preservation; permission scope-merge ordering, diagnostics, and round-trips. All hermetic —TempDirwith 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) orRedirect.Two things worth a look, both deliberately left as-is:
git branch --set-upstream-to=…,--unset-upstreamand--edit-descriptionclassify as read-only.branch_is_readonlyonly 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 dedicatedgittool, which isSideEffectClass::Writeand re-validates every option against its own allowlist. Butreadonly.rsis labelling a config-mutating command as a read, one layer above a security boundary. Seegit_branch_upstream_flags_are_deferred_to_the_git_tool.append_allow_rulesilently discards an unparseable existing permissions file (parse_permissions_toml(...).unwrap_or_default()), so a hand-edited-and-broken personal file loses itsdenyentries 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. Seeappend_allow_rule_discards_an_unparseable_existing_file.Verification
cargo fmt --all -- --checkclean,cargo clippy --all-targetsclean, andforge-config(89),forge-governance(84),forge-durable(24) all green after rebasing onto61621c5.cargo test --workspacewas also run. One run surfaced two failures —forge-connect::catalog::tests::refresh_models_dev_registry_uses_override_urlandforge-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 newforge-configtests are hermetic, and theforge-connectflake is an intra-binaryEnvGuardrace on process-global env vars that another test binary cannot influence). Flagging them as worth fixing separately.