Skip to content

Fix "app is not defined" when react-node operation runners call trigger() - #16

Merged
zfoong merged 2 commits into
mainfrom
ahmad/app-not-defined
Oct 1, 2026
Merged

zfoong merged 2 commits into
mainfrom
ahmad/app-not-defined

Conversation

@ahmad-ajmal

@ahmad-ajmal ahmad-ajmal commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

In the react-node blueprint, any operation runner that called trigger(...) failed at runtime with:

Operation "request-triage" threw: app is not defined

The runner toolbox in server.mjs wrapped app.trigger(...), but nothing in that file is named app. The adapter instance is const a2app = createA2App(...), and the Hono server is hono. The wrapper only looks up the name when it is called, so node --check and every boot passed. The error appeared only the first time a runner fired, which means the starter's own request-triage example was broken in every scaffolded app.

Fix

  • toolkits/blueprint-react-node/template/server.mjs: the wrapper now calls a2app.trigger(...), and the comment next to it names the right binding.

Existing apps pick this up automatically: adapter-sync runs on every launch, copies the toolkit's server.mjs into the app, and re-records the system-file hashes. No rebuild is needed.

Tests

  • Unit (toolkits/blueprint-react-node/test/app-to-agent.test.mjs): checks that the name the runner's trigger calls is the same name that createA2App(...) is assigned to. Putting app.trigger back fails with expected "a2app", actual "app".
  • Conformance (conformance/harness/src/lifecycle.ts, Safe-evolve class): a new check runs a2app <app> planning tasks task_welcome request-triage against the booted dev instance. It then confirms that the returned queued id is in the app's task queue with capability triage and payload { task: "task_welcome" }. This is the only check that goes through the runner toolbox on a running app.
    • The check parses only stdout, so the dev-instance banner on stderr can't break JSON parsing. run() now returns stdout alongside the merged out.
    • If the task list can't be parsed, the check reports only that, not a second "task missing from queue" failure.
  • conformance/README.md lists the new check among the Safe-evolve checks.

Verification

  • node toolkits/blueprint-react-node/test/app-to-agent.test.mjs: passes. It fails with the old app.trigger.
  • pnpm -r build && node conformance/harness/dist/run.js: 86/86 passed. With app.trigger put back, the new check fails with request-triage exit 1: ✗ Operation "request-triage" threw: app is not defined.

Not in scope

Go, Python, Rails and Rust blueprints call store.trigger(...) on an object they hold directly. They don't look up the adapter by name later, so this bug doesn't apply to them.

@ahmad-ajmal ahmad-ajmal self-assigned this Oct 1, 2026
@ahmad-ajmal ahmad-ajmal changed the title Fix trigger() in react-node operation runners throwing "app is not de… Fix "app is not defined" when react-node operation runners call trigger() Oct 1, 2026
@ahmad-ajmal
ahmad-ajmal marked this pull request as ready for review October 1, 2026 14:12
@ahmad-ajmal
ahmad-ajmal requested a review from zfoong October 1, 2026 14:12
@zfoong
zfoong merged commit e01b884 into main Oct 1, 2026
3 checks passed
@ahmad-ajmal
ahmad-ajmal deleted the ahmad/app-not-defined branch October 2, 2026 14:01
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.

2 participants