Skip to content

fix: preserve immutable built-in annotation definitions - #5869

Merged
Sinity merged 4 commits into
masterfrom
fix/annotation-definition-versions
Oct 1, 2026
Merged

Sinity merged 4 commits into
masterfrom
fix/annotation-definition-versions

Conversation

@Sinity

@Sinity Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

Register the five changed built-in seed annotation definitions at version 2. Ordinary USER opens retain their existing version 1 definitions, labels and batch provenance without rewriting history.

Problem

The phase/work-event retirement in PR5314 changed five definitions while retaining version 1. USER bootstrap replays packaged definitions, while durable annotation registration correctly refuses an occupied version with different canonical bytes. An ordinary supported predecessor reopen therefore refuses. Historical declarations containing retired target grains also failed live-only decoding before they could be inspected.

Solution

Ship current version 2 definitions for seed activity, goal event, outcome evidence, knowledge artifact and reusability. Preserve whichever supported version 1 definition an archive already holds, including definitions from the public commits immediately before and after PR5314. Historical decoding keeps declared provenance target strings and fingerprints; new registration, writes and imports retain live target admission. Retired structural targets produce explicit missing-target diagnostics. Conflicting occupied versions still refuse.

The existing versioned registry stores these vocabulary rows without changing USER DDL. Update the current CLI, MCP and daemon fixture consumers and document the current grains. Regressions use exact public historical definitions and neutral synthetic labels, with real facade-to-daemon import coverage on fresh and both historical archive variants.

Verification

Candidate 95514b47bf7493043a86288168caf091ca60d290, integrated with master 4dff4cf2b594bd6f9a3ded8f7dbf7bffa8fafb0c:

agentctl job start polylogue pytest_focused --workspace /realm/worktrees/polylogue-annotation-versions --json -- tests/unit/annotations tests/unit/storage/test_user_annotations_import.py tests/unit/storage/test_archive_tiers_user_write.py tests/unit/storage/test_archive_tiers_assertions.py tests/unit/storage/test_archive_tiers_archive.py tests/unit/storage/test_tier_bootstrap_transaction.py tests/unit/storage/test_archive_tiers_ddl.py tests/unit/core/test_schema_annotation_contracts.py tests/unit/core/test_operator_annotations.py tests/unit/cli/test_annotation_import_command.py tests/unit/cli/test_annotation_join_command.py tests/unit/cli/test_cli_operation_authority.py tests/unit/mcp/test_embedded_writer_boundary.py tests/unit/daemon/test_daemon_operation_route.py -p no:randomly

Job 5409: 493 passed in 114.66s; 493 selected = 493 terminal, one step, no retry. Receipt 20261001T051940Z-focused-test-4015920-2931845c records the same clean start and final head.

agentctl job start polylogue verify_quick --workspace /realm/worktrees/polylogue-annotation-versions --json

Job 5410: all 12 gates passed, exit 0; receipt 20261001T051942Z-quick-4016064-7beb3be8 binds the same clean head.

nix develop --accept-flake-config --command devtools schema closure --json polylogue/annotations/schema.py polylogue/annotations/batch.py polylogue/annotations/join.py polylogue/storage/sqlite/archive_tiers/user_annotations.py

Exit 0: schema, batch and user_annotations are inside the derived identity closure; join is outside. No new closure member. No live reconvergence was run.

Self-review

The author reread the project, storage, daemon and generic checklists and the whole 13-path diff. The final fourth author pass and integration delta are clean. All 12 non-overlapping owned blobs were preserved exactly during integration; the shared daemon test retains the upstream read-lifetime tests and the current seed version.

✓ Project 1 — siblings and owners. The five changed seeds share the existing schema registry and bootstrap persistence owner. Census covered schema/batch decoding, immutable persistence, joins, upsert writes, API/daemon imports, CLI and MCP consumers; four fixed seed-version fixture consumers now request v2. Historical target decoding has one schema-module owner.

✓ Project 2 — fix itself. Historical declaration decoding accepts only the two declared retired grains; registry registration and insertion call require_live_targets. Existing occupied rows still compare exact canonical bytes before an idempotent return. Live ObjectRef validation remains unchanged.

✓ Project 3 — memory and limits. The change introduces no archive-sized buffer, cap, timeout or truncation. Vocabulary sets contain the declared kinds; fixture snapshots contain five neutral seed records.

✓ Project 4 — cost per unit. Bootstrap still iterates the six packaged builtins. Only five new v2 rows are inserted once; reopen uses indexed schema_id/version lookups. Join adds constant-size kind and value validation per selected row.

✓ Project 5 — interruption. No transaction/lifecycle ownership changes. Existing bootstrap and daemon writer transactions own insertion and rollback; restarting twice is covered without altering recorded historical rows.

✓ Project 6 — ordering and races. No new check/use resource lifetime. Immutable schema comparison and insertion use the existing connection/transaction; no separately cached historical definition replaces durable evidence.

✓ Project 7 — failure classification. Unknown declarations, malformed target refs and occupied-version conflicts remain AnnotationSchemaError/AnnotationBatchError. New retired-target API imports are visibly DaemonOperationRejectedError; historical joins produce missing_target diagnostics.

