Repository navigation
docs(examples): example 26 must count triage_questions()'s three yes/no fields - #978
Merged
NandhaKishorM merged 1 commit intoOct 7, 2026
Conversation
…rimitives The example opened with "five questions ... a multi-way choice, two yes/no probabilities, and an ordinal score". laya.presets.triage_questions() ships three noul fields -- is_urgent, refund_requested, churn_risk -- plus the one choice and the one score, so the banner's own arithmetic was 1 + 2 + 1 = 4 against its stated "five questions". Fix the count to "three" and add a gate that reads the banner's stated numbers and the schema's actual type mix and refuses to pass when they disagree.
This was referenced Oct 6, 2026
Owner
|
Merged in 0.3.29.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
examples/26_presets_triage.pyopens its banner with a primitive count that the schema it namesdoes not return. The banner says:
But
laya/presets.py::triage_questions()ships threenoulfields --is_urgent,refund_requested,churn_risk-- plus onechoice(intent) and onescore(
frustration). The example's own print block already prints all three of them(
examples/26_presets_triage.py:40-45), so the banner disagreed with the page underneath it.The banner's own arithmetic is
1 + 2 + 1 = 4against its stated "five questions".One word changes: "two" -> "three". A gate is added to
tests/test_confidence.pyso thebanner's stated counts stay pinned to what
triage_questions()returns.Why
The count is not a stylistic thing to get wrong:
only 3 categories the prose lists (choice, "two yes/no", score) -- the "one extra noul"
is silently dropped by the prose. That is the class of drift this repo already gates against
in example pages fix(examples): example 24 must state the resident cap Router defaults to #844, fix(examples): example 28 must compute the conclusions it prints #850, docs(examples): example 40 must not call answer_confidence calibrated #972, docs(examples): example 18 must not call the shipped answer_confidence calibrated #973, docs(examples): example 30 must call score confidence 1 - H/log(k), not the entropy #974, docs(examples): example 21 must read its cost claim off the measurement it takes #975.
tests/test_confidence.pyalready runs in CI at.github/workflows/ci.yml:250, so the newsection is free coverage -- the same file gates the example 28 banner (page-28) and the
example 40 / 18 / 30 calibration wording (page-40, page-18, page-30).
Gate design
tests/test_confidence.pygains a fifth gate section (# ----- example 26's banner must count the primitives triage_questions() returns). Three rules:test_triage_preset_is_one_choice_three_noul_one_score-- the anchor. Callslaya.presets.triage_questions()directly (no weights) and asserts the returned dictis 5 keys with the exact type mix
{choice:1, noul:3, score:1}. If the schema ever moves,this breaks first and the banner test below follows -- the drift is loud, not silent.
test_example_26_banner_counts_match_the_preset-- reads the shipped example source, extractseach stated number with a
one|two|three|four|five|sixregex, and requires every one tomatch the schema. Also asserts the arithmetic inside the same sentence adds up:
choice + noul + score == total.test_example_26_drops_the_wrong_yes_no_count-- the ban. A regex\btwo\s+yes/no\s+probabilitis verified to fire on an inline
OLD_BANNER_26literal of the pre-fix wording and to notfire on the shipped example. The same positive regexes are asserted to read
OLD_BANNER_26as the pre-fix "two", so the positive rule was genuinely falsifiable -- no ban is a guess.
The gate is pure-Python: no weights, no device, no network.
Verification
Revert-the-fix witness (change only
threeback totwoon disk, re-run):Mutation harness at
laya-bench/mutate_example26_count.py, seven variants, each byte-restored,run with
PYTHONDONTWRITEBYTECODE=1:Mutants m6 and m7 change
laya/presets.pyitself, not just the prose. The schema anchortest_triage_preset_is_one_choice_three_noul_one_scorefails on m6 and the banner-countpositive rule fails on both, so the gate reads the actual dict, not a table.
Relationship to prior work
Same class as the example-page gates this quarter (#844, #850, #972, #973, #974, #975) and the
page-28 gate already living in this same file: the codebase asserts a fact the code does not
verify. This PR is the primitive-count version.
Nothing about the schema, the runtime, or the model changes. The only code edit is one word in
one banner.
Checklist
main(a4a8921 release: 0.3.28).python tests/test_confidence.py-- 137/0 green.ruff check laya/ --select=E9,F63,F7,F82,F401,F811 --line-length=120clean.python -m compileall -q laya/ tests/clean.tests/test_hooks_api.pyis untouched.