Skip to content

refactor(export): isolate portable media materialization - #591

Merged
chubes4 merged 4 commits into
mainfrom
refactor/441-media-materialization-direct
Oct 6, 2026
Merged

chubes4 merged 4 commits into
mainfrom
refactor/441-media-materialization-direct

Conversation

@chubes4

@chubes4 chubes4 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Continue #441 by giving admitted-media materialization one owner: portable-media.ts consumes the existing selection plan and retained family references, copies/deduplicates admitted files, allocates filenames and projects limit/budget/failed-media replacements in original family order.

The exporter supplies classified families and receives stage-owned replacement, content-hash/path and family-URL indexes plus assets, diagnostics and the media summary. Those indexes seed the existing captured-resource stage, which owns recursive copying and fallback promotion. Selection policy remains in portable-media-plan.ts; receipt/report projection remains in capture-export-evidence.ts.

This replaces approximately 120 lines of inline materialization with an explicit input/output boundary. It preserves existing naming, rendition/budget decisions, failed-sibling suppression, source bytes and publication rollback semantics. No performance improvement is claimed.

Verification

  • Exact same-directory filename/SHA256 baseline comparison against frozen main f90faac0: 8 routes × 4 fixtures (default budget, tight budget, zero budget, rendered document base). Every website/owned-sidecar byte matches, capture inputs remain unchanged and offline results match.
  • Fixtures include responsive renditions, duplicate content under different source URLs, same-basename collisions, oversized dimensions/bytes, extension inference, failed siblings, missing media and cyclic CSS/resource fallback. Selected counts/bytes remain 5/1750 (default), 3/800 (tight), 0/0 (zero).
  • One real-filesystem stage-seam regression verifies two distinct colliding files, deduplication, exclusions, failure suppression and subsequent captured-resource fallback using the media indexes. Resource promotion preserves the original media seed maps.
  • After integrating fix(capture): resolve resources against rendered document base #566 and fix(capture): learn and preserve mobile fluid geometry #574: typecheck and 205 tests / 8 files passed, including media selection/materialization, captured resources, exporter, publication recovery, document base, mobile fluid geometry and evidence projection.
  • Broad local run: 1,711 tests passed; two browser tests and one shutdown hook failed (navigation-context destruction, native snapshot elapsed threshold, browser-close timeout). All three affected files passed unchanged in a serial recheck (34 tests). Both raw runs are retained; authoritative CI remains the full-suite gate.
  • npm run build and npm run test:package passed after integration. Generated dist/ is unchanged from the base.
  • Fresh integrated neutral capture: 2 routes, 6/6 frozen baseline fidelity cells at 390/768/1440, offline self-consistency passed, zero source requests during replay.
  • Fresh integrated https://example.com/ capture: complete, 1 route, 3/3 frozen baseline cells. Baseline scope excludes dialogs, zoom and motion.

Reproduction: npm exec tsc -- --noEmit; npm exec vitest -- run src/lib/portable-media.test.ts src/lib/portable-media-plan.test.ts src/lib/portable-resources.test.ts src/lib/capture-export.test.ts src/lib/export-publication.test.ts src/lib/document-resource-base.test.ts src/lib/screenshot/mobile-fluid-capture.test.ts src/lib/capture-export-evidence.test.ts --maxWorkers=2; npm run build; npm run test:package. The retained loopback preload handles the independently established local localtest.me DNS limitation for broad browser runs.

Evidence is sealed outside the worktree: source/patch snapshots, parity drivers/fixtures/digests, raw failed and passing test logs, capture/fidelity results and SHA256 manifests. Candidate patch SHA256: 69f2a07009979f5e46197d642173e0fac4317710bb3d5d52bcc610f705757186.

AI assistance / execution provenance

OpenAI openai/gpt-6.1-sol through OpenCode implemented the stage extraction, reviewed source ownership, integrated upstream changes, ran verification and drafted this PR under Chris Huber's direction. Execution and finalization occur directly outside Homeboy under explicit operator authorization; retained session evidence links the runtime commands, source and results to #441. This slice does not close the broader tracker.

@chubes4

chubes4 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

The two CI failures were source-resize fixture readiness races, repaired independently in #593 (tracker #592). A delayed-delivery reproduction matched both observed signatures exactly: 208→228px for source height at width 600 and 33→29px for the viewport pose. The repair preserves all numerical assertions and passed full CI before merge (7f83aa91).

This branch now incorporates that upstream repair. The portable-media feature diff remains five files with the same verified patch SHA256 69f2a07009979f5e46197d642173e0fac4317710bb3d5d52bcc610f705757186; typecheck and the real media→resource seam regression passed after adoption. Full CI is running again on the new merge head. Both original failed attempts are retained with the evidence.

AI assistance: OpenAI openai/gpt-6.1-sol via OpenCode diagnosed/repaired the owning test layer and resumed this operator-authorized direct workflow outside Homeboy under Chris Huber's direction.

@chubes4
chubes4 merged commit 8106b3f into main Oct 6, 2026
1 check passed
@chubes4
chubes4 deleted the refactor/441-media-materialization-direct branch October 6, 2026 21:02
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