Repository navigation
fix(metadata-protocol): a package copy under a new namespace calls its own flows - #38642
objectstack-fleet[bot] wants to merge 4 commits into
Conversation
…enamed flows planNamespaceRename renamed a package flow under the prefix swap but kept every name that calls it: a subflow step's config.flowName, a translation's flows keys and a flow action's target still named the source's flow. The copy now rewrites a value equal to a renamed flow name, whole, at the derived index's flow sites and at a target beside a 'flow' executor. Claude-Session: https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE Co-authored-by: Claude <noreply@anthropic.com>
…'s renamed flows Engine pins (subflow flowName, flow action target with a non-flow control, the API endpoint and page action-block spellings, translation flows keys and their collision refusal) and door pins for the unmanaged import with targetNamespace and duplicatePackage, including the source-still-installed case and the parity of the two doors. Claude-Session: https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE Co-authored-by: Claude <noreply@anthropic.com>
…ng a copy's flows Claude-Session: https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 10 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 dd565445e8a5311af54c9335c2bc5f12ceddf10f && git checkout dd565445e8a5311af54c9335c2bc5f12ceddf10f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e6634cebd7ad07587f74b4bee8dfaa05235360bc fb44b0f29e0379caad9cd73d7bfc531cfbd98a11 && git checkout -B drift-repro e6634cebd7ad07587f74b4bee8dfaa05235360bc && git merge --no-ff fb44b0f29e0379caad9cd73d7bfc531cfbd98a11
node scripts/docs-audit/affected-docs.mjs --json e6634cebd7ad07587f74b4bee8dfaa05235360bc
|
…ne doubles The door pins for the flow-reference rename copy the stub engine of package-unmanaged-install.test.ts; `check-engine-double-contract --write` records its three pinned verbs (15 lines added, none changed, no seam lost). Claude-Session: https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Fixes #38595
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
planNamespaceRename(packages/metadata-protocol/src/package-namespace-rename.ts), the one rename engine behind the unmanaged install'stargetNamespaceandduplicatePackage, renamed a package flow under the prefix swap (crm_childtocrm2_child) but rewrote no name that calls it. It now builds a flow rename map from the package's ownflowitems and rewrites a value that EQUALS a renamed flow name, whole, at:flowsites,REFERENCE_SITES.byTarget.get('flow'), read the same way the object sites are (by property, wherever it occurs). Dumped at runtime on this tree it holds{fromType:'flow', property:'flowName'}and{fromType:'translation', property:'flows'}, so asubflowstep'sconfig.flowNameand a translation'sflowskeys follow;targetwhose sibling executor is'flow'. That istype: 'flow'on an action (ActionSchema, an object'sactions[], an inline action, anaction:groupmember, an API endpoint) andactionType: 'flow'on anaction:button/action:iconpage block, wheretypeis the component. The index cannot carrytarget, because on every other executor it names a URL, script, page, endpoint or form, and a property-wide site would rewrite those too and list them in the "Used by" answer.A flow the package does not hold keeps its name, a flow the prefix swap keeps keeps its name, and nothing is substring-rewritten. A value that is not a renamed flow name falls through to the rules every string already took, so nothing that read the same before reads differently now. Collisions work as they do for objects: a renamed flow name that meets a name the item already holds at that site (a translation keyed by both
crm_childandcrm2_child) refuses the item, and the refusal names the flow. The internalatReference: booleanof the walk became the site's rename map (object or flow), so both kinds share one walk and one collision rule.The publish gate of PR #38594 is not touched.
Tests
Engine pins, package-namespace-rename.test.ts (7 new cases)
flowNamefollows;other_flow, an unprefixedbare_childand a superstringcrm_child_v2keep their names; a flow action'stargetfollows whilemodal/script/apitargets equal to the same string do not; the objectactions[], API endpoint and pageactionTypespellings; translationflowskeys; the collision refusal; and a copy that keeps the source namespace renames nothing.Door pins, new package-namespace-rename-flow-refs-38595.test.ts (6 cases)
The harness (
makeEngine,crmBody) is copied frompackage-unmanaged-install.test.ts, which is not edited. Its automation service answerslistFlows, so a gate that judges a step's called flow has a non-empty universe.targetNamespace: 'crm2'installs, and the storedcrm2_parentcallscrm2_child;target: 'crm2_child', and themodalcontrol keepstarget: 'crm_child';crm2_parentcallscrm2_child;other_flowkeeps its name;duplicatePackageintocrm2gives the same result with the source installed, and the source still callscrm_child;crm2store identical flow and action items.Package run at 5ec669b
pnpm --filter @objectstack/metadata-protocol typecheck && … exec vitest run --maxWorkers=2under the verify lock:VERDICT command-exit 0,Test Files 373 passed | 9 skipped (382),Tests 23670 passed | 45 skipped (23715). The typecheck program lists the test files.Ablation
The fix commit came first. Then
scripts/ablation-replace.mjsswapped the one line that fills the flow rename map for a no-op (anchor 1 to 0, blobe90813508b99to114356add0b3). With that in place, 9 of the 13 new cases failed (Tests 9 failed | 26 passed (35)): every rewrite pin on both test files. The four that stayed green were the three controls and the parity case, which stays equal when both doors are equally wrong. The tool then restored the file: the blob matched HEAD again andgit diff HEADwas empty.Under PR #38594's gate (head 93f3643)
In a throwaway tree at that head, with this branch's two commits cherry-picked, the closure was built and both test files passed (
Tests 42 passed). With the same ablation there, the install pins fail with the gate's own 422:INVALID_METADATA,flow-subflow-unknownatflows[0].nodes[1].config.flowName, "calls flow 'crm_child' … Did you mean crm2_child". So the gate is live in this harness and the pins pass under it, without depending on its code. The tree was removed afterwards.Acceptance notes
When this branch and PR fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594 are both applied, a parent-first duplicate fails, and the remedy belongs in PR fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594. In that tree,
duplicatePackageof a base whose stored rows holdcrm_parent(callingcrm_child) beforecrm_childanswersfailed: [crm_parent: flow/crm2_parent failed author-time validation … config.flowName [flow-subflow-unknown]]and writes onlycrm2_child. PR fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594's duplicate leg states no copy-plan flow names. Its own comment says "duplicatePackagecopies stored rows, which the gate's own read of the stored flows already holds", and that stops being true once the copy's calls name the copy's flows. The install leg states them (copyPlanFlowNames) and passes in either order. This PR's duplicate pins store the called flow first, so they hold on both trees. The parent-first duplicate under the gate is reported for that PR's seat. It is not worked around here.Measured with the same engine probe, outside this card: the names of other non-object items (dashboard, page, report) are renamed by the prefix swap, but their references are not. That covers app navigation's
dashboardName/pageName/reportNameand a translation'sdashboards/pages/reportskeys. A dashboard header action withactionType: 'flow'keeps itsactionUrl. These are reported to the seat as one family. They are not fixed here.Outside the dispatched file surface, added by the PM's amendment:
scripts/engine-double-contract.pinned.jsongains 3 rows (15 lines) for the new test file's copied stub engine, produced bynode scripts/check-engine-double-contract.mjs --write. No existing row changed, andpnpm check:engine-double-contractexits 0 at fb44b0f.Verification
Read first, by risk:
package-namespace-rename.ts, thedeepRewriteobject branch: the child-site expressionreferenceSiteOf(k) ?? (site && k === 'name' ? site : flowTargetSite(v, k))replaced the old boolean. Object sites must behave exactly as before.package-namespace-rename.ts,flowTargetSiteandFLOW_EXECUTOR_KEYS: the one hand-written site.package-namespace-rename-flow-refs-38595.test.ts: the source-still-installed case and the duplicate parity.Two-minute check:
pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/package-namespace-rename-flow-refs-38595.test.ts src/package-namespace-rename.test.tsshould report 2 files and 35 tests passing.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE