Skip to content

feat(demo): measure completion claims against tool outcomes - #2795

Merged
Sinity merged 9 commits into
masterfrom
feature/fanout/demo-corpus
Jul 13, 2026
Merged

Sinity merged 9 commits into
masterfrom
feature/fanout/demo-corpus

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a deterministic, origin-stratified completion-claim cohort to polylogue demo receipts. Each sampled claim resolves only against typed tool outcomes and carries block-level evidence references.

Ref polylogue-67ac

Problem

The deterministic receipt showed one contradiction, but could not name a reproducible completion-claim population, sample selection, denominator, or aggregate unsupported/repaired rates.

Solution

  • Add a reusable deterministic cohort manifest compiler.
  • Select only assistant-authored completion-language candidates, stratified by origin with a template cap.
  • Require a fresh message FTS surface; missing or stale search evidence returns a typed failed receipt rather than a partial denominator.
  • Classify every typed action outcome, including is_error-only outcomes. A generic prior outcome is neutral; only a same-command failed→successful sequence is contradicted_then_repaired.
  • Compare each outcome at its result block's canonical transcript position, including message variants; report counts and percentages for every denominator bucket.
  • Render the aggregate headline and evidence references through demo receipts, and document the explicit local live-archive path.

Verification

  • POLYLOGUE_PYTEST_TMPDIR=/realm/tmp/polylogue-pytest python -m devtools test tests/unit/demo/test_demo_completion_claims.py — 13 passed.
  • python -m devtools verify --quick — passed: format, lint, strict mypy, generated surfaces, topology, layering, schema, and policy gates passed.
  • polylogue demo seed, polylogue demo verify, and polylogue demo receipts --completion-claims-only --format json against an isolated /realm/tmp archive — passed; seeded denominator 2, with 0.0% unsupported and 50.0% contradicted-then-repaired.
  • Anti-vacuity: the focused tests exercise the real seeded provider-parser/storage/action-view route. Deleting the stored recovery makes the evidence contradicted_without_recorded_repair; moving a result to a later variant makes the claim unsupported; removing tool-input command or tool-name identity forbids a repair match; nulling is_error preserves unknown; missing FTS refuses publication. Removing the corresponding production timing, identity, null-preservation, or FTS checks makes those tests fail.

Acceptance matrix

Bead Status Evidence
polylogue-67ac Partially satisfied The runtime API and live CLI route produce a deterministic manifest, denominator, category percentages, evidence refs, and typed classification. The requested live X/Y headline is deferred: repeated read-only live captures entered I/O sleep before output, so no stale or fabricated number is published.
polylogue-212.11 Deferred Existing construct 1 was already delivered; residual parser-v1/v2 interpretation and typed cross-source 14:32 hooks remain outside this PR.

@coderabbitai

coderabbitai Bot commented Jul 12, 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: 52 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

Run ID: ac7049d2-b6f9-4a11-bdc0-1b48b5f76e57

📥 Commits

Reviewing files that changed from the base of the PR and between 3a5102b and 787beac.

📒 Files selected for processing (6)
  • README.md
  • docs/plans/topology-target.yaml
  • polylogue/cli/commands/demo.py
  • polylogue/demo/__init__.py
  • polylogue/demo/receipts.py
  • tests/unit/demo/test_demo_completion_claims.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fanout/demo-corpus

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.

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

ℹ️ 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/demo/receipts.py Resolved
Comment thread polylogue/demo/receipts.py Resolved
@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 1

Findings and fixes:

  • Real: is-error-only tool results were dropped. Fixed outcome selection to retain either typed exit_code or is_error, with a provider-shaped regression.
  • Real: completion candidates admitted assistant-role protocol/context material. Fixed population filtering to assistant_authored, with a runtime-protocol exclusion regression.
  • Real: FTS-derived population could silently use stale/missing search state. Added the normal FTS readiness gate and a missing-FTS regression that returns a typed failed receipt without a headline.
  • Real: a generic preceding success was presented as support. Reclassified it as neutral prior_outcome_recorded; only same-command structural failure followed by success is called repaired.
  • Real: the README lacked a safe local live-archive invocation. Added an explicit --root … --no-seed path and its privacy/readiness constraints.
  • Borderline resolved: the result now includes an evidence fingerprint over selected claim refs, classifications, and typed outcome values, so evidence-state drift is visible separately from population selection.

Verification: python -m devtools test tests/unit/demo/test_demo_completion_claims.py (6 passed) and python -m devtools verify --quick (all observed gates passed).

The live aggregate remains intentionally unquoted: the live archive read did not complete, so publishing an X/Y number would be dishonest.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 2

Independent review found and this branch fixed:

  • Real: action timing was tied to the tool-use message. The resolver now joins the paired tool-result block and orders/filters by its owning message, with a late-result regression.
  • Real: neutral prior outcomes and unrepaired contradictions did not appear in headline accounting. The headline now exposes unsupported, neutral-prior, contradicted-then-repaired, and contradicted-without-repair buckets; their counts partition the denominator.
  • Real: the prior live README command still ran fixture-only proof logic. demo receipts --completion-claims-only --root … --no-seed now runs the live-compatible cohort route directly; the seeded CLI test proves that route.
  • Borderline fixed: evidence fingerprint drift is now tested independently from unchanged candidate-manifest identity.

Verification: python -m devtools test tests/unit/demo/test_demo_completion_claims.py (9 passed); python -m devtools verify --quick passed.

The live metric is still deferred honestly: runtime capability and documentation are present, but no current live X/Y receipt is committed until a read completes.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 3

Independent hostile review found and this branch fixed:

  • Real: human receipts showed counts but not the requested X%/Y% form. JSON now emits explicit percentage fields and both renderers show count plus percentage.
  • Real: comparisons ignored variant_index (and claim block position). Resolver predicates now use the canonical (message position, variant index, block position) ordering, with a same-position-variant regression.
  • Real: two same-tool actions with absent commands could compare as "" == "" and be called a repair. A repair now requires a nonempty canonical command, with a provider-storage regression.
  • Real: strict mypy rejected the dynamic renderer payload. Added runtime type validation; the pre-push quick gate then passed.
  • PR hygiene: refreshed the body from stale “6 passed” to the current 11 focused tests and documented the production dependencies and failure mutations.

Verification: POLYLOGUE_PYTEST_TMPDIR=/realm/tmp/polylogue-pytest python -m devtools test tests/unit/demo/test_demo_completion_claims.py — 11 passed; python -m devtools verify --quick — passed in pre-push.

Survived scrutiny: all action outcome decisions remain based on paired typed tool-result blocks, not assistant prose; every headline bucket still partitions the selected denominator.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 4

Independent hostile review found and this branch fixed:

  • Real: nullable typed is_error was coerced to false in emitted evidence, turning SQL unknown into a success claim. Evidence now preserves null, while classification still uses the retained exit code.
  • Real: repair matching also needs a known tool identity; two empty tool names could otherwise satisfy the same-tool comparison. Repairs now require nonempty tool name and command evidence.
  • Gate classification: the first pre-push quick run hit a transient mypy internal error under concurrent lane I/O; a direct full mypy --show-traceback passed for 1,912 sources, then a complete devtools verify --quick passed and stamped the pushed HEAD.

Verification: focused completion-claim suite passed (13 tests); python -m devtools verify --quick passed at 72a729ccf.

Survived scrutiny: receipt evidence preserves the archive's three-valued outcome truth; repaired is reserved for a typed, ordered, same-tool-and-command successful outcome.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 5 (clean)

Fresh clean-room review of origin/master...HEAD, both Beads including notes, PR body/comments, and inline feedback found zero new substantive findings.

What survived scrutiny:

  • The public seeded route was rerun on an isolated /realm/tmp archive: demo seed, demo verify, and the completion-claims receipt all passed. Its small public denominator is explicitly a method proof, not the deferred live prevalence metric.
  • All existing bot findings are fixed; no new substantive PR comments arrived (CodeRabbit remains rate-limited).
  • PR metadata was refreshed to the current 13-test result and the isolated command output; no production code changed after the clean review.

