Repository source: docs/plans/import_planning_speed/import_planning_speed_step4_implementation_summary.md
Import planning speed Step 4 implementation summary
Debug mode: enabled (inherited from Step 3)
Effort study: railspike-effort / v3/import_planning_speed; host ledger. Standing P2 enrollment.
Extended estimates: enabled
Cycle estimate: 0.55
Branch: feat/import_planning_speed. Built on origin/main f9d61535 (planning commit first made as 4bc38c64); rebased onto fc368349 before opening the PR, which made the planning commit 5fd337c3. Measurements below were taken on the f9d61535 base.
Entry notes
Step 4 entry projection: 0.55 reaffirmed from Step 3, 2026-11-17 UTC, same rater and exposure.
Reference drift:
mainmoved from the Step 1 baseline05486f22tof9d61535while Step 3 waited for approval. The new commits add structuredProgress: plan <done>/<total>lines (6a7f65e3) and do not open the signature cache during import, so the approved plan still applies.Enhancement request (planning progress): superseded.
mainshipped its own planning progress in6a7f65e3, so local commit51732a57was dropped and not carried onto this branch.Environment: the cloud sandbox can no longer download from PHP after the pause;
curlworks through a proxy PHP does not use. Live measurements use a freshcurlcopy of the zenmemes.com archive served on127.0.0.1:8765. Withoutimages.zip, every run reports images as partial (exit 2), which is unrelated to this cycle.
Stage 1 - Import planning opens the signature check cache
Original estimate: 0.15
Changes:
ContentImportRunner::run()callsSignatureCheckCache::useBeside()with the destination database path, inside the import locks, before preview or planning.New test
SignatureCheckCacheTest::testImportPlanningReusesChecksBesideTheDestinationDatabase: a preview with an explicit database path writes the cache beside that file only, and a second preview with an empty memory cache starts no GPG process.docs/reference/v3_cli.md:--dry-runnow says successful signature checks are saved beside the database.
Verification:
Passed: the new test failed before the change (GPG ran 4 times, no cache file) and passes after.
Passed:
./v3 test --smoke SignatureCheckCacheTest ContentImportPlannerTest ContentImportRecoveryTest ImportInstanceCommandTest ImportAdmissionTest ImportDeadlineRecoveryTest LegacyTimestampImportTest ImportedContentPublicationTest SignatureBudgetTest: 532 run, 532 passed.Passed: live archive, repeat import into the existing local repository, cache deleted first. Planning took 26.35 s cold, then 1.43 s and 1.41 s warm. Total run 30.95 s, then 6.81 s and 6.67 s. The cache held 292 checks after the first run.
Not run: full suite (maintainer runs it).
Notes:
The Stage 1 dry-run question was settled by documenting it: the cache is derived state, like the lock files a preview already creates.
The cold run is 26 s against 17 s last week because the archive grew; Stage 2 targets that cost.
Estimate details: original scope as Step 3 Stage 1; uncertainty was the GPG-count harness, which existed already in
SignatureCheckCacheTest. No revisions.
Retrospective stage-work assessment: 0.10 — less than estimated because the test harness and cache already existed.
— Claude · 2026-11-17 UTC · Model: Claude Opus 5.5
Stage 2 - One GPG home per signer key
Original estimate: 0.30
Changes:
OpenPgpSignatureVerifiertakesreuseKeyHomes: true. A key's first check runs packet inspection, import and key lookup in a home of its own; later checks with the same key bytes and expected fingerprint run onlygpg --verifythere. Each check's text and signature files are removed afterwards. The per-call budget, output limits,VALIDSIGfingerprint check and result shape are unchanged. The default constructor keeps one home per check.Prepared homes live under one parent per process,
forum-rewrite-gpg-keys-<pid>-<random>, capped at 64 keys. They are removed byreleasePreparedKeys()or when the verifier is dropped. A new parent first removes parents whose process no longer exists.After a fork, inherited homes are ignored and left to their owner. A home that disappeared is prepared again rather than reported as a failed signature.
ReactionSignature::status()shares one reusing verifier per process. Other callers (SignedPostIdentity.php,AuthApiController.php,LocalWriteService.php,audit_post_signatures.php) keep one home per check, as planned.New
tests/OpenPgpKeyReuseTest.php(7 tests), registered intests/run.php.
Verification:
Passed:
OpenPgpKeyReuseTestfailed before the change (unknown parameter) except the default-path test, and passes after: second check runs one GPG process; a signature from another key, tampered text and a wrong expected fingerprint are rejected after reuse; another key's bytes under a prepared fingerprint get a fresh home and fail; homes are removed on release and after a failed import; a dead process's parent is removed and a live one kept; a removed home is prepared again.Passed:
./v3 test --smokeplusActivityProjectionTest AgentIdentityServiceTest CommitEvidenceLookupTest OpenPgpKeyInspectorTest PostSignatureAuditCommandTest SignatureCheckCacheTest OpenPgpKeyReuseTest SignatureBudgetTest SignedPostTransactionTest WriteApiSmokeTest LocalAppSmokeTest ContentImportPlannerTest ContentImportRecoveryTest ImportInstanceCommandTest ImportAdmissionTest ImportDeadlineRecoveryTest LegacyTimestampImportTest ImportedContentPublicationTest AcceptedRetractionTest: 779 run, 779 passed, no GPG folders left in/tmp.Passed: live archive, cold import (cache deleted), GPG launches counted with a
PATHwrapper. Stage 1 code: planning 26.29 s, 1,168 launches for 292 signatures. Stage 2 code: planning 9.97 s, 394 launches (1.35 per signature). Warm: planning 1.53 s, no launches.Passed: import counts identical across Stage 1 cold, Stage 2 cold and Stage 2 warm runs (duplicate 7370, conflict 4, invalid 224, unsupported 87, excluded 721, scores existing 313).
Not run: full suite (maintainer runs it).
Notes:
Found during verification:
ImportDeadlineRecoveryTestkills the import withSIGKILLat its hard deadline, which left 9 prepared homes in/tmp. The per-process parent and dead-process sweep fix this; a kill now leaves one folder, removed by the next run. The old code could leave one home per kill.An earlier Stage 2 measurement used the wrong end marker (the image step, which now runs after publishing). The figures above use the
Installingline, as Stage 1 did.
Estimate details: original scope as Step 3 Stage 2; uncertainty was cleanup on every exit path, which turned out to need the killed-process sweep. No scope change; the sweep is the mitigation the plan named for piled-up homes.
Retrospective stage-work assessment: 0.35 — above the original because of the killed-process cleanup and fork handling.
— Claude · 2026-11-17 UTC · Model: Claude Opus 5.5
Stage 3 - Cloud Linux replay and concept entry
Original estimate: 0.08
- Changes:
- New `docs/concepts/signature_check_cache.md`; linked from `docs/concepts/instance_content_import.md`.
- `docs/runbooks/instance_content_import.md`: repeat imports reuse saved checks, and deleting the file is safe.
- Verification (live zenmemes.com archive from 2026-11-17, served on loopback; GPG launches counted with a `PATH` wrapper; planning measured from "Planning public records" to "Installing"):
| Run | `main` `f9d61535` | This branch |
| --- | --- | --- |
| First import, fresh checkout | 28.42 s planning, 38.70 s total, 1,168 GPG | 11.42 s planning, 18.21 s total, 394 GPG |
| Repeat import, same checkout | not measured (no cache use; same as first) | 1.42 s planning, 6.38 s total, 0 GPG |
| Repeat import, existing local repository | 26.29 s planning, 1,168 GPG | 1.53 s planning, 0 GPG |
- Passed: fresh-checkout counts identical on `main` and the branch: import 7372, invalid 226, unsupported 87, excluded 721. Status partial on both only because the loopback server has no `images.zip`.
- Passed: the first import into a fresh checkout leaves `signature_checks.sqlite3` beside its database, so the repeat needs no GPG.
- Passed: `--resume` after interruption, through `ImportDeadlineRecoveryTest` and `ContentImportRecoveryTest` in the Stage 2 run.
- Passed: `git diff --check`; concept and runbook links resolve to existing files.
- Not applicable: deployment, because `signature_checks.sqlite3` is derived and needs no migration.
- Notes:
- A first attempt at the fresh-checkout run used a destination without `records/instance/public.txt` and failed at publish on both `main` and the branch with "Unable to read canonical record". That was the test setup, not a regression; the rerun above adds the file.
- Estimate details: original scope as Step 3 Stage 3; uncertainty was archive drift, avoided by using one downloaded archive for every run. No revisions.
Retrospective stage-work assessment: 0.10 — slightly above the original, because the PHP download path stopped working in the sandbox and the archive had to be served from loopback.
— Claude · 2026-11-17 UTC · Model: Claude Opus 5.5
Stage 4 - Maintainer WSL replay
Original estimate: 0.03
Status: pending. Needs the maintainer to run
time ./v3 import-instance zenmemes.comtwice on WSL with this branch checked out. Cloud Linux results above do not satisfy this stage.