Skip to content

fix: H5 quality sweep (6krh, f47j, iuyr, es7b, omsw) - #4013

Merged
Sinity merged 6 commits into
masterfrom
feature/quality/h5-sweep
Aug 19, 2026
Merged

Sinity merged 6 commits into
masterfrom
feature/quality/h5-sweep

Conversation

@Sinity

@Sinity Sinity commented Aug 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Five small, independent quality fixes batched into one PR (H5 quality sweep,
.agent/campaigns/2026-08-overhaul/ queue row #12): two real code fixes with
red-before/green-after tests (polylogue-f47j, polylogue-iuyr), one
narrowing fix for a mislabelled-session bug found by a parallel audit
(polylogue-omsw class), and two beads (polylogue-6krh, polylogue-es7b)
that turned out to already be fully fixed and tested on master when
investigated — verified rather than assumed.

Problem

  • polylogue-f47j: registry.promote_cluster's samples-based candidate
    generator (generate_schema_from_samples) never received a
    PrivacyConfig, unlike the full generate pipeline's
    _generate_cluster_schema. An explicit deny rule supplied by a caller was
    silently ignored on the samples path — the same class of gap that let a
    low-cardinality UUID-shaped field record its literal per-record values
    verbatim during a 2026-07-29 promotion (caught after the fact by
    devtools schema_audit, fixed at the time by manual annotation
    stripping, not by this fix). Cold review on an earlier revision of
    this PR caught that the initial fix only plumbed privacy_config
    through the library function — it was still unreachable from
    devtools schema-promote, the actual command a live promotion runs, so
    every real run would have stayed exactly as unredacted as before this PR
    until that was completed
    (see Solution and the second commit below).
    The compensating control that actually caught the 2026-07-29 leak
    (devtools schema_audit's privacy-guard check) still runs in no gate —
    tracked separately as polylogue-32pwq, not in this PR's scope.
  • polylogue-iuyr: compute_session_cost's per-model loop called
    estimate_cost() for every model with a normalized name, but
    estimate_cost() silently returns 0.0 when the pricing catalog has no
    entry for that model. A model with real, nonzero reported/estimated tokens
    but no catalog price (e.g. claude-opus-5, a confirmed live catalog gap)
    surfaced as confidence='reported' with total_api_cost_usd=0.0 —
    indistinguishable from a provider that genuinely billed zero.
  • polylogue-omsw class (Hermes skill templates): the Hermes watch source
    recursively scans its entire ~/.hermes home directory (not just a
    sessions subtree), so skill prompt-prefill templates under
    optional-skills/**/templates/*.json reached artifact classification
    tagged provider="hermes". Their bare {"role", "content"} array shape
    satisfied the generic looks_like_record_entry heuristic in
    _classify_list and got claimed as a session, then quarantined when it
    failed to parse ("session artifact produced no materializable sessions").
    Found by a parallel dyica-classification audit (2026-08-19, bucket B6),
    both live template files still on disk for testing.
  • polylogue-6krh / polylogue-es7b: both were re-investigated per the
    dispatch and found to already be fully fixed and tested on master
    (see disposition matrix below) — no code changes made in this PR for
    either.

Solution

  • polylogue/schemas/generation/schema_builder.py: generate_schema_from_samples
    gains a privacy_config parameter, threaded into its _annotate_schema
    call (the same redaction path _generate_cluster_schema already used).
  • polylogue/schemas/tooling_registry.py: promote_cluster gains the same
    privacy_config parameter and forwards it.
  • polylogue/schemas/operator/registry.py: SchemaRegistryLike.promote_cluster
    protocol updated to match (plus tests/unit/scenarios/test_corpus.py's
    fake registry, to keep mypy's Protocol-conformance check green).
  • Completing the wiring to the real caller (added after cold review):
    polylogue/schemas/operator/models.py's SchemaPromoteRequest gains a
    privacy_config: JSONDocument | None field (the same shape
    SchemaInferRequest already carries); polylogue/schemas/operator/inference.py's
    promote_schema_cluster forwards it through _privacy_config() (now
    also exported as privacy_config_from_payload for reuse) into
    registry.promote_cluster(); devtools/schema_promote.py gains
    --privacy/--privacy-config flags, reusing
    build_schema_privacy_config — the exact same resolution the full
    generate pipeline's equivalent flags already use, not a parallel
    config path.
  • polylogue/archive/semantic/cost_compute.py: the per-model breakdown loop
    now checks pricing_catalog_source(norm) before trusting a 'reported'/
    'estimated' confidence; a model with no catalog entry downgrades to
    'unknown' regardless of token evidence, so estimate_cost()'s silent
    0.0 can never be read as a confident zero.
  • polylogue/archive/artifact_taxonomy/runtime.py: _classify_list narrows
    the Hermes branch — a list-shaped payload under provider="hermes" is
    only session-eligible when it's a genuine ATOF event stream (the one
    list-shaped Hermes source class; state.db/ATIF/session-snapshots are all
    single JSON documents). Any other Hermes list payload is refused outright
    instead of falling through to the generic looks_like_record_stream
    heuristic.

Alternative considered and rejected for the Hermes fix: narrowing the
Hermes parser predicates (polylogue/sources/parsers/hermes*.py), as
originally suggested. Traced the actual claim path instead — the parsers
were never reached; archive/artifact_taxonomy/runtime.py's generic
_classify_list (shared by every provider) is what admitted the template as
a session, so that is where the fix belongs.

Verification

  • devtools test tests/unit/schemas/test_promote_cluster_privacy_config.py — 4 passed (f47j library-level plumbing; red confirmed by reverting the source change and re-running before committing).
  • devtools test tests/unit/core/test_operator_inference.py — 6 passed, including test_promote_cluster_with_samples_honors_privacy_config_through_the_real_operator_route (f47j, operator-route completion; red confirmed — reverting the wiring made SchemaPromoteRequest(..., privacy_config=...) raise TypeError: unexpected keyword argument, i.e. the field genuinely didn't exist before this fix). Also ran tests/unit/core/test_operator_models.py, tests/unit/cli/test_operator_support_runtime.py, tests/unit/schemas/test_operator_commit.py, tests/unit/schemas/test_promotion_audit_privacy_guard.py, tests/unit/schemas/test_promotion_monotonicity.py — 38 passed total, no regressions.
  • devtools test tests/unit/core/test_cost_compute.py — 10 passed (iuyr; red confirmed the same way).
  • devtools test tests/unit/sources/test_artifact_taxonomy.py — 19 passed (Hermes fix; red confirmed the same way, plus the ATOF anti-over-narrow twin passes both before and after).
  • devtools test across every Hermes-touching test file (parsers, dispatch, live watcher/batch, storage, daemon) — 880 passed, no regressions.
  • devtools verify --quick — clean (format + lint + mypy + render-all-check + layering + schema policy + promotion audit).
  • Full devtools verify withheld: this worktree's testmon graph would need a full bootstrap (~45 min, first run in a freshly-provisioned lane venv) that dies with the worktree at merge time — per the digest-drift/lane-lifecycle policy, that cost buys nothing the coordinator's own terminal verify at merge doesn't already provide. The four focused suites above plus --quick are the substitute gate for this PR; the coordinator's merge-time devtools workspace merge / terminal verify is the release-baseline attestation of record.

Bead disposition matrix

Bead Disposition Evidence Notes
polylogue-f47j SATISFIED — close-candidate commits 5bb08f4, dc8dd06; tests/unit/schemas/test_promote_cluster_privacy_config.py, tests/unit/core/test_operator_inference.py::test_promote_cluster_with_samples_honors_privacy_config_through_the_real_operator_route All three layers now land: (1) privacy_config threaded through the library's samples path, (2) promotion_audit's check_privacy_guards wiring (AC #2) was already present on master before this PR — verified live, not assumed, (3) the operator-route wiring (SchemaPromoteRequest → promote_schema_cluster → devtools schema-promote --privacy) that a cold review found missing from the first revision — without it the library fix was unreachable from any real promotion.
polylogue-iuyr SATISFIED — close-candidate commit 8aa2629; tests/unit/core/test_cost_compute.py::test_catalog_gap_model_with_real_tokens_is_not_a_confident_zero Catalog-gap models now downgrade to unknown confidence instead of a confident $0.00.
polylogue-6krh SATISFIED, no diff in this PR — close-candidate polylogue/sources/live/cursor.py:_sync_convergence_debt_to_ops (writes status='deferred' for deliberate deferrals); both batch.py deferral call sites already pass deferred=True; all five reader/alert surfaces named in the bead (health.py, status.py, cli status.py, api/archive.py, metrics.py) already track failed_count/deferred_count separately; tests/unit/sources/test_convergence_debt_deferred_vocabulary.py covers the full writer→reader chain end to end. This was PR #3621, already merged. Remaining scope per the bead's own design note is post-deploy live verification only (not code) plus the t0m73 vocabulary-honesty registry check, which the bead explicitly says to note rather than build. Not something this PR can evidence from a worktree.
polylogue-es7b PARTIAL — item (a) only, bead stays open polylogue/storage/embeddings/materialization.py's exception handler (fallback to Origin.UNKNOWN_EXPORT sentinel, record_embedding_failure always called); tests/unit/storage/test_embedding_contracts.py::test_archive_failure_ledger_survives_origin_lookup_failure Item (a) (the one this sweep was scoped to) is already fixed and tested on master, no diff in this PR. Items (b)/(c)/(d) from the bead's own evidence (write_coordinator.py detached-writer counter, RuntimeError suppress potential hang, sampling_db.py missing-tier-file warning) are untouched and out of scope for this sweep — no successor bead exists yet for those; not included in the machine pr-scope carrier below since a partial disposition requires a linked successor I'm not able to create from a read-only lane. Coordinator: file a successor for (b)/(c)/(d) before considering this bead closeable.
polylogue-omsw Referenced, not dispositioned commit c8e9f22 Ref polylogue-omsw — this PR fixes one instance of the same artifact-misclassification class the bead already tracks (Hermes skill templates, dyica classification 2026-08-19 bucket B6), added as scope creep by the coordinator mid-PR. The bead's own scope (tool-result/journal sidecars, file-history-snapshot, codex-database misclassification) is broader and untouched here — do not close polylogue-omsw from this PR.

The machine-readable carrier below covers only polylogue-f47j and
polylogue-iuyr (the two beads this PR both mutates code for and can
satisfy without a successor). polylogue-6krh and polylogue-es7b are
evidenced in prose above rather than the typed carrier, since satisfying or
partial-closing them accurately would require either a diff this PR doesn't
carry (6krh — already fixed elsewhere) or a successor Bead this lane cannot
create (es7b's residual items b/c/d).

Sinity added 4 commits August 19, 2026 02:25
…path

generate_schema_from_samples (the candidate generator promote_cluster's
samples route calls) never received a PrivacyConfig, unlike the full
generate pipeline's _generate_cluster_schema. An explicit deny rule
supplied by a caller was silently ignored on this path -- exactly what
let a low-cardinality UUID-shaped field record its literal per-record
values verbatim during a 2026-07-29 promotion.

Ref polylogue-f47j
compute_session_cost's per-model loop called estimate_cost() for every
model with a normalized name, but estimate_cost() silently returns 0.0
when the pricing catalog has no entry for that model. Combined with
confidence carrying forward unconditionally from the token-evidence
check, a model with real nonzero reported/estimated tokens but no
catalog price (e.g. claude-opus-5, a confirmed live catalog gap)
surfaced as confidence='reported' with total_api_cost_usd=0.0 --
indistinguishable from a provider that genuinely billed zero.

Downgrade confidence to 'unknown' whenever a model has no catalog
price entry, regardless of whether its tokens were reported or
estimated.

Ref polylogue-iuyr
…cy_config param

The fake registry in test_corpus.py implements SchemaRegistryLike and
must carry the same signature as the protocol after polylogue-f47j
added privacy_config to promote_cluster.
The Hermes watch source recursively scans its entire ~/.hermes home
directory, not just a sessions subtree, so files under
optional-skills/**/templates/*.json (skill prompt-prefill templates)
reach artifact classification tagged provider="hermes". Their
{"role", "content"} shape satisfied the generic
looks_like_record_entry role/content-key heuristic in
_classify_list, so they were claimed as sessions and then quarantined
when they failed to parse.

Hermes's real source classes (state.db, verification evidence, ATIF
trajectory documents, session snapshots) are never bare JSON arrays --
only the ATOF event stream is list-shaped. Narrow the Hermes branch of
_classify_list so a list payload that isn't an ATOF stream is refused
outright instead of falling through to the generic heuristic.

Ref polylogue-omsw
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e7385758-e851-4f0e-a2d9-6a90ebe5aee7


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.

polylogue-f47j's library fix (generate_schema_from_samples/promote_cluster
threading privacy_config) was unreachable from the production caller: the
devtools schema-promote CLI had no privacy flag, SchemaPromoteRequest had
no privacy_config field, and promote_schema_cluster called
registry.promote_cluster() without the kwarg -- so every real
`devtools schema-promote` run stayed exactly as unredacted as before the
library fix.

- SchemaPromoteRequest gains a privacy_config field (same JSONDocument
  shape SchemaInferRequest already uses).
- promote_schema_cluster forwards it through _privacy_config(), reusing
  the same payload-to-PrivacyConfig conversion infer_schema already uses
  (exported as privacy_config_from_payload for other callers).
- devtools/schema_promote.py gains --privacy/--privacy-config flags,
  reusing build_schema_privacy_config -- the same resolution the full
  `generate` pipeline's --privacy/--privacy-config already use, not a
  parallel config path.

Red-first test through the operator route (promote_schema_cluster, not
just generate_schema_from_samples): a planted low-cardinality field
leaks into x-polylogue-values by default and is redacted once a
privacy_config denying that field reaches promote_schema_cluster.
@Sinity
Sinity merged commit d62ea4c into master Aug 19, 2026
3 checks passed
@Sinity
Sinity deleted the feature/quality/h5-sweep branch August 19, 2026 03:39
Sinity added a commit that referenced this pull request Aug 19, 2026
## Summary

Closure package for the `polylogue-t46.8` MCP verb-algebra epic's
children:
`polylogue-t46.8.2` (read migration) and `polylogue-t46.8.3` (privileged
families). Both beads' 2026-08-19 pass-2 notes agreed the implementation
is
done (103-tool-to-10-verb collapse shipped in PR #3095, `dc6fa632a`) and
what remains is proof runs plus one documentary report. This PR is
exactly
that: no production code changed.

## Problem

Both beads' AC lists were last touched before the collapse's supporting
test harnesses existed or were last run together. The 2026-08-19 pass-2
notes named specific unrun/unmeasured items:

- `t46.8.2` AC#2 (seven continuity drills + z9gh Workflow incident
replay)
and AC#3 (bounded pages/continuation for oversized cases) had harnesses
  (`test_cold_model_continuity_replay.py` ×2, `test_tool_discovery.py`,
`test_bounded_query_transport.py`) that existed but were "unrun in this
  audit".
- `t46.8.3` AC#5 (t8t coordination/context flows plus negative
  unauthorized/injection/retry fixtures) named four fixture files
  (`test_privileged_tools.py`, `test_tool_error_isolation.py`,
  `test_context_delivery_tool.py`, `test_status_scope_coordination.py`)
  in the same unrun state.
- `t46.8.3` AC#6 (final surface/token-cost/usage report naming every
  retained exception) was flagged as "genuine unbuilt scope".
- Both beads' AC#4 (per-tool production goldens/shadow telemetry proving
  no capability loss **before** deletion) is structurally unsatisfiable
  now — the old surface is already deleted, so there is no "before" left
  to shadow against.

## Solution

- Ran all eight named test files individually via `devtools test`,
sequentially, in this freshly-provisioned worktree off `origin/master`.
  All green — see the results table below.
- Wrote `docs/mcp-surface-report-2026-08.md`: the final 10-tool +
15-URI-
  resource surface, per-tool declared operations (measured live against
  `polylogue/mcp/declarations/registry.py`/`server_cutover.py`), the
capability-flag role-gating matrix, measured token cost of the
serialized
  tool declarations under each capability combination (via a real
  `build_server()` + `list_tools()` call, not an estimate from memory),
  every retained exception with its reason, and AC#4 restated as
  misframed-not-satisfiable with the post-hoc parity evidence available
  instead.
- Registered the report in `devtools/docs_surface.py`'s tiered doc index
(archive tier, same precedent as the existing dated retros) and linked
it
  from `docs/mcp-reference.md`. `devtools render all` regenerated
  `docs/README.md`'s index entry as a result — included in the diff.

No MCP production code was touched. If any suite had been red, per the
dispatch instructions this PR would have stopped at classification
(pre-existing vs. revealing) rather than fixing MCP internals here —
none
were.

## Verification

| Suite | AC | Result |
| --- | --- | --- |
| `tests/integration/test_cold_model_continuity_replay.py` | t46.8 AC#3
| 3 passed |
| `tests/unit/devtools/test_cold_model_continuity_replay.py` | t46.8
AC#3 | 10 passed |
| `tests/unit/mcp/test_tool_discovery.py` | t46.8.2 AC#2 | 9 passed |
| `tests/unit/mcp/test_bounded_query_transport.py` | t46.8.2 AC#3 | 1
passed |
| `tests/unit/mcp/test_privileged_tools.py` | t46.8.3 AC#5 | 60 passed |
| `tests/unit/mcp/test_tool_error_isolation.py` | t46.8.3 AC#5 | 6
passed |
| `tests/unit/mcp/test_context_delivery_tool.py` | t46.8.3 AC#5 | 6
passed |
| `tests/unit/mcp/test_status_scope_coordination.py` | t46.8.3 AC#5 | 2
passed |
| **Total** | | **97 passed, 0 failed** |

`devtools verify --quick` — clean (format + lint + mypy +
render-all-check,
including the new doc registration + regenerated `docs/README.md` index
+
layering + schema policy + promotion audit).

Full `devtools verify` not run: no production code changed (docs + a
one-line devtools registry entry only), and this worktree's testmon
graph
would need a full bootstrap with nothing to gain from it — same
digest-drift reasoning as the concurrent #4013 PR's gate substitution.

## Per-AC honesty breakdown (for the coordinator's own closing
bookkeeping)

This PR's pr-scope carrier marks both `t46.8.2` and `t46.8.3`
**satisfied**
per the dispatch's stated criterion ("SATISFIED if suites green + report
lands"). That criterion covers the ACs this task was actually scoped to
prove. It does **not** mean every AC on either bead's full text is
proven
by this PR — listed honestly below so the parent `t46.8`'s close (the
coordinator's own bookkeeping, not this PR's) has the complete picture.

**t46.8.2:**
- AC#1 (equivalence coverage) — not re-verified this pass; prior
sessions'
  notes claim it, not independently re-checked here.
- AC#2 (continuity drills + Workflow replay) — **satisfied**, proof run
above.
- AC#3 (bounded pages, no row cap) — **satisfied**, proof run above.
- AC#4 (pre-deletion goldens) — **misframed**, restated in the report
  (Section 5) with post-hoc parity evidence instead.
- AC#5 (≤15-tool default profile) — **satisfied**, structurally (6 base
  tools), confirmed in the report (Section 1).
- AC#6 (migration harness protects the shared transaction) — **not
  evidenced by this pass**; no suite here specifically targets removal/
  mutation of the shared query transaction failing the harness.
- AC#7 (concurrent incident-scale calls, cancellation/disconnect,
bounded
RSS/PSS/swap/temp, zero leaks) — **not evidenced by this pass**; none of
the eight suites run here are a load/leak-proof harness. If this AC
needs
its own proof run, it is a residual, not covered by "SATISFIED" per the
  dispatch's own naming of what this task covers.

**t46.8.3:**
- AC#1 (every family maps onto a declared verb, no lost operation) —
  **substantially evidenced**: the report's Section 4 names three
  operations (`delete_saved_view`, `import_annotation_batch`,
  `deliver_context`) not covered by the specific executor-routing proof
  test class, and `maintenance()`'s entire operation surface has zero
`OperationExecutor` routing (real, acknowledged, explicitly deferred to
  `kwsb.2`/`t46.9`) — not a silent gap, but also not a clean 100%.
- AC#2 (prompt/resource content cannot acquire instruction/write
  authority) — not re-verified this pass.
- AC#3 (candidate/judged state, idempotency, dry-run/authorization,
  receipts, status/recovery, role isolation) — **satisfied** by
  `test_privileged_tools.py`'s 60 passing tests, which cover this ground
  directly (confirm-gates, actuator routing, role gating).
- AC#4 (old tools/aliases removed) — **satisfied**: confirmed live in
the
  report that the five old registrar modules are fully deleted.
- AC#5 (t8t flows + negative fixtures) — **satisfied**, proof runs
above.
- AC#6 (final surface/token-cost/usage report) — **satisfied**, this
PR's
  report.

## Bead disposition matrix

| Bead | Disposition | Evidence | Notes |
| --- | --- | --- | --- |
| polylogue-t46.8.2 | **SATISFIED** per dispatch criterion —
close-candidate | commit (this PR); 4 test files, 23 passed;
`docs/mcp-surface-report-2026-08.md` | AC#6/#7 (migration-harness
protection, concurrent/leak-proof load test) not evidenced by this pass
— see honesty breakdown above. Coordinator's call whether those warrant
a residual bead before the parent closes. |
| polylogue-t46.8.3 | **SATISFIED** per dispatch criterion —
close-candidate | commit (this PR); 4 test files, 74 passed;
`docs/mcp-surface-report-2026-08.md` | `maintenance()` executor-routing
debt and 3 uncovered `write()` operations are real, named, and
explicitly deferred to `kwsb.2`/`t46.9` per the bead's own prior notes —
not new information, not blocking this bead's own AC (which asks for the
mapping + report, not for `t46.9` to have landed). |

The parent `polylogue-t46.8`'s close is the coordinator's own
bookkeeping,
per the dispatch — not attempted here.

<!-- polylogue-pr-scope:v2
{
  "assigned_beads": [
    "polylogue-t46.8.2",
    "polylogue-t46.8.3"
  ],
  "dispositions": [
    {
      "bead_id": "polylogue-t46.8.2",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "commit",
          "ref": "eb3592edd"
        },
        {
          "kind": "test",
"ref": "tests/integration/test_cold_model_continuity_replay.py"
        },
        {
          "kind": "test",
"ref": "tests/unit/devtools/test_cold_model_continuity_replay.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_tool_discovery.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_bounded_query_transport.py"
        },
        {
          "kind": "diff",
          "ref": "docs/mcp-surface-report-2026-08.md"
        }
      ],
      "successors": []
    },
    {
      "bead_id": "polylogue-t46.8.3",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "commit",
          "ref": "eb3592edd"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_privileged_tools.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_tool_error_isolation.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_context_delivery_tool.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/mcp/test_status_scope_coordination.py"
        },
        {
          "kind": "diff",
          "ref": "docs/mcp-surface-report-2026-08.md"
        }
      ],
      "successors": []
    }
  ],
  "mutated_beads": [],
"scope_digest":
"05d807ef6bdefe91359e9431035a016f3de33d54bf8f47b643a6a88304274574",
  "scope_kind": "bead",
  "version": 2
}
-->
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