@gate-forge/witness 0.13.9 → 0.14.0
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/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +21 -0
- package/dist/constants.js.map +1 -1
- package/dist/json.d.ts +2 -0
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +4 -0
- package/dist/json.js.map +1 -1
- package/dist/witness/api-settlement.d.ts +2 -0
- package/dist/witness/api-settlement.d.ts.map +1 -1
- package/dist/witness/api-settlement.js +2 -0
- package/dist/witness/api-settlement.js.map +1 -1
- package/dist/witness/browser.d.ts +8 -1
- package/dist/witness/browser.d.ts.map +1 -1
- package/dist/witness/browser.js +15 -3
- package/dist/witness/browser.js.map +1 -1
- package/dist/witness/openapi-at-bind.d.ts +48 -0
- package/dist/witness/openapi-at-bind.d.ts.map +1 -0
- package/dist/witness/openapi-at-bind.js +91 -0
- package/dist/witness/openapi-at-bind.js.map +1 -0
- package/dist/witness/page-observation.d.ts +1 -0
- package/dist/witness/page-observation.d.ts.map +1 -1
- package/dist/witness/page-observation.js.map +1 -1
- package/dist/witness/page-observer-registration.d.ts +12 -0
- package/dist/witness/page-observer-registration.d.ts.map +1 -1
- package/dist/witness/page-observer-registration.js +5 -1
- package/dist/witness/page-observer-registration.js.map +1 -1
- package/dist/witness/page-observer.d.ts.map +1 -1
- package/dist/witness/page-observer.js +1 -0
- package/dist/witness/page-observer.js.map +1 -1
- package/dist/witness/response-shape.d.ts +88 -0
- package/dist/witness/response-shape.d.ts.map +1 -0
- package/dist/witness/response-shape.js +146 -0
- package/dist/witness/response-shape.js.map +1 -0
- package/dist/witness/run-options.d.ts +13 -0
- package/dist/witness/run-options.d.ts.map +1 -1
- package/dist/witness/run-options.js +26 -0
- package/dist/witness/run-options.js.map +1 -1
- package/dist/witness/server.d.ts.map +1 -1
- package/dist/witness/server.js +155 -12
- package/dist/witness/server.js.map +1 -1
- package/package.json +4 -2
package/dist/witness/server.js
CHANGED
|
@@ -154,7 +154,7 @@ import { readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
|
154
154
|
import { join, resolve } from 'node:path';
|
|
155
155
|
import { ATTESTATION_VERSION, attestationMac, behaviorActionDigestOf, DEFAULT_QUEUE_POLL_INTERVAL_MS, DEFAULT_QUEUE_TERMINAL_TIMEOUT_MS, BehaviorCatalogSchema, BEHAVIOR_CASE_KIND, enumerationDigestOf, interpretObservedPath, pathMatchesShape, recordIdOf, resolveHttpRoute, } from '@gate-forge/core';
|
|
156
156
|
import { canonicalOf } from '../json.js';
|
|
157
|
-
import { DEFAULT_REQUEST_TIMEOUT_MS, HTTP_OBSERVED_KIND, KNOWN_RECORD_KINDS, LOOPBACK_HOSTNAME, OBSERVED_EXCHANGES_CAP, OBSERVED_KIND, PERSISTENCE_KIND, RUN_HEADER, DIRECT_CHANNEL, DIRECT_EXCHANGES_CAP, VERIFIER_HEADER, } from '../constants.js';
|
|
157
|
+
import { DEFAULT_REQUEST_TIMEOUT_MS, HTTP_EXCHANGES_KIND, HTTP_OBSERVED_KIND, HTTP_OPENAPI_KIND, KNOWN_RECORD_KINDS, LOOPBACK_HOSTNAME, OBSERVED_EXCHANGES_CAP, OBSERVED_KIND, PERSISTENCE_KIND, RUN_HEADER, DIRECT_CHANNEL, DIRECT_EXCHANGES_CAP, VERIFIER_HEADER, } from '../constants.js';
|
|
158
158
|
import { PageObserverRegistrationError, registerPageObserver, sweepPageVisits } from './page-observer-registration.js';
|
|
159
159
|
import { AdapterRegistryError, loadAdapters, makeAdapterContext } from './adapter-registry.js';
|
|
160
160
|
import { AttestationError, assertLoopback, envFingerprintMismatch, probeEnvFingerprint, } from './env-attestation.js';
|
|
@@ -165,6 +165,8 @@ import { SURFACE_DESCRIPTOR_VERSION, validateSurface, } from '../surface.js';
|
|
|
165
165
|
import { ChaosScheduler, chaosRouteKey } from './chaos.js';
|
|
166
166
|
import { recordTwinShape } from './twin-shapes.js';
|
|
167
167
|
import { assertNoStartedConflict, parseRunOptions, } from './run-options.js';
|
|
168
|
+
import { fetchOpenApiAtBind, openApiRecordPayload } from './openapi-at-bind.js';
|
|
169
|
+
import { RESPONSE_BODY_CAP_BYTES, buildResponseShapeIndex, judgeResponseShape, judgeEngineExchange, planResponseShape, shapeRank, } from './response-shape.js';
|
|
168
170
|
import { validateScopeSnapshot } from './behavior.js';
|
|
169
171
|
import { BEHAVIOR_BODY_LIMIT_BYTES, BehaviorDriverError, driveBehaviorRequest } from './behavior-request.js';
|
|
170
172
|
import { OBSERVE_CHANNEL, OBSERVED_E2E_TEST_KIND, SERVER_CHANNEL, SERVER_E2E_TEST_KIND } from '../constants.js';
|
|
@@ -582,6 +584,23 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
582
584
|
// recorded byte-identical to today.
|
|
583
585
|
const forwardUrl = stripMountPath(req.url ?? '/', state.options.mountPath);
|
|
584
586
|
const testCodeInitiated = req.headers['x-gateforge-initiator'] === 'test-code';
|
|
587
|
+
const rawFetchDest = typeof req.headers['sec-fetch-dest'] === 'string'
|
|
588
|
+
? req.headers['sec-fetch-dest'].toLowerCase()
|
|
589
|
+
: null;
|
|
590
|
+
const resourceType = typeof req.headers['x-gateforge-resource-type'] === 'string'
|
|
591
|
+
? req.headers['x-gateforge-resource-type'].toLowerCase()
|
|
592
|
+
: null;
|
|
593
|
+
const inferredFetchDest = resourceType === 'fetch' || resourceType === 'xhr'
|
|
594
|
+
? 'empty'
|
|
595
|
+
: resourceType === 'document'
|
|
596
|
+
? 'document'
|
|
597
|
+
: resourceType === 'stylesheet'
|
|
598
|
+
? 'style'
|
|
599
|
+
: resourceType === 'texttrack'
|
|
600
|
+
? 'track'
|
|
601
|
+
: resourceType;
|
|
602
|
+
const fetchDest = rawFetchDest ?? inferredFetchDest;
|
|
603
|
+
const resourceTypeConflict = rawFetchDest !== null && inferredFetchDest !== null && rawFetchDest !== inferredFetchDest;
|
|
585
604
|
// In-flight accounting (plan §11.4): a proxy exchange that starts
|
|
586
605
|
// before `/run-context` binds must refuse the bind — otherwise
|
|
587
606
|
// traffic from an older invocation could be signed under the new
|
|
@@ -643,6 +662,14 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
643
662
|
const collectionSnapshot = [];
|
|
644
663
|
let collectionBytes = 0;
|
|
645
664
|
let totalBytes = 0;
|
|
665
|
+
// Response-shape plan (0.14 WP4): decided from the route, status and
|
|
666
|
+
// content type held before any byte is copied. Null when this run
|
|
667
|
+
// asked for no shapes; an exchange with no plan carries no verdict.
|
|
668
|
+
const shapePlan = state.responseShape === null
|
|
669
|
+
? null
|
|
670
|
+
: planResponseShape(state.shapeIndex, method, observedPath, status, upstream.headers['content-type']);
|
|
671
|
+
const shapeBody = [];
|
|
672
|
+
let shapeBytes = 0;
|
|
646
673
|
upstream.on('data', (chunk) => {
|
|
647
674
|
totalBytes += chunk.length;
|
|
648
675
|
if (snapshotBytes < OBSERVED_BODY_SNAPSHOT_BYTES) {
|
|
@@ -657,6 +684,12 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
657
684
|
collectionSnapshot.push(Buffer.from(taken));
|
|
658
685
|
collectionBytes += taken.length;
|
|
659
686
|
}
|
|
687
|
+
if (shapePlan !== null && shapePlan.kind === 'validate' && shapeBytes < RESPONSE_BODY_CAP_BYTES) {
|
|
688
|
+
const room = RESPONSE_BODY_CAP_BYTES - shapeBytes;
|
|
689
|
+
const taken = chunk.length > room ? chunk.subarray(0, room) : chunk;
|
|
690
|
+
shapeBody.push(Buffer.from(taken));
|
|
691
|
+
shapeBytes += taken.length;
|
|
692
|
+
}
|
|
660
693
|
});
|
|
661
694
|
upstream.on('end', () => {
|
|
662
695
|
const seq = (state.observedSeq += 1);
|
|
@@ -676,6 +709,9 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
676
709
|
method,
|
|
677
710
|
path: observedPath,
|
|
678
711
|
status,
|
|
712
|
+
fetchDest,
|
|
713
|
+
resourceType,
|
|
714
|
+
...(resourceTypeConflict ? { resourceTypeConflict: true } : {}),
|
|
679
715
|
seq,
|
|
680
716
|
bodySha256: createHash('sha256').update(bodySnapshot).digest('hex'),
|
|
681
717
|
bodyBytes: totalBytes,
|
|
@@ -693,6 +729,9 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
693
729
|
: collectionConflict !== null
|
|
694
730
|
? { collectionConflict }
|
|
695
731
|
: {}),
|
|
732
|
+
...(shapePlan === null
|
|
733
|
+
? {}
|
|
734
|
+
: { shape: judgeResponseShape(shapePlan, Buffer.concat(shapeBody), totalBytes) }),
|
|
696
735
|
});
|
|
697
736
|
// Response attribution (Observe channel): what the response
|
|
698
737
|
// NAMED, kept even after the exchange is consumed, so a
|
|
@@ -712,7 +751,10 @@ async function startObservedProxy(state, sessionId, chaosSession) {
|
|
|
712
751
|
upstream.pipe(res);
|
|
713
752
|
};
|
|
714
753
|
const forwardHeaders = { ...req.headers, host: proxyTargetUrl.host };
|
|
715
|
-
|
|
754
|
+
for (const name of Object.keys(forwardHeaders)) {
|
|
755
|
+
if (name.startsWith('x-gateforge-'))
|
|
756
|
+
delete forwardHeaders[name];
|
|
757
|
+
}
|
|
716
758
|
const forward = request({
|
|
717
759
|
protocol: proxyTargetUrl.protocol,
|
|
718
760
|
hostname: proxyTargetUrl.hostname,
|
|
@@ -850,6 +892,30 @@ function sealPageObservationRecords(state, sessionId, outcome) {
|
|
|
850
892
|
}
|
|
851
893
|
state.pageObservationRecords.delete(sessionId);
|
|
852
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* Issues the session's ONE claim-free `http.exchanges` record (0.14
|
|
897
|
+
* WP2): the same transport snapshot the per-claim `http.observed`
|
|
898
|
+
* records carry (watermark, dedup, cap, `truncated`), bound to the
|
|
899
|
+
* SESSION identity instead of an obligation so no claim can ever select
|
|
900
|
+
* it. Only a session that sealed as PASSED retains its exchanges — the
|
|
901
|
+
* same non-passing rule {@link sealPageObservationRecords} applies to
|
|
902
|
+
* page observations — and a session that proxied nothing issues
|
|
903
|
+
* nothing. The record is ledger evidence for the verdict-time
|
|
904
|
+
* `httpLedger`; it never satisfies a claim.
|
|
905
|
+
*/
|
|
906
|
+
function issueSessionExchangesRecord(state, session) {
|
|
907
|
+
if (session.outcome !== 'passed')
|
|
908
|
+
return;
|
|
909
|
+
const { exchanges, truncated } = transportSnapshot(state, session);
|
|
910
|
+
if (exchanges.length === 0)
|
|
911
|
+
return;
|
|
912
|
+
issueRecord(state, session.sessionId, HTTP_EXCHANGES_KIND, session.testId, {
|
|
913
|
+
channel: OBSERVE_CHANNEL,
|
|
914
|
+
sessionId: session.sessionId,
|
|
915
|
+
exchanges,
|
|
916
|
+
...(truncated ? { truncated: true } : {}),
|
|
917
|
+
}, 'engine-observed');
|
|
918
|
+
}
|
|
853
919
|
function isPlainObject(value) {
|
|
854
920
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
855
921
|
}
|
|
@@ -1046,6 +1112,9 @@ export async function startWitness(options) {
|
|
|
1046
1112
|
? null
|
|
1047
1113
|
: { options: options.chaos, entries: [] },
|
|
1048
1114
|
twinShapes: options.twinShapes === undefined || options.twinShapes === null ? null : options.twinShapes,
|
|
1115
|
+
responseShape: null,
|
|
1116
|
+
openApi: null,
|
|
1117
|
+
shapeIndex: null,
|
|
1049
1118
|
expectedTests: new Map(),
|
|
1050
1119
|
enumerationDigest: null,
|
|
1051
1120
|
pageObservation: null,
|
|
@@ -1289,6 +1358,7 @@ async function handleHttpObservation(state, res, body) {
|
|
|
1289
1358
|
bodySha256: observedRequest.bodySha256,
|
|
1290
1359
|
bodyBytes: observedRequest.bodyBytes,
|
|
1291
1360
|
sessionId: session.sessionId,
|
|
1361
|
+
...(observedRequest.shape === undefined ? {} : { shape: observedRequest.shape }),
|
|
1292
1362
|
};
|
|
1293
1363
|
const issued = claimIds.map((claimId) => issueRecord(state, claimId, 'http.request', session.testId, payload, 'engine-observed'));
|
|
1294
1364
|
const first = issued[0];
|
|
@@ -1490,23 +1560,25 @@ async function handleBrowserAction(state, res, body) {
|
|
|
1490
1560
|
// INSIDE the engine interval (ticks between open and close), so the
|
|
1491
1561
|
// existing single-use http-observation consume path binds them.
|
|
1492
1562
|
for (const exchange of observation.exchanges) {
|
|
1563
|
+
// Judged with the proxy's plan and judge, so a UI-driven body gets the
|
|
1564
|
+
// same shape verdict as a proxied one (block mode never grades it missing).
|
|
1565
|
+
const shape = state.responseShape === null ? undefined : judgeEngineExchange(state.shapeIndex, exchange);
|
|
1493
1566
|
state.observed.push({
|
|
1494
1567
|
method: exchange.method,
|
|
1495
1568
|
path: exchange.path,
|
|
1569
|
+
fetchDest: exchange.fetchDest ?? null,
|
|
1570
|
+
resourceType: null,
|
|
1496
1571
|
status: exchange.status,
|
|
1497
1572
|
seq: (state.observedSeq += 1),
|
|
1498
1573
|
bodySha256: createHash('sha256').update(exchange.body).digest('hex'),
|
|
1499
1574
|
bodyBytes: exchange.body.length,
|
|
1500
|
-
// Engine-captured exchanges carry no request body (the engine
|
|
1501
|
-
// typed the input; entered fields ride the ui.action record) —
|
|
1502
|
-
// they can never serve an observe finalize, which requires the
|
|
1503
|
-
// proxied request bytes.
|
|
1504
1575
|
requestBody: null,
|
|
1505
1576
|
requestTruncated: false,
|
|
1506
1577
|
requestBytes: 0,
|
|
1507
1578
|
requestContentType: null,
|
|
1508
1579
|
sessionId: session.sessionId,
|
|
1509
1580
|
tick: (state.tick += 1),
|
|
1581
|
+
...(shape === undefined ? {} : { shape }),
|
|
1510
1582
|
});
|
|
1511
1583
|
}
|
|
1512
1584
|
// Suite-submittable intervals/records stay open-submission; the
|
|
@@ -1703,9 +1775,10 @@ async function handleRequest(state, req, res) {
|
|
|
1703
1775
|
}
|
|
1704
1776
|
if (state.engineBrowser === null)
|
|
1705
1777
|
throw new HttpError(503, 'page sweep needs the engine browser');
|
|
1778
|
+
const sweepSessionId = `page-sweep-${state.options.runId}-${body.audience}`;
|
|
1706
1779
|
const sweep = await sweepPageVisits({
|
|
1707
1780
|
browser: state.engineBrowser,
|
|
1708
|
-
sessionId:
|
|
1781
|
+
sessionId: sweepSessionId,
|
|
1709
1782
|
testId: 'page-sweep',
|
|
1710
1783
|
appBase: requireTrustedUiBase(state),
|
|
1711
1784
|
audience: body.audience,
|
|
@@ -1719,6 +1792,23 @@ async function handleRequest(state, req, res) {
|
|
|
1719
1792
|
: {}),
|
|
1720
1793
|
issueRecord: (obligationId, testId, payload) => issueRecord(state, obligationId, 'page.observed', testId, payload, 'engine-observed').recordId,
|
|
1721
1794
|
});
|
|
1795
|
+
// ONE claim-free `http.exchanges` record for the sweep session
|
|
1796
|
+
// (0.14 WP2): the same snapshot discipline as a test session
|
|
1797
|
+
// (dedup, cap, `truncated`). A REJECTED sweep session retains no
|
|
1798
|
+
// evidence — the same non-passing rule `sealPageObservationRecords`
|
|
1799
|
+
// applies to page observations — and a sweep that saw no API
|
|
1800
|
+
// exchange issues nothing.
|
|
1801
|
+
if (sweep.sessionRejected === null) {
|
|
1802
|
+
const { exchanges, truncated } = cappedExchangeSnapshot(sweep.exchanges);
|
|
1803
|
+
if (exchanges.length > 0) {
|
|
1804
|
+
issueRecord(state, sweepSessionId, HTTP_EXCHANGES_KIND, 'page-sweep', {
|
|
1805
|
+
channel: 'swept',
|
|
1806
|
+
sessionId: sweepSessionId,
|
|
1807
|
+
exchanges,
|
|
1808
|
+
...(truncated ? { truncated: true } : {}),
|
|
1809
|
+
}, 'engine-observed');
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1722
1812
|
sendJson(res, 200, { visits: sweep.visits, sessionRejected: sweep.sessionRejected });
|
|
1723
1813
|
return;
|
|
1724
1814
|
}
|
|
@@ -3090,6 +3180,7 @@ async function handleSessionClose(state, res, body) {
|
|
|
3090
3180
|
session.outcome = outcome;
|
|
3091
3181
|
}
|
|
3092
3182
|
sealPageObservationRecords(state, sessionId, session.outcome);
|
|
3183
|
+
issueSessionExchangesRecord(state, session);
|
|
3093
3184
|
// The session's own evidence died with its proxy at release; the
|
|
3094
3185
|
// observe snapshots are dropped HERE, at the moment the outcome is
|
|
3095
3186
|
// finally recorded, so an unreleased session's before-state can
|
|
@@ -3106,6 +3197,7 @@ async function handleSessionClose(state, res, body) {
|
|
|
3106
3197
|
session.sealedTick = (state.tick += 1);
|
|
3107
3198
|
session.outcome = typeof outcome === 'string' ? outcome : null;
|
|
3108
3199
|
sealPageObservationRecords(state, sessionId, session.outcome);
|
|
3200
|
+
issueSessionExchangesRecord(state, session);
|
|
3109
3201
|
state.workerSessions.delete(session.workerIndex);
|
|
3110
3202
|
// Observe snapshots die with the session: finalize runs BEFORE seal
|
|
3111
3203
|
// (the drain finalizes a passed test, then seals), so anything left
|
|
@@ -4547,29 +4639,71 @@ function zeroTrafficCause(state, session) {
|
|
|
4547
4639
|
}
|
|
4548
4640
|
function transportSnapshot(state, session) {
|
|
4549
4641
|
const watermark = state.runContext === null ? 0 : state.observedSeqAtBind;
|
|
4550
|
-
|
|
4642
|
+
// key -> position in `exchanges`, so a repeat can upgrade its shape in place.
|
|
4643
|
+
const seen = new Map();
|
|
4551
4644
|
const exchanges = [];
|
|
4552
4645
|
let truncated = false;
|
|
4553
4646
|
for (const exchange of state.observed) {
|
|
4554
4647
|
if (exchange.sessionId !== session.sessionId || exchange.seq <= watermark)
|
|
4555
4648
|
continue;
|
|
4556
|
-
const key = `${exchange.method} ${exchange.path} ${String(exchange.status)} ${exchange.initiator ?? 'page'}`;
|
|
4557
|
-
|
|
4649
|
+
const key = `${exchange.method} ${exchange.path} ${String(exchange.status)} ${exchange.initiator ?? 'page'} ${exchange.fetchDest ?? ''} ${exchange.resourceType ?? ''}`;
|
|
4650
|
+
const at = seen.get(key);
|
|
4651
|
+
if (at !== undefined) {
|
|
4652
|
+
// A repeat keeps the WORST shape verdict, so a mismatch on any repeat survives the dedup.
|
|
4653
|
+
const kept = exchanges[at];
|
|
4654
|
+
if (kept !== undefined && exchange.shape !== undefined && (kept.shape === undefined || shapeRank(exchange.shape) > shapeRank(kept.shape))) {
|
|
4655
|
+
exchanges[at] = { ...kept, shape: exchange.shape };
|
|
4656
|
+
}
|
|
4558
4657
|
continue;
|
|
4559
|
-
|
|
4658
|
+
}
|
|
4560
4659
|
if (exchanges.length >= OBSERVED_EXCHANGES_CAP) {
|
|
4561
4660
|
truncated = true;
|
|
4562
4661
|
continue;
|
|
4563
4662
|
}
|
|
4663
|
+
seen.set(key, exchanges.length);
|
|
4564
4664
|
exchanges.push({
|
|
4565
4665
|
method: exchange.method,
|
|
4566
4666
|
url: exchange.path,
|
|
4567
4667
|
status: exchange.status,
|
|
4668
|
+
fetchDest: exchange.fetchDest,
|
|
4568
4669
|
...(exchange.initiator === 'test-code' ? { initiator: exchange.initiator } : {}),
|
|
4670
|
+
resourceType: exchange.resourceType,
|
|
4671
|
+
...(exchange.resourceTypeConflict ? { resourceTypeConflict: true } : {}),
|
|
4672
|
+
...(exchange.shape === undefined ? {} : { shape: exchange.shape }),
|
|
4569
4673
|
});
|
|
4570
4674
|
}
|
|
4571
4675
|
return { exchanges, truncated };
|
|
4572
4676
|
}
|
|
4677
|
+
/**
|
|
4678
|
+
* Applies the SAME snapshot discipline `transportSnapshot` enforces —
|
|
4679
|
+
* dedup by `(method, url, status)`, cap at {@link OBSERVED_EXCHANGES_CAP}
|
|
4680
|
+
* with `truncated: true` past the cap — to an already-captured exchange
|
|
4681
|
+
* list (the page sweep's visits).
|
|
4682
|
+
*/
|
|
4683
|
+
function cappedExchangeSnapshot(exchanges) {
|
|
4684
|
+
const seen = Object.create(null);
|
|
4685
|
+
const kept = [];
|
|
4686
|
+
let truncated = false;
|
|
4687
|
+
for (const exchange of exchanges) {
|
|
4688
|
+
const key = `${exchange.method} ${exchange.url} ${String(exchange.status)} ${exchange.fetchDest ?? ''} ${exchange.resourceType ?? ''}`;
|
|
4689
|
+
if (key in seen)
|
|
4690
|
+
continue;
|
|
4691
|
+
seen[key] = true;
|
|
4692
|
+
if (kept.length >= OBSERVED_EXCHANGES_CAP) {
|
|
4693
|
+
truncated = true;
|
|
4694
|
+
continue;
|
|
4695
|
+
}
|
|
4696
|
+
kept.push({
|
|
4697
|
+
method: exchange.method,
|
|
4698
|
+
url: exchange.url,
|
|
4699
|
+
status: exchange.status,
|
|
4700
|
+
fetchDest: exchange.fetchDest ?? null,
|
|
4701
|
+
resourceType: exchange.resourceType ?? null,
|
|
4702
|
+
...(exchange.resourceTypeConflict ? { resourceTypeConflict: true } : {}),
|
|
4703
|
+
});
|
|
4704
|
+
}
|
|
4705
|
+
return { exchanges: kept, truncated };
|
|
4706
|
+
}
|
|
4573
4707
|
/**
|
|
4574
4708
|
* Resolves one observe-declared claim (record or typed note, never
|
|
4575
4709
|
* throws). `persistence:*` claims resolve against the session's own
|
|
@@ -5343,6 +5477,12 @@ async function handleRunContext(state, res, verifier, body) {
|
|
|
5343
5477
|
}
|
|
5344
5478
|
state.runContext = { runId, invocationId, inputDigest };
|
|
5345
5479
|
state.observedSeqAtBind = state.observedSeq;
|
|
5480
|
+
if (boundOptions.responseShape !== undefined && state.responseShape === null) {
|
|
5481
|
+
state.responseShape = boundOptions.responseShape;
|
|
5482
|
+
state.openApi = await fetchOpenApiAtBind(state.options.targetBaseUrl ?? null, boundOptions.responseShape.openapiPath, state.options.requestTimeoutMs);
|
|
5483
|
+
state.shapeIndex = state.openApi.status === 'fetched' ? buildResponseShapeIndex(state.openApi.document) : null;
|
|
5484
|
+
issueRecord(state, state.options.runId, HTTP_OPENAPI_KIND, 'run', openApiRecordPayload(state.openApi), 'engine-observed');
|
|
5485
|
+
}
|
|
5346
5486
|
sendJson(res, 200, { bound: true, runId, invocationId, inputDigest, ...appliedEcho(state) });
|
|
5347
5487
|
}
|
|
5348
5488
|
/**
|
|
@@ -5360,6 +5500,7 @@ function appliedOptionsOf(state) {
|
|
|
5360
5500
|
return {
|
|
5361
5501
|
chaos: state.chaos === null ? null : state.chaos.options,
|
|
5362
5502
|
twinShapes: state.twinShapes,
|
|
5503
|
+
responseShape: state.responseShape,
|
|
5363
5504
|
};
|
|
5364
5505
|
}
|
|
5365
5506
|
/**
|
|
@@ -5375,7 +5516,9 @@ function appliedOptionsOf(state) {
|
|
|
5375
5516
|
*/
|
|
5376
5517
|
function appliedEcho(state) {
|
|
5377
5518
|
const applied = appliedOptionsOf(state);
|
|
5378
|
-
return applied.chaos === null && applied.twinShapes === null
|
|
5519
|
+
return applied.chaos === null && applied.twinShapes === null && applied.responseShape === null
|
|
5520
|
+
? {}
|
|
5521
|
+
: { applied };
|
|
5379
5522
|
}
|
|
5380
5523
|
/**
|
|
5381
5524
|
* Serves the authenticated live attestation (pin #7, GF-23, plan §11.3):
|