Skip to content

fix(engine): isolate conflicting inventory members - #366

Open
miyaontherelay wants to merge 1 commit into
mainfrom
fix/node-live-agent-presence-reconciliation-0902
Open

fix(engine): isolate conflicting inventory members#366
miyaontherelay wants to merge 1 commit into
mainfrom
fix/node-live-agent-presence-reconciliation-0902

Conversation

@miyaontherelay

Copy link
Copy Markdown
Contributor

Summary

  • isolate provider, live-location, and identity conflicts within an authoritative node inventory
  • renew valid sibling presence leases and mark only those agents delivery-ready
  • preserve fail-closed rejection when no valid existing inventory member remains
  • add a node-scoped RelayFlow with a must-not-fire control and exact base/head delivery evidence

Runtime proof

Base dd477eb: one conflicting chief entry rejects the complete cursor-aware inventory; two valid siblings read offline and each retains one pending delivery.

Head: the conflict is reported as one rejected member, both valid siblings read active, receive and acknowledge delivery, and have empty pending queues.

Validation

  • focused inventory conformance: 3 passed
  • RelayFlow base and head: 2 passed per arm with expected bug/fixed signatures
  • delivery conformance: 54 passed
  • node conformance: 39 passed
  • multi-provider conformance: 28 passed
  • engine typecheck and source lint passed

No deployment is included.

Session-Id: 01a06151-60e7-77a2-830e-81263e3ce20b
@coderabbitai

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 6716bbd6-8d75-44e4-b7a8-a315d38da69f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".agentworkforce/trajectories/completed/2026-09/traj_uaqpcy4qgnoa/trajectory.json">
<violation number="1" location=".agentworkforce/trajectories/completed/2026-09/traj_uaqpcy4qgnoa/trajectory.json:104">
P2: This completed trajectory cannot be audited because it records no commits or changed files and both trace refs point to an unavailable object. Record the actual product and evidence commit range, complete file list, and matching start/end refs before marking the trajectory completed.</violation>
</file>
<file name="packages/engine/src/engine/node.ts">
<violation number="1" location="packages/engine/src/engine/node.ts:1583">
P1: When a mixed inventory reports the wrong `agent_id` for an agent already active on this node, this set omits the rejected member's name and the missing-agent sweep takes the real agent offline, emitting `agent.exited`. Preserve reported names for the missing check while continuing to exclude rejected members from reconciliation and delivery readiness.</violation>
</file>
<file name="tests/relayflows/cases/0902-node-inventory-presence-isolation/run.mjs">
<violation number="1" location="tests/relayflows/cases/0902-node-inventory-presence-isolation/run.mjs:57">
P3: The setup that writes .relay-pr-proof/ and the conformance probe test into the target tree runs before the try, so the finally cleanup only runs when the vitest invocation fails. If copyFile or writeFile throws after a prior setup step created a file, the leftover probe.test.ts and .relay-pr-proof/ stay in the checkout. Move the mkdir/copyFile/writeFile inside the try so the finally always removes them.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

throw rejectedInventoryErrors[0];
}

