-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workflow-engine): PrReviewLifecycle PoC — producing-side review work substrate (Aaron 'does it give you time to look at prs and put comments'); 18 tests pass #5810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AceHack
merged 2 commits into
main
from
otto-cli/b-0867-pr-review-lifecycle-poc-substrate-naming-substrate-producing-side-review-work-companion-to-b-0867-20-receiving-side-aaron-2026-05-28
May 28, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| // Invariant tests for PrReviewLifecycle — producing-side review work substrate. | ||
|
|
||
| import { describe, expect, test } from "bun:test"; | ||
| import { | ||
| PR_REVIEW_LIFECYCLE_UNIVERSE, | ||
| dispatchPrReviewTransition, | ||
| isPeerAgentTerritory, | ||
| newReviewContext, | ||
| type PrReviewLifecycle, | ||
| type ReviewFinding, | ||
| } from "./pr-review-lifecycle.js"; | ||
|
|
||
| describe("PrReviewLifecycle universe", () => { | ||
| test("7 distinct review-lifecycle states", () => { | ||
| expect(PR_REVIEW_LIFECYCLE_UNIVERSE.length).toBe(7); | ||
| const kinds = PR_REVIEW_LIFECYCLE_UNIVERSE.map((s) => s.kind); | ||
| expect(kinds).toContain("observe"); | ||
| expect(kinds).toContain("identify-finding"); | ||
| expect(kinds).toContain("verify-finding"); // grep-substrate-anchors step | ||
| expect(kinds).toContain("post"); | ||
| expect(kinds).toContain("conclude"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("dispatch transitions (happy path)", () => { | ||
| const baseContext = newReviewContext(5805, "self", "workflow-engine"); | ||
|
|
||
| test("observe with NO findings → conclude (no-engagement)", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "observe" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("conclude"); | ||
| expect(r.outcome.artifact?.kind).toBe("no-engagement-warranted"); | ||
| } | ||
| }); | ||
|
|
||
| test("observe WITH findings → identify-finding", () => { | ||
| const finding: ReviewFinding = { | ||
| prNumber: 5805, | ||
| kind: { kind: "substrate-honest-praise", reason: "rank-4 substrate-primitive lands cleanly" }, | ||
| content: "lgtm", | ||
| substrateAnchors: ["PR #5792 rank-4 substrate-primitive memory"], | ||
| }; | ||
| const ctx = { ...baseContext, findings: [finding] }; | ||
| const r = dispatchPrReviewTransition({ kind: "observe" }, ctx); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("identify-finding"); | ||
| } | ||
| }); | ||
|
|
||
| test("identify-finding → compose", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "identify-finding" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("compose"); | ||
| } | ||
| }); | ||
|
|
||
| test("compose → verify-finding (grep-substrate-anchors discipline)", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "compose" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("verify-finding"); | ||
| } | ||
| }); | ||
|
|
||
| test("verify-finding with substantiated finding → post", () => { | ||
| const finding: ReviewFinding = { | ||
| prNumber: 5805, | ||
| kind: { kind: "bug", severity: "minor" }, | ||
| content: "off-by-one suspected", | ||
| substrateAnchors: ["line 50: index < len"], // anchor present | ||
| }; | ||
| const ctx = { ...baseContext, findings: [finding] }; | ||
| const r = dispatchPrReviewTransition({ kind: "verify-finding" }, ctx); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("post"); | ||
| } | ||
| }); | ||
|
|
||
| test("verify-finding with UNSUBSTANTIATED finding → FindingUnsubstantiated feedback", () => { | ||
| const finding: ReviewFinding = { | ||
| prNumber: 5805, | ||
| kind: { kind: "bug", severity: "minor" }, | ||
| content: "vibes off", | ||
| substrateAnchors: [], // no anchor — per grep-substrate-anchors rule fails | ||
| }; | ||
| const ctx = { ...baseContext, findings: [finding] }; | ||
| const r = dispatchPrReviewTransition({ kind: "verify-finding" }, ctx); | ||
| expect(r.ok).toBe(false); | ||
| if (!r.ok) { | ||
| expect(r.feedback.kind).toBe("FindingUnsubstantiated"); | ||
| } | ||
| }); | ||
|
|
||
| test("post → follow-up with review-comment-posted artifact", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "post" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("follow-up"); | ||
| expect(r.outcome.artifact?.kind).toBe("review-comment-posted"); | ||
| } | ||
| }); | ||
|
|
||
| test("follow-up → conclude", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "follow-up" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("conclude"); | ||
| } | ||
| }); | ||
|
|
||
| test("conclude is terminal (stays at conclude)", () => { | ||
| const r = dispatchPrReviewTransition({ kind: "conclude" }, baseContext); | ||
| expect(r.ok).toBe(true); | ||
| if (r.ok) { | ||
| expect(r.outcome.nextState.kind).toBe("conclude"); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("ReviewFindingKind taxonomy", () => { | ||
| test("supports bug + design-question + substrate-engineering + naming + test-gap + praise + docs-gap + composes-with", () => { | ||
| const findings: ReviewFinding[] = [ | ||
| { prNumber: 1, content: "x", kind: { kind: "bug", severity: "critical" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "design-question", subject: "lifecycle DU shape?" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "substrate-engineering-suggestion", alternative: "prefer Result<T,F>" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "naming-improvement", current: "foo", proposed: "bar" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "test-gap", uncovered: "edge case X" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "substrate-honest-praise", reason: "composes cleanly" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "documentation-gap", missing: "F# interop note" } }, | ||
| { prNumber: 1, content: "x", kind: { kind: "composes-with-substrate", relatedRef: "PR #5805" } }, | ||
| ]; | ||
| expect(findings.length).toBe(8); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isPeerAgentTerritory discriminator", () => { | ||
| test("self → false (my own work)", () => { | ||
| expect(isPeerAgentTerritory("self")).toBe(false); | ||
| }); | ||
| test("peer-otto → true", () => { | ||
| expect(isPeerAgentTerritory("peer-otto")).toBe(true); | ||
| }); | ||
| test("peer-codex / peer-lior / peer-alexa → true", () => { | ||
| expect(isPeerAgentTerritory("peer-codex")).toBe(true); | ||
| expect(isPeerAgentTerritory("peer-lior")).toBe(true); | ||
| expect(isPeerAgentTerritory("peer-alexa")).toBe(true); | ||
| }); | ||
| test("human-aaron → true (substantive engagement; don't touch substrate)", () => { | ||
| expect(isPeerAgentTerritory("human-operator")).toBe(true); | ||
| }); | ||
| test("unknown → false (default; treat as substrate-honest mine)", () => { | ||
| expect(isPeerAgentTerritory("unknown")).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("newReviewContext constructor", () => { | ||
| test("initializes with empty findings + zero observations", () => { | ||
| const ctx = newReviewContext(5805, "self", "workflow-engine"); | ||
| expect(ctx.prNumber).toBe(5805); | ||
| expect(ctx.authorLane).toBe("self"); | ||
| expect(ctx.substrateScope).toBe("workflow-engine"); | ||
| expect(ctx.findings.length).toBe(0); | ||
| expect(ctx.observationsMade).toBe(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe("type-level PrReviewLifecycle exhaustive switch (compile check)", () => { | ||
| test("all 7 variants distinguishable", () => { | ||
| const variants: PrReviewLifecycle[] = [ | ||
| { kind: "observe" }, | ||
| { kind: "identify-finding" }, | ||
| { kind: "compose" }, | ||
| { kind: "verify-finding" }, | ||
| { kind: "post" }, | ||
| { kind: "follow-up" }, | ||
| { kind: "conclude" }, | ||
| ]; | ||
| expect(variants.length).toBe(7); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.