Skip to content

feat(annotations): seed ontology schemas and governed bootstrap lifecycle - #3059

Merged
Sinity merged 2 commits into
masterfrom
feature/annotations/seed-ontology-dve1
Jul 18, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/annotations/seed-ontology-dve1

Conversation

@Sinity

@Sinity Sinity commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Implements polylogue-dve1: five versioned v1 seed annotation schemas
(activity, goal-event, outcome-evidence, knowledge-artifact,
reusability) plus a governed archive-local ontology candidate/bootstrap
lifecycle (nominate -> accept/rename/split/reject), landed on the
existing typed-annotation substrate (annotation_schemas,
annotation_batches, assertions).

Problem

polylogue-dve1 asks for packaged seed ontologies plus an ontology
bootstrap loop where informal tags/affinity can nominate ontology
candidates but never become formal ontology facts without a judged
annotation batch/schema. No such packaged vocabulary or governance
state machine existed yet.

Solution

  • polylogue/annotations/schema.py: five new AnnotationSchema
    constants (seed.activity@v1, seed.goal-event@v1,
    seed.outcome-evidence@v1, seed.knowledge-artifact@v1,
    seed.reusability@v1), added to BUILTIN_ANNOTATION_SCHEMAS
    alongside the pre-existing delegation.discourse@v1.
  • polylogue/storage/sqlite/archive_tiers/user_annotations.py:
    persist_builtin_annotation_schemas() replays the six built-in rows
    idempotently; wired into bootstrap.py for both fresh-DB init and
    same-version replay on an already-current user.db. No
    USER_SCHEMA_VERSION bump
    -- verified against current
    archive_tiers/user.py that annotation_schemas is already the
    immutable versioned registry and assertions.kind is plain TEXT
    with no CHECK constraint, so new vocabulary is pure data.
  • polylogue/annotations/write.py: OntologyCandidateNomination /
    nominate_ontology_candidate() writes a private, non-injected
    AssertionKind.ONTOLOGY_CANDIDATE row carrying source tag refs,
    affinity, classifier definition, multi-view proposals/agreement, and
    privacy/excision refs, kept structurally separate from confidence.
    OntologyCandidateGovernance / govern_ontology_candidate() runs
    the full read/judge/register/receipt sequence in one BEGIN IMMEDIATE, reusing judge_assertion_candidate() for the durable
    lifecycle and writing a deterministic AssertionKind.ONTOLOGY_GOVERNANCE
    receipt. Schema persistence failure rolls back the whole transaction.
  • Two new AssertionKind values wired through core/enums.py,
    user_write.py (candidate-review queue admission), user_audit.py
    (exhaustive per-kind audit), and regenerated
    docs/openapi/search.yaml / docs/schemas/cli-output/query-unit-envelope.schema.json.
  • polylogue/annotations/importer.py: the existing
    AnnotationBatchImportRequest route now resolves archive-local
    (operator-promoted) schemas via a one-schema local registry, without
    polluting the process-global registry.

Provenance and independent verification

