Skip to content

fix: repair two master-red root causes — origin-vocab v3 latch, clock-guard isinstance - #3500

Merged
Sinity merged 2 commits into
masterfrom
fix/material-protocol/origin-vocab-v3
Aug 1, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/material-protocol/origin-vocab-v3

Conversation

@Sinity

@Sinity Sinity commented Aug 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Two independent full-suite-red root causes on master, both invisible to per-PR CI's heavy-test skip: the material-protocol origin-vocabulary drift latch (tripped by #3422 adding claude-design-session) and the clock guard's datetime replacement breaking isinstance in guarded test modules. Together they account for ~50 of the 128 failures in a devtools verify --all run on master.

Problem

  1. PR feat(sources): model Claude Design as a distinct origin, parse memories.json #3422 (2026-07-31 10:23) added claude-design-session to core.enums.Origin without bumping CURRENT_ORIGIN_VOCABULARY_VERSION — resolve_current_origin_vocabulary()'s deliberate drift latch asserts on every encode, failing all 22 material-protocol tests and downstream encoders.
  2. The clock guard installs a raising datetime subclass into guarded modules; isinstance(production_datetime, datetime) there became an always-false subclass check, failing 20+ tests (test_models timestamp parsing, timestamp guards, null-guard properties).

Solution

  • origin_vocab.py: version 2→3, frozen digest computed via the module's own documented command, v3 provenance comment; checked-in small-session fixture regenerated via write_revision (segment bytes identical, only manifest vocabulary fields changed).
  • clock_guard.py: GuardedDateTime gains a metaclass (_DelegatingInstanceCheck(type)) whose __instancecheck__ delegates to real datetime — clock reads still raise; type identity restored.

Verification

  • devtools test tests/unit/material_protocol/v1/ — 43 passed (was 22 failed)
  • devtools test tests/unit/sources/test_models.py tests/unit/core/test_timestamp_guards.py tests/unit/sources/test_null_guard_properties.py tests/unit/infra/test_clock_guard.py — 405 passed (test_models was 11 failed)
  • mypy --strict on both changed files — clean
  • Re-run of a 44-file failed set from a full-suite run: 128 → 78 failures; residual is a third class (Origin-list snapshot pins + a storage-cluster batch), tracked separately.

Co-Authored-By: Claude [email protected]

Summary by CodeRabbit

  • New Features

    • Added support for the updated origin vocabulary, including distinct claude-design-session origins.
    • Updated session metadata to use the latest vocabulary version and verification information.
  • Bug Fixes

    • Improved date/time validation behavior while preserving compatibility with standard datetime values.

Sinity and others added 2 commits August 1, 2026 01:27
…n-session

Problem: PR #3422 added claude-design-session to core.enums.Origin without
bumping CURRENT_ORIGIN_VOCABULARY_VERSION, tripping origin_vocab.py's
drift latch — resolve_current_origin_vocabulary() asserts on every encode,
failing 22+ material-protocol tests (and every downstream test that
encodes a revision) on master since 2026-07-31 10:23. Per-PR CI's heavy-
test skip let it land unnoticed.

