Skip to content

Commit d2c880d

Browse files
committed
fix(metadata-protocol): a flow read's _diagnostics and the restore doors judge a stored flow in its D2-converted spelling
The read's schema verdict (computeMetadataDiagnostics) and the restore doors' runtime rules judge a flow through storedFlowVerdictBody, the seam the save and publish doors judge through; the row is served and restored as stored. storedFlowVerdictBody's docblock now states the chain it replays is exactly the engine's rehydration chain, and why the one excluded entry (a default flip) never decides acceptance. Claude-Session: https://claude.ai/code/session_01JQwxbaKY2r8oRQXNGhYHHg Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3bf9be7 commit d2c880d

6 files changed

Lines changed: 62 additions & 16 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): a flow read's `_diagnostics` and the restore doors judge a stored flow in its D2-converted spelling, as the save and publish doors do
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
A flow stored in a legacy ADR-0087 D2 spelling that the automation engine registers (a `get_record` node's `config.filters`, for one) is accepted by the save door and both publish doors, but every read of it (`GET /meta/flow/:name`, the list read, the `?layers=true` read, the draft read and the diagnostics sweep) answered `_diagnostics: { valid: false }` naming the legacy key, and both restore doors (`rollbackMetaItem`, `revertCommit`) refused a history version in that spelling with `422 INVALID_METADATA`. The read's schema verdict and the restore doors' runtime rules now judge the row through the doors' conversion seam, with the chain the engine replays when it registers a stored row, and serve or restore the row as stored. A flow the rules still refuse once converted still reads `valid: false`, with the errors its current spelling gets, and a version refused once converted is still refused at restore.

‎packages/metadata-protocol/src/metadata-diagnostics.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { zodIssuesToMetadataIssues } from './protocol.js';
3838
// landed by #8300). Composed into `decorateMetadataItem` below — see the
3939
// ordering note there for why it is not applied per read exit.
4040
import { redactMetadataItem } from './metadata-redaction.js';
41+
import { storedFlowVerdictBody } from './protocol-flow-save-replay.js';
4142
// [#26707] The snapshot key a write type's findings are spelled under — the
4243
// runtime gate's own answer, so the publish verdict below is re-spelled
4344
// against the same prefix the gate wrote it with.
@@ -276,7 +277,18 @@ export function computeMetadataDiagnostics(
276277
// [#26886] …and judge each picklist-bound field as its author wrote it:
277278
// the `options` the runtime resolved onto it are not part of that shape
278279
// ({@link withoutResolvedPicklistOptions}).
279-
const candidate = withoutResolvedPicklistOptions(stripReadDecorations(item));
280+
//
281+
// [#29696] …and judge a FLOW in the spelling every door judges it in: its
282+
// ADR-0087 D2-converted body ({@link storedFlowVerdictBody}, the seam the
283+
// save door's fallback verdict, both publish doors and the restore doors
284+
// judge through). A served flow is a row at rest that no read converts
285+
// (`convertStoredItem` skips `flow`; the engine converts it when it
286+
// registers it), so judged as stored a legacy D2 spelling (`get_record`
287+
// `config.filters`) read `valid: false` while every door and the engine
288+
// accepted it. For the VERDICT only: the read serves the body it was
289+
// handed. Not a redaction, so the #8154 order below is untouched: the
290+
// body judged is still the unredacted one.
291+
const candidate = withoutResolvedPicklistOptions(storedFlowVerdictBody(singular, stripReadDecorations(item)));
280292

281293
// [#25783] A document parsed before against this same schema is answered
282294
// from the memo — see "The verdict memo" above.

‎packages/metadata-protocol/src/protocol-authoring-gate.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ export async function refuseRestoredBodyTheSaveDoorRefuses(
160160
type,
161161
name,
162162
state: 'active',
163-
body,
163+
// [#29696] A flow version is judged in its D2-converted spelling, as
164+
// both publish doors judge a stored flow draft (#29557): a history
165+
// body is a row at rest. Restored as stored; the credential read below
166+
// reads the stored version.
167+
body: storedFlowVerdictBody(type, body),
164168
source,
165169
packageId: binding,
166170
...(channel

‎packages/metadata-protocol/src/protocol-flow-save-replay.ts‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
* publish verdict (`draftPublishVerdict`) judge. One judge, one spelling: a
4040
* legacy D2 spelling the save door accepted and stored raw is accepted at
4141
* publish too, and what goes live is still the stored bytes.
42+
*
43+
* [#29696] The two other judges of a flow at rest judge through it too: the
44+
* read's `_diagnostics` schema half (`computeMetadataDiagnostics`, every read
45+
* exit that decorates) and the restore doors' runtime rules
46+
* (`refuseRestoredBodyTheSaveDoorRefuses`, for `rollbackMetaItem` and
47+
* `revertCommit`). Each serves or restores the body as stored.
4248
*/
4349

4450
import { ALL_CONVERSIONS, applyConversionsToFlow, type ConversionNotice } from '@objectstack/spec';
@@ -141,19 +147,32 @@ export function flowVerdictBody(body: unknown, options: { includeRetired: boolea
141147
}
142148

143149
/**
144-
* [#29557] The body a publish judges a STORED draft in: for a `flow`, the
145-
* {@link flowVerdictBody} of the draft row with the retired entries included;
146-
* every other type, the draft as stored. The two publish doors and the draft
147-
* read's publish verdict judge through here and promote, store and serve the
148-
* draft as stored.
150+
* [#29557] The body a STORED flow is judged in: for a `flow`, the
151+
* {@link flowVerdictBody} of the row with the retired entries included; every
152+
* other type, the row as stored. The two publish doors and the draft read's
153+
* publish verdict judge a stored draft through here, [#29696] the read's
154+
* `_diagnostics` schema half judges a served row and the restore doors' runtime
155+
* rules a history version; each promotes, serves or restores the row as stored.
156+
*
157+
* A stored row is data at rest, so the chain is the one the automation engine
158+
* replays when it registers the row: its stored-flow canonicalizer
159+
* (`canonicalizeFlow` in `service-automation/src/flow-definitions.ts`), which
160+
* every caller but the save door calls with no options, so retired entries
161+
* included, and which excludes `CONVERSIONS_NOT_REPLAYED_AT_REHYDRATION`. That
162+
* list and {@link FLOW_FALLBACK_VERDICT_NOT_REPLAYED} name the same one entry,
163+
* `flow-decision-mode-inclusive-explicit`, so this verdict replays exactly the
164+
* engine's chain. The entry is a DEFAULT FLIP, not a rescue: it writes
165+
* `mode: 'inclusive'` where a decision omits `mode`, and an omitted `mode`
166+
* parses (it means exclusive), so leaving it out never turns an accepted body
167+
* into a refused one; it only keeps the verdict from judging a meaning the row
168+
* does not have. By maintainer ruling (letter C on #15429) it is not replayed
169+
* over stored flows at all. No read path converts a flow either:
170+
* `convertStoredItem` skips `flow`, and `applyConversionsToStoredItem` is not
171+
* applied to it.
149172
*
150-
* A stored draft is a row at rest, so the chain is the full one: the one the
151-
* automation engine replays when it registers the published row (its stored-
152-
* flow canonicalizer, which every caller but the save door calls with no
153-
* options) and the one `applyConversionsToStoredItem` replays on read. The
154-
* retired-entry predicate of the save door ({@link flowSaveReplaysRetired},
173+
* The retired-entry predicate of the save door ({@link flowSaveReplaysRetired},
155174
* #23903 ruling B') is not asked again: it judges authored input, and the
156-
* draft's own save asked it, in draft mode as in publish mode. `type` is the
175+
* row's own save asked it, in draft mode as in publish mode. `type` is the
157176
* singular type name.
158177
*/
159178
export function storedFlowVerdictBody(type: string, body: unknown): unknown {

‎packages/metadata-protocol/src/protocol.draft-publish-verdict.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,7 @@ describe('[#29557] a stored flow draft in a legacy D2 spelling the engine regist
10741074
expect(await (protocol as any).draftPublishVerdict({ type: 'flow', name: 'legacy_fetch', body: stored, packageId: PKG }))
10751075
.toEqual([]);
10761076
// Served, it carries none of the rules the publish refused it on before.
1077-
// (The read's own schema half still judges the served body as stored;
1078-
// that seam is the read's, not the publish verdict's.)
1077+
// ([#29696] The read's own schema half is pinned in its own block below.)
10791078
const codes = ((await draftDiagnostics(protocol, 'flow', 'legacy_fetch')).errors ?? []).map((e) => e.code);
10801079
expect(codes).not.toContain('expression-invalid');
10811080
expect(codes).not.toContain('flow-region-shape-invalid');

‎packages/metadata-protocol/src/protocol.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,9 @@ export class ObjectStackProtocolImplementation implements
15581558
* ({@link assertRuntimeAuthoringRules}), judged as an `active` write
15591559
* bound to the row's own package, and told which credentials the
15601560
* write-only channel holds — the restore keeps them (R2) — as the draft
1561-
* promotion tells it;
1561+
* promotion tells it; [#29696] a flow version judged in its
1562+
* D2-converted spelling (`storedFlowVerdictBody`), as the promotion
1563+
* judges a flow draft, and restored as stored;
15621564
* - the authoring gate a domain plugin registers
15631565
* ({@link runAuthoringGate}), on the channel the save door asks it on.
15641566
*

0 commit comments

Comments
 (0)