Repository navigation
fix(workflow): Stop Settings Add link from submitting a pair the graph already has - #2174
Merged
Merged
Conversation
…wLab#2173) Settings → Workflow graphs → Add link submitted the pair blindly, and the host's normalizeGraph refuses the whole save on a pair it already lists ("Link A → B is listed twice"), so every other edit in that submission was lost. The drawer already avoided this through withEdge; the form did not. The form now reads the pair before it saves: repeating it is a no-op like the drawer, another kind over the same pair names the kind already there instead of submitting, and the To list marks the targets the chosen node already reaches. The host still fails closed — this only stops the form from producing a pair the host refuses.
HugoXK
marked this pull request as ready for review
November 2, 2026 14:05
Contributor
Author
Collaborator
|
Verdict: PASS at 7a586a4 Ran at this tip: Review points:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2173
Written-by: Dev-4
Owner: Dev-4
Reviewer: Reviewer
Claim-Id: 5c3608254a1248f88de2047c2212a66f
Branch: dev/4-settings-link-dedupe
Base: b282329
Tier: T2 — the live
.github/scripts/risk-gate.mjsjudge over this diff printsrisk-tier: T2; basis: plugins/workflow/client.js=T2, plugins/workflow/test/client.test.js=T2, changelog.d/2173-settings-link-duplicate.fixed.md=T1, docs/subsystems/workflow.md=T0.What changed
Settings → Workflows → Add link built the edge and submitted it without reading the edges the graph already lists. The host keys a link by its pair alone (
plugins/workflow/src/graph.js:150edgeKeytakesfrom/to, not the kind), so a second edge over the same two Bots makesnormalizeGraphthrowLink A → B is listed twice(plugins/workflow/src/graph.js:257) and refuses the whole graph:workflow.edgeskeeps what it had, and the user is left with onewf-errline and no new link. The same refusal met a different kind over a pair that already had one.plugins/workflow/client.jsnow reads the pair before it submits, with the rule the drawer'swithEdge(:656) already applies to its own wires:This pair already has a {kind} link — replace or delete it first.), so the user reads what blocks the save instead of the host'slisted twice;Name (linked),名称(已连接)— so the pair is visible before the form is filled in.Three helpers sit beside
withEdge:EDGE_KIND_LABEL,blankEdgeForm()(the one empty form the initial state and both clear paths use), andedgeKindOf(edge), which maps a stored edge to the form's kind the way the save writes it (loop === true→ loop,when→ condition, otherwise forward).Scope is this one form. The host
plugins/workflow/src/graph.jsis unchanged:normalizeGraphstill refuses a graph that lists one pair twice, so a caller that writes a duplicate through the API is refused exactly as before. This change only stops the Settings form from producing one. P-411 (when/untiltyped output names) is a separate issue and is untouched.Red first
On live main
b282329d6e79c85c9ebb3f037eeadf36bb9c1396, source untouched, only this branch'splugins/workflow/test/client.test.jsdropped into a cleangit archivetree (plugins/workflow/client.jsthere hashesf9c68c59f9de0b2343ae9bb77dd5a2c13858a5da46af79a6a96dcfc420b47085, the main blob):The fourth case,
#2173: a pair the graph does not have still saves and shows, passes on that base as well — it is the control that the guard does not eat a new pair. With the guard in place the same file on the tip is# tests 112 / # pass 112 / # fail 0.The test host refuses a repeated pair the way
normalizeGraphdoes, so the assertions are on the committedworkflow/graphpayload (nothing submitted / one edge) and on the banner text, not on a mock call count.Verification at the tip
Tip:
7a586a43bb1548acdd2506fd47140183a23e5632(tree7d0dcc2d4f1f399b318520018b1f96d0f411352c, single parentb282329d6e79c85c9ebb3f037eeadf36bb9c1396— live main at push time), 4 files, +135/−3:changelog.d/2173-settings-link-duplicate.fixed.md1/0,docs/subsystems/workflow.md2/0,plugins/workflow/client.js29/3,plugins/workflow/test/client.test.js103/0.git status --porcelainis empty.Ran
TZ=UTC ARCH_DOCS_BASE=b282329d6e79c85c9ebb3f037eeadf36bb9c1396 npm run verify→ exit 0 — core 2648, social 555, tree 127, timeline 140, workflow 354,.github/scripts598, interop 37, live-e2e 24, every suite# fail 0; lint 74/36/9/2/16 warnings and interop 1, live-e2e 0,0 errors;arch-docs: OK (4 changed file(s));ds-bot-patches check—ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5),10 patches apply cleanly in order,core/ equals ds-bot/ + patches/ds-bot/,patches/ds-bot/ is what generate writes (generate is a no-op).patches/ds-bot/has no hit onplugins/workflow/client.js, so nothing is mirrored there andgenerateis not involved.The branch was rebased onto
b282329dat push time (it was built onff160976, which isb282329d's parent): same four files, same deltas, same blobs.Not run (and why): the CI
packagejob (pack check, typecheck, actionlint) — it is not part ofnpm run verify; and the smoke bench, which this change does not reach.Acceptance
workflow.edgesis unchanged.Link A → B is listed twice.The host still refuses a duplicated pair written through the API;
plugins/workflow/src/graph.jsis untouched.Checkpoint
{ "pr": 2174, "claim": "Dev-4", "issue": 2173, "summary": "Settings Add link submitted a pair the graph already listed; the host keys a link by its pair, so normalizeGraph refused the whole graph and saved nothing, leaving one wf-err line. The form now reads the pair first: the same kind is a no-op, another kind names the kind already there instead of submitting, and the To list marks the targets the chosen From already reaches. The host is unchanged and still refuses a duplicate written through the API.", "files": [ "plugins/workflow/client.js", "plugins/workflow/test/client.test.js", "docs/subsystems/workflow.md", "changelog.d/2173-settings-link-duplicate.fixed.md" ], "checks": { "ran": "TZ=UTC ARCH_DOCS_BASE=b282329d6e79c85c9ebb3f037eeadf36bb9c1396 npm run verify (exit 0); red-first on clean b282329d; workflow suite on the tip", "result": "green", "at": "7a586a43bb1548acdd2506fd47140183a23e5632" }, "next": "none — ready for review" }