This reaches the requested clean-review fixpoint. No merge and no Bead state change were performed.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Final acceptance-criteria matrix

Bead Acceptance criterion Status Evidence / residual
polylogue-67ac Deterministic population/sample manifest; typed outcome resolution; denominator, missingness, evidence refs; receipts + README packaging Satisfied demo receipts --completion-claims-only emits the manifest, all four denominator buckets and block refs; README documents the private local command. The seeded CLI result is reproducible.
polylogue-67ac Publish the live-archive X% unsupported / Y% repaired headline Deferred Repeated read-only live attempts entered I/O sleep before output. This PR deliberately does not fabricate or retain a stale live number; the shipped command is ready to produce it locally when the archive read completes.
polylogue-212.11 Shared deterministic incident-world additions and construct verifier coverage Deferred This PR uses the existing receipts construct. Bead notes record prior delivery of the other constructs; parser v1/v2 interpretation and typed cross-source 14:32 hooks remain residual, out of this PR.

No Beads were closed or claimed.

Sinity and others added 9 commits July 13, 2026 02:21
Regenerate the topology projection after adding the deterministic cohort compiler.\n\nCo-Authored-By: Codex <[email protected]>
Problem: the deterministic receipts proof showed one contradiction but could not state a reproducible completion-claim sample frame or aggregate headline.\n\nWhat changed: compile an origin-stratified deterministic cohort manifest for declared completion-language candidates, then classify each only from typed action outcomes. The result reports unsupported and contradicted-then-repaired denominators with block evidence references.\n\nCompatibility: completion language is a declared lexical population, not an assertion that every assistant statement is a completion claim.\n\nRef polylogue-67ac\n\nCo-Authored-By: Codex <[email protected]>
Route completion-claim receipt lookup through messages_fts before
block lookup, avoiding a generic complete/finished corpus scan.

Verified: tests/unit/demo/test_demo_completion_claims.py — 2 passed;
quick gate passed.

Co-Authored-By: Claude <[email protected]>
Problem: completion-claim receipts could omit is-error-only outcomes, include protocol text, overstate a prior action as support, and raise if its FTS evidence was unavailable.\n\nWhat changed: require assistant-authored material and fresh FTS, retain every typed outcome, record an evidence-state fingerprint, and keep unavailable evidence inside the receipt's typed failure result. Document the explicit local live-archive invocation.\n\nCompatibility: a prior outcome now remains a neutral observation instead of support for a completion claim.\n\nRef polylogue-67ac\n\nCo-Authored-By: Codex <[email protected]>
Problem: the fixture receipts command could not run its completion cohort against an ordinary operator archive because it first required fixture-specific sessions.\n\nWhat changed: add an explicit completion-claims-only route that emits the cohort directly, while retaining the default deterministic fixture proof.\n\nRef polylogue-67ac\n\nCo-Authored-By: Codex <[email protected]>
Problem: completion claim evidence was ordered by tool invocation, and the aggregate concealed neutral or unrepaired evidence states.\n\nWhat changed: order actions by their paired result message, expose every classification bucket in the headline, and fingerprint the selected typed evidence separately from the sample manifest.\n\nRef polylogue-67ac\n\nCo-Authored-By: Codex <[email protected]>
Problem: completion receipts rendered only counts, ignored transcript variants, and could match two actions with absent command evidence as a repair.

What changed: expose percentage headline fields, compare claim and outcome by the canonical message/block ordering tuple, and require a nonempty canonical command for a repair match. Exercise all three paths through the seeded archive.

Ref polylogue-67ac
Problem: strict typing could not establish the dynamic headline payload field types.

What changed: validate count and percentage payload values before formatting the human receipt.

Ref polylogue-67ac
Problem: nullable typed outcome fields were rendered as known false values, and a blank tool name could satisfy repair identity.

What changed: retain NULL is_error as unknown in evidence output and require a nonempty tool name and command for repair classification. Add seeded archive regressions for both evidence gaps.

