Skip to content

test(context-gateway): pin Commands sync 409 mtime-conflict path (closes #772)#777

Merged
memtomem merged 1 commit intomainfrom
fix/issue-772-commands-409-test
May 4, 2026
Merged

test(context-gateway): pin Commands sync 409 mtime-conflict path (closes #772)#777
memtomem merged 1 commit intomainfrom
fix/issue-772-commands-409-test

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented May 4, 2026

Summary

  • Closes test: backfill 409 conflict-path fixture for Phase B (Commands) sync route #772 — backfill HTTP 409 conflict-path fixture for Phase B (Commands) sync route.
  • Mirrors TestUpdateSkill.test_mtime_conflict (tests/test_web_routes_context.py:222-231) for Commands, satisfying ADR-0001 §5 c4 (docs/adr/0001-context-gateway-sync-policies.md §5 c4).
  • The 409 path itself (packages/memtomem/src/memtomem/web/routes/context_commands.py:241-250) already exists in production — this is purely test-coverage backfill. No production code changes.

What §5 c4 actually requires

§5 c4 pins conflict semantics, not just the response label. A pure
status_code == 409 + status == "aborted" assertion would still pass a
regression that wrote body.content and then returned the abort envelope.

This PR adds two assertions on the conflict path:

  1. r.status_code == 409 and data["status"] == "aborted" — pins the soft-abort response shape (verbatim parity with Skills).
  2. cmd_file.read_text() == _CMD_CONTENT — pins the no-write semantics that §5 c4 actually targets.

Mutation validation

Before commit, I verified the new test is regression-tight by mutating
context_commands.py:241-250 to perform atomic_write_text before the
mtime-guard. The status-code assertion still passed (409 was still
returned), but the content assertion failed — confirming the test catches
the very class of regression §5 c4 is designed to prevent. The mutation
was reverted before the commit.

Sibling-test parity observation (not in scope)

The Skills counterpart at test_web_routes_context.py:222-231 only
asserts the response label, not the no-write semantics. That's a
hygiene gap of the same shape as #772 but for Phase A (Skills); it is
not a regression of any current behavior and is out of scope here.
Worth tracking as a follow-up if the team wants strict parity across
all three phases.

Test plan

  • uv run pytest -m "not ollama" packages/memtomem/tests/test_web_routes_context.py — 57/57 green
  • uv run ruff check packages/memtomem/tests/test_web_routes_context.py
  • uv run ruff format --check packages/memtomem/tests/test_web_routes_context.py
  • Mutation test (write-before-guard) → assertion fail confirmed → mutation reverted

Refs: #772, #761 (parent RFC), #769 (ADR §5)

🤖 Generated with Claude Code

ADR-0001 §5 c4 requires Phase B (Commands) to have an HTTP-layer fixture
that pins the conflict path on the canonical PUT route. Phase B shipped
before §5 was authored (RFC #761 / ADR landed in #769) and only had the
happy-path CRUD test — a future regression that wrote body.content and
then returned the 409 envelope would have gone undetected.

Mirror ``TestUpdateSkill.test_mtime_conflict`` for Commands: PUT with a
stale mtime_ns sentinel ("0"), assert 409 + status == "aborted", and
**also** assert the canonical file's bytes are unchanged. The content
assertion is what actually pins ADR §5 c4's no-write semantics; status
labeling alone is satisfied even when the guard runs after the write.

The 409 path itself (context_commands.py:241-250) already exists in
production code — this is purely test-coverage backfill.

Verified: mutation-tested by moving ``atomic_write_text`` above the guard;
test failed on the content assertion as expected. Reverted before commit.

Refs: #772, #761 (parent RFC), #769 (ADR §5)

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit 008de2c into main May 4, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: backfill 409 conflict-path fixture for Phase B (Commands) sync route

2 participants