Skip to content

Ezri's violin skill: a lesson gives it to her, exercises it each round and grades what she plays by ear (S2b, L6a) - #2032

Merged
seangalliher merged 5 commits into
mainfrom
feat/ad-1378-s2b-l6a-20261202
Dec 2, 2026
Merged

seangalliher merged 5 commits into
mainfrom
feat/ad-1378-s2b-l6a-20261202

Conversation

@seangalliher

@seangalliher seangalliher commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Refs #1935

What changes

When the Captain teaches Ezri a phrase by ear, she now holds a skill for it, each completed round exercises it, and a lesson that ends with three right by-ear attempts in a row grades her and moves her up one level. It rides on S2a's lesson service and is off wherever lessons are off (the lesson wiring is where all of it is registered), so merging it changes nothing for a vessel that has not enabled lessons.

  • The skill. violin_by_ear ("Violin, by ear") is a registered acquired skill with a 90-day decay rate. The first lesson she has gives it to her at FOLLOW by mentoring; a later lesson never gives it again, because acquire_skill is an upsert that resets a record's level and its exercises (it runs only when she holds no record, a suspended one included).
  • The qualification test (ViolinByEarQualification, tier 2, threshold 1.0). It grades one thing: the record of the lesson that has just closed. An attempt counts when it is her by-ear attempt of a round (never the retry, never the model's, never the retention take), measured against that lesson's phrase beat, with a take, no note errors (wrong, missed or extra notes), a median onset error within 60 ms and a largest within 120 ms. Three such attempts in consecutive rounds pass; the score is the longest run over three. It grades only a closed lesson of this vessel's current crew, for her, that a restart did not end, and whose label gives the phrase key twinkle-phrase-1. Registering a test also enrols it in the weekly drift run and in /qualify, which call every registered test with the runtime and no lesson: for those the test answers an inconclusive result with a fixed message, so no baseline is captured and drift statistics leave it out (BF-711).
  • The chain (ViolinSkillChain, skills/violin/skill.py). opened gives her the skill; round_completed records one exercise; closed runs the test, asks the existing qualification-skill bridge once (it moves her at most one level) and answers a ten-key summary. It reads the lesson record once, into one strict-JSON snapshot; a failure at any step is logged and never raises, and the answer names a fixed code (not_run, not_graded, skill_not_updated), never an exception's text.
  • The seam. LessonService(..., skills=None) takes the three hooks (SkillHooks); None means none runs, and the service then writes byte for byte what it wrote before. They run at the one site that writes a move, the end of _LessonBeats._commit, after the record, the Ship's Records entry, memory, the lesson_changed event (when the move announces) and the take marks, under the service's own lock: opened for the move that opens a lesson, round_completed for each round a move completes, closed for the move that closes it. Each hook runs on its own, on its own deep copy of the record: one that fails is one ERROR naming the lesson and the hook, and neither undoes the move nor keeps the next hook from running (a close the Captain's End held back until her retry completed is one move: its exercise comes first and the close is still graded). The close's answer is written into the record as summary.qualification by one more write of the closed record, with no event. No method is added to LessonService or to the beats class.
  • The wiring. _wire_lessons registers the skill, the test and the test's mapping to the skill on every start (each is an upsert), builds the chain when the runtime has a skill service (without the harness or the bridge a close is simply ungraded), and gives it to the service. The runtime gains two read-only properties, qualification_harness and qual_skill_bridge. Making qualification_harness public also hands the two holodeck wirings (_wire_holodeck_team_simulations, _wire_holodeck_scenarios) the harness they already read with getattr(runtime, "qualification_harness", None): both of their flags are off on the vessel (the Architect read them off its config/system.yaml), and a vessel that turns them on would now get a harness where it got None.
  • Contract. prompts/ad-1378-s2-the-lesson-loop.md is now revision 2u: the A140 and A141 rows record the Architect's cite checks of this slice and of the next (the proven skill as nature across --clean-slate), and its text was claims-checked by a second model.

What the Captain should know

  • The lesson's label must be "Twinkle, phrase 1" (any capitalisation or punctuation that gives the key twinkle-phrase-1) for a lesson to qualify; he types the label (the Lessons tab's start form leaves it empty). A hint beside the field is on the follow-up list.
  • At most one level per lesson, through the bridge that already guards every qualification (a pass raises the level one step; a lesson that does not pass moves nothing). The result is in the lesson's record as summary.qualification (its level before and after, the three take ids and a fixed error code when something failed) and in the harness's history; the HXI shows neither yet.
  • Not in this PR: keeping her level across --clean-slate. This PR gives her the skill and a way to earn levels; the next one (L6b) makes the proven level part of what a successor is born with. The Architect found that no public reader says which model an agent's runs used, so L6b commissions every successor at FOLLOW from a ledger and lets her first passed by-ear lesson restore the proven level. Nothing here depends on it.

One new test file, tests/test_ad1378_s2b_skill.py (196 tests, real components over tmp_path); no existing test, fixture or generated baseline changes.

What this does not claim

  • No lesson has run on the vessel: every test uses stand-in workers and real components over temporary directories; the live checks (S0's, S1's, a first lesson) wait for the Captain's go, as for S2a.
  • A hook that raises is logged, never retried. One exception is accepted and stated once in the code: a move whose own commit task is cancelled (a teardown cancels it; a caller's cancellation never does) stops at the await it is in, so its later hooks do not run and nothing retries them; the record, her skill and the harness are each as that point left them.
  • The weekly drift run still runs every registered test: the new test answers it inconclusive, and the drift detector's own handling of that is BF-711's, not changed here.

Review and proof

Diff Reviewer rounds on gpt-6.1-sol (pinned on every call and checked against the session log), my own hand mutants of each milestone, and Architect decisions at the round-three brakes, recorded on #1935. Each milestone was committed only on a READY verdict with zero Size findings.

Slice Rounds Size findings Hand mutants (killed) Exit run
Contract revisions 2t and 2u (claims checks of the new text) 5 and 3 0 claims checks of every sentence
L6a1 skill, test, adapter, runtime, registration 5 (two Architect round-three decisions) 0 77 (77) 1,648
L6a2 the seam, the hook site, the wiring 2 (a fresh reviewer, then a delta review of the repair) 0 37 (33) on the first candidate, 35 (34) on the repaired one 1,516

The two Architect decisions on L6a1: after three rounds of findings with one cause (the adapter read one record at six independent sites), closed reads its record once into a snapshot and everything after reads the snapshot; and the snapshot is strict JSON (allow_nan=False, as the Ship's Records entry is), with the strict round trip's coercions accepted and error results that the harness stores without lineage exempt from "the answer equals what was stored".

  • Gate: the canonical wrapper (scripts/run_test_gate.py) on the committed tree b6bde2ae (the merge of main at 374c7d61 included; receipt exit 0 with the tree unchanged): preflight (config reference, profiles and facade, AD ledger, seam contracts, architecture fitness 93 / 0 / 30 / 13, store registry, compileall), then 59,800 passed, 174 skipped, 0 failed (59,974 collected, 59,974 run) in 53 min 8 s on 12 workers, none lost; temp volume C:. The gate waited 20 minutes for a quiet moment because another lane's tests were running; no test of mine ran while it did.
  • CI: all six checks passed on head b6bde2ae (run 46968541276, 2026-12-02): python-tests-shard (1) 12 min 29 s, (2) 15 min 31 s, (3) 12 min 8 s, ui-tests 5 min 30 s, desktop-tests 17 s, discord-adapter-tests 1 min 4 s.
  • Follow-ups: the findings recorded and not repaired, each with its reach, are in one issue: AD-1378 S2b follow-ups: findings recorded and not repaired in the review rounds (the violin skill, its by-ear qualification, the lesson hooks and the proven skill as nature) #2031 (it also takes the findings of L6b when that lands).

seangalliher and others added 5 commits December 2, 2026 09:19
…e L6a slice plan (AD-1378 S2)

The Architect's cite check of section 13 against S2a as merged (origin/main 6b30f77) found that the skill machinery could not be built as written. It is recorded as A140 (a to n), and the passages it touches are corrected in place or extended: section 13's first five bullets and L6b's writer bullet, D21 (4), sections 14, 15, 16, 17, 18 (a step 8), 24 (item 13), 26 and 27 (a "Revision 2t" subsection).

- The qualifying phrase key is twinkle-phrase-1 (the label "Twinkle, phrase 1"), not twinkle-1.
- The test grades only the record a close hands it (LessonAtClose), never a search, and answers inconclusive for any other caller, because the weekly drift run and /qualify run every registered test.
- The chain runs at one site, the end of _LessonBeats._commit, through a SkillHooks seam (opened, round_completed, closed) and a skills= keyword on LessonService; neither class gets a method, both being at the srp-size limit. A _commit task that is itself cancelled stops at the await it is in: its hooks run at most once and nothing retries them.
- acquire_skill is called only when she holds no record, because it resets one.
- summary.qualification gains an error code and is written by a second rewrite of the closed record.
- L6b's one writer is the closed hook. L6a is two milestones: L6a1 (no lesson.py edit) and L6a2 (the hooks). Mutation rows Z54 to Z70 are new.

The claims check of this revision (four rounds, a warm reviewer on gpt-6.1-sol, and the Architect's decision at the round-three brake: continue, Design: holds) found nine wordings of its own text too wide or too narrow and all were corrected; its last round was READY with no size finding. Text only.

Refs #1935

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…L6b slice plan (AD-1378 S2)

The Architect's cite check of section 13's L6b bullets (the proven skill as nature across a reset) against S2a as merged (origin/main 6b30f77) changed its design in five places. It is recorded as A141 (a to j), and the passages it touches are corrected in place: section 13's L6b bullets, D23, P19, section 1 (item 6), A140 (f), (j) and (l), sections 14, 15, 16, 17, 24 (items 14 to 16), 26 and 27 (a "Revision 2u" subsection).

- No public reader says which model an agent's runs used, so every ledger row's model is null, every successor is commissioned at FOLLOW (by commission_from_nature, in _wire_lessons), and her first complete pass restores the proven level through one update_proficiency, because the bridge raises a level by one at most. Nothing holds her level at boot in this slice; a model reader and a same-model branch are a follow-up.
- The re-qualification state is worked out from the ledger at that pass and is not held in the service; start_check.nature is dropped (the lesson record is published whole in her Ship's Records entry), so L6b edits no line of lesson.py.
- The ledger is an append-only JSONL file written through asyncio.to_thread under a threading.Lock; a torn tail line is ended before the next append.
- --clean-slate clears skill-nature/ through one tuple, _NATURE_DIRS, that every nature site iterates (procedures first, the marker first).
- Nature comes only from the ledger, never from qualification_results.db or a lesson record.
- L6b is two milestones: L6b1 (the ledger, the reset, the census) and L6b2 (the writer, the reader, the wiring). Z44 is redefined and Z71 to Z83 are new.

The claims check of this revision (three rounds, a warm reviewer on gpt-6.1-sol) found four wordings of its own text too wide or too narrow (A140 (i) and (j) did not yet say what the restoration does to error and level_after; the harness database is qualification_results.db; one twin listed causes instead of pointing to A140 (i)) and all were corrected; its last round was READY with no size finding. Text only.

Refs #1935

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…apter (AD-1378 S2)

The first half of L6a (contract A140): everything the lesson loop will call at its three moments, built and registered, with no change to the lesson service (L6a2 wires the hooks).

- skills/violin/qualification.py: ViolinByEarQualification (a tier-2 harness test, threshold 1.0) grades only the lesson a LessonAtClose hands it, so the weekly drift run and /qualify, which hand a test another runtime, get an inconclusive result with a fixed error and capture no baseline. grade and by_ear_attempts count her by-ear attempts (rounds[i]["attempt"] only: never a retry, the model's block or the retention take) on the phrase key twinkle-phrase-1 ("Twinkle, phrase 1"), of this agent and this crew's timeline, in a lesson no restart ended: three in a row with every note right and the onsets inside 60 and 120 ms pass.
- skills/violin/skill.py: VIOLIN_BY_EAR (an acquired skill, decay 90 days) and ViolinSkillChain. opened gives her the skill at FOLLOW, by mentoring, only when she holds no record (acquire_skill resets one); round_completed records one exercise; closed reads its record once into a strict JSON snapshot, grades it through the harness and lets the bridge move her level at most one, and answers the contract's summary.qualification (name, passed, score, level_before, level_after, lesson_id, take_ids, timeline_id, at, error), with a fixed error code (not_run, not_graded, skill_not_updated) and never an exception's text. A hook never raises; a cancellation passes through every one.
- runtime.py and startup/finalize.py: qualification_harness and qual_skill_bridge as read-only properties (and _qual_skill_bridge set to None in __init__), and _wire_lessons registers the skill, the test and its mapping on every start (one INFO line; a failure is one WARNING and lessons still wire). Making qualification_harness public also hands the two holodeck wirings the harness they already read; both flags are off on the vessel.
- tests/test_ad1378_s2b_skill.py: 165 tests through the real registry, skill service, qualification store, harness and bridge.

Review: five rounds by a warm reviewer on gpt-6.1-sol (Size findings 0), and two Architect decisions at the round-three brakes (Design: holds, continue both times): closed reads its record exactly once into a snapshot, and the snapshot is strict JSON (allow_nan=False). Hand mutants: 77 of 77 killed. The findings recorded and not repaired (a registered-test dict iterated across awaits in the harness, stores that leave connections to the collector, two reads of one id in grade, the harness emitting after it saves) go to the S2b follow-up issue.

Refs #1935

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…1378 S2)

The second half of L6a (contract A140): the lesson service gives the chain that L6a1 built its three moments, and the wiring gives the service the chain.

- skills/violin/lesson.py: SkillHooks (opened, round_completed, closed) and LessonService(..., skills=None). The hooks run at the one site that writes a move, the end of _LessonBeats._commit, after the record, the Ship's Records entry, memory, lesson_changed and the take marks, under the service's own lock, through the module function _after_commit_skills: opened for the move that opens a lesson, round_completed for each round a move completes, closed for the move that closes it, whose answer is written into the closed record as summary.qualification by one more write of the record through _persist_lesson, with no event. Each hook runs on its own (_run_hook) on its own deep copy: one that raises is one ERROR naming the lesson and the hook, and neither undoes the move nor keeps the next hook from running, so a close that a retry's completion applies (one move: its exercise, then its qualification) is still graded when the exercise fails. A cancellation passes through every hook. Without skills the service writes what it wrote before, byte for byte. No method is added to LessonService or the beats class (both stay at 15; the beats class is 472 lines).
- startup/finalize.py: _wire_lessons builds ViolinSkillChain when the runtime has a skill service (the harness and the bridge, or None for a part it lacks, and the service's own timeline) and passes it as skills=.
- tests/test_ad1378_s2b_skill.py: 31 tests added (196 in the file), through the real lesson service over a real recording store, the real chain, skill service, harness and bridge: acquisition once, one exercise per completed round, the close's one advancement through the bridge, the summary written and kept through a later removal, the held-back close, the expiry close, a cancelled End, a cancelled commit task (never retried), a restart close never graded, a raising hook at each moment, a hook that changes its argument, the plain service unchanged, the wiring and the whole vessel.

Review: two rounds by a fresh reviewer on gpt-6.1-sol (Size findings 0). Round 1 found that one try around the three hooks let a failing round hook keep a held-back close from being graded; each hook now runs on its own and a test covers the combination. My hand mutants: 34 of 35 caught on the repaired candidate (the survivor, the hooks running before the take marks, changes nothing observable short of a cancellation and goes to the S2b follow-up issue).

Refs #1935

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…o the S2b L6a branch

Refs #1935

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant