Skip to content

Restrict import resume and abort to the unfinished lifecycle owner - #430

Open
adamziel wants to merge 8 commits into
trunkfrom
adamziel/preserve-command-abort-state
Open

Restrict import resume and abort to the unfinished lifecycle owner#430
adamziel wants to merge 8 commits into
trunkfrom
adamziel/preserve-command-abort-state

Conversation

@adamziel

@adamziel adamziel commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

An import command now resumes or aborts only its own lifecycle, and a completed command cannot clear another pipeline's state or artifacts.

Background

The unfinished owner controls admission while work can still resume. Completion removes that owner, but the final lower-level checkpoint still needs to identify the user-facing lifecycle that produced it. started_by_command records that provenance independently.

This change

Admission runs immediately after state loading, before work-option validation, tuning, preflight, authentication, or network I/O. An unfinished pull, pull-files, or pull-db pipeline owns its lower-level checkpoint. Otherwise, an in_progress or partial direct checkpoint owns the lifecycle. Rejections name the exact resume and abort commands.

All eight resumable commands use one ownership map for state and artifacts. Collision protection uses the completed checkpoint's full started_by_command scope instead of the final lower-level command's scope. A legacy completed checkpoint without that field rejects an overlapping abort and names the exact lower-level abort to run first; it no longer reports success while retaining ambiguous state.

File aborts replay the remote-index WAL and retain downloaded files plus pull/remote-index.jsonl. Database download aborts remove the SQL dump, table index, domain list, SQL buffer, and statistics, while db-apply keeps its inputs and external target unchanged.

A fresh direct command first persists artifact-cleanup, so interruption or removal failure repeats cleanup on the next invocation. Cleanup then advances to fresh-initialization; the first work phase is not exposed until command-specific state is saved with it. In particular, db-apply persists its URL rewrite map before a later invocation can enter the resume path.

High-level aborts continue to force the established {type:"lifecycle", event:"aborted", command:...} JSON record. Direct aborts force their {status:"aborted", message:...} record so throttling cannot hide either result.

Testing

The Import suite covers the ownership matrix, completed starter-scope collisions, legacy checkpoint abort instructions, interruption at both fresh-start phases, durable database rewrite configuration, cleanup through a real local endpoint, and both abort output contracts.

cd tests && ../vendor/bin/phpunit Import
vendor/bin/phpstan analyze --memory-limit=1G
vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 7.4- -ps packages/reprint-importer/src
git diff --check

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Pull pipeline performance — large-directory

Site: large-directory · 2,000+ plus targeted file-transfer scenarios files · 10,000 posts · 25,000 postmeta · PHP 8.5.9

trunk baseline unavailable — showing PR numbers only.

Stage Wall time Resume attempts Status Details
playground-sqlite-db-pull 9.47 s 1 condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
playground-sqlite-db-apply 3.61 s 1 condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
Total 13.07 s

Numbers carry runner noise; treat single-run deltas as directional, not authoritative.

📈 Trunk performance history — commit-by-commit timeline.

adamziel added 2 commits July 31, 2026 00:25
Admit resumable commands immediately after loading state so only the exact unfinished owner can resume or abort.

Save reset state before checked transient-artifact cleanup, and make fresh file and database downloads replace stale outputs.
@adamziel adamziel changed the title Keep unrelated import state across command aborts Restrict import resume and abort to the unfinished lifecycle owner Jul 31, 2026
adamziel added 5 commits July 31, 2026 02:16
Reset the prior partial marker before each database index attempt so a completed response can advance the command.

Update the MySQL E2E assertion to keep fresh downloads from restoring stale SQL buffers.
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