-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(daemon): anchor saved sibling validation #1262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
sethkarten
wants to merge
8
commits into
core03-managed-session-catalog
from
core04-saved-sibling-validation
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4e9c1f2
fix(daemon): anchor saved sibling validation
sethkarten f886010
Fix saved sibling relative parent validation
sethkarten 39e72c8
Merge commit 'b8f2c86c9d0ca092caa233d413ee7a0eeb67c5ab' into core04-s…
sethkarten 2b549ba
fix(daemon): anchor saved name reservations
sethkarten 6bcc7db
Merge updated core03 parent into core04
sethkarten 4052030
Merge commit '061955bacbbe8a3ebf2f9736aecc37653156de60' into HEAD
sethkarten e6d5c85
Merge commit '3bc6523edc48adf6ee3ea064d60320d3fbf5ec38' into HEAD
sethkarten 1dd52db
Merge core03-managed-session-catalog into core04-saved-sibling-valida…
sethkarten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| AGENT_FAMILY_REACH_ERROR, | ||
| assertAgentFamilyReach, | ||
| buildAgentFamilyRoster, | ||
| } from "../src/core/agent-messages.js"; | ||
|
|
||
| describe("agent message structural family validation", () => { | ||
| it("excludes malformed family edges while retaining catalog-resolved depth-two siblings", () => { | ||
| const root = { id: "root", depth: 0, status: "running" as const, sessionPath: "/root" }; | ||
| const otherRoot = { id: "other-root", depth: 0, status: "running" as const, sessionPath: "/other" }; | ||
| const child = { | ||
| id: "child", | ||
| depth: 1, | ||
| status: "idle" as const, | ||
| parentSessionPath: "/root", | ||
| sessionPath: "/child", | ||
| }; | ||
| const malformedRoot = { | ||
| id: "malformed-root", | ||
| depth: 0, | ||
| status: "idle" as const, | ||
| parentSessionId: "root", | ||
| parentSessionPath: "/root", | ||
| }; | ||
| const contradictoryChild = { | ||
| id: "contradictory-child", | ||
| depth: 1, | ||
| status: "idle" as const, | ||
| parentSessionId: "root", | ||
| parentSessionPath: "/other", | ||
| }; | ||
| const depthSkippingDescendant = { | ||
| id: "depth-skipping-descendant", | ||
| depth: 2, | ||
| status: "idle" as const, | ||
| parentSessionId: "root", | ||
| parentSessionPath: "/root", | ||
| }; | ||
| const malformedDeepSiblingA = { | ||
| id: "malformed-deep-sibling-a", | ||
| depth: 2, | ||
| status: "idle" as const, | ||
| parentSessionId: "root", | ||
| parentSessionPath: "/root", | ||
| }; | ||
| const malformedDeepSiblingB = { | ||
| id: "malformed-deep-sibling-b", | ||
| depth: 2, | ||
| status: "idle" as const, | ||
| parentSessionId: "root", | ||
| parentSessionPath: "/root", | ||
| }; | ||
| const catalog = [ | ||
| root, | ||
| child, | ||
| malformedRoot, | ||
| contradictoryChild, | ||
| depthSkippingDescendant, | ||
| malformedDeepSiblingA, | ||
| malformedDeepSiblingB, | ||
| ]; | ||
|
|
||
| // A root carrying a parent claim, contradictory dual claims, and a skipped | ||
| // depth must not become a direct family edge. | ||
| for (const malformed of [malformedRoot, contradictoryChild, depthSkippingDescendant]) { | ||
| expect(() => assertAgentFamilyReach(root, malformed, catalog)).toThrow(AGENT_FAMILY_REACH_ERROR); | ||
| expect(() => assertAgentFamilyReach(malformed, root, catalog)).toThrow(AGENT_FAMILY_REACH_ERROR); | ||
| } | ||
| expect(() => assertAgentFamilyReach(otherRoot, contradictoryChild, catalog)).toThrow(AGENT_FAMILY_REACH_ERROR); | ||
|
|
||
| // Two malformed depth-two rows that claim the root are not pseudo-siblings, | ||
| // and neither leaks into a roster. | ||
| expect(() => assertAgentFamilyReach(malformedDeepSiblingA, malformedDeepSiblingB, catalog)).toThrow( | ||
| AGENT_FAMILY_REACH_ERROR, | ||
| ); | ||
| expect(buildAgentFamilyRoster(malformedDeepSiblingA, catalog).entries).toEqual([]); | ||
| expect(buildAgentFamilyRoster(root, catalog).entries.map((entry) => entry.id)).toEqual(["child"]); | ||
|
|
||
| // A real depth-one parent in the supplied catalog restores legitimate | ||
| // depth-two siblings without weakening the malformed-edge exclusions above. | ||
| const deepParent = { id: "deep-parent", depth: 1, status: "running" as const, sessionPath: "/deep-parent" }; | ||
| const deepSiblingA = { | ||
| id: "deep-sibling-a", | ||
| depth: 2, | ||
| status: "idle" as const, | ||
| parentSessionId: "deep-parent", | ||
| parentSessionPath: "/deep-parent", | ||
| }; | ||
| const deepSiblingB = { | ||
| id: "deep-sibling-b", | ||
| depth: 2, | ||
| status: "idle" as const, | ||
| parentSessionPath: "/deep-parent", | ||
| }; | ||
| const deepCatalog = [deepParent, deepSiblingA, deepSiblingB]; | ||
| expect(() => assertAgentFamilyReach(deepSiblingA, deepSiblingB)).toThrow(AGENT_FAMILY_REACH_ERROR); | ||
| expect(assertAgentFamilyReach(deepSiblingA, deepSiblingB, deepCatalog)).toBe("sibling"); | ||
| expect(assertAgentFamilyReach(deepSiblingB, deepSiblingA, deepCatalog)).toBe("sibling"); | ||
| }); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.