Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions docs/modules/simulator/src.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Code-first simulator API.

## Public surface

### [`AgentConnection`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/network/router.ts#L80)
### [`AgentConnection`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/network/router.ts#L84)

_Interface_

Expand Down Expand Up @@ -358,7 +358,7 @@ export class ConversationSocket {

A conversation address bound to exactly one controlled endpoint.

### [`coreEvents`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L287)
### [`coreEvents`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L284)

_Variable_

Expand Down Expand Up @@ -863,7 +863,7 @@ export interface LinkDelivery {

One committed message about to cross a directed link.

### [`LinkDown`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L151)
### [`LinkDown`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L148)

_Class_

Expand All @@ -879,7 +879,7 @@ export class LinkDown extends Schema.TaggedClass<LinkDown>()(

A directed participant link transitioned from available to unavailable.

### [`LinkMessageDelayed`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L198)
### [`LinkMessageDelayed`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L195)

_Class_

Expand All @@ -898,7 +898,7 @@ export class LinkMessageDelayed extends Schema.TaggedClass<LinkMessageDelayed>()

Active link policies deferred one delivery by a known total duration.

### [`LinkMessageDropped`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L186)
### [`LinkMessageDropped`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L183)

_Class_

Expand All @@ -917,7 +917,7 @@ export class LinkMessageDropped extends Schema.TaggedClass<LinkMessageDropped>()

An active link policy discarded one committed message before delivery.

### [`LinkMessageHeld`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L210)
### [`LinkMessageHeld`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L207)

_Class_

Expand Down Expand Up @@ -957,7 +957,7 @@ Decides one delivery on a directed link. A policy reads only its input and
the ambient Clock; the link interpreter, never the policy, spends time and
records evidence.

### [`LinkPolicyCleared`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L176)
### [`LinkPolicyCleared`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L173)

_Class_

Expand All @@ -974,7 +974,7 @@ export class LinkPolicyCleared extends Schema.TaggedClass<LinkPolicyCleared>()(

A described policy stopped shaping one directed participant link.

### [`LinkPolicySet`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L166)
### [`LinkPolicySet`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L163)

_Class_

Expand All @@ -991,7 +991,7 @@ export class LinkPolicySet extends Schema.TaggedClass<LinkPolicySet>()(

A described policy became active on one directed participant link.

### [`LinkUp`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L160)
### [`LinkUp`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L157)

_Class_

Expand Down Expand Up @@ -1114,7 +1114,7 @@ export class ParticipantHandle<Name extends string = string> {
A router-issued network identity. The hidden symbol prevents structurally
similar protocol data from being used as an identity handle.

### [`ProgramFailed`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L227)
### [`ProgramFailed`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L224)

_Class_

Expand Down Expand Up @@ -1142,7 +1142,7 @@ export class ProgramFinished<A, E> extends Data.TaggedClass("ProgramFinished")<{

Customer-program completion plus its complete durable evidence.

### [`ProgramInterrupted`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L235)
### [`ProgramInterrupted`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L232)

_Class_

Expand All @@ -1157,7 +1157,7 @@ export class ProgramInterrupted extends Schema.TaggedClass<ProgramInterrupted>()

The customer program was interrupted.

### [`ProgramSucceeded`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L221)
### [`ProgramSucceeded`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L218)

_Class_

Expand Down Expand Up @@ -1187,7 +1187,7 @@ export interface ReadableRunLedger<Catalog extends AnyEventCatalog> {

Definition-bound read access to every committed core and customer event.

### [`ReceivedMessage`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/network/router.ts#L35)
### [`ReceivedMessage`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/network/router.ts#L39)

_Interface_

Expand All @@ -1199,7 +1199,7 @@ export interface ReceivedMessage {

A message delivered to one attached endpoint.

### [`RouterMessageCommitted`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L143)
### [`RouterMessageCommitted`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L140)

_Class_

Expand All @@ -1212,8 +1212,7 @@ export class RouterMessageCommitted extends Schema.TaggedClass<RouterMessageComm
) {}
```

The router durably committed one message. Payload content remains an
endpoint concern so this evidence also works with content-blind routers.
The router durably committed one message, plaintext parts included.

### [`RouterStarted`](https://github.com/chughtapan/moltzap/blob/main/packages/simulator/src/events/core.ts#L20)

Expand Down
41 changes: 20 additions & 21 deletions packages/evals/src/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ const ROUTER_COMMIT = RouterMessageCommitted.make({
messageId: MESSAGE_ID,
senderId: ALICE_ID,
routerSequence: routerSequence(0),
parts: [{ type: "text", text: SOCIAL_TEXT }],
createdAtMillis: 0,
});

const OPENCLAW_SELECTION = EvaluationEvidenceSelected.make({
Expand Down Expand Up @@ -215,28 +217,25 @@ it.effect("projects native gateway evidence in ledger order", () =>
}),
);

it.effect(
"pairs endpoint content testimony with content-blind router commits",
() =>
Effect.gen(function* () {
const evidence = yield* projectEvaluationEvidence(evaluationLedger());
it.effect("pairs endpoint content testimony with router commits", () =>
Effect.gen(function* () {
const evidence = yield* projectEvaluationEvidence(evaluationLedger());

assert.deepStrictEqual(
evidence.social.map((entry) => entry.eventId),
[CODE_SENT_ID, CODE_RECEIVED_ID],
);
assert.deepStrictEqual(
evidence.social.map((entry) => entry.routerCommitEventId),
[ROUTER_COMMIT_ID, ROUTER_COMMIT_ID],
);
for (const entry of evidence.social) {
assert.strictEqual(entry.routerCommit, ROUTER_COMMIT);
assert.deepStrictEqual(entry.observation.parts, [
{ type: "text", text: SOCIAL_TEXT },
]);
assert.isFalse(Reflect.has(entry.routerCommit, "parts"));
}
}),
assert.deepStrictEqual(
evidence.social.map((entry) => entry.eventId),
[CODE_SENT_ID, CODE_RECEIVED_ID],
);
assert.deepStrictEqual(
evidence.social.map((entry) => entry.routerCommitEventId),
[ROUTER_COMMIT_ID, ROUTER_COMMIT_ID],
);
for (const entry of evidence.social) {
assert.strictEqual(entry.routerCommit, ROUTER_COMMIT);
assert.deepStrictEqual(entry.observation.parts, [
{ type: "text", text: SOCIAL_TEXT },
]);
}
}),
);

it.effect("returns selected evidence identities in selection order", () =>
Expand Down
6 changes: 6 additions & 0 deletions packages/evals/src/grading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ const promptCommit = RouterMessageCommitted.make({
messageId: promptMessage,
senderId: peerId,
routerSequence: routerSequence(0),
parts: peerPrompt.parts,
createdAtMillis: 0,
});

const responseCommit = RouterMessageCommitted.make({
conversationId: conversation,
messageId: responseMessage,
senderId: targetId,
routerSequence: routerSequence(1),
parts: targetResponse.parts,
createdAtMillis: 0,
});

function record(
Expand Down Expand Up @@ -372,6 +376,8 @@ describe("ledger evidence projection", () => {
messageId: responseMessage,
senderId: otherId,
routerSequence: routerSequence(1),
parts: targetResponse.parts,
createdAtMillis: 0,
});
const error = yield* transcriptFromLedger(
openClawLedger(wrongResponse, wrongCommit),
Expand Down
31 changes: 15 additions & 16 deletions packages/simulator/src/MODULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Code-first simulator API.

## Public surface

### [`AgentConnection`](./network/router.ts#L80)
### [`AgentConnection`](./network/router.ts#L84)

_Interface_

Expand Down Expand Up @@ -353,7 +353,7 @@ export class ConversationSocket {

A conversation address bound to exactly one controlled endpoint.

### [`coreEvents`](./events/core.ts#L287)
### [`coreEvents`](./events/core.ts#L284)

_Variable_

Expand Down Expand Up @@ -858,7 +858,7 @@ export interface LinkDelivery {

One committed message about to cross a directed link.

### [`LinkDown`](./events/core.ts#L151)
### [`LinkDown`](./events/core.ts#L148)

_Class_

Expand All @@ -874,7 +874,7 @@ export class LinkDown extends Schema.TaggedClass<LinkDown>()(

A directed participant link transitioned from available to unavailable.

### [`LinkMessageDelayed`](./events/core.ts#L198)
### [`LinkMessageDelayed`](./events/core.ts#L195)

_Class_

Expand All @@ -893,7 +893,7 @@ export class LinkMessageDelayed extends Schema.TaggedClass<LinkMessageDelayed>()

Active link policies deferred one delivery by a known total duration.

### [`LinkMessageDropped`](./events/core.ts#L186)
### [`LinkMessageDropped`](./events/core.ts#L183)

_Class_

Expand All @@ -912,7 +912,7 @@ export class LinkMessageDropped extends Schema.TaggedClass<LinkMessageDropped>()

An active link policy discarded one committed message before delivery.

### [`LinkMessageHeld`](./events/core.ts#L210)
### [`LinkMessageHeld`](./events/core.ts#L207)

_Class_

Expand Down Expand Up @@ -952,7 +952,7 @@ Decides one delivery on a directed link. A policy reads only its input and
the ambient Clock; the link interpreter, never the policy, spends time and
records evidence.

### [`LinkPolicyCleared`](./events/core.ts#L176)
### [`LinkPolicyCleared`](./events/core.ts#L173)

_Class_

Expand All @@ -969,7 +969,7 @@ export class LinkPolicyCleared extends Schema.TaggedClass<LinkPolicyCleared>()(

A described policy stopped shaping one directed participant link.

### [`LinkPolicySet`](./events/core.ts#L166)
### [`LinkPolicySet`](./events/core.ts#L163)

_Class_

Expand All @@ -986,7 +986,7 @@ export class LinkPolicySet extends Schema.TaggedClass<LinkPolicySet>()(

A described policy became active on one directed participant link.

### [`LinkUp`](./events/core.ts#L160)
### [`LinkUp`](./events/core.ts#L157)

_Class_

Expand Down Expand Up @@ -1109,7 +1109,7 @@ export class ParticipantHandle<Name extends string = string> {
A router-issued network identity. The hidden symbol prevents structurally
similar protocol data from being used as an identity handle.

### [`ProgramFailed`](./events/core.ts#L227)
### [`ProgramFailed`](./events/core.ts#L224)

_Class_

Expand Down Expand Up @@ -1137,7 +1137,7 @@ export class ProgramFinished<A, E> extends Data.TaggedClass("ProgramFinished")<{

Customer-program completion plus its complete durable evidence.

### [`ProgramInterrupted`](./events/core.ts#L235)
### [`ProgramInterrupted`](./events/core.ts#L232)

_Class_

Expand All @@ -1152,7 +1152,7 @@ export class ProgramInterrupted extends Schema.TaggedClass<ProgramInterrupted>()

The customer program was interrupted.

### [`ProgramSucceeded`](./events/core.ts#L221)
### [`ProgramSucceeded`](./events/core.ts#L218)

_Class_

Expand Down Expand Up @@ -1182,7 +1182,7 @@ export interface ReadableRunLedger<Catalog extends AnyEventCatalog> {

Definition-bound read access to every committed core and customer event.

### [`ReceivedMessage`](./network/router.ts#L35)
### [`ReceivedMessage`](./network/router.ts#L39)

_Interface_

Expand All @@ -1194,7 +1194,7 @@ export interface ReceivedMessage {

A message delivered to one attached endpoint.

### [`RouterMessageCommitted`](./events/core.ts#L143)
### [`RouterMessageCommitted`](./events/core.ts#L140)

_Class_

Expand All @@ -1207,8 +1207,7 @@ export class RouterMessageCommitted extends Schema.TaggedClass<RouterMessageComm
) {}
```

The router durably committed one message. Payload content remains an
endpoint concern so this evidence also works with content-blind routers.
The router durably committed one message, plaintext parts included.

### [`RouterStarted`](./events/core.ts#L20)

Expand Down
10 changes: 6 additions & 4 deletions packages/simulator/src/events/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,29 +210,31 @@ test("represents process exit and signal as distinct classes", () =>
);
}));

test("keeps router commitment evidence content-blind", () =>
test("carries the committed message body on the commitment", () =>
Effect.gen(function* () {
const committed = yield* coreEvents.decode({
_tag: "moltzap.router-message-committed/v1",
conversationId: CONVERSATION_ID,
messageId: MESSAGE_ID,
senderId: AGENT_ID,
routerSequence: 0,
parts: [{ type: "text", text: "router plaintext" }],
createdAtMillis: 1_754_000_000_000,
});
const contentBearing = yield* coreEvents
const bodiless = yield* coreEvents
.decode({
_tag: "moltzap.router-message-committed/v1",
conversationId: CONVERSATION_ID,
messageId: MESSAGE_ID,
senderId: AGENT_ID,
routerSequence: 0,
parts: [{ type: "text", text: "router plaintext" }],
})
.pipe(Effect.either);

assert.instanceOf(committed, RouterMessageCommitted);
assert.lengthOf(committed.parts, 1);
assert.isTrue(
Either.match(contentBearing, {
Either.match(bodiless, {
onLeft: () => true,
onRight: () => false,
}),
Expand Down
Loading
Loading