Skip to content

fix(core): refuse an artifact package cycle as 422 CYCLIC_ARTIFACT_PACKAGES; install-local answers resolver refusals instead of a 500 - #34708

Merged
os-zhuang merged 9 commits into
mainfrom
claude/issue-34574-artifact-cycle-refusal
Nov 17, 2026
Merged

os-zhuang merged 9 commits into
mainfrom
claude/issue-34574-artifact-cycle-refusal

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #34574
Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 改了什么:组合制品里的包如果互相依赖成环,安装接口现在回 422,错误码是新登记的 CYCLIC_ARTIFACT_PACKAGES,details.cycle 列出环上的包。另外,本地安装在真实运行时下遇到制品解析器的其它三种拒绝时,也按各自的 422 回答,不再回不透明的 500。
  • 为什么改:以前作者只拿到一个不说原因的 500,要翻服务端日志才知道是循环依赖,或是 packages 写错了。
  • 风险与回滚:只改了被拒绝的请求怎么回答,原来能装上的制品照样能装。内核启动遇到插件循环时,报错文字与以前逐字相同。回滚就是 revert 本 PR,新错误码随之撤销。
  • 先看:packages/cloud-connection/src/marketplace-install-local-plugin.ts(1c 步新增的拦截,以及 declaredRefusalAnswer 转发 details)、packages/core/src/artifact-packages.ts(环如何变成 422)、packages/spec/src/api/error-code-ledger.zod.ts(新错误码的登记行)。
  • 两分钟验证:pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-resolver-refusal-real-runtime.test.ts,预期 5 个用例全部通过:环、packages 不是数组、包 id 重复这三种都回 422 和各自的错误码,合法的组合制品照常装上(200)。
  • 需要你做的:无,由席位在契约档审核后落地。

What changes

  • @objectstack/core
    • resolvePluginOrder now throws a cycle as PluginOrderCycleError. This is a new exported Error subclass with a cycle property listing the names along the cycle: each depends on the next, and the first is repeated last. The message is still [Kernel] Circular dependency detected: NAME, and the error carries no code or status, so kernel boot and the other callers of the sorter see no change.
    • resolveArtifactPackageEntries reads the cycle off that error, not off a second walk of the graph. It refuses with the envelope its sibling refusals use: code: 'CYCLIC_ARTIFACT_PACKAGES', status: 422 and details: { cycle }. The message names the cycle as "a" -> "b" -> "a" and still contains Circular dependency detected. Any other throw from the sorter is rethrown unchanged.
  • @objectstack/spec: CYCLIC_ARTIFACT_PACKAGES is registered in ERROR_CODE_LEDGER under @objectstack/core, beside its three siblings, using the seat's ledger text. The generated API references were regenerated with check:generated --fix; only check:docs was stale: content/docs/references/api/{error-code-ledger,contract,automation-api}.mdx.
  • @objectstack/cloud-connection (POST /api/v1/marketplace/install-local)
    • Step 1c, the runtime binder's unrunnable-code judgements, now answers a refusal from the artifact resolver with that refusal, through declaredRefusalAnswer. Steps 2a, 2b and 2c″ already did this. An undeclared throw is still rethrown.
    • Over the real runtime, step 1c is the first step that resolves a composed bundle's packages. Before this change, every resolver refusal (all three siblings, and the cycle) left the handler as a throw there. The transport renders no 422, so it answered 500 INTERNAL_ERROR.
    • declaredRefusalAnswer now also forwards the refusal's own details, which is how a cycle's details.cycle reaches the client.
  • Docblocks that described the cycle as a bare Error are corrected in dev-i18n.ts and runtime/src/artifact-collections.ts. Both are comment-only, so those packages get no changeset entry.
  • scripts/driver-memory-census.ledger.json gains one mock-replacement row, for dev-i18n-packages-reader.test.ts. That suite now replaces @objectstack/driver-memory with a not-found-throwing vi.mock, as five sibling plugin-dev harnesses do. Every DevPlugin boot in the file passes driver: false, so the real driver is never loaded. The mock exists because check:test-source-alias asks an edited test that reaches dev-plugin.ts's lazy driver import either to pay that load at collection or to mock it. The file's old comment forbidding a mock is rewritten to say why a replacement mock is not a consumer. The seat approved this in amendment 6941981971.

Tests

  • New pin, over the REAL runtime (no module mock): packages/cloud-connection/src/marketplace-install-local-resolver-refusal-real-runtime.test.ts drives the real install-local handler.
    • A two-package cycle answers 422 CYCLIC_ARTIFACT_PACKAGES with details.cycle.
    • packages: 'not-a-list' answers 422 INVALID_ARTIFACT_PACKAGES.
    • A duplicate package id answers 422 DUPLICATE_ARTIFACT_PACKAGE.
    • In those three cases nothing is registered, ledgered or read.
    • Control: the same packages without the closing dependency install (200).
    • A probe asserts that the runtime under test really carries collectJobsWithoutBody.
    • It is a new file rather than a describe in the install-local: an artifact the resolver refuses answers 503 "retry once the database answers" instead of the resolver's 422 #34432 file because that file mocks @objectstack/runtime for the whole file.
  • Core
    • artifact-packages.test.ts covers a two-package cycle (code, status, details.cycle, the message path) and a cycle path that skips packages outside the cycle and ignores an external dependency. Its control is the same packages without the closing edge, which resolve in dependency order.
    • plugin-order.test.ts covers PluginOrderCycleError's path, unchanged message and absent code/status, and a self-dependency.
  • Tests this change forced to move, each named:
    • marketplace-install-local-resolver-refusal-34432.test.ts: its cycle case pinned the cycle as an undeclared throw that is rethrown. It now pins the declared 422 CYCLIC_ARTIFACT_PACKAGES and details.cycle under that file's runtime mock, where step 2a reaches the resolver first. The rethrow leg has no other producer: the resolver's only remaining non-envelope throws are Plugin not found and Dependency not found, and neither is reachable through optionalDependencies. The 503 control (an unreadable table) is unchanged.
    • dev-i18n-packages-reader.test.ts: its cycle case pinned code and status as undefined. It now pins CYCLIC_ARTIFACT_PACKAGES, 422 and details.cycle. The memory driver is now a replacement mock (see What changes).
    • marketplace-install-local-namespace-gate-33922.test.ts, case "UNMOVED — an artifact MEMBER's refused namespace...": this case boots the real runtime and pinned the resolver's INVALID_ARTIFACT_PACKAGE_ENTRY as a throw out of the handler, which is the step-1c escape this PR closes. It now asserts the answered 422 with the same code and sentence, ADR-0112 envelope-clean.
Test runs (b1dc2a6, the last code commit; 8490dc5 adds only a merge of ui/ files from main)
  • On b1dc2a6, after a full turbo run build, under the verify lock (VERDICT command-exit 0):
    • spec check:generated: 14/14 up to date.
    • plugin-dev test: Test Files 10/10, Tests 89/89.
    • core plugin-order + artifact-packages: Test Files 2/2, Tests 42/42.
    • cloud-connection real-runtime + 34432 + namespace-gate-33922: Test Files 3/3, Tests 25/25.
    • typecheck for plugin-dev and cloud-connection: exit 0.
  • Whole-package runs on 1270f90 + f118d4c, before the forced moves:
    • typecheck for core, cloud-connection, plugin-dev, spec and runtime: exit 0.
    • core test: 151 files, 3611 tests, all passed.
    • plugin-dev test: 10 files, 89 tests, all passed.
    • spec test: 847 files, 27154 passed, 1 todo.
    • objectql artifact-load-path + package-source-stamp: 2/2 files, 26/26 tests.
    • cloud-connection test: 1 failed of 1308. That was the namespace-gate case named above; after its move the file reads 15/15.
  • The typecheck for those five packages was re-run after the forced moves: exit 0.
Ablations, one per behaviour (scripts/ablation-replace.mjs, anchor hit 1, mutation landed, restore proven blob == HEAD and git diff HEAD empty)

Every mutated file is read from source by the suite that runs, so no dist preflight is needed. The core suites import their own src. The cloud-connection suites import the handler by relative path; it reads @objectstack/core from dist, which was built from this head.

  • A1, artifact-packages.ts: the cycle rethrown bare (throw err;). Core: 2 failed / 40 passed, the two cycle cases.
  • A4, plugin-order.ts: the sorter throws the old bare Error. Core: 4 failed / 38 passed, the two PluginOrderCycleError cases and the two resolver cycle cases.
  • A2, marketplace-install-local-plugin.ts: step 1c's call moved ahead of its try. Cloud-connection: 3 failed / 7 passed, the real-runtime cycle, not-a-list and duplicate cases. The control and the mocked-runtime file stay green.
  • A3, declaredRefusalAnswer: the details spread deleted. Cloud-connection: 2 failed / 8 passed, the details.cycle assertions in both files.

