Repository navigation
feat(harness): scenario proof honesty and lifecycle (TH-8752, TH-8918, TH-8929, TH-8754) - #321
Draft
KarthikAvinashFI wants to merge 42 commits into
Draft
KarthikAvinashFI wants to merge 42 commits into
KarthikAvinashFI wants to merge 42 commits into
Conversation
…d counts at finish
…suite proving at certify
…n and give the proof test world setup outcomes
…e, and why names the real block
… and correct an overclaim
… a control's wrong transcript, else kept as written
…ader-only material
… block a case that contradicts it
…sources and asks for an assumption source
… live runtime for service-bound tools
…d named on publish, and a failed reseal keeps the change as a draft
…pability, and restore it under its key once the capability returns
… publish so a larger set never refuses the save
…en, and a control that cannot be played is no evidence
… nested in a list or object, counts as a leaked answer
…e a new case comes from
…ore-dropped-scenarios
…nario digest never reads it
…er of a case written in the same save
…ption source, as sources are now required
…ore-dropped-scenarios
…he check reads only calls that succeeded
…ore-dropped-scenarios
… an older suite rewritten as it was reads unchanged
…ore-dropped-scenarios
… declare_tool; fix_tool and adopt_tool say so instead of claiming the agent lacks it
…-scenario-lifecycle
KarthikAvinashFI
changed the base branch from
feat/TH-8752-proof-honesty
to
dev
November 15, 2026 19:54
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR covers
One PR for the Create scenarios work on
dev: proofs save whether each solution ran, negative controls, the leaked-answer check, grounding and suite proving, partial apply, and restoring scenarios a rebuild dropped.Merge order and base
dev(this PR's base).--prove-scenariosand readsscenario-proofs.json.#320: fix(harness): save whether each proof's solution ran and report proved counts
Why
TH-8752: a scenario whose reference solution never ran (its tools have no endpoint in the prove lane, so the steps were assumed) was saved as
holds: trueand reported as proved. Plan task T05 ("Make scenarios valid and meaningfully graded") needs an unproved case to read as unproved everywhere it is counted.This PR makes the saved proof say what really ran, and makes the build's Finished message report proved, kept as written and not proved apart.
What changed
src/fi/alk/harness/prove.pyProof.proved(holds, nothing assumed, nothing deferred),Proof.kept_as_written(not proved only because the lane could not execute something) andProof.blocked_reason()(first reason, faults before lane limits).LANE_CODES=proof_deferred,solution_assumed,control_not_run.src/fi/alk/harness/proofs.pyproved,kept_as_written,assumed,solution_steps,deferred,judged_only,blocked_reason, and awhythat names the assumed tools. Newproof_key(),unprovable_entry(),proof_counts().src/fi/alk/harness/hosted_chat_entrypoint.pyfinish_buildwrites the counts into the build-finished file and its reply reads "N proved, N kept as written (tools), N not proved (reasons). Report exactly these counts".src/fi/alk/harness/builder.py,nudge.py,scenario_tools.pyrecord_proofcall passessolution_stepsand saves underproof_key().src/fi/alk/harness/skills/builder/SKILL.mdfinish_buildreports as proved.tests/harness/proof_world.pytests/harness/test_proofs.py,tests/harness/test_builder_chat.pyBehavior callouts
holds: true, proved: false, kept_as_written: true, withwhynaming the tools whose steps never ran. Older readers that only look atholdsstill seetrue; the platform side readsprovedfor format 2 (companion PR below).proof_deferred, notnot_ready: its gates never ran, so they are unset rather than failed.Tests
test_assumed_steps_are_saved_and_not_proved,test_proof_counts_split_kept_as_written,test_unprovable_is_format_two,test_deferred_reads_proof_deferred_not_not_ready,test_holds_failures_map_to_codes,test_finished_message_reports_counts.tests/harnessmodule importing changed code (35 modules) andtests/test_harness.py. All new and named tests pass. Failures that exist identically ondev(0203bdf5):test_harness.py3,test_background_noise.py2,test_grade.py1,test_harness_architecture.py11.Added on this head:
b9b21ee6: the finishing reply carries the code-written counts and corrects an overclaim. Teststest_finished_turn_appends_code_counts,test_overclaim_gets_a_correction,test_exact_claim_gets_no_correction.99122c5d:test_assumed_steps_are_saved_and_not_provedfailed on this branch alone (the stub returned the check outcome type, and the check credited a failed call); the stub now returns the scenario-code outcome and the check reads only calls that succeeded.dev(0203bdf5):test_hosted_claude_session_uses_durable_resume_and_restricted_tools,test_a_skill_only_names_tools_its_stage_actually_has,test_the_system_prompt_stays_within_budget.Live proof
Local stack with production sandbox specs (4 CPU, 8192 MB, restricted egress). Validations re-proved seven existing environments with this code.
proved: false, assumed tools listed, counted "kept as written", never provedtest_finished_message_reports_counts); no fresh full build was run on this headPlaywright e2e
None in this repo. The platform flows that read these proofs (SIM-E2E-001 to 006 and 008) passed 7 of 7 on the stacked platform lifecycle branch, before its last base merge.
Scope out
#321: feat(harness): negative controls, leaked-answer check, grounding and suite proving
Why
TH-8918 (scenario lifecycle), plan task T05 ("Make scenarios valid and meaningfully graded"): a scenario is only worth running when its checks can fail a wrong behaviour, when nothing the caller or the agent sees gives the answer away, and when what it cites really says what it claims. Before this PR none of the three was checked: a case passed with checks that also passed a wrong refund, a case could quote its own grader text in the caller's instruction, and sources were not recorded at all.
This PR adds the three checks to the prove gate and a suite-wide re-prove that the platform's Validate runs at certify. The platform side (lifecycle states, Validate, archive, restore, source changes) is future-agi
feat/TH-8918-scenario-lifecycle.What changed
src/fi/alk/harness/scenario.pyNegativeControl(name,why,steps,must_fail) andScenarioSource(kindsrule,file,chat_message,evidence_case,requirement,assumption, with the quoted words) onScenario.src/fi/alk/harness/prove.pyno_negative_control,negative_control_passed,answer_leaked,source_unresolved;control_not_runwhen a control's tool has no endpoint here._outcomereads a refusal case asno_changeonly when the reference solution really left the world untouched.src/fi/alk/harness/leaks.py(new)what,judged,reference,verifier,comparison, tests, a control'swhy, evaluator-only files), a multi-word sub-goal name, or a computed expected value the world does not hold, found in the instruction, variables, persona, opening message or an actor's brief. Returns the excerpt and the grader field.src/fi/alk/harness/grounding.py(new)rule,file,requirementandassumptionsources against the contract and the world's files (matched_digestassha256:<hex>); other kinds are left for the platform.src/fi/alk/harness/prove_suite.py(new)broken_check, a run out of budget writes the restvalidation_incomplete. Keeps a 300 s margin before the job's deadline.src/fi/alk/harness/authoring_entrypoint.py--certify-only --prove-scenarios [--deadline-at]runs the suite re-prove before sealing and writesscenario-proofs.json; a failure there never fails the certify.src/fi/alk/harness/scenario_tools.pyaccept_scenariorefuses a case with one of the four codes above, with the reason; controls are checked against the agent's contract like solution steps.src/fi/alk/harness/proofs.pyoutcome, the controls that ran, the leaks found and the source results.skills/write-scenarios/SKILL.md,references/refusals.md,skills/builder/SKILL.mdtests/harness/*,tests/test_harness.pyaccept_scenariogained a negative control.Behavior callouts
no_negative_control). Existing saved scenarios are not rewritten; the platform reads them as legacy.control_not_run: the case is kept as written, never proved.answer_leakedwins over every lane code; a lane code never hides a fault (test_lane_codes_never_hide_a_fault).--prove-scenarios,--deadline-at). No new env var.Tests
test_negative_controls.py,test_leaks.py,test_grounding.py,test_prove_suite.py,test_proofs.py, plus adjusted fixtures intest_nudge_turn.py,test_builder_chat.pyandtests/test_harness.py.tests/harnessmodule importing changed code (35 modules) andtests/test_harness.py. All new and named tests pass. Failures identical ondev(0203bdf5):test_harness.py3,test_background_noise.py2,test_grade.py1,test_harness_architecture.py11.test_failure_message_is_not_grader_onlystrengthened.whytext. Two real bugs came out of it and are fixed here: a compared literal insidereturn None if ... == 42.50 else ...was not read by the leak check, and an assumed write step readno_change, so a write case looked like a refusal case.Live proof
Local stack with production sandbox specs (4 CPU, 8192 MB, restricted egress), builder chat on real demo agents.
test_two_refunds_control_fails,test_control_that_passes_blocksPlaywright e2e
None in this repo. The platform flows for the lifecycle (SIM-E2E-008 and SIM-E2E-001 to 006) passed 7 of 7 on the platform branch at
4fb67ad21, with this branch mounted.Plan lines S3 to S21 and the test pass on this head
ad37f0c5).live_proof.py,d751967e); a check that raises under a control reads broken and a control that cannot be played is no evidence (70e8de2f).prove_suite --keysproves only the named cases (445444e0).ec69f384); a blank assumption source does not count (2a29511b).6d08f42c).e61ebba3).must_pass, versioned with its content (f76c3f2b,23010c01).bf2c058a);37.5and37.50, and values nested in a list or object, count as a leaked answer (d45eba32).Fixed during the test pass:
d333f0c3scenario.jsongained"must_pass": false.must_passis written only when set, so an older suite rewritten as it was reads unchanged.3b2fbf9crequire_sources=Truehad no test (a mutation survived); a test now pins it.e4481805Tests on this head (the targeted harness modules, one process, the CI extras installed): 2620 pass. Three failures, the same on
dev(0203bdf5):test_hosted_claude_session_uses_durable_resume_and_restricted_tools,test_a_skill_only_names_tools_its_stage_actually_has,test_the_system_prompt_stays_within_budget. With the two branches stacked on it: 2658 pass, the same three.Mutation checks in this pass, all killed: the accept-time sources gate (2 tests fail), the builder submit sources flag (1),
must_passwritten only when set (1).Break-it attempts: a blank or whitespace assumption source (refused), an unchanged legacy case with no sources (saves), a changed legacy case with no sources (refused), a judge that cannot decide a policy conflict (not cached, never blocks), a control naming a check the case does not have (refused with the reason).
Live (production-spec local stack, pharmacy voice demo): asked the builder for a case about a prescription number that is not on file; it wrote the case as "not on file" and cited the person's words. Image on the platform PR #4107.
Scope out
source_model_fingerprint_mismatch,generated_runtime_entrypoint_ambiguous), in code this PR does not touch.#324: fix(harness): reseal the scenarios that load and name the ones that could not be applied
Why
TH-8929: when a builder turn changed several scenarios and one of them could not be loaded the way a run loads it, the reseal failed and the whole turn failed with it, so every good change was lost. Now the good changes save, the case that could not be applied keeps its last sealed version (or stays out if it was never sealed), and the platform is told which case it was and why.
What changed
src/fi/alk/harness/bundle_author_v2.pyscenario_seal_problems(authoring)loads each scenario folder alone, as a run does (scenario_source._load_one), and returns{key: first line of why}.reseal_scenarios(authoring, skip=...)reseals without the failing keys;_copy_scenarioskeeps a skipped case's last sealed copy, never under a folder name a case written in the same save uses.src/fi/alk/harness/hosted_chat_entrypoint.py_save_changeschecks first, reseals with the failing keys skipped and publishes withfailed_scenarios; the reply adds "Saved, except N scenarios that could not be applied: key: reason." A failure of the whole reseal (contract or seed) no longer fails the turn: the change is kept as the chat's unsaved draft and the reply says so.src/fi/alk/harness/hosted_conversation.pyConversationClient.publish(digest, failed_scenarios=...)sends{"digest", "failed_scenarios": [{"scenario_key", "reason"}]}, at most the platform's 200, and only when there is one.Behavior callouts
fix/TH-8929-partial-applyrefuses the unknown field; the field is sent only when a case failed, so ordinary saves are unaffected.Tests
test_builder_chat.py::test_one_broken_scenario_does_not_block_the_save::test_a_folder_a_run_cannot_load_keeps_its_sealed_version::test_a_held_copy_never_takes_the_folder_of_a_case_written_now::test_a_failed_reseal_keeps_the_change_as_a_draft::test_publish_sends_at_most_the_platform_limit_of_failed_scenariosRun on this branch (the targeted harness modules, one process): 2647 pass; three failures, the same on
dev(0203bdf5). Mutations: reseal withoutskip, and the held-copy folder guard, each fail their test.Break-it attempts: every case failing (each named), a never-sealed failing case (left out, the rest sealed), a held copy whose folder a good case took (fixed here: it raised
FileExistsErrorand failed the whole reseal), 250 failures (capped at 200), a multi-line reason (first line only).Live proof
The platform half is shown live on future-agi
fix/TH-8929-partial-apply(one case of twelve reads "Could not apply" with its reason, the others keep their state, and discard clears it). A builder turn that writes an unloadable folder is not reproducible on purpose: the builder's own gate refuses a broken case before it is written, so the reseal path is shown by the tests above.#325: feat(harness): record why a rebuild drops a scenario for a removed capability and restore it under its key when the capability returns
Why
TH-8754: when an agent version loses a tool, the scenario rebuild drops the cases that need it, and until now nothing remembered why. When the tool came back, the cases were gone for good: a rebuild wrote new ones under new keys, so their run history no longer lined up.
Now a rebuild records each case it drops for a removed capability (which tools and sub-goals it needed, which were missing, the agent version, a readable reason and the case's last content). When a later rebuild has every capability back, the case comes back under its own key from its last content, is proved like any other case, and is listed as restored.
What changed
src/fi/alk/harness/dropped.py(new)dropped.jsonbeside the scenarios:record_drops(from the turn-start snapshot, only drops whose needed tools or sub-goals are missing),restore(every record whose capabilities are all back goes into the kept list under its key),finish_restore(a restored case that fails its proof or is dropped again stays recorded withrestore_failedand the why),submit_refusal(a rebuild may bring a dropped key back only by restore),restore_note.save({})removes the file.src/fi/alk/harness/nudge.pyreport_update, restores at the start of the turn, and reportsrestoredandrestore_failed.src/fi/alk/harness/hosted_chat_entrypoint.pysrc/fi/alk/harness/skills/builder/topics/agent-update.mddeclare_tool.src/fi/alk/harness/amend.pyfix_toolandadopt_toolon a tool the contract lacks said "is not a tool this agent has"; they now say it is not in the contract and point atdeclare_tool. Found live: the builder took the old message at its word and never added the tool back, so nothing could be restored.Behavior callouts
HARNESS_VERSIONING_NUDGES_ENABLEDon. Production values do not set it today, so this feature does nothing in production until that flag is on.Tests
tests/harness/test_dropped_scenarios.py, 13 tests: a v5 drop records capabilities, agent and reason; an ordinary drop is not recorded; no restore while the capability is still missing; restore under the same keys and last content when it returns; restored cases are proved; restore only once every capability is back; a repeatedreport_updatekeeps the restore listed; the message names the restored cases and a changed argument; a restore that cannot be proved stays dropped with why; a restored case dropped again is a failed restore; a rebuild cannot write a new case under a dropped key; editing a restored case is allowed; with no drops leftdropped.jsonis removed and the scenario digest never reads it (so the platform hashes such a suite exactly as before).Also
tests/test_harness.py::test_fixing_a_tool_the_contract_lacks_points_at_declare_tool.Run on this branch (the targeted harness modules, one process): 2654 pass; three failures, the same on
dev(0203bdf5). Mutations: keeping an emptydropped.jsonfails the last test; the old refusal text fails thedeclare_tooltest.Break-it attempts (throwaway tests), all hold: a corrupt
dropped.jsonreads as no drops and restores nothing; a record whose content no longer reads as a scenario is refused with why while the others restore; a restore whose name a kept case now holds is refused; restoring twice restores nothing the second time;submit_refusalwith empty, null or padded keys.Live proof
See future-agi
feat/TH-8754-restore-dropped-scenariosfor the screenshots; the run is summarised here.Local stack with production sandbox specs, a chat demo environment (deals desk) on its environment v12, the last version before tools were added through chat. Rebuild nudges turned on locally (see the callout). Agent v3 is v1's source with the
apply_discounttool removed.apply_discountleaves the contract; the suite rebuild dropslive-manager-discount-negotiationandmanager-initiated-post-discussion-workflow; suite v10 keeps each drop with "agent v3 no longer hasapply_discount; the environment retiredapplied_discount_to_deal", the missing tools and sub-goals, and the agent version; the version diff carries the same reason422 scenario_key_retired: "live-manager-discount-negotiation was removed earlier and can't be reused; give the scenario a new name"apply_discountback withdeclare_tool(environment v18); the suite rebuild restores both cases under the same keys from their last content, proved by the gates; the card reads "2 scenarios restored" and lists them under RestoredSuite v10's diff (
GET versions/suite/{id}/diff/), removed entries:{"key": "live-manager-discount-negotiation", "reason": "agent v3 no longer has `apply_discount`; the environment retired `applied_discount_to_deal`", "capabilities": {"tools": ["apply_discount"], "sub_goals": ["applied_discount_to_deal"]}, "agent_version": "v3"}Found while running it, fixed here and in the harness PR: the rebuild card's change list showed the generic "removed when the environment was updated" instead of the stored reason (
ad6acfdcf); and on the first attempt the environment rebuild did not putapply_discountback (the harness told the builder it was "not a tool this agent has" when it was only missing from the contract), so nothing was restored. With the harness fix the second attempt restored both cases.The restored cases read Draft "No negative control" on the Scenarios tab: they were written before negative controls existed, which the lifecycle reports for any such case.
Linear
Linear: TH-8752
Linear: TH-8918
Linear: TH-8929
Linear: TH-8754
🤖 Generated with Claude Code
https://claude.ai/code/session_019gWFtEXoqSfwg3LAdyoEUb