Skip to content

Add direct tests for the write-gate refusal branches (edit_lines_impl_gated / edit_symbol_flow) #63

Description

@Eilodon

Finding §2.2 from the 2026-08-07 open-work review (docs/plans/2026-08-07-audit-findings-recovery-and-open-work-execution-plan.md).

test_gap_hotspots ranks these #1/#2 by structural centrality with no direct test (test_files: []):

  • crates/calm-server/src/tools/edit.rs::edit_lines_impl_gated (coreness 7)
  • crates/calm-server/src/tools/edit.rs::edit_symbol_flow (coreness 7)
  • crates/calm-server/src/tools/common.rs::make_state_read_conn (coreness 6, the new 0.6.0 state.db read path)

The only integration test in this area (crates/calm-server/tests/watcher_integration.rs) simulates the write+reindex sequence — it does not exercise the gate's refusal branches (EDIT_CONTEXT_REQUIRED, REASON_NOT_GROUNDED, confirm-required on hub/high-risk). Those are the security-relevant paths of CALM's central write-safety mechanism, and they are its least directly-tested code.

Scope

Add focused tests driving each refusal branch through the public edit_lines/edit_symbol entry points. The WS-1 enforce-transition suite (0.5.0) likely covers the happy path already (dead_code_confidence: none), so scope the new tests to the refusal branches specifically — confirm before duplicating happy-path coverage.

Bounded, no core change, high safety value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions