deepline 0.3.545 → 0.3.547
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
- package/dist/bundling-sources/sdk/src/errors.ts +1 -1
- package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
- package/dist/bundling-sources/sdk/src/index.ts +7 -1
- package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
- package/dist/bundling-sources/sdk/src/play.ts +71 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
- package/dist/bundling-sources/sdk/src/types.ts +33 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
- package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
- package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
- package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
- package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
- package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
- package/dist/cli/auth-AC5277PI.js +43 -0
- package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
- package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
- package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
- package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
- package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
- package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
- package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
- package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
- package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
- package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
- package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
- package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
- package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
- package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
- package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
- package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
- package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
- package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
- package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
- package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
- package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
- package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
- package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
- package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
- package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
- package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
- package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
- package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
- package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
- package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
- package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
- package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
- package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
- package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
- package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
- package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
- package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
- package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
- package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
- package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
- package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
- package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
- package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
- package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
- package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
- package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
- package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
- package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
- package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
- package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
- package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
- package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
- package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
- package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
- package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
- package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
- package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
- package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
- package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
- package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
- package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
- package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
- package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
- package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
- package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
- package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
- package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
- package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
- package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
- package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
- package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
- package/dist/cli/describe-GYYSLZLV.js +50 -0
- package/dist/cli/describe-core.d.mts +4 -4
- package/dist/cli/describe-core.d.ts +4 -4
- package/dist/cli/describe-core.js +1 -1
- package/dist/cli/describe-core.mjs +1 -1
- package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
- package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
- package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
- package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
- package/dist/cli/git-FZIQZNI4.js +25 -0
- package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
- package/dist/cli/index.js +150 -150
- package/dist/cli/index.mjs +46 -46
- package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
- package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
- package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
- package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
- package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
- package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
- package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
- package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
- package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
- package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
- package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
- package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
- package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
- package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
- package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
- package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
- package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
- package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
- package/dist/cli/search-JCWJX2XD.js +32 -0
- package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
- package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
- package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
- package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
- package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
- package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
- package/dist/cli/sessions-NA4SJH6Q.js +22 -0
- package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
- package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
- package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
- package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
- package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
- package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
- package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
- package/dist/cli/tools-WJQ6Y7E4.js +57 -0
- package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
- package/dist/cli/update-ZLRLTBRD.js +34 -0
- package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
- package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
- package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
- package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
- package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
- package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
- package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
- package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
- package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
- package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
- package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
- package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
- package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
- package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
- package/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +65 -40
- package/dist/index.mjs +33 -8
- package/dist/install-integrity.json +137 -130
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +640 -125
- package/dist/plays/play-description.d.mts +3 -3
- package/dist/plays/play-description.d.ts +3 -3
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +11 -11
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/cli/auth-455MB4K6.js +0 -43
- package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
- package/dist/cli/describe-ZRGYAEBT.js +0 -50
- package/dist/cli/git-RC4XDATD.js +0 -25
- package/dist/cli/search-O5VVMXII.js +0 -32
- package/dist/cli/sessions-3PWFWCHO.js +0 -22
- package/dist/cli/skills-RFOMVXIT.js +0 -36
- package/dist/cli/tools-CAO6EVUW.js +0 -57
- package/dist/cli/update-L4DQZY3G.js +0 -34
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which arm a drawn decision took, read off the graph and the order bound boxes
|
|
3
|
+
* report in — never off labels, values or log text.
|
|
4
|
+
*
|
|
5
|
+
* A decision box binds the statement that computes its value; the `if` that
|
|
6
|
+
* acts on it is ordinary code. What the runtime CAN see is which bound box the
|
|
7
|
+
* run reaches next. Each arm of a decision therefore owns its ENTRY set: the
|
|
8
|
+
* first bound boxes on a walk from the arm's target through unbound (sketched or
|
|
9
|
+
* conceptual) boxes. After the decision settles, the first bound box the run
|
|
10
|
+
* reports that the decision can reach at all names the arm:
|
|
11
|
+
*
|
|
12
|
+
* - in exactly one arm's entry set → that arm;
|
|
13
|
+
* - in several (two arms rejoin before any bound box), or reachable but in
|
|
14
|
+
* none (an entry box was never observed) → no claim;
|
|
15
|
+
* - not reachable from the decision → unrelated work; keep waiting.
|
|
16
|
+
*
|
|
17
|
+
* The decision itself re-entering (a loop) resolves the same way: if it is an
|
|
18
|
+
* arm's entry, that arm looped back; otherwise the pending choice is dropped.
|
|
19
|
+
*
|
|
20
|
+
* PURE — no runtime imports.
|
|
21
|
+
*/
|
|
22
|
+
import type { PlayDocflow } from './docflow';
|
|
23
|
+
|
|
24
|
+
export type DocflowDecisionArm = {
|
|
25
|
+
/** The edge's label, as drawn. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** The edge's target node id. */
|
|
28
|
+
to: string;
|
|
29
|
+
/** First bound boxes on this arm (see the module comment). */
|
|
30
|
+
entry: ReadonlySet<string>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type DocflowDecisionArmPlan = {
|
|
34
|
+
decisionId: string;
|
|
35
|
+
arms: readonly DocflowDecisionArm[];
|
|
36
|
+
/** Every node reachable from the decision, the decision included on a loop. */
|
|
37
|
+
reach: ReadonlySet<string>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type DocflowDecisionArmResolution =
|
|
41
|
+
| { kind: 'arm'; arm: DocflowDecisionArm }
|
|
42
|
+
/** The reported box says nothing about this decision. Keep waiting. */
|
|
43
|
+
| { kind: 'unrelated' }
|
|
44
|
+
/** The reported box is downstream but names no single arm. Stop waiting. */
|
|
45
|
+
| { kind: 'unresolvable' };
|
|
46
|
+
|
|
47
|
+
const plansByDocflow = new WeakMap<
|
|
48
|
+
PlayDocflow,
|
|
49
|
+
ReadonlyMap<string, DocflowDecisionArmPlan>
|
|
50
|
+
>();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* One plan per bound, labelled, multi-arm-capable decision. A decision with no
|
|
54
|
+
* labelled outgoing edge has no arm to name and gets no plan.
|
|
55
|
+
*/
|
|
56
|
+
export function docflowDecisionArmPlans(
|
|
57
|
+
docflow: PlayDocflow,
|
|
58
|
+
): ReadonlyMap<string, DocflowDecisionArmPlan> {
|
|
59
|
+
const cached = plansByDocflow.get(docflow);
|
|
60
|
+
if (cached) return cached;
|
|
61
|
+
const sketched = new Set(
|
|
62
|
+
docflow.nodes.filter((node) => node.sketch).map((node) => node.id),
|
|
63
|
+
);
|
|
64
|
+
const bound = new Set(
|
|
65
|
+
docflow.bindings
|
|
66
|
+
.map((binding) => binding.nodeId)
|
|
67
|
+
.filter((nodeId) => !sketched.has(nodeId)),
|
|
68
|
+
);
|
|
69
|
+
const successors = new Map<string, string[]>();
|
|
70
|
+
for (const edge of docflow.edges) {
|
|
71
|
+
successors.set(edge.from, [...(successors.get(edge.from) ?? []), edge.to]);
|
|
72
|
+
}
|
|
73
|
+
const plans = new Map<string, DocflowDecisionArmPlan>();
|
|
74
|
+
for (const node of docflow.nodes) {
|
|
75
|
+
if (node.kind !== 'decision' || !bound.has(node.id)) continue;
|
|
76
|
+
const arms: DocflowDecisionArm[] = [];
|
|
77
|
+
for (const edge of docflow.edges) {
|
|
78
|
+
if (edge.from !== node.id) continue;
|
|
79
|
+
const label = edge.label?.trim();
|
|
80
|
+
if (!label) continue;
|
|
81
|
+
arms.push({
|
|
82
|
+
label,
|
|
83
|
+
to: edge.to,
|
|
84
|
+
entry: entryBoxes(edge.to, bound, successors),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (arms.length === 0) continue;
|
|
88
|
+
plans.set(node.id, {
|
|
89
|
+
decisionId: node.id,
|
|
90
|
+
arms,
|
|
91
|
+
reach: reachableFrom(node.id, successors),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
plansByDocflow.set(docflow, plans);
|
|
95
|
+
return plans;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function entryBoxes(
|
|
99
|
+
start: string,
|
|
100
|
+
bound: ReadonlySet<string>,
|
|
101
|
+
successors: ReadonlyMap<string, readonly string[]>,
|
|
102
|
+
): Set<string> {
|
|
103
|
+
const entry = new Set<string>();
|
|
104
|
+
const seen = new Set<string>();
|
|
105
|
+
const queue = [start];
|
|
106
|
+
for (let head = 0; head < queue.length; head += 1) {
|
|
107
|
+
const current = queue[head]!;
|
|
108
|
+
if (seen.has(current)) continue;
|
|
109
|
+
seen.add(current);
|
|
110
|
+
if (bound.has(current)) {
|
|
111
|
+
entry.add(current);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
queue.push(...(successors.get(current) ?? []));
|
|
115
|
+
}
|
|
116
|
+
return entry;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function reachableFrom(
|
|
120
|
+
start: string,
|
|
121
|
+
successors: ReadonlyMap<string, readonly string[]>,
|
|
122
|
+
): Set<string> {
|
|
123
|
+
const reach = new Set<string>();
|
|
124
|
+
const queue = [...(successors.get(start) ?? [])];
|
|
125
|
+
for (let head = 0; head < queue.length; head += 1) {
|
|
126
|
+
const current = queue[head]!;
|
|
127
|
+
if (reach.has(current)) continue;
|
|
128
|
+
reach.add(current);
|
|
129
|
+
queue.push(...(successors.get(current) ?? []));
|
|
130
|
+
}
|
|
131
|
+
return reach;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** What the box `reportedNodeId`, reported after the decision settled, says. */
|
|
135
|
+
export function resolveDocflowDecisionArm(
|
|
136
|
+
plan: DocflowDecisionArmPlan,
|
|
137
|
+
reportedNodeId: string,
|
|
138
|
+
): DocflowDecisionArmResolution {
|
|
139
|
+
const matches = plan.arms.filter((arm) => arm.entry.has(reportedNodeId));
|
|
140
|
+
if (matches.length === 1) return { kind: 'arm', arm: matches[0]! };
|
|
141
|
+
if (matches.length > 1) return { kind: 'unresolvable' };
|
|
142
|
+
if (reportedNodeId === plan.decisionId || plan.reach.has(reportedNodeId)) {
|
|
143
|
+
return { kind: 'unresolvable' };
|
|
144
|
+
}
|
|
145
|
+
return { kind: 'unrelated' };
|
|
146
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a diagram the order reads: box ids, edges and subgraph
|
|
3
|
+
* membership. Structural, so a check report's slimmer diagram (the CLI's) fits
|
|
4
|
+
* as well as a parsed `PlayDocflow`.
|
|
5
|
+
*/
|
|
6
|
+
export type DocflowFlowShape = {
|
|
7
|
+
nodes: ReadonlyArray<{ id: string }>;
|
|
8
|
+
edges: ReadonlyArray<{ from: string; to: string }>;
|
|
9
|
+
subgraphs?: ReadonlyArray<{
|
|
10
|
+
id: string;
|
|
11
|
+
memberIds: readonly string[];
|
|
12
|
+
parentId?: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Every box and subgraph of a diagram in the order a reader follows it: each
|
|
18
|
+
* after every box that leads into it (longest-path layering over the drawn
|
|
19
|
+
* edges), a subgraph just before its first member, authored order breaking
|
|
20
|
+
* ties. Boxes on a cycle keep authored order after the rest. Unlike the run
|
|
21
|
+
* steps, sketches are included: a diagram review is about every drawn box.
|
|
22
|
+
*
|
|
23
|
+
* PURE and type-only against the parser, so the CLI can order a check's
|
|
24
|
+
* diagram issues without loading it.
|
|
25
|
+
*/
|
|
26
|
+
export function docflowFlowOrder(docflow: DocflowFlowShape): string[] {
|
|
27
|
+
const subgraphs = docflow.subgraphs ?? [];
|
|
28
|
+
const regionOf = new Map<string, string>();
|
|
29
|
+
for (const region of subgraphs) {
|
|
30
|
+
for (const memberId of region.memberIds) regionOf.set(memberId, region.id);
|
|
31
|
+
if (region.parentId) regionOf.set(region.id, region.parentId);
|
|
32
|
+
}
|
|
33
|
+
const endpoints = [
|
|
34
|
+
...docflow.nodes.map((node) => node.id),
|
|
35
|
+
...subgraphs.map((region) => region.id),
|
|
36
|
+
];
|
|
37
|
+
const known = new Set(endpoints);
|
|
38
|
+
const next = new Map<string, string[]>();
|
|
39
|
+
const indegree = new Map(endpoints.map((id) => [id, 0]));
|
|
40
|
+
for (const edge of docflow.edges) {
|
|
41
|
+
if (!known.has(edge.from) || !known.has(edge.to)) continue;
|
|
42
|
+
next.set(edge.from, [...(next.get(edge.from) ?? []), edge.to]);
|
|
43
|
+
indegree.set(edge.to, (indegree.get(edge.to) ?? 0) + 1);
|
|
44
|
+
}
|
|
45
|
+
const layer = new Map<string, number>();
|
|
46
|
+
const queue = endpoints.filter((id) => indegree.get(id) === 0);
|
|
47
|
+
for (const id of queue) layer.set(id, 0);
|
|
48
|
+
for (let head = 0; head < queue.length; head += 1) {
|
|
49
|
+
const current = queue[head]!;
|
|
50
|
+
for (const target of next.get(current) ?? []) {
|
|
51
|
+
layer.set(
|
|
52
|
+
target,
|
|
53
|
+
Math.max(layer.get(target) ?? 0, (layer.get(current) ?? 0) + 1),
|
|
54
|
+
);
|
|
55
|
+
const remaining = (indegree.get(target) ?? 0) - 1;
|
|
56
|
+
indegree.set(target, remaining);
|
|
57
|
+
if (remaining === 0) queue.push(target);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const onCycle = Math.max(0, ...layer.values()) + 1;
|
|
61
|
+
const depthOf = (id: string): number => {
|
|
62
|
+
const own = indegree.get(id) === 0 ? (layer.get(id) ?? 0) : onCycle;
|
|
63
|
+
const region = regionOf.get(id);
|
|
64
|
+
return Math.max(own, region ? depthOf(region) : 0);
|
|
65
|
+
};
|
|
66
|
+
const ordered = docflow.nodes
|
|
67
|
+
.map((node, index) => ({ id: node.id, index }))
|
|
68
|
+
.sort(
|
|
69
|
+
(left, right) =>
|
|
70
|
+
depthOf(left.id) - depthOf(right.id) || left.index - right.index,
|
|
71
|
+
)
|
|
72
|
+
.map(({ id }) => id);
|
|
73
|
+
// A subgraph is read where its first member falls, its members together.
|
|
74
|
+
const result: string[] = [];
|
|
75
|
+
const placed = new Set<string>();
|
|
76
|
+
const place = (id: string) => {
|
|
77
|
+
if (placed.has(id)) return;
|
|
78
|
+
const region = regionOf.get(id);
|
|
79
|
+
if (region && !placed.has(region)) {
|
|
80
|
+
place(region);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
placed.add(id);
|
|
84
|
+
result.push(id);
|
|
85
|
+
if (known.has(id) && subgraphs.some((candidate) => candidate.id === id)) {
|
|
86
|
+
for (const member of ordered) if (regionOf.get(member) === id) place(member);
|
|
87
|
+
for (const child of subgraphs)
|
|
88
|
+
if (regionOf.get(child.id) === id) place(child.id);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const id of ordered) place(id);
|
|
92
|
+
for (const region of subgraphs) place(region.id);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
@@ -25,6 +25,8 @@ export type DocflowReasonNodeState = {
|
|
|
25
25
|
error?: string | null;
|
|
26
26
|
nodeIo?: {
|
|
27
27
|
outputs?: Record<string, { kind: string; value?: unknown }>;
|
|
28
|
+
/** The arm the runtime recorded this decision taking, when it did. */
|
|
29
|
+
decision?: { arm: string; to: string } | null;
|
|
28
30
|
} | null;
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -338,7 +340,14 @@ export function deriveDocflowUnreachedReason(input: {
|
|
|
338
340
|
if (!node || node.kind !== 'decision') continue;
|
|
339
341
|
const outgoing = graph.successors.get(reachedId) ?? [];
|
|
340
342
|
if (outgoing.length < 2) continue;
|
|
341
|
-
|
|
343
|
+
// The recorded arm is the fact; which arm target carries state is only an
|
|
344
|
+
// inference, and a wrong one when arms rejoin at a shared box.
|
|
345
|
+
const recorded = stateFor(nodeStates, reachedId)?.nodeIo?.decision;
|
|
346
|
+
const taken = recorded
|
|
347
|
+
? outgoing.find(
|
|
348
|
+
(edge) => edge.to === recorded.to && edge.label?.trim() === recorded.arm,
|
|
349
|
+
)
|
|
350
|
+
: outgoing.find((edge) => graph.reached.has(edge.to));
|
|
342
351
|
const skipped = outgoing.find((edge) => edge.to === skippedId);
|
|
343
352
|
if (!taken || !skipped || taken.to === skippedId) continue;
|
|
344
353
|
const takenTarget = reasonNode(graph, docflow, taken.to);
|