Repository navigation
Give source's readings owners below their readers, ending its import cycle and passages' backward import - #7224
Merged
Merged
Conversation
…cycle `source`'s modules imported each other in a cycle (data_contracts, layer, passages, registry, revision_artifact, structure), and source.passages imported log.obligations, the last of source's allowances in the layers contract. Each back edge was a function in a module above or beside its fact. This moves each to the module that owns it; it changes no behaviour. The module and stylesheet readers leave revision_artifact, which kept them because capture was their first reader, though layer composition, delivery, inspection and checks read through them too: - what a module imports, a URL's local path, the containment gate and the refusal they raise (`javascript_imports`, `dependency_reference`, `resolve_dependency`, `PUBLIC_MODULES`, `ArtifactError`, `artifact_error`, `capture_finding`) join `resource_urls`; - the CSS reader (`_read_css`, `css_dependencies`, `css_drops`, `css_syntax_errors`, `rewrite_css`) joins `styles`, beside `dropped_css`, the half of it that was already there. So layer composition no longer imports revision_artifact. `registry.storage` held two concerns at different levels: the page's layer record, and the vocabularies composed from it, which read the composed layer and stored revisions. It keeps the record. The compositions move to the modules they read: - `layer` takes the record's compositions: `selected` merges into `layer.selected_layer`, and `selected_vocabulary` into its namesake, whose package-taking versions only storage called; `layer_vocabulary`, `layer_widgets` and `served_layer` follow; - `revision_artifact` takes a revision's vocabulary (`revision_vocabulary`, `revision_inputs`, `_Revisions`), beside `RevisionReading.registry`; - the new `vocabulary` holds the vocabulary each of a page's documents is read in (`page_vocabulary`, `active_registry`, `require_registry`, `read_page_registry`, `require_candidate`, `load_registry`), above revision_artifact, whose revisions it reads. The widgets a document declares that can ask the user are a reading of its markup and vocabulary, which `SourceReading` held through deferred imports of log.obligations: - the new `obligation_sources` holds them (`ObligationSources`, `obligation_sources`, `ObligationRegistration`, `obligation_registrations`, `widget_groups`, `group_tags`, `local_obligation_entry`, `shown_in`, `quoted_in`); - `element_name` and `caption_node` move from log.gesture_words to `passages`, beside the other words readings; - `enclosing_widgets` moves from log.projection to `structure`, which builds the holder chain it walks; - `SourceReading` and `SourceInventory` move from passages to the new `reading`, above every reading they hold, so their deferred imports of data_contracts and log.obligations become ordinary ones. The allowance `leaf.source.passages -> leaf.log.obligations` goes from `.config/importlinter.ini`, and `source`'s children are acyclic. Four tests patched a name where its old module looked it up; they now patch the module that calls it: `styles.dropped_css`, `reading.page_passages` beside `passages.page_passages`, `vocabulary.read_revision` beside `revision_artifact.read_revision`, and the website's `selected_layer`.
…eep start-up lean Review of the previous commit found readings still beside the wrong fact and two start-up paths loading more than before. This moves each to its owner. No reading changes; a cache's lifetime and one refusal's grouping do, as noted below. - The capture refusal (`ArtifactError`, `artifact_error`, `capture_finding`) leaves `resource_urls` for its own module, `capture_refusals`, which the URL and CSS readers and capture all import, so a stored manifest's digest mismatch no longer raises from the URL module. - `resource_urls.authored_imports` is the one reading of an authored module's resolved imports, collecting every refused import into the caller's list or raising them together where delivery's reading raised the first refused gate mid-walk; a module a capture admitted has none to raise. Capture's page-module and inline-script readings and delivery call it instead of pairing `javascript_imports` with `resolve_dependency` themselves. - `shown_in` and `quoted_in` move from `obligation_sources` to `structure`, beside the holder-chain walk they read: `quoted_in` decides event admission for any widget, asking or not. - `ObligationRegistration` drops `requested`, the cache of whether a widget asked in an earlier revision. The log fold, its one reader, keeps it in a weak map keyed by the earlier revision's reading, so it lasts as long as that reading rather than the compact inventory; `_inventory_size` no longer reserves room for it. - `styles` imports the URL reader inside `_is_stylesheet_url`, and `layer` imports the layer record inside `layer_vocabulary`, so `leaf package run` no longer loads pywhatwgurl and idna, and a hook hashing the skill no longer loads `registry.storage`. - `layer` refuses an unavailable selection through `registry_error`. - The headers of `vocabulary` and `styles` and the matching docstrings say what a capture keeps (the page's declarations and package selection, composed by the reading Leaf) and what the CSS reader is keyed by (the text and parsing mode).
# Conflicts: # .config/importlinter.ini # src/leaf/records/authored_checks/admission.py # src/leaf/records/authored_checks/source.py # src/leaf/records/page_data.py # src/leaf/serving/served_state/browser.py # tests/model/test_workflows.py
leaf-agent
approved these changes
Nov 26, 2026
This was referenced Nov 26, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
…a cycle (#7230) import-linter's layers contract checks only the imports between `src/leaf`'s eight packages, so the modules inside a package could import each other in a cycle, and six groups did. The cuts that ended them have landed (#7216, #7217, #7218, #7222, #7224). This adds import-linter's own `acyclic_siblings` contract over every package (`ancestors = leaf.*`). It recurses into subpackages such as `served_state` and `render_gate`, so a new cycle fails pre-commit as an upward import does, naming the import that closes it. A planted deferred import from `presence` into `delivery`, and one from `served_state.context` into `served_state.page`, each fail the contract; the tree as it stands passes. The config's header now says how to fix a cycle, and that a deferred import counts like any other, so deferring one ends no cycle; `src/AGENTS.md` states the rule beside the layering one. The maintainer asked for the cycles inside `agents` to be broken; this widens that to every package and keeps them broken. The two allowances the layers contract still lists are cut by #7223 and the PR after it. Tests: `lint-imports` (both contracts), pre-commit, and the two planted cycles above. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
…version asked (#7234) A page that showed a widget inside an exhibit (such as an `lf-sample`), then later moved it out already settled, listed a finished obligation (`done`, `dropped`) for a widget that never asked the user anything. The reading of the current version, the thread reader and the question check all leave a shown widget out, but the reader of earlier versions took `asking` from the widget's `matches_when` alone, and the log fold trusted it. `obligation_registrations` now calls the same `structure.shown_in`, so the historical reader applies the same rule as the others with no fourth copy of it. The event triggers needed it too: a widget shown in an interactive exhibit, written `phase=open` then `closed`, and later moved out not ready, also listed a finished obligation. A shown widget still gets a registration, so the history scan keeps walking back to versions where it stood outside and did ask. Codex found this while reviewing #7224, which moved the obligation sources from `log` to `source`; the bug predates the move. Tests: two regression tests in `tests/model/test_obligations.py`, the reported case and the write path, each failing before the fix; `lint-imports`, pre-commit, and 1,161 covering tests. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
A `leaf package install` landing partway through a cold read of a page's
vocabulary could pair one snapshot's declarations with the other's
modules, and the page was refused for that one read ("declares verbatim,
which a module provides, and has none at widgets/…"). The read resolved
the page's package selection three times, for the cache stamp, the
registry and the widget list, and the revision reading and its
composition did the same.
A read now resolves the selection once and takes the cache key, the
registry and the widget list from that one result: `layer_vocabulary`
and `layer_widgets` take an already-resolved `LayerVocabulary`,
`read_page_registry` and `_revision_composition` resolve once (the first
also reads the layer record once, after taking its stamp), and
`_compose_revision` no longer takes `page_dir`.
`runtime_selection.executing` had the same race between the layer's
files and the revision's registry, which could leave a page's widgets as
plain markup until a reload; it passes the vocabulary it built the files
from through a new `layer=` keyword of `revision_vocabulary`.
Two readers still resolve twice, `page.page_instructions` and
`page_inspection.inspect_artifact`; each failure lasts one command that
a retry fixes, and fixing either means changing a return type, so they
are left.
Codex found this while reviewing #7224; the race predates it.
Tests: `test_a_reading_composes_one_installation_of_a_package` swaps the
package's snapshot after each lookup and checks the candidate read, the
revision read and the served `/registry.json` each hold one
installation; all three failed before the fix. `lint-imports`,
pre-commit, and the 158 model and process tests that call the changed
functions.
> _This was written by Claude Code on behalf of max-sixty_
Co-authored-by: Claude <[email protected]>
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.
Ends the import cycle among
source'sdata_contracts,layer,passages,registry,revision_artifactandstructure, and the backward importsource.passages -> log.obligations. Nothing undersource/now imports a package above it. Three edges pointed the wrong way, each from a function kept beside its first user rather than the module that owns its fact:revision_artifactheld them because capture was their first user; layer composition, delivery, inspection and the checks read through them too. The module readers move down toresource_urls, which now holds the one resolved reading of a module's imports (authored_imports) that capture's page-module and inline-script readings and delivery all call. The stylesheet readers move tostyles, besidedropped_css. A capture's refusal (ArtifactError,artifact_error,capture_finding) gets its ownsource/capture_refusals.py, which the readers and capture import.registry/storage.pyheld the page's layer record and the vocabularies composed from it, which need the composed layer and stored revisions. It keeps the record. Storage'sselectedmerges intolayer.selected_layerand itsselected_vocabularyintolayer's, whose package-tuple versions had no caller but storage;revision_vocabularyandrevision_inputsmove torevision_artifact, beside the readings that use them; and a newsource/vocabulary.pyholds the vocabulary each of a page's documents is read in (page_vocabulary,read_page_registryand their kin). Storage's five deferred imports that dodged the cycle become ordinary ones.log.obligationsto a newsource/obligation_sources.py, withelement_nameandcaption_nodefromlog.gesture_wordsintopassagesand the exhibit walk (enclosing_widgets,shown_in,quoted_in) intostructure.SourceReadingandSourceInventorymove frompassagesto a newsource/reading.pyabove them. The log fold keeps its event-history cache of a registration in a weak map of its own, so the source inventory holds no event state.Behaviour is unchanged. Start-up loads what it did: two new imports stay deferred so
leaf package runand an empty session's hooks load no more than before, which a fresh-process comparison with the base checked.To weigh: the four new modules' names (
vocabulary,reading,obligation_sources,capture_refusals), andArtifactError's new import path for code that catches a capture's refusal. Most of the 100-odd files touched are import lines.This is one of the cuts the maintainer asked for to end
src/leaf's backward imports and the cycles inside its packages. Codex reviewed it, and its findings are folded in. It also reproduced two pre-existing bugs in the moved code, a widget moved out of an exhibit inventing a finished obligation from history and one vocabulary read combining two package installations; each gets its own PR after this one.Tests:
lint-imports, pre-commit, 2,096 covering tests intests/and 70 indev/tests, and an import of every module.