Acceptance notes

  • FROM → TO, measured.
  • Clause-②: yes (widening), per claim amendment 6939909352. One public error code is minted, and a 500 becomes a typed 422. Nothing that was accepted before is refused now.
  • Surface: amendment 6941981971 added marketplace-install-local-namespace-gate-33922.test.ts (moved by the step-1c fix, named under Tests) and scripts/driver-memory-census.ledger.json (one mock-replacement row). check:driver-memory-census and check:test-source-alias both exit 0 on 8490dc5.
  • Generated: only check:docs was stale after the ledger row. It was regenerated with check:generated --fix into content/docs/references/api/error-code-ledger.mdx, contract.mdx and automation-api.mdx. The other 13 artifacts were up to date, and they still were after the last origin/main merge, when check:generated was re-run.
  • Callers of resolveArtifactPackageEntries / resolveArtifactPackageOrder (cli namespace utils, core stack-collections, metadata, objectql, plugin-dev, plugin-security, runtime, verify) now see a cycle as the typed refusal.
    • No caller in packages/** source reads the old message text.
    • Two tests match only /Circular dependency detected/: the dogfood dataset-app-reads-module cell 3 and core plugin-order.test.ts:69. The new message keeps that phrase.
    • install-local's rehydrate classifies a declared 4xx as a refusal that no restart heals, which is the correct reading for a cycle.

Verification

  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at head 8490dc5 derived 129 families. All 129 were run, each with stdin from /dev/null and its exit code captured before any pipe; all 129 exited 0.
  • --ran reconciliation: 129 derived, 129 run, 0 NOT-MEASURED, 0 UNRUN.
  • node scripts/pm/check-governed-merges.mjs --pr 34708 at 8490dc5:
    • ✅ NOT governed — ordinary queue landing applies to a PR with exactly this file list.
    • It reports 0 of 17 paths on the register and a size of 548 changed lines (+463 / -85), under 3000.
    • Separately, the claim routes the review to the contract tier because of the spec ledger row and the new export.
  • On earlier heads: check:skill-examples, check:dual-build-cjs-loads and check:dts-closure refused on build prerequisites, which a full build cleared. check:test-source-alias and check:driver-memory-census were each red once, cleared by the two test edits and the ledger row above.
  • The dogfood battery is not run locally: the title carries no ! and Clause-② has no (narrowing) arm.

Generated by Claude Code

…CKAGES; install-local answers resolver refusals at step 1c

resolvePluginOrder throws its cycle as PluginOrderCycleError (message
unchanged, carries `cycle`); resolveArtifactPackageEntries answers it in
the ADR-0112 envelope its sibling refusals carry, with details.cycle. The
code is registered in ERROR_CODE_LEDGER under @objectstack/core.
install-local's step 1c (the runtime binder's judgements, the first reader
of the packages on a real runtime) answers a resolver refusal with that
refusal instead of letting it reach the transport as a 500, and
declaredRefusalAnswer forwards the refusal's details.

Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz
Co-authored-by: Claude <noreply@anthropic.com>
…wered 422, no longer thrown out of the door

Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/cloud-connection, @objectstack/core, @objectstack/plugin-dev, @objectstack/runtime, @objectstack/spec, touching 9 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/plugins/plugin-dev/src/dev-i18n.ts, packages/runtime/src/artifact-collections.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

13 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/api/error-catalog.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/api/error-handling-server.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/automation/connectors.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/data-modeling/external-datasources.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/data-modeling/seed-data.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/deployment/app-dependencies.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/deployment/cli.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/deployment/install-modes.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/deployment/marketplace-handbook.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/deployment/publish-and-preview.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/kernel/contracts/data-engine.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/protocol/kernel/plugin-spec.mdx (via resolvePluginOrder (symbol, a top-level function))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/releases/v17/17-1.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/releases/v17/17-4.mdx (via ERROR_CODE_LEDGER (symbol, a top-level const object))
  • content/docs/releases/v18/18-2.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))
  • content/docs/releases/v18/18-4.mdx (via /api/v1/marketplace/install-local (route, a path literal in a comment in ERROR_CODE_LEDGER))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/plugins/plugin-dev/src/dev-i18n.ts, packages/runtime/src/artifact-collections.ts) — pages documenting those are invisible to this run
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 188 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2e29287b9355b406caa3e63ac35c836a59df9704 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 3d2259f0007f770784ac1d55f1de5792bac5adee — the merge of head 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88 into base 2e29287b9355b406caa3e63ac35c836a59df9704, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 3d2259f0007f770784ac1d55f1de5792bac5adee && git checkout 3d2259f0007f770784ac1d55f1de5792bac5adee
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2e29287b9355b406caa3e63ac35c836a59df9704 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88 && git checkout -B drift-repro 2e29287b9355b406caa3e63ac35c836a59df9704 && git merge --no-ff 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88

node scripts/docs-audit/affected-docs.mjs --json 2e29287b9355b406caa3e63ac35c836a59df9704

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 2e29287b9355b406caa3e63ac35c836a59df9704 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Final head for review: 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88 (card #34574, branch claude/issue-34574-artifact-cycle-refusal). CI on this head, latest run per check: 66 green (54 success, 12 skipped), 0 failed. Derived gates 129/129 exit 0. check-governed-merges.mjs --pr 34708: NOT governed, 0 of 17 paths. Clause-②: yes (widening) (new public code CYCLIC_ARTIFACT_PACKAGES and export PluginOrderCycleError), Metadata-protocol: none. Surface amendments 6939909352 and 6941981971; dev report 6942992832. Owed: L1 review and the contract-tier L2 review (a packages/spec/src path), both on this head; then the seat's governed step. The PR stays a draft and unarmed. A push after this comment restarts both.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 8490dc5 · 2026-11-17T08:42Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmTHGRTjPqZAcBuo9WH

席位核对

L1 first review · ACCEPT · head 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88 (final head 6943080601) · card #34574 · read 2026-11-17T08:48Z

Checklist (read on GitHub at this head, not from the report)

  • Shape: draft, base main, mergeable_state: clean. Fixes #34574 is the only closing-keyword hit in the body. The body ends with the session-URL footer and the signed note.
  • Declarations: Clause-②: yes (widening) and Metadata-protocol: none, in both the body and the changeset. Confirmed as widening from the diff: the inputs that change (a cycle, packages that is not a list, a duplicate id) answered 500 INTERNAL_ERROR over the real runtime and now answer their declared 422. Nothing that was admitted before is refused now, and the control (the same packages without the closing edge) still installs with 200. The kernel's plugin-cycle message is byte-identical ([Kernel] Circular dependency detected: <name>, still no code or status). No Skills-docs: line is owed: the kind is none and there is no narrowing arm. The skills/** cycle text (objectstack-platform/rules/plugin-lifecycle.md:252) is about kernel plugins and is unchanged.
  • File surface: 17 files, +463/−85, from pulls/34708/files. Amendment 6941981971 covers the namespace-gate test and the census ledger row.
  • Mechanism, read in the source:
    • plugin-order.ts: path is pushed after visiting.add and popped before visiting.delete. So when a name is met again while it is still being visited, it is on path, and path.slice(indexOf(name)) plus the name gives the cycle in edge order. A self-dependency gives ['a','a']. PluginOrderCycleError keeps the old message, built from the last element, which is the name re-met, exactly as before. cycle is frozen.
    • artifact-packages.ts: only PluginOrderCycleError is re-wrapped. Plugin not found and Dependency not found still escape bare. refuse() gains an optional details.
    • Install-local step 1c: unrunnableCode now runs inside try. A declared status below 500 is answered through declaredRefusalAnswer, and anything else is rethrown. declaredRefusalAnswer forwards details only when it is a plain object, not an array and not null.
    • Other callers: I grepped the non-test source for branches on code or status near the resolver callers. Install-local's uninstall guard and pair-door text only answer a declared 4xx, which is now consistent for a cycle. No source caller matches the old message.
  • Spec face: one ERROR_CODE_LEDGER row, CYCLIC_ARTIFACT_PACKAGES, under @objectstack/core. The three regenerated docs differ only by +368 more → +369 more and the added bullet.
  • Tests:
    • ...resolver-refusal-real-runtime.test.ts (new) boots the real runtime and asserts that collectJobsWithoutBody is present. It covers three refusals, each checked with expectNothingWritten: no register call, no manifest-source entry, and planDeclaredRenames never called. It also has a 200 control.
    • The three forced test moves are each named in the body and match the diff.
    • The core tests pin the path through an optional edge, outsiders skipped, an external dependency ignored, and the unchanged message with no code.
  • Deviation, accepted: dev-i18n-packages-reader.test.ts drops a ⛔ NO driver-memory mock here comment and adds the absent-module vi.mock, with a census ledger row whose axis is mock-replacement.
    • The removed comment's premise was that a mock would make the file a third test consumer. But the census's closed vocabulary defines mock-replacement as "the real driver is never loaded here", which is not a ruled consumer.
    • main already carries 10 such rows, 4 of them in this same package (dev-plugin*.test.ts).
    • The edit is forced by check:test-source-alias on an edited test, and the area named it up front.
    • Recorded so L2 sees it; no change asked.
  • Gates at this head: check-runs on 8490dc5d…: 72 runs, 60 success, 12 skipped, 0 failed. The report's 54 predates the re-runs. git merge-tree --write-tree against today's origin/main is clean. check-governed-merges.mjs --pr 34708, read here: NOT governed, 0 of 17 paths, 548 lines.

Residual (code-read, no change asked)

  • The changeset bumps @objectstack/spec as patch for a new public error code. That is consistent with the ledger's additive rows; I only note it for the contract tier.

Owed after this

  • L2: owed, CONTRACT_REVIEW_TIER. Spec face: a non-test packages/spec/src row in the error-code ledger. Also Clause-②: yes and the new core export PluginOrderCycleError.
  • Landing tier: spec face, handed to the seat for Tier H (seat rule of 03:21Z). Not governed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88
Local-runs: none
Scope: packages/spec/src/api/error-code-ledger.zod.ts + packages/core/src/artifact-packages.ts, packages/core/src/plugin-order.ts, packages/cloud-connection/src/marketplace-install-local-plugin.ts, packages/plugins/plugin-dev/src/dev-i18n.ts (jsdoc), packages/runtime/src/artifact-collections.ts (jsdoc)

Inputs read: card #34574 body and all 7 comments (claim 6939731523, amendments 6939909352 and 6941981971, the three dev reports), PR #34708 body, its 17-file list and 3 comments, the net diff against merge-base 2e29287b9, and the 72 check-runs on this head: every one completed, each success or skipped, none failed, none pending. The remaining 11 paths (tests, changeset, three generated reference pages, the census ledger) are the lane seat's ACCEPT at TIER_DEFAULT.

① Derived judgments

  • Refusal vocabulary widens by one code: right. CYCLIC_ARTIFACT_PACKAGES joins ERROR_CODE_LEDGER['@objectstack/core'], so ErrorCode, ApiErrorSchema.code and FlowInnerRefusal.code each accept one more member. The stamp site is refuse() in packages/core/src/artifact-packages.ts, inside the owner key that lists it, which is what the provenance rule in the ledger header asks.
  • A package cycle moves from a bare Error to a typed refusal at every reader: right. The change is made once, in resolveArtifactPackageEntries, so every caller of it, of resolveArtifactPackageOrder, of resolveStackCollection and of the runtime's resolveArtifactCollections sees code: 'CYCLIC_ARTIFACT_PACKAGES', status: 422, details.cycle (cli namespace utils, metadata, objectql's manifest service and reload, plugin-dev, plugin-security, runtime, verify). The verdict itself is unchanged: the sorter refused the same inputs before, self-dependency included.
  • No previously accepted input is refused: right. resolvePluginOrder changes only the class of the value it throws and tracks a path array beside the existing visiting set; ordering and the set of refused graphs are untouched. The install-local change converts a throw into an answer and adds no new judgement.
  • install-local, real runtime: three sibling refusals and the cycle move from 500 INTERNAL_ERROR to their own 422: right. The transport cannot do this itself: declaredEnvelopeForThrow renders only a status that is a key of HttpStatusErrorCodeMap, and 422 is not one, so a thrown 422 falls to the bare 500. The door has to answer.
  • The new catch reclassifies nothing: right. declaredRefusalAnswer answers only a throw that itself declares a status below 500, with that throw's own status and its own registered code; an undeclared throw (a TypeError, a ZodError with no status) and any declared 5xx are rethrown unchanged. The sentence it appends, that nothing was installed or written, is true at this position: the unrunnable-code step precedes the conflict check, the datasource step, the hot-register and the ledger write. A side effect, stated because it is wider than the card: any other declared 4xx thrown out of the runtime binder's judgements at that step (for example MIXED_ARTIFACT_COLLECTION_SHAPE) is now also answered as itself instead of a 500. That is the same rule, and the right answer.
  • declaredRefusalAnswer forwards the refusal's own details on all four steps that use it: right, and a widening. The envelope from steps 2a, 2b and 2c″ may now carry details where it carried code and message only. It is read only when it is a plain object; ApiErrorSchema.details is z.unknown().optional(), so the envelope still parses.
  • New public export PluginOrderCycleError from @objectstack/core: right. packages/core/src/index.ts already re-exports ./plugin-order.js whole, so the class is on the package index. It extends Error, keeps the message [Kernel] Circular dependency detected: NAME byte for byte, and carries no code and no status. The absent code is the correct reading of the [Decision] Clause ② on an UNREGISTERED error code carried by a thrown value: #14552 landed no, #15963 lands yes, and they are the same class #16404 rule in the ledger header (a code that ships in dist owes a row): the sorter mints no vocabulary, and the one mapping to the ledger code is the instanceof branch in resolveArtifactPackageEntries. Kernel boot (kernel.ts, kernel-base.ts) and orderHydrationBatch call the sorter directly and none of them reads a code.
  • ArtifactPackageError gains an optional details: right, additive on an exported type.
  • Generated reference pages match the ledger. error-code-ledger.mdx, contract.mdx and automation-api.mdx each gain the one member in alphabetical position, and the two enum summaries move from +368 more to +369 more. No other page in the diff restates the list.
  • Doors, asked one by one. install-local: answered at the unrunnable-code step, and at 2a, 2b and 2c″ for a runtime that carries no judgements. Plugin order at kernel boot: no HTTP door, the typed error is the boundary. Runtime resolveArtifactCollections and the plugin-dev i18n reader: boot and dev-boot readers with no HTTP door of their own; both now throw the typed refusal and both docblocks say so. objectql's manifest service: reached from install-local only after the steps above, and its reload path catches and logs. I found no HTTP door on this tree that still answers 500 INTERNAL_ERROR for a package cycle under the runtime the repo ships.

② Semver level

Clause-②: yes (widening) — correct. The ledger header rules that registering a code widens the published error-code face, and the new export widens @objectstack/core. The line is present in the PR body and in the changeset body, with Metadata-protocol: none.

Metadata-protocol: none is right: nothing a metadata author can write is added, removed or re-read; a cyclic artifact was refused before and is refused now. Under AGENTS.md Post-Task step 3 the level follows the kind alone, and none takes patch. The changeset carries patch for @objectstack/core, @objectstack/spec and @objectstack/cloud-connection, the three packages whose behaviour or vocabulary moves. No BREAKING banner is owed: nothing is removed or renamed, and the changeset says a caller matching the old message still finds Circular dependency detected.

@objectstack/plugin-dev and @objectstack/runtime move by docblock only and carry no changeset entry. The corrected @throws text does ship in their declaration files, but the behaviour it describes is published by core and stated in core's entry. Accepted as the lane's call; Check Changeset is green on this head.

③ Boundary flags

  • Dev flag, report 6939868658 (needs_decision: no registered code fits a cycle): answered by the seat's naming ruling relayed in amendment 6939909352, which also moved the declaration to Clause-②: yes (widening). The name is the seat's call and is not judged here.
  • Dev flag, report 6941957403 (blocked: check:driver-memory-census red, remedy outside the surface): answered by amendment 6941981971. The ledger row is the mock-replacement axis the ledger itself defines for a vi.mock factory, it names the one test file whose mock this diff adds, and the factory in the diff throws not-found as the row says. The census is hand-edited by its own rule, not generated; the row is the whole change to that file.
  • Dev flag, same report (marketplace-install-local-namespace-gate-33922.test.ts outside the surface): answered by the same amendment as a forced move; lane remainder.
  • Dev flag, report 6942992832 (PR body patch refused by the relay): closed. The PR body on this head carries the prepared text and the signed trailer.
  • open_questions: none in any report.
  • Governed surface: none of the 17 paths is on the governed register (instruction files, skills, ADR surfaces), and Governed Surface Queue Guard is green on this head. The contract tier is owed by the published-schema face alone.
  • SQL push-down: not applicable. The diff adds no query, no id materialisation and no in-app join; the only new data structure is the sorter's in-memory visit path.
  • Docs Drift Check (advisory, comment 6941969340): the hand-written pages it lists name ERROR_CODE_LEDGER, the install-local route or resolvePluginOrder. I read the ones that discuss these refusals (content/docs/plugins/packages.mdx, content/docs/protocol/kernel/plugin-spec.mdx): neither states that an artifact cycle is a bare error, and the kernel boot message plugin-spec quotes is unchanged. Nothing is falsified.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/api/error-code-ledger.zod.ts — against the ruling it implements (amendment 6939909352, ADR-0130 D5) and its first consumer (declaredRefusalAnswer on install-local).

  • Needed: yes. The standard catalog has no member for "packages that cannot be ordered", and the three siblings each carry their own registered code at 422; a cycle answered under a sibling's code would mis-state the fault, and under the status-derived member would lose the specific code. The synonym gate and the admission lint are green.
  • Placed: under @objectstack/core, the package that stamps it, directly after its three siblings.
  • Shaped: the comment states the status (422, stamped by refuse()), the details.cycle shape and its reading order, and the door. Each sentence agrees with the code at this head: edges are manifest.dependencies keys entered as the sorter's optional edges, the path is read off PluginOrderCycleError.cycle, and install-local forwards details.
  • Tried to break: a cycle mixing hard and optional edges, a cycle reached past packages outside it, a dependency on a package the artifact does not carry, and a self-dependency all produce a path in edge order with the first id repeated last; path and visiting are pushed and popped together, so path.indexOf cannot miss. The instanceof test cannot fail across duplicate copies of core, because the throw and the catch are in one module graph. A non-cycle throw from the sorter is rethrown unchanged.

packages/core/src/plugin-order.ts, packages/core/src/artifact-packages.ts — agree with the ledger row and with their own docblocks, sentence by sentence. The module header's "never off a second walk of the graph" holds: the resolver reads the sorter's path and adds no second sort, which is what ADR-0130 D5 forbids. The refusal message keeps Circular dependency detected, so the two tests on main that match that phrase stay pinned.

packages/cloud-connection/src/marketplace-install-local-plugin.ts — the catch is the same three lines steps 2a, 2b and 2c″ already use, so the same bytes are answered alike whichever step reads them first, which is the function's stated contract. Judged under ① for what it can and cannot catch.

dev-i18n.ts, runtime/src/artifact-collections.ts — comment-only, and both now describe the behaviour the tree has.

Nits, none affecting correctness or the contract; all are prose in code files, so they are left as accepted deviations or a follow-up card, not fixed on this head:

  • N1 (nit) — the ledger comment says "two or more of whose packages depend on each other". A package whose manifest.dependencies names itself is refused under the same code with details.cycle of ['a', 'a'] (pinned in plugin-order.test.ts), so one package suffices.
  • N2 (nit) — the new row sits inside the group headed "The nine rows below are door: 'none' codes ... none reaches an HTTP door on this tree", and says "Door reading as the siblings", while the sibling paragraph directly above still records install-local answering with PLUGIN_REGISTER_FAILED. The new row's own reading is the true one. The sibling paragraph was already out of date on main (since install-local: composed artifacts read package-owned collections from the top level only (translationsLoaded 0; global-unique gate sees no objects) #34407 and install-local: an artifact the resolver refuses answers 503 "retry once the database answers" instead of the resolver's 422 #34432), and this PR extends the siblings' reach to the real runtime. Worth a follow-up card that refreshes the group count and the sibling door reading in one pass.
  • N3 (nit) — declaredRefusalAnswer's docblock (and the new test's title) call the unrunnable-code step "1c". In the handler that step is labelled 1d; 1c is the ADR-0087 protocol handshake.
  • N4 (nit) — details.cycle reaches the wire because declaredRefusalAnswer reads err.details itself. The shared resolveThrownHttpError does not read a thrown details, so a future door answering this refusal through the shared resolver would carry the code and status without the cycle. No such door exists on this tree. Recorded for whoever adds one.

Implemented-by: claude/issue-34574-artifact-cycle-refusal
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

Seat record · 2026-11-17T08:51Z · Head-sha: 8490dc5

维护者速读

  • 改了什么:组合制品里的包如果互相依赖成环,安装接口现在回 422,错误码是新登记的 CYCLIC_ARTIFACT_PACKAGES,details.cycle 列出环上的包。本地安装在真实运行时下遇到制品解析器的另外两种拒绝(packages 不是数组、包 id 重复)时,也按各自的 422 回答,不再回不说原因的 500。
  • 为什么改:以前作者只拿到一个 500,要翻服务端日志才知道是循环依赖还是 packages 写错了。
  • 风险与回滚:只放宽(Clause-②: yes (widening)):只改被拒绝的请求怎么回答,原来能装上的制品照样能装;内核启动遇到插件循环时,报错文字与以前逐字相同。回滚即撤回本 PR,新错误码随之撤销。
  • 先看:packages/cloud-connection/src/marketplace-install-local-plugin.ts(新增的拦截,以及 declaredRefusalAnswer 转发 details)、packages/core/src/artifact-packages.ts(环如何变成 422)、packages/spec/src/api/error-code-ledger.zod.ts(新错误码的登记行)。
  • 两分钟验证:pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-resolver-refusal-real-runtime.test.ts,预期 5 例全过:环、packages 不是数组、包 id 重复各回 422 和各自的错误码,合法的组合制品照常装上(200)。
  • 需要你做的:用 os-zhuang 审读并批准(本 PR 在 packages/spec/src 的错误码账本登记了新错误码)。契约复审 PASS 6943259717,钉在 Head-sha 8490dc5d22e034f0a368bc3f89d10d6b0bdfcf88。批准在案后由席位翻 ready,经合并队列落地。

席位意见:同意合并。把不透明的 500 换成说清原因的 422,作者和 AI 都能直接看到是哪个环;新错误码名由席位按既有命名定下,只加不减。

席位核对

  1. 形态:17 个文件,+463/−85,Fixes #34574;Clause-②: yes (widening),Metadata-protocol: none(故不欠 Skills-docs: 行)。在 packages/spec/src 新增错误码登记行,另有新导出 PluginOrderCycleError ⇒ spec 面交人;check-governed-merges 判 NOT governed(0/17)。
  2. 前提实测:真实运行时钉子 5 例覆盖三种拒绝各回 422 与合法制品 200;L1 确认三种原来都回 500。
  3. 门禁 check-runs:head 8490dc5d 上 72 条,60 绿、12 跳、0 红;mergeable clean;区门禁 129/129。
  4. 接受的偏差:L1-b2 ACCEPT 6943245653;契约复审 PASS 6943259717,无 must-fix/should-fix。L1 记录一处偏差不要求改:dev-i18n 测试删掉了「不许 mock driver-memory」的注释,改为一个 absent-module mock,并在 scripts/driver-memory-census.ledger.json 记一行 mock-replacement;普查词表本就把这类定义为不加载真驱动,main 上已有 10 条同类。namespace-gate-33922 测试按扩面第二次修订(6941981971)一并改动。
  5. 范围外去向:复审 nit N1(账本注释「两个或以上的包」漏了自依赖)、N2(error-code-ledger 该分组标题和兄弟段的门描述在 main 上已过时)、N3(docblock 与测试标题把步骤叫 1c,handler 里是 1d)、N4(共享的 resolveThrownHttpError 不读 throw 自带的 details,目前无门受影响)合为一张跟进卡,合并后由席位立卡交分诊。
  6. 落地条款:os-zhuang 授权批准在案后,席位翻 ready,经合并队列落地;Fixes #34574 合并即关卡,区清 install-local: a composed artifact with a package dependency cycle answers an opaque 500 instead of naming the cycle #34574 的 pm:dispatched 与 lease:o2-D。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 09:04
@os-zhuang
os-zhuang enabled auto-merge November 17, 2026 09:04
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit f02f4f6 Nov 17, 2026
78 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-34574-artifact-cycle-refusal branch November 17, 2026 09:36
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install-local: a composed artifact with a package dependency cycle answers an opaque 500 instead of naming the cycle

3 participants