What changed: CURRENT_ORIGIN_VOCABULARY_VERSION 2→3 with the new frozen
digest (computed via the module's own documented command) and the v3
provenance comment; the checked-in small-session fixture regenerated via
write_revision — segment bytes identical, only the manifest's vocabulary
version/digest fields changed.

Verification: devtools test tests/unit/material_protocol/v1/ — 43 passed
(was 22 failed).

Co-Authored-By: Claude <[email protected]>
…ansparent

Problem: the guard installs a raising datetime subclass into guarded test
modules' `datetime` symbol; `isinstance(production_datetime, datetime)`
inside such a module became a subclass check that always fails —
breaking 20+ tests (test_models timestamp parsing, timestamp guards,
null-guard display_date, and downstream) whenever the guard is active.
The guard exists to block clock reads, not to change type identity.

What changed: GuardedDateTime now carries a metaclass whose
__instancecheck__ delegates to real datetime, so isinstance behaves
identically to the unguarded module while now()/utcnow() still raise.

Verification: devtools test tests/unit/sources/test_models.py
tests/unit/core/test_timestamp_guards.py
tests/unit/sources/test_null_guard_properties.py
tests/unit/infra/test_clock_guard.py — 405 passed (test_models was 11
failed).

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: dd48d83e-a2e9-40d0-88fb-0d34f9f97b2c

📥 Commits

Reviewing files that changed from the base of the PR and between 2e7e84b and 605d965.

📒 Files selected for processing (3)
  • polylogue/material_protocol/v1/origin_vocab.py
  • tests/fixtures/material_protocol/v1/small-session/manifest.json
  • tests/infra/clock_guard.py

📝 Walkthrough

Walkthrough

The origin vocabulary advances to version 3 with a registered digest and updated fixture manifest. The clock guard adds delegated datetime instance checks while preserving blocked clock reads.

Changes

Origin vocabulary version 3

Layer / File(s) Summary
Vocabulary registry and fixture
polylogue/material_protocol/v1/origin_vocab.py, tests/fixtures/material_protocol/v1/small-session/manifest.json
The public vocabulary version and frozen registry now include version 3. The fixture manifest records the matching version and digest.

Clock guard type checks

Layer / File(s) Summary
Datetime instance check delegation
tests/infra/clock_guard.py
_RaisingDateTime uses a metaclass that delegates isinstance checks to the real datetime type.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary fixes: the origin vocabulary version update and the clock-guard isinstance compatibility fix.
Description check ✅ Passed The description covers the summary, problems, solutions, verification results, and remaining failures with sufficient technical detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/material-protocol/origin-vocab-v3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 012d9e8 into master Aug 1, 2026
3 checks passed
@Sinity
Sinity deleted the fix/material-protocol/origin-vocab-v3 branch August 1, 2026 09:01
Sinity added a commit that referenced this pull request Aug 1, 2026
… section (#3501)

## Summary

Orchestration-machinery hardening from the 2026-08-01 fanout audit: a
new `devtools workspace verify-worktree` command that catches the
worktree-isolation-escape failure mode before a lane's output is
trusted, a `lane-brief` "Recently merged on master (footprint overlap)"
section with an explicit PRIOR-SATISFACTION CHECK, standing-hazard
updates (no background idle-waits, no lane-side bd writes), and a
`.agent/CONVENTIONS.md` fix that scopes background execution to
coordinator sessions only.

## Problem

Four verified failure modes from the 2026-08-01 20-lane fanout (each
re-verified against source/git, not taken from the incident narrative):

1. An `isolation: "worktree"` dispatch silently ran in the main checkout
and left ~1700 uncommitted lines in the coordinator's live tree; no
tooling existed to verify a lane's claimed worktree (confirmed via the
devtools command catalog).
2. Lane agents' bd calls from stale worktrees reverted 5+ live
coordinator bead writes twice (polylogue-2ara, P1 open). Live evidence
in this lane: a plain `git switch -c` inside the worktree fired the
beads post-checkout JSONL import. Note:
`feature/devtools/worktree-import-guard` is NOT this fix — its commit
f51f373 is content-identical to merged PR #3475 (checkout_guard); the
branch is superseded and deletable. Remaining polylogue-2ara scope:
bd-invocation-time skip-import-if-older.
3. Three lanes stalled for multiple turns idle-waiting on backgrounded
`devtools test` runs — and `.agent/CONVENTIONS.md` itself recommended
"long test runs ... go to background execution".
4. Lane polylogue-2cuv burned its budget on a bead already satisfied by
a same-session merge; the brief's per-path last-3-commits crumbs did not
surface this.

Incidents 5/6 (master-red via narrow gates, repaired in #3498/#3500) are
assessed in the companion memo as a process-economics tradeoff,
deliberately not addressed with new tooling here.

## Solution

- `devtools/verify_worktree.py` (+ catalog entry, regenerated
`docs/devtools.md`): hard checks — path exists, inside a git repo, is a
LINKED worktree (`--absolute-git-dir` vs `--git-common-dir`), toplevel
distinct from the main checkout, `--expect-branch` match; advisory
checks — uncommitted changes, stale `.beads/issues.jsonl` (max
`updated_at` vs main checkout, string-comparable ISO-8601). `--json`,
`--strict`, exit 1 on hard failure.
- `devtools/lane_brief.py`: `_recent_master_commits()` aggregates `git
log --since=N days origin/master -- <footprint paths>` into a dedicated
section headed by a PRIOR-SATISFACTION CHECK instruction; new
`--recent-days`; hazards now forbid background idle-waits and lane-side
bd writes (polylogue-2ara).
- `.agent/CONVENTIONS.md`: async execution scoped to coordinator
sessions; new coordinator dispatch-hygiene bullet (run verify-worktree
after every spawn).

Companion memo (out-of-blast-radius recommendations, incl. sinnix
doctrine edits):
`.agent/scratch/2026-08-01-orchestration-audit-recommendations.md`
(gitignored; copy preserved in the session scratchpad).

## Verification

- `devtools test tests/unit/devtools/test_verify_worktree.py
tests/unit/devtools/test_lane_brief.py` — `24 passed in 5.18s`.
- Live smoke: `devtools workspace verify-worktree <this lane's worktree>
--expect-branch feature/devtools/orchestration-audit` → `verdict: OK`;
`devtools workspace verify-worktree /realm/project/polylogue` → `[FAIL]
linked_worktree ... MAIN checkout`, exit 1.
- `devtools verify --quick` — exit 0 (87.3s, all 18 steps green).
- Not run: full suite / `verify --all` (no substrate code touched;
testmon-affected + focused tests cover the changed surface).

## Anti-vacuity

The verify-worktree tests build real git repos + `git worktree add` and
exercise real `git rev-parse` semantics — dropping the
git-dir/common-dir comparison flips
`test_main_checkout_fails_isolation_check`; dropping the `updated_at`
comparison flips `test_stale_beads_jsonl_is_flagged`. The production
caller is the coordinator dispatch flow documented in
`.agent/CONVENTIONS.md` (and exercised live in this PR's verification).
`test_render_markdown_prior_satisfaction_warning_lists_recent_commits`
fails if the new section is dropped from `_render_markdown`.

Ref polylogue-2ara.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01P7dQJSbhvx7LSu5PW9Ns9S

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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