deepline 0.3.128 → 0.3.129

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.
Files changed (128) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +34 -9
  2. package/dist/bundling-sources/sdk/src/http.ts +22 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +22 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +265 -2
  6. package/dist/bundling-sources/shared_libs/play-runtime/bounded-batch-function.ts +682 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +21 -5
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5390 -1732
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +107 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +229 -7
  12. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +25 -4
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-capacity.ts +71 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +1 -1
  15. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +4 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +694 -28
  17. package/dist/bundling-sources/shared_libs/play-runtime/egress-bandwidth-probe.ts +167 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +103 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-receipt-output-reference.ts +34 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-response-size.ts +27 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +66 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +425 -71
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +210 -32
  24. package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +27 -13
  25. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +19 -6
  26. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +61 -2
  27. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +33 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +42 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +11 -11
  30. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +49 -16
  31. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +1653 -98
  32. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +807 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/memory-pressure-signal.ts +138 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +85 -3
  35. package/dist/bundling-sources/shared_libs/play-runtime/persistence-latch.ts +60 -2
  36. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +46 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +2 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +1 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +1 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +1 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +70 -27
  42. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +56 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/adaptive-provider-capacity-controller.ts +192 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/epoch-aimd-rate-controller.ts +194 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +220 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +214 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +43 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +30 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-rate-policy.ts +95 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-throttle-classifier.ts +40 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +1535 -11
  52. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +49 -2
  53. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +6 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +55 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/egress-probe.ts +221 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +339 -29
  57. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +28 -1
  58. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +192 -165
  59. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +6 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +90 -5
  61. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +281 -6
  62. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +27 -1
  63. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +19 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +108 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +40 -0
  66. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +11 -5
  67. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +30 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +276 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +723 -115
  70. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +98 -2
  71. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +3 -2
  72. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +41 -4
  73. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +448 -0
  74. package/dist/bundling-sources/shared_libs/play-runtime/runtime-map-row-feed.ts +215 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +11 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +161 -14
  77. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-value.ts +184 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +607 -121
  79. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +4 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +21 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +15 -2
  82. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +71 -14
  83. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +2 -2
  84. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +288 -119
  85. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +8 -6
  86. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +28 -3
  87. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/canonical-integration-operation-store.ts +179 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +80 -2
  89. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +31 -2
  90. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-store-contract.ts +104 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-reference.ts +47 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-retirement.ts +193 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +420 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +41 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +134 -3
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +1657 -95
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +885 -73
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-completion-coalescer.ts +452 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +601 -42
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +1 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +371 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +86 -7
  103. package/dist/bundling-sources/shared_libs/play-runtime/secret-redaction.ts +153 -22
  104. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +1 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +188 -38
  106. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +28 -13
  107. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +44 -1
  108. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +56 -4
  109. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +2 -0
  110. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +16 -10
  111. package/dist/bundling-sources/shared_libs/plays/dataset.ts +4 -1
  112. package/dist/cli/index.js +250 -38
  113. package/dist/cli/index.mjs +250 -38
  114. package/dist/{compiler-manifest-DfSnbCTW.d.mts → compiler-manifest-BIqRyj5m.d.mts} +1 -1
  115. package/dist/{compiler-manifest-DfSnbCTW.d.ts → compiler-manifest-BIqRyj5m.d.ts} +1 -1
  116. package/dist/index.d.mts +4 -2
  117. package/dist/index.d.ts +4 -2
  118. package/dist/index.js +231 -35
  119. package/dist/index.mjs +231 -35
  120. package/dist/install-integrity.json +31 -2
  121. package/dist/plays/bundle-play-file.d.mts +2 -2
  122. package/dist/plays/bundle-play-file.d.ts +2 -2
  123. package/dist/plays/bundle-play-file.mjs +65 -1
  124. package/dist/release.d.mts +1 -1
  125. package/dist/release.d.ts +1 -1
  126. package/dist/release.js +1 -1
  127. package/dist/release.mjs +1 -1
  128. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  INTEGRATION_OPERATION_CANONICAL_READER_CAPABILITY,
3
+ RUNTIME_RECEIPT_VALUE_REFERENCE_READER_CAPABILITY,
3
4
  type IntegrationOperationStorageMode,
4
5
  type ReaderFenceApplyOutcome,
5
6
  type ReaderFenceWriterMode,
@@ -52,6 +53,43 @@ export function createRuntimeGatewayReaderFenceJob(
52
53
  return { mode: fence.mode, source: 'fence', epoch: fence.epoch };
53
54
  },
