Skip to content

test(commands): assert mtime_ns echo on three-phase parity (closes #780)#781

Merged
memtomem merged 1 commit intomainfrom
test/commands-mtime-conflict-echo-780
May 4, 2026
Merged

test(commands): assert mtime_ns echo on three-phase parity (closes #780)#781
memtomem merged 1 commit intomainfrom
test/commands-mtime-conflict-echo-780

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented May 4, 2026

Summary

Closes #780. Adds the one-line mtime_ns echo assertion to
TestCommandCRUD.test_mtime_conflict so all three phases of the
context-gateway 409-conflict tests assert the retry-hint contract
identically.

Phase status: "aborted" no-write content mtime_ns echo
A Skills (test_web_routes_context.py:224) ✓ (#779)
B Commands (test_web_routes_context.py:585) this PR
C Agents (test_web_routes_context.py:793)

The 409 envelope already returns the echo correctly from
context_commands.py:248; the test was just under-asserting.

Why this isn't an ADR §5 c4 fix

§5 c4 pins the soft-abort label + no-write guarantee — both already
covered for Phase B by PR #777. The mtime_ns echo is the
retry-hint contract from context_commands.py:241-250, not §5 c4.
This is hygiene/parity, not a regression of any ADR requirement.
PR #779 explicitly called this out as a "file separately if the team
wants strict three-phase echo parity" follow-up.

Mutation-validation

Mirrored PR #779's pattern. Temporarily changed
context_commands.py:248 from:

"mtime_ns": str(current_mtime_ns),

to:

"mtime_ns": "0",

Result:

>       assert data["mtime_ns"] == str(cmd_file.stat().st_mtime_ns)
E       AssertionError: assert '0' == '1777930477924060002'

The new assertion fails as expected. The preceding 409 and
status == "aborted" assertions still pass — confirming the new line
is what catches a dropped/wrong echo, not the existing assertions.
Reverted; git diff on context_commands.py is empty.

Test plan

  • uv run pytest -m "not ollama" packages/memtomem/tests/test_web_routes_context.py — 58 passed.
  • uv run ruff check packages/memtomem/tests/test_web_routes_context.py — clean.
  • uv run ruff format --check packages/memtomem/tests/test_web_routes_context.py — clean.
  • Mutation-validation: new assertion fails on mutated production
    code; existing assertions still pass; revert is clean.

Refs: #779 (Phase A tightening, where this was filed as a follow-up),
#777 (Phase B no-write pin), #761 (parent RFC), #769 (ADR §5).

🤖 Generated with Claude Code

PR #777 (closes #772) and PR #779 (closes #778) tightened §5 c4 across
all three phases of context-gateway 409-conflict tests. mtime_ns echo
parity, however, was asymmetric: Phases A (Skills) and C (Agents) both
asserted `data["mtime_ns"] == str(<file>.stat().st_mtime_ns)`, while
Phase B (Commands) did not. The 409 envelope already returns the
correct echo from `context_commands.py:248`; the test was just under-
asserting.

This adds the matching one-line assertion to
`TestCommandCRUD.test_mtime_conflict`, mirroring the Skills/Agents
shape so a future regression that drops the echo for Commands fails
fast.

Note: the echo is the retry-hint contract, not §5 c4 itself (which
pins the soft-abort label and no-write guarantee — both already
covered for Phase B by PR #777). This is hygiene/parity, not a
regression of any ADR requirement.

Mutation-validation: temporarily mutated
`context_commands.py:248` from `str(current_mtime_ns)` to `"0"`. The
new echo assertion fails (`'0' == '1777930477924060002'`); the
preceding 409 / `status == "aborted"` assertions still pass. Revert
clean (`git diff` on the production file is empty).

- `uv run pytest -m "not ollama" packages/memtomem/tests/test_web_routes_context.py` — 58 passed.
- `uv run ruff check` + `ruff format --check` on the test file — clean.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit ecc961c into main May 4, 2026
11 checks passed
@memtomem memtomem deleted the test/commands-mtime-conflict-echo-780 branch May 4, 2026 21:41
@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(commands): add mtime_ns echo assertion to TestCommandCRUD.test_mtime_conflict for three-phase parity

2 participants