@@ -376,11 +376,13 @@ function findGuardianReviewStatus(events: CapturedAgentEvent[]): "approved" | "d
|
376 | 376 | function assertGuardianReviewCompleted(params: { |
377 | 377 | events: CapturedAgentEvent[]; |
378 | 378 | label: string; |
| 379 | +requireEvents?: boolean; |
379 | 380 | }): CapturedAgentEvent | undefined { |
380 | 381 | const completedEvents = params.events.filter( |
381 | 382 | (event) => event.data?.phase === "completed" && event.data?.status, |
382 | 383 | ); |
383 | | -if (completedEvents.length === 0 && !CODEX_HARNESS_REQUIRE_GUARDIAN_EVENTS) { |
| 384 | +const requireEvents = params.requireEvents ?? CODEX_HARNESS_REQUIRE_GUARDIAN_EVENTS; |
| 385 | +if (completedEvents.length === 0 && !requireEvents) { |
384 | 386 | return undefined; |
385 | 387 | } |
386 | 388 | expect( |
@@ -441,13 +443,20 @@ async function verifyCodexGuardianProbe(params: {
|
441 | 443 | const review = assertGuardianReviewCompleted({ |
442 | 444 | events: deniedResult.events, |
443 | 445 | label: "ask-back probe", |
| 446 | +requireEvents: false, |
444 | 447 | }); |
445 | 448 | // The approve/deny call is Codex policy-owned and may change independently. |
446 | | -// OpenClaw's contract here is that Guardian mode reaches Codex app-server and |
447 | | -// projects the structured review lifecycle back onto the agent event bus. |
| 449 | +// OpenClaw's strict projection contract is covered by the allow probe above. |
| 450 | +// Riskier prompts may be refused or ask back before Codex creates a review |
| 451 | +// event, depending on current policy/model behavior. |
448 | 452 | if (review?.data?.status === "denied") { |
449 | 453 | expect(deniedResult.text).toContain(askBackToken); |
450 | 454 | expect(deniedResult.text.toLowerCase()).toMatch(/approv|permission|guardian|reject|denied/); |
| 455 | +} else if (!review) { |
| 456 | +expect(deniedResult.text).toContain(askBackToken); |
| 457 | +expect(deniedResult.text.toLowerCase()).toMatch( |
| 458 | +/approv|permission|guardian|reject|denied|block|cannot|can't/, |
| 459 | +); |
451 | 460 | } |
452 | 461 | expect(deniedResult.text.trim().length).toBeGreaterThan(0); |
453 | 462 | } |
|