Repository navigation
Give duplicated Python helpers one home each, and fit generated thread titles - #5293
Merged
Merged
Conversation
…d titles Title limit. `registry.kernel.title_limit()` reads the kernel registry's `maxLength` on the `thread_title` event's `title`, and `thread.fit_title` is the one fit: it collapses whitespace and cuts at a word, ending in an ellipsis. The clerk and the page server's generated titles (`thread_titles.write_title`) both use it, and the CLI's `--title` help and `events.md` take the number from it. Behavior change: a generated title over 80 characters, or broken over lines, was refused at admission and left its thread untitled; it is now fitted and written. The six registry copies of the title schema stay inline. No kind's record refers to another's by `$ref`, and the protocol baseline compares a reference by its text, so the refactor would read as a protocol break. Band words. `hooks/claude-code.ts` can't import `activity-words.js`, whose imports reach the page's framework and Lit by server-absolute paths that no module loader resolves outside the page. The band keeps its words, unchanged on screen, and its comment no longer claims they are an All pages row's. Path locks. `locations.path_lock(*paths)` holds one lock per `path_lock_key` under `/tmp/leaf-path-locks-<uid>`, taken in sorted order. `package_write_lock` and file-binding saves both use it. Behavior change: a save to a bound file used to lock under `state_home()/files`, keyed by the path as stored. It now locks in the machine-local directory, keyed by the resolved path, case-folded on a case-insensitive volume, so two Leafs with different state homes serialize their saves of one file. The package locks' directory was `leaf-package-locks-<uid>`; the eval sandbox now allows the new name. Initialized pages. `event_log.initialized(page_dir)` says whether the page's log is a file and holds the rule in its docstring. The CLI's page argument, `page init`, reconnect advice, `owned_pages`, the package gate, command timing and the dev commands call it (`arrangement_eval` drops its guard, since `read_events` already reads a missing log as empty). The package gate no longer also requires `layer.json`, since init writes the layer record before the log. Behavior change: a directory holding an `events.jsonl` but no `layer.json` now counts as a page there, so its page-owned paths are protected. Log parser. `event_log._stored_events` is the one parse of the log (torn lines, seq by line number), and `_parse_events` drops the private session context from it for application readings. `interaction_log.read_interactions` reads the log through `read_stored_events` instead of splitting it itself. Each semantic row's `event` now carries its `seq`, and the row's separate `event_seq` is gone; `response_times` sorts by `event.seq`. Nudge words. The Claude Code module test and the claude-code journey read `harness.NUDGE_WORDS`, and the journey reads the wake summary as `reply_phases.LEAF_WAKE`, so the module test holds the TypeScript copy to the Python constant. A hooks module can import neither a Python constant nor JSON, so the copy stays. Claims directory. `state.claims_home()` is the resolved `claims/` that `service.claim_path`, `session_claims`, `standing_claims` and the watch read. Behavior change: a watch with no session used the unresolved directory, so on a state home under a symlink, such as one in `/tmp` on macOS, its comparison with change notifications, which name resolved paths, never matched. Lock loop. `state.flocked_descriptor(path, flags)` is the one loop that locks, checks that the path still names the file, retries, and unlocks before closing. `flocked` wraps its descriptor in a file object, and `leases.page_locked` uses it on the page directory. Behavior change: what a block writes through `flocked`'s file is flushed before the lock is released, where it used to be flushed after, and a descriptor that lost its path is unlocked before it is closed. Timestamps. `state.aware_instant` is the parse of Leaf's date-time format, moved beside `now_iso` from `registry.schema`, which imports the schema engine that harness hooks avoid. `interaction_log.interaction_time` and the Codex transcript check now use it. Behavior change: `page interactions --since` and `--until` refuse a time without the `T` separator, as the format does. Themes validate the catalogue with `registry.schema.json_validator`, imported only when a catalogue exists. `state.write_json` stays, since the `distribution` dev command uses it. Tests. `test_thread_titles` adds a generated title that is fitted rather than refused; it failed before this change. `test_clerk`'s title test drives a long title through the clerk's answer instead of calling the private helper. `test_file_bindings` finds the save's lock under `PATH_LOCKS`. `test_interaction_log` matches the new message for a time without an offset. `test_interact_claude_code_module` builds the nudge from `NUDGE_WORDS`. The package-lock journey observes `locations.flocked`, where the lock is now taken.
#5272 made `registry.schema` cheap to import, loading jsonschema only to validate, and moved `themes` onto `json_validator` itself. Both conflicts take main's side. `aware_instant` stays in `registry.schema`, its home on main: this branch had moved it to `state.py` only because importing `registry.schema` used to load the schema engine. `interaction_log.interaction_time` and the Codex transcript check now import it from there, and `sample_content`, `served_state.queues` and `user_views` keep main's imports.
leaf-agent
approved these changes
Nov 4, 2026
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.
Part of the 2026-11-03 sweep for duplicate implementations (#5291 changes how review and Tend look for them). Each question below was answered in more than one place in
src/leaf/,hooks/or the dev commands, and the copies had drifted; each now has one home that every caller uses.registry.kernel.title_limit()reads the kernel registry'smaxLengthon thethread_titleevent'stitle, andthread.fit_titleis the one fit: it collapses whitespace and cuts at a word, ending in an ellipsis. The clerk and the page server's generated titles (thread_titles.write_title) both use it, and the CLI's--titlehelp andevents.mdtake the number from it. The six registry copies of the title schema stay inline: no kind's record refers to another's by$ref, and the protocol baseline compares a reference by its text.locations.path_lock(*paths)holds one lock perpath_lock_keyunder/tmp/leaf-path-locks-<uid>, taken in sorted order.package_write_lockand file-binding saves both use it.event_log.initialized(page_dir)says whether a page's log is a file. The CLI's page argument,page init, reconnect advice,owned_pages, the package gate, command timing and the dev commands call it.event_log._stored_eventsis the one parse of the log (torn lines, seq by line number).interaction_log.read_interactionsreads throughread_stored_eventsinstead of splitting the log itself, and each semantic row'seventcarries itsseqin place of a separateevent_seq.state.claims_home()is the resolvedclaims/thatservice.claim_path,session_claims,standing_claimsand the watch read.state.flocked_descriptor(path, flags)is the one loop that locks, checks the path still names the file, retries, and unlocks before closing;flockedandleases.page_lockeduse it.interaction_log.interaction_timeand the Codex transcript check parse Leaf's date-time format withregistry.schema.aware_instantinstead of their own parsers; since Read a page without validating its layer's registry, and load jsonschema only to validate #5272, importingregistry.schemano longer loads jsonschema.hooks/claude-code.tscan import neither a Python constant nor the page's modules, so its copies stay, and its tests now hold them to their homes: the module test and the claude-code journey readharness.NUDGE_WORDSandreply_phases.LEAF_WAKE. The band words' comment no longer claims they are an All pages row's.Behavior changes:
state_home()/files, keyed by the path as stored. It now locks in the machine-local directory, keyed by the resolved path, case-folded on a case-insensitive volume, so two Leafs with different state homes serialize their saves of one file. The eval sandbox allows the new lock directory's name.events.jsonlbut nolayer.jsonnow counts as a page for the package gate, so its page-owned paths are protected./tmpon macOS, it never matched change notifications, which name resolved paths. It now does.flockedflushes what a block wrote before releasing the lock, and a descriptor that lost its path is unlocked before it is closed.page interactions --sinceand--untilrefuse a time without theTseparator, as the format does.Tests:
test_thread_titlesadds a generated title that is fitted rather than refused, which failed before this change.test_clerk's title test drives a long title through the clerk's answer instead of the private helper.test_file_bindingsfinds the save's lock underPATH_LOCKS, and the package-lock journey observeslocations.flocked.