Skip to content

fix(sources): bind acquisition to location and refuse foreign content - #5687

Merged
Sinity merged 15 commits into
claude/canonical-sourcesfrom
claude/strict-detect
Sep 28, 2026
Merged

Sinity merged 15 commits into
claude/canonical-sourcesfrom
claude/strict-detect

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

A source location now admits only its own origin. Shape detection at a bound location validates instead of re-identifying; content carrying another origin's shape is a typed refusal, never reparsed as that origin. Stacked on #5684 (canonical source locations); retarget to master once it merges.

Problem

Detection was cross-origin and outranked location: a payload's shape picked the parser wherever the file sat (detect_provider(...) or fallback). Evidence:

  • A read-only scan of the operator's live sources (aggregate only) found Gemini CLI prompt logs (~/.gemini/tmp/<project>/logs.json, 5 files) and a Hermes observability usage.json classified as Claude Code sessions.
  • The Drive/AI Studio source admitted any .json/.jsonl/.jsonl.txt file in the folder as a session, so a transcript uploaded to a chat was parsed as a session. The real folder holds 212+ prompt files (application/vnd.google-makersuite.prompt) beside ~2,500 attachments (.txt, .md, .pdf, a .json, …).

Solution

  • sources/dispatch.py: detect_provider* take expected; a bound location (anything but UNKNOWN) raises ForeignOriginContentError (code foreign_origin_content, picklable for parse workers) when another origin's detector matches. The raw-bytes chokepoint binds to its fallback_provider. Browser-capture specs use the envelope's declared provider, and refuse an envelope declaring a foreign origin at a bound location.
  • Live daemon (sources/live/batch.py, batch_support.py): the JSONL/JSON sniffs bind to the watched source's origin; a refusal becomes _mark_refused_cursor (warning event + live_ingest_admission convergence debt, re-evaluated each pass). Path-only Hermes checks apply only at a Hermes or unbound location.
  • One-shot ingest (source_acquisition*.py, source_parsing.py, emitter.py): the parse context carries bound_provider; ZIP exports opened from the inbox stay unbound. Refusals are recorded as cursor failures.
  • Declared raw-only paths are classified by location without consulting shape (live JSON branch and one-shot acquisition), so sidecars and prompt logs are retained evidence, never refused as foreign.
  • origin_specs.py: Gemini CLI logs.json is declared a raw-only prompt_history_log.
  • Drive: only the AI Studio prompt MIME type is a session; every other file in the folder is an attachment.
  • AGENTS.md and docs/provider-origin-identity.md describe the fail-closed rule.

Verification

  • devtools test tests/unit/sources/test_location_binding.py tests/unit/sources/test_drive_source_client.py tests/unit/sources/test_source_laws.py::test_session_emitter_detects_individual_jsonl_provider_from_payloads tests/unit/sources/test_live_batch_support.py tests/unit/sources/test_dispatch_evidence.py tests/unit/sources/test_dispatch_payloads.py → 282 passed, 1 failed. The failure, test_source_only_full_ingest_streams_admitted_zip_members_without_decoding, also fails on master.
  • A broader 38-file sources/pipeline selection before the rebase: 1085 passed, 18 failed. Two were mine (a detection stub signature, and the Drive pagination contract), both fixed. Of the other 16, six were re-run on the base and fail identically there: test_origin_contract[grok-export], the two otel tool-outcome contracts, the capability-matrix ingest seam, the hook-producer import check, and the gemini-cli token test. The remaining ten were not re-run on the base. They are the browser-capture tests that require a daemon (7), the skill_asset taxonomy test, the grok advertised-shapes test, and the ZIP streaming test; other workers today reported all of them failing on master.
  • Replay parity: parse_one_source_path over a 262 MB synthetic workload corpus (generate_workload_corpus(seed=11), 105 files, 61 sessions), base vs branch. The provider, session id and session_content_hash for every file are byte-identical (cmp). Timing is 23.8 s vs 24.0 s on alternating warm runs.
  • Real-source scan with the branch: all 24,324 Claude Code and 9,247 Codex files are unaffected. The Gemini CLI prompt logs are now raw-only evidence, and the Hermes usage.json is refused.
  • devtools schema closure: dispatch, batch, batch_support, source_acquisition_components, source_parsing, emitter, cursor, origin_specs and drive/source_support are IN, so this moves the derived identity and must land before the fresh build.

