Skip to content

Splice source edits through one helper, and read version names and stamps from files.py - #6039

Merged
leaf-agent merged 1 commit into
mainfrom
weekly/duplicates-src-hooks-2026-46
Nov 15, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
weekly/duplicates-src-hooks-2026-46

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

This is the weekly duplicate sweep of src/leaf/ and hooks/ (ISO week 46). It moves four capabilities that were implemented more than once to one home each, and moves every caller. Behavior does not change. Every replaced copy computed the same result as the home it now calls.

I left compose_document's two-insertion loop in revision_delivery.py alone. splice orders edits at the same offset by their text, but that loop relies on list order when <html> and <head> are both implicit.

Verification. ruff and ty pass on the touched files. These model tests pass: test_module_url_delivery, test_revision_delivery, test_live_shell_artifact, test_product_page, test_interact_document, test_interact_anchors and test_interact_layer, 626 tests in all. In dev/tests/model/test_product_page.py, the second case of test_a_composed_part_refuses_an_authored_copy fails at assert slot in authored, before compose runs. Its fixture string expects <img followed by alt="Sandbox at 16 spaces of indentation, and docs/index.html on main now indents that line by 18. The failure is in the test's fixture, not in this change.

Sets found but not consolidated here

Another open pull request already changes each of these:

These are not worth a shared helper, because they are one-line stdlib idioms or the copies differ in meaning:

  • json.dumps(..., sort_keys=True) used as a cache key.
  • Compact json.dumps with separators=(",", ":").
  • The script_kind(...) in {"module", "classic"} membership test.
  • lock_is_held(page_dir / SERVER_LOCK).
  • Inline closed-object JSON schemas.

Not consolidated, needs a separate look. sample_content._non_json_number repeats http.reject_json_constant. The real question is where Leaf refuses non-finite numbers. The HTTP path refuses NaN and numbers past a double's range. Sample fixtures refuse only NaN and infinity. No other reader of event JSON in src/leaf/ passes parse_constant. Sharing the helper would change the sample-json message without settling that question, so it is left out of this PR.

…amps from files.py

Weekly duplicate sweep of src/leaf/ and hooks/. Behavior is unchanged:

- `structure.splice` replaces revision_delivery's `_spliced` and the
  reverse-slice loops in `revision_artifact.bind_imports`,
  `structure.rewrite_attribute_references`, `leaf_dev.docs.compose` and
  `leaf_dev.arrangement_eval`. It works on str or bytes, and joins once, so those
  callers stop copying the whole source per edit.
- `live_shell` names a version's file with `files.version_name`.
- `validation.source_history` asks whether the active revision is stamped with
  `files.stamped_version`.
- A revision's manifest takes its HTML digest from `SourceDocument.digest`
  rather than hashing the document a second time.
@leaf-agent
leaf-agent merged commit ce46407 into main Nov 15, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the weekly/duplicates-src-hooks-2026-46 branch November 15, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant