From 04be2c5ad7b8e91b156bd9a8a7f18fb8bf319fdf Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sat, 3 Oct 2026 17:32:59 +0000 Subject: [PATCH 1/2] =?UTF-8?q?docs(agents):=20land=20stranded=20SPARK=20d?= =?UTF-8?q?eliverables=20=E2=80=94=20identity=20binding,=20governance=20br?= =?UTF-8?q?idge,=20spynel=20review,=20openroom=20default-surface=20room?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SITREP's 2026-09-22 refresh records four deliverables as DONE (review-accepted 2026-09-21), but they existed only as uncommitted working-tree files on the SPARK node β€” the same "branch-local is not landed" defect row 3068 of the claim register records. This lands them: - IDENTITY_BINDING.md β€” pmoves identity vocabulary <-> Spynel prefix-slot binding - GOVERNANCE_BRIDGE.md β€” Three-Body <-> Spynel five-role mapping - PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md β€” the review itself - openroom.default.surface room manifest + additive catalog row (16 OK at validation; the jons-edge UNDECLARED is pre-existing/baselined) - test_identity_binding.py + spynel timestamp test (skip cleanly off-node) Release Note: docs + room catalog; no runtime change. πŸ’˜ Generated with Crush --- pmoves/config/rooms/catalog.json | 16 +- .../rooms/openroom.default.surface.json | 147 ++++++++++++++++ pmoves/docs/AGENTS/GOVERNANCE_BRIDGE.md | 38 ++++ pmoves/docs/AGENTS/IDENTITY_BINDING.md | 79 +++++++++ ...-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md | 1 - .../spynel/test_spynel_document_timestamps.py | 120 +++++++++++++ pmoves/tests/test_identity_binding.py | 165 ++++++++++++++++++ 7 files changed, 563 insertions(+), 3 deletions(-) create mode 100644 pmoves/config/rooms/openroom.default.surface.json create mode 100644 pmoves/docs/AGENTS/GOVERNANCE_BRIDGE.md create mode 100644 pmoves/docs/AGENTS/IDENTITY_BINDING.md create mode 100644 pmoves/tests/spynel/test_spynel_document_timestamps.py create mode 100644 pmoves/tests/test_identity_binding.py diff --git a/pmoves/config/rooms/catalog.json b/pmoves/config/rooms/catalog.json index e4a4928589..1a8c95bc0d 100644 --- a/pmoves/config/rooms/catalog.json +++ b/pmoves/config/rooms/catalog.json @@ -169,7 +169,7 @@ "current_stage": "rehearsal", "stage_source": "ageless-beauty.room.practice.json::stage", "stage_verified_at": "2026-09-13T00:00:00Z" -}, + }, { "room_id": "b850-ledger.room.evidence", "agent_id": "b850-claude", @@ -193,6 +193,18 @@ "current_stage": "rehearsal", "stage_source": "manifest stage field (recovered room, no P7 session yet)", "stage_verified_at": "2026-09-23T00:00:00Z" + }, + { + "room_id": "openroom.default.surface", + "agent_id": "mavis", + "alter": "openroom", + "display_name": "OpenRoom β€” Default Operating Surface", + "stage": "rehearsal", + "manifest": "openroom.default.surface.json", + "summary": "Default operating surface for every agent session in this workspace: OpenRoom (PMOVES fork of MiniMax-AI/OpenRoom, submodule PMOVES-OpenRoom) is the browser-desktop host that opens the catalog's rooms under P7 session/stage discipline. Standing rule across all five Spynel agent roles β€” chat, developer, reviewer, notification, heartbeat β€” unless the user supersedes; source of truth: .spynel/instructions/agent-chat.md, agent-developer.md, agent-reviewer.md, agent-notification.md, agent-heartbeat.md (each carries the OpenRoom default-surface rule). Stage: rehearsal β€” the default-surface rule is routing policy, not a room activation.", + "current_stage": "rehearsal", + "stage_source": "openroom.default.surface.json::stage (default-surface entry added 2026-09-22; current_stage mirrors the manifest declaration, not a P7 activation)", + "stage_verified_at": "2026-09-22T11:53:53Z" } ] -} +} \ No newline at end of file diff --git a/pmoves/config/rooms/openroom.default.surface.json b/pmoves/config/rooms/openroom.default.surface.json new file mode 100644 index 0000000000..dce4e39409 --- /dev/null +++ b/pmoves/config/rooms/openroom.default.surface.json @@ -0,0 +1,147 @@ +{ + "room_id": "openroom.default.surface", + "version": "0.1.0", + "stage": "rehearsal", + "display_name": "OpenRoom β€” Default Operating Surface", + "description": "OpenRoom (PMOVES fork of MiniMax-AI/OpenRoom, submodule PMOVES-OpenRoom) is the browser-desktop host that opens the rooms of pmoves/config/rooms/catalog.json for operators and agents, with P7 session/stage discipline applied on entry. Standing workspace rule (persisted 2026-09-21): OpenRoom is the DEFAULT OPERATING SURFACE for all five Spynel agent roles β€” chat, developer, reviewer, notification, heartbeat β€” unless the user supersedes it; each role declares 'operating surface: OpenRoom' when signing output. Source of truth for the rule: the five .spynel/instructions/ role files (.spynel/instructions/agent-chat.md, agent-developer.md, agent-reviewer.md, agent-notification.md, agent-heartbeat.md).", + "agent_id": "mavis", + "alter": "openroom", + "room_type": "operator", + "owner_mode": "primary", + "access": { + "visibility": "private", + "owner_only": true, + "rating_note": "Operator/agent desktop host. Room-local expression is unrestricted; public egress stays behind policies.publish.egress_redaction_floor." + }, + "shell": { + "theme": { + "theme_id": "openroom", + "accent_color": "#7c5cff", + "icon": "door-open" + }, + "layout": { + "default_route": "/desktop", + "panels": [ + { + "panel_id": "room-desktop", + "kind": "browser", + "position": "center", + "size": 100, + "pinned": true + } + ] + } + }, + "apps": [ + { + "app_id": "openroom-desktop", + "kind": "browser", + "route": "/desktop", + "provider": "openroom", + "capabilities": [ + "room-launch", + "surface-render", + "p7-session" + ], + "pinned": true, + "status": "active" + } + ], + "notebook": { + "provider": "open-notebook", + "workspace_ref": "openroom", + "default_page": "orientation", + "sync": { + "mode": "mirrored", + "writeback_targets": [ + "entries" + ], + "artifact_prefix": "rooms/openroom" + } + }, + "skill_bindings": [ + { + "binding_id": "openroom-default-surface-declare", + "skill_id": "pmoves/openroom-default-surface", + "room_id": "openroom.default.surface", + "display_name": "Declare OpenRoom as the operating surface", + "intent": [ + "operating surface", + "openroom", + "sign output" + ], + "surface": { + "app_id": "openroom-desktop", + "target": "toolbar", + "route": "/desktop" + }, + "execution": { + "mode": "workflow", + "run_as": "agent", + "stream": "status", + "max_steps": 2 + }, + "context": { + "sources": [ + "user-intent", + "room-state" + ], + "include_last_turns": 1, + "artifact_types": [ + "text" + ] + }, + "outputs": [ + { + "target": "chat-response", + "delivery": "notify", + "artifact_type": "text" + } + ], + "guardrails": { + "require_approval": false, + "max_runtime_sec": 30, + "fail_open": false, + "one_active_run": true + }, + "enabled": true, + "tags": [ + "openroom", + "default-surface", + "governance" + ] + } + ], + "policies": { + "model_routing": "hybrid", + "publish": { + "allow_nats_emit": true, + "allow_external_publish": false, + "allowed_subjects": [ + "room.session.updated.v1" + ] + }, + "memory": { + "graphiti": false, + "notebook_writeback": true, + "chit_handoff": true + } + }, + "telemetry": { + "room_events_subject": "room.session.updated.v1", + "healthcheck_route": "/healthz" + }, + "provenance": { + "source": "pmoves/docs/ROOMS_ON_A_STAGE.md + .spynel/instructions/ (five role files)", + "updated_at": "2026-09-22T11:53:53Z", + "related_docs": [ + "pmoves/docs/ROOMS_ON_A_STAGE.md", + "pmoves/docs/ROOM_MANIFEST_CONTRACT.md", + ".spynel/instructions/agent-chat.md", + ".spynel/instructions/agent-developer.md", + ".spynel/instructions/agent-reviewer.md", + ".spynel/instructions/agent-notification.md", + ".spynel/instructions/agent-heartbeat.md" + ] + } +} diff --git a/pmoves/docs/AGENTS/GOVERNANCE_BRIDGE.md b/pmoves/docs/AGENTS/GOVERNANCE_BRIDGE.md new file mode 100644 index 0000000000..8fa171e730 --- /dev/null +++ b/pmoves/docs/AGENTS/GOVERNANCE_BRIDGE.md @@ -0,0 +1,38 @@ +# Governance Bridge β€” PMOVES Three-Body ↔ Spynel five-role + +Two governance systems run in this workspace. This page records how they line up **as they are today**, and names the gaps rather than inventing correspondences. Satisfies recommendation #2 (P1) of `pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md:208`. All citations are superproject state; nothing here claims anything about submodule code. + +## Body β†’ role mapping + +Three bodies against five roles is not a bijection. Two bodies have a usable Spynel counterpart, one has none, and three Spynel roles have no Three-Body counterpart. + +| Three-Body body | Spynel role (`.spynel/AGENTS.md:14`) | Relationship | +|---|---|---| +| **Delivery** β€” execution lane (`AGNOTE4482PHI.t1.md:20`) | `agent-developer` | Closest to a true pair: each is the only writing body in its system. | +| **Control** β€” governance lane, read-only (`AGNOTE4482PHI.t1.md:26`) | `agent-reviewer` | Partial. Control also owns merge sequencing and branch-pruning policy; the Spynel reviewer's authority stops at one task document (`.spynel/tasks/AGENTS.md:27`). | +| **Memory** β€” Cipher/CHIT custody and signature trail (`AGNOTE4482PHI.t1.md:32`) | **none** | Spynel has no memory or custody role. CHIT custody stays PMOVES-side via `.claude/agents/memory-agent.md`. | +| **none** | `agent-chat` | Communication dispatcher β€” records tasks and goals, delegates execution. Runs *before* any lane exists (`.spynel/AGENTS.md:15`). | +| **none** | `agent-notification` | Outbound delivery decision on terminal and actionable-waiting transitions (`.spynel/tasks/AGENTS.md:29`). | +| **none** | `agent-heartbeat` | Non-overlapping primary-owned workflow audit (`.spynel/AGENTS.md:21`). | + +## Per-phase prefix notes + +The Three-Body DoD is `claim β†’ work β†’ sign β†’ release` (`AGENTS.md:62`, `AGNOTE4482PHI.t1.md:55-58`). `.spynel/config.yaml:12-15` defines **four** prefix slots β€” chat, developer, reviewer, heartbeat β€” and **all four are empty strings today**, so no prefix is actually applied. There is no notification prefix slot. The table records the slot each phase *would* use. + +| Phase | Spynel role | Prefix slot | Register row KIND | Make target | +|---|---|---|---|---| +| claim | `agent-developer` | `harness.developer_agent_prefix` | `CLAIM` | `register-claim` (`pmoves/Makefile:395`) | +| work | `agent-developer` | `harness.developer_agent_prefix` | `UPDATE`, or no row | `register-note` (`pmoves/Makefile:437`) | +| sign | **no counterpart** | none | ACK block / trail entry | `sign-trail` (`pmoves/mk/preflight.mk:512`) | +| release | `agent-developer`; `agent-reviewer` when `review_required: true` | developer / reviewer slot | `RELEASE` | `register-release` (`pmoves/Makefile:417`) | + +`sign` is the real gap: no Spynel role emits a CHIT signature, and a `completion_summary` is not one. A task can move `working -> done` with no trail entry and no register row at all. + +## Two registers, two owners + +| Register | Path | Owner | Written by | +|---|---|---|---| +| CHIT claim register | `pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md` | PMOVES | `register-claim` / `register-release` / `register-note` (`pmoves/Makefile:389-487`) β€” never by hand | +| Spynel claim / lease | `.spynel/runtime/leases/` | Spynel | Spynel alone; agents must not edit (`.spynel/AGENTS.md:10`, `:20`) | + +**Neither register is derived from the other.** No tool reads across them, no transition in one writes the other, and an open CHIT lane neither blocks nor is blocked by a Spynel dispatch. A Spynel-dispatched developer session that edits code must file its own `CLAIM` row: being claimed into `working/` is task ownership, not lane ownership. diff --git a/pmoves/docs/AGENTS/IDENTITY_BINDING.md b/pmoves/docs/AGENTS/IDENTITY_BINDING.md new file mode 100644 index 0000000000..6528d11f9d --- /dev/null +++ b/pmoves/docs/AGENTS/IDENTITY_BINDING.md @@ -0,0 +1,79 @@ +# Identity binding β€” PMOVES vocabulary ↔ Spynel harness prefix slots + +Implements recommendation #1 (P1) of `pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md:206`. +Gated by `pmoves/tests/test_identity_binding.py`. All citations are superproject paths; +this document makes no claim about any submodule's code. + +## The binding in one line + +**The PMOVES vocabulary is the sole surface that declares identity. The Spynel +`harness.*_agent_prefix` slots declare none, so there is nothing for the CLAIM line to +override β€” the CLAIM line is simply the only writer.** + +The review stated it as "Spynel `harness.developer_agent_prefix` is overridden by the +CHIT-signed CLAIM line; the PMOVES vocabulary provides the *valid prefixes* set." That is +the right conclusion from a wrong premise, and the difference matters. Measured +2026-09-21: per `spynel docs harnesses` Β§ *Agent prefixes*, a prefix slot is "an optional +validated one-line harness-native command, such as `/goal` or `/ultrathink`" that Spynel +outer-trims and joins to the prompt with one ASCII space. It is a **prompt prefix, not an +identity prefix**. The two surfaces do not compete; one is empty of identity by +construction. + +## Which surface answers which question + +| Question | Authoritative surface | +|---|---| +| What is the set of valid identities and spellings? | `pmoves/config/identity_vocabulary.yaml:87` (`identities:`), plus `lanes:` `:380`, `harnesses:` `:449`, `provisioning:` `:397` | +| What identity does *this* session use? | Neither. It is the `OWNER=` argument at `pmoves/Makefile:395`, defaulting to `$REGISTER_OWNER` (`pmoves/Makefile:386`, `pmoves/tools/register_append.py:981`) | +| What author string actually lands in the register? | The CLAIM/RELEASE/NOTE row written by `pmoves/tools/register_append.py`; `:1083` refuses a row with no owner | +| Is that author string legal? | `pmoves/tools/identity_lineage.py:538` (`verify`), via `canonical_identity` `:326` β€” enforced post-hoc by `pmoves/tests/test_identity_lineage.py`, per the vocabulary's own rule at `pmoves/config/identity_vocabulary.yaml:37-40` | +| What text is prepended to the agent prompt? | `.spynel/config.yaml:12-15` | + +## The four configured slots and what may fill them + +`.spynel/config.yaml:7` `harness:` carries exactly four: + +| Slot | Line | May be filled by a vocabulary entry? | +|---|---|---| +| `chat_agent_prefix` | `.spynel/config.yaml:12` | No β€” harness-native command only | +| `developer_agent_prefix` | `.spynel/config.yaml:13` | No β€” harness-native command only | +| `reviewer_agent_prefix` | `.spynel/config.yaml:14` | No β€” harness-native command only | +| `heartbeat_agent_prefix` | `.spynel/config.yaml:15` | No β€” harness-native command only | + +The mapping is empty in both directions, and that is the contract: putting a vocabulary +identity into a prefix slot would inject that string into the prompt, not into the +register, producing an identity claim no gate reads. + +## Precedence when they disagree + +1. The CLAIM-line author string (`OWNER=`) is what the register records β€” always. +2. `pmoves/config/identity_vocabulary.yaml` decides whether that string is legal. +3. `.spynel/config.yaml` prefix slots have no vote. A disagreement between a prefix slot + and the vocabulary is not a tie to break; it is a misconfiguration to remove. + +## The empty-slot default β€” the live state, not an edge case + +All four slots are `""` today (`.spynel/config.yaml:12-15`, verified 2026-09-21). Per +`spynel docs harnesses`, an empty prefix "preserves the prompt byte-for-byte", so a +Spynel-dispatched session receives **no identity at all** from the harness. It resolves +identity only when it reaches `make -C pmoves register-claim` and supplies `OWNER=`. +Nothing validates that string at write time; `identity_lineage.verify()` catches it +afterward. + +That gap is live, not hypothetical. `pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md:2980` is a +NOTE filed `2026-09-21T21:19:28Z` by author `SPARK-CLAUDE` β€” a Spynel developer session on +this node with `developer_agent_prefix: ""`. `SPARK-CLAUDE` is **not** in the vocabulary, +so `verify()` currently returns exactly one finding naming it, while +`pmoves/config/signing_identity_cards.yaml:253` does carry `agent_id: "spark-claude"`. The +card exists; the vocabulary entry does not. Closing it is a vocabulary append, out of +scope here and deliberately not performed by this document. + +## The missing fifth slot + +`.spynel/instructions/` holds five role files β€” `agent-chat.md`, `agent-developer.md`, +`agent-reviewer.md`, `agent-heartbeat.md`, `agent-notification.md` β€” but `.spynel/config.yaml` +defines only four prefix slots. There is **no `notification_agent_prefix`**. Recorded, not +papered over: under this binding the asymmetry is harmless, because a prefix slot carries +no identity and the notification agent files no register row. It would become load-bearing +only if prefix slots ever gained identity meaning, which is exactly what the ratchet test +guards against. diff --git a/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md b/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md index 21c74312cf..ea446a7b43 100644 --- a/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md +++ b/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md @@ -185,7 +185,6 @@ Severity scale: **P0** (breaks the contract); **P1** (inconsistent / surprising) | 4 | Status folder set (goals) | `goals/{proposed, planning, active, review, reviewing, waiting, done, abandoned}` | All 8 present; none active. | n/a | n/a | **P2** | | 5 | Review-mode handling | `harness.reviews: skip-trivial \| always \| never`; per-task `review_required` boolean. | `reviews: skip-trivial` set; task has `review_required: false` β†’ direct completion permitted. Plumbed correctly. | n/a | n/a | **P2** | | 6 | **Identity vocabulary binding** | PMOVES side canonical = `pmoves/config/identity_vocabulary.yaml` (470 lines, the source of truth for `role_class`, agent IDs, persona validation). | Local `.spynel/config.yaml` has five `*_agent_prefix` slots, all empty; no identity file under `.spynel/`. The PMOVES-side vocabulary file lives outside the Spynel state directory and is referenced only conceptually (chat prompt says "the operator-grade persona is framing, the executor signs its own identity"). | n/a | n/a | **P1** β€” two parallel identity models in the same workspace without a documented binding contract; the executor / chat / reviewer / notifier / heartbeat persona role has no Spynel-side vocabulary file that defines what counts as a valid agent ID. | -| 7 | History / leases / exclusive folders | `history/`, `jobs/`, `runtime/leases/`, `attachments/`, `whatsapp.db` are Spynel-owned. | All five present and respected. No write attempted. | n/a | n/a | **pass** (no drift; protection enforced by `.spynel/AGENTS.md` Β§Contracts) | | 8 | Three-Body Rule (Delivery/Control/Memory) vs Five-role Spynel split | Three bodies enforced via `.claude/agents/` frontmatter `disallowedTools` in PMOVES.AI (`AGNOTE4482PHI.t1.md`). Spynel has five roles (`chat, developer, reviewer, notification, heartbeat`) under `.spynel/instructions/`. | Both governance systems run in the same workspace today (PMOVES Claude Code agents + Spynel orchestrator). The Three-Body ↔ Spynel-role mapping is **informal** (Delivery β‰ˆ developer; Control β‰ˆ reviewer; Memory β‰ˆ notification+heartbeat; chat β‰ˆ chat). | n/a | n/a | **P1** β€” no formal binding between the two governance systems; PMOVES agents reading `.spynel/AGENTS.md` get one set of constraints, Claude Code agents (Three-Body) get a different set. Risk: claim-register / CHIT trail could disagree on which lane was in flight. | | 9 | Prompt template override policy | All 10 templates under `.spynel/prompts/` are user-overridable; `skill_workshop` does not auto-modify managed skills (requires explicit user request). | Prompts present; no overrides observed. | Provides equivalent governance via `skill_workshop`'s "explicit user request only" rule (Hermes-gating-v6). The skills package enforces a stricter policy: a managed skill is *not* auto-modified by a preference or correction. | n/a | **P2** β€” parity is achieved at the policy level (both require explicit authorization); the Spynel-side contract is currently scoped to prompts/, while skills/ extends to skills, MEMORY/AGENTS/USER/TOOLS, and managed SKILL.md files. | | 10 | Notification-event coverage | `done, failed, cancelled` always dispatch a notification agent. Actionable `waiting` does the same. The notification agent decides and edits the log itself. | Documented and exercised via `notify.on` on observed task. The chat prompt also states "Do not contact the user or interpret later chat messages in this implementation session" β€” i.e. the implementation session does not send. | n/a | n/a | **P2** β€” boundary holds. | diff --git a/pmoves/tests/spynel/test_spynel_document_timestamps.py b/pmoves/tests/spynel/test_spynel_document_timestamps.py new file mode 100644 index 0000000000..ef0769c4e1 --- /dev/null +++ b/pmoves/tests/spynel/test_spynel_document_timestamps.py @@ -0,0 +1,120 @@ +"""Ratchet: timestamps in Spynel task and goal documents are well-formed UTC instants. + +Guards the contract stated in `.spynel/tasks/AGENTS.md` Β§ "Schema reference". + +Deliberately NOT asserted: that timestamps are *quoted*. Spynel's own writes are not +uniformly quoted (measured 2026-09-21: three `created_at` values are bare, so PyYAML +resolves them to `datetime` rather than `str`), and both forms denote the same instant. +The doc states quoting as the convention; this test asserts the instant-level invariant +that actually breaks dispatch when violated. +""" + +from __future__ import annotations + +import datetime as dt +import re +from pathlib import Path + +import pytest +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[3] +SPYNEL_ROOTS = (REPO_ROOT / ".spynel" / "tasks", REPO_ROOT / ".spynel" / "goals") + +# RFC 3339, explicit Z, second precision (optional fractional seconds). +RFC3339_Z = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$") + + +def _documents() -> list[Path]: + return sorted( + p + for root in SPYNEL_ROOTS + if root.is_dir() + for p in root.rglob("*.md") + if p.name != "AGENTS.md" + ) + + +def _front_matter(path: Path) -> dict: + text = path.read_text(encoding="utf-8") + if not text.startswith("---\n"): + pytest.fail(f"{path}: no YAML front matter") + end = text.find("\n---", 3) + if end == -1: + pytest.fail(f"{path}: unterminated YAML front matter") + data = yaml.safe_load(text[4:end]) + if not isinstance(data, dict): + pytest.fail(f"{path}: front matter is not a mapping") + return data + + +def _timestamp_fields(node, prefix: str = ""): + """Yield (dotted_name, value) for every key ending in `_at`, at any depth.""" + if isinstance(node, dict): + for key, value in node.items(): + name = f"{prefix}{key}" + if str(key).endswith("_at"): + yield name, value + yield from _timestamp_fields(value, f"{name}.") + + +def _instant(name: str, value, path: Path) -> dt.datetime: + """Normalize a timestamp to an aware UTC datetime, or fail with the offending value.""" + if isinstance(value, dt.datetime): + # Unquoted in YAML. Accepted, but it must still carry an explicit UTC offset. + if value.tzinfo is None or value.utcoffset() != dt.timedelta(0): + pytest.fail(f"{path}: {name}={value!r} lacks an explicit UTC (Z) offset") + return value + if isinstance(value, str): + if not RFC3339_Z.match(value): + pytest.fail( + f"{path}: {name}={value!r} is not RFC 3339 with an explicit Z UTC offset" + ) + return dt.datetime.fromisoformat(value.replace("Z", "+00:00")) + pytest.fail(f"{path}: {name}={value!r} is not a timestamp") + + +if not _documents(): + pytestmark = pytest.mark.skip( + reason="no .spynel/ task or goal documents in this checkout (.spynel/ is untracked)" + ) + + +@pytest.mark.parametrize("path", _documents(), ids=lambda p: p.name) +def test_timestamps_are_rfc3339_utc(path: Path) -> None: + front_matter = _front_matter(path) + fields = list(_timestamp_fields(front_matter)) + assert fields, f"{path}: front matter carries no timestamp field" + for name, value in fields: + _instant(name, value, path) + + +@pytest.mark.parametrize("path", _documents(), ids=lambda p: p.name) +def test_no_timestamp_postdates_updated_at(path: Path) -> None: + front_matter = _front_matter(path) + assert "updated_at" in front_matter, f"{path}: missing required `updated_at`" + updated_at = _instant("updated_at", front_matter["updated_at"], path) + for name, value in _timestamp_fields(front_matter): + if name in ("updated_at", "wake_at", "next_review_at"): + continue # wake_at / next_review_at are deliberately future-dated + assert _instant(name, value, path) <= updated_at, ( + f"{path}: {name}={value!r} postdates updated_at={front_matter['updated_at']!r}" + ) + + +@pytest.mark.parametrize("path", _documents(), ids=lambda p: p.name) +def test_direct_completion_completed_at_matches_updated_at(path: Path) -> None: + front_matter = _front_matter(path) + summary = front_matter.get("completion_summary") + if not isinstance(summary, dict) or summary.get("verdict") != "completed": + pytest.skip("not a direct-completion summary") + if front_matter.get("status") != "done": + # The contract attaches this equality to the `working -> done` move. A file still + # in flight may carry a drafted summary while `updated_at` keeps advancing. + pytest.skip("direct-completion summary not yet terminal (status != done)") + assert "completed_at" in summary, f"{path}: `completed` verdict without `completed_at`" + assert _instant( + "completion_summary.completed_at", summary["completed_at"], path + ) == _instant("updated_at", front_matter["updated_at"], path), ( + f"{path}: completion_summary.completed_at must equal updated_at exactly" + ) diff --git a/pmoves/tests/test_identity_binding.py b/pmoves/tests/test_identity_binding.py new file mode 100644 index 0000000000..335eb79ff4 --- /dev/null +++ b/pmoves/tests/test_identity_binding.py @@ -0,0 +1,165 @@ +"""The binding between the PMOVES identity vocabulary and Spynel's prefix slots. + +`pmoves/docs/AGENTS/IDENTITY_BINDING.md` says one load-bearing thing: the Spynel +`harness.*_agent_prefix` slots declare NO identity. They are harness-native +command prefixes (`/goal`, `/ultrathink`) that Spynel joins to the prompt, so +the PMOVES vocabulary is the only surface that declares who an agent is. + +The drift this exists to stop is a reader taking the slot name at face value and +filling `developer_agent_prefix` with a register identity -- say `SPARK-CLAUDE`. +That string would be injected into the PROMPT, never into the register, and no +existing gate would see it: `test_identity_lineage.py` reads the register, and +the register would be unchanged. + +DELIBERATELY NARROW. `identity_vocabulary.yaml` is append-only by design +(`pmoves/config/identity_vocabulary.yaml:37-40`), so nothing here may key on the +vocabulary's CONTENTS or SIZE -- a test that did would fail on the next +legitimate append. It asserts only what the doc claims, and +`test_appending_an_identity_does_not_break_the_binding` proves that by running +the same assertions against a vocabulary with an extra identity in it. + +Static: reads two files and resolves strings. No Spynel process, no network. +""" +from __future__ import annotations + +import importlib.util +import re +import sys +from pathlib import Path + +import pytest +import yaml + +REPO_ROOT = Path(__file__).resolve().parents[2] +CONFIG = REPO_ROOT / ".spynel" / "config.yaml" +BINDING_DOC = REPO_ROOT / "pmoves" / "docs" / "AGENTS" / "IDENTITY_BINDING.md" +VOCABULARY = REPO_ROOT / "pmoves" / "config" / "identity_vocabulary.yaml" + +# A slot counts as DOCUMENTED only from its row in the doc's slot table, which +# pairs the name with the `.spynel/config.yaml` line that defines it. Matching +# the bare name anywhere in the prose would count the paragraph that records +# `notification_agent_prefix` as deliberately ABSENT as if it documented a +# present slot -- inverting the check. +DOCUMENTED_SLOT = re.compile( + r"^\|\s*`([a-z]+_agent_prefix)`\s*\|\s*`\.spynel/config\.yaml:", re.MULTILINE +) +ABSENT_SLOT = "notification_agent_prefix" + + +def _module(): + path = REPO_ROOT / "pmoves" / "tools" / "identity_lineage.py" + spec = importlib.util.spec_from_file_location("identity_lineage", path) + module = importlib.util.module_from_spec(spec) + sys.modules["identity_lineage"] = module + spec.loader.exec_module(module) + return module + + +il = _module() + + +def _harness() -> dict: + """The `harness:` mapping, or skip. + + `.spynel/config.yaml` is private per-workspace state and is not tracked, so + it is absent in CI and on a fresh clone. Skipping is correct there: the + binding cannot drift on a node that has no Spynel config. + """ + if not CONFIG.exists(): + pytest.skip(f"{CONFIG} absent -- no Spynel config on this node") + doc = yaml.safe_load(CONFIG.read_text(encoding="utf-8")) or {} + harness = doc.get("harness") + if not isinstance(harness, dict): + pytest.skip(f"{CONFIG} has no `harness:` mapping") + return harness + + +def _configured_slots(harness: dict) -> set[str]: + return {k for k in harness if k.endswith("_agent_prefix")} + + +def _documented_slots() -> set[str]: + return set(DOCUMENTED_SLOT.findall(BINDING_DOC.read_text(encoding="utf-8"))) + + +# -------------------------------------------------------------------------- +# The gate +# -------------------------------------------------------------------------- + +def test_the_binding_doc_lists_exactly_the_configured_prefix_slots(): + """A slot the doc does not name is a slot nobody decided the meaning of. + + This is the one that fires when `notification_agent_prefix` is finally + added: the doc records its absence as a deliberate asymmetry, so adding it + must be accompanied by a decision written down, not a silent config edit. + """ + configured = _configured_slots(_harness()) + documented = _documented_slots() + assert configured == documented, ( + f"{CONFIG} and {BINDING_DOC.name} disagree on the prefix slots.\n" + f" configured but undocumented: {sorted(configured - documented)}\n" + f" documented but unconfigured: {sorted(documented - configured)}" + ) + + +def test_the_doc_still_records_the_absent_notification_slot(): + """The asymmetry is a recorded decision; deleting the note is drift too.""" + text = BINDING_DOC.read_text(encoding="utf-8") + assert ABSENT_SLOT in text, ( + f"{BINDING_DOC.name} no longer names {ABSENT_SLOT}. Five roles exist " + "under .spynel/instructions/ and four prefix slots are configured; " + "that gap is recorded on purpose." + ) + assert ABSENT_SLOT not in _configured_slots(_harness()), ( + f"{ABSENT_SLOT} is now configured -- give it a row in the slot table " + f"of {BINDING_DOC.name} and update the asymmetry note." + ) + + +def test_no_prefix_slot_holds_a_register_identity(): + """The binding itself: a prefix slot is a command, never an identity.""" + _assert_slots_carry_no_identity(_harness()) + + +def test_appending_an_identity_does_not_break_the_binding(tmp_path, monkeypatch): + """Proof the assertion above is append-safe, not merely narrow-looking. + + Runs the real assertion against a vocabulary carrying one identity more + than the live file. If the gate were keyed on vocabulary contents or size + this would fail, which is precisely the failure mode the docstring warns + about. + """ + doc = yaml.safe_load(VOCABULARY.read_text(encoding="utf-8")) or {} + doc.setdefault("identities", []).append( + {"canonical": "append-probe-identity", "aliases": ["APPEND-PROBE-IDENTITY"]} + ) + widened = tmp_path / "identity_vocabulary.yaml" + widened.write_text(yaml.safe_dump(doc), encoding="utf-8") + monkeypatch.setenv("PMOVES_IDENTITY_VOCABULARY", str(widened)) + + vocab = il.load_vocabulary() + assert il.canonical_identity("APPEND-PROBE-IDENTITY", vocab) == "append-probe-identity" + _assert_slots_carry_no_identity(_harness(), vocab=vocab) + + +def _assert_slots_carry_no_identity(harness: dict, vocab=None) -> None: + vocab = vocab if vocab is not None else il.load_vocabulary() + offenders = {} + for slot in sorted(_configured_slots(harness)): + value = str(harness.get(slot) or "").strip() + if not value: + continue # the documented empty-slot default: no identity injected + resolved = il.canonical_identity(value, vocab) + if resolved is not None: + offenders[slot] = (value, resolved) + assert not offenders, ( + "a Spynel prefix slot holds a register identity. Per " + f"{BINDING_DOC.name}, a prefix is a harness-native command joined to " + "the PROMPT; an identity placed here never reaches the claim register " + "and no lineage gate can see it. Use OWNER= on `make -C pmoves " + "register-claim` instead.\n" + + "\n".join( + f" {slot}: {value!r} resolves to identity {resolved!r}" + for slot, (value, resolved) in offenders.items() + ) + ) From a2bd09aaed077fc9f89804024fac223856c87593 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Wed, 21 Oct 2026 13:20:32 +0000 Subject: [PATCH 2/2] docs(review): address #3273 kilocode findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scrub absolute home path from public spynel review doc - reconcile four-vs-five prefix-slot contradiction with IDENTITY_BINDING.md - fix dangling policies.publish.egress_redaction_floor reference in room manifest - update identity binding example: spark-claude gap since closed on main (#3331) - catalog.json trailing newline - harden front-matter parser (multiline values, CRLF) + recurse lists in timestamp ratchet; lazy identity_lineage import in binding tests πŸ’˜ Generated with Crush --- pmoves/config/rooms/catalog.json | 2 +- .../rooms/openroom.default.surface.json | 2 +- pmoves/docs/AGENTS/IDENTITY_BINDING.md | 15 +++++++------- ...-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md | 6 +++--- .../spynel/test_spynel_document_timestamps.py | 20 ++++++++++++++++--- pmoves/tests/test_identity_binding.py | 13 +++++++++++- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/pmoves/config/rooms/catalog.json b/pmoves/config/rooms/catalog.json index 1a8c95bc0d..7a319adfb2 100644 --- a/pmoves/config/rooms/catalog.json +++ b/pmoves/config/rooms/catalog.json @@ -207,4 +207,4 @@ "stage_verified_at": "2026-09-22T11:53:53Z" } ] -} \ No newline at end of file +} diff --git a/pmoves/config/rooms/openroom.default.surface.json b/pmoves/config/rooms/openroom.default.surface.json index dce4e39409..1a53c3871c 100644 --- a/pmoves/config/rooms/openroom.default.surface.json +++ b/pmoves/config/rooms/openroom.default.surface.json @@ -11,7 +11,7 @@ "access": { "visibility": "private", "owner_only": true, - "rating_note": "Operator/agent desktop host. Room-local expression is unrestricted; public egress stays behind policies.publish.egress_redaction_floor." + "rating_note": "Operator/agent desktop host. Room-local expression is unrestricted; public egress stays behind policies.publish.allow_external_publish and its allowed_subjects gate." }, "shell": { "theme": { diff --git a/pmoves/docs/AGENTS/IDENTITY_BINDING.md b/pmoves/docs/AGENTS/IDENTITY_BINDING.md index 6528d11f9d..f85353abeb 100644 --- a/pmoves/docs/AGENTS/IDENTITY_BINDING.md +++ b/pmoves/docs/AGENTS/IDENTITY_BINDING.md @@ -60,13 +60,14 @@ identity only when it reaches `make -C pmoves register-claim` and supplies `OWNE Nothing validates that string at write time; `identity_lineage.verify()` catches it afterward. -That gap is live, not hypothetical. `pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md:2980` is a -NOTE filed `2026-09-21T21:19:28Z` by author `SPARK-CLAUDE` β€” a Spynel developer session on -this node with `developer_agent_prefix: ""`. `SPARK-CLAUDE` is **not** in the vocabulary, -so `verify()` currently returns exactly one finding naming it, while -`pmoves/config/signing_identity_cards.yaml:253` does carry `agent_id: "spark-claude"`. The -card exists; the vocabulary entry does not. Closing it is a vocabulary append, out of -scope here and deliberately not performed by this document. +That gap was live when this document was drafted (2026-09-21): a NOTE filed by author +`SPARK-CLAUDE` β€” a Spynel developer session with `developer_agent_prefix: ""` β€” was not in +the vocabulary while the signing card was pending. **It has since closed on main**: the +spark-claude signing card landed (PR #3331, `pmoves/config/signing_identity_cards.yaml`, +`agent_id: "spark-claude"`) and `pmoves/config/identity_vocabulary.yaml` now carries the +`spark-claude` canonical entry (with the `claude_spark -> spark-claude` alias). The +example stands as the shape of the gap: identity resolves only when the CLAIM reaches +`identity_lineage.verify()`, never at write time. ## The missing fifth slot diff --git a/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md b/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md index ea446a7b43..09f573e4f7 100644 --- a/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md +++ b/pmoves/docs/AGENTS/PMOVES-SPYNEL-VS-REGISTRIES-REVIEW-2026-09-21.md @@ -159,7 +159,7 @@ Legend: **pass** = matches canonical contract; **partial** = conformance gap tha | 3 | **Goal front matter** | `round, success_criteria` (list of stable IDs / conditions / evidence), review trigger. | `.spynel/goals/AGENTS.md` states the goal contract; no active goal file in `.spynel/goals/active/` to inspect against. Contract is implied but not exercised today. | n/a | n/a | **pass** (contract declared; not exercised) | | 4 | **Notification envelope β€” `notify.on`** | `[done, failed, waiting, cancelled]` per `.spynel/tasks/AGENTS.md`. | Observed on `t-20260921T163516Z`: `[done, failed, waiting, cancelled]` β€” exact match. | n/a | n/a | **pass** | | 5 | **Notification origin format** | `/`, channel ∈ `telegram \| whatsapp \| tui \| cli`. | Observed: `tui/local-930c568aed00d090604e46f034fbac05` β€” channel + conversation-handle, with the handle being a stable ID per `.spynel/AGENTS.md`. | n/a | n/a | **pass** | -| 6 | **Identity vocabulary / agent ID validation** | PMOVES side: `pmoves/config/identity_vocabulary.yaml` (470 lines). Spynel side: `.spynel/AGENTS.md` does not require a vocabulary file β€” agents self-identify via the persona prefix in `config.yaml` (`harness.chat_agent_prefix`, etc., currently empty strings). | Local config: all five prefix slots empty. No identity vocabulary file under `.spynel/` (identity_vocabulary.yaml lives in `pmoves/config/`, a separate surface). | n/a (skills package) | n/a (registry, not an identity verifier) | **partial** β€” see Phase A drift row 6 | +| 6 | **Identity vocabulary / agent ID validation** | PMOVES side: `pmoves/config/identity_vocabulary.yaml` (470 lines). Spynel side: `.spynel/AGENTS.md` does not require a vocabulary file β€” agents self-identify via the persona prefix in `config.yaml` (`harness.chat_agent_prefix`, etc., currently empty strings). | Local config: all four prefix slots empty (chat/developer/reviewer/heartbeat; notification is a fifth ROLE with no prefix slot β€” see IDENTITY_BINDING.md). No identity vocabulary file under `.spynel/` (identity_vocabulary.yaml lives in `pmoves/config/`, a separate surface). | n/a (skills package) | n/a (registry, not an identity verifier) | **partial** β€” see Phase A drift row 6 | | 7 | **Prompt template set under `.spynel/prompts/`** | 10 templates documented: `chat, task, create-task, goal, create-goal, goal-review, recovery, notification, review, heartbeat`. | All 10 present (chat.md, task.md, create-task.md, goal.md, create-goal.md, goal-review.md, recovery.md, notification.md, review.md, heartbeat.md); sizes 1.4 KB – 10.6 KB. | The `skill_workshop` skill allows creating/modifying skills **only on explicit user request** (Hermes-gating-v6 policy). The prompt template equivalent does not auto-load; user override is preserved per `.spynel/AGENTS.md`. | n/a | **pass** with a **partial** note: prompt override policy is correct, but it is *not* a contract declared by skills/registry; it's a Spynel-only contract. | | 8 | **State directory layout β€” `tasks/`** | `tasks/{todo, working, review, reviewing, waiting, done, failed, cancelled, archive}`. | Observed: `archive` present (cold retention only, populated by cleanup); the 8 active folders present. | n/a | n/a | **pass** | | 9 | **State directory layout β€” `goals/`** | `goals/{proposed, planning, active, review, reviewing, waiting, done, abandoned}` per `.spynel/goals/AGENTS.md`. | Observed: all 8 present; no active files. | n/a | n/a | **pass** | @@ -184,12 +184,12 @@ Severity scale: **P0** (breaks the contract); **P1** (inconsistent / surprising) | 3 | Status folder set (tasks) | `tasks/{todo, working, review, reviewing, waiting, done, failed, cancelled, archive}` | All 9 present (active 8 + archive). | n/a | n/a | **P2** | | 4 | Status folder set (goals) | `goals/{proposed, planning, active, review, reviewing, waiting, done, abandoned}` | All 8 present; none active. | n/a | n/a | **P2** | | 5 | Review-mode handling | `harness.reviews: skip-trivial \| always \| never`; per-task `review_required` boolean. | `reviews: skip-trivial` set; task has `review_required: false` β†’ direct completion permitted. Plumbed correctly. | n/a | n/a | **P2** | -| 6 | **Identity vocabulary binding** | PMOVES side canonical = `pmoves/config/identity_vocabulary.yaml` (470 lines, the source of truth for `role_class`, agent IDs, persona validation). | Local `.spynel/config.yaml` has five `*_agent_prefix` slots, all empty; no identity file under `.spynel/`. The PMOVES-side vocabulary file lives outside the Spynel state directory and is referenced only conceptually (chat prompt says "the operator-grade persona is framing, the executor signs its own identity"). | n/a | n/a | **P1** β€” two parallel identity models in the same workspace without a documented binding contract; the executor / chat / reviewer / notifier / heartbeat persona role has no Spynel-side vocabulary file that defines what counts as a valid agent ID. | +| 6 | **Identity vocabulary binding** | PMOVES side canonical = `pmoves/config/identity_vocabulary.yaml` (470 lines, the source of truth for `role_class`, agent IDs, persona validation). | Local `.spynel/config.yaml` has four `*_agent_prefix` slots, all empty (notification is a fifth role without a prefix slot); no identity file under `.spynel/`. The PMOVES-side vocabulary file lives outside the Spynel state directory and is referenced only conceptually (chat prompt says "the operator-grade persona is framing, the executor signs its own identity"). | n/a | n/a | **P1** β€” two parallel identity models in the same workspace without a documented binding contract; the executor / chat / reviewer / notifier / heartbeat persona role has no Spynel-side vocabulary file that defines what counts as a valid agent ID. | | 8 | Three-Body Rule (Delivery/Control/Memory) vs Five-role Spynel split | Three bodies enforced via `.claude/agents/` frontmatter `disallowedTools` in PMOVES.AI (`AGNOTE4482PHI.t1.md`). Spynel has five roles (`chat, developer, reviewer, notification, heartbeat`) under `.spynel/instructions/`. | Both governance systems run in the same workspace today (PMOVES Claude Code agents + Spynel orchestrator). The Three-Body ↔ Spynel-role mapping is **informal** (Delivery β‰ˆ developer; Control β‰ˆ reviewer; Memory β‰ˆ notification+heartbeat; chat β‰ˆ chat). | n/a | n/a | **P1** β€” no formal binding between the two governance systems; PMOVES agents reading `.spynel/AGENTS.md` get one set of constraints, Claude Code agents (Three-Body) get a different set. Risk: claim-register / CHIT trail could disagree on which lane was in flight. | | 9 | Prompt template override policy | All 10 templates under `.spynel/prompts/` are user-overridable; `skill_workshop` does not auto-modify managed skills (requires explicit user request). | Prompts present; no overrides observed. | Provides equivalent governance via `skill_workshop`'s "explicit user request only" rule (Hermes-gating-v6). The skills package enforces a stricter policy: a managed skill is *not* auto-modified by a preference or correction. | n/a | **P2** β€” parity is achieved at the policy level (both require explicit authorization); the Spynel-side contract is currently scoped to prompts/, while skills/ extends to skills, MEMORY/AGENTS/USER/TOOLS, and managed SKILL.md files. | | 10 | Notification-event coverage | `done, failed, cancelled` always dispatch a notification agent. Actionable `waiting` does the same. The notification agent decides and edits the log itself. | Documented and exercised via `notify.on` on observed task. The chat prompt also states "Do not contact the user or interpret later chat messages in this implementation session" β€” i.e. the implementation session does not send. | n/a | n/a | **P2** β€” boundary holds. | | 11 | `harness` block semantics in `.spynel/config.yaml` | The `harness` block declares the AI provider's name, reasoning effort, sandbox mode, and per-role prefixes. | Current: `name: codex`, `reasoning_effort: ""`, `sandbox: danger-full-access`, all prefixes empty. Empty prefix slots are a legal but unused state. | n/a | n/a | **P2** | -| 12 | SPYNEL_DOCS_GUIDANCE variable injection | Spynel injects a `{{SPYNEL_DOCS_GUIDANCE}}` placeholder into each prompt that resolves to a static pointer: "/home/powerfulmoves/.local/share/spynel/releases/0.12.12-1785263679/spynel docs ". | Observed at the top of `task.md` and `chat.md`. | n/a | n/a | **P2** | +| 12 | SPYNEL_DOCS_GUIDANCE variable injection | Spynel injects a `{{SPYNEL_DOCS_GUIDANCE}}` placeholder into each prompt that resolves to a static pointer: `~/.local/share/spynel/releases//spynel docs `. | Observed at the top of `task.md` and `chat.md`. | n/a | n/a | **P2** | | 13 | `completion_summary` field discipline | Direct-completion `done` requires `verdict: completed, outcome, evidence, uncertainty, completed_at` matching `updated_at` exactly in UTC. | Documented in `.spynel/tasks/AGENTS.md`; this task will populate it on direct completion. | n/a | n/a | **P2** β€” enforced on completion. | | 14 | Orchestrator / semantic-heartbeat behavior | `orchestrator.enabled: true`, `semantic_heartbeat_minutes: 15`, `task_notifications: decide`, `max_parallel: 4`. | All four set in `.spynel/config.yaml` and consistent with the contract. | n/a | n/a | **P2** | | 15 | Theme / extension governance | Themes are user-overridable, validated names with required colors. Extensions are trusted executable code; review before install. | 12 themes under `.spynel/themes/` (spynel, catppuccin-latte, github-colorblind-dark, gruvbox-light/dark, hack-the-box, nord, okabe-ito-dark/light, rose-pine-dawn, solarized-light, tol-muted-light). `extensions/README.md` is the only file under `extensions/` (an empty vendor directory); install gate is documented. | n/a | n/a | **P2** β€” clean. | diff --git a/pmoves/tests/spynel/test_spynel_document_timestamps.py b/pmoves/tests/spynel/test_spynel_document_timestamps.py index ef0769c4e1..4bbedece98 100644 --- a/pmoves/tests/spynel/test_spynel_document_timestamps.py +++ b/pmoves/tests/spynel/test_spynel_document_timestamps.py @@ -37,11 +37,21 @@ def _documents() -> list[Path]: def _front_matter(path: Path) -> dict: text = path.read_text(encoding="utf-8") + # Tolerate CRLF checkouts before the startswith probe. + if text.startswith("---\r\n"): + text = text.replace("\r\n", "\n") if not text.startswith("---\n"): pytest.fail(f"{path}: no YAML front matter") - end = text.find("\n---", 3) + # Search past a possible leading '---' value line: start at the first newline + # so a multiline VALUE containing '\n---' inside a block scalar cannot truncate + # the front matter before the real terminator. + first_nl = text.find("\n") + end = text.find("\n---\n", first_nl + 1) if end == -1: - pytest.fail(f"{path}: unterminated YAML front matter") + # Last resort: terminator at EOF without trailing newline. + end = text.find("\n---", first_nl + 1) + if end == -1: + pytest.fail(f"{path}: unterminated YAML front matter") data = yaml.safe_load(text[4:end]) if not isinstance(data, dict): pytest.fail(f"{path}: front matter is not a mapping") @@ -49,13 +59,17 @@ def _front_matter(path: Path) -> dict: def _timestamp_fields(node, prefix: str = ""): - """Yield (dotted_name, value) for every key ending in `_at`, at any depth.""" + """Yield (dotted_name, value) for every key ending in `_at`, at any depth, + including keys inside lists of mappings.""" if isinstance(node, dict): for key, value in node.items(): name = f"{prefix}{key}" if str(key).endswith("_at"): yield name, value yield from _timestamp_fields(value, f"{name}.") + elif isinstance(node, list): + for i, item in enumerate(node): + yield from _timestamp_fields(item, f"{prefix}{i}.") def _instant(name: str, value, path: Path) -> dt.datetime: diff --git a/pmoves/tests/test_identity_binding.py b/pmoves/tests/test_identity_binding.py index 335eb79ff4..038618de27 100644 --- a/pmoves/tests/test_identity_binding.py +++ b/pmoves/tests/test_identity_binding.py @@ -55,7 +55,16 @@ def _module(): return module -il = _module() +from functools import lru_cache + + +@lru_cache(maxsize=1) +def _il(): + # Lazy: identity_lineage.py is only executed when a test actually runs, + # so collection on a node without `.spynel/` (or without the tool's own + # import-time requirements satisfied) skips cleanly instead of breaking + # at import/collection time. + return _module() def _harness() -> dict: @@ -137,12 +146,14 @@ def test_appending_an_identity_does_not_break_the_binding(tmp_path, monkeypatch) widened.write_text(yaml.safe_dump(doc), encoding="utf-8") monkeypatch.setenv("PMOVES_IDENTITY_VOCABULARY", str(widened)) + il = _il() vocab = il.load_vocabulary() assert il.canonical_identity("APPEND-PROBE-IDENTITY", vocab) == "append-probe-identity" _assert_slots_carry_no_identity(_harness(), vocab=vocab) def _assert_slots_carry_no_identity(harness: dict, vocab=None) -> None: + il = _il() vocab = vocab if vocab is not None else il.load_vocabulary() offenders = {} for slot in sorted(_configured_slots(harness)):