Skip to content

make bench-revision runs the four corrections-and-time harnesses on one generated corpus, with a question that needs two facts, one of them superseded - #2189

Merged
zlareb1 merged 2 commits into
mainfrom
bench/forgetting-multihop-harness
Dec 5, 2026

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

make bench-revision runs pi_llm.py, forget_switch_eval.py, fama_forgetting.py and the supersession audit on one generated corpus. pi_llm.py --kinds adds a question that needs two facts, one of them superseded, and both questions as of an earlier day; make bench-revision-dry checks the scorer, the gate and the artifact writer with no server.

Why

The coverage page keeps "Corrections and time" at Harness only until four harnesses are published on one shared public corpus. They shared no input and no entry point: pi_llm.py generated its own episodes and wrote no file, forget_switch_eval.py and fama_forgetting.py ran inline cases, and supersession_audit.py read one namespace somebody else had written. None of them asked a question whose answer needs two facts, so nothing measured whether a correction still reaches an answer that arrives through a second fact.

This change gives the four one corpus and one command. No measurement is part of the change: it builds the instrument, and the coverage row stays Harness only.

Design in brief.

  • Corpus. The generated episodes of pi_llm.py (one coined project whose module is updated depth times) plus one ownership fact per episode: a coined team owns the project, dated the day before the first update, so a read as of any update's day sees it. Committed code rebuilds the corpus, so it is public with no download and any item count. _ENTITIES, _val and update_text keep their output, because the acceptance bench's floors are measured on them.
  • Questions. --kinds selects from four, all asked on the one ingest: current (the project's module today), current_2hop (the module of "the project owned by team X", which never names the project), asof and asof_2hop (the same two about the day of a middle update, sent with as_of at the last second of that day; depth 2 and up). The superseded fact is the second hop, project to module; the ownership fact is static. Each question records the writes its answer needs (gold_facts) and the update that replaced an earlier value (superseding_write, null at depth 1, the control where nothing was superseded).
  • Scoring. score_answer matches the coined value tokens, so one scorer serves every kind and no judge is called. has_later is new: a value written after the as-of time. An item keeps the majority of its repeats' clean_correct labels, so an abstention is a wrong answer.
  • Gate. --gate pairs the one-fact question (arm A) with the two-fact question of the same episode, depth and time (arm B) through bench/_gate.py, resampling whole episodes because one coined project serves every depth. The target passes --gate-min-delta -4: the default null band used as a non-inferiority margin. 100 episodes at depths 1, 2, 5 and 10 give 700 pairs in 100 clusters; with one pair in five differing between the arms the interval's half-width is about 3.1 points, inside the 4.0 band (test_the_planned_run_is_wide_enough holds this against the target's own flags).
  • Artifacts. --out writes JSONL: a header (the flags, the server's instrument from /v1/health, the gate), then one line per namespace and question with every repeat's full answer and label and the reply's source, memory_keys, superseded_dropped, stale_sentences_masked, entity_followed and decomposed_parts, which show whether the second hop and the supersession filter ran.
  • Audit. --audit-out calls supersession_audit.audit on the namespaces the run minted, inside the block that erases them, so the erasure also follows a failed run. The audit follows the asks and reads versions the run then erases, so a run with --audit-out checks OPENAI_API_KEY (the audit's judge) and the ClickHouse connection before its first request and exits 2 without either. The audit reads over its own default window of 7 days.
  • One command. A make target and not a runner module: the legs share only the corpus and the output directory.

Alternatives and their cost. bench/conflict_resolver_scenario.py is committed and has ground truth, but it holds six changing attributes, so one question is 16.7 points, and its relations are not single-valued, so the interval check cannot use it. A downloaded conversational set costs a long extraction per item and has no as-of question. A new hand-written fixture needs hundreds of authored items to reach the same interval. The cost of the generated corpus is templated sentences and one attribute; phrasing variety stays with the 45 hand-written cases of forget_switch_eval.py.

Scope and risk

  • Touches four harnesses under bench/, the Makefile, bench/README.md, four pages under docs/benchmarks/ and the tests. No server code, op, setting, table or migration.
  • Leaves alone bench/acceptance/memory_app.py, mutation_sequence.py, fact_consolidation.py, docs/benchmarks/results.md and the coverage row's status.
  • Tenant isolation and deletion. Every namespace is minted under bench-, registered as a bench namespace and erased by exact name when the run ends, fails or is interrupted. The target never passes --keep-namespaces. The audit reads only the namespaces its run minted, bound as one array parameter, with no FINAL.
  • Evaluation reads. No ask credits what it read unless --credit is passed. With more than one repeat an ask also sends llm_cache: false and precedents: false, so a repeat is a new answer and not the first one's bytes.
  • What the audit does not see. It pairs versions of one key. A value retired behind another key is not a pair, and both rates are then null and not 0. The short run (EPISODES=5) shows which path the updates took: pairs in the audit record, or superseded_dropped in the answer rows.
  • Could break: a script that parses the audit's --out record or calls the harness functions below.

Compatibility, rollout and rollback

  • Wire: none. No op, field, table, setting or migration is added, changed or removed.
  • Harness flags added:
    • pi_llm.py: --kinds (default current, which sends the same requests and writes no ownership fact), --repeats (below 1 is an argument error), --gate, --gate-band, --gate-min-delta, --judge-calibration (the shared gate arguments), --out, --audit-out (needs OPENAI_API_KEY and the server's .env), --dry.
    • supersession_audit.py: --namespace repeats.
    • fama_forgetting.py: --org (default dev), --episodes N (default 0: the two inline cases).
    • forget_switch_eval.py: --corpus-episodes N (default 0).
  • Make targets added: bench-revision (EPISODES=100, DEPTHS=1,2,5,10, REPEATS=3, ORG=dev, OUT=/tmp/loom_revision_<unix ts>) and bench-revision-dry.
  • Breaks, all inside bench/:
    • supersession_audit.py --out writes namespaces (a list) where it wrote namespace, and false_supersession_rate and omission_rate are null when no pair was labelled, where they were 0.0. --max-false-rate does not fail on a null rate.
    • pi_llm.py --credit is the shared gate flag, with the same meaning. A run against a server reads /v1/health first and exits 2 when it does not answer 200. run_episode takes a post callable and returns one row per question, and a row's has_latest is now has_gold.
    • fama_forgetting.run_case takes org.
  • Operator steps: none.
  • Rollback: a revert leaves nothing behind. Run artifacts land under /tmp and are not committed.

Tests

Ran, all on this branch:

  • ruff format --check and ruff check on the eight changed Python files: clean.
  • make typecheck: mypy-gate: 0 error(s); Success: no issues found in 71 source files.
  • pytest tests/unit/test_bench_pi_llm.py bench/test_supersession_audit.py bench/test_temporal_assertions.py bench/test_forget_switch_eval.py tests/unit/test_acceptance_benches.py tests/unit/test_bench_gate.py tests/unit/test_bench_gate_help_renders.py tests/unit/test_bench_namespaces.py -n 2: 81 passed.
  • pytest bench -q -n 2: 256 passed.
  • pytest tests/unit/test_package_contracts.py tests/unit/test_op_transport_contract.py tests/unit/test_tunable_constants.py tests/unit/test_store_names_refused.py tests/unit/test_degraded_unnoted.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py tests/unit/test_agent_instructions.py tests/analyzer -n 2: 601 passed, 12 skipped.
  • pytest tests/unit/test_format_hygiene.py tests/unit/test_stock_env_matches_docs.py tests/unit/test_docs_reference.py -n 2: 23 passed.
  • pi_llm.py --token t --audit-out FILE with OPENAI_API_KEY unset, and again with the key set and LOOM_CH_PORT on a closed port: each prints one line that names what is missing and exits 2 before any request. pi_llm.py --repeats 0: an argument error, exit 2.
  • python scripts/gates/function_length_gate.py: 52 functions over 50 statements, the baseline.
  • npx prettier@3.9.9 --check on the five changed Markdown files: clean.
  • make bench-revision-dry at the defaults: 1,400 question rows; the reader that answers the gold is 100% clean on every depth and kind, the reader that answers another value of the episode is 0% clean; gate: n=700 clusters=100, VERDICT PASS; exit 0.
  • make -n bench-revision prints the four legs; --help of the four harnesses renders.

What the new tests fail on:

  • test_every_two_fact_question_names_its_gold_facts_the_superseding_write_and_the_as_of_time: a two-fact question without the ownership fact, a superseding write that is no update of the episode, an as_of outside the gold update's interval, an as-of question at depth 1.
  • test_a_two_fact_question_never_names_the_entity_and_no_token_hides_in_another: a two-fact text that names the project, or a value token inside another value, a name or a question.
  • test_the_default_kind_sends_the_requests_it_sent_before: an ownership write, an as_of or a changed update text under --kinds current.
  • test_score_answer_on_recorded_answers: gold beside an earlier value read as clean, a later value read as correct for an as-of question, an answer with no value not read as an abstention.
  • test_gate_pairs_one_fact_with_two_fact_inside_an_episode: a pair across episodes, depths or times, an errored item left in the pair, all-stale two-fact answers not reading fail at --gate-min-delta -4.
  • test_the_planned_run_is_wide_enough: a change of kinds, depths or episodes in the target that leaves fewer pairs than the band needs.
  • test_dry_run_passes_and_writes_the_artifact_shape: a duplicate --credit, a missing header or row field, a scorer that calls every answer clean.
  • test_a_run_with_no_repeat_is_refused_when_its_flags_are_read: --repeats 0 or a negative value accepted.
  • test_audit_out_is_refused_before_the_first_request_without_its_judge_key_or_clickhouse: a run with --audit-out that sends a request without OPENAI_API_KEY or with a ClickHouse that refuses the connection, or a run without --audit-out that asks for either.
  • test_audit_out_reads_the_runs_namespaces_over_the_audits_own_window (a mock server and a recording ClickHouse client): a connect after the first request or a second connect, an audit read that is not between the last ask and the erasure, a namespace of the run missing from the bound list, a window narrower than the audit's default.
  • test_rates_are_null_without_a_labelled_pair, test_fetch_binds_every_namespace: a rate of 0.0 with no pair; a namespace interpolated into the statement or dropped from it.
  • test_corpus_cases_sit_inside_and_after_their_interval: a generated case read outside its interval, or a relation that is not single-valued, which would never close the interval.
  • test_a_corpus_case_scores_the_new_value_and_an_over_retirement: the new value read as a missing write, another stored key's retirement not read as an over-retirement, score reading the shared rows for a case with its own.

Not run, and no measurement is part of this change:

  • make bench-revision EPISODES=5, then make bench-revision. Both need a server with real providers, LOOM_BASE_URL, an org-admin LOOM_API_KEY for the erasure, the server's .env at the repository root and OPENAI_API_KEY for the audit's judge. At the defaults the run writes 400 namespaces with 2,200 memory.set_from_messages calls, sends 4,200 memory.ask calls, makes 435 extraction calls in forget_switch_eval.py and at most 1,400 judge calls in the audit.
  • No integration test: no server path changed, and the harness legs that call a server are the run above.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the harness changes, the tests, the make targets and the docs. Checked by running the commands above, by reading the full diff against the four harnesses on main, and by confirming that bench/acceptance/memory_app.py, the one caller of pi_llm outside this change, uses only _val and _ENTITIES, which are unchanged.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: none are affected.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. None added.
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. None changed.
  • The frontend builds and its tests pass, if frontend/ changed. Not changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature: none was requested.

🤖 Generated with Claude Code

…ne generated corpus, with a question that needs two facts

bench/pi_llm.py, forget_switch_eval.py, fama_forgetting.py and
supersession_audit.py shared no input and no entry point, and none asked a
question that needs two facts. They now read one corpus, the generated
episodes of pi_llm.py, and one make target runs them.

pi_llm.py:
- --kinds adds current_2hop (the module of "the project owned by team X",
  which needs the ownership fact and the latest update) and asof and
  asof_2hop (the same two questions as of the day of a middle update, sent
  with as_of). The default kind, current, sends the same requests.
- score_answer holds the scoring and adds has_later: a value written after
  the as-of time.
- --repeats, --gate, --gate-band, --gate-min-delta and --credit come from
  bench/_gate.py. The gate pairs the one-fact question with the two-fact
  question of the same episode, depth and time, and resamples episodes.
- --out writes JSONL: a header, then one line per namespace and question
  with every repeat's answer and label and the reply fields that show the
  second hop and the supersession filter.
- --audit-out runs supersession_audit.audit on the run's namespaces before
  they are erased. --dry runs two scripted readers and contacts no server.

supersession_audit.py: audit() holds the run, --namespace repeats, and both
rates are null when no pair was labelled. fama_forgetting.py: --org, and
--episodes N for cases built from the corpus under module_status.
forget_switch_eval.py: Case.existing, and --corpus-episodes N.

make bench-revision runs models_used and the four harnesses into one
directory. make bench-revision-dry is the pi_llm.py leg with --dry. No
measurement is part of this change.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 12:57am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 12:57am UTC

Request Review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit df182d6. Configure here.

Comment thread bench/pi_llm.py Resolved
…first write, and --repeats below 1 is refused

The supersession audit runs after the asks, on namespaces the run erases
when it ends. A run with --audit-out that has no OPENAI_API_KEY for the
audit's judge, or whose ClickHouse does not answer, exits 2 before it
contacts the server. Without the key the audit labelled only
byte-identical pairs and its record still named the judge.

supersession_audit.connect() returns the server's ClickHouse client and
connects it once; pi_llm.py calls it before the run and audit() reads
through the same connection.

The audit call leaves the window to the audit's default of 7 days. A
window of one day dropped the keys of the first depths from a run that
lasted longer than a day.

--repeats below 1 is an argument error. It raised IndexError in _item
after the episode's writes were sent.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zlareb1
zlareb1 merged commit a782540 into main Dec 5, 2026
78 of 80 checks passed
@zlareb1
zlareb1 deleted the bench/forgetting-multihop-harness branch December 5, 2026 01:15
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