Repository navigation
feat(sources): ingest local agent sources - #1024
Conversation
Problem: downstream consumers need source-complete local agent data without ad hoc repair layers in Lynchpin, while insight products need clearer provenance around fallback and timing semantics. What changed: add Gemini CLI, Hermes, and Antigravity source discovery/parsing, schema packages, artifact taxonomy, live watcher support, and completion/config wiring. Antigravity uses the local language-server Markdown export path and keeps raw sidecars classified as metadata. Also harden session insight date/timing provenance, bounded work-event reads, schema audit annotation boundaries, and sync SQLite schema initialization under concurrent connections. Verification: nix develop -c devtools verify -> verify: all checks passed. Closes #1018 Closes #1020 Closes #1021 Closes #1023 Refs #1019 Refs #1022
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (68)
📝 WalkthroughWalkthroughThis PR adds three new local conversation sources (Gemini CLI, Hermes, Antigravity) to Polylogue with full parsing, discovery, and live-watch support; enriches session work-event and phase evidence with timing/date provenance fields; extends work-event insights with canonical-session-date filtering; and generates schema metadata for all three new providers. ChangesNew Local Conversation Sources: Type Definitions & Routing
Session Work-Event Provenance & Insights
Schema Metadata, Configuration, & Storage
Tests & Documentation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes The PR is substantial with multiple independent subsystems (three new parsers, provenance propagation across 8+ storage/archive modules, dispatch routing updates, schema metadata generation, and comprehensive test coverage). While many changes are repetitive or mechanical (applying the same provenance pattern to similar functions), the depth requires careful validation of:
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4dd4b42d31
ℹ️ 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".
| _PATH_ONLY_SIDECARS = { | ||
| "bridge-pointer.json": "bridge pointer sidecar", | ||
| "sessions-index.json": "session index sidecar", | ||
| "logs.json": "agent log sidecar", |
There was a problem hiding this comment.
Limit path-only sidecar names to provider-specific roots
Adding "logs.json" to _PATH_ONLY_SIDECARS makes classify_artifact_path() skip any file with that basename before payload inspection, regardless of provider. In sources where a real conversation document is named logs.json (custom inbox drops, third-party exports, or ZIP entries), ingestion now silently drops valid conversations as non-conversation sidecars; this should be scoped to the relevant agent providers/paths instead of globally filename-based.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds first-class ingestion and schema support for additional local agent sources (Gemini CLI, Hermes, Antigravity), while also hardening the durable session-insight surface (bounded canonical-date reads + explicit timing/date provenance) and reducing a sync SQLite schema initialization race.
Changes:
- Introduce new provider identities + parsers for
gemini-cli,hermes, andantigravity, including source discovery, dispatch integration, artifact taxonomy rules, and live watcher suffix support. - Extend session insight models/queries to expose timing/date provenance and add canonical session-date filters for work-event/phase reads.
- Serialize sync SQLite schema initialization per DB path to prevent concurrent fresh-DB bootstrap failures.
Reviewed changes
Copilot reviewed 68 out of 71 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| CHANGELOG.md | Documents new local-agent sources and insight query/provenance changes. |
| docs/plans/topology-target.yaml | Updates topology tracking metadata for new/changed modules. |
| docs/test-quality-workflows.md | Updates generated workflow registry snapshot and scenario listings. |
| docs/topology-status.md | Updates generated topology status counts. |
| docs/verification-catalog.md | Updates generated verification catalog counts and provider annotation subjects. |
| polylogue/archive/artifact_taxonomy/runtime.py | Adds Antigravity-specific path/payload classification and new sidecar handling. |
| polylogue/archive/artifact_taxonomy/support.py | Extends sidecar taxonomy (e.g., logs, Hermes request dumps). |
| polylogue/archive/conversation/extraction.py | Adds timing/date provenance fields to work-event payload export. |
| polylogue/archive/semantic/pricing.py | Adjusts Pydantic config to allow model_* fields. |
| polylogue/archive/session/documents.py | Extends phase/work-event document contracts with provenance fields. |
| polylogue/archive/session/models.py | Emits provenance in session phase payloads and adds provenance helpers. |
| polylogue/cli/shell_completion_values.py | Adds new providers to shell completion descriptions. |
| polylogue/config.py | Renames Drive Gemini source to aistudio and uses watcher-based discovery for new locals. |
| polylogue/core/provider_identity.py | Registers new runtime providers and aliases (e.g., aistudio). |
| polylogue/insights/archive.py | Extends insight query model to accept canonical session-date filters. |
| polylogue/insights/archive_models.py | Bumps insight contract version; adds provenance fields to evidence payloads. |
| polylogue/insights/registry.py | Adds CLI flags for --session-date-since/--session-date-until on work-events. |
| polylogue/operations/archive.py | Plumbs canonical session-date filters through archive operations layer. |
| polylogue/paths/init.py | Exposes new local roots: gemini-cli, hermes, antigravity. |
| polylogue/paths/_roots.py | Defines filesystem roots for new local-agent sources. |
| polylogue/pipeline/services/ingest_worker.py | Passes source_path into parsing dispatch for path-sensitive providers. |
| polylogue/schemas/audit/checks.py | Adds “high-cardinality keys” schema annotation boundary to avoid deep recursion. |
| polylogue/schemas/observation_models.py | Registers sampling config for gemini-cli, hermes, and antigravity. |
| polylogue/schemas/providers/antigravity/catalog.json | Adds Antigravity schema package catalog (generated). |
| polylogue/schemas/providers/antigravity/manifest.json | Adds Antigravity schema manifest (generated). |
| polylogue/schemas/providers/antigravity/versions/v1/package.json | Adds Antigravity v1 schema package metadata (generated). |
| polylogue/schemas/providers/gemini-cli/catalog.json | Adds Gemini CLI schema package catalog (generated). |
| polylogue/schemas/providers/gemini-cli/manifest.json | Adds Gemini CLI schema manifest (generated). |
| polylogue/schemas/providers/gemini-cli/versions/v1/package.json | Adds Gemini CLI v1 schema package metadata (generated). |
| polylogue/schemas/providers/hermes/catalog.json | Adds Hermes schema package catalog (generated). |
| polylogue/schemas/providers/hermes/manifest.json | Adds Hermes schema manifest (generated). |
| polylogue/schemas/providers/hermes/versions/v1/package.json | Adds Hermes v1 schema package metadata (generated). |
| polylogue/schemas/sampling_sessions.py | Extends sampling to read .json session documents in addition to .jsonl. |
| polylogue/schemas/synthetic/build_batch.py | Extends synthetic generator to support schema-driven generation without explicit message paths. |
| polylogue/schemas/synthetic/core.py | Writes Antigravity synthetic artifacts as .md.metadata.json plus sibling .md. |
| polylogue/schemas/synthetic/wire_formats.py | Adds minimal wire-format config for antigravity. |
| polylogue/schemas/unified/fallbacks.py | Adds fallback extraction for local-agent records and Antigravity metadata. |
| polylogue/sources/dispatch.py | Adds provider detection + parse modes for local agent documents and Antigravity artifacts, with source_path threading. |
| polylogue/sources/emitter.py | Passes source_path through to parse_payload for path-sensitive parsing. |
| polylogue/sources/live/watcher.py | Adds suffix-aware watch sources and expands default sources for gemini-cli/hermes/antigravity. |
| polylogue/sources/parsers/antigravity.py | New Antigravity language-server export client + markdown/metadata parsing. |
| polylogue/sources/parsers/local_agent.py | New local-agent JSON document parsers for Gemini CLI and Hermes. |
| polylogue/sources/source_parsing.py | Prefers Antigravity language-server exports (with fallback) during source walks. |
| polylogue/storage/insights/session/profiles.py | Adds provenance to embedded phase/work-event documents and support signal refinements. |
| polylogue/storage/insights/session/timeline_rows.py | Adds provenance to timeline record evidence payloads and hydration output. |
| polylogue/storage/query_models.py | Extends timeline list query model with canonical session-date filters. |
| polylogue/storage/repository/insight/timeline_reads.py | Exposes canonical session-date filtering in repository insight reads. |
| polylogue/storage/runtime/archive/records.py | Allows model_* fields on MessageRecord via Pydantic config. |
| polylogue/storage/sqlite/connection.py | Serializes schema initialization per DB path to avoid concurrent bootstrap races. |
| polylogue/storage/sqlite/queries/mappers_insight_legacy.py | Adds provenance when falling back from legacy insight payload formats. |
| polylogue/storage/sqlite/queries/session_insight_timeline_reads.py | Adds canonical session-date filtering and event-time ordering for work events/phases. |
| polylogue/types.py | Adds new Provider enum entries: gemini-cli, hermes, antigravity. |
| tests/data/witnesses/mcp-tool-schemas.json | Updates MCP tool schema witness for new query fields. |
| tests/unit/cli/test_deterministic_output.py | Updates expected source naming for Drive (aistudio). |
| tests/unit/cli/test_insights.py | Adds tests for provenance fields and canonical session-date filtering behavior. |
| tests/unit/core/test_audit.py | Tests schema audit boundary behavior for high-cardinality key annotations. |
| tests/unit/core/test_config.py | Updates expected source naming for Drive (aistudio). |
| tests/unit/core/test_paths.py | Ensures new path-root helpers are exported from polylogue.paths. |
| tests/unit/core/test_sampling.py | Updates sampling tests for new providers and JSON session documents. |
| tests/unit/core/test_synthetic_semantics.py | Expands synthetic wire-format expectations to account for Antigravity. |
| tests/unit/pipeline/test_resilience.py | Updates parse_payload test doubles for the new source_path argument. |
| tests/unit/security/test_attachment_security.py | Disables Hypothesis deadline for a symlink-path test. |
| tests/unit/sources/test_live_watcher.py | Adds tests for suffix-based catch-up and WatchSource suffix acceptance. |
| tests/unit/sources/test_parsers_local_agent.py | New unit coverage for gemini-cli/hermes parsing and antigravity export/metadata behaviors. |
| tests/unit/sources/test_source_laws.py | Updates parse_payload test doubles for the new source_path argument. |
| tests/unit/storage/test_repository_insight_runtime.py | Validates new canonical session-date fields in query models. |
| tests/unit/storage/test_session_insight_mapper_fallbacks.py | Adds assertions for provenance values in legacy fallback mappers. |
| tests/unit/storage/test_session_insight_timeline_rows.py | Adds roundtrip assertions for provenance propagation in timeline rows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| text = _content_text(record.get("content")) | ||
| content_blocks = _content_blocks_from_content(record.get("content")) | ||
| reasoning = _string(record.get("reasoning_content")) or _string(record.get("reasoning")) | ||
| if reasoning: | ||
| content_blocks.append(ParsedContentBlock(type=ContentBlockType.THINKING, text=reasoning)) | ||
| for tool_index, tool_call in enumerate(_list(record.get("tool_calls")), start=1): | ||
| tool_record = json_document(tool_call) | ||
| if not tool_record: | ||
| continue | ||
| content_blocks.append(_tool_use_block(tool_record, fallback_id=f"tool-{index}-{tool_index}")) | ||
| tool_call_id = _string(record.get("tool_call_id")) | ||
| role = _role(_string(record.get("role")) or "unknown") | ||
| if role is Role.TOOL and text: | ||
| content_blocks.append(ParsedContentBlock(type=ContentBlockType.TOOL_RESULT, tool_id=tool_call_id, text=text)) | ||
| if not text and not content_blocks: | ||
| return None | ||
| provider_meta = _message_meta(record, keys=("finish_reason",)) | ||
| return ParsedMessage( | ||
| provider_message_id=tool_call_id or f"msg-{index}", | ||
| role=role, | ||
| text=text, | ||
| content_blocks=content_blocks or [ParsedContentBlock(type=ContentBlockType.TEXT, text=text)], |
| def _range_timing_provenance(start_time: str | None, end_time: str | None) -> str: | ||
| if start_time is not None and end_time is not None: | ||
| return "timestamped_range" | ||
| if start_time is not None: | ||
| return "start_timestamp_only" | ||
| if end_time is not None: | ||
| return "end_timestamp_only" | ||
| return "untimestamped" | ||
|
|
||
|
|
||
| def _date_provenance(canonical_session_date: str | None, start_time: str | None, end_time: str | None) -> str: | ||
| if canonical_session_date is None: | ||
| return "none" | ||
| if start_time is not None or end_time is not None: | ||
| return "event_timestamp" | ||
| return "date_only" |
…ity brain metadata (#3614) ## Summary Closes the source-admission/classification cluster spanning three beads: Claude Code tool-result sidecar admission (polylogue-omsw), Antigravity brain-metadata sidecar admission (polylogue-3m3de), and dead-code removal of `parse_drive_payload` (polylogue-194qk). ## Problem **polylogue-omsw**: `sources/live/tool_result_sidecars.py` joins Claude Code `tool-results/<tool_use_id>.<ext>` overflow content back to its owning `tool_result` block by `tool_use_id` -- these files are never independent conversation content. Content-shape classification alone cannot refuse them: a tool call's own output can coincidentally reproduce a genuine session-document shape byte-for-byte. Verified live against this machine's real `~/.claude/projects` corpus (12,821 non-hook tool-results files, 411 valid-JSON among them): one `tool-results/*.txt` sidecar whose content was a real claude.ai export document (an earlier turn's tool call had fetched and dumped one) classified as `SESSION_DOCUMENT`/`parse_as_session=True` under the prior content-only rules. **polylogue-3m3de**: reported 232 growing `raw_sessions` rows for `origin=antigravity-session`, all `brain/<uuid>/*.md.metadata.json` sidecars, zero real `.pb` conversations acquired. Investigation (scanned `classify_artifact`/`classify_artifact_path` against this machine's real `~/.gemini/antigravity/brain` corpus, 940 files): 0 leaks. The existing `AGENT_SIDECAR_META` path rule (polylogue-eo81, #1024/#3441) and `schemas/sampling_db.py`'s `schema_eligible` exclusion already close both downstream harms the bead names (session materialization, schema-inference contamination). The growing raw-row count is `source.db`'s durable raw-tier retention by design, not an admission-scope bug. The real unaddressed gap -- `sources/live/watcher.py`'s antigravity `WatchSource` only watches `.metadata.json`, never `.pb` -- is acquisition/daemon wiring work, explicitly left open per this fix's scope. **polylogue-194qk**: `sources/dispatch.py:1777-1828`'s `parse_drive_payload` re-implements chunk detection/list recursion the lowering pipeline (`_lower_drive_like_payload` -> `_parse_lowered_spec`) already owns, with zero production callers -- only self-recursion, `__all__`, and a self-validating test pair that exercises the dead function against itself. ## Solution - Added `tool_result_sidecar` `OriginArtifactRule` (`parse_policy="raw-only"`) to the Claude Code `OriginSpec`, matching `tool-results/<name>` paths (excluding `hook-*`, which keeps its own correct `HOOK_EVENT` content classification) so `classify_artifact`/`classify_artifact_path` refuse session admission by path, before any content heuristic runs -- same shape as the existing `AGENT_SIDECAR_META`/`WORKFLOW_JOURNAL` rules. Added `ArtifactKind.TOOL_RESULT_SIDECAR`. `path_suffixes` scoped to `.json` only (not the `.txt`/`.html` also found live) because `artifact_suffixes_for_provider` feeds `live/watcher.py`'s acquisition suffix filter directly -- widening it would expand what gets *acquired* archive-wide, out of scope. - Acknowledged the classifier-fingerprint drift gate (`docs/plans/classifier-fingerprints.json`) as `acknowledged_safe`: tightens acceptance only, no reparse needed (existing contaminated rows are the already-planned polylogue-x1gd index rebuild's job). - Added regression test pinning antigravity brain-metadata classification (no code change needed there -- already correct). - Deleted `parse_drive_payload` and its self-validating tests/imports. ## Verification - `devtools test tests/unit/sources/test_artifact_taxonomy.py tests/unit/sources/test_origin_specs.py tests/unit/sources/test_source_laws.py tests/unit/sources/test_dispatch_payloads.py` -> 181 passed, 2 pre-existing failures unrelated to this change (confirmed via isolated diff-based comparison to origin/master: both fail identically before this branch's commits -- a `_detect_provider_from_raw_bytes` monkeypatch-target rename and an unrelated claude-ai zip-entry detection assertion). - `devtools lab policy classifier-fingerprints` -> "Classifier fingerprint policy intact." - `devtools render all --check` -> no "out of sync" surfaces. - `devtools verify --quick` -> exit 0 (format, lint, mypy --strict, render-all-check, schema-versioning, classifier-fingerprints, and other lab policy gates all green). - Ad hoc live-corpus scans (not committed) against this machine's real `~/.claude/projects` tool-results files (12,821) and `~/.gemini/antigravity/brain` files (940): 0 classification leaks post-fix. Cleanup of existing contaminated `raw_sessions` rows is explicitly out of scope for both beads (raw-authority path owns it, per this repo's durable-tier policy). Ref polylogue-omsw, polylogue-3m3de, polylogue-194qk
|
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
Adds first-class ingestion for local agent sources: Gemini CLI, Hermes, and Gemini Antigravity. The branch also hardens the insight/work-event provenance surface needed by downstream consumers and fixes a sync SQLite schema-initialization race exposed by the broad gate.
Problem
Lynchpin and other downstream readers should not need local hacks to recover agent conversations or infer whether degraded insight rows are equivalent to freshly materialized products. Gemini CLI, Hermes, and Antigravity were missing as source families, and the insight layer still had ambiguous timing/fallback boundaries in work-event/profile products.
Solution
aistudio) distinct from Gemini CLI (gemini-cli) so Google Drive exports and local CLI sessions do not collapse into one source identity.Verification
nix develop -c devtools verify->verify: all checks passedincluding pytest (ok (295.7s)).nix develop -c git push -u origin feature/feat/local-agent-sources->verify: all checks passed.gemini-cli,hermes, andantigravity.Issue Matrix
.geminisessions are discoverable, schema-inferred, parsed, and covered by tests.aistudio,gemini-cli,hermes, andantigravityseparable, but the broader provider/source terminology migration remains open.Summary by CodeRabbit
New Features
--session-date-sinceand--session-date-untilfilters for work-event insightsChanged