54
55
 
56
+ async runtimeReceiptValueReferenceWriterMode(input) {
57
+ validateSchema(input.schema);
58
+ let fence: RuntimeGatewayReaderFence | null;
59
+ try {
60
+ fence = await ports.store.read({ schema: input.schema });
61
+ } catch {
62
+ return {
63
+ enabled: false,
64
+ source: 'fail_closed',
65
+ epoch: null,
66
+ failure: 'store_unavailable',
67
+ };
68
+ }
69
+ if (!fence) {
70
+ return { enabled: false, source: 'absent', epoch: null };
71
+ }
72
+ if (
73
+ !isValidRuntimeGatewayReaderFence(fence) ||
74
+ fence.schema !== input.schema
75
+ ) {
76
+ return {
77
+ enabled: false,
78
+ source: 'fail_closed',
79
+ epoch: null,
80
+ failure: 'invalid_record',
81
+ };
82
+ }
83
+ return {
84
+ enabled:
85
+ fence.mode === 'canonical_v1' &&
86
+ fence.canonicalReaderProof?.capability ===
87
+ RUNTIME_RECEIPT_VALUE_REFERENCE_READER_CAPABILITY,
88
+ source: 'fence',
89
+ epoch: fence.epoch,
90
+ };
91
+ },
92
+
55
93
  async apply(
56
94
  candidate: RuntimeGatewayReaderFenceCandidate,
57
95
  ): Promise<ReaderFenceApplyOutcome> {
@@ -102,7 +140,10 @@ export function validateRuntimeGatewayReaderFence(
102
140
  'Canonical reader fences require verified gateway reader proof.',
103
141
  );
104
142
  }
