Skip to content

feat(sources): ingest local agent sources - #1024

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/local-agent-sources
May 11, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/local-agent-sources

Conversation

@Sinity

@Sinity Sinity commented May 11, 2026 •

Copy link
Copy Markdown
Owner

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

  • Add Gemini CLI and Hermes local-agent parsers, schema packages, dispatch, source discovery, live watcher support, sampling/witness coverage, and tests.
  • Add Antigravity ingestion through its local language-server Markdown export path, while classifying raw protobuf/config sidecars as auxiliary metadata rather than pretending they are directly parseable transcripts.
  • Keep AI Studio (aistudio) distinct from Gemini CLI (gemini-cli) so Google Drive exports and local CLI sessions do not collapse into one source identity.
  • Extend session insight/profile/work-event models with timing/date provenance and bounded canonical-date reads for downstream consumers.
  • Treat high-cardinality embedded tool-parameter schema annotations as a schema-audit boundary, so provider schema inference remains meaningful instead of failing on nested arbitrary tool JSON.
  • Serialize sync SQLite schema initialization per database path, matching the async backend's one-time schema guard and preventing concurrent fresh-DB FTS bootstrap failures.

Verification

  • nix develop -c devtools verify -> verify: all checks passed including pytest (ok (295.7s)).
  • Pre-push hook via nix develop -c git push -u origin feature/feat/local-agent-sources -> verify: all checks passed.
  • Focused Antigravity smoke against the local language-server export path produced conversations from real local state.
  • Focused schema audits passed for gemini-cli, hermes, and antigravity.

Issue Matrix

Summary by CodeRabbit

  • New Features

    • Added support for Gemini CLI and Hermes as data sources
    • Added support for Antigravity with local Markdown export and brain artifact ingestion
    • Added --session-date-since and --session-date-until filters for work-event insights
    • Session work-event and phase evidence now include timing and date provenance information
  • Changed

    • Work-event results are now ordered by event time instead of conversation recency

Review Change Stack

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
Copilot AI review requested due to automatic review settings May 11, 2026 06:50
@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20a341c3-252f-4e58-9a86-f73437b964de

📥 Commits

Reviewing files that changed from the base of the PR and between 3cdb408 and 4dd4b42.

⛔ Files ignored due to path filters (3)
  • polylogue/schemas/providers/antigravity/versions/v1/elements/conversation_document.schema.json.gz is excluded by !**/*.gz, !**/*.json.gz
  • polylogue/schemas/providers/gemini-cli/versions/v1/elements/conversation_document.schema.json.gz is excluded by !**/*.gz, !**/*.json.gz
  • polylogue/schemas/providers/hermes/versions/v1/elements/conversation_document.schema.json.gz is excluded by !**/*.gz, !**/*.json.gz
