Repository navigation
feat(challenger): add knowledge cards, task history and novelty utilities - #328
Closed
Wings-Of-Disaster wants to merge 3 commits into
Closed
Wings-Of-Disaster wants to merge 3 commits into
Wings-Of-Disaster wants to merge 3 commits into
Conversation
…utable novelty score Three modules, no dependencies between them and none on anything else new. Each answers a measured failure rather than an imagined one. knowledge.py -- a challenger left to invent topics returns to the ones it can already verify. Left to draw uniformly from a bank of cards it does not do much better: measured on a 19-iteration run against a 256-card bank, uniform drawing reached 13 distinct cards, 5% coverage, and the tasks got easier each iteration only because the policy kept meeting the same ones. KnowledgeStore walks one seeded permutation instead of drawing from it. A cursor rather than a sample means every card is reached in len(cards) / blocks_per_epoch epochs and none repeats within a pass, so a 30-iteration run covers 240 of 256 where the same run by chance covered 13. route() returns an arm as well as a card. Two consecutive groups share an anchor and differ in arm, so a block is a matched pair -- one group handed the card, one told to propose from scratch -- rather than two unrelated draws. Arm order and anchor cursor are both hashed on the epoch, which stops a loop that rebuilds its challenger per iteration from replaying the identical sequence. The bank is authenticated rather than trusted. Every card carries the checkpoint and tokenizer sha256 it was mined from, the store hashes the file it read, and TWINKLE_KNOWLEDGE_CARDS_SHA256 pins that hash for a run that wants to fail loudly on a substituted bank. A run that cannot say which bank it used cannot be reproduced from its own record. KnowledgeCardSeeder adapts the store to a no-argument seeder protocol. The control arm returns None, which such a protocol already reads as "propose from scratch", so the comparison needs no special handling downstream. One fix came out of writing the tests: block was group_id // len(arms) with no remainder, which silently assumes group_id restarts each epoch -- true for a loop that rebuilds its challenger per iteration, false for one global counter, where the cursor aliases back onto the first blocks_per_epoch anchors forever. task_bank.py -- novelty is meaningless without something to be novel against. Within one run the proposals of a group can be compared to each other; the slower failure is iteration k+1 re-proposing what iteration k already trained on, and that needs a file that outlives a run. It is also the producer for verifier/rubric_score.build_rubric_prompt(references=...), which skips its novelty criteria when the reference set is empty and which nothing in the package currently supplied. ingest_recorder fills the bank from the recorder AgenticChallenger already writes, rather than from a hook into it: the challenger stays unaware a bank exists, a resumed run gets its history at once, and add() dedupes so an ingest-every-iteration call appends each task once. The similarity used to CHOOSE which stored tasks the judge reads is 3-gram Jaccard. It is weak and known to be: over one run's 207 kept statements the closest pair scored 0.077, so ranking by it is nearly ranking at random. It never scores novelty -- the judging is rubric_score's, whose criteria compare task shapes. novelty_metric.py -- if the novelty term comes from an LLM judge, measure it before trusting it. On two recorded runs the judge scored 93.3% and 98.5% of proposals exactly zero (1439 and 4589 judged proposals), and 66.2% and 91.6% of groups (225 and 783) scored identically on every sibling. GRPO subtracts the group mean and divides by the group standard deviation, so a term constant across a group contributes exactly zero gradient -- not a small effect, a mathematically zero one. Both runs had a novelty term in the reward and in those groups it did nothing. constant_group_rate is that measurement, exported so any replacement has to be judged the same way. NoveltyScorer replaces it with two terms computed inside the group, because that is the contrast GRPO uses: distance (1 - max cosine to the closest sibling) and spread (1 / cluster size over siblings within a threshold). The vectoriser is fitted on the whole corpus rather than per group, and that is load-bearing: these statements share their scaffolding verbatim, so per-group IDF weights the boilerplate above the content and every pair of siblings looks like a duplicate. cluster_threshold is calibrated from the observed sibling cosines by default -- on one recorded run a hand-picked 0.55 left 98% of proposals in singleton clusters and the spread term measured nothing. scikit-learn is imported inside the methods that use it, so a run that never scores novelty pays nothing, and it is added to the `test` extra so CI runs these tests rather than skipping them. The tests importorskip, so they degrade rather than fail where it is absent. Not wired into a reward here: which term a challenger_reward mixes, and at what weight, is a decision for the caller rather than a default these modules should set.
Keep both supported bank formats, release/provenance authentication, deterministic knowledge/control routing, task-ledger persistence and the full novelty scorer. Remove repeated experiment narratives from code comments while retaining caller contracts and calibration/vocabulary limitations. These modules provide reusable APIs. The cookbook records the ledger but does not consume its references for reward; NoveltyScorer does not change training. Unverifiable historical coverage figures are not used to justify this revision. Validation: executable ASTs match the original modules after stripping docstrings. Previously passing functional tests were not rerun for prose edits.
1 of 4 tasks
Use single quotes where no inner quotes require double quotes. Python 3.11 exposes complete f-string tokens to the string-fixer hook; the local Python 3.12 tokenizer handles these differently. The executable AST is unchanged. Full pre-commit checks pass.
Wings-Of-Disaster
force-pushed
the
pr3-knowledge-bank
branch
2 times, most recently
from
October 26, 2026 05:51
62cddb2 to
7ef522d
Compare
1 of 4 tasks
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.
PR type
PR information
Load authenticated knowledge-card bundles and deterministically alternate knowledge/control groups.
Add a persistent kept-task ledger and a TF-IDF scorer for sibling novelty.
The bundle includes its manifest and release files.
TaskBank.ingest_recorder(save_dir)records kept proposals.
NoveltyScorerneedsscikit-learn; these utilities do not change rewards.Experiment results