105
- if (proof.capability !== INTEGRATION_OPERATION_CANONICAL_READER_CAPABILITY) {
143
+ if (
144
+ proof.capability !== INTEGRATION_OPERATION_CANONICAL_READER_CAPABILITY &&
145
+ proof.capability !== RUNTIME_RECEIPT_VALUE_REFERENCE_READER_CAPABILITY
146
+ ) {
106
147
  throw new Error(
107
148
  'Canonical reader fence has an unsupported gateway capability.',
108
149
  );
@@ -33,9 +33,10 @@ export type PlayLaunchQueuePolicy = {
33
33
  };
34
34
 
35
35
  /**
36
- * CLI/API launches are user-visible requests. Give a short capacity window so
37
- * a temporary spike can clear, but never let an interactive run appear to
38
- * succeed and then start charging much later without an explicit retry.
36
+ * Retained for callers that need to describe the historical API capacity
37
+ * window in diagnostics. Accepted API launches no longer apply this deadline:
38
+ * the architecture contract is durable admission, and an accepted run must
39
+ * not silently disappear merely because a burst outlasted one worker fleet.
39
40
  */
40
41
  export const API_LAUNCH_CAPACITY_WAIT_SECONDS = 60;
41
42
 
@@ -75,15 +76,14 @@ export function resolvePlayLaunchQueuePolicy(
75
76
  case 'api':
76
77
  return {
77
78
  triggerSource: 'api',
78
- // API/CLI callers need a bounded, user-visible outcome. A brief
79
- // capacity window absorbs normal spikes; after that the run is
80
- // terminalized with a typed queue-expired/capacity result rather than
81
- // starting unexpectedly much later. The priority still lets manual
82
- // work win the next slot within its organization without bypassing
83
- // cross-org fairness.
79
+ // Once accepted, API/CLI work is a durable customer intent. The
80
+ // admission service still bounds request concurrency and active-run
81
+ // limits before enqueue; after enqueue, autoscaling/backpressure must
82
+ // drain the run rather than converting temporary capacity pressure
83
+ // into silent work loss.
84
84
  priority: 100,
85
- maxDelaySeconds: API_LAUNCH_CAPACITY_WAIT_SECONDS,
86
- sandboxCapacityMaxWaitSeconds: API_LAUNCH_CAPACITY_WAIT_SECONDS,
85
+ maxDelaySeconds: null,
86
+ sandboxCapacityMaxWaitSeconds: null,
87
87
  };
88
88
  case 'webhook':
89
89
  return {
@@ -1,6 +1,8 @@
1
+ import { stringifyPostgresJson } from './postgres-json';
2
+ import { boundRunLogLine } from './run-log-buffer';
1
3
  import { createSecretRedactionContext } from './secret-redaction';
2
4
  import {
3
- assertRuntimeReceiptOutputWithinLimit,
5
+ assertSerializedRuntimeReceiptOutputWithinLimit,
4
6
  inspectConvexLedgerPayload,
5
7
  jsonByteLengthUpTo,
6
8
  LEDGER_TERMINAL_RESULT_MAX_BYTES,
@@ -57,21 +59,54 @@ export function sanitizeOpaqueLedgerPayload(value: unknown): unknown {
57
59
  return redactedIssue ? opaqueLedgerPayloadSummary(redactedIssue) : redacted;
58
60
  }
59
61
 
60
- /** Secret-redact a receipt payload without coupling its 10 MiB cell limit to the ledger. */
61
- export function sanitizeRuntimeReceiptPayload(value: unknown): unknown {
62
- // Reject an obviously oversized source before doing redaction work, then
63
- // validate the exact value that will be persisted. Redaction normally shrinks
64
- // credential-shaped values but can expand short matched strings.
65
- assertRuntimeReceiptOutputWithinLimit({
66
- output: value,
67
- path: 'runtime receipt output',
68
- });
62
+ /** A receipt payload redacted once, serialized once, and measured from that text. */
63
+ export type SanitizedRuntimeReceiptPayload = {
64
+ /** The redacted value. Callers return or re-project this, never the source. */
65
+ value: unknown;
66
+ /**
67
+ * Canonical Postgres JSON text for `value`, byte-identical to what
68
+ * `stringifyPostgresJson(value ?? null)` produces. `jsonb` accepts this text
69
+ * directly, so the completion path never re-serializes the same output.
70
+ */
71
+ serialized: string;
72
+ /** UTF-8 byte length of `serialized`; the measured size the limit is enforced on. */
73
+ bytes: number;
74
+ };
75
+
76
+ /**
77
+ * Secret-redact a receipt payload without coupling its 10 MiB cell limit to the
78
+ * ledger, and serialize it exactly once.
79
+ *
80
+ * The limit is enforced on the redacted, serialized value that is actually
81
+ * persisted. Redaction normally shrinks credential-shaped values but can expand
82
+ * short matched strings, so measuring the source instead would be wrong in both
83
+ * directions.
84
+ *
85
+ * Redaction is identity-preserving: a payload carrying no credential comes back
86
+ * as the very object that was passed in, with no deep clone, and is serialized
87
+ * exactly once. Only a payload that actually redacts pays for a rebuilt value.
88
+ */
89
+ export function sanitizeRuntimeReceiptPayloadForStorage(
90
+ value: unknown,
91
+ ): SanitizedRuntimeReceiptPayload {
69
92
  const redacted = ledgerIngressRedactor.redact(value);
70
- assertRuntimeReceiptOutputWithinLimit({
71
- output: redacted,
93
+ // `undefined` is not JSON. The receipt contract stores it as jsonb `null`,
94
+ // which is exactly what the previous `stringifyPostgresJson(output ?? null)`
95
+ // parameter produced.
96
+ const serialized = stringifyPostgresJson(redacted ?? null);
97
+ if (serialized === undefined) {
98
+ throw new TypeError('Runtime receipt output is not JSON-serializable.');
99
+ }
100
+ const bytes = assertSerializedRuntimeReceiptOutputWithinLimit({
101
+ serialized,
72
102
  path: 'runtime receipt output after secret redaction',
73
103
  });
74
- return redacted;
104
+ return { value: redacted, serialized, bytes };
105
+ }
106
+
107
+ /** Secret-redact a receipt payload without coupling its 10 MiB cell limit to the ledger. */
108
+ export function sanitizeRuntimeReceiptPayload(value: unknown): unknown {
109
+ return sanitizeRuntimeReceiptPayloadForStorage(value).value;
75
110
  }
76
111
 
77
112
  export function sanitizeLedgerLogLines(value: unknown): string[] {
@@ -80,9 +115,7 @@ export function sanitizeLedgerLogLines(value: unknown): string[] {
80
115
  .filter((line): line is string => typeof line === 'string')
81
116
  .slice(0, MAX_LEDGER_LOG_LINES_PER_EVENT)
82
117
  .map((line) =>
83
- ledgerIngressRedactor
84
- .redactString(line.trim())
85
- .slice(0, MAX_LEDGER_LOG_LINE_LENGTH),
118
+ boundRunLogLine(ledgerIngressRedactor.redactString(line.trim())),
86
119
  )
87
120
  .filter(Boolean);
88
121
  }