📒 Files selected for processing (68)
  • CHANGELOG.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/archive/artifact_taxonomy/runtime.py
  • polylogue/archive/artifact_taxonomy/support.py
  • polylogue/archive/conversation/extraction.py
  • polylogue/archive/semantic/pricing.py
  • polylogue/archive/session/documents.py
  • polylogue/archive/session/models.py
  • polylogue/cli/shell_completion_values.py
  • polylogue/config.py
  • polylogue/core/provider_identity.py
  • polylogue/insights/archive.py
  • polylogue/insights/archive_models.py
  • polylogue/insights/registry.py
  • polylogue/operations/archive.py
  • polylogue/paths/__init__.py
  • polylogue/paths/_roots.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/schemas/audit/checks.py
  • polylogue/schemas/observation_models.py
  • polylogue/schemas/providers/antigravity/catalog.json
  • polylogue/schemas/providers/antigravity/manifest.json
  • polylogue/schemas/providers/antigravity/versions/v1/package.json
  • polylogue/schemas/providers/gemini-cli/catalog.json
  • polylogue/schemas/providers/gemini-cli/manifest.json
  • polylogue/schemas/providers/gemini-cli/versions/v1/package.json
  • polylogue/schemas/providers/hermes/catalog.json
  • polylogue/schemas/providers/hermes/manifest.json
  • polylogue/schemas/providers/hermes/versions/v1/package.json
  • polylogue/schemas/sampling_sessions.py
  • polylogue/schemas/synthetic/build_batch.py
  • polylogue/schemas/synthetic/core.py
  • polylogue/schemas/synthetic/wire_formats.py
  • polylogue/schemas/unified/fallbacks.py
  • polylogue/sources/dispatch.py
  • polylogue/sources/emitter.py
  • polylogue/sources/live/watcher.py
  • polylogue/sources/parsers/antigravity.py
  • polylogue/sources/parsers/local_agent.py
  • polylogue/sources/source_parsing.py
  • polylogue/storage/insights/session/profiles.py
  • polylogue/storage/insights/session/timeline_rows.py
  • polylogue/storage/query_models.py
  • polylogue/storage/repository/insight/timeline_reads.py
  • polylogue/storage/runtime/archive/records.py
  • polylogue/storage/sqlite/connection.py
  • polylogue/storage/sqlite/queries/mappers_insight_legacy.py
  • polylogue/storage/sqlite/queries/session_insight_timeline_reads.py
  • polylogue/types.py
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/unit/cli/test_deterministic_output.py
  • tests/unit/cli/test_insights.py
  • tests/unit/core/test_audit.py
  • tests/unit/core/test_config.py
  • tests/unit/core/test_paths.py
  • tests/unit/core/test_sampling.py
  • tests/unit/core/test_synthetic_semantics.py
  • tests/unit/pipeline/test_resilience.py
  • tests/unit/security/test_attachment_security.py
  • tests/unit/sources/test_live_watcher.py
  • tests/unit/sources/test_parsers_local_agent.py
  • tests/unit/sources/test_source_laws.py
  • tests/unit/storage/test_repository_insight_runtime.py
  • tests/unit/storage/test_session_insight_mapper_fallbacks.py
  • tests/unit/storage/test_session_insight_timeline_rows.py

📝 Walkthrough

Walkthrough

This 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.

Changes

New Local Conversation Sources: Type Definitions & Routing

Layer / File(s) Summary
Provider Types & Identity
polylogue/types.py, polylogue/core/provider_identity.py
Three new Provider enum members (GEMINI_CLI, HERMES, ANTIGRAVITY) added; canonical runtime/schema provider lists and aliases expanded to map aistudio/ai-studio/hermes-agent to their canonical forms.
Local Filesystem Paths
polylogue/paths/_roots.py, polylogue/paths/__init__.py
Three path accessor functions added: gemini_cli_path(), hermes_sessions_path(), antigravity_path(); re-exported via public polylogue.paths module.
Artifact Classification
polylogue/archive/artifact_taxonomy/runtime.py, polylogue/archive/artifact_taxonomy/support.py
Antigravity sidecars (logs.json, opaque/resolved patterns, brain config filenames) explicitly classified as METADATA_DOCUMENT; generic sidecar reasoning delegated to new path_only_sidecar_reason() helper; Antigravity markdown-export and brain-metadata payloads detected as CONVERSATION_DOCUMENT in _classify_dict.
Local Agent Parser (Gemini CLI & Hermes)
polylogue/sources/parsers/local_agent.py
New 257-line module with detection predicates, message parsers, and conversation builders for Gemini CLI and Hermes; extracts timestamps, roles, content blocks (text/thinking/tool-use), and metadata from respective JSON session schemas.
Antigravity Parser
polylogue/sources/parsers/antigravity.py
New 415-line module managing local Antigravity language-server lifecycle, querying for summaries, exporting markdown, and parsing both markdown-export and brain-metadata payloads into ParsedConversation structures; includes HTTP client, payload detection, and markdown-to-message sectioning logic.
Fallback Semantic Extractors
polylogue/schemas/unified/fallbacks.py
Added local-agent fallback extractor (generic for Gemini CLI/Hermes) and Antigravity-specific fallback extractor; wired into provider dispatch table.
Payload Dispatch & Routing
polylogue/sources/dispatch.py
Extended LoweredPayloadMode with local_agent_document and local_artifact_document modes; added source_path field to LoweredPayloadSpec; updated _detect_provider_from_record to identify new provider payloads; new lowering builders _local_agent_document_spec and _local_artifact_document_spec; extended _parse_lowered_spec to route to local_agent and antigravity parsers; added source_path parameter to parse_payload signature.
Ingest Pipeline
polylogue/pipeline/services/ingest_worker.py, polylogue/sources/emitter.py
Updated emitter and ingest_worker to pass source_path through parse_payload for artifact context during Antigravity processing.
Source Discovery & Live Watch
polylogue/sources/source_parsing.py, polylogue/sources/live/watcher.py
Antigravity-specific branch in source parsing attempts language-server exports; WatchSource gains configurable suffixes field and updated accepts() predicate; catch-up scan honors per-source suffixes; default_sources expanded with JSON and metadata.json suffix support for new sources.

