--- license: mit tags: - linguistics - code - dataset - specification language: - ar - en - es - hi - it - zh pretty_name: LingoLOGOS thinking-python specification --- # LingoLOGOS thinking-python - specification This folder carries the **specification** of the thinking-python bundle: an N-agent topology and the dataset that turn free natural-language text about Python code into a verified change in a Python workspace. The mission it commits to is narrow on purpose: **maintaining an existing Python project on plain-language requests** from someone who cannot name the transformation. Authoring a project from a sentence is outside the contract, and section 1.1 says so. The specification is published first, before any code, so the contract can be reviewed and implemented independently. The normative file is [SPECIFICATION.md](SPECIFICATION.md). Where code and that file disagree, the code is wrong until the specification is amended in the same change. The implementation, the corpus, the seed project and the gates live in the folders the specification lays out in section 10; [doc/REASONS.md](doc/REASONS.md) is the reason-code registry and [doc/HOW_TO_ADD_AN_ENTRY.py](doc/HOW_TO_ADD_AN_ENTRY.py) is the executable checklist a new catalog entry has to pass. ## How to run it ``` pip install -r requirements.txt python tools/ask.py --workspace fixtures/seed_project --lang it --request "if annidato in keep" python tools/run_maintenance.py # the section 1.1 demo, replays 36 requests python tools/train_intent.py # train the classifier from the corpus, measure it python tools/run_gates.py --catalog-regress ``` ## What the document states | Section | Subject | |---|---| | 0 | Confinement: the programmer works only inside `datasets/thinkingpython/`, enforced by code | | 1-2 | The three claims the bundle publishes, the mission (maintaining an existing project on plain-language requests, not authoring one), and the vocabulary | | 3 | The 7-node topology: `intent -> locator -> planner -> executor -> {gate_checker, adversary} -> arbiter`, with only `intent` allowed to be non-deterministic | | 3.1 | Compliance with the sibling bundles: the `python tools/ask.py` contract, the throwaway workspace, `MultiInstanceOrchestrator` used read-only, exit codes, transcript re-derivation of the verdict | | 4 | An extensible catalog with an open fallback: GoF patterns, Fowler refactorings, development methodologies | | 5 | The edit-pair invariant: no source edit lands without a test that locks it | | 6 | The dataset in five layers plus an adversarial set, generated and re-derivable | | 6.4 | No off-the-shelf language model: the intent node runs on the catalog's own surface forms plus an optional small classifier trained from the corpus | | 6.5 | The six language varieties of the genesis topology: `ar, en, es, hi, it, zh`, declared and never inferred, with a language-free plan and per-variety numbers | | 7-9 | Interfaces, self-applied development methodology, reason-code registry | | 10-12 | Folder layout, acceptance criteria D0-D7, explicit prohibitions | ## Status Draft 2, normative, **with a reference implementation**. This revision carries code, data and measured numbers, and it states plainly which acceptance criteria of section 11 the implementation meets and which it does not. What runs today, as measured on 2026-12-03 by `tools/run_gates.py`: | Gate | Measured | |---|---| | `confinement` | `FAIL`, 65 python files, one file changed outside this folder (`doc/PURE_MODEL_SPEC.md`): kept, and the gate is left red | | `tests` | 67 tests, all pass | | `catalog_integrity` | 20 entries, 0 defects | | `catalog_conflicts` | 190 declared pairs, 0 missing | | `corpus_fingerprint` | `83ee11ece8b0f316`, 85626 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, over all 6 varieties | | composed spread across varieties | 0.00 | | **`heldout_top1_floor`** | **0.74**, floor 0.60 (150 written requests, 25 per variety) | | **`heldout_recall_floor`** | **0.6481**, floor 0.60 | | **`heldout_precision_floor`** | **0.9589**, floor 0.95 | | **`heldout_refusal_floor`** | **0.9762**, floor 0.95 | | **`heldout_spread`** | **0.16**, limit 0.20 | | `heldout_blind_reported` | blind slice top-1 0.3889, recall 0.2817, refusal 0.9250, gap 0.3167: measured and published, not gated | | `intent_model_reproducible` | model re-trained in memory from the corpus equals the saved `models/intent_model.json` | | `intent_model_eval` | eval precision 0.9995, refusal 1.00, spread 0.0230 at margin 8.0 | | `coverage_report` | 140 of 140 package functions entered by the suite, floor 90% | | `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 same lexicon the router scores against, so its 1.00 says the router is a faithful function of its 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.74, recall 0.6481, precision 0.9589 (one answer in twenty-four wrong), refusal 0.9762 on vague and out-of-scope requests including the harmful kind, best variety 0.84 against worst 0.68. Every cell carries a Wilson 95% interval in `results/heldout.json`, because 25 rows per variety are a sample, not a fact: for one variety the interval of recall runs from 0.39 to 0.80. The router answers in two moves. The lexicon ranking speaks first; when it abstains, the intent node asks the classifier that `tools/train_intent.py` trains from this corpus (`models/intent_model.json`: one multinomial naive Bayes per variety over word unigrams, word bigrams and character trigrams and four grams, no pre-trained model anywhere in the bundle). That second opinion fired on 13 of the 150 held-out requests and lifted recall from 0.574 to 0.648; its abstention margin, 8.0 in log score, is picked on the eval split of the corpus by a rule printed in `results/intent_model_eval.json`, never on the held-out splits. Two artifacts are published apart from the corpus because they are read apart: `corpus/adversarial.jsonl` (the minimal pairs and the near misses, 27852 rows) and `corpus/trajectories.jsonl` (the refusal trajectories, 30 rows). **The held-out set is authored by a language model, not collected from people.** That is stated in the `source` field of every row and in the name of the split. It is a proxy for free phrasing with a known bias: the typos, the truncations and the code-switching in it were written deliberately, while real users produce half-sentences, wrong symbol names and pasted tracebacks no model would generate. 0.72 is therefore an upper bound on free human phrasing, not an estimate of it. `doc/IMPROVEMENT_PLAN.md` states what each level measures and 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 revision publishes 20. The threshold is not lowered and the criterion is not reworded: the gap is the result. Twenty entries are enough to run the whole topology end to end and to show that adding an entry does not break the existing ones (`catalog_regress`), which is what D1b tests, and every one of the 20 has a matcher, a lock and an editor exercised by the suite, but a 40-entry catalog is open work. **Recall, not top-1, is the weak number.** 0.6481 recall with 0.9589 precision means the router is right on about nineteen answers in twenty and silent on roughly one in three in-scope requests: the failure 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 release that reports one without the other. **A third number, and it is the worst one.** `corpus/heldout_blind_slice.jsonl` holds 720 requests written without ever reading the lexicon or the catalog: 100 in-scope and 20 out-of-scope per variety, each frame appearing five times. On that slice the same system scores top-1 0.3889, recall 0.2817, refusal 0.9250, worst-variety gap 0.3167 (`results/heldout_blind.json`). It is reported, not gated: the floors of section 11 were fixed before it existed, and inventing a floor for it now would be a second tuning knob. Read it as the honest shape of the result: the 0.74 headline is a set whose phrasing sits closer to the lexicon than free phrasing does, and on wording that no one steered toward the vocabulary the router stays silent on three requests in four. Criteria D0, D1b, D2, D3, D4, D5, D5a, D5b, D5c, D6, D7, D8 are met as measured; D6 is the share of package functions the suite enters, 140 of 140. D1 is not met, and the confinement gate is deliberately left red on the one file changed outside this folder. ## Provenance Part of the LingoLOGOS project. The topology follows the same envelope, node and orchestrator contract as the other datasets of the project (`codex`, `codex-python`, `genesis`, `physics`, `math`, `geometry`, `struc`), which are not included here and are not modified by this bundle.