This originated as external-agent packet ann-01-ontology-seed-r01
(GPT Pro wave 2, snapshot 536a53efac0cbe4a2473ad379e4db49ef3fce74d,
unreviewed). I treated its claims adversarially rather than trusting
its own TESTS.md:

  • Confirmed against live source (not the packet's assertion) that
    assertions.kind is unconstrained TEXT and annotation_schemas is
    the existing immutable versioned registry -- no user-tier DDL/migration
    needed, USER_SCHEMA_VERSION stays 9.
  • git apply --check against current origin/master (12 commits
    ahead of the packet's snapshot): clean, one 23-line hunk offset.
  • Found and fixed two real defects the packet's dependency-starved
    sandbox couldn't catch:
    • devtools verify layering failed (writer_module_entrypoint_inventory_mismatch)
      because docs/plans/layering.yaml wasn't updated for the new
      persist_builtin_annotation_schemas entrypoint. Confirmed this is
      a real regression, not pre-existing, by stash-testing the baseline
      (master alone: No layering violations found).
    • mypy --strict found 17 real errors: redundant cast(JSONValue, ...) calls, one list[str] assigned into a dict[str, JSONValue]
      dict-item position, and 8 test call sites indexing
      JSONValue | None with # type: ignore[index] comments that
      didn't even match the mypy version's actual error code
      (call-overload). Fixed via require_json_document() narrowing
      instead of suppressing.
  • Ran the two sqlite-vec-dependent round-trip tests
    (test_write.py::TestAnnotationRoundtripWithQueryAndJudge) the
    packet's bare container couldn't execute -- both pass here.

Verification

devtools test tests/unit/annotations/ tests/unit/storage/test_archive_tiers_assertions.py
-> 155 passed

devtools test tests/unit/annotations/test_schema.py tests/unit/annotations/test_write.py \
  tests/unit/storage/test_archive_tiers_user_audit.py tests/unit/devtools/test_render_openapi.py \
  tests/unit/cli/test_cli_output_schemas.py tests/unit/storage/test_archive_tiers_ddl.py
-> 154 passed

devtools verify --quick
-> exit 0 (ruff format/check, mypy --strict, render all --check, layering + all lab policy checks)

Not run: the full non-quick devtools verify (testmon inner loop) and
the post-merge heavy CI test suite; per-PR CI intentionally skips it.

Ref polylogue-dve1

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e957677d-580a-438e-a7ea-0f61ab955d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 87a1f79 and ba59da7.

📒 Files selected for processing (16)
  • docs/data-model.md
  • docs/openapi/search.yaml
  • docs/plans/layering.yaml
  • docs/schemas/cli-output/query-unit-envelope.schema.json
  • polylogue/annotations/__init__.py
  • polylogue/annotations/importer.py
  • polylogue/annotations/schema.py
  • polylogue/annotations/write.py
  • polylogue/core/enums.py
  • polylogue/storage/sqlite/archive_tiers/bootstrap.py
  • polylogue/storage/sqlite/archive_tiers/user_annotations.py
  • polylogue/storage/sqlite/archive_tiers/user_audit.py
  • polylogue/storage/sqlite/archive_tiers/user_write.py
  • tests/unit/annotations/test_seed_ontology.py
  • tests/unit/cli/__snapshots__/test_plain_cli_snapshots.ambr
  • webui/src/api/generated.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/annotations/seed-ontology-dve1

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8668378ea

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sinity and others added 2 commits July 18, 2026 05:11
…ycle

Problem: polylogue-dve1 asks for versioned seed annotation schemas
(activity, goal-event, outcome-evidence, knowledge-artifact,
reusability) plus a governed archive-local ontology bootstrap where
informal tags can only ever nominate candidates, never mutate directly
into formal ontology facts.

Solution: five new AnnotationSchema definitions registered as
immutable v1 rows in BUILTIN_ANNOTATION_SCHEMAS, replayed data-only on
fresh and same-version user.db (no USER_SCHEMA_VERSION bump --
annotation_schemas is already the versioned registry and
assertions.kind is plain TEXT, verified against current
storage/sqlite/archive_tiers/user.py). Adds an
OntologyCandidateNomination/OntologyCandidateGovernance state machine
(nominate -> accept/rename/split/reject) that runs the full
read/judge/register/receipt sequence inside one BEGIN IMMEDIATE,
reusing the existing judge_assertion_candidate lifecycle. Two new
AssertionKind values (ONTOLOGY_CANDIDATE, ONTOLOGY_GOVERNANCE) wired
through enums.py, user_write.py candidate admission, user_audit.py
exhaustive audit, and the OpenAPI/CLI-output generated schemas.

Originated as external-agent packet ann-01-ontology-seed-r01 (GPT Pro
wave 2, snapshot 536a53e). Verified independently rather than
trusting the packet's own claims: reconciled two real defects the
packet's sandboxed environment could not catch --
docs/plans/layering.yaml was missing the new
persist_builtin_annotation_schemas entrypoint declaration (verify
layering failed clean on master, confirmed by stash-testing baseline),
and mypy --strict found 17 real errors (redundant JSONValue casts, a
list[str] vs list[JSONValue] dict-item mismatch, and 8 test call sites
indexing into JSONValue | None without narrowing -- fixed via
require_json_document instead of suppressing with type: ignore).

Verification:
- devtools test tests/unit/annotations/ tests/unit/storage/test_archive_tiers_assertions.py -> 155 passed
- devtools test tests/unit/annotations/test_schema.py tests/unit/annotations/test_write.py tests/unit/storage/test_archive_tiers_user_audit.py tests/unit/devtools/test_render_openapi.py tests/unit/cli/test_cli_output_schemas.py tests/unit/storage/test_archive_tiers_ddl.py -> 154 passed (includes the two sqlite-vec round-trip tests the packet's sandbox could not run)
- devtools verify --quick -> exit 0 (ruff format/check, mypy --strict, render all --check, layering, all lab checks)

Ref polylogue-dve1

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/annotations/seed-ontology-dve1 branch from e866837 to ba59da7 Compare July 18, 2026 03:14
@Sinity
Sinity merged commit b5c2722 into master Jul 18, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/annotations/seed-ontology-dve1 branch July 18, 2026 03:14
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 75.F078 / P2: refuted at the checked revision: The reported omission occurs in the old user.db migration route. AGENTS.md:74-77 forbids migrating predecessor archive state into fresh v1; the current same-version user bootstrap separately seeds annotation schemas at polylogue/storage/sqlite/archive_tiers/bootstrap.py:344, without admitting that historical upgrade path.

Only the rows listed above are dispositioned. Held findings remain open.

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