Repository navigation
docs(atlas): Add the doctrine sheet and refuse an unknown owning gate - #5352
Conversation
An atlas page may now declare which gate enforces the invariant a section describes, on an `**Owning gate**:` line. Each declared name is resolved against the live `devtools.gate.GATES_BY_NAME`, so a doctrine cannot keep naming a gate that has been deleted or renamed. The denominator is the registry itself rather than a copy of it here: a gate that leaves `GATES` disappears from the check's vocabulary on the next run with no edit to this module. `devtools gate doc-commands` already rejects a stale gate name written as a runnable `devtools gate` invocation inside a Markdown code segment. It never sees an owner written as a bare name, which is the residual this covers; both spellings are accepted so a sheet using the runnable form still resolves. The check rides inside the existing atlas gate and adds no new gate name. A value that is neither `none` nor a list of backticked gate tokens is a refusal rather than a skip, so prose cannot hide an unchecked owner beside a resolvable one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
Polylogue's seven standing invariants -- time, writer ownership, finding provenance, degradation, non-goals and revisit triggers, injected-context trust, unification -- had no written owner, gate, failure signal or change procedure anywhere a reader could find them. `grep -i doctrine docs/architecture-spine.md` returned nothing, so the route the epic's own criteria describe reached nothing. The sheet goes under `docs/atlas/` specifically because `devtools gate atlas` globs that directory and proves every `path:line` citation still resolves. Anywhere else under `docs/` gets no anchor enforcement at all. Each stanza names the invariant, its executable owner, its gate, the observable failure, and the change procedure, and points at the owner instead of restating an enum or a field list. Where source does not establish an owner the sheet records an open question rather than inventing one: finding provenance and injected-context trust have no repository gate, the layering gate does not prove process-level sole writership, and the sixth unification dimension the epic names does not exist in `CompatibilityKey`. The sheet is honest about what the gate buys. `devtools gate atlas` proves an anchor resolves; it makes no judgement about whether the prose around it is still true. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
Four recorded non-goals -- desktop-automation scope, OTLP-as-projection, context-bundles-are-not-authority, no one-off render palette -- survived only in tracker comment text. `docs/execution-plan.md`, which held them, was retired without the cross-check its own retirement note required, and no non-goals register existed anywhere in the repository. Each entry is now affirmed against current source with a citation, or recorded with its residual; none is carried forward silently. The palette entry is affirmed with a named residual: nine per-tool-kind card accents are still literal colour keywords rather than generated tokens, and no gate enforces palette centralization at all. Honest limit: this section has no independent automated guard. The atlas gate proves its citations resolve and nothing more; whether a non-goal is still the right call is a reviewer's judgement. A fifth salvaged candidate -- the closure-posture rule about certifying deployed truth -- is not a non-goal and is recorded under open questions rather than filed here to make the section look complete. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
The injected-context stanza cited scheduler.py:163-176, which starts four lines inside `_policy_is_authorized` and ends past its last refusal. The range now covers the predicate from its signature through the adoption check. The atlas gate could not catch this: every line in the old range exists. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (8)
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f5cfa334f
ℹ️ 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".
…#5356) ## Summary Three `o21` leaves on the query terminal-execution path. **This moves the index schema identity** — see the landing window below. ## polylogue-o21.5 — the 50k cap silently truncated, and it wasn't the only defect ### Pre-change behaviour at the boundary, measured not reasoned Probe with `_AGG_ROW_FETCH_CAP` monkeypatched to 2 over a 3-row population: ``` CAPPED metrics: [(None, 2, {'count': 2, 'sum_word_count': 8.0, 'avg_word_count': 4.0, ...})] CAPPED pipeline result: {..., 'exact': False, 'sampled_rows': 2} ``` **It silently truncates — it does not refuse** — and the truncation is only *partly* flagged. Metric values and per-group `count` describe the first N rows in time-ascending order. `pipeline.result.exact=false` and `sampled_rows` are set, but the terminal `outcome` stays `ok` and never `degraded`, `has_next` is computed over truncated groups, and `selected_rows_exact` becomes `None`. **A complete-looking envelope carrying sample numbers** — which is the outcome contract's `degraded`-outranks-`empty` rule violated at the other end. ### `percentile` lowered faithfully, and got *more* correct Nearest rank is an integer definition; the Python reducer computed `math.ceil(rank / 100 * n)` in binary floating point. Enumerated: **290 of 198,000 `(rank, n)` pairs for `n ≤ 2000` pick the wrong element** — e.g. `p7` over 100 distinct values selected the 8th smallest instead of the 7th. SQL uses exact integer arithmetic, `MAX(1, MIN(n, (rank * n + 99) / 100))`. Confirmed by mutation: replacing it with `CAST(CEIL(rank / 100.0 * n) AS INTEGER)` reproduces the float artifact in SQLite, so **the defect was the float, not the definition**. Deliberate behaviour change, stated in the commit message. ### The bead's concrete input is wrong twice `agg avg(duration_ms) by tool` cannot parse: the syntax is `| agg avg:FIELD`, and `duration_ms` is not in `action`'s `aggregate_metric_fields`. The entire non-count metric surface is **three** `(unit, field)` pairs — `message.word_count`, `action.is_error`, `action.exit_code`. A real input is `messages where role:assistant | agg avg:word_count`. ## polylogue-o21.8 — understated, not overstated The bead records that the audit tried to turn the duplicated field maps into a reachable wrong output and **failed**, so it is filed as consolidation. That holds for the bracket path it examined — but a reachable wrong output **does** exist on the aggregate path: `_AGGREGATE_ROW_FIELDS` had no `session.repo` entry for any unit, while `session.repo` is a declared `aggregate_group_fields` member for every SQL unit. Measured at base: `messages where role:assistant | group by session.repo | agg count, avg:word_count` returned **a single `[missing]` group over all rows**, while the `count` terminal on the same expression returned the two real repositories. A second divergence: `delegations | group by basis | agg count` grouped by raw `instruction_tool_use_block_id` values while the count terminal groups by the `edge`/`action` discriminator. The o21.8 commit stays framed as consolidation; the defect sits in the o21.5 commit, which is what fixes it. ## polylogue-o21.7 — the mirror was already broken at head The bead describes drift hypothetically. In fact `explanation_payload_to_ast` **rejected the producer's own output for any `| agg ...` expression** with 7 validation errors. It is a test-gate and published-schema defect rather than a live route failure — no production path calls it — but `docs/openapi/search.yaml` and `webui/src/api/generated.ts` described a shape the server does not emit. The existing parity test's corpus contained no `agg` case, which is why it survived. ### Byte-equivalence of the refactor Captured `explain_expression(...).to_payload()` for a 38-expression corpus covering every predicate kind, pipeline stage, clause kind, entry branch and conditional key. After converting all 28 producers to declaration-driven rendering: ``` IDENTICAL: 38 expressions, payloads equal after timestamp redaction ``` The only redaction is the `since:7d` relative-date resolution. `QUERY_DEFINITION_PROTOCOL_VERSION` untouched; `query_ref` identity cannot move, because predicate payloads are unchanged and `hash_payload` sorts keys. Wire change is additive plus one narrowing (`terminal.action` from `string` to `"rows" | "count" | "agg"`); nothing removed, nothing widened; no repository consumer reads these types. ## Anti-vacuity — nine mutations executed, all restored Including **G, the bead's exact o21.8 condition**: a *single* deletion of `"type": "message_type"` reddens **three** tests across both paths. Others: the `LIMIT 50000` restoration (`assert 50000 == 50001`), the float percentile (`{'p7_word_count': 8.0} != {'p7_word_count': 7.0}`), removing the progress handler (`DID NOT RAISE QueryWorkBudgetExceededError`), and `"avg": "SUM"` in the reducer map, caught by the cross-surface parity test. Mutation C reproduces the *observable* of the deleted lookup rather than literally restoring the Python reducer — **labelled as a proxy, not a literal restore**. Nothing material is reasoned-not-executed. ## Parity, pagination, cancellation - **Cancellation**: 20,000 rows through `InterruptibleSQLiteRead` with a 10,000-opcode budget; both the `agg` and `rows` branches raise with `receipt.interrupted is True`. - **Pagination**: a 5-group aggregate walked at offsets 0/2/4, asserting `selected_rows_exact == 5` on every page — the *total*, not the page. - **CLI/API/MCP/HTTP**: one grouped `agg` page walked through `Polylogue.query_units`, the daemon HTTP route and the MCP `query` tool, resuming by continuation between pages, all three compared against word counts the test computes itself. ## THE LANDING WINDOW **All three index fingerprints move; the index tier must reconverge. This must land before a fresh rebuild starts, never during one.** | | base `2bbecb9cd` | branch | | --- | --- | --- | | lowering | `74fafc04…` | `a9bdbc48…` | | materializer | `9dc1287d…` | `8216f7ff…` | | replay_routing | `eef8760e…` | `b14bb766…` | | **index identity** | `0356cac3…` | `1a1bda47…` | | ops identity | `3d18f2a0…` | unchanged | Closure membership is a **one-for-one swap, 555 → 555**: `payload_schema.py` enters, `query_ast_schema.py` leaves. **Two bead closure verdicts were wrong at my base**: `query_ast_schema.py` was recorded IN but measures **out** after the change (the schema module became downstream of the producers instead of upstream), and `render_openapi.py` is out. Neither `daemon/event_bus.py` nor `archive_tiers/ops_write.py` was touched. Useful for scheduling: **#5352, #5353 and #5354 did not move the identity** — `origin/master` read `0356cac3…` at 540228b, 51222af and 2bbecb9 alike. ## Verification (post-rebase) `devtools verify --quick` **exit 0**, all 25 gates including `schema-closure` and `controlled-read`. `devtools render all --check` exit 0, **0** lines matching `out of sync` (grepped, not inferred). Focused suites green across `tests/unit/archive`, the AST schema, field map, metadata, continuation parity, and the query exec laws. Broad selection of 2163 tests: **10 non-pass, all inherited**, proven by detached checkout of `origin/master` inside this worktree. One of those I'd have miscounted: `test_descriptor_runtime_transform_units_reject_aggregate_pipeline` is a **skip** (`got empty parameter set`), not a failure. ## Residuals - **`_LARGE_POPULATION` is pinned to the historically deleted bound (50,001), not to "any bound".** A future implementation introducing a cap *above* 50,000 would not be caught. No test can catch an unknown bound; the declared condition is the concrete one. - The 50k exactness test costs ~11 s. The size is deliberate — anything smaller stays green under mutation A. - `to_payload()` is derived, but four escape hatches remain in the declarations (`omit_when` callables ×2, read-only `payload_*` properties ×4). Declared per field, so no mirror exists, but they are hand-written logic. - `WithUnitWindow`, `SessionQueryPipeline` and `SessionQueryTerminalStage` keep hand-written `to_payload()` — not part of the published AST schema, so converting them would widen the diff without removing a mirror. Stated, not hidden. - Two follow-ups filed separately: `test_schema_closure.py`'s `IN_CLOSURE` roster is **stale at master** (`daemon/write_coordinator.py` left the closure and the test was not updated — 3 reds unrelated to this swap), and `analysis/orchestration_evidence.py:140` compares a possibly-`None` count with `>` (6 MCP reds, already filed as polylogue-w4hfb). Closes polylogue-o21.5, polylogue-o21.7, polylogue-o21.8. polylogue-o21.6 untouched. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added named aggregate metrics, including count, sum, average, minimum, maximum, and percentile calculations. * Added grouping support and paginated aggregate results across the Python API, HTTP API, MCP, and CLI. * Aggregate results are now exact across complete matching datasets, including large result sets and NULL values. * Added support for aggregate stages and metric results in API schemas and generated client types. * Expanded field resolution for grouping and bracket predicates across query unit types. * **Documentation** * Updated aggregate metric documentation with exact calculation and percentile behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
feat(devtools): Census every durable rewrite at statement grain Closes the blocking evidence gap that two prior polylogue-6kur AC4 audits both named in their own words: the durable-UPDATE census was grep-literal, so nobody could read AC4 as a proof of absence. WHAT THE GREP COULD NOT SEE The previous census matched `UPDATE <table>` against a generated durable table list. It therefore could not see `INSERT OR REPLACE`, `ON CONFLICT ... DO UPDATE`, interpolated table names, or a correction expressed as delete-then-reinsert. This replaces it with a statement-grain AST census. Measured at head: 138 durable rewrite sites and 33 caller-supplied-SQL helpers across source (84), audit (28), user (22) and 4 whose table does not resolve statically. By kind: 81 update, 36 delete, 17 upsert_do_update, 4 insert_or_replace. The last two kinds -- 21 sites -- are exactly the shapes the grep was structurally blind to. WHY IT IS NOT SUBSUMED BY AN EXISTING CENSUS layering's writer-module census is FILE grain: it proves which modules execute DML, so new DML added inside an already-listed module is invisible to it, and 26 of these sites live in modules it already lists. rebuild-routes censuses who can REACH a rebuild entrypoint; a direct UPDATE against a durable table reaches no rebuild entrypoint at all. ENFORCEABLE, NOT A DOCUMENT The campaign already refused to commit a 459-entry list because it would rot with no gate. So the deliverable is a check whose OUTPUT is the enumeration, carried by the existing `layering` gate -- no new gate name, the same choice #5352 made by putting its check inside `atlas`. WHAT THE RATCHET ASSERTS TODAY, STATED PRECISELY Every one of the 138 sites is pinned as `unclassified`, which means the census SAW the site -- not that the site is legitimate. The enforced property is that a NEW durable rewrite cannot appear undeclared. Adjudicating the existing 138 against the classification vocabulary (lifecycle_transition, guarded_producer_refinement, deliberate_redaction, two_phase_recovery, finite_actuator, declared_retention, row_supersession) is follow-up work, and until it happens this is NOT evidence that no masking backfill exists. Declaring `masking_backfill` fails the gate by design. ANTI-VACUITY, BOTH DIRECTIONS EXECUTED: * Add a new undeclared `UPDATE raw_sessions` to source_write.py -> `durable_write_undeclared` naming the exact site. Reverted. * Declare one existing site `masking_backfill` -> `durable_write_masks_a_producer` quoting "an after-the-fact correction of a value a producer got wrong". Reverted. * The clean tree reports 0 violations, so the check is not a blanket prohibition. VERIFICATION: devtools verify --quick exit 0, all gates including layering. devtools render all --check exit 0, zero "out of sync". Both new devtools modules measure schema-closure `out`, so the derived identity does not move and this can land during a rebuild. RESIDUAL, named rather than papered over: this closes G1 (the statement-grain denominator). G2 -- an exhaustive census of archive-wide derived corrective sweeps -- and G3 -- a systematic search for read-path masks -- are NOT closed. The one real backfill found at head was located only because it was in the named _repair_* family, so a _reconcile_*/_normalize_*/_converge_* twin would still be invisible, and the one read-path mask found was found incidentally. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
Summary
Adds
docs/atlas/doctrine.md— seven invariants, each naming its executableowner, owning gate, observable failure and change procedure — and makes the atlas
gate refuse a doctrine that names a gate which does not exist.
The sheet points at executable authority rather than restating it. It says so in
its own text: "When the sheet and the owner disagree, the owner wins and the
stanza is wrong."
Why this is more than prose
docs/atlas/is wheredevtools gate atlasproves every cited path and linerange still resolves, in the quick set. 41 anchors, gate exit 0.
cpf.9 is the executable half, and it is what keeps the other two honest.
devtools/verify_atlas.pyimportsGATES_BY_NAMEfromdevtools.gateandmembership-tests against the object. There is no name list in the checker, in
the test, or in a data file — and the tests derive both operands from the
registry too (the positive case uses
sorted(GATES_BY_NAME)[0]; the negative caseasserts its candidate is absent before using it). Neither the check nor its test
can outlive a renamed gate.
This is the defect class the campaign keeps hitting: a bead whose
verification_commandsnameddevtools verify portfolio-frontierstayeddispatchable-looking long after that command was deleted.
The gap this actually closes
devtools gate doc-commandsalready resolvesdevtools gate <name>against liveGATE_NAMESacross all ofdocs/**/*.md. That was probed empirically: abackticked
`devtools gate writer-ownership`in a new atlas page failsdoc-commands today. What passed both gates at head was the declarative form —
**Owning gate**: \writer-ownership`` — which is the real residual. The new checkaccepts both spellings and refuses any value it cannot parse, so prose cannot hide
an unchecked owner beside a resolvable one.
No new gate name:
devtools gate --listcount is unchanged at 29. The check ridesinside
verify_atlas.py::inspect, which the existingatlasgate already runs.What could and could not be established from code
core/temporal.py,verify_timestamp_doctrine.py,tests/infra/clock_guard.pytimestamp-doctrine— durable DDL only; weakest-source propagation has no gate, and the sheet says soverify_layering.py+layering.yaml+ census baselinelayering— the manifest's own comment says the inventory proves declaration, not exclusivity; no code proving process-level sole writership was found, recorded as an open question rather than asserted_finding_value,validate_control,finding_provenance.pysurfaces/outcome.py,devtools/sqlite_degradation.pylayering— traced the census intoverify_layering.py's blocking violation list rather than trusting the manifest keyatlas, citations only — no automated guard on the judgement, stated explicitly per cpf.8 rather than fabricatedderive_assertion_context_trust, theContextSourceProtocol,_policy_is_authorizedCompatibilityKey's five dimensions, the registration-time refusal, the scaffold's two refusalsdeclaration-bindings— established by reading the verifier importing the live module-level registries, which is what triggersregister()Two invariants have no gate at all, and the sheet records that as
nonewiththe reason instead of implying coverage.
Non-goals: affirmed against source, not carried forward
Three affirmed with citations. The fourth — the no-one-off-render-palette rule —
is affirmed with a named residual:
webui/src/styles.css:435-443declares nineper-tool-kind card accents as literal CSS colour keywords rather than generated
tokens, while
webui/src/generated/tokens.cssexists and is generated frompolylogue/ui/theme.py. Small, real, and unowned by any gate. No entry was carriedforward unchecked.
Anti-vacuity — executed
writer-ownership(absent from the registry)[BLOCK] docs/atlas/doctrine.md :: Doctrine: writer ownership :: unknown-gate :: writer-ownership, exit 1:13-9999missing-anchor :: polylogue/core/temporal.py:13-9999 (file has 85 lines)GATES_BY_NAMEresolutiondevtools gate atlasreturned exit 0 on a doctrine naming a nonexistent gate, proving the resolution call is load-bearing_entry("Atlas: Doctrine", …)render docs-surface: out of sync: docs/README.mdVerification
devtools verify --quick— exit 0, 24/24 gates, re-run after rebase(
atlasok,doc-commandsok)devtools render all --check— exit 0,grep -c 'out of sync'= 0devtools test tests/unit/devtools/test_verify_atlas.py— 11 passed (4pre-existing + 7 new)
devtools testover gate-registry, gate-independence, docs-surface anddoc-commands — 63 passed
devtools schema closure— all touched non-docs filesoutA blind spot found in my own sheet, and written down
The atlas gate proves an anchor resolves, not that the range is the right
range. After the rebase the anchors were re-checked by symbol against the prose,
which found one wrong range (
scheduler.py:163-176started four lines inside thefunction and ended past its last refusal) that the gate could not catch because
every line in it existed. Corrected. A range-vs-symbol check is conceivable but
needs a declaration surface; it was not built. The sheet records the limit.
Open questions recorded in the sheet, not invented answers
finding and tests prove it, but nothing detects a new finding-shaped write path
bypassing the projection function. cpf's own 2026-07-04 comment records that this
hook was mis-pointed at a docs-publishing lane and never re-filed.
ContextSourcefrom reaching operator-class output.CompatibilityKeycarries five."Remaining domain semantics" has no dimension in source — it is carried as the
scaffold's free-text
justification, which nothing validates. Either it belongsin
CompatibilityKeyor the sixth item should leave cpf's criteria. That is adesign decision, not made here.
the operator's live deployment and archive cannot certify deployed truth — is not
a non-goal and has no home. Recorded so the retirement that orphaned it does not
orphan it twice.
declaration surface exists to diff the sheet's terms against a generated
vocabulary without inventing machinery.
Scope
Two one-line expansions, both with a rationale:
devtools/gate.py'satlasdescription became false once the gate also resolves owning gates, and
devtools gate --listis the user-visible authority for what a gate does; and onetable row in
docs/atlas/00-core.md, because CLAUDE.md names it as the documentedatlas entry point, so a sheet absent from it is reachable from the spine but
invisible to the route agents are told to take.
Closes polylogue-cpf.7, polylogue-cpf.8, polylogue-cpf.9.
🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq