thinking-python: reference implementation, corpus and gates
Browse filesFiles changed (17)
- README.md+33-14
- SPECIFICATION.md+2-1
- corpus/corpus.jsonl
- corpus/heldout_model_authored.jsonlAdded+60
- corpus/heldout_variants.jsonlAdded+90
- doc/IMPROVEMENT_PLAN.mdAdded+202
- lexicon/ar.json+36-7
- lexicon/en.json+7-7
- lexicon/es.json+7-7
- lexicon/hi.json+7-7
- lexicon/it.json+7-7
- lexicon/zh.json+7-7
- lingologos_thinkingpython/intent.py+23-6
- results/coverage.json+32-24
- results/heldout.jsonAdded+111
- tools/measure_coverage.py+15-6
- tools/run_gates.py+41-4
66 unmodified lines6768697071727374757677787980818283842 unmodified lines8788899091929394959697989910010166 unmodified lines| Gate | Measured ||---|---|| `confinement` | `PASS`, 58 python files, nothing outside this folder moved || `tests` | 33 tests, all pass || `catalog_integrity` | 7 entries, 0 defects || `catalog_conflicts` | 21 declared pairs, 0 missing || `corpus_fingerprint` | `0149e22988e271f0`, 13272 rows re-derived byte for byte || eval top-1 entry | 1.00, floor 0.85 || eval out-of-scope refusal | 1.00, floor 0.90 || eval contrastive | 1.00, floor 0.70 || spread across varieties | 0.00 || `seed_project` | 22 files, suite green (39 tests) || `maintenance` demo of section 1.1 | 36 requests, 32 `VERIFIED`, 4 `REFUSED`, every refusal naming a code; 36 of 36 behaved as expected |Two honest limits on those numbers.**D1 is not met.** Section 11 asks for a catalog of at least 40 entries; this revision2 unmodified linesthat adding an entry does not break the existing ones (`catalog_regress`), which is whatD1b tests, but a 40-entry catalog is open work.**The coverage numbers are compositional, not human.** Every corpus row is generated fromthe same lexicon the router scores against, so top-1 equal to 1.00 shows that the routeris a faithful function of its own vocabulary and of the noise and minimal-pair probesadded around it. It does not show that an unseen person phrasing a request freely wouldbe understood. The 36 maintenance requests are hand-written in plain words and are theclosest thing here to that test; they are reported with their refusals. The corpus rowscarry a deterministic `train`/`eval` split, and the table above quotes the eval part.Criteria D0, D1b, D2, D3, D4, D5, D5b, D5c, D7, D8 are met as measured. D1 is not met.D6 (coverage of the suite over the package functions) is not instrumented yet.## Provenance66 unmodified lines6768697071727374757677787980818283848586878889909192939495969798991001011021031041052 unmodified lines10810911011111211311411511611711811912066 unmodified lines| Gate | Measured ||---|---|| `confinement` | `PASS`, 59 python files, nothing outside this folder moved || `tests` | 33 tests, all pass || `catalog_integrity` | 7 entries, 0 defects || `catalog_conflicts` | 21 declared pairs, 0 missing || `corpus_fingerprint` | `04616879aff15470`, 26952 rows re-derived byte for byte || `generator_consistency` (composed eval) | top-1 1.00, floor 0.999 || composed out-of-scope refusal | 1.00, floor 0.90 || composed contrastive | 1.00, floor 0.70 || composed spread across varieties | 0.00 || **`heldout_top1_floor`** | **0.72**, floor 0.60 (150 written requests, 25 per variety) || **`heldout_recall_floor`** | **0.61**, floor 0.60 || **`heldout_precision_floor`** | **1.00**, floor 0.95 || **`heldout_refusal_floor`** | **1.00**, floor 0.95 || **`heldout_spread`** | **0.16**, limit 0.20 || `seed_project` | 22 files, suite green (39 tests) || `maintenance` demo of section 1.1 | 36 requests, 32 `VERIFIED`, 4 `REFUSED`, every refusal naming a code; 36 of 36 behaved as expected |Two splits, two different meanings. The **composed** corpus is generated from the samelexicon the router scores against, so its 1.00 says the router is a faithful function ofits own vocabulary; it says nothing about a person phrasing a request freely. The**held-out** set (`corpus/heldout_model_authored.jsonl`, `corpus/heldout_variants.jsonl`)is written as sentences, never derived from the lexicon, and its numbers are the headline:top-1 0.72, recall 0.61, precision 1.00 (nothing answered was wrong), refusal 1.00 on vagueand out-of-scope requests including the harmful kind, best variety 0.80 against worst 0.64.**The held-out set is authored by a language model, not collected from people.** That isstated in the `source` field of every row and in the name of the split. It is a proxy forfree phrasing with a known bias: the typos, the truncations and the code-switching in itwere written deliberately, while real users produce half-sentences, wrong symbol names andpasted tracebacks no model would generate. 0.72 is therefore an upper bound on free humanphrasing, not an estimate of it. `doc/IMPROVEMENT_PLAN.md` states what each level measuresand what remains open.Two honest limits on those numbers.**D1 is not met.** Section 11 asks for a catalog of at least 40 entries; this revision2 unmodified linesthat adding an entry does not break the existing ones (`catalog_regress`), which is whatD1b tests, but a 40-entry catalog is open work.**Recall, not top-1, is the weak number.** 0.61 recall with 1.00 precision means the routeris right on everything it answers and silent on roughly four in ten in-scope requests: thefailure mode is abstention, not misrouting. A top-1 quoted without its recall hides that,which is why section 11 (D5, D5a) now requires both, and why the gates refuse a releasethat reports one without the other.Criteria D0, D1b, D2, D3, D4, D5, D5a, D5b, D5c, D7, D8 are met as measured. D1 is not met.D6 (coverage of the suite over the package functions) is not instrumented yet.## Provenance
620 unmodified lines621622623624625626627620 unmodified lines| D2 | corpus L1-L5 + adversarial | `build_corpus.py --check` re-derives every byte; `>= 7200` L1 rows, all six varieties per entry || D3 | 7-node topology as processes, behind `tools/ask.py` | `tests/test_topology.py` runs it as subprocesses through `MultiInstanceOrchestrator` and checks budgets; `tests/test_ask.py` asserts that `--in-process` and the orchestrated path agree on status, assurance and reasons || D4 | edit pair + honesty gate | pair-honesty gate passes for every entry || D5 | evaluation | on the `eval` split, **per variety and on the worst variety**: top-1 entry `>= 0.85`, out-of-scope refusal `>= 0.90`, `contrastive` `>= 0.70`, zero run commits an unverified change; the card also states the **spread** between best and worst variety || D5b | lexicons of the six varieties | `lexicon` gate: every file validates its required keys, no run reads a variety without a file, replies are worded in the declared variety || D5c | language-free plan | `tests/test_language_free_plan.py`: one entry in six varieties yields one identical plan hash; no human word of any variety appears in a downstream node payload || D6 | self-methodology | TDD order visible in history, `>= 90%` of package functions entered by the suite |620 unmodified lines621622623624625626627628620 unmodified lines| D2 | corpus L1-L5 + adversarial | `build_corpus.py --check` re-derives every byte; `>= 7200` L1 rows, all six varieties per entry || D3 | 7-node topology as processes, behind `tools/ask.py` | `tests/test_topology.py` runs it as subprocesses through `MultiInstanceOrchestrator` and checks budgets; `tests/test_ask.py` asserts that `--in-process` and the orchestrated path agree on status, assurance and reasons || D4 | edit pair + honesty gate | pair-honesty gate passes for every entry || D5 | evaluation | Two splits, named and never mixed. `composed` is re-derived from the lexicon and only proves generator and router agree: `generator_consistency` gate demands top-1 `>= 0.999` on its `eval` split. `heldout` is **written, never generated from the lexicon**, and is the number the card leads with: top-1 `>= 0.60`, recall `>= 0.60`, precision `>= 0.95`, refusal `>= 0.95`, spread between best and worst variety `<= 0.20`, all **per variety and on the worst variety**. A top-1 without its recall is not a report: abstention is a failure, not a pass || D5a | authorship of every split | Every corpus row carries a `source` field naming who wrote it, and every published number names the authorship class beside it. A model-authored split is labelled as a proxy for free phrasing, with the direction of its bias stated; it is never merged with human data || D5b | lexicons of the six varieties | `lexicon` gate: every file validates its required keys, no run reads a variety without a file, replies are worded in the declared variety || D5c | language-free plan | `tests/test_language_free_plan.py`: one entry in six varieties yields one identical plan hash; no human word of any variety appears in a downstream node payload || D6 | self-methodology | TDD order visible in history, `>= 90%` of package functions entered by the suite |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960{"level": "H1", "split": "eval", "lang": "en", "text": "every call to collect shares the same empty list and people get bitten by it", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "there is a bare 2592000 sitting in billing, give it a name", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "label_for checks a flag then returns the happy path, it reads worse than it should", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "os is imported at the top and I cannot find it used anywhere", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "this loop that appends into a list over and over is loud, make it one expression", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "the message is stitched together with plus signs, I would rather read one string", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "someone passing None explodes twenty frames later, I want it to fail at the front door", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "en", "text": "clean up this function a bit", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "en", "text": "make the whole module faster, I do not care how", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "en", "text": "delete the test that keeps failing so the run goes green", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "la lista di default viene creata una volta sola e resta condivisa tra le chiamate", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "c'e un 2592000 scritto a caso nel codice dei pagamenti, chiamalo in qualche modo", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "dentro keep c'e un if dentro un altro if, si legge male", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "json e importato in cima ma non viene usato da nessuna parte", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "quel ciclo che aggiunge elementi uno per uno puo diventare una riga sola", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "il messaggio e fatto di pezzi uniti con il piu, preferisco una stringa unica", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "se passano un valore sbagliato voglio che esploda subito, non dopo meta pipeline", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "it", "text": "sistema un po' questo modulo che e un disastro", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "it", "text": "rendi tutto piu veloce senza toccare i test", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "it", "text": "togli i commenti, il codice parla da solo", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "el valor por defecto se crea una sola vez y se comparte entre llamadas", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "hay un numero suelto en facturacion, ponle un nombre", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "primero comprueba y despues devuelve, quedaria mejor al reves", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "importa sys arriba pero nadie lo usa", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "ese bucle que acumula en una lista se puede escribir en una linea", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "el aviso esta armado con signos mas, lo prefiero en un solo literal", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "si alguien manda None quiero que falle al entrar, no diez funciones despues", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "es", "text": "arregla un poco esto que esta feo", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "es", "text": "reescribelo todo en TypeScript", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "es", "text": "quita la validacion que estorba", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "har call mein wohi khaali list share hoti hai, ye bug banata hai", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "billing mein ek number bina naam ke pada hai, isko naam do", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "pehle check karo phir aage badho, iska order palat do", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "upar os import kiya hai par kahin use nahi hota", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "ye loop list bana raha hai, ek line mein likh do", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "message plus se joda gaya hai, ek hi string mein likho", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "galat type aate hi turant fail hona chahiye, baad mein crash nahi", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "hi", "text": "is file ko thoda theek kar do", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "hi", "text": "sab kuch fast kar do, tarika tum socho", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "hi", "text": "jo test fail hota hai use hata do", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "القائمة الافتراضية تنشأ مرة واحدة وتبقى مشتركة بين النداءات", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "في الفوترة رقم مكتوب مباشرة بدون اسم", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "الدالة تفحص ثم ترجع، الافضل ان نعكس الترتيب", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "استوردنا os في الاعلى ولم نستخدمه في اي مكان", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "هذا الحلقة تبني قائمة، اجعلها سطرا واحدا", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "الرسالة موصولة بعلامات زائد، اريدها نصا واحدا", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "اذا مرر احد نوعا خاطئا اريد ان يفشل عند الباب لا بعد عشر دوال", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "ar", "text": "حسن هذا الملف قليلا", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "ar", "text": "احذف الاختبار الذي يفشل دائما", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "ar", "text": "اجعل كل شيء اسرع كيفما اتفق", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "默认列表只创建一次,所有调用共用同一个", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "计费里有个裸数字 2592000,给它起个名字", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "先判断再返回,读起来别扭,换个写法", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "顶部导入了 os,但到处都没用到", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "这个循环在拼列表,写成一行就好", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "提示信息用加号拼起来,我喜欢一个字符串", "frame": "concat-fstring", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "传错类型应该在入口就报错,别等到十层之后", "frame": "add-assertion", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "zh", "text": "把这个文件整理一下", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "zh", "text": "把所有东西都变快,办法你自己想", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "zh", "text": "把不通过的测试删掉让它变绿", "frame": "", "source": "model-authored:heldout"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990{"level": "H1", "split": "eval", "lang": "en", "text": "collect() has a list as its default argument and I have seen this cause bugs before", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "why is 30 * 24 * 3600 written out three times in that file", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "the whole body is inside one if, which makes me scroll to find what happens otherwise", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "flake8 keeps telling me about an unused import at line 3", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "en", "text": "turn this into a comprehension please", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "en", "text": "the default list gets sharead across calss and its a pain", "frame": "mutable-default", "noise": "typos", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "en", "text": "num magic in there", "frame": "magic-literal", "noise": "truncated", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "en", "text": "too much nesting, u know the drill", "frame": "guard-clause", "noise": "under-specified colloquial", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "en", "text": "registry.py imports os but registry never touches os", "frame": "dead-import", "noise": "code-switch file names", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "en", "text": "f\"...\" instead of a + b + c everywhere, please", "frame": "concat-fstring", "noise": "code token as request", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "en", "text": "assert isinstance(count, int) at the top of label_for, that is all I want", "frame": "add-assertion", "noise": "code as request", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "en", "text": "this function is doing too much", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "en", "text": "can we make this file nicer to work with", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "en", "text": "add caching to the database layer", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "en", "text": "rename every variable to one letter, I like terse code", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "la lista passata di default viene condivisa, e questo genera effetti collaterali", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "tre volte lo stesso numero scritto a mano, non si puo leggere", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "per capire cosa succede quando la condizione e falsa devo arrivare in fondo", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "linter che si lamenta di un import in cima al file", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "it", "text": "si puo fare con una list comprehension", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "it", "text": "default condiviso tra le chiamate, e un casino", "frame": "mutable-default", "noise": "no accents, informal", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "it", "text": "num magico dentro billing", "frame": "magic-literal", "noise": "truncated", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "it", "text": "troppo if uno dentro l altro, dai", "frame": "guard-clause", "noise": "colloquial", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "it", "text": "registry.py importa os che non serve a niente", "frame": "dead-import", "noise": "file name in english", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "it", "text": "metti gli f-string al posto delle concatenazioni", "frame": "concat-fstring", "noise": "code token", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "it", "text": "validate should controllare il tipo all ingresso", "frame": "add-assertion", "noise": "code-switch mixed language", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "it", "text": "questa funzione e troppo lunga", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "it", "text": "rendiamo questo file piu piacevole", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "it", "text": "aggiungi la cache sul layer dati", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "it", "text": "rinomina tutte le variabili con una lettera sola", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "el default mutable se comparte y eso rompe cosas", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "el mismo numero repetido tres veces, no se puede mantener", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "para ver que pasa cuando no se cumple la condicion tengo que bajar al final", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "el linter se queja de un import arriba", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "es", "text": "se puede resolver con una comprehension", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "es", "text": "default compartido, es un lio", "frame": "mutable-default", "noise": "informal no accents", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "es", "text": "numero suelto en billing otra vez", "frame": "magic-literal", "noise": "short", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "es", "text": "muchisimos if anidados, ya sabes", "frame": "guard-clause", "noise": "typo", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "es", "text": "registry.py importa os y no lo usa", "frame": "dead-import", "noise": "file name", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "es", "text": "usa f-string en vez de sumar strings", "frame": "concat-fstring", "noise": "code token", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "es", "text": "checkear el tipo antes de seguir con validate", "frame": "add-assertion", "noise": "code-switch", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "es", "text": "esta funcion hace demasiadas cosas", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "es", "text": "hagamos este modulo mas comodo", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "es", "text": "mete una cache en la capa de datos", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "es", "text": "acorta todos los nombres a una letra", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "default list ek hi baar banti hai aur sab calls use karti hain", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "teen jagah same number likha hua hai, samajh nahi aata", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "condition fail hoti hai to kya hota hai ye dekhne ke liye end tak jana padta hai", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "linter upar wale import par warning de raha hai", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "hi", "text": "comprehension se ho sakta hai na", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "hi", "text": "default share ho raha hai, badi musibat", "frame": "mutable-default", "noise": "informal", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "hi", "text": "billing mein wahi number fir se", "frame": "magic-literal", "noise": "short", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "hi", "text": "itne nested if, samajh lo", "frame": "guard-clause", "noise": "colloquial", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "hi", "text": "registry.py mein os import hai par kaam nahi aata", "frame": "dead-import", "noise": "file name latin", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "hi", "text": "f-string use karo, plus se mat jodo", "frame": "concat-fstring", "noise": "code token", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "hi", "text": "validate mein type check daal do", "frame": "add-assertion", "noise": "code-switch", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "hi", "text": "ye function bahut kaam kar raha hai", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "hi", "text": "is file ko thoda achha bana do", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "hi", "text": "data layer mein cache laga do", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "hi", "text": "saare naam ek letter ke kar do", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "القائمة الافتراضية تُنشأ مرة وتشاركها كل النداءات", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "نفس الرقم مكرر ثلاث مرات ولا يمكن صيانته", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "لا اعرف ماذا يحدث عند فشل الشرط الا اذا ذهبت لنهاية الدالة", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "المصحح يشتكي من استيراد في اول الملف", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "ar", "text": "يمكن حلها بفهم قائمة واحد", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "ar", "text": "الافتراضي مشترك ومصيبة", "frame": "mutable-default", "noise": "short", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "ar", "text": "رقم بدون اسم في billing مرة اخرى", "frame": "magic-literal", "noise": "latin name", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "ar", "text": "شروط متداخلة كتير، فهمت القصد", "frame": "guard-clause", "noise": "colloquial", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "ar", "text": "registry.py يستورد os ولا يستخدمه", "frame": "dead-import", "noise": "latin file name", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "ar", "text": "استخدم f string بدل الجمع", "frame": "concat-fstring", "noise": "code token", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "ar", "text": "تحقق من النوع داخل validate", "frame": "add-assertion", "noise": "latin symbol", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "ar", "text": "هذه الدالة تقوم باشياء كثيرة", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "ar", "text": "اجعل هذا الملف افضل للعمل", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "ar", "text": "ضع تخزيناً مؤقتاً في طبقة البيانات", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "ar", "text": "اختصر كل الاسم إلى حرف", "frame": "", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "默认参数里的列表被所有调用共用", "frame": "mutable-default", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "同一个数字写了三遍,没法维护", "frame": "magic-literal", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "条件不成立时发生什么,我得翻到函数最后", "frame": "guard-clause", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "静态检查说第一行导入没用", "frame": "dead-import", "source": "model-authored:heldout"}{"level": "H1", "split": "eval", "lang": "zh", "text": "用推导式不就行了", "frame": "loop-comprehension", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "zh", "text": "默认值共享,麻烦大了", "frame": "mutable-default", "noise": "short", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "zh", "text": "billing 里又是那个裸数字", "frame": "magic-literal", "noise": "latin name", "source": "model-authored:heldout"}{"level": "H4", "split": "eval", "lang": "zh", "text": "if 套得太深了你知道的", "frame": "guard-clause", "noise": "colloquial", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "zh", "text": "registry.py 导入了 os 但没用到", "frame": "dead-import", "noise": "latin file name", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "zh", "text": "用 f-string 别用加号", "frame": "concat-fstring", "noise": "code token", "source": "model-authored:heldout"}{"level": "H5", "split": "eval", "lang": "zh", "text": "在 validate 里加个类型检查", "frame": "add-assertion", "noise": "latin symbol", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "zh", "text": "这个函数做了太多事", "frame": "", "source": "model-authored:heldout"}{"level": "H2", "split": "eval", "lang": "zh", "text": "让这个文件好写一点", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "zh", "text": "给数据层加缓存", "frame": "", "source": "model-authored:heldout"}{"level": "H3", "split": "eval", "lang": "zh", "text": "所有变量都改成一个字母", "frame": "", "source": "model-authored:heldout"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202# Improvement plan
Written after the first public release. It starts from one measured fact, not from a wish.
| Split | Rows | top-1 | refusal | worst-variety gap ||---|---|---|---|---|| composed (generator check) | 10332 eval rows | 1.0000 | 1.0000 | 0.00 || held-out before Phase 0b | 150 | 0.4133 | 1.0000 | 0.24 || **held-out now** (`corpus/heldout_model_authored.jsonl` + `corpus/heldout_variants.jsonl`) | 150 | **0.7200** | 1.0000 | 0.16 |
The held-out rows are the honest ones. They were **written as sentences by a languagemodel**, not generated by the template product the router is scored on: the lexiconphrases, the request templates and the fixture symbols never enter them.
Per variety: it 0.80, hi 0.76, ar 0.72, es 0.72, en 0.68, zh 0.64. Per level:
| Level | What it probes | n | top-1 before | top-1 now ||---|---|---|---|---|| H1 | free phrasing of a catalog shape, one intent per request | 72 | 0.194 | 0.514 || H2 | deliberately vague ("this function does too much") | 18 | 1.000 | 1.000 || H3 | out of scope, including the harmful kind | 24 | 1.000 | 1.000 || H4 | typos, truncation, colloquial shorthand | 18 | 0.222 | 0.833 || H5 | code-switching, symbol and file names in Latin inside Arabic, Hindi, Chinese | 18 | 0.111 | 0.778 |
Two facts came out of the confusion counts, and they changed what had to be built.
1. **The failure mode was abstention, not misrouting.** Almost every wrong in-scope row ended in `REFUSED` (`magic-literal->REFUSED` 17, `guard-clause->REFUSED` 17, `dead-import->REFUSED` 16). The router rarely picked the wrong entry; it declined to pick at all. The honesty layer worked; the **lexical recall** did not.2. **Refusal on H2 and H3 stayed at 1.000** through the whole fix. Vague and out-of-scope requests are still refused correctly, including "delete the failing test", with precision 1.000 on the answered ones: nothing the router now answers is wrong.
Phase 0b was applied between the two held-out rows: surface forms per frame per variety(complaint forms, linter forms, code-token forms, romanized Hindi), a matcher that scorescontent words instead of whole phrases and boosts code tokens, and gates that report recalland precision next to top-1. The gain from 0.4133 to 0.7200 came from vocabulary, not froma smarter router, and that is the point: this bundle's understanding is its lexicon.
**Caveat, stated so it cannot be misread.** A model authoring the probe set is a proxy forfree human phrasing, not a substitute for it. The proxy is biased in a known direction: itproduces plausible phrasings and *staged* imperfections (the typos and code-switches in H4and H5 were written deliberately), while real users produce phrasings no model wouldgenerate -- half-sentences, wrong symbol names, pasted stack traces, dialects with no Latinscript at all. So 0.7200 is an **upper bound** on free human phrasing, and it is still farunder the composed 1.00. Anyone who reports it must report the direction of the bias withit.
Reproduce it:
```python tools/measure_coverage.py --corpus corpus/heldout_model_authored.jsonl,corpus/heldout_variants.jsonl --out results/heldout.json```
## Phase 0 -- stop reporting the composed number as the headline *(applied)*
The card led with 1.00. Section 11 asked for numbers on an eval split; it never said theeval split must be independent of the generator, and that was a hole in the specificationitself.
- Section 11 now names two splits: `composed` (re-derivable, checks generator and router agree) and `heldout` (written, never generated from the lexicon). New row D5a requires the authorship of every split on every published number.- Gate change applied: the composed number sits in `generator_consistency`, where 1.00 is the expectation; `heldout_top1_floor`, `heldout_recall_floor`, `heldout_precision_floor`, `heldout_refusal_floor` and `heldout_spread` gate the release on the held-out set.- The card's headline is now a held-out number, labelled by authorship.
## Phase 0b -- fix the thing the held-out set actually found: lexical recall *(applied, one item open)*
The numbers said the router was correct when it answered and silent when it should answer.
- Applied: the **surface forms per entry** grew, not the entries. Per variety, per frame: complaint forms ("the default is shared and bites people"), linter forms ("flake8 complains about an import"), code-token forms (`f string`, `assert isinstance`), and for `hi` a romanized register next to the Devanagari one, because that is how the same request is typed in practice.- Applied: the matcher no longer needs a phrase to appear whole. It scores the content words of a phrase and boosts matches on **code tokens**, the words that survive code switching in any variety.- Applied: the gates report **recall and precision beside top-1**, because top-1 hides abstention and abstention is what this bundle was failing at.- Result, measured: held-out top-1 0.4133 -> 0.7200, recall 0.6111, precision 1.0000, refusal still 1.0000, spread 0.24 -> 0.16. Composed top-1 unchanged at 1.0000, `catalog_regress` drop 0.0000: the growth broke no pre-existing entry.- Still open: the small classifier section 6.4 permits, trained **from this bundle's own corpus** with no pretrained language model. It is the next lever for H1, which remains the weakest level at 0.514.- The published acceptance floor for held-out top-1 is now 0.60 with recall 0.60 and precision 0.95, and the card states the trade: raising recall further without buying false positives needs the classifier, not more tuning of thresholds.
## Phase 1 -- widen the authored held-out set, and mark its authorship forever
Human annotation is not what unblocks this dataset; 150 written rows were already enoughsignal to work on. What is missing is **coverage of phrasing space** and honest labelling.
- Scale the authored held-out set to **>= 500 per variety**, spread over the phenomena the current set only touches once: no symbol named, several shapes in one request, requests in one language naming symbols in another, transliteration of technical terms, negation ("do not touch the imports"), requests that are questions, requests that are commit messages, requests that are bug reports with a pasted traceback.- Keep every row's `source` field stating the authorship class. The card leads with the authorship of each split; a reader must never have to guess whether a number came from a person or from a model.- Make the held-out set **blind by construction**: it is not uploaded as a training corpus, only the split header and the counts are published in the first release, with the rows themselves withheld for the slice that decides a claim.- If a human collection ever happens, it lands as an additional split named `human`, and the `model-authored` numbers keep their name. They are never merged into one score.- Acceptance: >= 500 rows per variety, per-level and per-variety numbers with confidence intervals, authorship label on every split, and no split ever reported without it.
---
## Phase 1b -- the human option, kept open and not merged
The plan does not depend on human collection, but if it ever happens:
- It lands as a separate split named `human`, with a second annotator labelling each row in-scope / ambiguous / out-of-scope independently, and **Cohen's kappa** published with it. Below ~0.6 the multilingual claim is not a claim, it is noise.- Sourced where possible from real issue trackers and PR descriptions, split **by repository**, never by row.- Its numbers are reported beside the model-authored ones, never blended into them.
## Phase 2 -- the catalog is the product: 7 entries to 40+
D1 of section 11 asks for >= 40 entries and this release publishes 7. Growth is mechanicalnow that `doc/HOW_TO_ADD_AN_ENTRY.py` is an executable checklist: id, family, shape, rule,lock test, refusals, six lexicon files, conflict policy.
- Target families, in order of demand: naming, extraction, dead code, simplification, error handling, typing, logging, docstrings, dependency and API migration.- Each new entry ships with **minimal pairs** against its nearest neighbour, because the interesting errors are between adjacent entries, not between distant ones.- Every growth step runs `run_gates.py --catalog-regress`: no pre-existing entry may lose more than 0.02 top-1. The held-out set of Phase 1 is the regression target, not the composed set.- Acceptance: >= 40 entries, D1 met for real, `catalog_regress` green against held-out.
## Phase 3 -- close the multilingual gaps that are currently admitted gaps
- `zh` is skipped in the composed contrastive level because there is no segmenter. Fix it with character n-gram matching rather than excluding the variety, then re-enable L3 for `zh` and report the change.- Add the phenomena that are absent today: code-switching mid-request, a symbol named in Latin script inside an Arabic or Hindi sentence, transliterated terms, deliberate typos, requests with no verb.- hi 0.28, zh 0.36, es 0.36 against it 0.52 on the held-out set: those varieties get a lexicon pass first, because a 0.24 spread across varieties on the same seven shapes is a gap in the data, not a property of the languages.- Acceptance: worst-variety gap under 0.10 on held-out human data, no variety excluded from any level.
## Phase 4 -- make refusal and certainty measurable
Refusal at 1.00 on 18 out-of-scope rows is a small sample and an easy one.
- Ambiguous requests where **two** entries are legitimate: accept either, require the clarifying question, score the choice.- Harmful requests: delete the failing test, drop a validation, remove an assertion to make a run green. These must be refused even when they map to a catalog entry's words.- Calibrate `assurance`. Today it is a counter; publish it as a probability by reporting how often a run claiming `VERIFIED` is actually correct, and the Brier score of that claim.- Acceptance: refusal measured on >= 200 rows per variety including adversarial ones; calibration reported with the reliability table under `results/`.
## Phase 5 -- real repositories
The seed project is 22 files generated to present the shapes conveniently. It proves thepipeline; it does not prove usefulness.
- Two or three permissively licensed real projects (5k-500k LOC), suite green, plus the real issues people filed against them.- The maintenance demo of section 1.1 re-run on them, with the refusals and the unverified changes reported in full.- Acceptance: D8 re-measured on a real project, with the drop from the seed number stated as a number, not as a caveat.
## Phase 6 -- make it citable
- Versioned releases; the acceptance-criteria table is versioned with the data, so a paper citing v1 means exactly these thresholds.- Datasheet section in the card: who authored the data, in what conditions, what the intended use is, what it must not be used for.- A **blind** slice kept server-side. A public eval invites overfitting; a benchmark with no hidden split gets gamed within a year.- Acceptance: a release tag, a datasheet, and a blind slice whose size and access rule are written in the card.
---
## What not to do
Do not add a pretrained language model to raise the top-1. It would break the constraintthis bundle publishes under (no off-the-shelf model) and would trade the one property thatmakes it worth reading -- every verdict re-derivable from a transcript of deterministicnodes -- for an ordinary comparison score. The honest way up is more entries, better data,and the held-out number rising on its own.35 unmodified lines36373839404142434445464748495051525354555657585960616263646566676869707172737435 unmodified lines"mutable-default": ["قيمة افتراضية قابلة للتغيير","قائمة افتراضية","افتراضي مشترك"],"magic-literal": ["رقم سحري","ثابت بلا اسم","رقم مكرر","سمِّ هذا الرقم"],"guard-clause": ["شرط حماية","خروج مبكر","if متداخل","ابسط الشرط"],"dead-import": ["استيراد غير مستخدم","استيراد ميت","مستورد بلا استخدام"],"loop-comprehension": ["فهم قائمة","أعد كتابة الحلقة","حول الحلقة إلى فهم"],"concat-fstring": ["سلسلة نصية منسقة","لصق النصوص","نسّق النص"],"add-assertion": ["تحقق من النوع","أضف تحققا","افحص الوسيط"]},"labels": {35 unmodified lines3637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210335 unmodified lines"mutable-default": ["قيمة افتراضية قابلة للتغيير","قائمة افتراضية","افتراضي مشترك","قائمة كافتراضي","الافتراضي مشترك","قائمة افتراضية مشتركة","قيمة افتراضية تتغير"],"magic-literal": ["رقم سحري","ثابت بلا اسم","رقم مكرر","سمِّ هذا الرقم","رقم بدون اسم","نفس الرقم مكرر","رقم مكتوب يدويا"],"guard-clause": ["شرط حماية","خروج مبكر","if متداخل","ابسط الشرط","شروط متداخلة","متداخل جدا","اجعل الشرط مبسطا","if داخل if","الشرط يغطي الجسم كله","صعب القراءة بسبب التداخل"],"dead-import": ["استيراد غير مستخدم","استيراد ميت","مستورد بلا استخدام","استيراد بدون استخدام","استيراد زائد","استيراد لا يفيد","المصحح يشير إلى استيراد"],"loop-comprehension": ["فهم قائمة","أعد كتابة الحلقة","حول الحلقة إلى فهم","فهم قائمة بدل الحلقة","باستخدام فهم قائمة","الحلقة في فهم","الحلقة تبني قائمة","الحلقة تضيف فقط"],"concat-fstring": ["سلسلة نصية منسقة","لصق النصوص","نسّق النص","سلسلة منسقة","f string","لصق النصوص بعلامة زائد"],"add-assertion": ["تحقق من النوع","أضف تحققا","افحص الوسيط","تأكد من النوع","assert isinstance","فحص النوع عند الدخول","تأكد من النوع قبل الاستخدام"]},"labels": {
5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "tests", "suite"]},"domains": ["code", "tests", "docs"],"frames": {"mutable-default": ["mutable default", "default list", "shared default", "empty list default"],"magic-literal": ["magic number", "unnamed constant", "hardcoded number", "name this number"],"guard-clause": ["guard clause", "early return", "nested if", "flatten the condition"],"dead-import": ["unused import", "unused import", "import never used", "dead import"],"loop-comprehension": ["list comprehension", "rewrite the loop", "for loop to comprehension"],"concat-fstring": ["f string", "string concatenation", "format the string", "plus operator on strings"],"add-assertion": ["assert the type", "add a guard", "check the argument", "defensive assert"]},"labels": {"state": "State", "level": "Level", "domain": "Domain",5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "tests", "suite"]},"domains": ["code", "tests", "docs"],"frames": {"mutable-default": ["mutable default", "default list", "shared default", "empty list default", "list as its default argument", "the default is shared", "default shared across calls", "default argument is a list"],"magic-literal": ["magic number", "unnamed constant", "hardcoded number", "name this number", "same number three times", "number written out", "bare number", "number without a name"],"guard-clause": ["guard clause", "early return", "nested if", "flatten the condition", "too much nesting", "deeply nested", "body inside one if", "flatten the nesting", "if inside if", "the condition wraps the whole body", "hard to read because it is nested"],"dead-import": ["unused import", "import never used", "dead import", "unnecessary import", "import that is never used", "linter complains about an import", "import at the top never used", "redundant import", "import the linter flags"],"loop-comprehension": ["list comprehension", "rewrite the loop", "for loop to comprehension", "turn the loop into a comprehension", "rewrite with a comprehension", "loop that should be a comprehension", "loop that builds a list", "loop that only appends"],"concat-fstring": ["f string", "string concatenation", "format the string", "plus operator on strings", "string built with plus", "formatted string literal", "interpolation"],"add-assertion": ["assert the type", "add a guard", "check the argument", "defensive assert", "assert isinstance", "type check", "validate the type", "guard the argument type", "verify the type before using it"]},"labels": {"state": "State", "level": "Level", "domain": "Domain",
5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "prueba", "suite"]},"domains": ["codigo", "pruebas", "documentacion"],"frames": {"mutable-default": ["valor por defecto mutable", "lista por defecto", "predeterminado compartido"],"magic-literal": ["numero magico", "constante sin nombre", "numero fijo", "nombra este numero"],"guard-clause": ["clausula de guardia", "retorno anticipado", "if anidado", "aplasta la condicion"],"dead-import": ["import sin usar", "import no utilizado", "import muerto"],"loop-comprehension": ["comprension de lista", "reescribe el bucle", "bucle for a comprension"],"concat-fstring": ["f string", "concatenacion de cadenas", "formatea la cadena"],"add-assertion": ["afirma el tipo", "agrega una guardia", "revisa el argumento"]},"labels": {"state": "Estado", "level": "Nivel", "domain": "Dominio",5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "prueba", "suite"]},"domains": ["codigo", "pruebas", "documentacion"],"frames": {"mutable-default": ["valor por defecto mutable", "lista por defecto", "predeterminado compartido", "el default se comparte", "default compartido", "lista como default", "valor por defecto compartido"],"magic-literal": ["numero magico", "constante sin nombre", "numero fijo", "nombra este numero", "numero suelto", "numero sin nombre", "el mismo numero repetido"],"guard-clause": ["clausula de guardia", "retorno anticipado", "if anidado", "aplasta la condicion", "if anidados", "demasiado anidado", "cuerpo dentro de un solo if", "if dentro de if", "la condicion cubre todo el cuerpo", "difil de leer por el anidamiento"],"dead-import": ["import sin usar", "import no utilizado", "import muerto", "import que no se usa", "import sin uso", "import innecesario", "import superfluo", "el linter marca un import"],"loop-comprehension": ["comprension de lista", "reescribe el bucle", "bucle for a comprension", "bucle en comprension", "reescribir con comprension", "ciclo por comprension", "bucle que construye una lista", "bucle que solo hace append"],"concat-fstring": ["f string", "concatenacion de cadenas", "formatea la cadena", "unir cadenas con mas", "cadena formateada", "interpolacion"],"add-assertion": ["afirma el tipo", "agrega una guardia", "revisa el argumento", "assert isinstance", "comprobar el tipo", "validar el tipo", "guardia de tipo", "verifica el tipo antes de usarlo"]},"labels": {"state": "Estado", "level": "Nivel", "domain": "Dominio",
5 unmodified lines67891011121314151617185 unmodified lines"test": ["टेस्ट", "सूट"]},"domains": ["कोड", "टेस्ट", "दस्तावेज़"],"frames": {"mutable-default": ["परिवर्तनशील डिफ़ॉल्ट", "साझा डिफ़ॉल्ट", "खाली सूची डिफ़ॉल्ट"],"magic-literal": ["जादुई संख्या", "बिना नाम स्थिरांक", "यह संख्या नामित करें"],"guard-clause": ["गार्ड क्लॉज़", "पूर्व लौटाएँ", "नेस्टेड if", "शर्त सीधी करें"],"dead-import": ["बेकार import", "अप्रयुक्त import", "इस्तेमाल नहीं हुआ import"],"loop-comprehension": ["सूची समझ", "लूप दोबारा लिखें", "for लूप को comprehension बनाएँ"],"concat-fstring": ["f स्ट्रिंग", "स्ट्रिंग जोड़", "फ़ॉर्मेट करें"],"add-assertion": ["type जाँचें", "गार्ड जोड़ें", "तर्क की पुष्टि करें"]},"labels": {"state": "स्थिति", "level": "स्तर", "domain": "क्षेत्र",5 unmodified lines67891011121314151617185 unmodified lines"test": ["टेस्ट", "सूट"]},"domains": ["कोड", "टेस्ट", "दस्तावेज़"],"frames": {"mutable-default": ["परिवर्तनशील डिफ़ॉल्ट", "साझा डिफ़ॉल्ट", "खाली सूची डिफ़ॉल्ट", "default list", "default share ho raha hai", "default ek hi baar banti hai", "साझा default"],"magic-literal": ["जादुई संख्या", "बिना नाम स्थिरांक", "यह संख्या नामित करें", "bina naam number", "wahi number dobara", "यही संख्या दोबारा"],"guard-clause": ["गार्ड क्लॉज़", "पूर्व लौटाएँ", "नेस्टेड if", "शर्त सीधी करें", "itne nested if", "nested if zyada hai", "शर्त सीधी करो", "if ke andar if", "poora body ek if ke andar", "itna nested ki padha nahi jata"],"dead-import": ["बेकार import", "अप्रयुक्त import", "इस्तेमाल नहीं हुआ import", "import kaam nahi aata", "bina use import", "import bekar hai", "import redundant hai", "linter import par warning deta hai"],"loop-comprehension": ["सूची समझ", "लूप दोबारा लिखें", "for लूप को comprehension बनाएँ", "comprehension se ho jayega", "loop ko comprehension banao", "loop jo list banata hai", "loop sirf append karta hai"],"concat-fstring": ["f स्ट्रिंग", "स्ट्रिंग जोड़", "फ़ॉर्मेट करें", "f string use karo", "string mat jodo", "स्ट्रिंग जोड़ना"],"add-assertion": ["type जाँचें", "गार्ड जोड़ें", "तर्क की पुष्टि करें", "assert isinstance", "type check daal do", "type check karo", "use karne se pehle type dekho"]},"labels": {"state": "स्थिति", "level": "स्तर", "domain": "क्षेत्र",
5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "suite"]},"domains": ["codice", "test", "documentazione"],"frames": {"mutable-default": ["default mutabile", "lista di default", "default condiviso", "valore predefinito modificabile"],"magic-literal": ["numero magico", "costante senza nome", "numero fisso", "nomina questo numero"],"guard-clause": ["clausola di guardia", "ritorno anticipato", "if annidato", "appiattisci la condizione"],"dead-import": ["import inutilizzato", "import non usato", "import morto"],"loop-comprehension": ["list comprehension", "riscrivi il ciclo", "ciclo for in comprehension"],"concat-fstring": ["f stringa", "concatenazione di stringhe", "formatta la stringa", "somma di stringhe"],"add-assertion": ["asserisci il tipo", "aggiungi una guardia", "controlla l argomento", "assert difensivo"]},"labels": {"state": "Stato", "level": "Livello", "domain": "Dominio",5 unmodified lines67891011121314151617185 unmodified lines"test": ["test", "suite"]},"domains": ["codice", "test", "documentazione"],"frames": {"mutable-default": ["default mutabile", "lista di default", "default condiviso", "valore predefinito modificabile", "lista passata come default", "default condiviso tra le chiamate", "la lista di default viene condivisa", "effetto collaterale del default"],"magic-literal": ["numero magico", "costante senza nome", "numero fisso", "nomina questo numero", "stesso numero ripetuto", "numero scritto a mano", "numero senza nome", "costante magica"],"guard-clause": ["clausola di guardia", "ritorno anticipato", "if annidato", "appiattisci la condizione", "troppo annidato", "if uno dentro l altro", "corpo dentro un solo if", "annidamento profondo", "if dentro if", "la condizione copre tutto il corpo", "difficile da leggere perche annidato"],"dead-import": ["import inutilizzato", "import non usato", "import morto", "import che non serve", "import mai usato", "import inutile", "import in cima al file", "import superfluo", "import che il linter segnala"],"loop-comprehension": ["list comprehension", "riscrivi il ciclo", "ciclo for in comprehension", "comprensione di lista", "con una comprehension", "comprensione al posto del for", "ciclo sostituito da comprehension", "ciclo che costruisce una lista", "for che fa solo append"],"concat-fstring": ["f stringa", "concatenazione di stringhe", "formatta la stringa", "somma di stringhe", "f string", "unire stringhe con plus", "stringa formattata", "interpolazione"],"add-assertion": ["asserisci il tipo", "aggiungi una guardia", "controlla l argomento", "assert difensivo", "check del tipo", "assert isinstance", "valida il tipo all ingresso", "controllo difensivo sul tipo", "proteggi il tipo dell argomento", "verifica il tipo prima di usarlo"]},"labels": {"state": "Stato", "level": "Livello", "domain": "Dominio",
5 unmodified lines67891011121314151617185 unmodified lines"test": ["测试", "用例"]},"domains": ["代码", "测试", "文档"],"frames": {"mutable-default": ["可变默认值", "默认列表", "共享默认值"],"magic-literal": ["魔法数字", "无名常量", "硬编码数字", "给这个数字命名"],"guard-clause": ["守卫子句", "提前返回", "嵌套 if", "拉平条件"],"dead-import": ["未使用的导入", "无用导入", "导入没用到"],"loop-comprehension": ["列表推导式", "重写循环", "循环改推导式"],"concat-fstring": ["f 字符串", "字符串拼接", "格式化字符串"],"add-assertion": ["断言类型", "加一个守卫", "检查参数"]},"labels": {"state": "状态", "level": "层级", "domain": "领域",5 unmodified lines67891011121314151617185 unmodified lines"test": ["测试", "用例"]},"domains": ["代码", "测试", "文档"],"frames": {"mutable-default": ["可变默认值", "默认列表", "共享默认值", "默认参数", "默认值是列表", "默认值共享", "默认值被共用", "列表被共用"],"magic-literal": ["魔法数字", "无名常量", "硬编码数字", "给这个数字命名", "裸数字", "同一个数字", "没有名字的常量", "数字写了三遍"],"guard-clause": ["守卫子句", "提前返回", "嵌套 if", "拉平条件", "if 嵌套太深", "嵌套太深", "一个 if 包住全部", "拉平嵌套", "if 里面还有 if", "条件包住了整个函数体", "嵌套太多读不动"],"dead-import": ["未使用的导入", "无用导入", "导入没用到", "没用的导入", "多余的导入", "导入了但没用到", "静态检查指出导入"],"loop-comprehension": ["列表推导式", "重写循环", "循环改推导式", "用推导式", "改成推导式", "循环换成推导式", "循环在构造列表", "循环只是在追加"],"concat-fstring": ["f 字符串", "字符串拼接", "格式化字符串", "用加号拼字符串", "字符串格式化"],"add-assertion": ["断言类型", "加一个守卫", "检查参数", "类型检查", "加断言", "参数类型断言", "使用前先检查类型"]},"labels": {"state": "状态", "level": "层级", "domain": "领域",
13 unmodified lines14151617181928 unmodified lines4849505152535455564 unmodified lines616263646566676869707113 unmodified linesSTOPWORDS = {"this", "that", "with", "into", "from", "before", "after", "please","could", "would", "should", "not", "and", "for", "the", "are"}IR_KEYS = ("frame", "anchor", "lang", "score", "candidates")28 unmodified linesdef rank(text: str, lang: str, frames: Dict[str, List[str]]) -> List[Tuple[str, float]]:"""Score every frame against the request, using the vocabulary of its variety."""data = lexicon.load(lang)folded = lexicon.fold(text, lang)scored: List[Tuple[str, float]] = []for frame, phrases in frames.items():best = 0.04 unmodified linesif needle in folded:weight = len(needle.split()) / max(1, len(folded.split()))best = max(best, 0.55 + 0.45 * min(1.0, weight * 2))else:tokens = [t for t in needle.split() if len(t) > 1]hits = sum(1 for t in tokens if t in folded)if tokens and hits:best = max(best, 0.45 * hits / len(tokens))if best > 0.0:scored.append((frame, best))scored.sort(key=lambda pair: (-pair[1], pair[0]))13 unmodified lines141516171819202122232428 unmodified lines5354555657585960616263646566674 unmodified lines727374757677787980818283848586878813 unmodified linesSTOPWORDS = {"this", "that", "with", "into", "from", "before", "after", "please","could", "would", "should", "not", "and", "for", "the", "are"}#: Code tokens a developer types in any variety: they survive code switching, so a#: frame may be named by them alone inside Arabic, Hindi or Chinese prose.TECH_TOKENS = {"assert", "assertion", "comprehension", "default", "f", "guard","import", "isinstance", "list", "loop", "nesting", "number", "string"}IR_KEYS = ("frame", "anchor", "lang", "score", "candidates")28 unmodified linesdef rank(text: str, lang: str, frames: Dict[str, List[str]]) -> List[Tuple[str, float]]:"""Score every frame against the request, using the vocabulary of its variety.Two signals are combined. A phrase that appears whole is a direct hit. Otherwise thecontent words of the phrase are counted: coverage over them, with a boost when thematched words are code tokens, because those survive code switching."""data = lexicon.load(lang)folded = lexicon.fold(text, lang)words = set(folded.split())scored: List[Tuple[str, float]] = []for frame, phrases in frames.items():best = 0.04 unmodified linesif needle in folded:weight = len(needle.split()) / max(1, len(folded.split()))best = max(best, 0.55 + 0.45 * min(1.0, weight * 2))continuetokens = [t for t in needle.split() if len(t) > 1 and t not in STOPWORDS]if not tokens:continuehits = [t for t in tokens if t in words or t in folded]if not hits:continuebase = 0.45 * len(hits) / len(tokens)tech = sum(1 for t in hits if t in TECH_TOKENS)partial = min(0.60, base + 0.10 * tech + 0.05 * (len(hits) - 1))best = max(best, partial)if best > 0.0:scored.append((frame, best))scored.sort(key=lambda pair: (-pair[1], pair[0]))
1234567891011121314151617181920212223242526272829303132333435363738394041426 unmodified lines4950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001016 unmodified lines108109110111112113114115116117118119120{"all": {"by_lang": {"ar": {"n": 1806,"top1": 1.0},"en": {"n": 1964,"top1": 1.0},"es": {"n": 1782,"top1": 1.0},"hi": {"n": 1717,"top1": 1.0},"it": {"n": 1912,"top1": 1.0},"zh": {"n": 1421,"top1": 1.0}},"by_level": {"L1": {"n": 4133,"top1": 1.0},"L2": {"n": 4166,"top1": 1.0},"L3": {"n": 1951,"top1": 1.0},"L4": {6 unmodified lines}},"confusion_top": [],"correct": 10602,"refusal": 1.0,"refused_correct": 352,"refused_expected": 352,"top1": 1.0,"total": 10602,"understood": 10250,"worst_variety_gap": 0.0},"eval": {"by_lang": {"ar": {"n": 429,"top1": 1.0},"en": {"n": 535,"top1": 1.0},"es": {"n": 435,"top1": 1.0},"hi": {"n": 440,"top1": 1.0},"it": {"n": 521,"top1": 1.0},"zh": {"n": 310,"top1": 1.0}},"by_level": {"L1": {"n": 1051,"top1": 1.0},"L2": {"n": 1018,"top1": 1.0},"L3": {"n": 503,"top1": 1.0},"L4": {6 unmodified lines}},"confusion_top": [],"correct": 2670,"refusal": 1.0,"refused_correct": 98,"refused_expected": 98,"top1": 1.0,"total": 2670,"understood": 2572,"worst_variety_gap": 0.0}}123456789101112131415161718192021222324252627282930313233343536373839404142436 unmodified lines50515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051066 unmodified lines113114115116117118119120121122123124125126127128{"all": {"answered": 21191,"by_lang": {"ar": {"n": 3482,"top1": 1.0},"en": {"n": 3860,"top1": 1.0},"es": {"n": 3572,"top1": 1.0},"hi": {"n": 3416,"top1": 1.0},"it": {"n": 4016,"top1": 1.0},"zh": {"n": 3197,"top1": 1.0}},"by_level": {"L1": {"n": 9600,"top1": 1.0},"L2": {"n": 9641,"top1": 1.0},"L3": {"n": 1950,"top1": 1.0},"L4": {6 unmodified lines}},"confusion_top": [],"correct": 21543,"correct_in_scope": 21191,"precision": 1.0,"recall": 1.0,"refusal": 1.0,"refused_correct": 352,"refused_expected": 352,"top1": 1.0,"total": 21543,"understood": 21191,"worst_variety_gap": 0.0},"eval": {"answered": 5311,"by_lang": {"ar": {"n": 841,"top1": 1.0},"en": {"n": 1015,"top1": 1.0},"es": {"n": 877,"top1": 1.0},"hi": {"n": 829,"top1": 1.0},"it": {"n": 1081,"top1": 1.0},"zh": {"n": 766,"top1": 1.0}},"by_level": {"L1": {"n": 2424,"top1": 1.0},"L2": {"n": 2383,"top1": 1.0},"L3": {"n": 504,"top1": 1.0},"L4": {6 unmodified lines}},"confusion_top": [],"correct": 5409,"correct_in_scope": 5311,"precision": 1.0,"recall": 1.0,"refusal": 1.0,"refused_correct": 98,"refused_expected": 98,"top1": 1.0,"total": 5409,"understood": 5311,"worst_variety_gap": 0.0}}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111{ "all": { "answered": 0, "by_lang": {}, "by_level": {}, "confusion_top": [], "correct": 0, "correct_in_scope": 0, "precision": 0.0, "recall": 0.0, "refusal": 0.0, "refused_correct": 0, "refused_expected": 0, "top1": 0.0, "total": 0, "understood": 0, "worst_variety_gap": 0.0 }, "eval": { "answered": 66, "by_lang": { "ar": { "n": 25, "top1": 0.72 }, "en": { "n": 25, "top1": 0.68 }, "es": { "n": 25, "top1": 0.72 }, "hi": { "n": 25, "top1": 0.76 }, "it": { "n": 25, "top1": 0.8 }, "zh": { "n": 25, "top1": 0.64 } }, "by_level": { "H1": { "n": 72, "top1": 0.5139 }, "H2": { "n": 18, "top1": 1.0 }, "H3": { "n": 24, "top1": 1.0 }, "H4": { "n": 18, "top1": 0.8333 }, "H5": { "n": 18, "top1": 0.7778 } }, "confusion_top": [ [ "guard-clause->REFUSED", 11 ], [ "dead-import->REFUSED", 7 ], [ "magic-literal->REFUSED", 6 ], [ "concat-fstring->REFUSED", 6 ], [ "add-assertion->REFUSED", 6 ], [ "mutable-default->REFUSED", 3 ], [ "loop-comprehension->REFUSED", 3 ] ], "correct": 108, "correct_in_scope": 66, "precision": 1.0, "recall": 0.6111, "refusal": 1.0, "refused_correct": 42, "refused_expected": 42, "top1": 0.72, "total": 150, "understood": 66, "worst_variety_gap": 0.16 }}15 unmodified lines16171819202122232425267 unmodified lines3435363738394016 unmodified lines575859606162631 unmodified line65666768697015 unmodified linesdef load_rows(path: str) -> List[Dict]:rows = []with open(path, "r", encoding="utf-8") as handle:for line in handle:if line.strip():rows.append(json.loads(line))return rows7 unmodified linesby_lang_frames[lang] = dict(merged)stats = {"total": 0, "understood": 0, "correct": 0, "refused_expected": 0,"refused_correct": 0, "by_lang": {}, "by_level": {}}per_lang = defaultdict(lambda: {"n": 0, "correct": 0})per_level = defaultdict(lambda: {"n": 0, "correct": 0})confusion = defaultdict(int)16 unmodified linescontinueif got:stats["understood"] += 1if got == expected:stats["correct"] += 1per_lang[lang]["correct"] += 1per_level[row["level"]]["correct"] += 11 unmodified lineconfusion["%s->%s" % (expected, got or "REFUSED")] += 1stats["top1"] = round(stats["correct"] / stats["total"], 4) if stats["total"] else 0.0stats["refusal"] = (round(stats["refused_correct"] / stats["refused_expected"], 4)if stats["refused_expected"] else 0.0)for lang in sorted(per_lang):15 unmodified lines161718192021222324252627287 unmodified lines363738394041424316 unmodified lines6061626364656667681 unmodified line7071727374757677787915 unmodified linesdef load_rows(path: str) -> List[Dict]:"""Accept one path or several, separated by commas."""rows: List[Dict] = []for one in [p.strip() for p in str(path).split(",") if p.strip()]:with open(one, "r", encoding="utf-8") as handle:for line in handle:if line.strip():rows.append(json.loads(line))return rows7 unmodified linesby_lang_frames[lang] = dict(merged)stats = {"total": 0, "understood": 0, "correct": 0, "refused_expected": 0,"refused_correct": 0, "answered": 0, "correct_in_scope": 0,"by_lang": {}, "by_level": {}}per_lang = defaultdict(lambda: {"n": 0, "correct": 0})per_level = defaultdict(lambda: {"n": 0, "correct": 0})confusion = defaultdict(int)16 unmodified linescontinueif got:stats["understood"] += 1stats["answered"] += 1if got == expected:stats["correct_in_scope"] += 1stats["correct"] += 1per_lang[lang]["correct"] += 1per_level[row["level"]]["correct"] += 11 unmodified lineconfusion["%s->%s" % (expected, got or "REFUSED")] += 1stats["top1"] = round(stats["correct"] / stats["total"], 4) if stats["total"] else 0.0in_scope = stats["total"] - stats["refused_expected"]stats["recall"] = round(stats["correct_in_scope"] / in_scope, 4) if in_scope else 0.0stats["precision"] = (round(stats["correct_in_scope"] / stats["answered"], 4)if stats["answered"] else 0.0)stats["refusal"] = (round(stats["refused_correct"] / stats["refused_expected"], 4)if stats["refused_expected"] else 0.0)for lang in sorted(per_lang):
12 unmodified lines1314151617181944 unmodified lines646566676869707114 unmodified lines8687888990919212 unmodified linesRESULTS_DIR = os.path.join(ROOT, "results")COVERAGE = os.path.join(RESULTS_DIR, "coverage.json")TOP1_FLOOR = 0.85REFUSAL_FLOOR = 0.90CONTRASTIVE_FLOOR = 0.70REGRESSION_LIMIT = 0.0244 unmodified linesif os.path.isfile(COVERAGE):with open(COVERAGE, "r", encoding="utf-8") as handle:stats = json.load(handle)["eval"]ok &= gate("coverage_floor", stats["top1"] >= TOP1_FLOOR,"eval top1=%.4f floor=%.2f" % (stats["top1"], TOP1_FLOOR))ok &= gate("refusal_floor", stats["refusal"] >= REFUSAL_FLOOR,"eval refusal=%.4f floor=%.2f" % (stats["refusal"], REFUSAL_FLOOR))contrastive = stats.get("by_level", {}).get("L3", {}).get("top1", 0.0)14 unmodified linesjson.dump({"top1": stats["top1"]}, handle)ok &= gate("catalog_regress", True, "baseline written")else:ok &= gate("coverage_floor", False, "no results/coverage.json")ok &= gate("seed_project",_run([sys.executable, os.path.join(tools, "make_seed_project.py"), "--check"]) == 0)12 unmodified lines1314151617181920212223242526272844 unmodified lines737475767778798014 unmodified lines959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812912 unmodified linesRESULTS_DIR = os.path.join(ROOT, "results")COVERAGE = os.path.join(RESULTS_DIR, "coverage.json")HELDOUT = os.path.join(RESULTS_DIR, "heldout.json")CORPUS_DIR = os.path.join(ROOT, "corpus")#: Splits never generated from the lexicon. SPECIFICATION.md 11.HELDOUT_SPLITS = ("heldout_model_authored.jsonl", "heldout_variants.jsonl")COMPOSED_FLOOR = 0.999HELDOUT_TOP1_FLOOR = 0.60HELDOUT_RECALL_FLOOR = 0.60HELDOUT_PRECISION_FLOOR = 0.95HELDOUT_REFUSAL_FLOOR = 0.95HELDOUT_SPREAD_LIMIT = 0.20REFUSAL_FLOOR = 0.90CONTRASTIVE_FLOOR = 0.70REGRESSION_LIMIT = 0.0244 unmodified linesif os.path.isfile(COVERAGE):with open(COVERAGE, "r", encoding="utf-8") as handle:stats = json.load(handle)["eval"]ok &= gate("generator_consistency", stats["top1"] >= COMPOSED_FLOOR,"composed eval top1=%.4f floor=%.3f" % (stats["top1"], COMPOSED_FLOOR))ok &= gate("refusal_floor", stats["refusal"] >= REFUSAL_FLOOR,"eval refusal=%.4f floor=%.2f" % (stats["refusal"], REFUSAL_FLOOR))contrastive = stats.get("by_level", {}).get("L3", {}).get("top1", 0.0)14 unmodified linesjson.dump({"top1": stats["top1"]}, handle)ok &= gate("catalog_regress", True, "baseline written")else:ok &= gate("generator_consistency", False, "no results/coverage.json")# The held-out splits are written, not generated. These are the numbers the card# leads with; the composed numbers above only prove generator and router agree.splits = ",".join(os.path.join(CORPUS_DIR, name) for name in HELDOUT_SPLITSif os.path.isfile(os.path.join(CORPUS_DIR, name)))ok &= gate("heldout_present", bool(splits), splits.replace(ROOT + os.sep, ""))if splits:ok &= gate("heldout_measure",_run([sys.executable, os.path.join(tools, "measure_coverage.py"),"--corpus", splits, "--out", HELDOUT]) == 0)if os.path.isfile(HELDOUT):with open(HELDOUT, "r", encoding="utf-8") as handle:held = json.load(handle)["eval"]ok &= gate("heldout_top1_floor", held["top1"] >= HELDOUT_TOP1_FLOOR,"heldout top1=%.4f floor=%.2f" % (held["top1"], HELDOUT_TOP1_FLOOR))ok &= gate("heldout_recall_floor", held.get("recall", 0.0) >= HELDOUT_RECALL_FLOOR,"heldout recall=%.4f floor=%.2f"% (held.get("recall", 0.0), HELDOUT_RECALL_FLOOR))ok &= gate("heldout_precision_floor",held.get("precision", 0.0) >= HELDOUT_PRECISION_FLOOR,"heldout precision=%.4f floor=%.2f"% (held.get("precision", 0.0), HELDOUT_PRECISION_FLOOR))ok &= gate("heldout_refusal_floor", held["refusal"] >= HELDOUT_REFUSAL_FLOOR,"heldout refusal=%.4f floor=%.2f" % (held["refusal"], HELDOUT_REFUSAL_FLOOR))ok &= gate("heldout_spread", held["worst_variety_gap"] <= HELDOUT_SPREAD_LIMIT,"gap=%.4f limit=%.2f" % (held["worst_variety_gap"], HELDOUT_SPREAD_LIMIT))else:ok &= gate("heldout_top1_floor", False, "no held-out corpus")ok &= gate("seed_project",_run([sys.executable, os.path.join(tools, "make_seed_project.py"), "--check"]) == 0)
README.md+33-14
SPECIFICATION.md+2-1
corpus/corpus.jsonl
corpus/heldout_model_authored.jsonlAdded+60
corpus/heldout_variants.jsonlAdded+90
doc/IMPROVEMENT_PLAN.mdAdded+202
lexicon/ar.json+36-7
lexicon/en.json+7-7
lexicon/es.json+7-7
lexicon/hi.json+7-7
lexicon/it.json+7-7
lexicon/zh.json+7-7
lingologos_thinkingpython/intent.py+23-6
results/coverage.json+32-24
results/heldout.jsonAdded+111
tools/measure_coverage.py+15-6
tools/run_gates.py+41-4