const names = new Set(acceptedInventoryAgents.map((agent) => agent.name));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: When a mixed inventory reports the wrong agent_id for an agent already active on this node, this set omits the rejected member's name and the missing-agent sweep takes the real agent offline, emitting agent.exited. Preserve reported names for the missing check while continuing to exclude rejected members from reconciliation and delivery readiness.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/engine/src/engine/node.ts, line 1583:
<comment>When a mixed inventory reports the wrong `agent_id` for an agent already active on this node, this set omits the rejected member's name and the missing-agent sweep takes the real agent offline, emitting `agent.exited`. Preserve reported names for the missing check while continuing to exclude rejected members from reconciliation and delivery readiness.</comment>
<file context>
@@ -1540,19 +1542,49 @@ export async function reconcileInventory(
+ throw rejectedInventoryErrors[0];
+ }
+
+ const names = new Set(acceptedInventoryAgents.map((agent) => agent.name));
+ const liveInvocationIds = new Set(acceptedInventoryAgents.flatMap((agent) => (
+ agent.invocation_id ? [agent.invocation_id] : []
</file context>
Suggested change
constnames=newSet(acceptedInventoryAgents.map((agent)=>agent.name));
constnames=newSet(inventoryAgents.map((agent)=>agent.name));

"approach": "Standard approach",
"confidence": 0.94
},
"commits": [],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This completed trajectory cannot be audited because it records no commits or changed files and both trace refs point to an unavailable object. Record the actual product and evidence commit range, complete file list, and matching start/end refs before marking the trajectory completed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .agentworkforce/trajectories/completed/2026-09/traj_uaqpcy4qgnoa/trajectory.json, line 104:
<comment>This completed trajectory cannot be audited because it records no commits or changed files and both trace refs point to an unavailable object. Record the actual product and evidence commit range, complete file list, and matching start/end refs before marking the trajectory completed.</comment>
<file context>
@@ -0,0 +1,112 @@
+ "approach": "Standard approach",
+ "confidence": 0.94
+ },
+ "commits": [],
+ "filesChanged": [],
+ "projectId": "AgentWorkforce/relaycast",
</file context>

Comment on lines +57 to +64
await mkdir(proofDir, { recursive: true });
await copyFile(path.join(caseDir, 'probe.test.ts'), probePath);
await writeFile(
configPath,
`import { defineConfig } from 'vitest/config';\n\nexport default defineConfig({ test: { environment: 'node', include: ['packages/engine/src/__tests__/conformance/.relayflow-node-inventory-presence.test.ts'] } });\n`
);

try {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The setup that writes .relay-pr-proof/ and the conformance probe test into the target tree runs before the try, so the finally cleanup only runs when the vitest invocation fails. If copyFile or writeFile throws after a prior setup step created a file, the leftover probe.test.ts and .relay-pr-proof/ stay in the checkout. Move the mkdir/copyFile/writeFile inside the try so the finally always removes them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/relayflows/cases/0902-node-inventory-presence-isolation/run.mjs, line 57:
<comment>The setup that writes .relay-pr-proof/ and the conformance probe test into the target tree runs before the try, so the finally cleanup only runs when the vitest invocation fails. If copyFile or writeFile throws after a prior setup step created a file, the leftover probe.test.ts and .relay-pr-proof/ stay in the checkout. Move the mkdir/copyFile/writeFile inside the try so the finally always removes them.</comment>
<file context>
@@ -0,0 +1,90 @@
+ 'packages/engine/src/__tests__/conformance/.relayflow-node-inventory-presence.test.ts'
+);
+const configPath = path.join(proofDir, 'vitest.config.mts');
+await mkdir(proofDir, { recursive: true });
+await copyFile(path.join(caseDir, 'probe.test.ts'), probePath);
+await writeFile(
</file context>
Suggested change
awaitmkdir(proofDir,{recursive: true});
awaitcopyFile(path.join(caseDir,'probe.test.ts'),probePath);
awaitwriteFile(
configPath,
`import { defineConfig } from 'vitest/config';\n\nexport default defineConfig({ test: { environment: 'node', include: ['packages/engine/src/__tests__/conformance/.relayflow-node-inventory-presence.test.ts'] } });\n`
);
try{
try{
awaitmkdir(proofDir,{recursive: true});
awaitcopyFile(path.join(caseDir,'probe.test.ts'),probePath);
awaitwriteFile(
configPath,
`import { defineConfig } from 'vitest/config';\n\nexport default defineConfig({ test: { environment: 'node', include: ['packages/engine/src/__tests__/conformance/.relayflow-node-inventory-presence.test.ts'] } });\n`
);
run(process.execPath,[vitestEntry,'run','--config',configPath,'--reporter=verbose'],targetDir);
}finally{

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@miyaontherelay