Residuals

  • Refused files are re-evaluated and re-recorded on every live pass (by design; moving the file clears it).
  • import explain and retained reparse sites stay unbound, since they also serve inbox ZIP exports with mixed record kinds; admission, where binding matters, happens at acquisition.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@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: 3e959fd10c

ℹ️ 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/dispatch.py Resolved
Comment thread polylogue/sources/live/batch_support.py Resolved
Comment thread polylogue/sources/cursor.py Resolved
Comment thread polylogue/sources/live/batch_support.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Comment thread polylogue/sources/live/batch_support.py Resolved
Comment thread polylogue/sources/emitter.py Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T04:20:33.221261Z a5e3e53 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 700708dac0

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/source_acquisition.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/sources/source_parsing.py Resolved

@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: be8e2fe501

ℹ️ 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/decoder_zip.py Resolved

@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: 36538f08b8

ℹ️ 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/origin_specs.py Resolved

@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: d6c23fa752

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Comment thread polylogue/sources/source_parsing.py Resolved
Comment thread polylogue/sources/decoder_zip.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
@Sinity
Sinity force-pushed the claude/strict-detect branch from d6c23fa to 95eaab8 Compare September 27, 2026 23:12

@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: 95eaab8fb7

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/source_parsing.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved

@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: ee393ad711

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved

@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: f8f9853104

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
@Sinity
Sinity force-pushed the claude/canonical-sources branch from 8458849 to 897c0cf Compare September 28, 2026 01:33

@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: ca8bd5d1c2

ℹ️ 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/dispatch.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved

@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: 6057f07c12

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/daemon/cli.py Resolved

@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

