Repository navigation
Ezri learns a phrase by ear in a lesson the Captain starts, through a lesson service that binds her two tools, one audio floor, a recording store only the Captain can delete from and the Lessons tab's routes - #2026
Merged
Conversation
The S2 build contract for #1935, drafted by claude-architect and revised for the Captain's 2026-11-29 answers: hearing listens by default and he mutes it, the violin skill becomes nature once proven, lesson history is culture, and her voice and instrument share his headphones. The four-beat Suzuki lesson service over the two tools she already has, one audio floor lock, the lesson record, recordings only he can delete, and progress across sessions. L1 and L2 are new files and build beside S0 and S1. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applies the Architect's decision on the architecture-fitness failures and on four readings the first Builders took. The recording store becomes four classes in one module, so none passes the 15-method limit. A recording whose discard could not unlink it (a Windows lock) is marked and finished later and is never adopted, so a muted capture cannot become a kept recording. `commit` takes `timeline_id` as a required keyword. The retention sentence reads "the phrase" when the machine has no label, and the closing sentence no longer says nothing was recorded when a play finished after End lesson. A recording ref scrubs every path-like token, spaces and relative paths included. S0's two oversized classes are recorded as accepted debt with a removal condition. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pure, standard-library-only pieces of the Suzuki-style lesson loop. The state machine holds only the order of a round: the Captain plays and she listens, she answers the whole phrase, he plays the correction and she listens, and she answers again; a call out of turn is a refusal with a plain sentence about what comes next, and it reads no clock, mute or file. Progress turns one answer into figures and compares each lesson's round-1 attempt per crew timeline without recomputing or storing anything. The lesson record is one Markdown entry whose fenced json block is the authority, rendered idempotently and parsed back with a plain reason when it cannot be; a recording enters the record only as an id and figures, never a path. Reviewed in two rounds. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applies the Architect's decision after the first review of the recording store. The discard marker is created under its final name, with no temporary file and no rename, so an interrupted write can never leave a declined capture unmarked and adoptable. The double fault, where the capture cannot be removed and no marker can be created, is a stated limit: it is logged at ERROR, raised, and a later process adopts the capture, which the Captain sees and can delete. The lesson service reports that exception to the Captain, and finish_discard lives in the file operations class. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applies the HXI lane's amendment requests S2-A1 to S2-A10 as A11 to A20, so the lesson routes' answers and the HXI's fixtures agree. The bodies of status, the lesson snapshot, the recordings list, the lesson list, progress and the delete answer are pinned, with the error envelope S1 already uses and a muted start answered as a detail object. A repeated speech start renews its lease (the floor already does this; the routes' tests will pin it), and the speech deferral holds while any hearing capture is listening. A route-shape test reads the HXI fixtures once the HXI slice has merged. Text only: the lesson core and the floor and recording store are untouched. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The audio floor serialises the instrument and the microphone with speech: one hold at a time (a second is refused at once), a wait for the speech signal bounded by a lease of the announced length plus two seconds, thirty when the length is unknown and at most ninety, and a grant that records a speech start at any moment from the claim to the release. The recording store keeps the Captain's lessons on disk: reservations with unique ids, a WAV and a sidecar that commit together, a tombstone before any unlink, and an orphan the next start adopts as kept. A capture that was declined is never kept: when a file will not go (a Windows lock) a marker created under its final name holds the discard, so no interrupted write can leave it unmarked, and a recovery finishes the removal. If neither the file nor a marker can be handled the store logs an error and raises, and the capture stays visible to the Captain. Both modules are standard-library only. Reviewed in two rounds. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Architect's D9 decision at S0's M4b, applied as decided. A work item dispatched to an agent (AD-839) is posted into her thread as role="captain" with an agent-authored title and description, so "role == captain" is not proof that the Captain wrote a message. S0's D9 now binds a message into a take's verdict only when its metadata.source is absent or one of the HXI chat channels. S2 reads no thread of its own and the verdict stays S0's mechanism, so only the premise P1 changes (change A21); no S2 code changes. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Text only. The Architect's cite check of L3a against the merged S0 (Design: holds): section 3's exit names S0's tests and a merge of main first; record_to is optional on S0's play request and omitted when None (D-L3a-1), so run_contract stays unchanged; the decoder needs a recording field in _REPLY_FIELDS and the client checks the path against the request; the recording is the rendered stereo mix at the host's sample rate (D-L3a-2), written from rendered.audio after the device play; _pcm24_bytes takes numpy as an argument; PlayOutcome gains a frozen RecordingInfo; the SRP limit is kept; L3b uses the same omit-when-None rule for S1's worker. Rows A22 to A30. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Main now carries the S0 music host (merge 46b1b1e). One semantic conflict, in the AD-1346 file-write census, where S0's host client and S2's recording store each add one file: both entries are kept in path order, and the counts are the measured combination (files 73 + 2 = 75, System 70; unlink 71, rmtree 15, open 20, replace 26; the two sides' comments both kept). Nothing else conflicted; the checkers (config facade, profiles and reference, ledger, seam contracts, architecture fitness with srp-size 92, store registry) pass on the merged tree. L3a (the wire fields in S0's worker and client) builds on this. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An optional absolute record_to path on S0's play request (omitted from the
request when None, so S0's wire is byte-identical) makes the music host write
the rendered stereo mix, exactly as it sent it to the device (the click and the
peak cap included, the host's rate, PCM 24-bit), to <path>.part, fsync it and
os.replace it into place after a complete `played`, before the reply. The reply
gains `recording: null | {path, frames, sample_rate, channels, bytes} |
{error, detail}`; a failed write never fails the play. The worker validates
record_to (an absolute .wav path whose file name matches the recording-id
pattern) before the job starts, so an invalid one answers bad_request even
while another play holds the host. The decoder gains the recording field; the
client checks the reply's path, rate and channels against what it asked for and
treats a recording it did not ask for as a protocol violation on any reply,
refusals included. PlayOutcome gains a frozen RecordingInfo; MusicHostClient
stays at 24 methods and 469 lines. The stand-in worker gains --write-wav and
--break-write.
Review (gpt-6.1-sol): round 1 NOT READY (two P3: an unasked recording on a
refusal reply bypassed the check; the tests did not pin fullmatch over match or
validation before the busy decision), both repaired; round 2, a delta review,
READY. The six-file exit command: 697 passed. Size findings: 0.
Refs #1935.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Main now carries the S1 hearing faculty (merge 7fa2938). One semantic conflict, in the AD-1346 file-write census, where S1's hearing listener and S2's recording store each add one file: both entries are kept in path order, and the counts are the measured combination (files 74 + 2 = 76, System 69 + 2 = 71; unlink 71, rmtree 16, open 21, replace 26; the three sides' comments all kept). Nothing else conflicted (S1's `playing` property in the music host client merged cleanly with L3a's `record_to`). L3b (the wire fields in S1's worker, protocol and listener) and the revision-2f text of the contract build on this. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applies the Architect's cite check of L3b, L4 and L5 against S1's final code (rows A31 to A53 and decisions D-L3b-1, D-L3b-2, D-L4-1, D-L4-2). Text only. Three are real defects: A38 (the hook types cannot live in probos.skills.violin, because S1's boundary test forbids the hearing tool importing it, so they go in tools/lesson_port.py), A40 (compare_attempt needs HeardPhrase objects, so the tool call keeps the listen outcome and its phrases) and A41 (S1's ticket latch already discards the numbers after captured, so D7 and D20 change). The rest is cite drift and counts: config facade 314/301/13/232/233/1907, events 394/34/42, the profiles census 450/229/221/85/144, LessonService split into a facade and two helpers (srp-size stays 93), the file-write census merge numbers (done in 7a729bf) and the exit commands for L3b, L4 and L5. Two premise cites (P14, P20) follow the Architect's new line numbers. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A listen request may carry record_to, an absolute path to a new rec-<UTC time>-<8 hex>.wav in an existing directory; the key is left out when there is none, so S1's request is byte for byte what it was. The worker checks the path before it opens the input and, once the analysis has succeeded with the device closed, writes the captured channel (mono, capture rate, 24-bit, stdlib wave) to <path>.part, syncs it and renames it, then prints the reply, which gains `recording` (path, frames, sample_rate, channels, bytes, or a write_failed detail that never fails the listen). A refused, failed or undeliverable listen leaves neither the file nor a .part. The decoder checks the field's exact types; the listener treats a recording that does not match the request (one nobody asked for, none when one was asked for, another path) as a protocol violation. No audio crosses the pipe, and no module under src imports an audio package. The stand-in worker gains --write-wav and --write-fail. Two S1 pins that name the ListenReply field set gain "recording" with a comment (test_reply_carries_no_samples, and test_unknown_reply_fields_never_reach_the_result, which the Architect's cite check had missed and which failed until it was changed); no other S0 or S1 test changes. Review: one round, READY, Size findings 0 (gpt-6.1-sol). Two injected-only findings are recorded for the S2 follow-ups, not repaired: the worker accepts a path longer than the decoder's 1,024 characters (the vessel's encoder cannot send one), and one refusal case in the new tests passes at the wrong guard. 47 hand mutants of the new checks: 47 killed. Exit command 1,049 passed, 2 skipped; srp-size 93. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
L3b is built and committed (one review round, READY, Size findings 0). L4a (the
lessons config) was reviewed once, NOT READY on three ordinary-reach findings
about lessons.recordings_dir: a configured checkpoints, semantic, ship-records or
scout_reports is cleared by a reset (verified by execution), no length bound, and
a grammar stricter than D8's wording. The Architect's decision (Q1 to Q3): the
directory must be in the lesson- namespace, at most 64 characters, no dot; D8,
section 12's reset row, Z18 and L5's G1 are reworded. The answer's regex had an
off-by-one (7 + 1 + 55 is 63), so the contract says {0,56}.
Also: A35 missed a second S1 pin on the ListenReply field set
(test_unknown_reply_fields_never_reach_the_result), now named with the first;
L4 is built in four slices (L4a config; L4b1 the two events and the history
side; L4b2 the beats side and the port types; L4c the hooks, offer notes and
wiring), because the AD-1195 producer test needs the emitting file to exist with
both events and the history side emits both; L7 rewrites hearing.md:108; and the
Builder's accepted readings of L3b are recorded. Text only.
Refs #1935.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… S2 L4a) `LessonsConfig` (off by default: crew allowlist, idle and maximum minutes, the speech wait and the recordings directory) joins `SystemConfig` as `lessons`. Nothing reads it yet: L4b and L4c build the service and the wiring. `lessons.recordings_dir` must be one directory name in the `lesson-` namespace: lowercase letters, digits, `-` and `_`, at most 64 characters, no dot. No reset tier, `--clean-slate` or UUID clear names that namespace, and a test enumerates `RESET_TIERS` (directories and files, case-folded, plus the nature directory) so a future reset name inside it fails. The first review found that the validator accepted `checkpoints`, `semantic`, `ship-records` and `scout_reports`, which a reset clears (a reset deleted a configured recording), had no length bound, and was stricter than D8's words. The Architect decided the namespace rule; its pattern allowed 63 characters, and the contract and the code allow 64. The pinned counts and generated files move with it: the config facade (names 314, owned 301, models 232, fields 1907), the default-config dump in the AD-1152 test, `config-profiles.yaml` (one `lessons.enabled` row; census 450/229/221/85/144), the facade baseline and `config-reference.md`. Reviewed in three rounds (the last READY, no size findings); 21 hand mutants of the validators, the numbers and the reset-code tie, all killed. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
L4b1 (the two lesson events and the history side of the service) was built and verified: the exit command passed (966 tests on a clean export) and 78 hand mutants left 12 survivors (three equivalent, nine test gaps). Reading it found five things the contract had not settled, and the Architect decided them: an unreadable lesson.json is reported beside the list, not as a row (the merged HXI's validator rejects the whole list on one such row); a restart close writes no end time; the start check compares the WAV's size, through a new RecordingStore.audio_size; the lesson record's verdict status is refreshed from the retry take's own record (a new read-only PracticeRecordService.verdict_status; a verdict still pending at a restart becomes none, with the reason); and the take record path is known before close_take (PracticeRecordService.record_path), which closes a circular dependency between complete_play and close_take. Also: L4b2 is built as L4b2a (the lifecycle) then L4b2b (the beats), with seven rules for them (the mute is read before the start check, the retention block carries a take record path, a removal is re-applied before every rewrite of lesson.json, reconcile re-reads under the lock and skips a live lesson, end and expiry with a ticket outstanding, the double fault, the method budget); L4c passes the records reader to S0's service at finalize.py:281; D8's prose now says what A56's regex says; and L4b1's accepted readings are recorded. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…1378 S2 L4b1) Two EventType members, `LESSON_CHANGED` and `LESSON_RECORDINGS_REMOVED`, both declared DURABLE (the AD-1195 pins move by A46's numbers: 394 members, 34 routed, 42 durable), and `LessonService` with its history side: the lessons' list and progress from the `lesson.json` files, removal of recordings at the Captain's word, reconcile at boot, and the read half of the start-of-session check. The beats side (`start`, the beats, the mute pause) comes in L4b2. - Removal (D9): the service is the only caller of `remove_by_captain`. A request tombstones and unlinks each recording, announces what it removed (one event per at most 25 recordings: the durable projection keeps 31 items of a list), then marks the lesson record (`lesson.json` first, then its Ship's Records entry) and the take records, keeping the figures. A cancelled request settles first; overlapping requests run one after the other. - Reconcile (D7, D18): closes every open lesson as `restart` from a fresh read taken under the lock, writes no end time it does not know, and shows a verdict still pending after a restart as `none`, with the reason. - Lists and progress (D21): readable lessons only, with the files that cannot be read named beside them (the merged HXI's validator rejects a list with a null-filled row); a null or unknown timeline is never the current crew's. - The start check (section 12): compares each recording's size with the recorded one (`RecordingStore.audio_size`, new), reports what is missing, and repairs nothing of its own. - `PracticeRecordService` gains `mark_recording_removed` (the take's recording marked removed with its figures kept, the entry's own classification and department kept) and `verdict_status` (a read-only view of the take record's verdict). S0's own writes are unchanged. Reviewed in four rounds: the whole candidate twice, then the delta of each repair (the fourth on the Architect's decision at the round-three brake). The first round found eight defects, one of them P1 (a rewritten take record could change who may read it); the second found the same class once more (an entry whose header could not be parsed was republished as readable by the ship), a cancellation gap and a start-check gap; the third found one regression in the cancellation helper; the fourth found nothing. All were repaired. Hand mutants: 117 on the third candidate (115 killed; the two survivors are equivalent), and the 39 of the removal group again on the fourth (35 killed); the four that survive are one equivalent and three behaviours of the settlement helper that no test pins (a failed settlement's log and swallow, and the cancellation count), recorded for the follow-up issue. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
L4b1 (the two lesson events and the history side of the service) passed its fourth review round with no findings and is committed. Its four rounds (the whole candidate twice, then the delta of each repair) changed the contract in six places: the removal event is announced in chunks of at most 25 recordings, because the durable projection keeps 31 items of a list (A68); the start check changes nothing of its own, and lists the store first so a pending unlink is finished for any phrase (A69); the mark on a take record keeps who can read the entry and refuses, writing nothing, when that cannot be read safely (A70); a cancelled removal settles first (A71); and, at the round-three brake, the Architect's decision that the settlement helper waits with asyncio.wait, so a cancelled settlement task counts as a cancellation and is logged as incomplete (A73). Also: L4b2a leaves the outstanding-ticket slot, the re-application of removals and the verdict refresh to L4b2b, because nothing in L4b2a can open a ticket or add a recording (A72). D9, the lesson_recordings_removed payload line, section 12's check and section 15 Section 4's slice list are reworded to match. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ols, the status read and the lazy expiry (AD-1378 S2 L4b2a) `LessonService` gains the lesson that is open (`_LessonBeats`, in `skills/violin/lesson.py`): `start`, `end`, `next_round`, `skip_retention`, `snapshot` and a lazy expiry, behind one lock, with `tools/lesson_port.py` (the standard-library-only port; `LessonRefusal` so far) and one new refusal code, `lesson_not_saved`. The beats (`begin_beat`, the completions, the comparison) come in L4b2b. - Start (D2, A60, A72): refused in this order: a muted agent (the service never unmutes it and a muted start has no effects), a lesson in progress, the label, the conversation (`thread_not_with_agent`; a check that cannot be made counts as no). One lesson runs ship-wide. The phrase key comes from the label (NFKD, marks dropped by category, casefold, each run of non-alphanumerics one `-`, at most 256 characters: the durable log keeps 512 per string), and the start's stasis compares the unrounded start time with the vessel's wake. - Controls (D20): End, Next round and Skip retention are allowed while paused. A control is not activity: the idle minutes run from the last beat, the start counting as the first. - Expiry (A60): lazy, at the real deadline rather than the time of the check, and run first by every public call except `reconcile` (the history calls included). A muted start refuses before any expiry runs. The closing record carries a mute that the closing call saw first (A96). - Pauses (D20): every call that finds a live lesson reads its agent's mute once, under the lock. A mute seen for the first time is one entry in `pauses` (`_after` for a transition, `_observed` for a read), an unmute that a call saw makes the next mute a new entry, and a pause is never an event and never activity. The requested agent's mute is read again right before an opening is decided, because a mute can arrive while an expiry is written. - One write path (D1, D21): `_step` takes the lock, runs the expiry and then the call's move; `_commit` writes `lesson.json` first, then the Ship's Records entry, then holds the move in memory and announces `lesson_changed`, as one unit that the caller's cancellation cannot split. If the write task itself is cancelled, `lesson.json` is read back and memory follows what it holds. A move that cannot be written leaves the lesson as it was and answers `lesson_not_saved`. Reviewed in four rounds: the whole candidate, then the delta of each repair. Round 1 found eight P2 defects (a start admitted after a mute that came during its conversation check; controls counted as activity; the history calls skipped expiry; a status read left the pause latch set after an unmute; a refused control dropped the mute it had seen; a 60-character label gave a key that the durable log cut; U+034F became a separator; truncated timestamps made a false `stasis_before`) and a size finding. Round 2 found two variants of the same class (a stale admission read after an awaited expiry; calls with no builder dropped what they observed), and round 3 one more (the expiry dropped a first-seen mute from the closing record) and a leftover. At the round-three brake the Architect chose to continue and to build the pause in `_after`, so that no transition can leave it out; round 4 found nothing (READY, no size findings). Hand mutants on the four candidates: 77, 94, 98 and 104 (101 of the last 104 killed; the three that survive are informational, unreachable or equivalent until the beats exist). The injected-only findings and the informational survivors are recorded for the S2 follow-up issue. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
L4b2a (the lesson lifecycle of the service) passed its fourth review round with no findings and is committed. Three things change the contract. The Architect checked the L4b2b text against that code and the S0 and S1 tools: eight cites did not hold (the refresh seam belongs in `_commit`; `_LessonBeats` needs `practice_records` and `record_path`; the port may import `probos.audio.recordings` and types its parameters `Any`; `TakeLessonFields` was defined nowhere; `lesson=` is passed only with a ticket; `take` may be `None`; `record_path` needs a module-level `_take_path`; the `seen_by` values were wrong), six gaps are decided (the ticket's life cycle, when a beat is taken against whether its recording is kept, notes for the comparison, retention-stage failures, an expired lesson's offer note, the first-lesson sentence) and five statements are corrected (A75 to A93). L4b2b is built in four slices, the first being the ticket (A95), with the pure builders in a new module (A94). L4b2a's own readings are recorded (A74: the refusal code `lesson_not_saved`, the idle rule from the last beat, expiry in every public call, the muted start that settles nothing, the fresh admission read, the key limit and the stasis compare). At the round-three brake the Architect decided that a mute first seen by the call that closes an overdue lesson is one entry in the closing record, and that the pause is computed in `_after` so that no transition can leave it out (A96). D12, D20 and sections 4, 5, 9, 14 and 15 Section 4 are reworded to match. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… offer_note (AD-1378 S2 L4b2b1) The first of the four slices that build the beats of the lesson service (contract A95). It builds nothing that completes a beat: `begin_beat`, `observe_muted` and `offer_note` on `LessonService`, over the ticket a beat holds, with the types and the two pinned sentences in `tools/lesson_port.py`. - `begin_beat(agent_id, thread_id, kind)` (D12, A88) answers `None` when no lesson of hers is open (her tool runs as S0 and S1 do), a refusal (`lesson_elsewhere`, `hearing_muted`, `busy`, `out_of_turn`, decided in that order, with `beat_in_progress` for the Captain's controls while a beat is out) or a `BeatTicket`, whose reservation is the recording the service now owns until it commits or discards it. An unlocked look decides only whether a recording is worth reserving (a muted agent reserves nothing, D20); the lock then decides everything again and discards the reservation of a beat it refuses. An allowed beat changes memory only: the ticket takes the slot and the idle clock is reset, which is the one thing that makes a beat activity. From the reservation to the slot the call is one unit that a cancelled caller cannot split: a ticket nobody received is taken back and its reservation discarded. - The close a beat holds back (A88): End or expiry with a listen ticket closes the lesson at once; with a play ticket the close is held back until the play completes (slice 3 applies it), the answer is the lesson as it stands, and nothing is written or announced; a ticket older than the idle minutes is abandoned, logged at ERROR and ignored. His End overrides a held-back expiry, never the reverse. - `observe_muted` (D20) records a mute a muted tool call saw and says the lesson is paused; `offer_note` (D22, A92) is the synchronous sentence her tools are offered with, and says nothing once the lesson has run out. - One structural rule in `_step` closes the class that three rounds of L4b2a found on three paths: a call whose `build` makes no move while a lesson is live settles the mute it read, as a refusal does (A74(j)). A pause now names the call that saw it (`begin_beat`, `observe_muted`, `status`: A82), and `pauses` is still appended to in exactly two places. - A ticket's release never depends on a write (A108, A109). A ticket given back after its caller was cancelled settles the mute it read as the take-back's own pause (`begin_beat`); if that write fails, or its write task is cancelled, `_cleared` clears the slot in memory only, so no failed write holds the lesson, the mute stays unacknowledged for the next call that reads it, and the reservation is discarded either way. A held-back End or expiry whose write fails keeps its ticket (clearing it would lose the Captain's End), and the abandoned-ticket bound then ends the lesson, as the Captain's End if he gave one, dated at the check, not as `expired`. Reviewed in four rounds: one whole review, then three delta reviews of three repair rounds (the fourth was allowed by the Architect's decision at the round-three brake). Hand mutants: 167, 161 killed; the six that survive are informational or unreachable (a downgraded completed round that no path can complete yet, a mute read again, two calls the no-move rule makes redundant, a `seen_by` no caller reaches, and the identity guard of `_cleared`). Two injected-only findings of the last round (a `reserve` cancelled after the store allocated, and a cancellation during the final discard) go to the S2 follow-up. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revision 2k: the Architect checked the build brief of the listen beat (L4b2b2) against L4b2b1's code and S1's tools before anything was built, and found fourteen places where it would not have worked or would have been guessed; five were structural. The contract now says: `complete_listen` takes the tool's floor grant, read after the hold exits and in a `finally` (A97); the hearing sidecar's `source` is the input label only (A98); a closed lesson answers a block, not a refusal (A99); D21-5's inputs, condition and text, decided before the call's own move (A100); the repeat bookkeeping and what the block stores (A101); the beat predicate and the events, so that a listen the tool's latch muted is not a beat even when `phrases` is non-empty (A102); `_step` gains an async phase for the store work, because a completion must await the store under the lock and the lock is not reentrant (A103); a failed record write after `commit` releases the slot (A104); the double fault (A105); the shapes of the removal refresh in `_commit` (A106); and every completion of the live ticket resets the idle clock (A107). Revision 2l: what L4b2b1's four review rounds decided for the slices that follow. A ticket's release never depends on a record write, a failed write or a cancelled write task alike: every path that gives a ticket back goes through one function, which clears the slot in memory only when its own write cannot be made, except for a held-back End or expiry, whose ticket stays until the abandoned bound (A108, the Architect's decision at the round-three brake); and an abandoned ticket closes a held End as the Captain's End, dated at the check (A109). A88 and A104 point to them. Section 5's sidecar `source` and the listen hook's step 4 are reworded to match. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d release and the removal refresh (AD-1378 S2 L4b2b2) The second of the four slices that build the beats of the lesson service (contract A95). `complete_listen(ticket, *, outcome, phrases, result, floor=None)` closes the beat a ticket was handed out for, exactly once on every exit of her tool, and adds nothing to what a lesson needs from the tool side (the hook is L4c's). - Under the lock, after the lazy expiry and with the one reading of the mute that `_step` makes, a stale ticket is answered that the lesson ended (a block, not a refusal: A99); a mute discards the file, records `muted_while_listening` and one pause, and is answered with the pause sentence; a heard phrase with an ok outcome is a beat, stored with the state moved and one `lesson_changed`, whether or not its recording is kept (the file is committed only if the worker reported it at the reserved path and the store takes it, else the ref says `not_kept` and why); anything else, and a discard that raises (D7's double fault, reported with no path in it), is an entry in the round's `events` with the state unchanged and nothing announced. Every completion of the live ticket resets the idle clock. - `_step` gains an async `prepare` phase: a completion must await the store after the mute reading and before its move, and the lock is not reentrant, so the commit or the discard of its file is run inside the step (A103). Its unit runs whole whatever cancels the caller; the caller's cancellation is raised once the clean-up is done, and a cancelled owned task is only a failed write. - `lesson_beats.py` holds what a finished listen means for the record, as pure functions: which event a listen is (A102: the tool's latch answers `muted_while_listening` before it builds anything, so the phrases alone cannot tell), the `phrase` and `model` blocks, how a repeat keeps the capture it replaces in a flat `earlier` list, where a failure goes, and D21-5's sentence about an earlier crew's lessons, which leads every answer built from a live lesson until its first beat is stored (`observe_muted` too). - A ticket's release never depends on a write (A108): `_release` is factored out of `_give_back` and shared with the failed-write path, so a record write that fails after the file was committed releases the slot and leaves the file for the Captain; a cancelled owned task counts as a failed step; `_give_back` also absorbs a cancellation that lands in its final discard. - The removal refresh (A106): every write applies the removals the Captain made since the record was last written, writes and holds that copy, and then marks the take records. A store that cannot be listed is a warning and the write goes ahead. Reviewed in one round on the whole candidate. Its one size finding, an unused binding in a test, was deleted without a further round; its three injected-only findings are recorded for the follow-up (a cancelled commit can keep audio while the answer says it was not recorded; a failing expiry write pre-empts the in-memory release fallback; the release after a failed completion names `begin_beat`, which the next slice corrects). Hand mutants: 190, 184 killed; the six survivors are informational (five known from earlier slices, and the refresh's defensive copy of the record). Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Architect read L4b2b3 against L4b2b2's candidate before anything was built, and found twenty places where the build would not have worked or would have been guessed; five were structural, and the slice is split in two. L4b2b3a, the take side, the measurement and the verdict: `LessonFeedback` carries the measured block as a third field (A110); `lesson_beats.py` may import the stdlib-only audio modules at runtime, with the boundary test an exact set (A111); the store work becomes beat-agnostic and a measurement that raises is only an ERROR (A114); a release names the call that saw the mute, which L4b2b2's review found (A119); `_feedback_of` keeps the not-stored prefix (A120); the verdict refresh is one function called by every rewrite (A121); `last_measured` is derived from the record (A122); `close_take(lesson=)` fills the take's four fields (A126); the model block always carries its comparison (A128). L4b2b3b, `complete_play`: a retry completes its round (A112); one cancellation skeleton for both completions (A113); the play predicate is S0's, which amends A89 (A115); the measured block (A116); what `complete_play` takes and returns (A117); a held-back close is applied in the completion's own move (A118); the summary's first attempt and best retry (A123); a retention play ticket until L4b2b4 (A124); `take=None` (A125); and a stricter `LessonPort` conformance test (A129). A63 is stale on one point (A127). Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… lesson service (AD-1378 S2 L4b2b3a) The third slice of the beats of the lesson service, first half (contract A95, A110 to A129): everything the take side needs before `complete_play` exists. The play half follows in two milestones, so nothing here has a tool caller yet (the hooks are L4c's). - The measurement. The listen of the model beat compares her attempt (the round's `attempt.notes`, rebuilt as S1's `NoteRef`s) with the first phrase she has just heard, with S1's `compare_attempt` and S2's `lesson_stats`, under the lock, in the same store work that keeps or discards the recording. The block (section 5's `measured`: `against`, `method`, `comparison`, `stats`, `note`) is stored in the model block as `attempt_vs_model` (always present on a model block, `None` without attempt notes) and carried to her tool as `LessonFeedback.measured`, a third optional field whose absence leaves every other block byte-identical. A measurement that raises is an ERROR and the beat stands without it. `lesson_beats.py` gains `PlayedNote`, `played_notes`, `heard_phrase`, `measure` and `last_measured` (the snapshot's last figure, derived from the record and kept nowhere), and may import the three standard-library-only measuring modules at runtime; its boundary test is an exact set. - The store work is beat-agnostic: `_keep_or_discard(..., taken, unkept, label, source, measure, ...)` and `_commit_file(..., label, source)`, so the play half reuses them. Every property of the listen's result matrix still holds. - The verdict refresh (A62): one function, `_refresh_verdicts`, called by every rewrite of a lesson record (a write under the lock, a removal rewrite, a restart close). Live it only writes what the take record says (`bound` or `none`), asks only a verdict still pending, never turns a verdict not bound yet into `none`, and a reader that raises is a warning that keeps the last status. A restart close lets a raising reader propagate, as before. - A release names the call that saw the mute (`seen_by`, which L4b2b2's review found missing), and `_feedback_of` keeps the not-stored prefix when the lesson has gone or has become another lesson. - S0: `PracticeRecordService.record_path(take)` says where a take's record will be written, and `close_take(lesson=...)` fills the take's `round`, `session`, `measured` and `recording` as deep copies; `audio_kept` stays false and outside a lesson the record is what it was. Reviewed in two rounds: the whole candidate (NOT READY, no size findings, two injected-only regressions: a restart close that swallowed a raising verdict reader and settled a bound verdict as lost for good, and a malformed listen result that raised out of `complete_listen` instead of being stored as a failed beat, each repaired with a regression test) and then the delta (READY with no size findings; its one new finding, a malformed non-empty `phrases` (an object without notes) that raises after the file was committed, is the same in the previous code, needs an injected input and is recorded for the follow-up). Hand mutants: 218 on the first candidate, 212 killed; the six survivors were three known informational ones, one equivalent over S1's output (its notes never overlap), and two test gaps (the model is measured against the first heard phrase; only a pending verdict is asked of the take record) that now have a test each, killed on the final tree together with the repair's own mutants. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Architect read L4b2b3b against L4b2b3a's candidate and found it is two milestones, not one, and that three points of the draft would not have worked. L4b2b3b1 is the shared ground (a retry completes its round, the one completion skeleton, the pure play functions) and L4b2b3b2 is `complete_play` with the held-back close, the retention interim and the port. - A113: the skeleton takes a `plan` that it calls inside its own `try`. A completion that hands it ready-made partials would put what it derives from the tool's report (`taken`, `unkept`, the sidecar's source, the measure) outside the clean-up, which undoes the rule L4b2b3a's Builder kept. - A124: the retention interim is a memory-only release. A retention lesson's record has no rounds, so a `play_failed` recorded through the machine would open a round 0. - A117: a take's fields carry a recording and figures only for a block that stood, because the double fault sets the recording reference before its discard fails. - A110, A120, A125: play answers carry `measured`; a live lesson that still holds a close answers the closed sentence; a verdict is `None` whenever its record path is, or it would show pending for good. One amendment the Architect listed is dropped. It accepted L4b2b3a's reading that a verdict reader that raises during a restart close settles the verdict as lost; the review ran it against the previous code and showed it misreports a bound verdict for good, so A121 keeps today's semantics and the code was repaired. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…unctions: the shared ground of the play beat (AD-1378 S2 L4b2b3b1) The third slice of the beats of the lesson service, second half, first milestone (contract A95, A111 to A113, A115, A116, A123, revision 2n): what both completions and the play beat share, so that `complete_play` (L4b2b3b2) and the retention beat (L4b2b4) are written on it. Nothing here has a tool caller yet (the hooks are L4c's), and `play_event`, `play_block` and `with_play` have none until `complete_play`. - One skeleton, called with a plan (A113). `_settle_beat(ticket, plan, settled, seen_by)` holds what `complete_listen` had: the cancellation baseline, the store work and the move run to their end whatever cancels the caller, the clean-up of a beat that was not stored (the slot released through `_release`, the reservation discarded once, a committed file stays), and the caller's cancellation raised once after all of it. `plan` is called inside the clean-up, so whatever is derived from the tool's report is covered by it: a derivation that raises frees the slot, discards the reservation and is then the caller's. `complete_listen` builds its plan with `_listen_plan` (the same derivations as before) and answers through `_feedback_of`. It is a move: every earlier test passes unchanged. - A retry completes its round (A112): `_after` marks the round a retry closes `completed` and `summary.rounds_completed` counts it; every other close keeps the flag the round held. - The pure functions of the play beat in `lesson_beats.py` (A115, A116, A123): `play_event` (a play is a beat only when the host says `played` and the phrase is not silent by S0's own test, `SILENT_DBFS`, so the lesson and the take record agree; a mute wins; every other status S0 reports is a failed play with that status; no host sentence is ever written), `play_block` (the attempt's and the retry's block, the attempt alone holding `remarks_take_id`) and `with_play` (stores the block in the round it belongs to, sets a retry's `verdict`, recomputes the summary's `first_attempt` and `best_retry` and keeps its other keys). `lesson_beats` takes one more runtime import, S0's `probos.audio.expressive.protocol` (standard library only), and its boundary test says so. Reviewed in two rounds: the whole candidate (READY, no size findings; four injected-only findings, none a regression, recorded for the follow-up: a cancellation during the fallback clear's lock wait leaves a ticket held, as the previous code does too; the feedback helper's answer while a held End is pending, which the next slice changes; the play event is not total for a status object that raises when read or compared; a stale ticket's failed derivation logs no error naming the recording) and then the delta of three added tests (READY with no size findings and no finding of its own: each added case was run against the mutant it targets and fails there). Hand mutants: 255 on the first candidate, 247 killed; the eight survivors were five known or provably unobservable (a redundant disjunct, an unread time-zone argument and three informational ones carried from the previous slice) and three test gaps in the new functions (an integer peak, a NaN figure listed first, a figures block that is no mapping) that now have a test each, killed on the final tree. Exit run on the final tree: 1,803 passed. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ort: the play beat of the lesson service (AD-1378 S2 L4b2b3b2)
The second milestone of the beats of the lesson service, second half (contract A95, A110, A113, A115 to A121, A124, A125, A127, A128, revision 2n): the completion of a play, built on the one skeleton L4b2b3b1 left. Nothing here has a tool caller yet (the hooks are L4c's).
- `complete_play(ticket, *, take, phrase, outcome) -> (TakeLessonFields | None, LessonFeedback)` completes the play a ticket was handed out for, whatever became of it, exactly once per ticket: through `_settle_beat` with its own plan (`_play_plan`), so a derivation from the tool's report is covered by the clean-up. The store work keeps the file (the sidecar names the voice and the instrument, the state and the take; `None` for a play with no take) or discards it; a played, non-silent phrase is a beat whether or not its recording is kept, measured under the lock (the attempt against the phrase she heard, the retry against the model); a failure, a mute and a double fault are an entry in the round's events with the state unchanged; a retry also sets its round's verdict pending, only when the take's record path could be made.
- The held-back close (A118): the Captain's End or an expiry held back while she played is applied by the same write: the beat is stored, then one `_control` ends the lesson, so there is one record, `ended_at` is the completion time, `lesson_changed` follows once and the mute is not read twice. A live lesson that still holds a close answers the closed sentence (A120).
- The fields for the take record (`_lesson_fields`, A117): the round, the session, and the figures and the recording ref only for a block that stood (the double fault sets the ref before its discard fails). They are given whether or not the lesson's own write succeeded: the take record is S0's authority.
- The retention interim (A124): until L4b2b4, a retention play ticket is released with its file discarded and nothing recorded but a first-seen pause or a held close, because a retention lesson's record has no round 0 for an event to go in.
- The port: `LessonPort` in `tools/lesson_port.py` (the five calls the two tools make), with a conformance test of the service against it (names, kinds, defaults, coroutine-ness), and `TakeRecordMarker.record_path` (A127).
Reviewed in three rounds, the last two on deltas. Round 1, the whole candidate: READY, no size finding; two injected-only findings, neither a regression: a second cancellation of the owned write task during `_commit`'s read-back can lose an already-written beat (it reproduces on the parent's listen path, and is recorded for the follow-up), and a docstring that promised "the file discarded" after a discard that raises, which D7 leaves behind (repaired). Round 2: NOT READY on two P3: three more docstrings with the same claim, and a test comment whose premise the wire protocol refutes (the host admits one error text only); repaired by words, with every disposal claim in the two source files enumerated. Round 3: the repair is proven code-identical (the syntax trees of both versions, docstrings stripped, are equal, and the comparison is shown able to fail); NOT READY on two P3 about fault-path prose (a docstring says "no reservation held" and a comment says "the beat is stored" where D7's double fault leaves the store's reservation open and stores only the failure event, and two log lines read as completed outcomes): they are reached only by an injected discard failure, the earlier text said the same, so under the round-three rule they are recorded for the follow-up and not repaired here. Hand mutants: 158 rows over four trees, 151 killed; the seven survivors are equivalent (a dead field, a dead name, two redundant guards, a line L4b2b4 replaces, the redundant disjunct known from the previous slice, and the host's error text, which the wire protocol admits in one value only; a defensive test pins its pass-through). Exit run on the final tree: 1,945 passed.
Three existing tests changed, each strengthened or extended and none weakened: the AST test that lists the tool calls bound to the lesson now lists `complete_play`; the pin that `_released` is written once now reads `{_release, _played}` (L4b2b4 puts it back when it deletes the retention interim); the one-skeleton test now expects both completions.
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Architect drafted L4b2b4, the retention beat, against the committed code and the two briefs of the play beat, and found it is one milestone: the beat reuses `complete_play` and the shared completion skeleton unchanged and deletes the interim L4b2b3b2 builds, so it adds no new race surface.
- A95: the previous lesson's model beat (what she last heard) is carried as `HistoryCheck.retention_model`, a field of its own that `as_dict()` leaves out. A95 put it in `previous["retention_heard"]`, which `start` copies whole into `start_check`, and so into `lesson.json` and the Ship's Records entry; A90 says the reference model stays in memory.
- A117: a retention take now has fields (`round` is `{lesson_id, round: 0, beat: "retention"}`, and the figures and the recording are filled under the same "the block stood" rule); A117 gave `None` for the retention beat.
- A122: `last_measured` falls back to the retention figure (`round` 0) when no round holds a measurement, so the live panel shows it before round 1's attempt; the HXI already accepts round 0.
- A124: the memory-only interim is superseded. `_after` opens a round only when the transition's round is above 0, so a retention completion goes through the same play path as the attempt and the retry; a retention play's failures are entries in `retention.events` (A91) and the state stays `retention_check`.
- Section 9 step 4 fills `retention.record` as well; section 12's "N lessons" prompt is not built (her first `lesson.next` in a retention lesson usually comes from the retention play's own answer, so the prefix rule would put it in front of the wrong sentence): section 4's pinned sentence is her prompt.
Text only.
Refs #1935.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… measured against the previous lesson (AD-1378 S2 L4b2b4)
The last milestone of the beats of the lesson service (contract A64, A88, A90, A91, A95, A100, A108, A114, A117, A118, A122, A124, revision 2o): the play of the retention check, which until now was released with its file discarded and nothing recorded. Nothing here has a tool caller yet (the hooks are L4c's).
- The model, in memory only (A90). `HistoryCheck.retention_model`, its own last field, is built in `_LessonHistory.check` from the previous lesson's record it has already loaded (this crew's only), by one finder (`_retention_source`) that `_retention_against` now shares, so what the start check names and what the lesson holds never disagree. `as_dict()` leaves it out, so `start_check`, `lesson.json`, the Ship's Records entry and `lesson_changed` are unchanged in every key and value. `_Open.retention_model` is set at the start only when the lesson begins in its check, is never replaced or written, and is not rebuilt after a restart (a restart closes the lesson).
- Round 0 is no round (A91). The pending retention block gains `events`; `_after` opens a round only for a round number above 0; a failed retention play, a mute and a double fault are entries in `retention.events`, with the state unchanged and no round 0 made.
- The beat (A124). The retention play completes as the attempt does: the machine's event, then the beat stored in the retention block (`status: measured`, keeping `previous_lesson_id`, `against`, `given` and the events), round 1 opened and `lesson_changed` once; a close held back while she played is applied by the same write. It is measured against the previous lesson's model (`_retention_measured`: no model, no figure; a `heard` that cannot be rebuilt is an ERROR and the beat stands with `measured: null`). The interim is deleted. The take record gets the lesson fields with round 0 (`_lesson_fields` no longer excludes retention), and `last_measured` falls back to the retention figure as round 0, which the HXI accepts (the shipped validators accepted all 37 real outputs of the candidate, a retention lesson among them).
- Words only, carried from L4b2b3b2's third review round: the `_listen_plan` and `_play_plan` docstrings and the `_commit_file` comment no longer say that no reservation is held or that the beat is stored where D7's double fault leaves the reservation open and the file for the next restart to adopt.
Review: two rounds. Round 1 (the whole candidate) found a deep-copy test that could not fail (the retention model's notes could be the stored list itself and no test saw it) and three docstrings that said the retention play is measured against "the model" where the design says the previous lesson's last model heard, else its last phrase; both are repaired, and a test for the stored failure entry's copy was added with them. Round 2 (the delta) found nothing: ready, no size findings. Hand mutants: 39 rows over three trees, 35 killed; two of the three survivors (the model's notes, and the stored failure entry, shared instead of copied) were observable after all by a direct call of the pure functions and are now killed by one new test each, the third (the guard that a stale ticket's lesson is the live one) is equivalent because a stale ticket measures nothing under the lock. Exit run on the final tree: 2,033 passed; the event types stay at 394 and the architecture check is unchanged.
Existing tests changed, each with its reason and none weakened: the 3b1 pins that refused a retention play now accept it and the replaced ones are covered by new tests; the two dicts that pin the pending and skipped retention blocks gain `"events": []`; the pin that `_released` is written once reads `{_release}` again; the two tests that pinned the interim (a release with nothing stored, a held close applied on the release) are replaced by the retention beat's stored and held-close tests.
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…en and a play are beats of her lesson (AD-1378 S2 L4c1) The two tools now take part in the Captain's lesson (contract section 9; A38 to A42, A53, A77, A79, A80, A83, A85, A86, A97, A99, A125; D7, D10, D12, D20, D22). They look `runtime.lessons` and `runtime.audio_floor` up as each step needs them, and nothing sets either yet (the wiring and the offer notes are L4c2's). With no service on the runtime a tool answers as it did before lessons, except that it holds the audio floor while it works when one is wired. - `tools/lesson_hook.py` (new; the standard library, and `probos.audio.floor` for typing only): `hold_floor` (the floor's hold, or a hold that waits for nothing when no floor is wired) and `lesson_call` (one awaited call to the lesson service: its answer, or `None` and an ERROR log when it raised an `Exception`; a cancellation always passes through, and a call that raised while the caller's `cancelling()` count rose raises the cancellation in its place, because the service raises a failing clean-up instead of the caller's pending cancellation). - The listen. After S1's own gates and its busy check the tool asks the service for a ticket (`begin_beat`), holds the floor for a capture, runs S1's `_listen` unchanged in shape (the source-scan test that pins it is untouched; `record_to` reaches the listener through a keyword mapping) and completes the ticket in a `finally` after the hold has been released, exactly once on every way out, adding the `lesson` block the service answers to the result. A muted call gains the block `observe_muted` answers, after S1's muted answer is built. A refusal is S1's shape with the service's code and sentence and no fault. The phrases the lesson measures are the phrases her result reports (the capped list), not the listener's. - The play. After the performer has shaped the phrase the tool asks for a ticket, opens the take, and holds the floor for a play around `client.play` only, handing the worker the destination the ticket names for the recording. With a ticket the end of the play is one task of its own, kept in `_closing`, that the caller's cancellation cannot reach: the lesson's completion first (the take record holds the fields it gives), then S0's settlement with `lesson=`. The caller waits for it; a caller already cancelled, or cancelled during the wait, waits at most `CANCEL_CLOSE_S`, is told by a WARNING when it is still running, and then raises its cancellation. With no ticket S0's path is unchanged and `close_take` is called with S0's keywords. - One change on a vessel with lessons off, once L4c2 wires the floor: with music or hearing on, the two tools share the audio floor (D10), so a play while a capture is running, or the reverse, answers `busy`. The pull request for S2 says so. - Tests. `tests/test_ad1378_s2_tool_hooks.py` (84 tests) runs the tools against the real `LessonService`, `FilesystemRecordingStore`, `AudioFloor`, listener and host client (stand-in workers), noting every call each makes of the others: the two beats crossing every seam (including the kind of each tool's floor hold), the exactly-once matrices (26 listen and 21 play endings, including cancellations at the hold's speech wait, the listen, the completion's lock and write, and right after `begin_beat`), no lesson byte for byte in three worlds, the refusals of both tools, the muted cases, a lesson ended mid-listen, the floor's serialisation, a caller cancelled twice, what the agent reads of a fault and of a result that is not one, and the hook's two functions. `test_lesson_hook_imports_only_the_floor_and_the_port` joins the boundary tests. The one existing test changed is S1's `test_writes_nothing`, whose allowed set gains `lessons` and `audio_floor` with A42's comment. - A fault inside a lesson answers as S0 or S1 would: its `error` text is not extended with the lesson's next-step sentence, because the agentic loop shows the agent that text alone and the fault lane takes it as the defect's signature and noise class (`fault_detection.py`, `executor.classify_tool_error`). The `lesson` block stays in `output` for the record. Three tests render real results through both agent-facing adapters to pin this (Architect decision; contract section 4, "Failures change no state"). Review: five rounds and two Architect decisions at the round-three brake. Round 1 read the whole slice and found four things: the fault's `error` text (decided with the Architect, above), a WARNING that could fire where its sentence was false, a leftover constant (deleted), and a slot probe that a mute made vacuous. After those repairs no executable source line changed (the three source files are AST-identical from that candidate to this one); rounds 2 to 5 found docstring clauses that were false on some path and one missing test assertion, and each was repaired by deleting the clause or with the Architect's text. Hand mutants: two campaigns of 32 and 42 rows, 29 and 41 killed; the four survivors (the kind of each tool's floor hold, the busy outcome, a WARNING for a task that was already done) each got an assertion that now kills them. Exit run on the final tree: 2,298 passed; the event types stay at 394 and the architecture check is unchanged (`srp-size` 93). Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… lesson is offered to her tools, wired at boot and closed at shutdown (AD-1378 S2 L4c2)
The lesson service (L1 to L4b) and the two tool hooks (L4c1) now have the runtime around them (contract sections 9 and 15; D8, D10, D18, D22; A43, A48, A65, A72, A92). Nothing is on by default: with the default config (music, hearing and lessons all off) a vessel changes in nothing but the new attributes being `None`.
- `agentic_dispatch.py`. The two blocks that offer `listen_to_sound` (S1) and `play_synth_phrase` (S0) add the lesson service's own sentence to the offered definition when the service gives one (`offer_note(agent_id, thread_id)`): hearing's after its own note, the synth's after the description. The call sits inside each block's `try`, so an `offer_note` that raises withdraws the tool it was for (D22: a tool is never offered without its disclosure while a lesson records). The synth definition with the note is kept out of manifest deferral like hearing's. No method is added to `WorkItemAgenticExecutor`, and a registry-refused agent is neither offered the tool nor is the service asked about it.
- `finalize.py`. `_wire_audio_floor` builds one `AudioFloor(tts_wait_s=lessons.tts_wait_seconds)` when music or hearing is enabled, lessons or not (D10), and leaves `runtime.audio_floor` `None` otherwise. `async _wire_lessons` builds the recording store and the lesson service when `lessons.enabled`: one WARNING for each runtime part the lessons need and the runtime lacks (`music_host`, `practice_records`, `hearing_control`, `audio_floor`, `creative_output_writer`, `chat_thread_store`, `callsign_registry`, `data_dir`), then the service's `reconcile()` with a 30 s deadline (`LESSON_RECONCILE_S`) BEFORE `runtime.lessons` and `runtime.lesson_recordings` are set, so a lesson a previous boot left open is closed as `restart` (one `lesson_changed` for each) before anything can start one. The deadline limits what the reconcile starts, not how long one call may take: a recording-store call cannot be cancelled and runs to its end first, so a call that hangs holds the boot (the constant's comment and the docstring say so). A reconcile that raises, or is still running at the deadline and is cancelled there, closes the store and leaves lessons off; a cancellation of the wiring closes the store and is raised again; a service that cannot be built closes the store and its error propagates. One INFO line per allowlisted type with its callsign. `_wire_music` hands the practice record service `runtime.records_store` (or `None` when the runtime has none) as its records reader. The two calls sit on the lines directly after `_wire_hearing`.
- `shutdown.py`. `_close_lessons` closes the recording store directly after `_close_hearing`. It writes nothing (D18), so a lesson that is open stays open in its record for the next boot's reconcile; the close is idempotent, and one that fails is logged once and not raised.
- `synth_phrase_tool.py` (found by the first review round: the floor made it visible). A synth call refused because a listen holds the floor told the model "The synthesizer voice is still playing another phrase"; S1's own `busy` sentence names both causes, the synth's named one. `_sounded` now marks that refusal in `PlayOutcome.detail` (`FloorBusy.held_kind == "capture"`) and `_settle` answers it with "A listen is running, so nothing was played. Try again when it has finished." The reason stays `busy`, the take is discarded as before, and no lesson code reads a play's `detail`. L4c1's tests had asserted the status, not the sentence.
- `lesson_port.py`, `lesson.py`: docstring edits only (the Architect's text; with docstrings stripped, `ast.dump` of both files is unchanged). The port's and the public service's docstrings said when the service answers `None` ("without a lesson open for her ... answer ``None``", "another agent's call ... answers ``None``"), which is false for a lesson open in another conversation (`lesson_elsewhere`) and for a failed expiry or pause write (`lesson_not_saved`, which `_LessonBeats.begin_beat` can answer to any caller). The conditions are now stated once, at that provider (its docstring lists `lesson_not_saved`), and the consumers' docstrings say only what the call answers.
- Tests. `tests/test_ad1378_s2_wiring.py` (56 cases) runs the real route, intent bus, executor, tool registry, practice record service, Ship's Records store, hearing control and listener, music host client (stand-in workers), audio floor, recording store and lesson service, wired by the shipped functions: the whole loop once (the offer, both tools, `lesson.json` with committed recordings, the take record with the lesson's fields, both definitions whole under an armed manifest), the offer notes (a lesson open here, none, in another thread, another agent's, expired, muted, a refused agent, a raising `offer_note`), `_wire_audio_floor`, `_wire_lessons` (off and silent whatever the runtime lacks; each of the eight parts as an absent attribute and as `None`; the deadline (30 s, and a store call that is running at it ends before lessons stay off); an empty allowlist; the previous boot's open lesson closed before publication; the stasis; the thread check; a reconcile that never ends, raises or is cancelled; a service that cannot be built), `records=`, the order of the calls in startup and shutdown, and `_close_lessons`. `tests/test_ad1378_s2_tool_hooks.py` (85 tests) gains the synth sentence for a floor held by a listen: the `floor_busy` exactly-once row and the floor-serialisation test assert the message, and the latter that the sentence holds none of the words S0's own test keeps out of what the agent reads ("violin", "you heard", "you hear it"; S0's list is `MESSAGES` and the descriptions, which the new sentence is not part of); `test_a_floor_held_for_a_play_tells_the_synth_another_phrase_is_playing` pins S0's own `busy` sentence for a floor held by a play.
- One visible change on a vessel with lessons off: with music or hearing on, the audio floor now exists, so a play while a capture is running, or the reverse, answers `busy` (D10); a synth call refused while a listen holds the floor now says a listen is running. The pull request for S2 says so. No speech wait happens until L5's `/api/audio/tts-playback` exists.
Review: three rounds and one Architect decision. Round 1 read the whole slice and found eight things: a reconcile bound that did not bound startup (the recording store never abandons a thread call, so the wiring waits for the one it is in; the Architect decided that "bounded" means a deadline on what starts, and the words and a test now say so), a regression of this wiring (the synth answer above), a service that could not be built leaving the store open, and five test and comment faults (a fixture that left a profile store open, a comment with the wrong idle limit, a marker that named an unused guard, two unused fixture options (deleted: the size finding), a thread assertion that compared names). Round 2 read the repair and found that the new capture sentence was pinned only by the constant that supplies it, so the old false sentence passed the tests; the tests now carry the sentence as a literal. Round 3 read that repair and found nothing. Hand mutants: three campaigns of 58, 67 and 69 rows with 56, 65 and 67 killed; the two survivors in each are equivalent (a redundant reset of a variable inside an `except`, and a second `close()` of a store whose `close` is idempotent). Exit run on the final tree: 2,717 passed; the event types stay at 394 and the architecture check is unchanged (`srp-size` 93).
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
L4c1 and L4c2 were reviewed (five and three rounds) and decided some things the contract did not say, or said wrongly. This records them as A130 to A136 and corrects the places that said otherwise. - A130 and A131: the two tools' hooks live in `tools/lesson_hook.py`, outside S1's pinned `_listen`, and a lesson play finishes through one owned tail kept in `SynthPhraseTool._closing`. - A132: a fault inside a lesson answers exactly as S0 or S1 would (nothing is appended to `error`; the `lesson` block stays in `output`). Section 4's "plus `lesson.next` (unchanged)" said the sentence was unchanged; the completion computes it, and only the lesson's state is unchanged by a fault. - A133: `begin_beat` can answer `lesson_not_saved` to any caller whose settle of an expiry or a first pause cannot be written, another agent's included. D12's list of its answers, A84 and section 4's "Another thread" paragraph said otherwise. - A134: "bounded at 30 s" for the boot reconcile is a deadline on what starts, not a limit on one call (a recording-store call cannot be cancelled and runs to its end first). A hard bound is recorded as deferred, with the reasons the abandoned owned task was rejected. Section 15's file row says so. - A135: the recording store is closed on every path that does not publish it. - A136: a tool the floor refuses says why by the kind of hold (a synth call refused while a listen holds the floor no longer says another phrase is playing), with the visible change on a vessel with lessons off recorded for the S2a pull request. D10 points to it. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… (AD-1378 S2)
The reviewer checked revision 2p's new clauses against the code by executing them, and nine were wrong or too broad. Corrected:
- Section 15's file row said the reconcile is `await runtime.lessons.reconcile()`, but `runtime.lessons` is `None` while it runs (the wiring calls its local service). Its description of `_wire_lessons` also said one INFO line for the reason, "starts nothing" and a different condition; both now say what the code does (one WARNING for each missing part, silent when lessons are off, the store's own I/O threads start with the reconcile).
- A133: a first pause that cannot be written is answered with the refusal the call had already chosen (`hearing_muted` for the lesson's own agent, `lesson_elsewhere` for her other threads); `lesson_not_saved` is for the call that chose none, which is another agent's. An expiry that cannot be written is always `lesson_not_saved`. D12's `None` no longer says "byte for byte": the shared floor still applies.
- A131 and A132: settlement receives the lesson fields, and a take that is discarded or cannot be written carries nothing; the `lesson` block is in `output` when the call holds a ticket (a failure before that is S0's own answer). The duplicated `lesson.next` formula, which left out the closed cases, is replaced by a pointer to `_feedback_of`. Section 4's failure paragraph is limited to beats that hold a ticket, adds `retention.events`, and names the separate paths (a refusal before the ticket, the muted pre-check).
- A135: the store is closed when the service cannot be built, the reconcile fails or passes its deadline, or the wiring is cancelled; an exception that is neither an `Exception` nor a cancellation propagates without the close.
- A136 and D10: only the synth tool distinguishes the kind of hold; the hearing tool's sentence names both causes.
- Section 4's "Another thread": the lazy expiry runs first, so an overdue lesson is closed and the call is lesson-free.
- A42 and section 9 quote the comment S1's test now carries ("the lesson hook and the floor are runtime attributes the tool may read").
Three older passages the check found stale are left for the follow-ups list, because revision 2p did not touch them: A88's account of what `begin_beat` writes and which second call is `busy`, section 9's `observe_muted` step, and section 9's blanket byte-identical sentence.
Text only.
Refs #1935.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… too broad (AD-1378 S2) The delta check of the revision 2p amendment executed the repaired passages again, and three clauses claimed more than the code does. Corrected: - A132: a call that holds a ticket does not always get a `lesson` block. The completion supplies none when the service raised (`lesson_call` answers `None` and the tool goes on without one), so the clause now says "when the call holds a ticket and the completion supplies feedback". - Section 4's failure paragraph: the muted pre-check (`observe_muted`) may settle a pause, but it writes none when the mute has lifted since the tool read it; it now says "may settle a pause and adds no event or beat". - Section 4's "Another thread": `lesson_elsewhere` follows a lazy expiry that has been settled and left her lesson open. An expiry that cannot be written answers `lesson_not_saved` instead (A133). Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… more than the code does: revision 2q (AD-1378 S2) The claims check of revision 2p found three passages that predate it and are stale against the built code; a search for the same words found two more. Each is corrected in place and tagged "(revision 2q, A137)", and A137 records them. - A86 and section 9's `play_synth_phrase` step 6: "a result outside a lesson is byte-identical" is true of the `recorded` field, which lives only in the `lesson` block. It is not true of the whole result, because the two tools share the audio floor (A136, D10). The step now says the block is added when the completion answers one (a completion that raised answers none). - Section 9's closing line for a play with no ticket: step 1 still runs when a service is wired (it answers `None`), `complete_play` is not called, `record_to` and `lesson=` are not passed, and the result is S0's own except where the shared floor refuses the call or holds it for speech. - A88: `begin_beat` writes the closing record of a lesson that ran out, and a first-seen pause for any call that is refused or makes no move while the lesson's agent is muted (another agent's call included); a second `begin_beat` gets `busy` only from the lesson's own agent in her conversation while a ticket is out, after `lesson_elsewhere` and `hearing_muted`, and another agent's call answers `None`. - Section 9's step 0 of `listen_to_sound`: `observe_muted` writes a pause only for a first sighting of the mute; if the mute has lifted since the tool read it, it writes none and the block says what comes next. - Section 26's second criterion: with lessons off the tools are S0's and S1's except for the shared audio floor, and every lessons route but `GET /status` answers 503 `lessons_unavailable`. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eck (AD-1378 S2) The reviewer executed revision 2q's clauses against the code and found five that were too broad, plus three older passages that still called the tools "unchanged". Corrected: - `observe_muted` (section 9 step 0 and A137): it answers `None` when the lesson was closed while the call waited, not when it "ran out" (a play ticket defers a close, and a failed expiry write leaves the lesson open, and the call still gets a block); and the block follows the service's own reading of the mute under its lock, not whether the mute lifted since the tool read it (a mute that lifts during the pause write still gets the paused block). - A88 "what writes": `begin_beat`'s deciding step writes at most a first-seen pause; the clean-up of a cancelled call can also write the close that a held End was waiting for (A108, `_begin_beat` -> `_give_back` -> `_released`). - A88 and A137: another agent's call answers `None` unless an expiry or first pause it settles cannot be written, when it answers `lesson_not_saved` (A133). - Sections 2 and 20 and the K3 review row: "unchanged outside a lesson" now carries "except for the shared audio floor (D10, A136) and the lesson service's refusals where they apply (D12, A133)". - Section 26's second criterion and A137: the 503 of every lessons route but `GET /status` is for a request that passes the crew-scope gate and, where the route reads a JSON body, the parsing of that body (a missing token is 401 and an unparseable body 422 first). A137 now says eight passages and names the two claims checks. Text only. Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…en no lesson of hers is open, not when "the" lesson closed (AD-1378 S2)
The claims check of the 2q repair ran one more case through the real hearing tool: a lesson for the same agent in the same conversation that was opened while a muted call waited for the service's lock got a `lesson` block, so "answers `None` when the lesson was closed while the call waited" (A137, section 9 step 0) was still too broad. `lesson.py`'s `observe_muted` answers `None` when `_hers(self.live, agent_id, thread_id)` is false at the call, and again when it is false once the call's `_step` has run; otherwise the block is built from the lesson that is open then, which can be a later lesson than the one the call began with (an End and a new start can both run while the call waits). A137 and section 9's step 0 now say exactly that.
Text only: two lines of `prompts/ad-1378-s2-the-lesson-loop.md`, +2/-2 (CRLF kept: 1,126 lines, no bare LF). The comment on that `None` return in `lesson.py` ("it ran out while the call waited") is narrower than the check; it is recorded as a follow-up, not edited here.
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ch signal (AD-1378 S2 L5a)
The lesson service, the recording store and the audio floor (L1 to L4c2) now have the Captain's side: ten routes under `/api/lessons` and one under `/api/audio`, all behind `require_crew_scope` (contract section 10; D9, D11; A11 to A18, A137 and A138). Nothing is on by default: with `lessons.enabled` false every lessons route but `GET /status` answers 503 `lessons_unavailable`, `/status` answers 200 with `enabled` false, and the speech signal answers 503 `audio_floor_unavailable` while no audio floor is wired.
- `routers/lessons.py` (new, 459 lines). `GET /status` (whether lessons are on and for whom, the open lesson, the floor, the bytes kept); `POST /{agent_id}/start` (a slot id, a certificate UUID or a `did:probos` DID; the agent's type must be on the lessons, music and hearing allowlists, and the conversation must be one she is in); `POST /{lesson_id}/next-round`, `/skip-retention` and `/end`; `GET /api/lessons` (the lesson records, newest first; a row the HXI's validator would refuse is moved to `unreadable`, as a file that cannot be read is); `GET /progress`; `GET /recordings` (grouped by lesson, newest lesson first, each lesson's recordings oldest first by `(created_at, recording_id)`, no path anywhere); `GET /recordings/{id}/audio` (a `FileResponse`, `audio/wav`, `no-store`; 410 for a recording the Captain removed); `POST /recordings/delete` (a Captain order: 403 while no crew-scope token is configured, at most 50 ids, `confirmed` the JSON value `true`). A refusal of the service answers `{"detail": "<code>"}` (the muted start: `{"detail": {"code", "message"}}`) through one table, `REFUSAL_STATUS`, which a test holds to every code the service constructs. The routes emit nothing and call the recording store through `list_recordings`, `total_bytes` and `audio_path` only.
- `routers/audio.py` (new). `POST /api/audio/tts-playback` forwards the HXI's utterance starts and ends to the audio floor (204; a repeated start renews its lease).
- `api.py`: the two routers are imported and included after hearing's (two imports, two include entries).
- Decisions the review made (contract revision 2r, A138). The three action routes take **no body**: a body of any kind is refused 422 `body_not_allowed` before the service is asked. FastAPI would have ignored it, and in the first review round an array body advanced a round, malformed JSON ended a lesson and an extra-key object skipped the retention check; the HXI posts these three with no body and no content type. The order of a refusal is the gate, then 503, then the agent, the token or the no-body rule, then the body's schema, then the service (`_lesson_agent` is a dependency, so a request for an absent agent is 404 whatever its body). A request that fails its schema answers 422 with a list `detail` of `type`, `loc` and `msg` and no `input` (`_RefusalRoute`, a router-scoped route class: FastAPI's own answer echoes each refused input, and NaN or an infinity in a body turned it into a 500); a body FastAPI cannot read is refused by FastAPI first (422 `json_invalid` for text that decodes but is not JSON, 400 for bytes it cannot decode), the gate included. **Deviation:** `_RefusalRoute` is copied in the two routers (follow-up HT shares it).
- Tests. `tests/test_ad1378_s2_routes.py` (new, 39 test functions) runs the real routers over a runtime that the shipped wiring built (`_wire_creative_expression`, `_wire_music`, `_wire_hearing`, `_wire_audio_floor`, `_wire_lessons`), through `httpx.ASGITransport` on the test's own loop: the gate on all eleven routes; each refusal's status and body; the removal (token, confirmation, 50 ids, the four outcomes, a store failure, a cancelled request that still settles, the seam to the files and the events); 410 and `no-store`; that the routes emit nothing; the answers' shapes against the HXI's fixtures and the rules of its validators (ported, and compared with the literal TypeScript by a reviewer); every route total over malformed input with the state unchanged (over a hundred rows); a real-app test that `create_app` mounts each route once and that the real gate fails closed until a token is set. `tests/test_ad1378_s2_boundaries.py` pins the labels (D17), that the removal's one caller is the route's `delete_recordings`, that the routes use three store methods only, and that they import no `EventType`.
Review: three rounds by the Diff Reviewer (GPT-6.1 Sol). Round 1 (the whole candidate): not ready, eleven findings, all repaired, one Size finding (a redundant union in a test, deleted). Round 2 (the delta): not ready, Size 0; the HXI's request shape was stated wrongly (it posts the three actions with no body and no content type), bytes the decoder cannot read answer 400 and not 422, and the routes test rig left `threads.db` connections to the garbage collector: all three repaired; the OpenAPI failure is pre-existing and recorded. Round 3 (the delta: docstrings and test rows only, production code equal to round 2 once docstrings are stripped): READY, Size findings 0; the reviewer ran the literal HXI calls against a real `create_app` and detected 18 targeted counterfactuals. Hand mutants: two campaigns of 112 (r1) and 128 (r2) rows; on r2, 125 killed and 3 survived, all three equivalent (a removal body model that is not strict, which JSON cannot tell apart; an infinite `expected_s`, which the bounds refuse; and an agent check that need not wait for the 503, because `start_lesson` declares the availability dependency first). Exit on r2, 38 test files: 3,005 passed; the event types stay at 394; the architecture check, the config facade check and the config profile check are unchanged (93/0/30/13; 314/301/13/232/1907; 3/58/171/229/58). Size findings: one in round 1 (a redundant union in a test, deleted), none since.
Found and recorded, not fixed here, and both already tracked: `create_app(...).openapi()` raises when the HXI bundle is absent (`api.py` fallback route's `HTMLResponse` annotation; reproduced before this change; F-141 on #1523), and `ChatThreadStore` leaves its SQLite connections to the garbage collector (the test rig collects them itself; item T of #1876).
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…1378 S2) L5a's three review rounds (READY at round 3; committed as 0df0e30) decided things the build prompt did not say, or said differently. They are recorded as A138 (a to i), and the passages they touch are corrected in place and tagged "(revision 2r, A138)": section 8's audio route bullet, section 10 (the three action routes' row and the Errors, `/status`, `/recordings`, delete bullets and the closing line), section 15's Section 5 split, section 16's routes row, and A16. - The three action routes take no body: a body of any kind is refused 422 `body_not_allowed` before the service is asked (the HXI posts them with no body and no content type: `lessonAction` goes through `crewScopeFetch(url, {method: 'POST'})`). - The order of every refusal: the crew-scope gate, 503 `lessons_unavailable`, the resource or the token or the no-body rule, the schema, the service. FastAPI reads and decodes a JSON body before it solves any dependency, so a body it cannot read is refused first, the gate included: 422 `json_invalid` for text that decodes but is not JSON, 400 for bytes it cannot decode (UTF-16 and UTF-32 JSON decode). The three actions declare no body, so for them the gate comes first. - A schema refusal is 422 with a list `detail` of `{type, loc, msg}` and no `input`: a stated exception to A16 (`_RefusalRoute`). - `GET /recordings`: the order of a group's recordings, a group's callsign, and that a recording is listed only when its lesson is a row `_listing` shows. `GET /status`'s `enabled`. A list row the HXI's validator would refuse. The recording-store calls the routes make. - The real-app mount test, and the split of section 5 into L5a and L5b. Text only. Probes behind it: the no-body forms, the order of refusal, the decoder's 400. The claims check of this revision comes with revision 2s. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The lesson loop (L1 to L5a) now has its seam tests: a lesson that goes in at the Captain's routes and the chat route, through her real tools and the shipped wiring, and comes out at the files and the route answers, over stand-in workers for the music host and the hearing worker; and the retention guards of contract section 17. Tests only: nothing under `src/` changes (section 15's Section 5, A138(i)). - `tests/test_ad1378_s2_e2e.py` (new, 8 tests). One full lesson on a Twinkle fixture (start, four beats, a retry that completes the round, the take records bound to his words, the record, the recordings and their sidecars, the events); two series of three lessons, one whose first-attempt errors fall and one that stays level, with the direction the progress route gives; delete-then-progress-unchanged (the removal's figures, the tombstones, the records' "removed" marks, and a later take bound after the removal, whose record still says removed); the retention check at the next lesson; the mute mid-lesson (a stand-in worker that holds its capture open and marks its steps in a timeline file: the test waits for the worker's own mark, posts the mute, and observes the real listener's own outcome for that beat, with the listener's deadline moved out of reach so that only the mute's stop can end the listen; the mute ends the worker, nothing is recorded, and the same beat is retried on unmute); a second runtime built on the same model after a restart that chats through the new runtime (the restart forgets the first runtime's model, so the chat connects it again); and start refused while muted. The Twinkle fixture `tests/fixtures/ad1378_s2_twinkle_reply.json` is a worker reply for the phrase. - `tests/test_ad1378_s2_retention.py` (new, 6 tests). G1 no reset tier touches a lesson's recordings (all tiers, the default root and a configured one); G2 records and recordings survive a restart, and a second runtime built by the shipped wiring settles what the first left; G3 episodes keep their activation across a stasis, **skipped** until BF-1018 (#1927) merges; G4 a lesson writes nothing under notebooks; G5 recordings are outside every reaper's root (the attachment store's and the browser recorder's, with the recorder's directory resolved against the process's current directory as production resolves it); G6 lesson history survives a full reset as culture (an earlier crew's lessons are listed as records, progress and the retention check read only the current crew's, and a successor's start says so). Review: gpt-6.1-sol, four rounds (the first on the whole candidate, the others on the delta). Round 1: not ready, Size findings 1, seven findings, all repaired: the mute test had a one-second success window (a 1.36 s delay of the test's reaction made it fail) and passed when the mute's kill callback was omitted (the worker now holds its capture open and the test waits for its own `hold_began_at` mark, so only a mute that stops the worker passes); G5's browser half could not fail (production reads the recorder's directory against the process's current directory, and the test never set it); a sidecar's `timeline_id` could be null with no failing test; G6 never started a successor lesson with retention; the deletion test ended before the later write of the take record that the removal must survive; and unused plumbing. Round 2: not ready, three findings, all repaired: the mute test still had a window of its own (a reaction 31 s after readiness failed it although the listener's deadline had not passed, because the worker finished its capture after 30 s), `restart()` left the first runtime's model cached so that a chat with the same model still went through the first runtime, and an unused option on the initial listener. Round 3: not ready, Size findings 1, and three findings. The repair of round 2 had made a broken mute pass: with the worker holding 120 s and a reaction between 15 and 44 s, the listener's own 45 s deadline (30 s of analysis margin after the 15 s capture bound) ended the worker, and the tool's mute latch turned that result into `muted_while_listening` whether or not the mute had stopped anything (P2, regression); nothing committed pinned that `restart()` forgets the first runtime's model (P3); the `frames` argument of the harness is fixed-value plumbing (P4, size; filed). The Architect's round-three brake judged the design sound and allowed one more round on it: the mute test now observes the real listener's own outcome for the beat (it must end `muted` and by the mute), moves the listener's deadline out of reach for that turn so that only the mute's stop can end it, and a new test pins the restart. Round 4: ready, Size findings 0. The reviewer first reproduced both round-3 weaknesses on the previous candidate (a mute that stops nothing passed at a 20 s reaction; a listener whose kill records the reason but never stops the run passed at 31.4 s), then found nothing on this one: with the control's stop omitted, or the listener's kill not stopping, the mute test fails at every reaction from immediate to 44 s; a reaction beyond the 60 s turn timeout is not accepted as a mute; reverting only the deadline change restores the false pass (so the observer and the deadline are both needed); the observer reads the outcome the listener returns, and the deadline is longer only for the muted beat; the new restart test fails when the model reset is removed. Evidence on clean exports of the final candidate: 56 hand mutants on the production seams these tests guard, 56 killed (the 52 of round 1 left three alive, D5, V3 and V4, each now killed; the three added for the repaired seams and the two for the mute's stop, the control that never kills the listen and the listener whose kill never stops the run, are killed); the mute test was also run with the test's own reaction delayed by 0, 31 and 44 s: a correct mute passes at every delay, and a mute that stops nothing fails at every delay (the candidate before round 4 passed that mutant at 20 s); both files three times in a row and in reversed order, 13 passed and 1 skipped each (17 to 20 s); the 42-file exit run on a clean export passed: 3,056 passed, 1 skipped (the BF-1018 guard) in 625 s; the event types stay at 394 and the architecture, config facade and config profile checks are unchanged (93/0/30/13; 314/301/13/232/1907; 3/58/171/229/58). Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
docs/architecture/lessons.md (new) describes the lesson loop as it is built: what a lesson measures, keeps and lets the Captain delete; the machine's six states and the sentence she is given in each; the retention check; the Captain's words as the verdict and his controls during a lesson; what a mute does (it pauses the lesson); the lesson and take records and where they live; the recordings, their removal and the audio floor; what she is told; the retention guards; the routes, the order a request is refused in and the bodies; the HXI's Lessons tab; how to turn it on; what it is not. hearing.md and expressive-output.md gain the recording sections (the worker writes the file, no reply carries samples, a late cancellation can leave a file that the lesson service discards), docs/research/reference-projects.md the mir_eval entry the S2 contract section 19 decided, and mkdocs.yml the page's navigation entry. Docs only: no code, test or config changes. Review: every sentence was checked against the code by gpt-6.1-sol, which executed the cases each one describes, in four rounds. Round 1 (the whole page): not ready, thirty items (eight P2 and seventeen P3 on ordinary paths, five that only an injected storage fault reaches), all repaired. Round 2 (the delta): not ready, one P2 (the summary of when audio is kept ignored the boot adoption of a finished orphan, a regression of the first repair) and nine P3, all repaired by exact replacements and their twins; one more, a failed `lesson.json` rename after a removal, only an injected storage fault reaches and is recorded. Round 3 (the delta): not ready, three P3 in older clauses (a play's recording "kept if" hearing reads unmuted, the hearing page's "the vessel keeps it", and "change no state" and "the same beat is retried" with no mention of a pending End or expiry), none a regression of a repair. The Architect's round-three brake judged the design sound (the page states each rule once and points to it) and allowed one more round on the delta only, with no fifth round. Round 4 (the delta: the reviewer's four narrowings, two sweep edits, and the same one-word narrowing in the contract's D20): ready, Size findings 0, each changed sentence confirmed by executing the case it describes (an unmuted completion keeps a successful recording but not a cancelled play or one whose write failed; committed recordings survive the boot reconcile and the Captain's deletion turns the audio route from 200 to 410; failed plays settle a pending End or expiry as closed; a muted listen can be retried only while the lesson is open; recovery adopts an unmarked orphan and removes a marked capture); one finding outside the delta, the contract's unchanged mid-listen sentences in D20, which have the same missing qualification, is filed and not repaired. The same mistake in every round was a sentence true on the usual path written as if it held on every path (a recording is kept only if hearing reads unmuted when the beat completes, which boot recovery's adoption of a finished orphan does not obey; a result shape that differs when the mute lands between S1's check and the beat's start; a recording report that a late cancellation omits; a failure that changes no state while an End is pending). Findings that only an injected storage fault reaches, and code defects the page had to describe as they are (the pinned pause sentence, offer note and banner), are recorded for the follow-up issue and not repaired here. Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
prompts/ad-1378-s2-the-lesson-loop.md. Revision 2s corrects the clauses of the contract that said more than the code does. A second model found them by claims checks that executed the cases: the L7 docs page against the code, then the contract's own changes since revision 2q, then the corrections themselves, in four rounds (round 1: eight P3; round 2: one P2 and four P3, the fifth being the pause sentence below; round 3: one P2 and three P3; round 4: two P3). Each is recorded in the amendment log as A139 (a to r): the next-round skip in the retention check; a play admitted unmuted that runs through a mute; the phrase listened to more than once before her single attempt; a play cancelled after its file was written; a recording reference that never holds an audio path; `tts_signal` read once, at the start; a sidecar adopted after a crash; the label's two limits and start's 503; a tab that never unmutes by itself; a kill after a listen's write that leaves its file; retention that stays null when it was not requested; an empty callsign that counts; the by-ear attempt; the results the tool hooks leave unchanged while the floor is free; the Why cells of D2 and D20, which said a recording exists only if its beat completed unmuted and left out the file a crash can leave behind (D7); and D20's sentence that an unmuted reading keeps a play's recording, which only allows it to be kept (found on the docs page by its third check, and narrowed to "may be kept").
The mute readings are the part that took four rounds: the contract had said, path by path, whether a completion reads the mute, and every round found one more path (a stale ticket, a clean-up step, a mute that lands late). At the round-three brake the Architect judged the design suspect (the contract counted readings that the code takes by one rule, copied into three places) and decided to continue with the longer text, and to cut it to the rule if round 4 found anything in it. Round 4 did: the clean-up of a completion whose record could not be written reads the mute again, so even "a mute that lands during the store work is not seen by that completion" was too wide, and a finished WAV that a Windows lock left behind with a discard marker is removed at the next boot, not adopted, so D2's new wording about a crash was too wide too. D20 now says once which reading of the mute decides a completion's file (the main step's, under the service's lock), that a mute landing after it does not change that decision, and cites the docstring of the service's locked step (`lesson.py:2496-2508`) for what a stale ticket's step and a clean-up step read; the amendment log points to it, so a wrong sentence can live in one place. D2's Why cell says a finished, unmarked WAV may be adopted after a crash (D7). There was no fifth round, as the Architect decided. The pause sentence that the service, her offer note and the HXI banner say ("nothing is listened to or recorded until he unmutes it") is wider than a play admitted before the mute can be; it is recorded for a coordinated change of the three strings and their tests (section 24, item 12) and is not changed here. Text only: no code, test or config changes.
Refs #1935
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…2009; BF-985 #2011) into the S2 lesson-loop branch Main moved to 107b6df (eight pull requests: the AD-1391 test selector slices, BF-1008 residuals, BF-985's rollback flush and BF-1030's timing marker). No conflicts: the S2a files and main's overlap only in host_client.py and shutdown.py, which merge cleanly, and the trackers, which are edited after this merge. Rehearsed first with git merge-tree and in a scratch tree (tests/test_run_test_gate.py 116 passed, 1 skipped; the AD ledger check current). Refs #1935 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dger Text only, after merging main. PROGRESS.md gains the S2a entry (the lesson loop, L1 to L7, and what is not done), DECISIONS.md the S2 decisions (D1, D4, D5, D7, D9, D10, D16, D20, D21 and D22, with the reversal), and the AD/BF ledger pair is regenerated with scripts/gen_ad_ledger.py (tests/test_ad1184_ad_ledger.py passes). Refs #1935. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 of 87 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1935
What changes
The Captain can teach Ezri a phrase by ear. In the HXI's Lessons tab he starts a lesson on a phrase for a crew member he has enabled; he plays the phrase on his violin and says so; she listens (
listen_to_sound) and answers by playing it back on her synthesizer (play_synth_phrase); he plays the correction; she listens and answers again: the four beats of a Suzuki round, repeated for as many rounds as he wants. Every lesson leaves a record of what she got right and wrong, and the recordings are his to keep or to delete. It is off by default, and merging it changes nothing for a vessel that has not enabled it (the steps are below).LessonService(probos.skills.violin.lesson) holds at most one open lesson ship-wide, bound to one agent and one conversation. Each of her two tools asks it to bind the call to the beat it is (begin_beat), then tells it what the job did (complete_listen,complete_play); tool descriptions do not change, and what to do next reaches her in the result'slesson.nextsentence. A call out of turn is refused with a plain sentence about what comes next. The service never calls her model and never starts her turns.compare_attempt): wrong, missed and extra notes, and the median onset error in milliseconds. Her notes are what she chose and the instrument renders them exactly, so a right note's cents figure is his intonation, not hers; the headline pitch measure is wrong or missed notes, and cents are kept and labelled as including his intonation. Progress compares each lesson's round-1 attempt (her answer before any correction) across a phrase's lessons, per crew, and gives a direction word with the whole series: three points give a direction, not a trend, and the output says so.creative/<callsign>/music-lesson-<stamp>-<id>.md(a fenced JSON block is the authority) and<root>/<lesson_id>/lesson.jsonbeside the recordings, which is written first and is what progress and reboot reconcile read. The Captain's words about a take stay verbatim in the take record; the lesson record only references them. A recording enters a record as an id and figures, never a path.record_to, after the play or the analysis succeeded, 24-bit WAV), committed with a sidecar, and kept inlesson-recordings/under the data directory until the Captain removes it:POST /api/lessons/recordings/deleteneeds the crew-scope token andconfirmed: true; the sidecar is tombstoned (the figures stay), then the WAV is unlinked, then the records say "removed by the Captain on ". No agent tool, and nothing but the router and the service, calls the store'sremove_by_captain(an AST test pins it). The recordings directory is one name in a reservedlesson-namespace that no reset tier,--clean-slatedirectory or UUID clear names (a test enumeratesRESET_TIERS).probos.audio.floor.AudioFloorserialises her phrases, the captures and her speech playback: a second hold anywhere is refused at once withbusy, and a hold waits (at mostlessons.tts_wait_seconds, 20) while the HXI says her voice is playing (POST /api/audio/tts-playback). With no signal at all, holds proceed at once and the lesson record saystts_signal: "none_seen". It is built whenever music or hearing is on, because both of her tools hold it even outside a lesson.hearing_muted: they take no beat and do not advance the state, so round and beat stay (the Captain's End, or the idle expiry, can still close the lesson). A mute mid-listen kills the worker and discards the capture, and, while the lesson is still open, the same beat can be retried after he unmutes. A play that is already running is not stopped by a mute, but its recording is discarded if hearing reads muted when it completes. The service reads the mute and keeps no copy, and it never unmutes.lessonblock repeats it withrecords_audio: trueand whether this call was recorded. Nothing scores her on any of it.timeline_id. Progress, the retention check and the qualification read only the current crew's lessons; an earlier crew's lessons are shown as records, not her memories, and a successor's firstlesson.nextsays so. The retention check (her first play from memory, measured against the previous lesson) isnot_applicablefor a crew with no lesson of its own.require_crew_scope):GET /api/lessons/status,POST /api/lessons/{agent_id}/start,POST /api/lessons/{lesson_id}/next-round,/skip-retentionand/end(these three take no body),GET /api/lessons,/progress,/recordingsand/recordings/{id}/audio,POST /api/lessons/recordings/delete, andPOST /api/audio/tts-playback. The HXI's Lessons tab and its speech hold shipped with the HXI change (AD-1378 HXI) and read a 404 as unavailable, so the tab goes live with this backend.LessonsConfig(six fields, off by default), two durable events (lesson_changed,lesson_recordings_removed),record_toon the music host'splayand the hearing worker'slisten, the faculty pagedocs/architecture/lessons.mdand corrections tohearing.mdandexpressive-output.md, and the contractprompts/ad-1378-s2-the-lesson-loop.md(revision 2s, with every decision and the readings the reviews accepted).In existing code: the two tools gain their hooks (outside a lesson each answers as before, except that it holds the audio floor while it works, and a synth call refused while a listen holds the floor now says a listen is running); the two offer blocks in
agentic_dispatch.pyadd the service's sentence when it has one; the wiring is instartup/finalize.pyand the shutdown instartup/shutdown.py; the take record (practice_record.py) gains optional lesson fields that stay null outside a lesson; both workers' wire protocols gain an optionalrecord_torequest field and arecordingreply field.What the Captain runs after the merge (a restart is needed)
Nothing here records until he gives his go and does the following. His
config/system.yamlis not changed by this PR.musichost-fetch.ps1, thenmusichost_smoke.py) and S1's (hearing-fetch.ps1, hishearing.json,hearing_smoke.py). Lessons needmusic,hearingandcreative_expressionenabled and the crew member's role on both themusicand thehearingallowlists as well as the lessons one.config/system.yaml:lessons: {enabled: true, crew_allowlist: [counselor]}(the other fields default:recordings_dir: lesson-recordings,idle_minutes: 20,max_minutes: 90,tts_wait_seconds: 20).ui/distonly if he has not since AD-1378 HXI.What this does not claim
Tests changed knowingly
Eleven existing test files and two fixtures changed, each a pin or a stand-in the new code moves; the generated baselines move with them.
test_ad1195_durable_event_seam.py,test_ad1195_durable_producers.py,test_ad1195_event_persistence_contract.pyandtest_ad1195_eventlog_pair_freeze.py(the two new events are routed durable members:EventType392 to 394); the defaultSystemConfigdump intest_ad1152_agentic_correlation.py(lessonsis popped with its six defaults asserted, as S0 and S1 did formusicandhearing);test_ad1270e1_config_facade.py; the file-write census (test_ad1346_admission_file_write_census.pyandtests/fixtures/ad1346_file_write_census.py: the recording store is a file writer);test_ad1378_s0_practice_record.py(the take record's optional lesson fields, null outside a lesson);test_ad1378_s1_hearing_tool.pyandtest_ad1378_s1_protocol.py(the field-set pins of the listen reply, which gainsrecording, with a comment each); and the two stand-in workerstests/fixtures/fake_hearing_worker.pyandfake_musichost_worker.py(they write a recording when asked, and the hearing stand-in can hold its capture and mark its steps in a timeline file).docs/development/config-facade-baseline.yaml,config-profiles.yamlandconfig-reference.mdare regenerated for thelessonssection. Eighteen test files and fixtures are new.Review and proof
Diff Reviewer rounds on
gpt-6.1-sol(pinned on every call and checked against the session log), a consolidated focused check on each frozen candidate, my own hand mutants of each milestone, and Architect decisions at the round-three brakes and on four design questions, recorded on #1935 and in the contract's A-rows. Every slice was committed only on a READY verdict whose Size findings were zero.record_to(music host)record_to(hearing worker)begin_beat,observe_muted,offer_notecomplete_listencomplete_playand the portThe first round of the larger slices found real defects, not style: L4b1's first round found a P1 (a rewritten take record could change who may read it) and the same class again in round 2; L4b2a's first round found eight P2 defects (a start admitted after a mute that came during its conversation check, controls counted as activity, and others); L4c2's first found that the boot reconcile's bound did not bound startup (the Architect decided that "bounded" means a deadline on what starts, and the words and a test now say so); L5a's first found that the three action routes ignored a body (an array advanced the round and malformed JSON ended the lesson).
prompts/ad-1378-s2-the-lesson-loop.mdis revision 2s: every decision, the Architect's cite checks and the reviews' findings as A1 to A139, each revision claims-checked against the code by a second model.scripts/run_test_gate.py) on the committed treec34e474c(the merge ofmainat107b6dfaincluded; 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,512 passed, 174 skipped, 0 failed (59,686 collected, 59,686 run) in 49 min 19 s on 12 workers, none lost; temp volumeC:.c34e474c(run 46905386185):python-tests-shard (1)to(3)passed in 14 min 2 s, 12 min 8 s and 12 min 8 s,ui-testsin 6 min 20 s,desktop-testsin 15 s, and the aggregatepython-testsin 18 s.create_app(...).openapi()raising whileui/distis absent is F-141 on Follow-up: residual findings from the #1239 / #1515 / #1511 wave #1523, andChatThreadStoreleavingthreads.dblocked on Windows until the garbage collector runs is item T of Follow-up: residual findings from the #1670 (BF-932), #1867 (BF-1005) and #1870 (BF-1006) wave #1876.