Repository navigation
feat(cli): os validate --target judges the stack against a target environment's restriction profile - #31237
Conversation
…on profile Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fKNXpyrradyNkX9jx
…ironment's restriction profile Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fKNXpyrradyNkX9jx
… plugin loads at collection Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fKNXpyrradyNkX9jx
…racket placeholder Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fKNXpyrradyNkX9jx
📓 Docs Drift CheckThis PR changes 1 package(s): 20 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 35 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 53282d56b6aea5396240469ec80f55e5c6801854 && git checkout 53282d56b6aea5396240469ec80f55e5c6801854
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin df22adc370bae67424297c3d00841ce7ca0d3365 8c5e74a7b61a2eded18b13b6cfdded4838ba22ef && git checkout -B drift-repro df22adc370bae67424297c3d00841ce7ca0d3365 && git merge --no-ff 8c5e74a7b61a2eded18b13b6cfdded4838ba22ef
node scripts/docs-audit/affected-docs.mjs --json df22adc370bae67424297c3d00841ce7ca0d3365
|
|
domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F 席位核对 — ACCEPT · domain:server#4 · Head-sha:
|
Requested by 田騏 · project thread
Fixes #31156
Clause-②: yes
Metadata-protocol: none
维护者速读
os validate新增--target PROFILE_FILE。它读取目标环境的限制配置(第 1 项已合入的RestrictionProfileSchema),把本地元数据里该环境不允许的东西逐条拒掉,每条写明是哪一项、被哪条规则拒(写代码、定时任务、流程节点类型);本地 spec / skills 版本和目标环境不一致时只告警,不拒。--target时命令行为完全不变(有对照测试)。只改packages/cli,patch 版本。回滚就是还原这个 PR。另外:--target目前只接受文件,传 URL 会被明确拒绝,因为目标环境还没有定义发布限制配置的地址(第 3 项在 cloud 仓)。packages/cli/src/utils/restriction-profile.ts(三条读者规则在judgeNodeType);packages/cli/src/commands/validate.ts的 step 0 / 1c / 3f;packages/cli/test/validate-target-restriction-profile.test.ts。pnpm --filter @objectstack/cli exec vitest run src/utils/restriction-profile.test.ts test/validate-target-restriction-profile.test.ts,预期 30 个用例全部通过。What changes
os validate --target PROFILE_FILEjudges the stack against a target environment's restriction profile. Without--targetnothing new runs.Step 0, the profile.
loadRestrictionProfilereads the file and parses it withRestrictionProfileSchema(@objectstack/spec/system, PR #31191). It runs before the stack is loaded. A URL, a missing file, a file that is not JSON, or a profile the schema refuses is refused through the catch-all (--json:error, exit 1), and the message names the schema issue path.{}is refused, so an absent dimension never reads as "no restriction".Step 1c, version drift.
restrictionProfileVersionDriftcompares the project's@objectstack/specand@objectstack/skillswithversions.spec/versions.skills. They are resolved from the config's directory; spec falls back to the CLI's own copy, the way the protocol drift advisory resolves it. Each package that differs gives one warning (package,local,target,message). A project that does not install the skills catalog getslocal: null. The warnings ride--jsonwarnings(appended last inwarningsSoFar()), and the text face prints them in their own block. They never refuse, and--strictdoes not gate them: the target's version is the environment's, not something the stack can fix, the same reason the protocol drift advisory is never gated by--strict.Step 3f, the refusals.
judgeRestrictionProfileruns after every other refusal. Those gates ask whether any runtime accepts the stack; this one asks whether this target does. It gives one row per refused item:rule(the ONE profile dimension),where(the item, named),pathandmessage. It walks eachpackages[]entry, or the stack and itsmanifestwhen there are no packages, the way the CLI's other walks do.allowCode: falserefuses eachhooksentry (the profile docblock names hooks) and each item under a key the spec classifies as code:UNMANAGED_INSTALL_KEY_DISPOSITIONSdispositioncode, the one tabledefineStack's unmanaged-install refusal and the install planner already share (functionsper function,plugins/devPluginsper entry, the others per key, on the stack or its manifest). An empty key (functions: {}) refuses nothing, by the sameunmanagedInstallValueCarriestest.allowScheduledAutomation: falserefuses each flow oftype: 'schedule'and eachjobsentry.allowedFlowNodeTypesrefuses each node, at every region depth (collectFlowGraphs), whose built-in type is not listed.Reader rules, from the contract review of item 1 (record 6710350208 ③/④, restated in the claim):
start/end(FLOW_STRUCTURAL_NODE_TYPES) are always allowed.FlowNodeAction(FLOW_BUILTIN_NODE_TYPES) cannot be named byallowedFlowNodeTypes, soallowCodegoverns it. UnderallowCode: falseit is refused naming that rule. Undertrueit is allowed.scriptnode underallowCode: falseis refused byallowCodealone, whether or notallowedFlowNodeTypeslists it. Undertrueit is judged byallowedFlowNodeTypes.URL form. No route for an environment's published profile is defined in this repository: no
restrictionroute appears in the spec route ledger or underpackages/spec/src/api. Card 3 (objectstack-ai/cloud#3713) is in the cloud repository, which this session cannot read. So the URL form is not guessed. A URL is refused, and the message names the file form as the remedy. Once card 3 publishes an endpoint, the URL form is a follow-up.The gate-parity ledger (
test/validate-build-gate-parity.test.ts) gainsjudgeRestrictionProfileunderVALIDATE_ONLY_GATES(os buildnames no target, so there is no profile for it to judge against), and the other two calls under aNOT_A_GATEreason.Tests
src/utils/restriction-profile.test.ts(21): a CONTROL all-open profile; each dimension (allowCode over a hook, the functions, a plugin, a script node and a plugin node; an empty code key; a manifest code key; allowScheduledAutomation over a job and a scheduled flow; allowedFlowNodeTypes at the top level and inside a loop body); thepackages[]walk; the three reader rules (start/end under an empty list;approvalunder allowCode false and true;scriptnaming one rule, and judged by the list under allowCode true); the loader (valid, invalid naming the issue path,{}, not JSON, missing, URL); version drift (CONTROL equal, one package differing, skills not installed).test/validate-target-restriction-profile.test.ts(9, in-processValidate.run): CONTROL without--target(exit 0, no drift entry); CONTROL all-open profile; one refusal per dimension through--json; the text face; version drift as a warning (exit 0, and--strictwith the drifted target reads the same exit as--strictwith no target); an invalid profile; a URL.Ablations (one-time, scripts/ablation-replace.mjs, each restored to blob 11f11e59 == HEAD with git diff HEAD empty; the tests import src, so no dist is on the path)
type === 'script'→'ABLATED_script'): 3 failed / 27 passed (the command's allowCode row set, the reader's allowCode row set, "script names ONE rule").flow.type === 'schedule'→'ABLATED_schedule'): 3 failed / 27 passed (the command's allowScheduledAutomation row, its text face, the reader's schedule row set).FLOW_STRUCTURAL_NODE_TYPESearly return): 5 failed / 25 passed (every allowedFlowNodeTypes case now also refusesstart/end).Acceptance notes
FlowNodeAction.parallelandtry_catch(ADR-0031 containers) are registered by@objectstack/service-automation's own builtins (src/builtin/parallel-node.ts,try-catch-node.ts), but they are notFlowNodeActionids. Reader rule 2, as ruled, therefore refuses them underallowCode: false(the message says only that the type is outside the registry, not that it is a plugin), and no profile can list them. This is fail-closed, not silent. Raised as an open question for the spec lane in the report.devPluginsis refused underallowCode: falsebecause the spec's code table classifies itcode, although it is a dev-only overlay. Kept literal to the one table rather than carving out a second list. Noted in the report.allowCodereads exactly what the profile docblock and the code table name. JS bodies elsewhere (a job's or an action's sandboxedbody) are not judged byallowCode: a job is still refused byallowScheduledAutomation, and an action'stargetfunction is refused throughfunctions. Noted, not filed.allowedFlowNodeTypesdocblock note inpackages/spec(review 6710350208 ④) is not ridden here: the claim keepspackages/specout. Listed as an open question in the report.pnpm execsetsNODE_PATHto the workspace's hoisted store, so a tmp-dir fixture resolves the workspace@objectstack/skills. The command test therefore installs its own skills manifest at a known version, and the not-installed case is pinned on the reader with a tree whose resolution is controlled.Verification
The derived gate list below was taken on dcbb8da, based on
66bf5b4a.origin/mainthen moved todf22adc37and was merged once before opening (head 8c5e74a). The incoming commits touchpackages/spec(docs, migration entries) and one unrelatedpackages/clitest, so the scoped re-checks ran on 8c5e74a:pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generatedexit 0 (all 14 artifacts up to date); the two new test files plustest/validate-build-gate-parity.test.ts, Test Files 3 passed, Tests 63 passed;pnpm --filter @objectstack/cli typecheckexit 0. The branch delta againstorigin/mainis still exactly the six files of this PR. Before the merge, 651989c added only a one-line changeset wording change (an angle-bracket placeholder spelled as a path), and the families that read the changeset were rerun on it:node scripts/check-adr-0087-registration.mjs --base origin/main,node scripts/check-changeset-no-major.mjs --base origin/main,node scripts/check-empty-changeset.mjs --base origin/main,pnpm check:changeset-gate-self-tests,pnpm check:doc-authoring,pnpm check:issue-citations,pnpm check:nul-bytesandnode scripts/check-closing-keyword-parity.mjs, each exit 0.Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 62 commands)
All on dcbb8da:
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0node scripts/check-adr-0087-registration.mjs --self-test :: exit 0node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0node scripts/check-closing-keyword-parity.mjs :: exit 0node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0node scripts/check-comment-mask-adoption.mjs :: exit 0node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0node scripts/check-comment-mask-corpus.mjs :: exit 0node scripts/check-dts-emitted.mjs --self-test :: exit 0node scripts/check-empty-changeset.mjs --base origin/main :: exit 0node scripts/check-empty-changeset.mjs --self-test :: exit 0node scripts/check-issue-citations.mjs :: exit 0node scripts/check-plugin-teardown-shape.mjs :: exit 0node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0node scripts/ci/snapshot-next.mjs --self-test :: exit 0node scripts/docs-audit/check-affected-docs.mjs :: exit 0node scripts/docs-audit/check-drift-comment.mjs :: exit 0node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0node scripts/release-pending-publish.mjs --self-test :: exit 0pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0pnpm check:changeset-gate-self-tests :: exit 0pnpm check:ci-filter-parity :: exit 0pnpm check:cli-test-child-env :: exit 0pnpm check:closed-ceremony-text :: exit 0pnpm check:cross-package-test-inputs :: exit 0pnpm check:doc-authoring :: exit 0pnpm check:driver-memory-census :: exit 0pnpm check:dts-closure :: exit 0pnpm check:dual-build-cjs-loads :: exit 0pnpm check:engine-double-contract :: exit 0pnpm check:gitlink-declared :: exit 0pnpm check:i18n :: exit 0pnpm check:i18n-coverage :: exit 0pnpm check:i18n-walk-parity :: exit 0pnpm check:issue-citations :: exit 0pnpm check:keyed-text-bounds :: exit 0pnpm check:lean-entry-closure :: exit 0pnpm check:logger-receiver-detach :: exit 0pnpm check:nul-bytes :: exit 0pnpm check:objectql-double-limit :: exit 0pnpm check:org-identifier :: exit 0pnpm check:page-declaration-shape :: exit 0pnpm check:platform-object-tenancy-census :: exit 0pnpm check:published-files :: exit 0pnpm check:query-options-erasure :: exit 0pnpm check:refd-timer-probe :: exit 0pnpm check:registry-log-declared :: exit 0pnpm check:rest-log-spy-declared :: exit 0pnpm check:slot-lookup :: exit 0pnpm check:sourcemap-no-sources-content :: exit 0pnpm check:system-context-census :: exit 0pnpm check:test-source-alias :: exit 0pnpm check:tier-file-adoption :: exit 0pnpm check:type-check-coverage :: exit 0pnpm check:type-check-debt :: exit 0pnpm check:undeclared-dep-imports :: exit 0pnpm check:vouch-for-reference-callers :: exit 0pnpm check:watch-hint-literal :: exit 0pnpm check:where-matcher :: exit 0On the first pass (head 3f6ecdb), six were not green and were fixed or rerun:
node scripts/check-plugin-teardown-shape.mjs --self-testexit 3: the shallow clone did not hold the positive-control commit 621a487. It was fetched, then exit 0.pnpm check:dual-build-cjs-loads,pnpm check:i18n,pnpm check:i18n-coverage,pnpm check:i18n-walk-parityexit 3: their prerequisites were not built.turbo run build --filter='./packages/**' --filter='./examples/**'ran (82/82 tasks), then each exited 0.pnpm check:test-source-aliasexit 1: the new command test reached@objectstack/objectql/coreand@objectstack/plugin-securitythrough the source's dynamic imports. Module-top imports were added (dcbb8da), then exit 0.Reconciliation:
node scripts/pm/dispatch-gates.mjs --ranwith the exit-coded record gives 62 derived, 62 run, 0 NOT-MEASURED (a derived zero: all 62 recorded an exit code).Package, on dcbb8da:
pnpm --filter @objectstack/cli typecheckexit 0 (tsc + check:test-typecheck);pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2VERDICT command-exit 0: Test Files 400 passed (400), Tests 5653 passed (5653). The first full run (3f6ecdb) foundvalidate-build-gate-parity.test.ts"every call site … is classified" red on the three new names. They were classified in dcbb8da. Its twopublished-subpath-*suite errors were "packages/cli is not built" and cleared after the build;node --stack-size=4000 node_modules/eslint/bin/eslint.js packages/cli --no-inline-configexit 0;node scripts/check-nul-bytes.mjsexit 0.The integration tier (
--project integration) is declared to CI: the diff touches no spawn entry and no integration-tier file.Human Minimum
packages/specholds no runtime logic. (packages/specnot touched.)pnpm lintpasses. (eslint over packages/cli,--no-inline-config, exit 0.)main, one pull request.@objectstack/clipatch;Metadata-protocol: nonegrades patch.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code
🤖 Generated with Claude Code