Session Work-Event Provenance & Insights

Layer / File(s) Summary
Document & Model Provenance
polylogue/archive/session/documents.py, polylogue/archive/session/models.py, polylogue/archive/conversation/extraction.py
WorkEventDocument and SessionPhaseDocument gain timing_provenance and date_provenance optional fields; _phase_to_dict and WorkEvent.to_dict compute these from timestamp/date presence using new helper functions.
Storage Evidence & Payload Models
polylogue/insights/archive_models.py
Contract version bumped 5→6; ArchiveInsightModel sets protected_namespaces=(); WorkEventEvidencePayload and SessionPhaseEvidencePayload gain timing_provenance and date_provenance fields with defaults.
Storage Timeline & Hydration
polylogue/storage/insights/session/timeline_rows.py
event_evidence_payload() and phase_evidence_payload() populate provenance; hydrate_work_event() reads them back; private helpers compute provenance strings.
Storage Profile & Signal Enrichment
polylogue/storage/insights/session/profiles.py
_phase_document, _phase_payload_from_phase, and _work_event_document compute provenance; event_support_signals and phase_support_signals enriched with partial_timestamp_range, date_only_range, and word_count.
Legacy Conversion
polylogue/storage/sqlite/queries/mappers_insight_legacy.py
session_work_event_evidence_from_legacy and session_phase_evidence_from_legacy compute and include provenance using helper functions; legacy document builders similarly updated.
Insight Query & Filtering
polylogue/insights/archive.py, polylogue/storage/query_models.py, polylogue/storage/repository/insight/timeline_reads.py
ConversationTimelineWindowInsightQuery and SessionTimelineListQuery gain session_date_since/until optional fields; list_session_work_events and list_session_work_event_records accept and forward these parameters.
SQLite Timeline Query
polylogue/storage/sqlite/queries/session_insight_timeline_reads.py
list_work_events and list_session_phases filter by canonical_session_date using SQLite date() wrapper; full-text search ordering changed from source_sort_key to BM25 plus timestamp-derived descending order.
CLI & Operations
polylogue/insights/registry.py, polylogue/operations/archive.py
session_work_events insight gains --session-date-since and --session-date-until CLI options; list_session_work_event_insights forwards date parameters to repository.

Schema Metadata, Configuration, & Storage

Layer / File(s) Summary
Provider Schema Catalogs
polylogue/schemas/providers/{gemini-cli,hermes,antigravity}/{catalog,manifest,versions/v1/package}.json
Added 15 JSON files defining catalog, manifest, and package metadata for three new providers with conversation_document element definitions, bundle scope metadata, and profile information.
Schema Observation
polylogue/schemas/observation_models.py
Extended PROVIDERS mapping with Gemini CLI, Hermes, Antigravity configs including descriptions, db_provider_names, session_dirs, and sample_granularity="document".
Sample JSON Support
polylogue/schemas/sampling_sessions.py
_iter_session_json_documents rewritten to handle both .json and .jsonl files with suffix allowlist, mtime sorting, and max_sessions downsampling.
Synthetic Output
polylogue/schemas/synthetic/build_batch.py, polylogue/schemas/synthetic/core.py, polylogue/schemas/synthetic/wire_formats.py
_SyntheticBatchContext protocol declares _role_cycle() method; _generate_conversation passes role_cycle to SemanticValueGenerator; SyntheticCorpus.write_spec_artifacts branches on antigravity provider to write .md and .md.metadata.json; PROVIDER_WIRE_FORMATS adds antigravity entry.
Schema Audit
polylogue/schemas/audit/checks.py
check_annotation_coverage recognizes x-polylogue-high-cardinality-keys annotation and skips recursive traversal into additionalProperties when present.
Pydantic Configuration
polylogue/archive/semantic/pricing.py, polylogue/storage/runtime/archive/records.py
PricingModel and MessageRecord updated to set protected_namespaces=() for legacy field compatibility.
Database Sync
polylogue/storage/sqlite/connection.py
Added per-database-path thread-safe locks to serialize schema initialization and prevent concurrent migration races.
Source & Config
polylogue/config.py, polylogue/cli/shell_completion_values.py
Drive/Gemini source renamed from "gemini" to "aistudio"; shell completion updated with descriptions for all providers (gemini, aistudio, gemini-cli, hermes, antigravity).

Tests & Documentation

Layer / File(s) Summary
Parser & Dispatch Tests
tests/unit/sources/test_parsers_local_agent.py
275 lines of new tests covering Gemini CLI, Hermes, and Antigravity parsing through dispatch, artifact classification, provider identity normalization, markdown export sectioning, brain metadata hydration, and source walking.
Live Watcher Tests
tests/unit/sources/test_live_watcher.py
Extended _make_watcher helper; added tests for JSON session file discovery with source-specific suffixes and WatchSource.accepts() suffix validation.
Provenance & Insight Tests
tests/unit/cli/test_insights.py, tests/unit/storage/test_session_insight_*.py
Added assertions for work-event/phase evidence provenance fields; added CLI test filtering work-events by session date range; extended mappers/timeline roundtrip tests.
Config & Path Tests
tests/unit/core/test_config.py, tests/unit/core/test_paths.py, tests/unit/core/test_sampling.py
Updated source name assertions; added gemini_cli_path, hermes_sessions_path, antigravity_path to all assertions; extended provider config tests; added JSON session document sampling test.
Audit & Synthetic Tests
tests/unit/core/test_audit.py, tests/unit/core/test_synthetic_semantics.py
Added high-cardinality schema boundary test; extended wire-format and provider-availability tests for antigravity; updated Hypothesis deadline settings.
Schema & Resilience Tests
tests/data/witnesses/mcp-tool-schemas.json, tests/unit/pipeline/test_resilience.py, tests/unit/sources/test_source_laws.py
Updated MCP tool schemas with session date filters; adjusted monkeypatched parse_payload signatures to accept source_path.
Documentation
CHANGELOG.md, docs/plans/topology-target.yaml, docs/test-quality-workflows.md, docs/topology-status.md, docs/verification-catalog.md
CHANGELOG records new sources, provenance fields, and CLI options; topology and verification catalogs updated with new provider metrics, schema annotations, and proof obligations.

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:

  • Language-server client lifecycle and HTTP marshalling (Antigravity parser)
  • Dispatch routing correctness and fallback extraction integration
  • Provenance computation logic consistency across 6+ modules
  • SQLite query correctness for date filtering and ranking
  • Live watcher suffix matching behavior under the new configurable model

Possibly related PRs

  • Sinity/polylogue#687: Renames and refactors insight vocabulary and derived status; overlaps with session provenance and evidence-payload naming.
  • Sinity/polylogue#230: Centralizes typed archive product payloads; overlaps with session storage and payload model seams.
  • Sinity/polylogue#276: Refactors storage query models and timeline reads; related to session_date filters and repository interfaces.

Suggested labels

type:feature, area:parser, area:schema, area:storage, area:sources, area:cli, area:qa

Poem

🐰 Three local sources emerge from home-dirs deep—
Gemini chats, Hermes secrets, Antigravity sleep,
With timestamps traced and dates provenance-blessed,
The polylogue rabbit hops through sources with zest!
Date-bounded reads and language-servers bright,
The warren's now richer, the vision more light. 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/local-agent-sources

@Sinity
Sinity merged commit 1618887 into master May 11, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the feature/feat/local-agent-sources branch May 11, 2026 06:50

@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: 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread polylogue/sources/dispatch.py Resolved

Copilot AI 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.

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, and antigravity, 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.

Comment on lines +127 to +148
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)],
Comment on lines +456 to +471
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"
Sinity added a commit that referenced this pull request Aug 3, 2026
…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
@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.

  • 71.F037 / P2: stale at the checked revision: The old Antigravity brain-metadata session parser has been removed from dispatch. polylogue/sources/dispatch.py:1813 admits only recognized Markdown-export payloads for this document branch and returns no specs otherwise, so an artifactType/summary metadata object cannot become the cited bogus Antigravity conversation.

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

2 participants