import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import { test } from "node:test"; const HERE = dirname(fileURLToPath(import.meta.url)); const ROOT = process.env.MOSAIC_CONTRACT_ROOT ?? join(HERE, "fixtures"); const proactive = readFileSync(join(ROOT, "skills-local", "ms-proactive-agent", "SKILL.md"), "utf8"); const executive = readFileSync(join(ROOT, "skills-local", "ms-executive-update", "SKILL.md"), "utf8"); const honesty = readFileSync(join(ROOT, "skills-local", "ms-honesty", "SKILL.md"), "utf8"); test("cross-seat waits require communication rather than agent-watch polling", () => { assert.equal( proactive.includes("A row waiting on someone else is not a candidate; it gets a watch"), false, "proactive contract must not contradict ms-agent-watch", ); assert.match(proactive, /Use existing message delivery for another agent.s response/); assert.match(proactive, /Do not poll its private\s+files or pane/); assert.match(proactive, /external\s+conditions with no existing wake owner/); }); test("proactive turns close every communication obligation before reporting", () => { assert.match(proactive, /Close communication obligations/); for (const required of [ "persist any required", "exact receipt", "return event", "escalation owner", "A report to the user is not delivery to another agent", ]) { assert.equal(proactive.includes(required), true, `missing proactive closeout requirement: ${required}`); } }); test("executive updates cannot replace direct owner communication", () => { assert.match(executive, /## Communication closeout before reporting/); assert.match(executive, /An executive update does not replace direct communication/); assert.match(executive, /A no-change line does not satisfy an unsent acknowledgement, handoff, review request,\s+blocker, or result/); }); test("honesty classifies communication state and routes access limits", () => { assert.match(honesty, /## Communication evidence/); assert.match(honesty, /Drafted is not sent\. Sent is not delivered\. Delivered is not acknowledged\. Acknowledged is not completed\./); assert.match(honesty, /A credential refusal is correct behavior, but it is not a terminal communication state/); assert.equal( honesty.includes("actually re-measured the thing you are waiting on, or a watch is armed to do so"), false, "another-seat waits must not inherit the stale remeasure-or-watch binary", ); assert.match( honesty, /Another-seat and operator waits use the\s+recorded delivery receipt, required return event, escalation owner, and existing wake\s+path\. They do not require polling or an `agent-watch`\./, ); assert.match(honesty, /External-condition waits require\s+a fresh measurement or a permitted watch\./); });