Skip to content

fix(amp): colocate standalone event workers - #740

Merged
ScriptedAlchemy merged 4 commits into
mainfrom
fix/amp-event-worker
Sep 7, 2026
Merged

fix(amp): colocate standalone event workers#740
ScriptedAlchemy merged 4 commits into
mainfrom
fix/amp-event-worker

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • emit each standalone event worker beside the wrappers that load it
  • preserve the existing root worker while supporting nested Amp and mixed-host artifacts
  • make hostless Workbench invocation select a wrapper-adjacent worker before the legacy root fallback
  • build, relocate, validate, install, replace, uninstall, and execute the nested Amp worker in regression coverage
  • document the nested Amp hook layout in English and Chinese

Follow-up to #729 after delayed self-review found nested Amp event wrappers could not load the root-level Flight worker.

Local gate

  • pnpm build — pass
  • pnpm typecheck — pass
  • pnpm lint — pass
  • pnpm test:unit — pass
  • pnpm test:route-unit — pass
  • pnpm test:projection — pass
  • pnpm test:integration:run — pass
  • pnpm test:packed — pass
  • pnpm docs:site:build — pass

All commands ran after rebasing onto current origin/main at HEAD 1a32aaaeb7.

Deslop

Deslop: GPT-5.6 Sol, 1 edit. Reused the standalone-worker predicate for source-input planning; no defensive casts, redundant comments, or unrelated abstractions remain.

Self-review

  • Claude Fable 5.1 Thinking xhigh: found Workbench's root-only hostless worker lookup, missing bilingual layout updates, a fixture host type error, ambiguous prose, and lost root fallback coverage. All were fixed and verified.
  • Claude Fable 5.1 Thinking xhigh rerun after fixes: no findings; merge-ready.
  • GPT-5.6 Sol: verified per-directory planning, sibling launch resolution, manifest and compile evidence, receipt-owned install/replace/uninstall, relocation execution, one Amp index.js, and root+nested hostless lookup. No remaining findings.
  • Codex review shown by gh pr view --comments completed on the opening commit without a concrete suggestion body.

@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1a32aaa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agent-bundle Patch
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T07:29:55.305969Z 38127a3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38127a3e43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

name: outputRelativePath === hooksFlightWorkerPath
? 'hooks-flight'
: outputRelativePath.replaceAll('/', '-').replace(/\.mjs$/u, ''),
outputRelativePath,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve the worker relative to the selected wrapper

When an artifact contains only an Amp standalone event route, this emits the sole worker under .amp/plugins/<name>/hooks/ and no longer emits hooks/hooks-flight.mjs. However, productionBindingFor in src/dev/routes/route-invocation-service.ts still searches only for that exact root path, so a Workbench Amp event invocation returns ROUTE_INVOCATION_COMPILED_ROUTE_UNAVAILABLE_CODE before launching the otherwise valid wrapper. Select the colocated worker from the selected wrapper path instead of hard-coding the root worker.

Useful? React with 👍 / 👎.

Comment on lines +651 to +655
const workerEntries = workerPlans.map(([outputRelativePath, hook]) => ({
name: outputRelativePath === hooksFlightWorkerPath
? 'hooks-flight'
: outputRelativePath.replaceAll('/', '-').replace(/\.mjs$/u, ''),
outputRelativePath,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the documented composite artifact tree

This per-wrapper-directory output means an Amp standalone route emits .amp/plugins/<name>/hooks/hooks-flight.mjs, and mixed targets may emit both nested and root workers, but the English and Chinese reference/targets-artifacts.mdx and guide/start/project-structure.mdx pages still show only hooks/hooks-flight.mjs and describe hooks/ as shared and emitted once. Update both locale documents so the public artifact layout matches the build output.

AGENTS.md reference: AGENTS.md:L132-L138

Useful? React with 👍 / 👎.

@ScriptedAlchemy
ScriptedAlchemy merged commit 4447ec8 into main Sep 7, 2026
3 checks passed
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