Ref polylogue-67ac
@Sinity
Sinity force-pushed the feature/fanout/demo-corpus branch from 72a729c to 787beac Compare July 13, 2026 00:22
@Sinity
Sinity merged commit 7b48d36 into master Jul 13, 2026
3 of 15 checks passed
@Sinity
Sinity deleted the feature/fanout/demo-corpus branch July 13, 2026 00:22
Sinity added a commit that referenced this pull request Jul 13, 2026
…807,2780,2790,2791,2795,2802,2806,2809

uwk3, jph5 (rigor-contracts #2783), bby.17 (web-cockpit #2793), dmp
(terminal-note #2801), ra3w (basetemp-fix #2807), r4no/bkff/r2kb
(extension-redesign #2780) fully satisfied — closed. nhjs (#2793), peo
(daemon-forensics #2802), 4g3n (#2780), 67ac/212.11 (demo-corpus #2795),
rsad (mcp-ergonomics #2790, real gaps remain per 5-iteration adversarial
cap), 9e5.8.4/jnj.7 (provider-origin #2806), mrxt/37t.12/p5g/rxdo.4
(annotation-judgment #2791), s7ae.8/20d.2 (live-performance-2 #2809)
partially satisfied — noted with disposition, left open.

Also discovered and documented the actual root cause of this session's
recurring bead-revert incidents: bd reimports the live database from
.beads/issues.jsonl on every CLI invocation, so a write not immediately
exported is lost the moment the next bd command runs. Every mutation in
this commit was individually export-verified against that behavior.

Co-Authored-By: Claude <[email protected]>
Sinity added a commit that referenced this pull request Jul 14, 2026
…2885)

## Summary

Adds `devtools demo real-slice-screen`, a read-only extraction + privacy
screening harness for candidate real-archive session slices, plus the
harness's own test coverage. This is the "harness/fixture machinery"
half of
polylogue-212.11's real-archive-data extension; the actual candidate
slice
and its privacy write-up are a separate, deliberately-unmerged artifact
(see
Verification below) awaiting operator spot-check before any real content
is
folded into `polylogue/scenarios/`.

## Problem

polylogue-212.11 ("one shared deterministic proof world for all flagship
demos") has already landed 37 declared constructs on a fully-synthetic
Incident 14:32 corpus (PRs #2662, #2674). Per explicit operator
direction,
the shared proof world should also draw on a real, representative slice
of
the operator's own archive (`/realm/db/polylogue`) rather than staying
synthetic-only — "the point is representative data, not full
determinism."

That requires a privacy-vetting step. The bead's own instructions are
explicit that this step must **not** be autonomous: a candidate slice
has to
be pulled, screened, and handed to the operator as a flagged, reviewable
artifact before it becomes a permanent shared fixture. This PR ships the
reusable machinery for that step; it does not itself promote any real
content into the product tree.

## Solution

- **`devtools/proof_world_real_slice.py`** — given one or more session
ids
(or a refs file) and a real archive root, opens the archive read-only
via
  `Polylogue.get_session()` (the API's `ArchiveStore.open_existing(...,
  read_only=True)` default — never mutates the source archive), flattens
each session's message text + structured block payloads to plain text,
and
  runs a pattern screen:
  - **secret/credential shapes**: AWS access key ids, generic
    `key=value`/`key: value` credential assignments, bearer tokens,
    `BEGIN ... PRIVATE KEY` blocks, OpenAI-style `sk-...` keys, Slack
    tokens, SSH public keys, JWT-shaped strings.
  - **PII-adjacent shapes**: email addresses, `/home/<user>` paths, IPv4
    addresses — with a small allowlist for common test placeholders
(`[email protected]`, `127.0.0.1`, `0.0.0.0`, ...) so the report isn't
    dominated by noise from ordinary test fixtures.
- Any secret-pattern hit -> `flagged`; any non-allowlisted PII hit (with
no
    secret hit) -> `review`; otherwise `clean`.
  - Writes `SCREENING_REPORT.md` (per-session verdict + truncated match
    samples), `manifest.json`, and per-session `transcripts/*.txt` to an
arbitrary output directory. It never writes into `polylogue/scenarios/`
or any other product fixture path — promoting a slice stays a distinct,
    explicit, human-gated step.
- Registered as `devtools demo real-slice-screen` in
`devtools/command_catalog.py` (category `workspace`); `docs/devtools.md`
  regenerated via `devtools render devtools-reference`.
- `tests/unit/devtools/test_proof_world_real_slice.py`: pure-function
  coverage of the pattern scanner and verdict logic (including the
  allowlist), the text-flattening helper, report rendering, CLI argument
handling, and an end-to-end read path against a `SessionBuilder`-seeded
archive that plants a real AWS-key-shaped string and asserts it is both
  read back correctly and flagged.

### What this PR does *not* do

- It does not fold any real archive content into the shared demo corpus.
  I ran the harness against 5 candidate sessions from the operator's own
archive (their own dev-work sessions on this very repository —
flaky-test
hunting, pipeline-idempotency test design, and two issue
implementations)
  and wrote up the result (0 flagged, 3 "review" — all traced to test
  placeholders/loopback IPs/the operator's own home path in their own
tool-output truncation messages, not third-party data — 2 fully clean)
as
  a distinct, gitignored artifact under
`.agent/scratch/real-slice-vetting-2026-07-14/` (`OPERATOR-SUMMARY.md`,
`SCREENING_REPORT.md`, `manifest.json`, `transcripts/`). That directory
is
**not** part of this diff — `.agent/scratch/*` is gitignored — and is
left
  in place for a quick operator spot-check per the task's explicit
instruction that this step "should NOT be treated as fully autonomous."
- The remaining declared-but-unimplemented AC items from the bead notes
(parser v1/v2 dual interpretation, typed cross-source 14:32 event hooks)
  are unaffected by this PR and remain open follow-up scope on
polylogue-212.11 — see the bead's own notes history (PRs
#2662/#2674/#2795).
- No raw provider JSON/JSONL bytes were extracted from the archive's
blob
store; the harness reads normalized message text via the `Polylogue`
API.
  If/when the slice is approved, a follow-up should decide whether real
  parser-replay fidelity (raw bytes) or the normalized text is the right
  fixture-generator input — that decision is out of scope here.

## Verification

```
devtools test tests/unit/devtools/test_proof_world_real_slice.py tests/unit/devtools/test_command_catalog.py
  -> 19 passed in 37.41s

devtools verify --quick
  -> exit_code 0 (ruff format/check, mypy --strict, render all --check,
     topology/layering/closure-matrix/manifests/ci-workflows/doc-commands/
     test-infra-currency/test-clock-hygiene/pytest-timeout-overrides/
     degrade-loudly all ok)
```

Anti-vacuity:
`test_screen_session_reads_real_archive_and_flags_planted_secret`
drives the real production path (`Polylogue.get_session` against a
`SessionBuilder`-seeded archive, not a mock/stub) and fails if
`scan_text`'s
secret-pattern set is emptied, or if `screen_session` stops calling it.

Ref polylogue-212.11.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added a read-only command to extract and privacy-screen candidate
archive sessions.
  - Supports selecting sessions directly or from a references file.
- Generates screening reports, structured results, and transcript files.
- Detects credential-like content and personally identifying
information, with redacted secret samples.

- **Documentation**
  - Added the new workspace command to the developer tools catalog.

- **Tests**
- Added coverage for detection, redaction, verdicts, file handling,
reporting, and command-line validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <[email protected]>
@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.F047 / P2: fixed-already at the checked revision: The completion-claim action query accepts either a known exit_code or is_error at polylogue/demo/receipts.py:272, and classification reads is_error independently at line 297. The prior and repair result projections also guard nullable exit codes at lines 415 and 421, preserving is_error-only failures and later repairs without a conversion exception.
  • 65.F048 / P2: fixed-already at the checked revision: The secondary completion-claim read is now inside its own guarded block at polylogue/demo/receipts.py:570-573. Database, schema-read and OS failures add a completion-claim evidence problem, and the final result derives ok from the accumulated problems at line 578 rather than allowing that read to escape the receipt boundary.

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