Skip to content

fix(sources): acquire real Antigravity conversations, fix directory gate - #3441

Merged
Sinity merged 2 commits into
masterfrom
feature/sources/antigravity-conversation-acquisition
Jul 31, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/sources/antigravity-conversation-acquisition

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the acquisition half of the "Antigravity inversion" forensic finding
(polylogue-eo81): 314MB / 44 real Antigravity conversation trajectories
(conversations/*.pb) were never acquired at all, while 116 per-artifact
metadata sidecars were ingested as noise sessions. Also adds a regression
fixture for the separately-audited Codex silent-parse-loss finding
(polylogue-i415), which investigation showed needs no parser fix.

Problem

A forensic audit of the live archive found every antigravity-session row
(116/116) was a 1-message fragment from brain/<uuid>/*.md.metadata.json —
artifact metadata, not conversations — while raw_sessions/raw_artifacts
held zero rows for conversations/*.pb, the actual 314MB of real
conversation content. Root cause, traced in polylogue/sources/parsers/antigravity.py
and polylogue/sources/source_parsing.py:

  1. The language-server export path (already built: it converts .pb
    trajectories to markdown via the local Antigravity language server's
    ConvertTrajectoryToMarkdown RPC, so this code never has to
    reverse-engineer the protobuf schema) was gated on
    source.path / "sessions" — a directory that has never existed on this
    machine. The real directory is conversations/, so the gate always
    short-circuited to a no-op and the export path never ran.
  2. Cascade discovery used SearchConversations, which only surfaces a small
    recently-tracked subset — verified empirically at 10 of 44 real
    conversations — rather than every cascade with a .pb file still on
    disk. GetCascadeTrajectory/ConvertTrajectoryToMarkdown happily serve
    any cascade id whose .pb file exists, regardless of whether the
    language server's live index currently tracks it.

This is an acquisition-side loss: the .pb bytes were never captured at
all, so the operator's planned index rebuild (which only replays
source.db) would not have recovered them without this fix landing first.

Separately, the audit's Codex finding (polylogue-i415: 11 rollouts up to
3.3MB parsed to message_count=0 despite real content) turned out to be
already fixed in the current parser — see Verification below — so this PR
adds a regression fixture rather than a codex.py change.

Solution

  • polylogue/sources/parsers/antigravity.py: ground cascade discovery in
    the conversations/*.pb file listing (disk truth) instead of the search
    RPC; enrich title/workspace/snippet metadata from search results when
    available for a given cascade.
  • polylogue/sources/source_parsing.py: fix the directory gate to
    conversations/. Snapshot the raw .pb bytes into the blob store per
    exported session (mirrors hermes_state's sqlite snapshot pattern) so
    source.db holds real acquired bytes with a stable content hash for
    idempotent re-ingest, not an ephemeral export that re-runs unconditionally
    every pass. Add an explicit brain-metadata fallback walk
    (_iter_antigravity_brain_metadata_fallback) for when the language server
    truly cannot be reached — no conversations/ dir, no binary, or a benign
    connection failure before any session was obtained — but deliberately
    not for a mid-export abort, which must surface loudly (existing
    AntigravityPartialExportError semantics) rather than being silently
    backfilled with degraded fragments.
  • polylogue/archive/artifact_taxonomy/runtime.py: reclassify
    *.md.metadata.json as a non-session sidecar (AGENT_SIDECAR_META) in
    the generic per-file walk, so per-artifact brain metadata is no longer
    fragmented into noise sessions by default now that real conversations are
    acquired directly. parse_brain_metadata remains directly usable and is
    what the new fallback walk calls.
  • tests/unit/sources/test_silent_ingest_loss.py: new regression fixture
    (test_codex_dense_reasoning_and_tool_call_rollout_yields_messages) built
    from real record shapes copied out of the affected rollout (prose
    replaced with placeholders), locking in that a dense
    response_item/reasoning/function_call/custom_tool_call stream
    containing real message records must not silently parse to zero.

Existing tests updated to match the corrected behavior:
test_antigravity_brain_artifact_metadata_parses_sibling_markdown (now
asserts the path-only classification is a non-session sidecar, while
parse_brain_metadata itself remains directly usable),
test_antigravity_source_walk_prefers_language_server_exports (mkdir
target renamed sessions → conversations), plus the driver-level tests
in test_antigravity_language_server.py / test_silent_ingest_loss.py
updated to provide the now-required conversations/*.pb disk-truth files
for their fake-client scenarios.

Acquisition vs. parse classification

  • Antigravity .pb conversations (this PR): acquisition loss. Bytes
    were never captured; a rebuild alone would not have helped. Fixed here.
  • Codex silent-parse-loss (polylogue-i415): parse loss, already fixed.
    The 11 affected rollouts' raw bytes already exist in source.db (verified
    by blob_size/live-file-size match). Re-parsing those exact archived raw
    bytes with the current codex.py (unmodified by this PR) produces the
    expected non-zero message counts — e.g. 1023 messages for the 3.3MB
    sample that materialized as message_count=0. The loss was a stale
    materialization from an older parser version; the operator's planned
    index rebuild will resolve it with no code change. This PR only adds the
    regression fixture so that shape cannot silently regress again.

Verification

devtools test tests/unit/sources/test_antigravity_language_server.py \
  tests/unit/sources/test_silent_ingest_loss.py \
  tests/unit/sources/test_parsers_local_agent.py \
  tests/unit/sources/parsers/test_antigravity.py \
  tests/unit/sources/test_dispatch_payloads.py \
  tests/unit/sources/parsers/test_origin_regression_pack.py
# -> 107 passed (test_antigravity_language_server.py + test_silent_ingest_loss.py: 6+6=... see individual runs, all green)

devtools verify --quick
# -> exit_code 0 (ruff format, ruff check, mypy --strict, render all --check, layering,
#    closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands,
#    docs-coverage, test-infra-currency, pytest-timeout-overrides, degrade-loudly,
#    hash-boundary-census, schema-versioning policy, schema promotion audit)

Manual verification directly against the live machine's real Antigravity
data and archived Codex raw bytes (read-only; no live-archive writes):

  • Called AntigravityLanguageServerClient.export_markdown() for cascade
    a6db7297-78ae-46d5-9956-d4c5a1fc0917 — a .pb file present on disk but
    absent from SearchConversations' 10-item result — and got back
    82,274 characters of real conversation markdown, confirming the
    disk-truth discovery strategy recovers cascades the search index misses.
  • Ran the exact fixed function, iter_source_sessions_with_raw, against the
    real Source(name="antigravity", path=~/.gemini/antigravity) with
    capture_raw=True and a scratch blob store (not the live archive):
    produced all 44 sessions, all 44 with a raw blob snapshot (blob sizes
    matching the real .pb file sizes on disk, e.g. 26,888,066 bytes for the
    largest), 2,162 total real messages, zero brain-metadata fallback
    fragments (correct — the language server served all 44).
  • Re-parsed all 17 codex-session rows with message_count=0 in the live
    archive (/realm/db/polylogue) against their exact archived raw bytes
    (verified identical via blob_size == live on-disk file size): 11 now
    produce real, non-trivial message counts (3 to 1073) with the current
    parser; the remaining 6 are genuinely near-empty stubs (≤5KB, 1-4
    records) — confirming the bead's own classification.

Not done in this PR (needs operator action)

The live polylogued.service runs from a Nix-built package
(/nix/store/.../python3.14t-polylogue-0.3.0/), a separate deployment
artifact from this checkout — it does not pick up this fix until the
PR merges and Sinnix rebuilds/redeploys the service. I deliberately did
not attempt to acquire into the live archive: doing so today would
either (a) run against the old, still-buggy deployed code (no-op) or (b)
require writing to the archive outside the daemon's write path while the
daemon is live, which the mission explicitly said to avoid without
certainty of safety. Operator action needed: merge this PR, redeploy
polylogued (Sinnix rebuild), then either wait for the next scheduled
Antigravity source catch-up or run polylogue import ~/.gemini/antigravity
against the redeployed daemon to acquire the 44 real conversations. I did
not run polylogue check --cleanup or any destructive/reset command.

Existing degraded fragment sessions (the 116 brain-metadata-fragment
rows) are left untouched by this PR — no deletion or reclassification of
already-materialized rows, only of future ingest behavior. A retroactive
cleanup/reclassification pass for those existing rows is separate,
deliberate, deletion-adjacent work and is intentionally out of scope here;
recommend tracking it as a follow-up against polylogue-eo81 if the operator
wants it done.

Ref polylogue-eo81, polylogue-i415

Co-Authored-By: Claude [email protected]

Problem: forensic audit (polylogue-eo81) found the Antigravity origin
inverted -- all 116 antigravity-session rows were 1-message metadata
sidecar fragments, while the 44 real conversation trajectories (314MB
of .pb protobuf files under conversations/) had zero raw rows. Root
cause was two-fold:

1. The language-server export path (already built to convert .pb
   trajectories to markdown via the local Antigravity language
   server's ConvertTrajectoryToMarkdown RPC -- avoiding the need to
   reverse-engineer the protobuf schema) was gated on a
   `source.path / "sessions"` directory that has never existed on this
   machine; the real directory is `conversations/`, so the gate always
   short-circuited to a no-op.
2. Cascade discovery used SearchConversations, which only surfaces a
   small recently-tracked subset (10 of 44 real conversations,
   verified empirically) rather than every cascade with a .pb file
   still on disk. GetCascadeTrajectory/ConvertTrajectoryToMarkdown
   happily serve any cascade id whose .pb file exists regardless of
   whether the live index tracks it.

Solution:
- polylogue/sources/parsers/antigravity.py: ground cascade discovery
  in `conversations/*.pb` file listing (disk truth), enriching
  title/workspace/snippet metadata from search results when available.
- polylogue/sources/source_parsing.py: fix the directory gate to
  `conversations/`; snapshot the raw .pb bytes into the blob store per
  exported session (mirrors hermes_state's sqlite snapshot pattern) so
  source.db holds real acquired bytes with a stable content hash for
  idempotent re-ingest. Add an explicit brain-metadata fallback walk
  for when the language server truly cannot be reached (no
  conversations/ dir, no binary, or a benign connection failure before
  any session was obtained) -- but NOT for a mid-export abort, which
  must surface loudly rather than being silently backfilled.
- polylogue/archive/artifact_taxonomy/runtime.py: reclassify
  `*.md.metadata.json` as a non-session sidecar (AGENT_SIDECAR_META)
  in the generic per-file walk, so per-artifact brain metadata is no
  longer fragmented into noise sessions by default now that real
  conversations are acquired directly. `parse_brain_metadata` remains
  used explicitly by the new fallback walk.

This fix is acquisition-side: the .pb bytes were never captured at
all, so the operator's planned index rebuild (which only replays
source.db) would not have recovered them without this change landing
first.

Also adds a regression fixture (tests/unit/sources/test_silent_ingest_loss.py)
for the separately-audited Codex silent-parse-loss finding
(polylogue-i415): verified against the live archive's actual raw bytes
that the CURRENT Codex parser already produces the expected message
counts for all 11 affected 2025-era rollouts (e.g. 1023 messages for
the 3.3MB sample that showed message_count=0) -- that loss was a stale
materialization from an older parser version, not a defect in the
current parser, so no codex.py change is needed; the fixture guards
the shape from silently regressing.

Verification:
- devtools test tests/unit/sources/test_antigravity_language_server.py
  tests/unit/sources/test_silent_ingest_loss.py
  tests/unit/sources/test_parsers_local_agent.py
  tests/unit/sources/parsers/test_antigravity.py
  tests/unit/sources/test_dispatch_payloads.py
  tests/unit/sources/parsers/test_origin_regression_pack.py
  -> 107 passed
- devtools verify --quick -> exit 0 (format, lint, mypy --strict, render all --check)
- Manually verified against the live archive at /realm/db/polylogue:
  language-server export produces real markdown (116530 chars) for a
  cascade id absent from SearchConversations' 10-item result but
  present as conversations/a6db7297-....pb; re-parsed all 17
  message_count=0 codex-session rows against their exact archived raw
  bytes (verified by blob_size match), confirming 11 now parse
  correctly and 6 are genuinely near-empty stubs (<=5KB, <=4 records).

Ref polylogue-eo81, polylogue-i415

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 40 minutes

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

How can I continue?

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

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

How do review limits work?

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

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

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 684f0122-9759-48f5-bf5c-53715fd64baa

📥 Commits

Reviewing files that changed from the base of the PR and between dd912a7 and ec0927f.

📒 Files selected for processing (7)
  • .beads/issues.jsonl
  • polylogue/archive/artifact_taxonomy/runtime.py
  • polylogue/sources/parsers/antigravity.py
  • polylogue/sources/source_parsing.py
  • tests/unit/sources/test_antigravity_language_server.py
  • tests/unit/sources/test_parsers_local_agent.py
  • tests/unit/sources/test_silent_ingest_loss.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Ref polylogue-eo81, polylogue-i415

Co-Authored-By: Claude <[email protected]>

@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: 4c7a940348

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

Comment thread polylogue/sources/source_parsing.py Resolved
Comment thread polylogue/sources/source_parsing.py Resolved

resolved_blob_root = blob_store_root()
resolved_store = blob_store or BlobStore(resolved_blob_root)
blob_hash, blob_size = resolved_store.write_from_path(pb_path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve a replayable Antigravity raw payload

When raw capture is enabled, this stores the binary protobuf itself as the session's durable raw payload, but reset/reprocess later sends that blob through ingest_worker.build_raw_payload_envelope, which only has a binary special case for Hermes and otherwise decodes JSON/JSONL. A real Antigravity .pb therefore fails decoding, so rebuilding the rebuildable index from source.db cannot recreate these sessions. Persist a replayable language-server export envelope alongside the original artifact, or add a protobuf-aware Antigravity replay path.

AGENTS.md reference: AGENTS.md:L89-L94

Useful? React with 👍 / 👎.

Comment thread polylogue/sources/source_parsing.py Resolved
@Sinity
Sinity merged commit 7b4f881 into master Jul 31, 2026
3 checks passed
@Sinity
Sinity deleted the feature/sources/antigravity-conversation-acquisition branch July 31, 2026 10:54
Sinity added a commit that referenced this pull request Jul 31, 2026
…vity (#3479)

## Summary

44 real Antigravity conversations have never been acquired. The
discovery logic to acquire them landed in #3441 and could never fire,
because `Source.runtime_root` points at a directory that does not
contain the data.

## Problem

The archive holds **116 `antigravity-session` rows, all of them
`*.md.metadata.json` sidecars** materialising as one-message sessions.
Meanwhile `~/.gemini/antigravity/conversations/` holds **44 `.pb`
files** — the actual conversations — totalling 345 MB, none of it
acquired. The origin is inverted: metadata archived, conversations
dropped.

PR #3441 fixed the discovery path to ground on `conversations/*.pb`
(`sources/source_parsing.py:73`). That fix is correct and has never
executed, because:

```
Source.runtime_root = "~/.antigravity"      ← 4 KB, one `extensions` dir, 0 .pb files
actual data          ~/.gemini/antigravity  ← 345 MB, conversations/ with 44 .pb
```

Every acquired sidecar row's `source_path` already points under
`~/.gemini/antigravity/brain/…`, so the correct root was observable in
the archive's own data the whole time.

## Solution

Corrects `runtime_root`, with the evidence recorded inline at the
declaration.

Also updates `tests/unit/core/test_sources.py`, which asserted the
literal `"~/.antigravity"`. That test pinned the bug rather than a
contract — the enclosing test is
`test_runtime_root_present_for_local_session_sources`, whose intent is
that local session sources *have* a root, not that antigravity's is any
particular string.

## Verification

```
provider_to_source(ANTIGRAVITY).runtime_root  → ~/.gemini/antigravity
  exists: True
  conversations/: True, 44 .pb files
```

`devtools test tests/unit/core/test_sources.py` → 28 passed. `devtools
verify --quick` → exit 0.

## Note

This unblocks acquisition but does not perform it — the 44 conversations
remain unacquired until an import runs against the corrected root. A
rebuild does not recover them; they were never in `source.db`.

Ref polylogue-eo81.

Co-authored-by: Claude Opus 5 <[email protected]>
Sinity added a commit that referenced this pull request Aug 2, 2026
…sions

Problem

Every antigravity-session row in the live archive (116/116, measured
2026-07-31) is a 1-message fragment materialized from a per-artifact
~/.gemini/antigravity/brain/<uuid>/*.md.metadata.json sidecar -- metadata,
not conversation content. Real conversation content lives in
conversations/*.pb trajectories; acquiring those was already fixed by PR
#3441 (merged), which also stopped classifying future metadata sidecars as
sessions. That fix is forward-only: the 116 already-materialized phantom
sessions and their unclassified raw rows are untouched by it. This closes
the retroactive half of polylogue-eo81/polylogue-msia (the two beads
describe the same finding).

Solution

- polylogue/storage/antigravity_phantom_sweep.py: read-only
  scan_antigravity_phantom_sessions() joins sessions to session_tags on the
  existing degraded:brain-metadata-fragment auto-tag (written at ingest
  time by PR #1856) -- precise, already-present evidence, no new content
  classification needed. Cross-checks each candidate's raw_id against
  source.db's raw_sessions row when a source connection is given, and
  reports (rather than assumes) when that raw row is already missing.
- polylogue/storage/artifacts/persistence.py: adds
  materialize_artifact_observations_for_raw_ids(), a scoped sibling of the
  existing materialize_artifact_observations() full census, so an actuator
  that already knows exactly which raw ids it touched doesn't have to pay
  for a 43k-row census just to classify a handful of rows.
- devtools/antigravity_phantom_sweep_report.py: read-only report CLI.
- devtools/antigravity_phantom_purge_apply.py: --apply-gated actuator.
  Dry-run by default; --apply calls ArchiveStore.delete_sessions() on the
  flagged session ids (the same primitive CLI delete / MCP
  write(operation='delete_session') already reach -- rebuild-safe, since
  PR #3441's ingest-side classifier already refuses *.md.metadata.json as
  session content) and materialize_artifact_observations_for_raw_ids() on
  their raw ids (persists an explicit AGENT_SIDECAR_META classification).
- Registered both as `devtools workspace antigravity-phantom-sweep` /
  `antigravity-phantom-purge-apply`, mirroring the binary-artifact-sweep
  pattern from polylogue-hbtj2 (PR #3576).

Real .pb conversation acquisition: out of scope here, already done.

PR #3441 (merged 2026-07-31) already built acquisition for
conversations/*.pb -- not a raw protobuf parser, but calling Antigravity's
own local language-server RPC (ConvertTrajectoryToMarkdown) to export each
cascade to markdown, verified against 44 real files on the live machine
(2,162 real messages, blob sizes matching on-disk .pb sizes). No new
protobuf-format work was needed or attempted in this change; the only
remaining step is operational (sinnix redeploy + reingest), not code.

Verification

devtools test tests/unit/storage/test_antigravity_phantom_sweep.py
  -> 5 passed (real parse_brain_metadata/parse_markdown_export fixtures,
     real ArchiveStore.write_raw_and_parsed writer; dry-run leaves the
     session untouched; --apply deletes only the tagged phantom and
     leaves a co-located real antigravity session and its raw row alone)
devtools test tests/unit/devtools/test_command_catalog.py \
  tests/unit/devtools/test_render_devtools_reference.py \
  tests/unit/devtools/test_devtools_main.py
  -> 17 passed
devtools verify --quick
  -> exit_code 0 (ruff format/check, mypy --strict, render all --check,
     topology, layering, closure-matrix, schema/manifest/policy lab checks)

Not run: devtools verify --all (no seeded testmon db in this worktree;
--quick plus the two focused pytest runs above are the verification
evidence for this PR, per repo convention for a worktree without a
pre-seeded testmon cache).

Ref polylogue-eo81, polylogue-msia

Co-Authored-By: Claude <[email protected]>
Sinity added a commit that referenced this pull request Aug 2, 2026
…sions (#3581)

## Summary

Retroactive half of the antigravity-inversion finding (polylogue-eo81 / polylogue-msia, the same finding described in two beads): adds a read-only sweep and an `--apply`-gated actuator that delete the 116 already-materialized brain-metadata phantom sessions in the live archive and persist an explicit non-session classification for their raw rows.

## Problem

Every `antigravity-session` row in the live archive (116/116, measured 2026-07-31) is a 1-message fragment materialized from a per-artifact `~/.gemini/antigravity/brain/<uuid>/*.md.metadata.json` sidecar -- metadata, not conversation content. Real conversation content lives in `conversations/*.pb` trajectories.

Acquiring those `.pb` conversations was already fixed by PR #3441 (merged 2026-07-31): it calls Antigravity's own local language-server RPC (`ConvertTrajectoryToMarkdown`) to export each cascade to markdown -- not a raw protobuf parser, since the language server already exposes trajectory content over RPC -- and verified against all 44 real files on this machine (2,162 real messages, blob sizes matching on-disk `.pb` sizes). That PR also stopped classifying *future* metadata sidecars as sessions (`AGENT_SIDECAR_META`).

That fix is forward-only. The 116 already-materialized phantom sessions, and their still-unclassified raw rows in `source.db`, are untouched by it -- PR #3441's own notes call this out explicitly as deliberately out of scope, deferred to a follow-up. This PR is that follow-up.

## Solution

- `polylogue/storage/antigravity_phantom_sweep.py`: read-only `scan_antigravity_phantom_sessions()`. Joins `sessions` to `session_tags` on the existing `degraded:brain-metadata-fragment` auto-tag (written at ingest time by PR #1856) -- precise, already-present evidence, no new content classification needed. Cross-checks each candidate's `raw_id` against `source.db`'s `raw_sessions` row when a source connection is given, and reports (rather than assumes) when that raw row is already missing.
- `polylogue/storage/artifacts/persistence.py`: adds `materialize_artifact_observations_for_raw_ids()`, a scoped sibling of the existing `materialize_artifact_observations()` full census (from polylogue-hbtj2 / PR #3576), so an actuator that already knows exactly which raw ids it touched doesn't pay for a 43k-row census just to classify a handful of rows. (Also fixes a latent bug in the new function: the connection needs `row_factory = sqlite3.Row` set before `_row_to_raw_session` can read columns by name -- caught by this PR's own test.)
- `devtools/antigravity_phantom_sweep_report.py`: read-only report CLI (text or `--json`).
- `devtools/antigravity_phantom_purge_apply.py`: `--apply`-gated actuator. Dry-run by default; `--apply` calls `ArchiveStore.delete_sessions()` on the flagged session ids (the same primitive CLI `delete` / MCP `write(operation='delete_session')` already reach -- rebuild-safe, since PR #3441's ingest-side classifier already refuses `*.md.metadata.json` as session content and won't resurrect them on re-ingest) and `materialize_artifact_observations_for_raw_ids()` on their raw ids (persists an explicit `AGENT_SIDECAR_META` classification).
- Registered both as `devtools workspace antigravity-phantom-sweep` / `antigravity-phantom-purge-apply`, mirroring the binary-artifact-sweep pattern from polylogue-hbtj2.

## Real `.pb` conversation acquisition: already done, not attempted here

Item 2 of both beads' AC ("decide and, if tractable, implement real `.pb` conversation acquisition") was already resolved by PR #3441 before this session started. No protobuf reverse-engineering was needed: the fix routes through Antigravity's own local language-server export RPC rather than parsing the wire format directly. The only remaining step is operational (Sinnix redeploy of the daemon + a reingest pass to acquire the 44 real conversations), not code -- confirmed still pending as of this PR (`raw_sessions` has zero rows referencing `antigravity/conversations` in the live archive checked during this session).

## Verification

```
devtools test tests/unit/storage/test_antigravity_phantom_sweep.py
  -> 5 passed
```
Builds the phantom shape through the real production parser (`parse_brain_metadata`) and the real archive writer (`ArchiveStore.write_raw_and_parsed`), plus a co-located real antigravity session (`parse_markdown_export`, no degraded flag) to prove the sweep and purge never touch it. Confirms: dry-run mutates nothing; `--apply` deletes only the tagged phantom, leaves the real session and its raw row alone, and writes exactly one `raw_artifacts` row with `artifact_kind = AGENT_SIDECAR_META` for the purged raw id.

```
devtools test tests/unit/devtools/test_command_catalog.py tests/unit/devtools/test_render_devtools_reference.py tests/unit/devtools/test_devtools_main.py
  -> 17 passed
```

```
devtools verify --quick
  -> exit_code 0 (ruff format/check, mypy --strict, render all --check, topology,
     layering, closure-matrix, schema/manifest/policy lab checks)
```

Not run: `devtools verify --all` (no seeded testmon db in this worktree). `--quick` plus the two focused pytest runs above are the verification evidence for this PR.

Manual, read-only cross-check against the live archive (`/realm/db/polylogue`, no writes): confirmed the exact shape both beads describe -- 116 `antigravity-session` rows, all `message_count=1`, all tagged `degraded:brain-metadata-fragment`, all `raw_sessions.source_path` ending `.md.metadata.json`, zero existing `raw_artifacts` rows for any of them, and zero `raw_sessions` rows referencing `antigravity/conversations` (the redeploy+reingest for PR #3441's fix has not happened yet). This PR's actuator was not run against the live archive -- per instruction, only built and tested against fixtures.

Ref polylogue-eo81, polylogue-msia
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 added a commit that referenced this pull request Aug 3, 2026
…ion (#3638)

## Summary

The live daemon never acquired Antigravity's real conversation
trajectories (`conversations/*.pb`) despite PR #3441 fixing the
batch-importer's directory-gate bug. This closes the daemon-side
acquisition gap with a new periodic reconciliation loop, plus two
related bugs found while tracing the root cause.

## Problem

Verified live 2026-08-03 (polylogue-3m3de): `raw_sessions`
origin='antigravity-session' held 232 rows (grown from 116 before PR
#3441 merged three days earlier), every one a `brain/*.md.metadata.json`
sidecar fragment, and zero rows for `conversations/*.pb` -- the 44 real
conversations (314MB) sitting permanently un-acquired by the running
daemon.

Root cause traced to `sources/live/watcher.py`: the live daemon's only
acquisition model for local sources is the `WatchSource` file-watcher,
and for antigravity it only matches `*.metadata.json`
(`WatchSource(name="antigravity", root=antigravity_path(),
suffixes=(".metadata.json",))`). `.pb` files are structurally invisible
to it, and even if watched, the watcher's per-file streaming-JSON model
has no hook to drive the local Antigravity language-server subprocess
the `.pb` -> markdown conversion requires. #3441's fix only reached the
batch importer (`pipeline/services/archive_ingest.py`), which the
running daemon never calls -- only a one-shot `polylogue import` does.
So the watcher kept admitting metadata-only fragments forever while the
real conversations sat permanently un-acquired.

Reproduced directly: running `antigravity.iter_language_server_exports`
against the real `~/.gemini/antigravity` archive (44 real `.pb` files,
314MB) works correctly and yields real conversation content -- the
acquisition *code* is sound, it is simply never invoked by the live
daemon.

Two more bugs surfaced while tracing this:
1. `pipeline/services/archive_ingest.py`'s multi-worker parse branch
called `iter_antigravity_language_server_sessions(source)` without
`capture_raw=True` (unlike the sequential branch), so every exported
session's `raw_data` was `None` and raw provenance collapsed onto one
non-unique source_path instead of each conversation's actual `.pb`
file/bytes.
2. No way to export a bounded subset of cascades --
`iter_language_server_exports` always converted the whole corpus, which
would make a periodic reconciliation loop re-run the language-server
subprocess for already-acquired conversations on every tick.

## Solution

- `sources/parsers/antigravity.py`: added `only_cascade_ids` filter to
`iter_language_server_exports`, threaded through
`source_parsing.iter_antigravity_language_server_sessions`. `None`
(default) preserves existing behavior.
- `pipeline/services/archive_ingest.py`: fixed the parallel-path
`capture_raw` omission.
- New `polylogue/daemon/antigravity_conversation_acquisition.py`:
`periodic_antigravity_conversation_acquisition_check`, following the
existing periodic-daemon-check shape (`embedding_backlog.py`,
`blob_gc_periodic.py`). Runs on a 30-minute cadence via
`daemon_write_coordinator`, diffs `conversations/*.pb` cascade ids
against `raw_sessions` to find not-yet-acquired ones, and converts only
those (bounded to 25/tick) via the new `only_cascade_ids` filter. Wired
into `daemon/cli.py`'s `periodic_loops`.
- `docs/plans/layering-surface-baseline.json`: added 7 entries for the
new daemon module's direct substrate imports, matching the existing
pattern for sibling periodic-check modules (`embedding_backlog.py`,
`blob_gc_periodic.py`, `secret_scan_sweep.py` are baselined the same way
-- there is no existing product-layer seam for "acquire raw provider
bytes" and every sibling periodic check takes the same direct-substrate
path).
- `docs/plans/topology-target.yaml` regenerated for the new module.

**Not in scope / deferred:** actually re-triggering full acquisition
against the live production archive (this PR ships the mechanism; the
daemon will pick up the 44 real conversations on its next reconciliation
tick after deploy). Did not add a `.pb` suffix to the `WatchSource`
itself -- the per-file streaming-JSON watcher model cannot drive a
subprocess conversion, so a dedicated periodic loop is the correct
shape, not a watcher suffix change.

## Verification

- `devtools test tests/unit/sources/test_antigravity_language_server.py`
-- 21 passed (includes 2 new tests for `only_cascade_ids`)
- `devtools test tests/unit/pipeline/test_archive_ingest_shared_raw.py
tests/unit/pipeline/test_archive_ingest_commit_batching.py
tests/unit/sources/parsers/test_antigravity.py` -- 21 passed
- `devtools test
tests/unit/daemon/test_antigravity_conversation_acquisition.py` -- 4
passed (new file: acquisition, idempotent re-run, bounded batching)
- `devtools verify --quick` -- `exit_code: 0`
(format/lint/mypy/render-all/layering all ok)

Ref polylogue-3m3de
@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.

  • 72.F021 / P1: stale at the checked revision: The former parse_sources_archive parallel branch no longer exists. The current daemon cohort conversion at polylogue/sources/live/batch.py:3353-3357 invokes the shared exporter with capture_raw=True and the active blob publisher, retaining protobuf bytes rather than a serialized ParsedSession fallback.
  • 72.F022 / P1: fixed-already at the checked revision: polylogue/sources/source_walk.py:139-143 now admits declared Antigravity protobuf paths. The daemon live batch invokes trajectory conversion and raw capture at polylogue/sources/live/batch.py:3353-3363, so the acquisition path is no longer limited to brain metadata or a direct archive parser.

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

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

  • 73.F016 / P2: stale at the checked revision: polylogue/sources/source_parsing.py:117-119 explicitly removes brain metadata as a transcript fallback. Export errors now produce a coverage-gap report, including obtained and expected counts at :223-225, rather than substituting unrelated artifact fragments for failed conversations.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant