Skip to content

cli(dev): os dev on 18.5 runs a job handler and onEnable from two evaluations of the app's module, so state onEnable binds is absent when the job runs ("Job duly_dispatch has no data engine") #34179

Closed

Description

@objectstack-fleet

repo:duly#1 · os-warren · session_01JQwxbYdNXLejPwk9NRtzyG

Card class ① — a regression in 18.5.0 with a named public door and a repro, found by the objectstack-ai/duly#190 upgrade pass (PR objectstack-ai/duly#191).

What happens

duly's nightly job duly_dispatch (a defineJob handler) reads a data engine that the app binds once from defineStack({ onEnable }) (bindDispatchEngine(ctx.ql), a module-scope variable in src/jobs/dispatch.job.ts).

door 18.3.0 18.5.0
objectstack dev (and duly pnpm demo, which spawns objectstack dev --compile), clock at 01:00 sys_job_run duly_dispatch success, tasks created failed: "Job 'duly_dispatch' has no data engine", 4 of 4 runs, no tasks
objectstack start (serve without --dev), same recipe success success

Where (read from @objectstack/cli 18.5.0 dist/commands/serve.js, matches the measurement)

duly's config is a host config, so all three commands reach the !hasAppPluginAlready && configHasMetadata branch. Under --dev the #31761 block composes the dev artifact door and the wrap becomes new AppPlugin(loadArtifactBundle(dist/objectstack.json)): mergeRuntimeModule attaches the job functions from the bundled dist/objectstack-runtime.*.mjs, and graftAuthoredRuntimeMembers grafts onEnable from the config module. Those are two module evaluations of the same source file, so onEnable writes the module state of a copy the job never runs. The code comment says "both are one evaluation of the same module"; the measurement says otherwise. Without --dev the wrap is new AppPlugin(config), one evaluation, and the job works.

Expected

A dev boot runs an app's job functions and its onEnable from one module evaluation, as os start does and as 18.3 os dev did; or the platform refuses/announces the split instead of a silent per-run failure.

Impact

Any app whose job, action or hook handler reads state its onEnable sets at module scope silently stops working under os dev only, while os start, the gates and CI stay green. Not measured: an artifact-only boot (OS_ARTIFACT_URL, no config file).

Evidence: duly project report duly-18.5-browser-check/REPORT.md (sections "Dispatch" and "pnpm start"), clock/dispatch-0100.txt, clock/start-dispatch-0100.txt.

Dedupe: is:issue "no data engine" (133 hits, none on this), is:issue job handler module evaluation onEnable (1 hit, #14299, unrelated), is:issue created:>2026-11-12 os dev job handler (22 hits, none on this); #31761 is the change, closed.

Activity

  1. added
    bug
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · lease:A5 · p2 · 2026-11-16T00:51Z

    ⛔ Not a claim.

    A regression in 18.5.0, found by duly's upgrade pass (objectstack-ai/duly#190). objectstack dev evaluates the app module twice, so a defineJob handler runs from a different evaluation than onEnable. Module state that onEnable binds is missing when the job runs ("Job 'duly_dispatch' has no data engine"). It worked on 18.3.0. The measured door is the dev server (and pnpm demo), so p2. If the seat finds production boot (os start / serve) also double-evaluates, regrade p1. A5 (cli).

  3. added
    domain:server
    pm:queue
    priority:p2
    on Nov 16, 2026
  4. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

    Claim: server area-lease mode (#33751 §2), area S3, slot freed by PR #34043 entering the merge queue · executed by an os-dev sub-agent (mode:subagent) · posted at 2026-11-16T01:19Z
    Session: session_01QsR2jTEivi2wogPpeo3xd5
    Account: zhuangjianguo
    Branch: claude/area-A5-34179
    Worktree: objectstack-issue-34179
    Domain: domain:server
    Seat: domain:server#5
    File surface: packages/cli/src/commands/serve.ts (the host-config devArtifactDoor wrap block) and packages/cli/src/utils/graft-runtime-hooks.ts (or the runtime-module merge it pairs with), their tests under packages/cli/src/**, a patch changeset. Stop on breach and explain in the report.
    Container & model: M, mode:subagent, model: default, effort: high
    Clause-②: no
    Metadata-protocol: none (boot composition; no authorable key changes; the dev confirms against the diff)
    Responsibility: the cli dev boot's artifact-door wrap (objectstack repo: platform card carries the fix) | no platform path covers it; os start composes one evaluation | every app whose job, action or hook handler reads module state its onEnable binds, under os dev; duly's nightly dispatch job hits it now
    Thread-read: 6904291433
    Premise: holds (the card measures it on 18.5.0; the dev re-measures on main first, and also measures whether os start or serve without --dev double-evaluates, which the triage says regrades the card to p1)
    Serial constraints cleared: none. No open PR touches packages/cli/src/commands/serve.ts or graft-runtime-hooks.ts (file lists of all 61 open PRs read at claim time). The dev runs git merge-tree against origin/main before the push.
    Pre-claim lane: server, because the fix is in packages/cli.
    Pre-claim deps: none open (#31761, the change that introduced the wrap, is closed).
    Prior rulings read:

    • docs/adr/** grep for dev artifact, loadArtifactBundle, objectstack-runtime bundle, module evaluation: zero hits.
    • The serve.ts docblock of the os dev --no-compile warns "this boot serves the STALE build", yet the public forms route serves the edited source #31761 block states the intended rule, "one source per boot … the module contributes only the members a JSON artifact cannot carry … both are one evaluation of the same module". The card measures that last clause false. The fix restores the stated rule; it does not change it.
    • Triage 6904291433 (p2, regrade to p1 if production boot also double-evaluates).

    Generated by Claude Code

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 16, 2026
  6. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

    Regrade p2 → p1 · area S3 · 2026-11-16T03:05Z

    Triage 6904291433 set the condition for this: "If the seat finds production boot (os start / serve) also double-evaluates, regrade p1." The dev measured real boots on main's composition, with a job handler reading state its onEnable bound. Production fails too: a non-host config under os start (createStandaloneStack plus the hasAppPluginAlready graft) left the state unset. Results by boot:

    • host os dev: unset;
    • host os start: bound;
    • non-host os dev: unset;
    • non-host os start: unset;
    • artifact-only os start: unset. Its onEnable never runs, by the documented rule that an artifact carries no onEnable. That is not this defect.

    The fix on claude/area-A5-34179 changes the one graft that both serve sites call, so it covers the production path as well. The PR follows.

    Generated by Claude Code

  7. added
    priority:p1
    and removed
    priority:p2
    on Nov 16, 2026
  8. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5
    os-dev-report

    {
      "issue": 34179,
      "status": "done",
      "branch": "claude/area-A5-34179",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34297",
      "head": "e367244114",
      "session": "session_01QsR2jTEivi2wogPpeo3xd5",
      "premise_still_valid": true,
      "summary": "graftAuthoredRuntimeMembers (packages/cli/src/utils/graft-runtime-hooks.ts, now async, called at both serve graft sites) re-points every callable an artifact's runtime module supplied at the config module's own callable for the same ref (lowerCallables over the normalized config, the reading os compile builds the runtime module from), whenever the bundle has a runtimeModule and runs the config module's onEnable. onEnable and all job, hook and action handlers then share one module evaluation. Fixed doors: os dev on host and non-host configs, and os start / os serve on a non-host config (measured double-evaluating on main, the p1 regrade). Unchanged: artifact-only boots (no onEnable runs) and host os start. A ref the config no longer serves (stale artifact under --no-compile) stays on the runtime module, and the boot warns once naming it. One top-level row added to packages/cli/test/normalized-call-sites.test.ts, granted by the area.",
      "tests": "Head e367244114: cli unit project Test Files 423 passed (423), Tests 6017 passed (6017). New pin in graft-runtime-hooks.test.ts: in-process os compile, the runtime's loadArtifactBundle, serve's bundleConfigModule, a real AppPlugin, handlers read via collectBundleFunctions; a functions-entry job handler and a hook see the engine onEnable bound. Ablation (ablation-replace.mjs, anchor x1 to x0): 3 failed | 18 passed, 'Caused by: Error: Job one_dispatch has no data engine'; restored, blob == HEAD, git diff HEAD empty. Real boots (1 s interval job writes the state onEnable set): main composition gives host os dev unset, host os start bound, non-host os dev unset, non-host os start unset, artifact-only unset; this PR gives bound on all four config doors, artifact-only unchanged.",
      "gates": "cli typecheck (8192 MB heap) exit 0; pnpm lint exit 0; dispatch-gates --commands on the merged tree: 74 families all exit 0, --ran reconciled '74 run, 0 NOT-MEASURED (a DERIVED zero)'. check:dual-build-cjs-loads and check:i18n-coverage first exited 3 (workspace unbuilt) and read 0 after a workspace build. check:type-check-debt first returned 99 (queue) and read 0 on the re-take. PR body gates: check-changeset-no-major, check-adr-0087-registration, check-closing-keyword-parity, check-partof-closing-keyword all exit 0. CI check-runs: in_progress at report time. cli integration tier and direct dependents declared to CI: the module is not in cli's exports.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — pr_create via fleet-write relay (PR 34297); this os-dev-report comment via post-stamped",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · boundary: an artifact-only boot runs no onEnable (the runtime module exports only functions); single evaluation, documented, not this defect",
        "carrier: area S3 · dev-common asks for direct-dependent tests; os-dev.md owes them only on a public-surface change, and graft-runtime-hooks is not exported; declared to CI",
        "carrier: none · graft-runtime-hooks.test.ts wall is about 22 s locally, mostly import/transform of the in-process os compile (tests 345 ms); no test-budget header without a CI reading"
      ],
      "deviations": "The 'main' boot column was measured with the re-point line removed from the built dist (sha256 restored), not with a separate main build. Merge commit e367244114 carries git's default message.",
      "files_changed": [
        ".changeset/34179-dev-one-module-evaluation.md",
        "packages/cli/src/commands/serve.ts",
        "packages/cli/src/utils/graft-runtime-hooks.ts",
        "packages/cli/src/utils/graft-runtime-hooks.test.ts",
        "packages/cli/test/normalized-call-sites.test.ts"
      ]
    }
  9. removed
    pm:dispatched
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdomain:serverpriority:p1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions