Repository navigation
Commit c99c8a5
<!-- claude-projects-attribution: {"github_login":"hotlong"} -->
_Requested by **Jack** · [project
thread](https://claude.ai/code/project/chan_01EF41AQooqveF2DGD8nqPzS?thread=cmsg_01EF41AQooqveF2DGD8nqPzSQjE3Rv5C52idJzRKDS6vRk)_
Fixes #39282
Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: none — `skills/` describes the two durable-pause rules as
authoring refusals, which they still are on every save and publish; only
how an already-published or stored body is read on load changes
Follow-up owed: AGENTS.md PD12 still reads as if every tightening rule
refuses on load; it should name the at-rest posture this PR adds
(governed path, not edited here)
## 维护者速读
- 已发布的包、已存进租户库的流程,碰到两条“分支暂停”规则(#38875 顺序、#38838
并发)时:**照常加载、登记、能跑**,只记一条警告(点名规则、节点、边)。HotCRM 7.0.1 的 `quote_generation`
不会再让整个应用掉线。
- **新保存照旧 422**:新建、重存、Studio 草稿、MCP 草稿、`os validate`、`defineFlow` 都还拒收。
- 运行时守卫不变:真要丢分支的一次运行仍然失败;条件互斥(HotCRM
的写法)的运行正常暂停、恢复。并发守卫的监视只在进程内存里,警告里写明了。
- 第 1 轮返工补上:元数据插件的整包读取(`createStandaloneStack`、`os serve`、verify
走这条)也改为放行只警告;`os migrate meta --stored` 预览不再把这种行报失败,命中列为待办,`--apply`
仍被保存门拒。复制包和非托管导入走保存门,仍严格。
- 破坏性只在 TypeScript:`resolveArtifactPackageEntries` /
`resolveArtifactPackageOrder` 的姿态参数改为必填。
## What changes
**One helper, a named set of two rules**
(`packages/spec/src/automation/at-rest-tolerance.ts`, exported from
`@objectstack/spec/automation`):
- `reportAtRestToleratedRule(ctx, ruleId, issue)` is how both rules
raise their issue now. The issue carries the rule id, which is the
rule's D3 migration entry id
(`flow-sequential-branch-durable-pause-refused`,
`flow-concurrent-branch-durable-pause-refused`).
- `parseAtRest(schema, value)` → `{ success, data | error, findings }`.
It parses strictly; when every failing issue is a tolerated rule, it
parses again with those rules lowered, and reports one finding per hit
with its full path. Anything else (an unknown key, a wrong type) is
refused at rest exactly as a strict parse refuses it.
- `parseWithPosture(schema, value, posture)` is the one switch a door
with a required posture reads through. `describeAtRestFinding` is the
warning text: the rule's own sentence, what the run-time guard does, and
its limit.
- `AT_REST_TOLERATED_RULES` holds exactly these two; a later rule joins
by reporting through the same helper.
**Load doors read at rest; write doors stay strict:**
- `@objectstack/core` `resolveArtifactPackageEntries(artifact, { posture
})` / `resolveArtifactPackageOrder`: posture is required. Load paths
pass `'at-rest'` (objectql and metadata plugin artifact loads, runtime
artifact handlers and app plugin, the artifact-granted permissions
reader, verify, plugin-security, plugin-dev i18n). The CLI namespace
checks pass `'strict'`. A returned entry carries `findings` only when
there is a hit. The objectql plugin logs `[artifact_at_rest_finding]`
for each.
- `@objectstack/metadata` artifact source (`artifactSource`, the door
`createStandaloneStack`, `os serve` and the verify harness boot
through): `_parseAndRegisterArtifact` used to parse the whole artifact
with a strict `ObjectStackDefinitionSchema.parse` /
`EnvironmentArtifactSchema.parse` before the package resolver ran, so
the shape still dropped the artifact there. It now reads both through
`parseAtRest`: a hit loads with one `[MetadataPlugin]
[artifact_at_rest_finding]` warning naming the rule, the node and the
full path; any other failure is refused as before. This covers a flow in
a package (`packages[1]`), in a single-package artifact's top-level
`flows`, and inside the environment-artifact envelope. Every other
strict whole-artifact parse left on the tree is an authoring path (`os
validate`, `os build`, `defineStack`), which stays strict.
- `@objectstack/metadata-protocol` `migrateStoredMetadata` (`os migrate
meta --stored`): the preview's flow canonicalization was strict, so a
stored row with the shape, which the engine now arms and runs, was
reported `failed` and its other conversions were not previewed. The
preview now asks the engine's canonicalizer at rest: the row is
`pending` with its D2 notices, and each hit is a TODO (`conversionId` =
the rule id, `path`, the warning as `message`). `--apply` writes through
the save door, which still refuses it, so that row reports `failed` with
the door's refusal and is not written. `resolveFlowCanonicalizer`'s
options and `StoredFlowCanonicalization` gain the optional `posture` /
`findings`.
- **Still strict, by design:** copying a package (`duplicatePackage`)
and an `unmanaged` import write through the save door, so a package
carrying the shape (HotCRM 7.0.1 among them) cannot be copied or
imported unmanaged until the flow is rewritten. Installing it, from the
marketplace too, and booting it are loads.
- `@objectstack/service-automation`: the private `canonicalizeFlow`
takes a required posture. `registerFlow(name, def, armedFrom?, { posture
})` and `canonicalizeStoredFlow(name, def, { posture })` default to
strict, so cloud's two-argument call and every write door are unchanged.
The four arming steps (boot pull, re-sync, cold-boot bind, mutation
sync), the held-definition check and resume's stored-flow recovery pass
`'at-rest'`. Arming with a finding logs `[flow_at_rest_finding]` and
`getFlowRegistration` answers `{ state: 'registered', atRestFindings: [{
ruleId, path, message }] }`. A door that puts back the body it holds
keeps the at-rest posture it was armed with.
- `@objectstack/spec` `FlowRegistrationSchema`'s `registered` arm gains
the optional `atRestFindings`; each finding's `ruleId` is the closed
enum of `AT_REST_TOLERATED_RULES`.
- Docs: `content/docs/automation/flows.mdx` gains "A flow already
published or stored is loaded, with a finding", and the registration
table's `registered` row names `atRestFindings`.
- The two migration entries' acceptance criteria now say a published or
stored flow still loads, with the finding, and only its next save or
publish is refused.
**Deviations from the order's recommended shape**
- `_diagnostics` is unchanged: a stored row carrying the shape already
reads `valid: false` with the rule's issue there, which is right,
because its next save is refused.
- No `package-registry.zod.ts` findings field, and no `registry.ts`
change: the objectql registry's `validate()` does not parse flows.
- The boot pull records the finding on the flow's registration status
rather than through a separate refusal record.
- `registerFlow` / `canonicalizeStoredFlow` take an optional posture
defaulting to strict rather than a required one: their callers include
cloud and many tests, and strict is the safe default. `canonicalizeFlow`
and the two artifact resolvers have it required.
- `stackPackageBodies` (a collection reader, not a gate) reads at rest;
`declaredPackageEntries` parses nothing and passes strict.
- Call-site posture edits reach beyond the order's named file surface
(metadata, runtime, cli, verify, plugin-security, plugin-dev,
`dry-run.ts`, `engine-resume-facet.ts`, `engine-registration-facet.ts`,
`protocol.zod.ts`); each is a posture argument or the
registration-status field.
## Tests
| Group | File | Tests |
|---|---|---|
| 1. HotCRM shape: strict refuses; `parseAtRest` passes with one finding
carrying the rule id; 6. structural errors still refused at rest |
`packages/spec/src/automation/at-rest-tolerance.test.ts` | 15 |
| 2. Whole artifact, package at `packages[1]`: at rest all load, finding
on `[1]` only; strict → `INVALID_ARTIFACT_PACKAGE_ENTRY` / 422;
structural errors refused at rest |
`packages/core/src/artifact-packages.test.ts` (new block) | 7 |
| 3. Engine: write-door `registerFlow` refuses; at-rest arm warns and
serves the finding; each condition direction parks and resumes; both
conditions holding fails at run time naming the dropped branch; a stored
row the protocol serves arms at boot and runs |
`packages/services/service-automation/src/at-rest-arming-39282.test.ts`
| 14 |
| 4. Save doors still 422 `INVALID_METADATA` at the anchoring edge,
nothing written: create, re-save of the stored row, Studio draft, MCP
`save_metadata_draft` request; each with no automation service, with an
engine-faithful canonicalizer (throws, `protocol-save.ts` falls back to
the raw body), and with one that parses at rest |
`packages/metadata-protocol/src/protocol.save-at-rest-pause-39282.test.ts`
| 24 |
| 2b. Metadata plugin artifact door, booted end to end from a local file
(`artifactSource: { mode: 'local-file' }`, `bootstrap:
'artifact-only'`): the flow at `packages[1]`, in top-level `flows`, and
inside the envelope each loads, registers `quote_generation` and warns
once naming the rule, `notify_owner` and the path; each with an unknown
key beside the shape is refused and registers nothing; a clean artifact
warns nothing |
`packages/metadata/src/plugin-artifact-at-rest-39282.test.ts` | 15 |
| 2c. `os migrate meta --stored` on the real stack the command boots: a
stored row with the shape and a legacy `filters` is previewed `pending`
with the D2 notice and a TODO naming the rule and `notify_owner`;
`--apply` reports it `failed` with the save door's refusal and leaves
the row unwritten |
`packages/cli/src/commands/migrate/meta.stored-flow-at-rest-39282.integration.test.ts`
| 2 |
| 5. The concurrent rule | every file above runs both rules
(`describe.each`) | — |
Rejection tests assert `code` and `status`. The engine's write-door case
has no status at that layer: it pins the thrown `ZodError`'s one issue
(`code: 'custom'`, the anchoring edge's path,
`params.atRestToleratedRule` = the rule id); the save-door file pins the
422 `INVALID_METADATA` it becomes.
**Ablation** (each run with the fix reverted on disk; spec rebuilt where
a downstream package reads its `dist`):
- A, tolerance removed (the rule always raises): spec 6 of 15 red, core
2 of 7 red, engine 12 of 14 red.
- B, tolerance leaking everywhere (the rule never raises, and
`parseAtRest` passes any failure): spec 13 of 15 red, core 6 of 7 red,
engine 8 of 14 red (including both write-door refusals), save doors 24
of 24 red.
- Round 1 additions, fix reverted on disk: the metadata door with its
strict parses back, 6 of 15 red (every load case; the refusal cases and
the clean control stay green by design); the stored-migration preview
without the at-rest wrapper, 2 of 2 red (the row reported `failed`).
- Every new test is red under A or B, except three that are green by
design: the two constant pins (the set is exactly the two rules; each id
is its entry's id), which fail to compile without the fix, and the core
shape pin "no `findings` key when there is no hit".
## Acceptance notes
- Out of scope (Q7): the sequential rule still refuses mutually
exclusive conditions at save, as it did. HotCRM's `quote_generation`
needs a rewrite before its next save; until then it loads, runs and
warns.
- The concurrent run-time watch lives in process memory: an engine
restart between the first pause and the later branch keeps the old
behaviour. The warning says so.
## Verification
- `pnpm exec turbo run typecheck` over spec, core, service-automation,
metadata-protocol, objectql, metadata, runtime, cli, verify,
plugin-security, plugin-dev, rest: 82 of 82 tasks pass (cli's test layer
holds its existing 28-error ledger unchanged).
- `vitest run`: spec `src/automation src/migrations src/api` 4305 passed
| 2 todo; core 3972 passed; service-automation 4558 passed; objectql
14697 passed; metadata 2981 passed; metadata-protocol `flow` 181 passed
plus the new file's 24; runtime (artifact, app-plugin, automation,
load-artifact, standalone, resolve-project) 2122 passed | 6 skipped; cli
(resolver readers) 549 passed; verify 517; plugin-security `app-default`
28; plugin-dev 91; rest (`public-form`, `meta-migrate`) 400.
- Round 1 (head 85c770d): typecheck over spec, service-automation,
metadata-protocol, metadata and cli, 75 of 75 tasks pass. `vitest run`:
metadata 2996 passed (all); spec `src/api src/automation` 4050 passed;
service-automation `at-rest-arming-39282` 14; metadata-protocol
save-at-rest, stored-migration and flow-canonicalizer 92; cli
`src/commands/migrate` 702 passed | 8 skipped, and the integration
`meta.stored-flow*` files 5 passed. Gates re-run green:
`check:engine-double-contract`, `check:objectql-double-limit`,
`check:test-source-alias` (the new cli test pays its boot's lazy loads
at collection), `check:spec-parsed-alias`, `check:driver-memory-census`,
`check-nul-bytes`, `check-platform-checklist`,
`check:adr-0087-registration`; overlap check clean against origin/main.
- Earlier pushes in this PR, for the record: 9f549dc adds the
`flows.mdx` paragraph; 4b02a9b makes the plugin-dev posture test mock
`@objectstack/driver-memory` absent and boot with `driver: false`, with
its `scripts/driver-memory-census.ledger.json` entry, so it adds no
driver-memory binding.
- `pnpm --filter @objectstack/spec check:generated --fix`: 5 stale
artifacts regenerated (additive exports only) and re-checked green.
- `node scripts/pm/overlap-check.mjs
--branch=claude/project-thread-oge7d7
--repo=objectstack-ai/objectstack`: clean. `node
scripts/check-nul-bytes.mjs`: OK. `node
scripts/check-platform-checklist.mjs --changed-from origin/main`: OK.
`pnpm check:adr-0087-registration`: OK (exemption
`no-migration-prescription`).
- `node scripts/pm/dispatch-gates.mjs --commands`: all 135 named
commands run locally. 125 pass. Four failed on this diff and were fixed:
`check:engine-double-contract` (ledger `--write` for the new save-door
test), `check:objectql-double-limit` (that test's `find` double now
matches its `where` and holds the bound), `check:spec-parsed-alias`
(`FlowRegistrationAtRestFindingParsed` added), `check:test-source-alias`
(plugin-dev test pays its lazy loads at collection); each re-run green.
Six exit 3, prerequisite not met in this container, nothing measured:
`check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity` (need the
built CLI closure), `check:dual-build-cjs-loads` (needs a full build),
`spec check:skill-examples` (needs client-react's declarations), and
`check-plugin-teardown-shape --self-test` (shallow clone cannot reach
its pinned fixture). CI runs these.
Write budget: `git push`, one relay `pr_create` (with assignee), one
card report comment; round 1: `git push`, one relay body edit.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Q4EjjMtNXyvi9n6LLE6Ahf
<!-- signed: repo:cloud#5 · hotlong · session_01Q4EjjMtNXyvi9n6LLE6Ahf
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 850d240 commit c99c8a5
59 files changed
Lines changed: 1789 additions & 118 deletions
File tree
- .changeset
- content/docs
- automation
- references
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- cli
- src
- commands/migrate
- utils
- test
- core/src
- metadata-protocol/src
- metadata/src
- objectql/src
- plugins
- plugin-dev/src
- plugin-security/src
- rest/src
- runtime/src
- security
- services/service-automation/src
- spec
- api-surface
- authorable-surface
- declaration-map
- docs/references/api
- export-origins
- json-schema.manifest
- src
- api
- automation
- migrations/entries/semantic
- verify/src
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1789 | 1789 | | |
1790 | 1790 | | |
1791 | 1791 | | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
1792 | 1806 | | |
1793 | 1807 | | |
1794 | 1808 | | |
| |||
2769 | 2783 | | |
2770 | 2784 | | |
2771 | 2785 | | |
2772 | | - | |
| 2786 | + | |
2773 | 2787 | | |
2774 | 2788 | | |
2775 | 2789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
0 commit comments