feat: integrate automatic game resource delivery

This commit is contained in:
2026-09-06 09:50:49 +08:00
parent f721966f3c
commit 4df4bc9624
20 changed files with 1667 additions and 191 deletions

View File

@@ -0,0 +1,119 @@
# Task: Implement automatic Game Resource project delivery
## Identity
- Task ID: 20260906-game-resource-auto-delivery-7a4e2c91
- Mode: Feature
- Branch: codex/20260906-game-resource-auto-delivery-7a4e2c91-game-resource-auto-delivery
- Worktree: D:\Datas\OthersProjects\makelore-game-resource-auto-delivery-7a4e2c91
- Base commit: f721966f3c8db982279e34033b94b4347f0a8174
- Owner: codex-root
- Status: Ready for Integration
## Scope
- Replace the Agent-driven Game Resource `generate -> status polling -> path prompt -> save`
choreography with one Main-owned generate-and-deliver workflow.
- Keep the existing Works Square hosted generation/status/content protocol and billing
authority; do not add a second Provider submission or charge during polling or local
delivery recovery.
- Materialize every completed output beneath the frozen original project, using
deterministic project-relative paths and the existing short-lived project write lease.
- Project bounded progress and the terminal saved paths through the existing Pi product-tool
bridge, while removing status/save instructions from the Agent-facing Skill surface.
- Add public-seam unit/integration coverage for submit-once polling, replay, multi-output
delivery, project switching, write conflicts, local retry, cancellation/detach, and
packaged resource consistency.
## Intent And Constraints
- User confirmation covers the metered generation and automatic delivery together. There is
no second filename or save confirmation.
- Provider execution and local delivery are distinct states. A successful Provider result is
never regenerated or refunded solely because local materialization fails.
- Freeze the trusted project ID/path when the operation begins. A later active-project switch
must not redirect files.
- Do not hold the project write lease while the remote job is queued/running. Acquire it only
for the bounded terminal materialization transaction and always release it.
- Replays of the same logical operation return the same execution and project-relative paths;
they do not submit or charge again.
- A conversation/worker abort detaches the waiting UI. It does not silently cancel an already
accepted remote execution; the explicit cancel capability retains its existing meaning.
- The Renderer, Pi extension, Skill, and model do not gain filesystem, credential, Provider,
billing, or retry authority. Electron Main remains the deep owner.
- No server, Marketplace policy, pricing, Provider configuration, or deployment change is in
scope unless implementation evidence proves the current typed protocol cannot express this
client-owned orchestration.
- Concurrent Task Gate: Passed. This isolated feature task is the only current owner of the
Game Resource delivery/bridge/resource files; the user root worktree is not touched.
- Planning Gate: Passed after loading current project memory, ADR-006, ADR-008, the prior
Game Resource implementation and project-wide activation records, the accepted delivery
design record, and the concrete Main/Pi/write-lease implementation seams.
## Outcome
- Added a Main-owned `GameResourceDeliveryCoordinator` and atomic local receipt store.
One confirmed `game_resource_generate` call now submits once, polls the existing typed
execution internally, downloads every terminal output, and writes deterministic
create-only files beneath
`assets/generated/game-resource/<executionId>/output-<n>.<ext>` in the frozen original
project.
- Provider and local-delivery state remain separate. Successful Provider executions use
up to three bounded local delivery attempts; unresolved receipts survive app restart or
session refresh and resume without another generation request or Token Point charge.
One unavailable reconciliation no longer blocks other persisted deliveries.
- The coordinator downloads before acquiring the shared Pi project write lease, holds that
lease only while creating project files and recording touched paths, preserves existing
files with different bytes, and treats a missing historical run in the in-memory change
tracker as a non-fatal post-save condition.
- Extended the authenticated Pi product bridge with an opt-in NDJSON progress path for
dynamic job tools and bumped the generated extension to `makelore-runtime-v6.mjs`.
Game Resource now projects one card through submitted, generating, saving, saved, and
failure/review states instead of exposing repeated Agent polling calls.
- Reduced the shipped Game Resource Agent surface to templates, generate, explicit cancel,
browser, and review. `game_resource_status` and `game_resource_save_output` remain
internal transport capabilities only and no longer appear in the package manifest or
Skill. One user confirmation now explicitly covers both the metered generation and
automatic save of all outputs.
- Wired one shared write-lease coordinator and delivery coordinator in Coding composition,
including background-lifecycle ownership, startup/session receipt recovery, shutdown
detachment, and existing change tracking. No server, Provider, Marketplace policy,
pricing, admission, or billing authority changed.
## Verification
- TDD public-seam red/green: the new coordinator tests first exposed missing transient
delivery retry, cross-receipt recovery isolation, and the late saving-progress transition;
the final coordinator suite passes 10/10. Coverage includes submit-once polling,
concurrent and persisted replay, multi-output save, frozen project path, background and
project write leases, restart recovery, download/write failure recovery, no-overwrite
conflicts, pending review, touched paths, and progress ordering.
- Focused Game Resource/Registry/Pi bridge/resource/timeline/composition suite: 13 files,
99 tests passed; the coordinator subset is 10/10 and the manifest/artifact pair is 25/25.
- Full unit suite: 227 files, 1,901 passed, 2 skipped; isolated pressure suite 1/1 passed.
- TypeScript typecheck passed. Full ESLint passed with zero errors and only five unchanged
warnings in `src/pages/Home/index.tsx` and `src/pages/Makelore/index.tsx`.
- Vite Renderer/Main/Preload/utility production build passed. Windows Electron tests passed
2 files / 8 tests. Unified Plugin workspace Electron E2E passed 3/3.
- Windows x64 Pi runtime stage passed with 130 production packages and six runtime assets.
Built Main output contains `makelore-runtime-v6.mjs`; the retired Agent-facing status/save
tool names are absent from the Game Resource package and built Main output.
- `git diff --check` passed. Project documentation and task drift gates are completed during
final handoff.
- No live paid Provider generation was run: doing so would create a real Token Point charge
and is not needed to verify this client-owned orchestration change.
## Follow-ups
- Integration mode should promote the architecture/data-flow/business-rule/current-state
candidates below after accepting this source commit. A live paid Provider acceptance may
be run separately only with explicit authorization for the charge.
## Promotion Candidates
- Target: ADR/module-map/data-flow/business rules/current state/success criteria.
Proposal: record that Game Resource generation is one Main-owned submit-and-deliver
operation; polling is internal, all outputs are automatically saved under the frozen
original project, and the write lease is held only during terminal materialization.
Evidence: implementation commit plus focused/lifecycle/package verification. Future impact:
Agents no longer own hosted-job polling, path selection, or a second save confirmation.