portfolio-optimiser-claude/tests
Kjell Tore Guttormsen d691510163 fix(okf): nested frontmatter keys must not forge the type that gates verdict exclusion
The frontmatter parser is a line-oriented approximation of YAML with no nesting
model, and it flattened INDENTED keys into the same mapping. Two measured
defects followed, the second load-bearing:

1. Sibling blocks sharing an inner key COLLIDED. Given OKF §10's canonical
   Attested Computation shape, `executor.resource` vanished silently and
   `attester.resource` was promoted to a top-level `resource`. No error raised.

2. An indented `type:` OVERWROTE the column-0 one, making the verdict-exclusion
   gate in `bundle_context` forgeable. A file declaring `type: verdict` at
   column 0, carrying any nested block with a `type:` in it, rendered its body
   straight into the read-context — defeating the §11 seam whose own docstring
   claimed "a mislabelled or injected edge cannot smuggle a verdict into the
   context". The type CHECK was there; the VALUE it checked was writable.

This is spec-legal input, not malformed input: method-spec §2 calls it YAML
frontmatter, and ingest-spec §7 (`:153`, `:216`) says unknown keys MAY follow
the stamp and ride through navigation.

Fix: only column-0 keys participate; indented lines are skipped, never
flattened. Nested blocks become OPAQUE — stated as a limitation in the
docstring, not dressed up as a nesting model we do not have (§1 honesty rule).

Single parse site, so the fix covers the class: `hitl.py:157` (verdict_id,
gated on .type) and `experience.py:137` (realization_rate, expected_actual)
all read through `ConceptFile.frontmatter`; `promotion.py` only emits, from a
fixed template.

Golden-neutral by measurement: 0 indented frontmatter lines across all 17
frontmatter-bearing files in `shared/examples/`.

Both tests written RED first and confirmed to die on the SEAM assertion, not on
a collateral one — the forgery test rendered `## project: Seed` before the fix.
Each negative carries a standalone positive control (sessions 17-18: a control
can itself hide behind a preceding assert).

Provenance: hypothesis received from llm-ingestion-okf, who measured the
flattening in their own parser and flagged that ours shares the form. They had
NOT measured our side. The type-clobber variant is ours, found by measuring the
neighbourhood rather than only the reported case.

Suite 688 -> 690.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DJmse16bEkaSBtvXhncEUc
2026-08-01 19:53:03 +02:00
..
data feat(portfolio): K11 — per-run value report, pure projection over the three layers (parity row 25) [skip-docs] 2026-07-25 06:25:02 +02:00
_scripted.py feat(loop): S8 — D7 agentic loop: budget meter, maker-checker gate, informed refinement 2026-07-03 07:21:02 +02:00
test_budget.py feat(portfolio): C3.5 — pre-call run-total USD budget belt (parity row 16/31) [skip-docs] 2026-07-23 22:45:37 +02:00
test_bygg_energi_mikro.py feat(validator): S6 — deterministic backbone: typed IR, golden-frozen validator, provenance stamp 2026-07-03 06:27:40 +02:00
test_checker_gate_loadbearing.py feat(loop): S8 — D7 agentic loop: budget meter, maker-checker gate, informed refinement 2026-07-03 07:21:02 +02:00
test_cli_paritet_loadbearing.py fix(run): classify portfolio-mode flags by allowlist so a new flag fails closed 2026-07-25 15:33:30 +02:00
test_contracts.py feat(portfolio): K2 — sequential multi-project run (parity row 4) 2026-07-23 21:39:39 +02:00
test_costsim.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_dry_run_loadbearing.py feat(portfolio): K8 — live-run drill, pre-call artifact capture (parity row 21) [skip-docs] 2026-07-24 06:54:58 +02:00
test_goals.py feat(ledger): K1 — savings ledger + goal contract (parity rows 2-3) 2026-07-17 04:00:14 +02:00
test_hitl_loadbearing.py feat(portfolio): K9 — HITL verdict routing + pending tracking (parity row 22) [skip-docs] 2026-07-24 19:58:29 +02:00
test_ingest.py chore(deps): re-pin llm-ingestion-okf to v0.3.1 + migrate tests to stable error codes 2026-07-20 07:22:09 +02:00
test_ingest_adoption.py chore(deps): re-pin llm-ingestion-okf to v0.3.1 + migrate tests to stable error codes 2026-07-20 07:22:09 +02:00
test_ingest_golden.py feat(ingest): I3 — D7-speil av ingest (filkatalog/CSV), bygget fra commons-spec alene 2026-07-04 06:12:43 +02:00
test_ingest_loadbearing.py test(loadbearing): positive controls for the vacuous-negative class 2026-07-31 21:15:57 +02:00
test_ingest_spec_loadbearing.py test(ingest-spec): make the §12 detach-proofs permanent tests 2026-07-31 18:35:41 +02:00
test_ingest_sql.py chore(deps): re-pin llm-ingestion-okf to v0.3.1 + migrate tests to stable error codes 2026-07-20 07:22:09 +02:00
test_ingest_sql_golden.py feat(ingest): I5 — SQL D7-speil, bygget fra commons-spec alene 2026-07-04 07:18:59 +02:00
test_ingest_sql_loadbearing.py feat(ingest): adopt llm-ingestion-okf as Door A implementation (first consumer) 2026-07-16 20:46:51 +02:00
test_ir.py fix(validator): C2.6 — finiteness hardening, Infinity can no longer vacuously clear the gate (closes R-2) 2026-07-16 20:10:12 +02:00
test_ledger_loadbearing.py fix(ledger): normalize every load rejection to ValueError at the ledger's own entrance 2026-07-25 15:29:27 +02:00
test_loop.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_method_spec_loadbearing.py test(spec): C1.1 — method-spec integrity guard (§11 'Spec integrity', closes C-N1) 2026-07-16 19:59:01 +02:00
test_notify_loadbearing.py feat(portfolio): K10 — notification/notifier seam, opt-in webhook egress (parity row 23) [skip-docs] 2026-07-24 20:16:56 +02:00
test_notify_seam_loadbearing.py feat(portfolio): K10 — notification/notifier seam, opt-in webhook egress (parity row 23) [skip-docs] 2026-07-24 20:16:56 +02:00
test_okf.py fix(okf): nested frontmatter keys must not forge the type that gates verdict exclusion 2026-08-01 19:53:03 +02:00
test_outbox_loadbearing.py feat(portfolio): K5 — outbox persistence, run_id-named pairs (parity row 7) [skip-docs] 2026-07-23 22:31:18 +02:00
test_persona_skill_loadbearing.py feat(learning): S9 — D7 læringssløyfe: verdict-inbox, fail-closed promoteringsgate, artefakt-sourced persona 2026-07-03 07:36:15 +02:00
test_portfolio.py feat(portfolio): K2 — sequential multi-project run (parity row 4) 2026-07-23 21:39:39 +02:00
test_portfolio_learning_loadbearing.py feat(portfolio): K3 — portfolio learning loop (shared verdict store, parity row 5) [skip-docs] 2026-07-23 22:08:02 +02:00
test_preflight.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_provenance.py feat(validator): S6 — deterministic backbone: typed IR, golden-frozen validator, provenance stamp 2026-07-03 06:27:40 +02:00
test_provenance_sdk_version_loadbearing.py feat(run): stamp the drill's SDK build in the dry-run run-config [skip-docs] 2026-07-25 15:35:16 +02:00
test_run_entrance_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_s10_run_layer.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_sdk_isolation.py feat(inbox): C2.5 — inbox hardening + SDK version guard (closes C-F7, C-N3, R-6) 2026-07-16 20:26:41 +02:00
test_sdk_version_guard.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_simulation_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_step1_expel_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_step5_refine_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_step7_async_loop_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_step8_promotion_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_validator.py fix(validator): C2.6 — finiteness hardening, Infinity can no longer vacuously clear the gate (closes R-2) 2026-07-16 20:10:12 +02:00
test_valuereport_loadbearing.py test(loadbearing): close the vacuous-negative class across the whole suite 2026-07-31 21:39:28 +02:00
test_valuereport_seam_loadbearing.py feat(portfolio): K11 — per-run value report, pure projection over the three layers (parity row 25) [skip-docs] 2026-07-25 06:25:02 +02:00