Repository navigation
Splice source edits through one helper, and read version names and stamps from files.py - #6039
Merged
Merged
Conversation
…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.
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.
This is the weekly duplicate sweep of
src/leaf/andhooks/(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.Applying non-overlapping
(start, end, text)edits to a source. The new home isstructure.splice, which isrevision_delivery._splicedmoved and generalised to str or bytes. It replaces five copies:revision_delivery._spliced, from Cut a corpus revision's server work, and the view check's forced pass after it #3313, removed.revision_artifact.bind_imports, from Address delivered documents and resources in one parsed walk #1280.structure.rewrite_attribute_references, from Support seekable video and audio in page media #1658.leaf_dev.docs.compose, from Compose the docs' copied parts from their owners at build, and parse HTML through SourceDocument #2660.leaf_dev.arrangement_eval, from Build inspectable page content before composing explanations #4629.The four reverse-slice loops copied the whole source once per edit. Each of them applies edits that don't overlap and don't start at the same offset, so splicing them in one pass gives the same output.
The file name of a stamped version.
live_shellwrotef"v{version}.html"inline, from Make Leaf pages complete reactive applications #666. It now callsfiles.version_name.Whether a note stamps a revision.
validation/source_history.pyscanned for the note inline, from fe4e8ea. It now callsfiles.stamped_version, which was added in the same commit.The
sha256:digest of a revision's HTML.revision_artifact._capture_artifacthasheddocument.dataagain, from Make Leaf pages complete reactive applications #666. It now readsSourceDocument.digest, from Canonicalize page preparation and validation #606, which holds the same value.I left
compose_document's two-insertion loop inrevision_delivery.pyalone.spliceorders edits at the same offset by their text, but that loop relies on list order when<html>and<head>are both implicit.Verification.
ruffandtypass 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_anchorsandtest_interact_layer, 626 tests in all. Indev/tests/model/test_product_page.py, the second case oftest_a_composed_part_refuses_an_authored_copyfails atassert slot in authored, beforecomposeruns. Its fixture string expects<imgfollowed byalt="Sandboxat 16 spaces of indentation, anddocs/index.htmlonmainnow 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:
leaf_dev. Give each of leaf-dev's internal mechanisms one home #6014 moves them ontoharness.claude_code_config,harness.codex_homeandhook_transport.INLINE_OPENING.hooks._awaits_agentrepeatsholding.running_turns. Fix the forks review's six bugs, and read who holds each thread once per served state #6032 rewritesrunning_turns.activity.unansweredand thepage-open-owesfinding.activity.py,findings.pyandsession.pyare all being changed in Make a to-do an obligation record #5979, Address Claude Code forks by agent id, and score the line fork on a lookup in a file the session just changed #6018 and Fix the forks review's six bugs, and read who holds each thread once per served state #6032.media._UPLOAD_TYPESandrevision_delivery.media_size.media.pyis being changed in Give each of leaf-dev's internal mechanisms one home #6014.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.json.dumpswithseparators=(",", ":").script_kind(...) in {"module", "classic"}membership test.lock_is_held(page_dir / SERVER_LOCK).Not consolidated, needs a separate look.
sample_content._non_json_numberrepeatshttp.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 insrc/leaf/passesparse_constant. Sharing the helper would change thesample-jsonmessage without settling that question, so it is left out of this PR.