✓ Project 8 — silent outcomes. Historical retired targets increment missing_target_count and carry an assertion/target diagnostic; they never enter live resolution or silently disappear. Invalid values and absent required evidence continue through invalid_value accounting.

✓ Project 9 — cleanup on failure. New production logic acquires no resource. Existing archive/context managers close connections; real daemon import tests inspect that rejected retired batches were not persisted.

✓ Project 10 — identity and keys. Only five current version numbers change. Definition JSON/fingerprint rules, batch/assertion references and producer fields are preserved. Fixtures pin exact public commits and assert byte/hash equality on both supported v1 variants.

✓ Project 11 — lossless transforms. Read DTOs preserve historical phase/work_event strings without relabeling. Raw schema, batch and assertion tuples are equal before and after two ordinary USER opens; explicit v1 references remain v1 while current writes stamp v2.

✓ Project 12 — degenerate inputs. Unknown target kinds and empty retired identities are refused. Historical decoder matches the public predecessor opaque colon grammar, including rejection of trailing empty identity qualifiers. Current schema validation remains unchanged for fields, evidence and abstention.

✓ Project 13 — consumers. Repository census of all five seed IDs found fixed-version daemon, MCP and two CLI fixture consumers, all updated. Production import requires an explicit version; current registry selects highest packaged v2. Unchanged delegation v1 remains v1; docs show current grains and historical contract.

✓ Project 14 — tests and stubs. Ordinary initialize_archive_database/ArchiveStore reopen and real Polylogue-to-daemon imports exercise production routes. Historical occupied-version mutations now use explicit open_existing(read_only=False) after the ordinary read-only block closes; all intentional fixture writes were censused against their actual authority. Reverting packaged versions to v1 makes historical open fail; removing retired admission guards makes registration/import refusal fail; removing immutable comparison makes occupied-version tests fail.

✓ Project 15 — trust boundaries. Tracked fixtures contain only canonical public definitions and neutral synthetic labels. No operator archive, capture, private receipt, secret or paid-provider call enters the diff.

✓ Storage 1 — derived migration. N/A: no index/ops DDL or migration change. Exact-head closure reports schema.py, batch.py and user_annotations.py inside the conservative derived identity closure; join.py is outside. No live reconvergence was run.

✓ Storage 2 — purchased vectors. N/A: no embeddings DDL, provider, vector or tier operation changes.

✓ Storage 3 — durable enum checks. N/A: USER DDL is unchanged; new versioned vocabulary rows use the existing annotation_schemas table and immutable write boundary.

✓ Storage 4 — writer authority. Production writes retain bootstrap or daemon writer ownership. SQL fixture setup is confined to synthetic test roots; no live archive mutation occurs.

✓ Storage 5 — durable authority. The existing durable schema row remains authority for historical reads and batch interpretation. A current global definition is never used to reinterpret an occupied v1 row.

✓ Daemon 1 — progress timeout. N/A: daemon product code and deadline semantics are unchanged; only its seed fixture version is updated and full operation-route coverage is selected.

✓ Daemon 2 — writer authority. Real facade imports continue through mutation.annotation.import_batch and the resident writer; no bypass is introduced. Embedded MCP and CLI authority tests are selected.

✓ Generic 1 — acceptance. Reproduction established ordinary USER-open refusal before edits. Both exact historical variants, fresh archives, restart, current writes/imports and immutable drift are covered. Final behavioral receipt records493 selected=493 terminal passed on the clean head; Independent local review is accepted; protected publication is required before landing.

✓ Generic 2 — exhaustive defect classes. Searched all annotation ObjectRef parsing, accepts_target_kind, registration and persistence consumers, and all five seed IDs. Corrected every fixed seed-version fixture found, plus both typing defects and the unnecessary closure-growing helper module in one batch.

✓ Generic 3 — replacement and consumers. Only current v2 seeds ship. No competing historical v1 definition is reinserted; the separate helper predecessor was deleted and every consumer imports the existing schema owner.

✓ Generic 4 — visible failures. Admission remains strict for new operations; historical decoding is provenance only. Drift and malformed evidence refuse visibly; retired structural targets report a named gap without fabricating a live target.

✓ Generic 5 — anti-vacuity. Tests name their mutants: reverting current seed versions fails ordinary supported reopen; overwriting historical rows fails raw tuple/fingerprint checks; permitting retired registration/write/import fails refusal assertions; bypassing immutable comparison fails current and historical occupied-version tests.

✓ Generic 6 — public boundary. Full diff reviewed against master4dff4cf2: 13 owned paths, neutral fixture data and public historical constructor definitions. Receipts, reproduction scripts and narrated evidence remain private scratch/Beads state.

Independent local review is clean and accepted at the exact candidate head. It independently compared all ten historical definitions against their public source commits and verified the final receipt boundaries. Hosted Codex review requests are disabled by the operator.

Residuals

Historical phase/work-event targets remain provenance and cannot be structurally resolved or newly written. No live archive operation, paid call, corpus run, USER DDL migration or host change was performed. The historical PR5314 finding remains held until accepted default-branch evidence.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-01T05:43:09.908186Z 95514b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity enabled auto-merge (squash) October 1, 2026 05:39
@Sinity
Sinity merged commit ca80dad into master Oct 1, 2026
3 checks passed
@Sinity
Sinity deleted the fix/annotation-definition-versions branch October 1, 2026 05:42
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