Skip to content

cli(feat): add crash-safe demo seeding - #147

Merged
Ducksss merged 11 commits into
devfrom
claude/fervent-shaw-45f7c9
Jul 20, 2026
Merged

Ducksss merged 11 commits into
devfrom
claude/fervent-shaw-45f7c9

Conversation

@Ducksss

@Ducksss Ducksss commented Jun 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add strict payload-components seed <component> [--cwd <path>] and payload-components add <component> [--cwd <path>] [--demo] interfaces.
  • Generate a reviewable, operator-run Payload Local API script only after the component is fully installed and every manifest file, dependency, and wiring fragment is verified.
  • Keep database access outside the distribution CLI; generation itself performs no database or network operation.
  • Store a private high-entropy ownership record under .payload-components/demo-state/ and atomically replace only version-marked owned scripts.
  • Require a drafts-enabled Pages collection and mutate only the exact owned draft Page and Media records.
  • Journal Page and Media create operations before mutation so an interrupted run can reconcile its exact document and resume without duplicating content.
  • Type the hydrated layout against the consumer's generated Page.layout, validate it before mutation, and fill missing upload relationships at block roots and in nested arrays.
  • Refuse path escapes, symlinks, unrelated existing files, ownership collisions, ambiguous recovery matches, incomplete hydrated layouts, and recorded partial installs.
  • Never publish implicitly and never delete Media records.

Why

Demo content is useful only if it cannot silently publish, overwrite consumer files, or mutate unrelated Payload documents. The generated script keeps elevated Local API access explicit and reviewable while the private ownership record and write-ahead operation tokens make reruns and interruption recovery fail closed.

Security contract

  • --demo runs only after all five install stages and installed-state recording succeed.
  • Recorded partial installs fail closed even when copied files and fragments happen to exist.
  • Generated scripts require Pages drafts and verify exact IDs plus tokenized markers before reuse or update.
  • Owned Page updates use overrideLock: false.
  • Every create is preceded by a unique persisted operation token; recovery adopts only one exact matching document.
  • overrideAccess: true exists only in the explicit operator-run script.
  • No registry item, manifest schema, site runtime, Payload collection, secret, telemetry, migration, or component-source change is included.

Verification

  • VITEST_MAX_WORKERS=2 E2E_PORT=3211 pnpm test:release
    • lint, source build, TypeScript, registry reproducibility/schema, and production build
    • 194 integration tests passed, 1 expected skip
    • 31 frontend E2E, 67 visual, and 14 accessibility/GEO tests passed
  • Fresh Payload 3.86 smoke: hero-basic generated types, TypeScript, seed execution, build, and browser render
  • Fresh Payload 3.86 required-upload smoke: hero-video generated script TypeScript and seed execution
  • Focused seed command/runtime/fresh-harness suites: 43 passed
  • CodeRabbit findings resolved, including crash consistency and bounded generated-seed subprocesses

Scope note

The original incomplete admin-field-hints sweep was removed. This PR contains demo seeding, its tests, smoke-harness reuse, and documentation only.

@vercel

vercel Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
payload-components Ready Ready Preview, Comment Jul 20, 2026 1:24pm
payload-components-97bf Ready Ready Preview, Comment Jul 20, 2026 1:24pm

@Ducksss

Ducksss commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Retargeted to dev, which is the integration branch. This still needs rebase/conflict resolution before review because GitHub reports merge conflicts.

@Ducksss
Ducksss force-pushed the claude/fervent-shaw-45f7c9 branch from af3b6f5 to 0eda9b1 Compare July 10, 2026 14:49
Copilot AI review requested due to automatic review settings July 10, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Summary:
- Add strict seed and add --demo orchestration that generates a reviewable
  Payload script only after a complete component install.
- Fail closed on partial installs, path escapes, symlinks, unowned output,
  ownership conflicts, drafts-disabled Pages, and mutation failures.
- Make Page and media reruns idempotent, atomic, marker-scoped, and safe
  across interrupted writes, with complete CLI and consumer documentation.

Rationale:
- Give contributors useful demo content without adding database access or
  runtime dependencies to the distribution CLI.
- Keep elevated Local API access explicit and operator-run while preventing
  implicit publication or unrelated content and file mutations.

Tests:
- lint, source build, TypeScript, registry and integration checks
- 111 integration tests passed; 1 skipped
- packed CLI contract passed with add --demo
- 14 focused browser tests and 275-page production build passed
- fresh Payload 3.85.2 hero-basic seed smoke passed end to end
- CodeQL security-and-quality found no diff-scoped findings
- full fresh smoke reached all 31 installs, then hit an unchanged existing
  pricing-enterprise identifier-length limit
Ducksss added 5 commits July 16, 2026 14:45
# Conflicts:
#	tests/int/fresh-payload-smoke.int.spec.ts
#	tests/int/payload-components-pack.int.spec.ts
#	tools/payload-components/smoke/fresh-payload-repo.ts
Summary:
- require healthy install state, dependencies, files, and wiring
- bind generated Page and Media writes to local tokenized state
- preserve the real Payload smoke harness and exercise demo seeding
- document collision, rerun, and filesystem safety guarantees

Rationale:
- database-visible slugs, titles, and alt text are forgeable
- exact locally recorded IDs prevent unintended elevated mutations
- media deletion is unsafe without independent ownership proof

Tests:
- pnpm lint
- pnpm source:build
- pnpm exec tsc --noEmit
- pnpm run test:int (160 passed, 1 skipped)
Summary:
- journal unique Page and Media operation tokens before database creates
- reconcile exact interrupted creates and persist their ownership IDs
- cover create failures, restart recovery, and collision refusal
- document the crash-safe demo seeding contract

Rationale:
- prevent successful database writes from becoming untracked when local state
  persistence is interrupted
- preserve fail-closed ownership checks without duplicating or deleting content

Tests:
- pnpm lint
- pnpm source:build
- pnpm exec tsc --noEmit
- pnpm run test:int
Summary:
- add a 20-second timeout to generated demo seed runtime subprocesses

Rationale:
- prevent a hung generated script from stalling the integration suite forever

Tests:
- pnpm exec vitest run tests/int/payload-components-seed-runtime.int.spec.ts
- pnpm exec eslint tests/int/payload-components-seed-runtime.int.spec.ts
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d9137e4-7e79-4533-a033-a85133928691

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fervent-shaw-45f7c9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ducksss Ducksss changed the title cli(feat): add safe opt-in demo seed scripts cli(feat): add crash-safe demo seeding Jul 19, 2026
@Ducksss
Ducksss merged commit 9a62a3c into dev Jul 20, 2026
12 checks passed
Ducksss added a commit that referenced this pull request Jul 23, 2026