Skip to content

Commit 3afe1db

Browse files
test(runtime): make the isPausedRun pin able to fail — separate the verdict from the companion field
The reverse verification caught this: replacing `isPausedRun`'s body with `!!result.screen` — the tolerant-consumer sniff PD #12 forbids — left the whole runtime suite green. Every assertion in the pin was satisfied by it, because a screen happened to accompany the paused fixture and to be absent from all the negatives, so the test could not fail against the one shape it exists to forbid. Adds the two cases that separate the readings: an `approval`/`wait` pause with NO screen is still a pause, and a screen on a result that is not parked does not make it one. Both go red under that substitution. Also states plainly, at the route-level case, that this door answers a pause and a terminal success identically on the wire by design, so no route assertion can tell which arm produced the response — the discrimination lives on the predicate. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y26DJEHSBhhAQ6wwfsHNza
1 parent c79fdf0 commit 3afe1db

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

‎packages/runtime/src/domains/automation-trigger-paused-run.test.ts‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ describe('#9510 — a triggered run that PAUSED is answered as the third state',
9898

9999
it(`${route.label}: a pause with no screen (approval, wait) is still the paused answer`, async () => {
100100
// `screen` is a screen-flow field; an `approval` or `wait` node
101-
// pauses without one. The state is read off `status`, so its
102-
// absence must change nothing — a door that keyed on `screen` would
103-
// report every approval pause as a terminal success.
101+
// pauses without one, and the body a caller resumes with must be
102+
// the same either way.
103+
//
104+
// ⚠️ Honest about its own reach: this door answers a pause and a
105+
// terminal success IDENTICALLY on the wire — deliberately, since
106+
// both are `200` plus the engine result — so no route-level
107+
// assertion can tell which arm produced the response. What it pins
108+
// is the PAYLOAD (`status`, `runId`, no refusal envelope); that the
109+
// arm reads the lifecycle verdict rather than sniffing `screen` is
110+
// pinned on `isPausedRun` itself, below.
104111
const dispatcher = makeDispatcher({ success: true, status: 'paused', runId: 'run_b21', durationMs: 3 });
105112

106113
const result = await dispatcher.handleAutomation(route.path('flaky_approval'), 'POST', {}, CTX);
@@ -119,14 +126,25 @@ describe('#9510 — the shared dispatch table names the non-terminal state', ()
119126
});
120127

121128
it('reads the producer\'s lifecycle verdict, never the incidental fields', () => {
122-
// `runId` and `screen` ride along on a pause; neither DEFINES it. A
123-
// reader that sniffed them would call a resume refusal (which also
124-
// carries a run id) a live pause.
129+
// `runId` and `screen` ride along on a pause; neither DEFINES it.
125130
expect(isPausedRun(PAUSED)).toBe(true);
126131
expect(isPausedRun({ success: true, runId: 'run_x' })).toBe(false);
127132
expect(isPausedRun({ success: false, status: 'failed', error: 'boom' })).toBe(false);
128133
expect(isPausedRun(undefined)).toBe(false);
129134
expect(isPausedRun(null)).toBe(false);
135+
136+
// ⭐ The two cases that actually SEPARATE reading the verdict from
137+
// sniffing a companion field — and the reason they are spelled out:
138+
// every assertion above is satisfied by a predicate that returns
139+
// `!!result.screen`, because a screen happens to accompany the paused
140+
// fixture and to be absent from all the negatives. A pin that cannot
141+
// fail against the tolerant-consumer shape PD #12 forbids is not
142+
// pinning anything, so these two carry the sentence:
143+
//
144+
// - an `approval` or `wait` pause has NO screen and is still a pause;
145+
expect(isPausedRun({ success: true, status: 'paused', runId: 'run_b21' })).toBe(true);
146+
// - a screen on a result that is not parked does NOT make it one.
147+
expect(isPausedRun({ success: true, status: 'completed', screen: PAUSED.screen })).toBe(false);
130148
});
131149

132150
it('never promotes a paused run into the FLOW_FAILED row, even against the grain', () => {

0 commit comments

Comments
 (0)