|
1 | 1 | // CL-7366: prove the aligned routine and workflow-authoring paths end to |
2 | 2 | // end, against a real Postgres and a real hub+sidecar pair, driving only |
3 | | -// PUBLIC APIs (no seeded internal rows to fake success). Scenarios: |
| 3 | +// PUBLIC APIs (no seeded internal rows to fake success) — with one |
| 4 | +// sanctioned exception: `readRunAddress` below reads `workflow_run` |
| 5 | +// directly from Postgres, because no public route exposes a run's own |
| 6 | +// address by run id (consistent with `routine-trigger-input.test.ts`'s |
| 7 | +// existing precedent; see that function's own doc comment). Scenarios: |
4 | 8 | // |
5 | 9 | // 1. Bench-level routine create with no invited agent, targeting a |
6 | 10 | // deployed definition discovered via `GET .../workflows/targets`; |
|
11 | 15 | // is real but belongs to a different tenant, both 404. |
12 | 16 | // 4. Myra-shaped author -> preview -> deploy over the run-authenticated |
13 | 17 | // `/api/workflow-workflow-authoring` surface: authoring an asset, |
14 | | -// previewing its deploy (CL-7362's native preview seam is not wired |
15 | | -// yet — the route answers a documented `unavailable` envelope, |
16 | | -// asserted here rather than faked; see the inline note below), |
17 | | -// deploying it directly (now a routine target, previously not), |
18 | | -// and a wrong `expectedWireHash` on redeploy failing closed with |
19 | | -// `wire_hash_mismatch`. |
| 18 | +// previewing its deploy (a static, read-only render of the committed |
| 19 | +// source — package name, file list, declared tool pins; CL-7362's |
| 20 | +// probe-without-freeze vendored delta was reverted, see VENDORED.md), |
| 21 | +// and deploying it directly (now a routine target, previously not). |
20 | 22 | // 5. The routine run's own agent principal holds no `approval:*` |
21 | 23 | // grant — approving a deploy is never something an agent can do |
22 | 24 | // to itself. |
@@ -652,40 +654,31 @@ describe.skipIf(databaseUrl === undefined)( |
652 | 654 | }, |
653 | 655 | ); |
654 | 656 | const previewData: unknown = await preview.json(); |
655 | | - if (preview.status === 502) { |
656 | | - // CL-7362 ("Preview: native probe with empty ApprovalSet, no |
657 | | - // freeze") is not wired yet — `docs/workflow-source-authoring.md` |
658 | | - // lists this seam under "Seams that do not exist yet" as of |
659 | | - // this proof landing. The route answers a canonical |
660 | | - // `unavailable` envelope rather than pretending to preview, so |
661 | | - // this asserts exactly that fail-closed shape instead of a |
662 | | - // real wireHash/grants preview, and the deploy below proceeds |
663 | | - // without a preview-derived expectedWireHash. |
664 | | - const previewError = record( |
665 | | - record(previewData, "preview response")["error"], |
666 | | - "preview error", |
667 | | - ); |
668 | | - if (previewError["code"] !== "unavailable") { |
669 | | - throw new Error( |
670 | | - `deploy preview: expected the documented CL-7362 ` + |
671 | | - `"unavailable" envelope, got ${JSON.stringify(previewData)}`, |
672 | | - ); |
673 | | - } |
674 | | - } else if (preview.status !== 200 && preview.status !== 201) { |
| 657 | + if (preview.status !== 200 && preview.status !== 201) { |
675 | 658 | throw new Error( |
676 | 659 | `deploy preview: expected 200/201, got ${preview.status}: ${JSON.stringify(previewData)}`, |
677 | 660 | ); |
678 | | - } else { |
679 | | - const previewBody = record( |
680 | | - record(previewData, "preview response")["data"], |
681 | | - "preview response data", |
| 661 | + } |
| 662 | + const previewBody = record( |
| 663 | + record(previewData, "preview response")["data"], |
| 664 | + "preview response data", |
| 665 | + ); |
| 666 | + // The preview is a STATIC read of the already-committed source |
| 667 | + // (never install/probe/gate/freeze, see VENDORED.md) — asserted |
| 668 | + // unconditionally, not as a fallback branch: the vendored delta |
| 669 | + // that would have made this a real no-freeze probe was reverted. |
| 670 | + stringField(previewBody, "commitSha", "preview response"); |
| 671 | + stringField(previewBody, "entry", "preview response"); |
| 672 | + stringField(previewBody, "packageName", "preview response"); |
| 673 | + if (!Array.isArray(previewBody["files"])) { |
| 674 | + throw new Error( |
| 675 | + `preview response missing a files array: ${JSON.stringify(previewData)}`, |
| 676 | + ); |
| 677 | + } |
| 678 | + if (!Array.isArray(previewBody["toolPackagePins"])) { |
| 679 | + throw new Error( |
| 680 | + `preview response missing a toolPackagePins array: ${JSON.stringify(previewData)}`, |
682 | 681 | ); |
683 | | - stringField(previewBody, "wireHash", "preview response"); |
684 | | - if (!Array.isArray(previewBody["grants"])) { |
685 | | - throw new Error( |
686 | | - `preview response missing a grants array: ${JSON.stringify(previewData)}`, |
687 | | - ); |
688 | | - } |
689 | 682 | } |
690 | 683 |
|
691 | 684 | const notYetTargets = await api( |
@@ -748,40 +741,6 @@ describe.skipIf(databaseUrl === undefined)( |
748 | 741 | await Bun.sleep(200); |
749 | 742 | } |
750 | 743 |
|
751 | | - const wrongHash = await fetch( |
752 | | - `${hub.baseUrl}/api/workflow-workflow-authoring/${assetId}/deploy`, |
753 | | - { |
754 | | - method: "POST", |
755 | | - headers: runHeaders, |
756 | | - body: JSON.stringify({ |
757 | | - commitSha, |
758 | | - entry: WORKFLOW_SOURCE_ENTRY, |
759 | | - expectedWireHash: "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", |
760 | | - }), |
761 | | - }, |
762 | | - ); |
763 | | - const wrongHashData: unknown = await wrongHash.json(); |
764 | | - if (wrongHash.status !== 409) { |
765 | | - throw new Error( |
766 | | - `redeploy with a wrong expectedWireHash: expected 409, got ` + |
767 | | - `${wrongHash.status}: ${JSON.stringify(wrongHashData)}`, |
768 | | - ); |
769 | | - } |
770 | | - const wrongHashError = record( |
771 | | - wrongHashData, |
772 | | - "wrong-expectedWireHash response", |
773 | | - )["error"]; |
774 | | - const errorCode = record( |
775 | | - wrongHashError, |
776 | | - "wrong-expectedWireHash error", |
777 | | - )["code"]; |
778 | | - if (errorCode !== "wire_hash_mismatch") { |
779 | | - throw new Error( |
780 | | - `redeploy with a wrong expectedWireHash: expected code ` + |
781 | | - `"wire_hash_mismatch", got ${JSON.stringify(errorCode)}`, |
782 | | - ); |
783 | | - } |
784 | | - |
785 | 744 | return { assetId, principalId }; |
786 | 745 | }, |
787 | 746 | ).then((result) => result.assetId); |
@@ -869,8 +828,8 @@ describe.skipIf(databaseUrl === undefined)( |
869 | 828 | console.log( |
870 | 829 | "routine-alignment: gate achieved: routine target discovery, " + |
871 | 830 | "retarget (success and fail-closed), agent-authored author/" + |
872 | | - "preview/deploy, deploy wire-hash fail-closed, agent-cannot-" + |
873 | | - "approve, and the workflow detail route all hold end to end.", |
| 831 | + "preview/deploy, agent-cannot-approve, and the workflow detail " + |
| 832 | + "route all hold end to end.", |
874 | 833 | ); |
875 | 834 | }, 240_000); |
876 | 835 | }, |
|
0 commit comments