Repository navigation
feat(sources): wire Grok account-data export parser - #3201
Conversation
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1353f3d422
ℹ️ 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".
| parser_paths=(), | ||
| normalizer_paths=(), | ||
| fixture_paths=("tests/unit/sources/test_origin_specs.py",), | ||
| "accepted", |
There was a problem hiding this comment.
Do not accept Grok without required schema evidence
When devtools provider-completeness --check runs, this accepted row is paired with schema_paths=() below, while provider_completeness._row_for_spec treats schema_package as required for accepted packages. The command therefore reports provider-package:grok-export/export-json@v1: schema_package is missing and exits 1, including for an unfiltered repository readiness check; add schema evidence or keep the mode non-accepted until that evidence exists.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4bc6c6b: downgraded this completeness mode's maturity from accepted to proposed (kept OriginSpec.lifecycle="executable" — the parser itself is real and admitted, only the schema-discovery evidence is missing), mirroring the precedent unknown-export/browser-capture already sets for a wired-but-unharvested origin. Verified with python -m devtools.provider_completeness --check: grok-export no longer appears in the accepted-blockers list. One caveat: the overall command still exits 1, but solely from a pre-existing, unrelated beads-issue row — confirmed via git show origin/master:polylogue/sources/origin_specs.py that beads-issue has had the identical accepted+schema_paths=() pattern since before this PR, i.e. this isn't something this change introduced. Filed polylogue-gt3g to track fixing that separately rather than expanding this PR's scope.
Problem: three CodeRabbit findings on the Grok export parser PR. 1. tests/unit/sources/test_provider_completeness.py indexed the old 'provider-package:grok-export/reserved@v1' key -- KeyError once origin_specs.py renamed the package ref to '.../export-json@v1'. This test was not in the original 69-test verification set. 2. origin_specs.py marked the grok export-json completeness mode maturity="accepted" with schema_paths=() (no harvested schema catalog exists for the reconstructed wire shape). provider_ completeness._row_for_spec treats an empty schema_paths as a required-item blocker for "accepted" rows, so `devtools provider-completeness --check` failed on the grok row. Downgraded maturity to "proposed" (matching the precedent set by unknown- export/browser-capture, which is real+wired but similarly lacks harvested schema evidence) with an explicit caveat. Confirmed via `git show origin/master:polylogue/sources/origin_specs.py` that beads-issue has had the identical accepted+schema_paths=() pattern since before this PR -- that pre-existing, unrelated `--check` failure is filed as polylogue-gt3g rather than fixed here. 3. dispatch.py's _lower_grok_export_payload admitted every mapping in the "conversations" list without checking grok.looks_like_ conversation, so a malformed entry alongside a valid one produced a phantom titled zero-message session. Applied the shape predicate per entry (skip silently on mismatch), matching how _bundle_record_specs already drops non-record ChatGPT/Claude AI bundle entries rather than emitting empty sessions per malformed item -- the established convention for partially-malformed bundles in this file. Verification: - devtools test tests/unit/sources/parsers/test_grok.py tests/unit/sources/parsers/test_origin_regression_pack.py tests/unit/sources/test_dispatch_ordering.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_origin_specs.py tests/unit/sources/test_provider_completeness.py -> 75 passed (adds a mixed-validity-wrapper regression: one valid + three malformed conversation shapes -> exactly the two valid sessions, original array-position ids preserved). - python -m devtools.provider_completeness --check -> grok-export no longer appears in the accepted-blockers list (now "proposed"; totals: 8 complete / 1 partial / 2 proposed). Overall exit code is still 1 solely from the pre-existing beads-issue row (polylogue-gt3g). - devtools verify --quick -> exit 0. Ref polylogue-y2hb Co-Authored-By: Claude <[email protected]>
Problem: grok-export was declared as a reserved Origin token with no
parser admitted (origin_specs.py, CLAUDE.md), even though the live
archive holds sessions tagged grok-export -- those turned out to be
browser-capture DOM scrapes of grok.com pages routed through the
generic browser_capture fallback parser, not a real Grok data-export
importer. xAI publishes no official export schema, so the wire shape
is reconstructed from independent secondary evidence: the open-source
grok-export-viewer tool (executable code parsing the real
prod-grok-backend.json export), ai-chat-importer.com's documented
sample, and a grok.com API-scraping userscript, all of which converge
on a `{"conversations": [{"conversation": {...}, "responses": [...]}]}`
document with no native conversation/message id.
Solution:
- New polylogue/sources/parsers/grok.py: looks_like_conversation /
looks_like_export detectors and parse_conversation, accepting both
the nested (`{"response": {...}}`) and flatter secondary-source
response shapes, and both MongoDB extended-JSON and plain timestamps.
provider_session_id/provider_message_id are synthesized from the
dispatch fallback id and file-relative position, the same convention
used for other id-less sources (Antigravity brain-artifact fragments).
- dispatch.py: registers grok detection in the loose dict-key tier
(after Claude AI, before Gemini -- tightness 85) in both the
single-record and one-element-sequence detection paths, adds
Provider.GROK to RECORD_DETECTOR_PROVIDER_ORDER, and adds
_lower_grok_export_payload to unwrap a one-file/N-conversation export
document into per-conversation ParsedSessions (using
_single_document_record so a full-ingest one-element-list wrap of a
lone document still parses, matching the existing gemini-cli/hermes/
antigravity convention).
- origin_specs.py: GROK_EXPORT flips from lifecycle="reserved" to a
real executable OriginSpec + completeness-mode row (maturity
"accepted", explicit caveat that no schema-discovery harvesting pass
has run against a real xAI sample).
- Removes the "reserved token, no wired parser" caveats from CLAUDE.md
and docs/architecture.md.
Verification:
- devtools test tests/unit/sources/parsers/test_grok.py
tests/unit/sources/parsers/test_origin_regression_pack.py
tests/unit/sources/test_dispatch_ordering.py
tests/unit/sources/test_dispatch_payloads.py
tests/unit/sources/test_origin_specs.py -> 69 passed (nested/flat
response shapes, Mongo-date and plain timestamps, missing/unknown
sender, empty conversations, multi-conversation bundle splitting
through the real detect_provider/parse_payload dispatch path,
one-element-list document wrapping, origin/dispatch-precedence laws).
- devtools verify --quick -> exit 0 (ruff format/check, mypy --strict,
render all --check, topology/layering/closure-matrix/manifests/
ci-workflows/doc-commands/docs-coverage/test-infra-currency/
test-clock-hygiene/pytest-timeout-overrides/degrade-loudly).
- devtools render topology-projection && devtools render
topology-status (new module under polylogue/).
- NOT run: the default `devtools verify` testmon-affected path --
testmon is unseeded on this fresh worktree checkout and two
--seed-testmon attempts in this heavily-loaded shared session did
not finish a full non-slow pass (partial progress showed scattered
pre-existing failures unrelated to sources/dispatch.py, consistent
with shared-machine contention from concurrent agent sessions, not
this change). The full targeted-test evidence above exercises every
changed line through the real dispatch path.
Ref polylogue-y2hb
Co-Authored-By: Claude <[email protected]>
Problem: three CodeRabbit findings on the Grok export parser PR. 1. tests/unit/sources/test_provider_completeness.py indexed the old 'provider-package:grok-export/reserved@v1' key -- KeyError once origin_specs.py renamed the package ref to '.../export-json@v1'. This test was not in the original 69-test verification set. 2. origin_specs.py marked the grok export-json completeness mode maturity="accepted" with schema_paths=() (no harvested schema catalog exists for the reconstructed wire shape). provider_ completeness._row_for_spec treats an empty schema_paths as a required-item blocker for "accepted" rows, so `devtools provider-completeness --check` failed on the grok row. Downgraded maturity to "proposed" (matching the precedent set by unknown- export/browser-capture, which is real+wired but similarly lacks harvested schema evidence) with an explicit caveat. Confirmed via `git show origin/master:polylogue/sources/origin_specs.py` that beads-issue has had the identical accepted+schema_paths=() pattern since before this PR -- that pre-existing, unrelated `--check` failure is filed as polylogue-gt3g rather than fixed here. 3. dispatch.py's _lower_grok_export_payload admitted every mapping in the "conversations" list without checking grok.looks_like_ conversation, so a malformed entry alongside a valid one produced a phantom titled zero-message session. Applied the shape predicate per entry (skip silently on mismatch), matching how _bundle_record_specs already drops non-record ChatGPT/Claude AI bundle entries rather than emitting empty sessions per malformed item -- the established convention for partially-malformed bundles in this file. Verification: - devtools test tests/unit/sources/parsers/test_grok.py tests/unit/sources/parsers/test_origin_regression_pack.py tests/unit/sources/test_dispatch_ordering.py tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_origin_specs.py tests/unit/sources/test_provider_completeness.py -> 75 passed (adds a mixed-validity-wrapper regression: one valid + three malformed conversation shapes -> exactly the two valid sessions, original array-position ids preserved). - python -m devtools.provider_completeness --check -> grok-export no longer appears in the accepted-blockers list (now "proposed"; totals: 8 complete / 1 partial / 2 proposed). Overall exit code is still 1 solely from the pre-existing beads-issue row (polylogue-gt3g). - devtools verify --quick -> exit 0. Ref polylogue-y2hb Co-Authored-By: Claude <[email protected]>
4bc6c6b to
1373b9c
Compare
## Summary Downgrade `Origin.BEADS_ISSUE` maturity from "accepted" to "proposed" to resolve the provider-completeness blocker that was causing `devtools provider-completeness --check` to fail repo-wide. ## Problem The beads-issue provider package was marked as `maturity="accepted"` with `schema_paths=()` (empty). The provider-completeness check treats an empty schema_paths as a missing schema_package, which becomes a required blocker for any "accepted" row, causing `devtools provider-completeness --check` to exit 1 with an "accepted provider-package blockers" error. This was a pre-existing issue that predated PR #3201 (grok-export). ## Solution Following the grok-export precedent from PR #3201, downgrade beads-issue to "proposed" maturity with an explicit caveat. The detector and parser are real and admitted (OriginSpec.lifecycle="executable"), but no schema-discovery harvesting pass has run against real Beads repository export samples. The wire shape is reconstructed from secondary sources (see polylogue/sources/parsers/beads.py), not a harvested provider-package catalog. Changes: - Modified `polylogue/sources/origin_specs.py`: downgrade BEADS_ISSUE completeness mode maturity from "accepted" to "proposed" - Updated caveats to mirror grok-export wording style, explaining the schema gap and path to promotion to "accepted" ## Verification ``` python -m devtools.provider_completeness --check ``` Before: exits 1 with "accepted provider-package blockers: provider-package:beads-issue/issue-jsonl@v1: schema_package is missing" After: exits 0 with no blockers. Status shows: - beads-issue: proposed (previously accepted/partial) - grok-export: proposed (unchanged) - unknown-export: proposed (unchanged) - 8 complete origins (unchanged) Tests pass: `devtools test tests/unit/sources/test_origin_specs.py` — 4 tests, all passed Type check: `mypy --strict polylogue/sources/origin_specs.py` — Success Ref polylogue-gt3g Co-authored-by: Claude Fable 5 <[email protected]>
## Summary Closes the remaining conformance-law gaps in the OriginSpec admission kernel (`polylogue/sources/origin_specs.py`) against every clause of `polylogue-2qx.1.1`'s acceptance criteria: a public-origin/Provider-token leak guard, a stream/parser binding parity check against dispatch, and a live proof of the `lifecycle="reserved"` admission path. ## Problem `polylogue-2qx.1.1` asked for the OriginSpec admission kernel (built on the `polylogue/declarations` DeclarationSpec kernel from `polylogue-o21.1`) plus a conformance law where missing parser, stream/parser conflict, ambiguous detector order, absent fixture, undeclared coverage, leaked Provider token, and non-injective Provider-to-Origin collision each yield a source-locatable diagnostic. Auditing the live repo found the kernel **already exists on master** — `polylogue/sources/origin_specs.py` landed incrementally via unrelated feature PRs (#3051, #3087, #3088, #3092, #3201, #3228: Claude Workflow admission, Hermes ATOF/ATIF, the Grok parser, provider_completeness migration) without ever citing this bead, so `bd`'s tracking never reflected it — the 2026-07-18 warroom sweep found no bead-tagged commits and reset the bead to open even though the code was there. It already covers all 11 `Origin` tokens, consumes the declarations kernel correctly, and is wired into `provider_completeness.py`, the artifact taxonomy, the live watcher, and Claude Code orchestration. Auditing it clause-by-clause against the AC found three real gaps: 1. No diagnostic caught a public origin `public_name` colliding with a raw `Provider`-wire token — the doctrine in `docs/provider-origin-identity.md` ("no provider wording on public origin surfaces") was enforced only indirectly (public_name must equal `origin.value`, and no current `Origin`/`Provider` pair happens to collide), with no explicit guard or diagnostic for a future collision. 2. No check parity-verified declared `stream_parser_path` presence against `sources/dispatch.py:STREAM_RECORD_PROVIDERS` — a stream/parser binding could silently drift from dispatch's actual streaming behavior with no diagnostic. 3. The module docstring still claimed a live "reserved origin" pilot, but Grok shipped a real parser (`polylogue-611`, #3201) after this bead was written, so no `OriginSpec` is currently `lifecycle="reserved"` and that admission path had no live proof. ## Solution - Added `_PROVIDER_TOKEN_VALUES` and a guard in `OriginSpecRegistry.register()` that rejects a declaration whose `public_name` collides with any `Provider` enum value, ordered before the existing public-name/origin equality check so it is independently testable (a synthetic declaration can trip it without also tripping the equality check). - Added `validate_stream_parser_parity()`, parity-checked against `sources/dispatch.py:STREAM_RECORD_PROVIDERS` the same way `validate_dispatch_precedence()` already parity-checks detector tightness order. **Zero edits to `dispatch.py`** — only a new read-only import of its existing `STREAM_RECORD_PROVIDERS` constant, respecting this slice's ownership boundary with the concurrent `ingest_worker.py`/`decoders.py` lane. - Updated the module docstring to honestly state Grok's promotion from reserved to executable, and point at the new synthetic reserved-lifecycle test as the live proof of that admission path (since no real production `Origin` is currently reserved). - Added five tests to `tests/unit/sources/test_origin_specs.py`: undeclared- coverage rejection, provider-token-leak rejection, a synthetic `lifecycle="reserved"` registration (built via `replace()` of the real Grok spec) proving the reserved admission contract requires no parser/detector tightness while still requiring coverage/fixture evidence, and positive plus negative stream/parser parity checks. ## Verification - `devtools test tests/unit/sources/test_origin_specs.py` → 8 passed - `devtools test tests/unit/sources/test_dispatch_ordering.py tests/unit/sources/test_dispatch_payloads.py` → 21 passed - `devtools test -k "provider_completeness or origin_specs or dispatch_ordering"` → 26 passed - `mypy --strict polylogue/sources/origin_specs.py tests/unit/sources/test_origin_specs.py` → Success, no issues found - `devtools verify --quick` → exit 0 (all 16 steps ok: format, lint, mypy, render all, topology, layering, closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands, docs-coverage, test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly) - No new module/file added, so no topology projection regen was required. ## AC matrix | # | AC | Status | | --- | --- | --- | | 1 | `origin_specs.py` defines complete typed fields/lifecycle states, consumes `polylogue/declarations` without adding source semantics to that kernel | Satisfied (pre-existing on master; verified by reading `polylogue/declarations/*` and confirming `origin_specs.py` only wraps `DeclarationSpec`/`DeclarationRegistry`, adding no kernel-layer semantics) | | 2 | Claude Code / ChatGPT / reserved Grok pilots derive/validate deterministic tightness, parser/assembly registration, public origin values, coverage/completeness rows, fixtures, docs, reparse consequences from one declaration each | Satisfied for Claude Code (executable, tightness 60, stream+artifact-rule bindings) and ChatGPT (executable, tightness 70). Grok itself is now executable (real parser shipped after this bead was written, #3201) rather than reserved; the reserved-lifecycle admission contract is proven live by this PR's new synthetic test rather than by a real reserved origin, since every current public `Origin` token is admitted as executable or compatibility-only | | 3 | `dispatch.py` uses derived registration/order or is parity-checked by it; adding a synthetic executable origin requires one OriginSpec + adapter + fixtures | Satisfied — `validate_dispatch_precedence()` (pre-existing) plus this PR's new `validate_stream_parser_parity()` parity-check `dispatch.py`'s `RECORD_DETECTOR_PROVIDER_ORDER`/`STREAM_RECORD_PROVIDERS` without restructuring dispatch.py | | 4 | Missing parser / stream-parser conflict / ambiguous or cyclic detector order / absent fixture / undeclared coverage / leaked Provider token / non-injective collision each yield a source-locatable diagnostic + repair | Satisfied — missing parser, absent fixture, and non-injective collision without policy were pre-existing `ValueError` raises (now also covered by a dedicated undeclared-coverage test in this PR); ambiguous detector order was pre-existing (`ambiguous_detector_tightness`); this PR adds the previously-missing stream/parser-conflict diagnostic (`stream_parser_parity_mismatch`) and leaked-Provider-token guard. "Cyclic" detector order has no distinct failure mode beyond ambiguous tightness, since tightness is a total order, not a graph | | 5 | Provider stays in adapters, Origin is the public vocabulary, Gemini/Drive-style collisions require an explicit collision policy | Satisfied (pre-existing `collision_policy` field + registration guard, exercised by `aistudio-drive`'s `Provider.GEMINI`/`Provider.DRIVE` fiber) | | 6 | Focused declaration/dispatch/public-schema/completeness/fixture/mutation/render/quick verification passes | Satisfied — see Verification section above | `polylogue-2qx.1.2` (migrate every current origin onto OriginSpec, delete parallel inventories) is explicitly out of this slice's scope per the bead's own design text — it is largely already superseded in practice too (all 11 origins are already declared here and `provider_completeness.py` already projects from `ORIGIN_SPECS`), but a formal audit of that bead's own AC (exact-eleven-token enumeration, parallel-inventory deletion, dispatch golden fixture) is left to whoever picks it up. Ref polylogue-2qx.1.1 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented origin names from exposing internal provider terminology. * Added validation to ensure origin evidence is complete before registration. * Improved consistency checks for origins that support streaming data. * **New Features** * Added support for reserved-lifecycle origins used in fixtures, including required supporting evidence without requiring parser configuration. * Added diagnostics for mismatches between streaming capabilities and origin configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <[email protected]>
…gue-2qx.1.2) (#3250) ## Summary Audits and closes the remaining gap in polylogue-2qx.1.2 ("migrate every current origin onto OriginSpec"). Most of this bead's scope was already shipped to `master` untagged across #3051/#3087/#3088/#3092/#3201/#3228/#3246 (closing `polylogue-2qx.1.1`'s notes confirm this). This PR verifies that prior work end-to-end, proves the parity checks actually catch regressions (not just pass today), and closes one concrete residual gap: a second, un-declared provider-to-assembly-hook dispatch that Claude Code, Codex, and AI Studio/Drive depend on. ## Problem `polylogue/sources/origin_specs.py` already declares all eleven `Origin` tokens with lifecycle/detector-tightness/parser/fixture/coverage bindings, and `polylogue/sources/provider_completeness.py` already derives its rows from `ORIGIN_SPECS` (`PACKAGE_MODE_SPECS` is a tuple comprehension over it, parity-proven by `test_provider_completeness_is_a_projection_of_every_origin_spec`). Dispatch-order and stream-parser-binding parity are also already mechanically checked (`validate_dispatch_precedence`, `validate_stream_parser_parity`) against the real production values in `sources/dispatch.py` (`RECORD_DETECTOR_PROVIDER_ORDER`, `STREAM_RECORD_PROVIDERS`). What was genuinely missing: the bead's design explicitly calls for "Claude Code and Codex specs [to] expose typed assembly/orchestration/title/action extension hooks (consumed later by 2qx.2, j2zz, ih67) — a typed field on the spec, not another registry." `polylogue.sources.assembly.get_assembly_spec()` is exactly that second, un-declared provider dispatch (`ProviderAssemblySpec` factory for `Provider.CLAUDE_CODE`/`Provider.CODEX`/ `Provider.GEMINI`) — it existed in production but had no OriginSpec declaration or parity check, so a caller had no way to discover the hook from `origin_specs.py` and no test would catch it drifting from the real registry. Also: `docs/provider-origin-identity.md` documented Provider/Origin/Source doctrine but never pointed at `origin_specs.py` as the per-origin admission authority a reader should trust over any hand-maintained list. ## Solution - `polylogue/sources/origin_specs.py`: added `OriginSpec.assembly_spec_path` (`"module/path.py:ClassName"` or `None`) declaring which `ProviderAssemblySpec` a given origin's provider wire binds. Populated for the three origins with a real live hook: `claude-code-session` → `assembly_claude_code.py:ClaudeCodeAssemblySpec`, `codex-session` → `assembly_codex.py:CodexAssemblySpec`, `aistudio-drive` → `assembly_gemini.py:GeminiAssemblySpec` (its `Provider.GEMINI` wire is the one `get_assembly_spec` keys on). Added `validate_assembly_spec_parity()`, following the exact idiom of `validate_dispatch_precedence`/ `validate_stream_parser_parity`: it checks the declared field against the live `get_assembly_spec(provider)` return value rather than replacing that registry with a second one in `origin_specs.py`. - `tests/unit/sources/test_origin_specs.py`: two new tests — one asserting the three declared hook paths (and `None` for two origins without a live hook), one asserting `validate_assembly_spec_parity(get_assembly_spec) == ()` plus the mutation shape (a resolver that always returns `None` makes every origin that declares a hook path report `assembly_spec_parity_mismatch`). - `docs/provider-origin-identity.md`: added an "Origin admission" section naming `origin_specs.py` as the per-origin declaration authority and pointing at both live-production parity checks. - No parallel hand-maintained inventory was deleted, because the audit found none left inside my ownership (`polylogue/sources/**`) — see the residual below for the one still outstanding elsewhere. ### Residual found outside owned scope `polylogue/cli/shell_completion_values.py:_ORIGIN_DESCRIPTIONS` is a hand-maintained `dict[str, str]` of 8 of the 11 origin tokens (missing `beads-issue`, `grok-export`, `unknown-export`) used for shell-completion help text, and it is **not** parity-checked against `Origin`/`ORIGIN_SPECS` the way `polylogue/agent_integration/spec.py:ORIGIN_MEANINGS` already is (that one has a `RuntimeError` guard requiring exact `Origin`-enum order match — already satisfies AC4, no action needed there). `cli/**` is out of this lane's ownership (per dispatch instructions, another lane owns it concurrently); flagging as a follow-up rather than touching it here. ## Verification - `devtools test tests/unit/sources/test_origin_specs.py tests/unit/sources/test_provider_completeness.py` → **15 passed** - `devtools test tests/unit/sources/ -k "origin_specs or provider_completeness or dispatch or assembly"` → **144 passed** - `devtools test tests/unit/sources/test_parsers_props.py` (protected file) → **43 passed** - `devtools verify --quick` → all 16 steps `ok`, `"exit_code": 0` (ruff format/check, mypy --strict, render all, topology/layering/closure-matrix, manifests, ci-workflows, doc-commands, docs-coverage, test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly) - Anti-vacuity mutations, run manually then reverted (`git checkout --`), each confirmed the *existing* production dependency actually fails on the mutation before I added anything: - Removing `_grok_spec()` from the registration loop → `ORIGIN_SPEC_REGISTRY.diagnostics()` reports `missing_origin_spec` for `grok-export`. - Dropping Claude Code's `detector_tightness` below `gemini_cli_session`'s (contradicting its real last-in-branch-order position) → `validate_dispatch_precedence(RECORD_DETECTOR_PROVIDER_ORDER)` reports `dispatch_tightness_mismatch`. - Deleting Codex's new `assembly_spec_path` declaration → `validate_assembly_spec_parity(get_assembly_spec)` reports `assembly_spec_parity_mismatch` for `codex-session` (this is the mutation the new code in this PR is proven against). ## AC matrix (polylogue-2qx.1.2) 1. **Satisfied (pre-existing).** All eleven `Origin` tokens are declared exactly once in `ORIGIN_SPECS`; `set(by_origin) == set(Origin)` is asserted in `test_origin_specs_cover_the_public_enum_and_admission_lifecycles`, and `OriginSpecRegistry.diagnostics()` emits `missing_origin_spec` for any omission (proven above). 2. **Satisfied (pre-existing + this PR).** Every executable origin declares acquisition modes, detector/parser/stream-parser/fixture/coverage/fidelity/reparse fields; `claude-code-session` additionally declares 6 typed `OriginArtifactRule`s for its workflow/journal/transcript/sidecar/adopt-manifest/coordinator-stream family. `grok-export` is `lifecycle="executable"` today (it shipped a real parser via #3201/polylogue-611 after 2qx.1.1's pilot design assumed it would stay reserved — documented at the top of `origin_specs.py`); the `reserved` lifecycle contract itself is proven against a synthetic variant since no current `Origin` is genuinely reserved. `unknown-export` is `lifecycle="compatibility-only"` with explicit fallback semantics; `beads-issue` is executable with `issue-jsonl` acquisition and its own non-`accepted` completeness maturity caveat (no harvested schema sample yet). This PR adds the Claude/Codex/AI-Studio assembly hook declaration. 3. **Satisfied (pre-existing).** `validate_dispatch_precedence`/`validate_stream_parser_parity` parity-check tightness and stream-binding against `sources/dispatch.py`'s real `RECORD_DETECTOR_PROVIDER_ORDER`/`STREAM_RECORD_PROVIDERS`; mutation-proven above (deleting/reordering a declaration fails). 4. **Satisfied (pre-existing) for `provider_completeness.py`; this PR extends it to the assembly-hook axis.** `PACKAGE_MODE_SPECS` is a direct tuple comprehension over `ORIGIN_SPECS`, parity-proven by `test_provider_completeness_is_a_projection_of_every_origin_spec`. `agent_integration/spec.py:ORIGIN_MEANINGS` is separately parity-guarded against `Origin` at import time. **Deferred**: `cli/shell_completion_values.py:_ORIGIN_DESCRIPTIONS` remains a stale, un-parity-checked hand-maintained inventory — out of this lane's ownership (`cli/**`), flagged as a residual above rather than a named follow-up bead (small, mechanical, single-file fix for whichever lane next touches CLI completions). 5. **Satisfied (pre-existing).** `aistudio-drive`'s `provider_wires=(Provider.GEMINI, Provider.DRIVE)` with `collision_policy` is registration-enforced (`OriginSpecRegistry.register` raises `ValueError` if `len(provider_wires) > 1` without a `collision_policy`, tested in `test_origin_spec_rejects_missing_fixture_and_noninjective_collision_without_policy`); `docs/provider-origin-identity.md` already documented the non-reversal doctrine, and this PR adds the pointer from that doc to the enforcing code. 6. **Misframed — recorded honestly rather than claimed satisfied.** `polylogue-2qx.2` (Claude Code orchestration artifact admission) already closed via PR #3088, and its own close reason states it shipped as a `claude_workflow_materializer` convergence stage *without* the OriginSpec migration this bead was meant to gate — the blocking edge was explicitly force-closed as "over-blocking" because the merged implementation disproves that ordering. So AC6 as written ("Claude/Codex extension hooks are the only admission path used by 2qx.2...") cannot be retroactively true for `2qx.2`. `j2zz` (Codex child-action lowering) and `ih67` (Codex title enrichment) are still open; this PR's new `assembly_spec_path`/`validate_assembly_spec_parity` gives them a real typed admission point to consume going forward, but I did not modify `assembly_codex.py`/`ih67`/`j2zz` scope — those remain their own beads' work, not migrated by me here. ## Files touched - `polylogue/sources/origin_specs.py` - `tests/unit/sources/test_origin_specs.py` - `docs/provider-origin-identity.md` Ref polylogue-2qx.1.2 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Added guidance on how origin metadata is declared, validated, and kept aligned with runtime behavior. - Documented checks for provider completeness and assembly-related configuration. - **Improvements** - Added validation to detect mismatches between declared origin capabilities and available assembly behavior. - Added assembly configuration metadata for Claude Code, Codex, and AI Studio origins. - **Tests** - Added coverage confirming assembly declarations and runtime parity checks behave as expected. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Wires a real parser for the
grok-exportOrigin, which was previously declared as a reserved token with no admitted parser.Problem
Origin.GROK_EXPORT/Provider.GROKexisted in the vocabulary (core/enums.py,core/sources.py) with a fullProvider <-> Originmapping, butorigin_specs.pydeclared itlifecycle="reserved"with no parser bound, andCLAUDE.md/docs/architecture.mdstated "no wired parser yet".Investigating the live archive (read-only) showed 16
raw_sessionsrows already taggedorigin='grok-export'— but these are browser-capture DOM scrapes of grok.com/X pages (capture_id: "grok:dom:...",adapter_name: "grok-dom-v1"), routed through the genericbrowser_capture.pyfallback parser (which maps anysession.providerstring throughProvider.from_stringwith no Grok-specific logic). That acquisition path was already correctly wired and is untouched by this PR. What was actually missing is a parser for a genuine Grok account-data export document (the file a user downloads from grok.com/X settings), which is whatpolylogue-y2hbasked for.xAI publishes no official export schema. The wire shape here is reconstructed from three independent secondary sources that converge on the same structure:
core.pyparses the real export file (namedprod-grok-backend.jsonby xAI):data["conversations"]→ each item hasitem["conversation"]["title"]/item["responses"], each response nested asr["response"]["sender"]/r["response"]["message"].conversations/conversation/responsestop-level shape, documentscreate_timeas MongoDB extended JSON ({"$date": {"$numberLong": "..."}}), and explicitly states the export has no conversation id, no attachments/images.sender/message/createTimefield names live from grok.com's own API, withsender === "human"for the user turn.Solution
polylogue/sources/parsers/grok.py(new):looks_like_conversation/looks_like_exportdetectors andparse_conversation. Accepts both the nested ({"response": {...}}) production shape and the flatter shape some secondary docs show, plus both MongoDB extended-JSON and plain ISO/epoch timestamps. Since no confirmed shape carries a native conversation or message id,provider_session_id/provider_message_idare synthesized from the dispatch-provided fallback id and file-relative position — the same conventionantigravity.pyuses for its id-less brain-artifact fragments.polylogue/sources/dispatch.py: registers Grok detection in the loose dict-key tier (after Claude AI, before Gemini) in both the single-record and one-element-sequence detection paths; addsProvider.GROKtoRECORD_DETECTOR_PROVIDER_ORDERat the matching position; adds_lower_grok_export_payloadto unwrap a one-file/N-conversation export document into per-conversationParsedSessions via_single_document_record(so a full-ingest one-element-list wrap of a lone document still parses — the same fix class as the existing gemini-cli/hermes/antigravity regression).polylogue/sources/origin_specs.py:Origin.GROK_EXPORTflips fromlifecycle="reserved"to a real executableOriginSpec(detector_tightness=85, between Claude AI's 80 and AI Studio/Drive's 90) plus a completeness-mode row (maturity="accepted") carrying an explicit caveat that no schema-discovery harvesting pass has run against a real xAI export sample.CLAUDE.mdanddocs/architecture.md.Not changed
sources/parsers/browser_capture.py) — already correct, untouched.polylogue/agent_integration/spec.py'sOriginMeaning("grok-export", "Grok conversation exports.")anddocs/agent-manual.md/docs/agent-integration-reference.md— already accurate, no "reserved" wording to remove.Verification
Covers: nested/flat response shapes, Mongo-date and plain timestamps, missing/unknown sender, empty conversations, blank-message skipping, malformed date payloads, multi-conversation bundle splitting through the real
detect_provider/parse_payloaddispatch path, one-element-list document wrapping, and theOriginSpecdispatch-precedence/admission laws.ruff format/check, mypy --strict,
render all --check, topology/layering/closure-matrix/manifests/ci-workflows/doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/degrade-loudly.(new module under
polylogue/).Not run: the default
devtools verifytestmon-affected path. Testmon is unseeded on this fresh worktree checkout, and two--seed-testmon --skip-slowattempts in this heavily-loaded shared session (multiple concurrent agent test runs observed on the box) did not finish a full non-slow pass — the second attempt ran 855s and still reported"status": "incomplete"withexpected_count: 16585. The scattered failures visible mid-run spanned modules unrelated tosources//dispatch.py, consistent with shared-machine contention rather than this change. The targeted-test evidence above exercises every changed line through the real dispatch path; pre-merge CI will run the full suite.Ref polylogue-y2hb