self._cursor.record_convergence_debt(
stage="live_ingest_admission",
subject_type="source_path",
subject_id=str(path),
error=reason,

P2 Badge Clear plain-file admission debt after correction

When a bound plain file is first refused and later replaced with valid owning-origin content, the next pass ingests it successfully but never clears this live_ingest_admission row. This stage is excluded from the generic debt drain, so readiness remains degraded indefinitely despite the corrected file; clear the path's admission debt on successful acquisition, as the ZIP-member path does.

AGENTS.md reference: AGENTS.md:L129-L134

ℹ️ 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/live/batch.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/sources/source_parsing.py Resolved

@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: 66f47af4bb

ℹ️ 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/daemon/cli.py Resolved
Comment thread tests/infra/daemon_cold_start.py Resolved
Sinity and others added 13 commits September 28, 2026 05:50
A source location now admits only its own origin. Shape detection at a
bound location validates instead of re-identifying: content carrying
another origin's shape raises ForeignOriginContentError, which the daemon
records as a typed admission refusal (live_ingest_admission debt) and
one-shot ingest records as a cursor failure. Only the import inbox and
browser-capture envelopes, which declare their provider, still classify.

Drive admits only the AI Studio prompt MIME type, so a transcript the
operator uploaded to a chat stays an attachment. Gemini CLI's prompt log
is declared raw-only, and declared raw-only paths are classified by
location without consulting shape.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…cation

Review follow-up: provider wires of one origin (drive/gemini) are not
foreign; the JSON sampler no longer swallows the refusal as a ValueError;
raw-only paths are classified before any content probe; ZIP members and
the live Hermes/Codex SQLite arms inherit the location binding; fact
documents are validated like sessions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
… one-shot code

Second review round: a refused ZIP member no longer discards admissible
siblings; bound JSON documents are validated before their blob enters
the publication batch; browser-capture envelopes keep their declared
provider (a sequence's first element is a parser hint, not a location);
one-shot parse refusals record the foreign_origin_content code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…blishing

Third review round: grouped ZIP members are validated against the
archive location before preservation; the live ZIP path passes its
binding and names refused members; one-shot plain files are validated
from the source path before streaming, so a refused file never enters
the publication batch; raw-only ZIP members skip session probing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…ct, grouped and source-only input

Round five review: production-baseline ZIP replay shares the grouped-member validator and records refused members as excluded, so replay and live agree; live ZIP member refusals create live_ingest_admission debt; one-shot fact documents are validated before the non-session return; grouped ZIP members are validated before publication; the source-only live route validates bound raws from a bounded prefix before retaining them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…ed member debt

Round six review: source-only ZIP members are validated against the
location before preservation; .jsonl.txt streams are validated on the
source-only route; grouped plain files are validated before one-shot
publication; baseline replay binds the location rather than the sniffed
dominant provider, so inbox archives stay unbound; an admitted ZIP member
clears its earlier refusal debt; unsupported broad-root candidates with
another origin's shape are refused rather than excluded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…n route

Round seven review, and the invariant behind the rounds before it: every
acquisition route calls refuse_foreign_material before a bound source
file's bytes are retained, published, parsed or baselined. The live
source-only and broad-root branches, one-shot plain, fact and grouped
files, and the production baseline now share that check instead of
open-coding it. Also: retained ZIP enumeration binds the declared source
and records foreign members as refused member dispositions; a post-copy
refusal drops its queued publication (ArchiveBlobPublisher
.discard_pending_hash); a pass over a bound archive clears refusal debt
for members it no longer refuses, including removed ones.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Round eight review. The invariant behind the remaining races: a path
check followed by a copy validates bytes other than the ones retained.
Every retaining route now captures first and validates the captured blob
once (sources/bound_capture.py) before any raw is recorded, dropping the
queued publication on refusal; the pre-copy path checks it replaces are
removed. Also: grouped-member and oversized-first-record validation is
byte-bounded (completed keys of a truncated record still decide);
ZIP-member debt is keyed by ordinal so duplicate names stay distinct;
source-only ZIP passes reconcile member debt; retained plain inputs bind
the declared location, not the database-member binding.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…clared DBs, aliases

Round nine review: a bound document validates each record instead of locking onto the first provider; one-shot grouped files validate the captured bytes before the flush reserves them; a declared database member of another origin is refused by the shared choke point; retained source aliases resolve to their origin before binding.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…t refusals

Round ten review: the production baseline validates the same first chunk it hashes rather than a separate read, so a file changed between the two cannot be baselined as accepted while live capture refuses it; an aborted ZIP scan drops its partial per-pass refusal set.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Round eleven review: one-shot grouped parsing reads the captured,
validated blob instead of reopening the source path; the shared check
validates the completed partial structure of a truncated JSON document,
not only of a truncated JSONL record; an unreadable ZIP member keeps any
refusal gap it carried.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@Sinity
Sinity force-pushed the claude/strict-detect branch from 66f47af to 0ca47e2 Compare September 28, 2026 03:57
Round twelve review: a grouped capture refused while parsing (its
discriminator beyond the validation prefix) releases the reservation its
flush made; a retained ZIP member refused mid-split drops the splits it
had already captured.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@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: b262dc52f7

ℹ️ 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/decoder_zip.py Resolved
Comment thread polylogue/sources/live/batch.py Resolved
Round thirteen review, answered with one rule instead of per-route
cleanup: release_captures_on_refusal scopes an admission unit (a file,
a ZIP member); on ForeignOriginContentError every capture the unit made
is released by receipt, so identical captures are each released. Applied
to one-shot grouped files, one-shot ZIP members, retained ZIP members,
and live ZIP members, which also roll back the records they had yielded.
The Hermes SQLite fast path refuses a foreign declared database before
snapshotting.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@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

self._cursor.record_convergence_debt(
stage="live_ingest_admission",
subject_type="source_path",
subject_id=str(path),
error=reason,

P2 Badge Clear admission debt after a plain file recovers

When a bound plain file is refused and a later revision contains valid owning-origin content, the successful ingest resets its cursor but never clears the live_ingest_admission debt created here. A repository-wide check shows that this stage is cleared only for ZIP-member subjects, so the stale plain-path row keeps readiness degraded even after the corrected file has been durably ingested. Fresh evidence beyond the ZIP reconciliation fixes is this separate plain-file debt key; clear it when the path is successfully admitted or removed.

AGENTS.md reference: AGENTS.md:L129-L134

ℹ️ 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_acquisition.py Resolved
Comment thread polylogue/sources/decoder_zip.py Resolved
Comment thread polylogue/sources/live/cursor.py Resolved
@Sinity
Sinity merged commit 5689fcd into claude/canonical-sources Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the claude/strict-detect branch September 28, 2026 07:17
Sinity added a commit that referenced this pull request Sep 28, 2026
…#5687)

A source location now admits only its own origin. Shape detection at a
bound location validates instead of re-identifying; content carrying
another origin's shape is a typed refusal, never reparsed as that
origin. Stacked on #5684 (canonical source locations); retarget to
`master` once it merges.

Detection was cross-origin and outranked location: a payload's shape
picked the parser wherever the file sat (`detect_provider(...) or
fallback`). Evidence:
- A read-only scan of the operator's live sources (aggregate only) found
Gemini CLI prompt logs (`~/.gemini/tmp/<project>/logs.json`, 5 files)
and a Hermes observability `usage.json` classified as **Claude Code**
sessions.
- The Drive/AI Studio source admitted any `.json`/`.jsonl`/`.jsonl.txt`
file in the folder as a session, so a transcript uploaded to a chat was
parsed as a session. The real folder holds 212+ prompt files
(`application/vnd.google-makersuite.prompt`) beside ~2,500 attachments
(`.txt`, `.md`, `.pdf`, a `.json`, …).

- `sources/dispatch.py`: `detect_provider*` take `expected`; a bound
location (anything but `UNKNOWN`) raises `ForeignOriginContentError`
(code `foreign_origin_content`, picklable for parse workers) when
another origin's detector matches. The raw-bytes chokepoint binds to its
`fallback_provider`. Browser-capture specs use the envelope's declared
provider, and refuse an envelope declaring a foreign origin at a bound
location.
- Live daemon (`sources/live/batch.py`, `batch_support.py`): the
JSONL/JSON sniffs bind to the watched source's origin; a refusal becomes
`_mark_refused_cursor` (warning event + `live_ingest_admission`
convergence debt, re-evaluated each pass). Path-only Hermes checks apply
only at a Hermes or unbound location.
- One-shot ingest (`source_acquisition*.py`, `source_parsing.py`,
`emitter.py`): the parse context carries `bound_provider`; ZIP exports
opened from the inbox stay unbound. Refusals are recorded as cursor
failures.
- Declared `raw-only` paths are classified by location without
consulting shape (live JSON branch and one-shot acquisition), so
sidecars and prompt logs are retained evidence, never refused as
foreign.
- `origin_specs.py`: Gemini CLI `logs.json` is declared a raw-only
`prompt_history_log`.
- Drive: only the AI Studio prompt MIME type is a session; every other
file in the folder is an attachment.
- `AGENTS.md` and `docs/provider-origin-identity.md` describe the
fail-closed rule.

- `devtools test tests/unit/sources/test_location_binding.py
tests/unit/sources/test_drive_source_client.py
tests/unit/sources/test_source_laws.py::test_session_emitter_detects_individual_jsonl_provider_from_payloads
tests/unit/sources/test_live_batch_support.py
tests/unit/sources/test_dispatch_evidence.py
tests/unit/sources/test_dispatch_payloads.py` → 282 passed, 1 failed.
The failure,
`test_source_only_full_ingest_streams_admitted_zip_members_without_decoding`,
also fails on master.
- A broader 38-file sources/pipeline selection before the rebase: 1085
passed, 18 failed. Two were mine (a detection stub signature, and the
Drive pagination contract), both fixed. Of the other 16, six were re-run
on the base and fail identically there:
`test_origin_contract[grok-export]`, the two otel tool-outcome
contracts, the capability-matrix ingest seam, the hook-producer import
check, and the gemini-cli token test. The remaining ten were not re-run
on the base. They are the browser-capture tests that require a daemon
(7), the `skill_asset` taxonomy test, the grok advertised-shapes test,
and the ZIP streaming test; other workers today reported all of them
failing on master.
- Replay parity: `parse_one_source_path` over a 262 MB synthetic
workload corpus (`generate_workload_corpus(seed=11)`, 105 files, 61
sessions), base vs branch. The provider, session id and
`session_content_hash` for every file are byte-identical (`cmp`). Timing
is 23.8 s vs 24.0 s on alternating warm runs.
- Real-source scan with the branch: all 24,324 Claude Code and 9,247
Codex files are unaffected. The Gemini CLI prompt logs are now raw-only
evidence, and the Hermes `usage.json` is refused.
- `devtools schema closure`: dispatch, batch, batch_support,
source_acquisition_components, source_parsing, emitter, cursor,
origin_specs and drive/source_support are IN, so this moves the derived
identity and must land before the fresh build.

- Refused files are re-evaluated and re-recorded on every live pass (by
design; moving the file clears it).
- `import explain` and retained reparse sites stay unbound, since they
also serve inbox ZIP exports with mixed record kinds; admission, where
binding matters, happens at acquisition.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Adds a CircleCI job, `stacked-review-threads`, to the `gate` workflow.
On a PR targeting master, it fails while any PR merged into that PR's
head branch, at any stack depth, has an unresolved review thread. The
log names each offending PR and thread URL.

## Problem

Master's branch protection requires conversation resolution, but a PR
merged into another PR's head branch is never checked. #5682 merged into
#5643's branch and #5687 into #5684's with 11 unresolved Codex threads
between them; that code reaches master through the parent PR.

## Solution

- `devtools/stacked_review_threads.py` (stdlib only) walks merged PRs
whose base is the root's head branch, then their head branches,
recursively. Every PR merged into the root's head branch counts, and so
does every PR merged into a stacked head before that head merged. Commit
ancestry and PR creation windows are not used, because rebases and
squash merges erase both. Each parent PR is expanded once, and threads
are read only for PRs inside the stack.
- `.circleci/config.yml` gains the `stacked-review-threads` job. It
skips non-PR builds and fork PRs, since nothing in this repository can
merge into a fork branch. GitHub Actions is billing-locked on this repo,
so CircleCI is the mechanism.
- Actions has no trigger for resolving a thread, and CircleCI has none
either. The job re-evaluates on each push, and "Rerun workflow"
re-triggers it by hand.

## Verification

- `nix develop --command devtools test
tests/unit/devtools/test_stacked_review_threads.py`: `devtools test:
PASSED exit=0` (9 passed). The tests use synthetic GraphQL responses and
cover two-level stacks, PRs merged before the root or the child opened,
reused child lifetimes, post-merge grandchildren, thread pagination, and
a branch cycle.
- `ruff check`, `ruff format --check`, and `mypy` on both files: clean.
- A read-only live run of `python3 -m devtools.stacked_review_threads
--repo Sinity/polylogue --pr 5643` exits 1 and names #5682 with 7
unresolved threads. The same run with `--pr 5684` names #5687 with 4.

## Residuals

- **Operator action needed.** The CircleCI project has no GitHub token,
so the job currently fails with `no GitHub token: set GH_TOKEN or
GITHUB_TOKEN`. Add a read-only token (pull requests: read on
Sinity/polylogue) as the project's `GH_TOKEN` variable. After that, add
`ci/circleci: stacked-review-threads` to master's required contexts.
- A PR merged long ago into a branch whose name was later reused fails
the gate and is named in the log; resolving its threads clears it. A
read-only run across all 36 open master PRs showed no such case.
- Branch renames are not followed, because GitHub keeps no rename
history.
- After a thread is resolved, or unresolved again, the result stays
stale until the next push or a rerun.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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