Skip to content

feat(reader): provenance view with bounded raw access (#1125) - #1172

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/reader-provenance-view
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/reader-provenance-view

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a per-conversation provenance read surface (#1125) so the web
reader can show the source artifact and ingest metadata that produced a
conversation, plus an opt-in, server-bounded raw payload preview.

Problem

Operators inspecting an archived conversation had no surfaced answer to
"where did this row come from" — the existing /api/conversations/{id}/raw
endpoint returned provider_meta and a flat raw_artifacts list with no
content hash, no acquisition timestamp, no validation state, and no way
to peek at the actual source bytes safely. The reader's "Raw" inspector
tab repeated provider/branch/parent fields already present elsewhere
without any provenance value.

Solution

  • polylogue/daemon/provenance.py: new module owning the joined
    read from conversations + raw_conversations and the bounded
    raw-payload assembly. RAW_PREVIEW_MAX_BYTES is the hard cap.
    Source paths under $HOME are rendered as ~ so absolute
    filesystem locations do not leak unnecessarily.
  • polylogue/daemon/http.py: new route
    GET /api/conversations/{id}/provenance. include_raw=1 opts
    in to the preview; bytes=N only narrows the window (a client
    asking for 1e9 bytes is clamped to the server cap).
  • Quarantine/unreadable state surfaces explicitly via quarantined +
    quarantine_reason (parse_error, validation_failed, no_raw_artifact,
    blob_missing, blob_unreadable) instead of silently omitting fields.
  • UTF-8 prefixes return as text; non-UTF-8 prefixes fall back to
    base64 so binary artifacts are still inspectable safely.
  • polylogue/daemon/web_shell.py + web_shell_provenance.py:
    inspector "Raw" tab now loads provenance on selection. The raw
    preview button is an explicit opt-in click, not auto-loaded.
    Provenance JS moved to a sibling module so web_shell.py stays
    under its file-size budget.

Alternative considered: a separate /api/conversations/{id}/provenance/raw
endpoint for the preview. Rejected — one endpoint with an explicit
opt-in query parameter keeps the metadata + preview ordering visible
and matches the existing reader pattern.

Verification

  • nix develop -c pytest tests/unit/daemon/test_provenance_endpoint.py
    → 16 passed in 10.45s. Tests pin: bounded-payload contract (clamp
    on huge bytes request), quarantine surfacing for each cause,
    home-path sanitization (no raw home path appears in the serialized
    payload), base64 fallback for binary blobs, 404 for missing
    conversations, and default-omission of the raw preview.
  • nix develop -c pytest tests/unit/daemon/ → 447 passed in 15.46s
    (no regressions in adjacent daemon contract / security tests).
  • nix develop -c devtools verify --quick → exit_code 0 (format,
    lint, mypy --strict, render-all --check, every manifest lint).

Acceptance criteria status (issue #1125)

  • Reader exposes a provenance panel for every conversation with a
    known source artifact — renderInspectorRaw loads provenance
    on selection.
  • Raw payload viewer is bounded; expanding it is an explicit user
    action — include_raw=1 is opt-in and clamped to
    RAW_PREVIEW_MAX_BYTES.
  • Source paths are sanitized for display — home prefix replaced
    with ~; source_path_contains_home advertised so the UI
    shows a "home prefix sanitized" hint.
  • Quarantined / unreadable raw artifacts render explicitly —
    quarantined flag + quarantine_reason enum, no silent gap.
  • Reader routes only through the public provenance read surface —
    no direct raw-table SQL in the reader JS; everything goes through
    /api/conversations/{id}/provenance.
  • Tests assert the raw payload envelope cannot return unbounded
    payloads —
    TestProvenanceEndpoint::test_client_cannot_widen_raw_preview_cap
    sends bytes=999999999 against an 8×-cap blob and asserts
    max_bytes == RAW_PREVIEW_MAX_BYTES and
    bytes_returned <= cap.
  • Visual smoke harness (test(reader): add local web reader visual smoke harness #865) coverage — deferred to test(reader): add local web reader visual smoke harness #865 (the
    harness is separate infrastructure; this PR ships the bounded
    contract the harness will exercise).

Closes #1125

@coderabbitai

coderabbitai Bot commented May 17, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 29 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9fee4930-a2f9-47ed-9bca-791183b4ed35

📥 Commits

Reviewing files that changed from the base of the PR and between f3275ad and e78ec37.

📒 Files selected for processing (8)
  • docs/plans/file-size-budgets.yaml
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/daemon/http.py
  • polylogue/daemon/provenance.py
  • polylogue/daemon/web_shell.py
  • polylogue/daemon/web_shell_provenance.py
  • tests/unit/daemon/test_provenance_endpoint.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/reader-provenance-view

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 and usage tips.

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

ℹ️ 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/daemon/provenance.py Resolved
Per-conversation provenance read surface plus inspector panel.

- New module polylogue/daemon/provenance.py exposes
  build_provenance_payload(): joins conversations + raw_conversations,
  surfaces content_hash, source path (home-sanitized), acquisition
  timestamp, blob size, validation/quarantine state.
- New endpoint GET /api/conversations/{id}/provenance returns the
  metadata envelope. include_raw=1 attaches a bounded raw payload
  preview; the server cap RAW_PREVIEW_MAX_BYTES is enforced regardless
  of client-supplied bytes parameter.
- Web reader Raw inspector tab loads provenance on conversation
  selection; raw preview button is opt-in (no auto-load).
- PROVENANCE_JS extracted to web_shell_provenance.py to keep
  web_shell.py under its file-size budget.
- 16 new tests pin the bounded-payload contract, quarantine surfacing,
  home-path sanitization, and base64 fallback for binary blobs.

Closes #1125
@Sinity
Sinity force-pushed the feature/feat/reader-provenance-view branch from a7d5a31 to e78ec37 Compare May 17, 2026 10:13
@Sinity
Sinity merged commit 89b06f2 into master May 17, 2026
3 checks passed
@Sinity
Sinity deleted the feature/feat/reader-provenance-view branch May 17, 2026 10:13
@Sinity

Sinity commented Sep 30, 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.

  • 65.F001 / P2: Fix and current-source recheck assigned to polylogue-bwuz0; not claimed fixed. polylogue/daemon/provenance.py:318 fixes the top-level quarantine state before the preview read. Lines 360-366 insert the preview and return without propagating its blob_missing or blob_unreadable result into quarantined/quarantine_reason.
  • 65.F037 / P2: stale at the checked revision: polylogue/daemon/web_shell_provenance.py was deleted in 0612cf7 (feat: Complete typed WebUI cutover and delete the legacy interpolated r… (feat: Complete typed WebUI cutover and delete the legacy interpolated r… #4645)); the cited code no longer exists at 5ebcfe5.

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.

feat(reader): provenance view with bounded raw payload access

1 participant