Skip to content

test: add generated workflow reliability contract#77

Open
khaliqgant wants to merge 1 commit into
mainfrom
codex/ricky-workflow-never-fail
Open

test: add generated workflow reliability contract#77
khaliqgant wants to merge 1 commit into
mainfrom
codex/ricky-workflow-never-fail

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

  • add a named generated workflow reliability contract suite
  • assert generated pipeline, DAG, and supervisor workflows are repair-aware by default
  • assert master/child generation keeps nested auto-fix enabled, child final validation soft, and master final validation hard
  • encode incident fixtures for run-update-config-2, legacy child final validation, and malformed Workforce persona repair responses so they repair/resume instead of stopping at attempt one

Related

Verification

  • npm run typecheck
  • npx vitest run test/generated-workflow-reliability-contract.test.ts src/product/generation/pipeline.test.ts src/local/auto-fix-loop.test.ts
  • npm test
  • git diff --check

Note: validation in this worktree used a temporary root node_modules symlink to the main Ricky checkout for dependency resolution; it was removed before commit.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a comprehensive test suite for generated workflow reliability contracts (test/generated-workflow-reliability-contract.test.ts), validating repair-aware generation, master/child workflow rendering, and auto-fix retry/repair behavior under failure conditions. Supporting trajectory metadata files document the completed work.

Changes

Generated Workflow Reliability Contract Tests

Layer / File(s) Summary
Trajectory & Metadata
.trajectories/completed/2026-05/traj_nc2i7uwepync.json, .trajectories/completed/2026-05/traj_nc2i7uwepync.md, .trajectories/index.json
Trajectory logs record completion of the reliability contract test suite, including task metadata, timestamps, and summary of coverage areas (repair-aware generation, auto-fix retry behavior, validation rejection, legacy repair softening). Index is updated with the new trajectory entry.
Test Fixtures & Helpers
test/generated-workflow-reliability-contract.test.ts
SpecFixtureOverrides interface and spec() factory assemble NormalizedWorkflowSpec inputs for the generator. Helper builders (localArtifactRequest(), successResponse(), blockerResponse(), execution(), fakeClassification(), guidedDebugger(), workflowContent(), legacyMasterWorkflowContent(), legacyChildWorkflowContent(), sdkRuntimeBlockerEvidence()) construct mocked requests, responses, workflow content, and debugger evidence.
Generation Contract Tests
test/generated-workflow-reliability-contract.test.ts
Parameterized tests verify generated artifacts across fixture variants (pipeline, DAG, supervisor override) contain repair-aware retry wiring, repair loop elements, and expected failOnError gate configurations.
Rendering & Validation Tests
test/generated-workflow-reliability-contract.test.ts
Master/child workflow rendering assertions verify retry configuration, step ordering semantics, and completion markers. Negative test confirms validateGeneratedArtifact rejects weak artifacts with REPAIR_AWARE_RETRY_MISSING issue code.
Auto-fix Incident Tests
test/generated-workflow-reliability-contract.test.ts
runWithAutoFix tests with mocked local execution verify repair and retry from failed child steps, deterministic legacy validation repair (non-terminal conversion), and retry behavior when Workforce persona repair returns malformed output (error surfaced, no artifact rewrite).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • AgentWorkforce/ricky#58: Both PRs exercise deterministic auto-fix behavior and runWithAutoFix logic for generated artifacts with repair and retry semantics.
  • AgentWorkforce/ricky#54: New tests directly exercise the auto-fix, Workforce persona repair, and retry/resume plumbing that PR #54 introduces (previousAttempts, tier escalation, malformed persona handling).
  • AgentWorkforce/ricky#49: Tests target the same auto-fix, generated-workflow rendering, and Workforce persona repair changes introduced in PR #49.

Poem

🐰 A rabbit's ode to testing repose,
With fixtures, helpers, and flows that compose,
Auto-fix retries from failure rebound,
Repair-aware contracts keep workflows sound,
Each test a small victory, carefully penned! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely and clearly summarizes the main change: adding a generated workflow reliability contract test suite, which matches the primary objective of the changeset.
Description check ✅ Passed The description is directly related to the changeset, detailing the specific test coverage added (repair-aware workflows, master/child generation rules, incident fixtures) and includes verification steps and related references.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ricky-workflow-never-fail

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/generated-workflow-reliability-contract.test.ts (1)

202-223: ⚡ Quick win

Make the “without artifact rewrite” contract explicit with an artifactWriter assertion.

This test currently infers no rewrite from warning text. Add a writer spy and assert it was not called so the behavioral contract is directly enforced.

Suggested patch
+  const artifactWriter = vi.fn().mockResolvedValue(undefined);
   const result = await runWithAutoFix(localArtifactRequest(
     'workflows/generated/reliability-malformed.ts',
     workflowContent(),
   ), {
     maxAttempts: 7,
     runSingleAttempt,
+    artifactWriter,
     workflowRepairer: vi.fn().mockRejectedValue(new Error(
       'Workforce persona response must be structured JSON or include fenced TypeScript artifact and JSON metadata blocks.',
     )),
     classifyFailure: fakeClassification,
     debugWorkflowRun: guidedDebugger,
   });

   expect(result.ok).toBe(true);
   expect(runSingleAttempt).toHaveBeenCalledTimes(2);
+  expect(artifactWriter).not.toHaveBeenCalled();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/generated-workflow-reliability-contract.test.ts` around lines 202 - 223,
The test infers "no artifact rewrite" from a warning string instead of asserting
behavior; add an artifactWriter spy (e.g., artifactWriter = vi.fn()) and pass it
into the runWithAutoFix options alongside runSingleAttempt and workflowRepairer,
then assert that artifactWriter was not called (e.g.,
expect(artifactWriter).not.toHaveBeenCalled()) for the retry attempt(s) to make
the contract explicit; reference the runWithAutoFix invocation, the
runSingleAttempt mock, and the workflowRepairer mock when adding the
artifactWriter and the new assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.trajectories/completed/2026-05/traj_nc2i7uwepync.json:
- Line 47: The projectId value currently contains a user-specific absolute path;
replace it with a portable identifier (e.g., a repo-relative path or logical
slug) by editing the "projectId" field in the JSON (located where "projectId":
"/Users/khaliqgant/Projects/AgentWorkforce/ricky-workflow-never-fail" appears)
and set it to a non-machine-specific value such as "ricky-workflow-never-fail"
or "./ricky-workflow-never-fail"; commit the change and ensure any generation
scripts write repo-relative or slug values instead of absolute local paths.

In `@test/generated-workflow-reliability-contract.test.ts`:
- Around line 104-109: The test currently dereferences result.artifact!
immediately after calling generate, which can hide generation validation errors;
before const artifact = result.artifact! add an explicit assertion that
generation succeeded (e.g., assert/expect that result.success/result.ok is true)
and, on failure, include the generation diagnostics or result message so the
test fails with clear validation info; update the block around generate(...) /
result to assert success before using artifact and then proceed to use artifact
and weakArtifact as before.

---

Nitpick comments:
In `@test/generated-workflow-reliability-contract.test.ts`:
- Around line 202-223: The test infers "no artifact rewrite" from a warning
string instead of asserting behavior; add an artifactWriter spy (e.g.,
artifactWriter = vi.fn()) and pass it into the runWithAutoFix options alongside
runSingleAttempt and workflowRepairer, then assert that artifactWriter was not
called (e.g., expect(artifactWriter).not.toHaveBeenCalled()) for the retry
attempt(s) to make the contract explicit; reference the runWithAutoFix
invocation, the runSingleAttempt mock, and the workflowRepairer mock when adding
the artifactWriter and the new assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ae7931c-3763-4652-a3b0-3e070b3a402c

📥 Commits

Reviewing files that changed from the base of the PR and between 45ae3cf and 0c3baa6.

📒 Files selected for processing (4)
  • .trajectories/completed/2026-05/traj_nc2i7uwepync.json
  • .trajectories/completed/2026-05/traj_nc2i7uwepync.md
  • .trajectories/index.json
  • test/generated-workflow-reliability-contract.test.ts

},
"commits": [],
"filesChanged": [],
"projectId": "/Users/khaliqgant/Projects/AgentWorkforce/ricky-workflow-never-fail",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid committing absolute local paths in trajectory metadata.

Line 47 includes a machine-specific absolute path (/Users/...), which leaks local user information and makes artifacts non-portable across environments. Prefer a repo-relative identifier (or logical project slug) in committed files.

Suggested patch
-  "projectId": "/Users/khaliqgant/Projects/AgentWorkforce/ricky-workflow-never-fail",
+  "projectId": "AgentWorkforce/ricky-workflow-never-fail",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"projectId": "/Users/khaliqgant/Projects/AgentWorkforce/ricky-workflow-never-fail",
"projectId": "AgentWorkforce/ricky-workflow-never-fail",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.trajectories/completed/2026-05/traj_nc2i7uwepync.json at line 47, The
projectId value currently contains a user-specific absolute path; replace it
with a portable identifier (e.g., a repo-relative path or logical slug) by
editing the "projectId" field in the JSON (located where "projectId":
"/Users/khaliqgant/Projects/AgentWorkforce/ricky-workflow-never-fail" appears)
and set it to a non-machine-specific value such as "ricky-workflow-never-fail"
or "./ricky-workflow-never-fail"; commit the change and ensure any generation
scripts write repo-relative or slug values instead of absolute local paths.

Comment on lines +104 to +109
const result = generate({
spec: implementationSpec,
artifactPath: 'workflows/generated/reliability-policy.ts',
});
const artifact = result.artifact!;
const weakArtifact = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard result.artifact behind a success assertion for clearer failures.

Line 108 dereferences result.artifact! without asserting generation succeeded first, which can surface a null-deref instead of the validation errors when generation regresses.

Suggested patch
   const result = generate({
     spec: implementationSpec,
     artifactPath: 'workflows/generated/reliability-policy.ts',
   });
-  const artifact = result.artifact!;
+  expect(result.success, result.validation.errors.join('\n')).toBe(true);
+  expect(result.artifact).not.toBeNull();
+  const artifact = result.artifact!;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/generated-workflow-reliability-contract.test.ts` around lines 104 - 109,
The test currently dereferences result.artifact! immediately after calling
generate, which can hide generation validation errors; before const artifact =
result.artifact! add an explicit assertion that generation succeeded (e.g.,
assert/expect that result.success/result.ok is true) and, on failure, include
the generation diagnostics or result message so the test fails with clear
validation info; update the block around generate(...) / result to assert
success before using artifact and then proceed to use artifact and weakArtifact
as before.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to 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