@nextera.one/axis-server-sdk 2.1.0 → 2.1.1
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/codec/axis1.encode.d.mts +10 -0
- package/dist/codec/axis1.encode.d.ts +10 -0
- package/dist/codec/axis1.encode.js +65 -0
- package/dist/codec/axis1.encode.js.map +1 -0
- package/dist/codec/axis1.encode.mjs +41 -0
- package/dist/codec/axis1.encode.mjs.map +1 -0
- package/dist/codec/axis1.signing.d.mts +8 -0
- package/dist/codec/axis1.signing.d.ts +8 -0
- package/dist/codec/axis1.signing.js +61 -0
- package/dist/codec/axis1.signing.js.map +1 -0
- package/dist/codec/axis1.signing.mjs +37 -0
- package/dist/codec/axis1.signing.mjs.map +1 -0
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +6 -244
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +8 -238
- package/dist/core/index.mjs.map +1 -1
- package/dist/index-VxXqZPuH.d.mts +51 -0
- package/dist/index-VxXqZPuH.d.ts +51 -0
- package/dist/index.d.mts +1340 -480
- package/dist/index.d.ts +1340 -480
- package/dist/index.js +2952 -372
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2958 -364
- package/dist/index.mjs.map +1 -1
- package/dist/types/frame.d.mts +11 -0
- package/dist/types/frame.d.ts +11 -0
- package/dist/types/frame.js +78 -0
- package/dist/types/frame.js.map +1 -0
- package/dist/types/frame.mjs +54 -0
- package/dist/types/frame.mjs.map +1 -0
- package/package.json +2 -1
- package/dist/index-1uEwnW-w.d.mts +0 -122
- package/dist/index-1uEwnW-w.d.ts +0 -122
package/dist/index.mjs
CHANGED
|
@@ -340,76 +340,90 @@ var init_sensor_decorator = __esm({
|
|
|
340
340
|
});
|
|
341
341
|
|
|
342
342
|
// src/decorators/tlv-field.decorator.ts
|
|
343
|
-
var
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
existing
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return (target, propertyKey) => {
|
|
368
|
-
const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
369
|
-
const prop = String(propertyKey);
|
|
370
|
-
let entry = existing.find((e) => e.property === prop);
|
|
371
|
-
if (!entry) {
|
|
372
|
-
entry = { property: prop, tag: 0, validators: [] };
|
|
373
|
-
existing.push(entry);
|
|
343
|
+
var require_tlv_field_decorator = __commonJS({
|
|
344
|
+
"src/decorators/tlv-field.decorator.ts"(exports) {
|
|
345
|
+
"use strict";
|
|
346
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
347
|
+
exports.TLV_VALIDATORS_KEY = exports.TLV_FIELDS_KEY = void 0;
|
|
348
|
+
exports.TlvField = TlvField2;
|
|
349
|
+
exports.TlvValidate = TlvValidate2;
|
|
350
|
+
exports.TlvUtf8Pattern = TlvUtf8Pattern2;
|
|
351
|
+
exports.TlvMinLen = TlvMinLen2;
|
|
352
|
+
exports.TlvEnum = TlvEnum2;
|
|
353
|
+
exports.TlvRange = TlvRange2;
|
|
354
|
+
__require("reflect-metadata");
|
|
355
|
+
exports.TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
356
|
+
exports.TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
357
|
+
var textDecoder = new TextDecoder();
|
|
358
|
+
function assertUniqueFieldMetadata(existing, property, tag) {
|
|
359
|
+
const duplicateProperty = existing.find((item) => item.property === property);
|
|
360
|
+
if (duplicateProperty) {
|
|
361
|
+
throw new Error(`Duplicate @TlvField for property ${property}`);
|
|
362
|
+
}
|
|
363
|
+
const duplicateTag = existing.find((item) => item.tag === tag);
|
|
364
|
+
if (duplicateTag) {
|
|
365
|
+
throw new Error(`Duplicate @TlvField tag ${tag} for ${property}; already used by ${duplicateTag.property}`);
|
|
366
|
+
}
|
|
374
367
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return
|
|
368
|
+
function TlvField2(tag, options) {
|
|
369
|
+
return (target, propertyKey) => {
|
|
370
|
+
const existing = Reflect.getOwnMetadata(exports.TLV_FIELDS_KEY, target.constructor) || [];
|
|
371
|
+
const property = String(propertyKey);
|
|
372
|
+
assertUniqueFieldMetadata(existing, property, tag);
|
|
373
|
+
existing.push({
|
|
374
|
+
property,
|
|
375
|
+
tag,
|
|
376
|
+
options
|
|
377
|
+
});
|
|
378
|
+
Reflect.defineMetadata(exports.TLV_FIELDS_KEY, existing, target.constructor);
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function TlvValidate2(validator) {
|
|
382
|
+
return (target, propertyKey) => {
|
|
383
|
+
const existing = Reflect.getOwnMetadata(exports.TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
384
|
+
const prop = String(propertyKey);
|
|
385
|
+
let entry = existing.find((e) => e.property === prop);
|
|
386
|
+
if (!entry) {
|
|
387
|
+
entry = { property: prop, tag: 0, validators: [] };
|
|
388
|
+
existing.push(entry);
|
|
389
|
+
}
|
|
390
|
+
entry.validators.push(validator);
|
|
391
|
+
Reflect.defineMetadata(exports.TLV_VALIDATORS_KEY, existing, target.constructor);
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function TlvUtf8Pattern2(pattern, message) {
|
|
395
|
+
const matcher = new RegExp(pattern.source, pattern.flags);
|
|
396
|
+
return TlvValidate2((val, prop) => {
|
|
397
|
+
const str = textDecoder.decode(val);
|
|
398
|
+
matcher.lastIndex = 0;
|
|
399
|
+
return matcher.test(str) ? null : message || `${prop}: failed pattern check`;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
function TlvMinLen2(min, message) {
|
|
403
|
+
return TlvValidate2((val, prop) => {
|
|
404
|
+
return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
function TlvEnum2(allowed, message) {
|
|
408
|
+
const set = new Set(allowed);
|
|
409
|
+
return TlvValidate2((val, prop) => {
|
|
410
|
+
const str = textDecoder.decode(val);
|
|
411
|
+
return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function TlvRange2(min, max, message) {
|
|
415
|
+
return TlvValidate2((val, prop) => {
|
|
416
|
+
if (val.length !== 8)
|
|
417
|
+
return `${prop}: u64 must be 8 bytes`;
|
|
418
|
+
let n = 0n;
|
|
419
|
+
for (const b of val)
|
|
420
|
+
n = n << 8n | BigInt(b);
|
|
421
|
+
if (n < min || n > max) {
|
|
422
|
+
return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
|
|
423
|
+
}
|
|
424
|
+
return null;
|
|
425
|
+
});
|
|
404
426
|
}
|
|
405
|
-
return null;
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
var TLV_FIELDS_KEY, TLV_VALIDATORS_KEY;
|
|
409
|
-
var init_tlv_field_decorator = __esm({
|
|
410
|
-
"src/decorators/tlv-field.decorator.ts"() {
|
|
411
|
-
TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
412
|
-
TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
413
427
|
}
|
|
414
428
|
});
|
|
415
429
|
|
|
@@ -444,7 +458,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
444
458
|
exports.extractDtoSchema = extractDtoSchema2;
|
|
445
459
|
exports.buildDtoDecoder = buildDtoDecoder2;
|
|
446
460
|
__require("reflect-metadata");
|
|
447
|
-
var tlv_field_decorator_1 = (
|
|
461
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
448
462
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
449
463
|
function extractDtoSchema2(dto) {
|
|
450
464
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
@@ -553,7 +567,7 @@ var require_axis_id_dto = __commonJS({
|
|
|
553
567
|
};
|
|
554
568
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
555
569
|
exports.AxisIdDto = void 0;
|
|
556
|
-
var tlv_field_decorator_1 = (
|
|
570
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
557
571
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
558
572
|
var AxisIdDto2 = class extends axis_tlv_dto_1.AxisTlvDto {
|
|
559
573
|
};
|
|
@@ -571,25 +585,26 @@ import "reflect-metadata";
|
|
|
571
585
|
function AxisPartialType(BaseDto) {
|
|
572
586
|
class PartialDto extends BaseDto {
|
|
573
587
|
}
|
|
574
|
-
const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
|
|
588
|
+
const fields = Reflect.getOwnMetadata(import_tlv_field.TLV_FIELDS_KEY, BaseDto) || [];
|
|
575
589
|
const partialFields = fields.map((f) => ({
|
|
576
590
|
property: f.property,
|
|
577
591
|
tag: f.tag,
|
|
578
592
|
options: { ...f.options, required: false }
|
|
579
593
|
}));
|
|
580
|
-
Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
581
|
-
const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
594
|
+
Reflect.defineMetadata(import_tlv_field.TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
595
|
+
const validators = Reflect.getOwnMetadata(import_tlv_field.TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
582
596
|
if (validators.length > 0) {
|
|
583
|
-
Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
597
|
+
Reflect.defineMetadata(import_tlv_field.TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
584
598
|
}
|
|
585
599
|
Object.defineProperty(PartialDto, "name", {
|
|
586
600
|
value: `Partial${BaseDto.name}`
|
|
587
601
|
});
|
|
588
602
|
return PartialDto;
|
|
589
603
|
}
|
|
604
|
+
var import_tlv_field;
|
|
590
605
|
var init_axis_partial_type = __esm({
|
|
591
606
|
"src/base/axis-partial-type.ts"() {
|
|
592
|
-
|
|
607
|
+
import_tlv_field = __toESM(require_tlv_field_decorator());
|
|
593
608
|
}
|
|
594
609
|
});
|
|
595
610
|
|
|
@@ -608,7 +623,7 @@ var require_axis_response_dto = __commonJS({
|
|
|
608
623
|
};
|
|
609
624
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
610
625
|
exports.AxisResponseDto = exports.RESPONSE_TAG_UPDATED_BY = exports.RESPONSE_TAG_CREATED_BY = exports.RESPONSE_TAG_UPDATED_AT = exports.RESPONSE_TAG_CREATED_AT = exports.RESPONSE_TAG_ID = void 0;
|
|
611
|
-
var tlv_field_decorator_1 = (
|
|
626
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
612
627
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
613
628
|
exports.RESPONSE_TAG_ID = 1;
|
|
614
629
|
exports.RESPONSE_TAG_CREATED_AT = 2;
|
|
@@ -3322,6 +3337,213 @@ var init_observation_hash = __esm({
|
|
|
3322
3337
|
}
|
|
3323
3338
|
});
|
|
3324
3339
|
|
|
3340
|
+
// src/engine/observation/truth-scoring.ts
|
|
3341
|
+
function scoreTruth(obs, expected) {
|
|
3342
|
+
const anomalies = [];
|
|
3343
|
+
let passedChecks = 0;
|
|
3344
|
+
let totalChecks = 0;
|
|
3345
|
+
totalChecks++;
|
|
3346
|
+
if (obs.endMs && obs.decision) {
|
|
3347
|
+
passedChecks++;
|
|
3348
|
+
} else {
|
|
3349
|
+
anomalies.push({
|
|
3350
|
+
code: "OBS_NOT_FINALIZED",
|
|
3351
|
+
level: "critical",
|
|
3352
|
+
message: "Observation was not finalized"
|
|
3353
|
+
});
|
|
3354
|
+
}
|
|
3355
|
+
totalChecks++;
|
|
3356
|
+
if (obs.stages.length > 0) {
|
|
3357
|
+
passedChecks++;
|
|
3358
|
+
} else {
|
|
3359
|
+
anomalies.push({
|
|
3360
|
+
code: "OBS_NO_STAGES",
|
|
3361
|
+
level: "warning",
|
|
3362
|
+
message: "Observation has no execution stages"
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
totalChecks++;
|
|
3366
|
+
const failedStages = obs.stages.filter((s) => s.status === "fail");
|
|
3367
|
+
if (failedStages.length === 0 || obs.decision === "DENY") {
|
|
3368
|
+
passedChecks++;
|
|
3369
|
+
} else {
|
|
3370
|
+
for (const stage of failedStages) {
|
|
3371
|
+
anomalies.push({
|
|
3372
|
+
code: "STAGE_FAILED",
|
|
3373
|
+
level: "warning",
|
|
3374
|
+
message: `Stage '${stage.name}' failed: ${stage.reason ?? "unknown"}`,
|
|
3375
|
+
field: `stages.${stage.name}`
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
totalChecks++;
|
|
3380
|
+
const invalidSensors = obs.sensors.filter((s) => s.durationMs < 0);
|
|
3381
|
+
if (invalidSensors.length === 0) {
|
|
3382
|
+
passedChecks++;
|
|
3383
|
+
} else {
|
|
3384
|
+
anomalies.push({
|
|
3385
|
+
code: "SENSOR_INVALID_TIMING",
|
|
3386
|
+
level: "warning",
|
|
3387
|
+
message: `${invalidSensors.length} sensor(s) have negative duration`
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3390
|
+
totalChecks++;
|
|
3391
|
+
if (obs.durationMs !== void 0 && obs.durationMs >= 0 && obs.durationMs < 3e5) {
|
|
3392
|
+
passedChecks++;
|
|
3393
|
+
} else {
|
|
3394
|
+
anomalies.push({
|
|
3395
|
+
code: "OBS_DURATION_ANOMALY",
|
|
3396
|
+
level: "warning",
|
|
3397
|
+
message: `Observation duration ${obs.durationMs}ms is suspicious`,
|
|
3398
|
+
actual: obs.durationMs
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
if (expected) {
|
|
3402
|
+
if (expected.decision !== void 0) {
|
|
3403
|
+
totalChecks++;
|
|
3404
|
+
if (obs.decision === expected.decision) {
|
|
3405
|
+
passedChecks++;
|
|
3406
|
+
} else {
|
|
3407
|
+
anomalies.push({
|
|
3408
|
+
code: "DECISION_MISMATCH",
|
|
3409
|
+
level: "critical",
|
|
3410
|
+
message: `Expected decision '${expected.decision}', got '${obs.decision}'`,
|
|
3411
|
+
field: "decision",
|
|
3412
|
+
expected: expected.decision,
|
|
3413
|
+
actual: obs.decision
|
|
3414
|
+
});
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
if (expected.statusCode !== void 0) {
|
|
3418
|
+
totalChecks++;
|
|
3419
|
+
if (obs.statusCode === expected.statusCode) {
|
|
3420
|
+
passedChecks++;
|
|
3421
|
+
} else {
|
|
3422
|
+
anomalies.push({
|
|
3423
|
+
code: "STATUS_MISMATCH",
|
|
3424
|
+
level: "warning",
|
|
3425
|
+
message: `Expected status ${expected.statusCode}, got ${obs.statusCode}`,
|
|
3426
|
+
field: "statusCode",
|
|
3427
|
+
expected: expected.statusCode,
|
|
3428
|
+
actual: obs.statusCode
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
if (expected.effect !== void 0) {
|
|
3433
|
+
totalChecks++;
|
|
3434
|
+
if (obs.resultCode === expected.effect || obs.facts?.effect === expected.effect) {
|
|
3435
|
+
passedChecks++;
|
|
3436
|
+
} else {
|
|
3437
|
+
anomalies.push({
|
|
3438
|
+
code: "EFFECT_MISMATCH",
|
|
3439
|
+
level: "warning",
|
|
3440
|
+
message: `Expected effect '${expected.effect}', got '${obs.resultCode}'`,
|
|
3441
|
+
field: "resultCode",
|
|
3442
|
+
expected: expected.effect,
|
|
3443
|
+
actual: obs.resultCode
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
if (expected.maxDurationMs !== void 0) {
|
|
3448
|
+
totalChecks++;
|
|
3449
|
+
if (obs.durationMs !== void 0 && obs.durationMs <= expected.maxDurationMs) {
|
|
3450
|
+
passedChecks++;
|
|
3451
|
+
} else {
|
|
3452
|
+
anomalies.push({
|
|
3453
|
+
code: "DURATION_EXCEEDED",
|
|
3454
|
+
level: "warning",
|
|
3455
|
+
message: `Execution took ${obs.durationMs}ms, max allowed ${expected.maxDurationMs}ms`,
|
|
3456
|
+
field: "durationMs",
|
|
3457
|
+
expected: expected.maxDurationMs,
|
|
3458
|
+
actual: obs.durationMs
|
|
3459
|
+
});
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
if (expected.minSensorsPassed !== void 0) {
|
|
3463
|
+
totalChecks++;
|
|
3464
|
+
const passed = obs.sensors.filter((s) => s.allowed).length;
|
|
3465
|
+
if (passed >= expected.minSensorsPassed) {
|
|
3466
|
+
passedChecks++;
|
|
3467
|
+
} else {
|
|
3468
|
+
anomalies.push({
|
|
3469
|
+
code: "INSUFFICIENT_SENSORS",
|
|
3470
|
+
level: "warning",
|
|
3471
|
+
message: `Only ${passed} sensors passed, minimum required ${expected.minSensorsPassed}`,
|
|
3472
|
+
field: "sensors",
|
|
3473
|
+
expected: expected.minSensorsPassed,
|
|
3474
|
+
actual: passed
|
|
3475
|
+
});
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
if (expected.assertions) {
|
|
3479
|
+
for (const [key, expectedValue] of Object.entries(expected.assertions)) {
|
|
3480
|
+
totalChecks++;
|
|
3481
|
+
const actualValue = obs.facts[key];
|
|
3482
|
+
if (deepEqual(actualValue, expectedValue)) {
|
|
3483
|
+
passedChecks++;
|
|
3484
|
+
} else {
|
|
3485
|
+
anomalies.push({
|
|
3486
|
+
code: "ASSERTION_FAILED",
|
|
3487
|
+
level: "warning",
|
|
3488
|
+
message: `Assertion failed for facts.${key}`,
|
|
3489
|
+
field: `facts.${key}`,
|
|
3490
|
+
expected: expectedValue,
|
|
3491
|
+
actual: actualValue
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
const confidence = totalChecks > 0 ? passedChecks / totalChecks : 0;
|
|
3498
|
+
const hasCritical = anomalies.some((a) => a.level === "critical");
|
|
3499
|
+
const status = computeTruthStatus(confidence, hasCritical, anomalies.length);
|
|
3500
|
+
const isDeed = status === "confirmed" || status === "partial" && !hasCritical;
|
|
3501
|
+
return {
|
|
3502
|
+
status,
|
|
3503
|
+
confidence,
|
|
3504
|
+
anomalies,
|
|
3505
|
+
passedChecks,
|
|
3506
|
+
totalChecks,
|
|
3507
|
+
verifiedAt: Date.now(),
|
|
3508
|
+
isDeed
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
function computeTruthStatus(confidence, hasCritical, anomalyCount) {
|
|
3512
|
+
if (hasCritical) return "failed";
|
|
3513
|
+
if (confidence === 1) return "confirmed";
|
|
3514
|
+
if (confidence >= 0.8) return "partial";
|
|
3515
|
+
if (confidence >= 0.5) return "uncertain";
|
|
3516
|
+
return "disputed";
|
|
3517
|
+
}
|
|
3518
|
+
function verifyObservation(obs, expected) {
|
|
3519
|
+
const verdict = scoreTruth(obs, expected);
|
|
3520
|
+
return { observation: obs, verdict };
|
|
3521
|
+
}
|
|
3522
|
+
function deepEqual(a, b) {
|
|
3523
|
+
if (a === b) return true;
|
|
3524
|
+
if (a === null || b === null) return false;
|
|
3525
|
+
if (typeof a !== typeof b) return false;
|
|
3526
|
+
if (typeof a !== "object") return String(a) === String(b);
|
|
3527
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
3528
|
+
if (a.length !== b.length) return false;
|
|
3529
|
+
return a.every((v, i) => deepEqual(v, b[i]));
|
|
3530
|
+
}
|
|
3531
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
3532
|
+
const aKeys = Object.keys(a);
|
|
3533
|
+
const bKeys = Object.keys(b);
|
|
3534
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
3535
|
+
return aKeys.every(
|
|
3536
|
+
(key) => deepEqual(
|
|
3537
|
+
a[key],
|
|
3538
|
+
b[key]
|
|
3539
|
+
)
|
|
3540
|
+
);
|
|
3541
|
+
}
|
|
3542
|
+
var init_truth_scoring = __esm({
|
|
3543
|
+
"src/engine/observation/truth-scoring.ts"() {
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
|
|
3325
3547
|
// src/engine/observation/response-observer.ts
|
|
3326
3548
|
function verifyResponse(ctx, response) {
|
|
3327
3549
|
if (!response.effect || typeof response.effect !== "string") {
|
|
@@ -3396,92 +3618,14 @@ __export(axis_bin_exports, {
|
|
|
3396
3618
|
getSignTarget: () => getSignTarget
|
|
3397
3619
|
});
|
|
3398
3620
|
import * as z from "zod";
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
}))
|
|
3405
|
-
);
|
|
3406
|
-
if (hdrBytes.length > MAX_HDR_LEN) throw new Error("Header too large");
|
|
3407
|
-
if (frame.body.length > MAX_BODY_LEN) throw new Error("Body too large");
|
|
3408
|
-
if (frame.sig.length > MAX_SIG_LEN) throw new Error("Signature too large");
|
|
3409
|
-
const hdrLenBytes = encodeVarint(hdrBytes.length);
|
|
3410
|
-
const bodyLenBytes = encodeVarint(frame.body.length);
|
|
3411
|
-
const sigLenBytes = encodeVarint(frame.sig.length);
|
|
3412
|
-
const totalLen = 5 + // Magic (AXIS1)
|
|
3413
|
-
1 + // Version
|
|
3414
|
-
1 + // Flags
|
|
3415
|
-
hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
|
|
3416
|
-
if (totalLen > MAX_FRAME_LEN) throw new Error("Total frame too large");
|
|
3417
|
-
const buf = new Uint8Array(totalLen);
|
|
3418
|
-
let offset = 0;
|
|
3419
|
-
buf.set(AXIS_MAGIC, offset);
|
|
3420
|
-
offset += 5;
|
|
3421
|
-
buf[offset++] = AXIS_VERSION;
|
|
3422
|
-
buf[offset++] = frame.flags;
|
|
3423
|
-
buf.set(hdrLenBytes, offset);
|
|
3424
|
-
offset += hdrLenBytes.length;
|
|
3425
|
-
buf.set(bodyLenBytes, offset);
|
|
3426
|
-
offset += bodyLenBytes.length;
|
|
3427
|
-
buf.set(sigLenBytes, offset);
|
|
3428
|
-
offset += sigLenBytes.length;
|
|
3429
|
-
buf.set(hdrBytes, offset);
|
|
3430
|
-
offset += hdrBytes.length;
|
|
3431
|
-
buf.set(frame.body, offset);
|
|
3432
|
-
offset += frame.body.length;
|
|
3433
|
-
buf.set(frame.sig, offset);
|
|
3434
|
-
offset += frame.sig.length;
|
|
3435
|
-
return buf;
|
|
3436
|
-
}
|
|
3437
|
-
function decodeFrame(buf) {
|
|
3438
|
-
let offset = 0;
|
|
3439
|
-
if (offset + 5 > buf.length) throw new Error("Packet too short");
|
|
3440
|
-
for (let i = 0; i < 5; i++) {
|
|
3441
|
-
if (buf[offset + i] !== AXIS_MAGIC[i]) throw new Error("Invalid Magic");
|
|
3442
|
-
}
|
|
3443
|
-
offset += 5;
|
|
3444
|
-
const ver = buf[offset++];
|
|
3445
|
-
if (ver !== AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
|
|
3446
|
-
const flags = buf[offset++];
|
|
3447
|
-
const { value: hdrLen, length: hlLen } = decodeVarint(buf, offset);
|
|
3448
|
-
offset += hlLen;
|
|
3449
|
-
if (hdrLen > MAX_HDR_LEN) throw new Error("Header limit exceeded");
|
|
3450
|
-
const { value: bodyLen, length: blLen } = decodeVarint(buf, offset);
|
|
3451
|
-
offset += blLen;
|
|
3452
|
-
if (bodyLen > MAX_BODY_LEN) throw new Error("Body limit exceeded");
|
|
3453
|
-
const { value: sigLen, length: slLen } = decodeVarint(buf, offset);
|
|
3454
|
-
offset += slLen;
|
|
3455
|
-
if (sigLen > MAX_SIG_LEN) throw new Error("Signature limit exceeded");
|
|
3456
|
-
if (offset + hdrLen + bodyLen + sigLen > buf.length) {
|
|
3457
|
-
throw new Error("Frame truncated");
|
|
3458
|
-
}
|
|
3459
|
-
const hdrBytes = buf.slice(offset, offset + hdrLen);
|
|
3460
|
-
offset += hdrLen;
|
|
3461
|
-
const bodyBytes = buf.slice(offset, offset + bodyLen);
|
|
3462
|
-
offset += bodyLen;
|
|
3463
|
-
const sigBytes = buf.slice(offset, offset + sigLen);
|
|
3464
|
-
offset += sigLen;
|
|
3465
|
-
const headers = decodeTLVs(hdrBytes);
|
|
3466
|
-
return {
|
|
3467
|
-
flags,
|
|
3468
|
-
headers,
|
|
3469
|
-
body: bodyBytes,
|
|
3470
|
-
sig: sigBytes
|
|
3471
|
-
};
|
|
3472
|
-
}
|
|
3473
|
-
function getSignTarget(frame) {
|
|
3474
|
-
return encodeFrame({
|
|
3475
|
-
...frame,
|
|
3476
|
-
sig: new Uint8Array(0)
|
|
3477
|
-
});
|
|
3478
|
-
}
|
|
3621
|
+
import {
|
|
3622
|
+
decodeFrame,
|
|
3623
|
+
encodeFrame,
|
|
3624
|
+
getSignTarget
|
|
3625
|
+
} from "@nextera.one/axis-protocol";
|
|
3479
3626
|
var AxisFrameZ;
|
|
3480
3627
|
var init_axis_bin = __esm({
|
|
3481
3628
|
"src/core/axis-bin.ts"() {
|
|
3482
|
-
init_constants();
|
|
3483
|
-
init_tlv();
|
|
3484
|
-
init_varint();
|
|
3485
3629
|
AxisFrameZ = z.object({
|
|
3486
3630
|
/** Flag bits for protocol control (e.g., encryption, compression) */
|
|
3487
3631
|
flags: z.number().int().nonnegative(),
|
|
@@ -3501,12 +3645,7 @@ var init_axis_bin = __esm({
|
|
|
3501
3645
|
// src/core/signature.ts
|
|
3502
3646
|
import * as crypto2 from "crypto";
|
|
3503
3647
|
function computeSignaturePayload(frame) {
|
|
3504
|
-
|
|
3505
|
-
...frame,
|
|
3506
|
-
sig: new Uint8Array(0)
|
|
3507
|
-
};
|
|
3508
|
-
const encoded = encodeFrame(frameWithoutSig);
|
|
3509
|
-
return Buffer.from(encoded);
|
|
3648
|
+
return Buffer.from(getSignTarget(frame));
|
|
3510
3649
|
}
|
|
3511
3650
|
function signFrame(frame, privateKey) {
|
|
3512
3651
|
const payload = computeSignaturePayload(frame);
|
|
@@ -4387,11 +4526,12 @@ var init_tlv_encode = __esm({
|
|
|
4387
4526
|
});
|
|
4388
4527
|
|
|
4389
4528
|
// src/codec/axis1.encode.ts
|
|
4529
|
+
import { AXIS_MAGIC as AXIS_MAGIC2, AXIS_VERSION as AXIS_VERSION2 } from "@nextera.one/axis-protocol";
|
|
4390
4530
|
function encodeAxis1Frame(f) {
|
|
4391
4531
|
if (!Buffer.isBuffer(f.hdr) || !Buffer.isBuffer(f.body) || !Buffer.isBuffer(f.sig)) {
|
|
4392
4532
|
throw new Error("AXIS1_BAD_BUFFERS");
|
|
4393
4533
|
}
|
|
4394
|
-
if (f.ver !==
|
|
4534
|
+
if (f.ver !== AXIS_VERSION2) throw new Error("AXIS1_BAD_VER");
|
|
4395
4535
|
const hdrLen = encVarint(BigInt(f.hdr.length));
|
|
4396
4536
|
const bodyLen = encVarint(BigInt(f.body.length));
|
|
4397
4537
|
const sigLen = encVarint(BigInt(f.sig.length));
|
|
@@ -4411,13 +4551,14 @@ var MAGIC;
|
|
|
4411
4551
|
var init_axis1_encode = __esm({
|
|
4412
4552
|
"src/codec/axis1.encode.ts"() {
|
|
4413
4553
|
init_tlv_encode();
|
|
4414
|
-
MAGIC = Buffer.from(
|
|
4554
|
+
MAGIC = Buffer.from(AXIS_MAGIC2);
|
|
4415
4555
|
}
|
|
4416
4556
|
});
|
|
4417
4557
|
|
|
4418
4558
|
// src/codec/axis1.signing.ts
|
|
4559
|
+
import { AXIS_MAGIC as AXIS_MAGIC3, AXIS_VERSION as AXIS_VERSION3 } from "@nextera.one/axis-protocol";
|
|
4419
4560
|
function axis1SigningBytes(params) {
|
|
4420
|
-
if (params.ver !==
|
|
4561
|
+
if (params.ver !== AXIS_VERSION3) throw new Error("AXIS1_BAD_VER");
|
|
4421
4562
|
const hdrLen = encVarint(BigInt(params.hdr.length));
|
|
4422
4563
|
const bodyLen = encVarint(BigInt(params.body.length));
|
|
4423
4564
|
const sigLenZero = encVarint(0n);
|
|
@@ -4436,7 +4577,7 @@ var MAGIC2;
|
|
|
4436
4577
|
var init_axis1_signing = __esm({
|
|
4437
4578
|
"src/codec/axis1.signing.ts"() {
|
|
4438
4579
|
init_tlv_encode();
|
|
4439
|
-
MAGIC2 = Buffer.from(
|
|
4580
|
+
MAGIC2 = Buffer.from(AXIS_MAGIC3);
|
|
4440
4581
|
}
|
|
4441
4582
|
});
|
|
4442
4583
|
|
|
@@ -4736,6 +4877,7 @@ var init_tlv2 = __esm({
|
|
|
4736
4877
|
});
|
|
4737
4878
|
|
|
4738
4879
|
// src/types/frame.ts
|
|
4880
|
+
import { AXIS_MAGIC as AXIS_MAGIC4 } from "@nextera.one/axis-protocol";
|
|
4739
4881
|
function decodeAxis1Frame(buf) {
|
|
4740
4882
|
let off = 0;
|
|
4741
4883
|
const magic = buf.subarray(off, off + 5);
|
|
@@ -4770,7 +4912,7 @@ var MAGIC3;
|
|
|
4770
4912
|
var init_frame = __esm({
|
|
4771
4913
|
"src/types/frame.ts"() {
|
|
4772
4914
|
init_tlv2();
|
|
4773
|
-
MAGIC3 = Buffer.from(
|
|
4915
|
+
MAGIC3 = Buffer.from(AXIS_MAGIC4);
|
|
4774
4916
|
}
|
|
4775
4917
|
});
|
|
4776
4918
|
|
|
@@ -4893,7 +5035,52 @@ var init_capabilities = __esm({
|
|
|
4893
5035
|
}
|
|
4894
5036
|
});
|
|
4895
5037
|
|
|
5038
|
+
// src/law/law.types.ts
|
|
5039
|
+
function buildAxisLawEvaluationContext(input) {
|
|
5040
|
+
const metadata = input.metadata ?? {};
|
|
5041
|
+
const packet = input.packet;
|
|
5042
|
+
const packetBody = input.frameBody ?? packet?.body ?? packet?.args ?? void 0;
|
|
5043
|
+
const capsuleId = metadata.capsule_id ?? metadata.capsuleId ?? packet?.capsuleId ?? input.clientId;
|
|
5044
|
+
const audience = input.aud ?? metadata.audience ?? packet?.aud;
|
|
5045
|
+
const tps = metadata.tps ?? packet?.tps ?? packet?.tickTps;
|
|
5046
|
+
return {
|
|
5047
|
+
actorId: input.actorId,
|
|
5048
|
+
intent: input.intent,
|
|
5049
|
+
audience,
|
|
5050
|
+
tps,
|
|
5051
|
+
country: input.country,
|
|
5052
|
+
ip: input.ip,
|
|
5053
|
+
path: input.path,
|
|
5054
|
+
clientId: input.clientId,
|
|
5055
|
+
deviceId: input.deviceId,
|
|
5056
|
+
sessionId: input.sessionId,
|
|
5057
|
+
capsuleId,
|
|
5058
|
+
metadata,
|
|
5059
|
+
packet,
|
|
5060
|
+
frameBody: packetBody
|
|
5061
|
+
};
|
|
5062
|
+
}
|
|
5063
|
+
var init_law_types = __esm({
|
|
5064
|
+
"src/law/law.types.ts"() {
|
|
5065
|
+
}
|
|
5066
|
+
});
|
|
5067
|
+
|
|
5068
|
+
// src/law/index.ts
|
|
5069
|
+
var law_exports = {};
|
|
5070
|
+
__export(law_exports, {
|
|
5071
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext
|
|
5072
|
+
});
|
|
5073
|
+
var init_law = __esm({
|
|
5074
|
+
"src/law/index.ts"() {
|
|
5075
|
+
init_law_types();
|
|
5076
|
+
}
|
|
5077
|
+
});
|
|
5078
|
+
|
|
4896
5079
|
// src/risk/index.ts
|
|
5080
|
+
var risk_exports = {};
|
|
5081
|
+
__export(risk_exports, {
|
|
5082
|
+
RiskDecision: () => RiskDecision
|
|
5083
|
+
});
|
|
4897
5084
|
var RiskDecision;
|
|
4898
5085
|
var init_risk = __esm({
|
|
4899
5086
|
"src/risk/index.ts"() {
|
|
@@ -6001,6 +6188,374 @@ var require_axis_sensor_chain_service = __commonJS({
|
|
|
6001
6188
|
}
|
|
6002
6189
|
});
|
|
6003
6190
|
|
|
6191
|
+
// src/timeline/timeline.engine.ts
|
|
6192
|
+
import { createHash as createHash5, randomBytes as randomBytes6 } from "crypto";
|
|
6193
|
+
function generateId(prefix) {
|
|
6194
|
+
return `${prefix}_${randomBytes6(16).toString("hex")}`;
|
|
6195
|
+
}
|
|
6196
|
+
function sha2566(data) {
|
|
6197
|
+
return createHash5("sha256").update(data).digest("hex");
|
|
6198
|
+
}
|
|
6199
|
+
function hashPayload2(payload) {
|
|
6200
|
+
return sha2566(JSON.stringify(payload));
|
|
6201
|
+
}
|
|
6202
|
+
function diffObjects(a, b) {
|
|
6203
|
+
const diffs = [];
|
|
6204
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
6205
|
+
for (const key of allKeys) {
|
|
6206
|
+
const va = a[key];
|
|
6207
|
+
const vb = b[key];
|
|
6208
|
+
if (JSON.stringify(va) !== JSON.stringify(vb)) {
|
|
6209
|
+
diffs.push({ field: key, original: va, replayed: vb });
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
return diffs;
|
|
6213
|
+
}
|
|
6214
|
+
var TimelineEngine;
|
|
6215
|
+
var init_timeline_engine = __esm({
|
|
6216
|
+
"src/timeline/timeline.engine.ts"() {
|
|
6217
|
+
TimelineEngine = class {
|
|
6218
|
+
constructor(store) {
|
|
6219
|
+
this.store = store;
|
|
6220
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
6221
|
+
}
|
|
6222
|
+
/** Register an intent handler for timeline execution */
|
|
6223
|
+
registerHandler(handler) {
|
|
6224
|
+
this.handlers.set(handler.intent, handler);
|
|
6225
|
+
}
|
|
6226
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6227
|
+
// Record (store a real execution as a timeline event)
|
|
6228
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6229
|
+
async recordEvent(intent, actorId, payload, result, options = {}) {
|
|
6230
|
+
const event = {
|
|
6231
|
+
event_id: generateId("evt"),
|
|
6232
|
+
timeline_id: options.timelineId ?? "prime",
|
|
6233
|
+
branch_id: options.branchId ?? "main",
|
|
6234
|
+
parent_event_id: options.parentEventId ?? null,
|
|
6235
|
+
intent,
|
|
6236
|
+
actor_id: actorId,
|
|
6237
|
+
capsule_id: options.capsuleId,
|
|
6238
|
+
tps_coordinate: options.tpsCoordinate,
|
|
6239
|
+
payload_hash: hashPayload2(payload),
|
|
6240
|
+
result_hash: hashPayload2(result),
|
|
6241
|
+
status: "executed",
|
|
6242
|
+
domain: "prime",
|
|
6243
|
+
determinism: options.determinism ?? "deterministic",
|
|
6244
|
+
witness_id: options.witnessId,
|
|
6245
|
+
created_at: Date.now(),
|
|
6246
|
+
metadata: { payload, result }
|
|
6247
|
+
};
|
|
6248
|
+
await this.store.saveEvent(event);
|
|
6249
|
+
return event;
|
|
6250
|
+
}
|
|
6251
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6252
|
+
// Replay
|
|
6253
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6254
|
+
async replay(request) {
|
|
6255
|
+
const originalEvent = await this.store.getEvent(request.source_event_id);
|
|
6256
|
+
if (!originalEvent) {
|
|
6257
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6258
|
+
}
|
|
6259
|
+
const handler = this.handlers.get(originalEvent.intent);
|
|
6260
|
+
if (!handler) {
|
|
6261
|
+
throw new Error(`No handler registered for intent '${originalEvent.intent}'`);
|
|
6262
|
+
}
|
|
6263
|
+
const originalPayload = originalEvent.metadata?.payload ?? {};
|
|
6264
|
+
const replayPayload = request.mode === "analytical" && request.override_payload ? request.override_payload : originalPayload;
|
|
6265
|
+
const snapshot = await this.store.getSnapshotByEvent(originalEvent.event_id);
|
|
6266
|
+
const context = {
|
|
6267
|
+
event_id: generateId("evt"),
|
|
6268
|
+
timeline_id: originalEvent.timeline_id,
|
|
6269
|
+
branch_id: `replay_${originalEvent.branch_id}`,
|
|
6270
|
+
domain: "audit",
|
|
6271
|
+
actor_id: originalEvent.actor_id,
|
|
6272
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6273
|
+
snapshot: snapshot ?? void 0,
|
|
6274
|
+
is_replay: true,
|
|
6275
|
+
is_simulation: false
|
|
6276
|
+
};
|
|
6277
|
+
const startMs = Date.now();
|
|
6278
|
+
const handlerResult = await handler.execute(replayPayload, context);
|
|
6279
|
+
const durationMs = Date.now() - startMs;
|
|
6280
|
+
const replayedEvent = {
|
|
6281
|
+
event_id: context.event_id,
|
|
6282
|
+
timeline_id: originalEvent.timeline_id,
|
|
6283
|
+
branch_id: context.branch_id,
|
|
6284
|
+
parent_event_id: originalEvent.event_id,
|
|
6285
|
+
intent: originalEvent.intent,
|
|
6286
|
+
actor_id: originalEvent.actor_id,
|
|
6287
|
+
capsule_id: originalEvent.capsule_id,
|
|
6288
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6289
|
+
payload_hash: hashPayload2(replayPayload),
|
|
6290
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6291
|
+
status: "replayed",
|
|
6292
|
+
domain: "audit",
|
|
6293
|
+
determinism: originalEvent.determinism,
|
|
6294
|
+
created_at: Date.now(),
|
|
6295
|
+
metadata: { payload: replayPayload, result: handlerResult.result_data }
|
|
6296
|
+
};
|
|
6297
|
+
await this.store.saveEvent(replayedEvent);
|
|
6298
|
+
const originalResult = originalEvent.metadata?.result ?? {};
|
|
6299
|
+
const differences = diffObjects(originalResult, handlerResult.result_data);
|
|
6300
|
+
const deterministicMatch = originalEvent.result_hash === replayedEvent.result_hash;
|
|
6301
|
+
return {
|
|
6302
|
+
original_event: originalEvent,
|
|
6303
|
+
replayed_event: replayedEvent,
|
|
6304
|
+
mode: request.mode,
|
|
6305
|
+
deterministic_match: deterministicMatch,
|
|
6306
|
+
differences,
|
|
6307
|
+
duration_ms: durationMs
|
|
6308
|
+
};
|
|
6309
|
+
}
|
|
6310
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6311
|
+
// Fork
|
|
6312
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6313
|
+
async fork(request) {
|
|
6314
|
+
const sourceEvent = await this.store.getEvent(request.source_event_id);
|
|
6315
|
+
if (!sourceEvent) {
|
|
6316
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6317
|
+
}
|
|
6318
|
+
const handler = this.handlers.get(sourceEvent.intent);
|
|
6319
|
+
if (!handler) {
|
|
6320
|
+
throw new Error(`No handler registered for intent '${sourceEvent.intent}'`);
|
|
6321
|
+
}
|
|
6322
|
+
const branch = {
|
|
6323
|
+
branch_id: generateId("branch"),
|
|
6324
|
+
timeline_id: generateId("timeline"),
|
|
6325
|
+
origin_timeline_id: sourceEvent.timeline_id,
|
|
6326
|
+
origin_event_id: sourceEvent.event_id,
|
|
6327
|
+
branch_type: "fork",
|
|
6328
|
+
creator_subject_id: request.actor_id,
|
|
6329
|
+
purpose: request.purpose,
|
|
6330
|
+
status: "active"
|
|
6331
|
+
};
|
|
6332
|
+
await this.store.saveBranch(branch);
|
|
6333
|
+
const snapshot = {
|
|
6334
|
+
snapshot_id: generateId("snap"),
|
|
6335
|
+
timeline_id: sourceEvent.timeline_id,
|
|
6336
|
+
event_id: sourceEvent.event_id,
|
|
6337
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6338
|
+
state_hash: hashPayload2(
|
|
6339
|
+
sourceEvent.metadata?.result ?? {}
|
|
6340
|
+
),
|
|
6341
|
+
state_data: sourceEvent.metadata?.result ?? {},
|
|
6342
|
+
created_at: Date.now()
|
|
6343
|
+
};
|
|
6344
|
+
await this.store.saveSnapshot(snapshot);
|
|
6345
|
+
const context = {
|
|
6346
|
+
event_id: generateId("evt"),
|
|
6347
|
+
timeline_id: branch.timeline_id,
|
|
6348
|
+
branch_id: branch.branch_id,
|
|
6349
|
+
domain: "fork",
|
|
6350
|
+
actor_id: request.actor_id,
|
|
6351
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6352
|
+
snapshot,
|
|
6353
|
+
is_replay: false,
|
|
6354
|
+
is_simulation: false
|
|
6355
|
+
};
|
|
6356
|
+
const handlerResult = await handler.execute(request.new_payload, context);
|
|
6357
|
+
const forkedEvent = {
|
|
6358
|
+
event_id: context.event_id,
|
|
6359
|
+
timeline_id: branch.timeline_id,
|
|
6360
|
+
branch_id: branch.branch_id,
|
|
6361
|
+
parent_event_id: sourceEvent.event_id,
|
|
6362
|
+
intent: sourceEvent.intent,
|
|
6363
|
+
actor_id: request.actor_id,
|
|
6364
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6365
|
+
payload_hash: hashPayload2(request.new_payload),
|
|
6366
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6367
|
+
status: "forked",
|
|
6368
|
+
domain: "fork",
|
|
6369
|
+
determinism: sourceEvent.determinism,
|
|
6370
|
+
created_at: Date.now(),
|
|
6371
|
+
metadata: {
|
|
6372
|
+
payload: request.new_payload,
|
|
6373
|
+
result: handlerResult.result_data
|
|
6374
|
+
}
|
|
6375
|
+
};
|
|
6376
|
+
await this.store.saveEvent(forkedEvent);
|
|
6377
|
+
return { branch, forked_event: forkedEvent, snapshot };
|
|
6378
|
+
}
|
|
6379
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6380
|
+
// Simulate
|
|
6381
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6382
|
+
async simulate(request) {
|
|
6383
|
+
const handler = this.handlers.get(request.intent);
|
|
6384
|
+
if (!handler) {
|
|
6385
|
+
throw new Error(`No handler registered for intent '${request.intent}'`);
|
|
6386
|
+
}
|
|
6387
|
+
let snapshot;
|
|
6388
|
+
if (request.from_snapshot_id) {
|
|
6389
|
+
const loaded = await this.store.getSnapshot(request.from_snapshot_id);
|
|
6390
|
+
if (!loaded) {
|
|
6391
|
+
throw new Error(`Snapshot ${request.from_snapshot_id} not found`);
|
|
6392
|
+
}
|
|
6393
|
+
snapshot = loaded;
|
|
6394
|
+
}
|
|
6395
|
+
const branch = {
|
|
6396
|
+
branch_id: generateId("branch"),
|
|
6397
|
+
timeline_id: generateId("timeline"),
|
|
6398
|
+
origin_timeline_id: "prime",
|
|
6399
|
+
origin_event_id: "simulation_origin",
|
|
6400
|
+
branch_type: "simulation",
|
|
6401
|
+
created_at_tps: request.at_tps,
|
|
6402
|
+
creator_subject_id: request.actor_id,
|
|
6403
|
+
purpose: request.purpose,
|
|
6404
|
+
status: "active"
|
|
6405
|
+
};
|
|
6406
|
+
await this.store.saveBranch(branch);
|
|
6407
|
+
const context = {
|
|
6408
|
+
event_id: generateId("evt"),
|
|
6409
|
+
timeline_id: branch.timeline_id,
|
|
6410
|
+
branch_id: branch.branch_id,
|
|
6411
|
+
domain: "shadow",
|
|
6412
|
+
actor_id: request.actor_id,
|
|
6413
|
+
tps_coordinate: request.at_tps,
|
|
6414
|
+
snapshot,
|
|
6415
|
+
is_replay: false,
|
|
6416
|
+
is_simulation: true
|
|
6417
|
+
};
|
|
6418
|
+
const startMs = Date.now();
|
|
6419
|
+
const handlerResult = await handler.execute(request.payload, context);
|
|
6420
|
+
const durationMs = Date.now() - startMs;
|
|
6421
|
+
const simulatedEvent = {
|
|
6422
|
+
event_id: context.event_id,
|
|
6423
|
+
timeline_id: branch.timeline_id,
|
|
6424
|
+
branch_id: branch.branch_id,
|
|
6425
|
+
parent_event_id: null,
|
|
6426
|
+
intent: request.intent,
|
|
6427
|
+
actor_id: request.actor_id,
|
|
6428
|
+
tps_coordinate: request.at_tps,
|
|
6429
|
+
payload_hash: hashPayload2(request.payload),
|
|
6430
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6431
|
+
status: "simulated",
|
|
6432
|
+
domain: "shadow",
|
|
6433
|
+
determinism: "bounded_nondeterministic",
|
|
6434
|
+
created_at: Date.now(),
|
|
6435
|
+
metadata: { payload: request.payload, result: handlerResult.result_data }
|
|
6436
|
+
};
|
|
6437
|
+
await this.store.saveEvent(simulatedEvent);
|
|
6438
|
+
branch.status = "completed";
|
|
6439
|
+
await this.store.saveBranch(branch);
|
|
6440
|
+
return {
|
|
6441
|
+
branch,
|
|
6442
|
+
simulated_event: simulatedEvent,
|
|
6443
|
+
predicted_outcome: handlerResult.result_data,
|
|
6444
|
+
side_effects: handlerResult.side_effects ?? [],
|
|
6445
|
+
duration_ms: durationMs
|
|
6446
|
+
};
|
|
6447
|
+
}
|
|
6448
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6449
|
+
// Compare timelines
|
|
6450
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6451
|
+
async compare(timelineIdA, timelineIdB) {
|
|
6452
|
+
const eventsA = await this.store.getEventsByTimeline(timelineIdA);
|
|
6453
|
+
const eventsB = await this.store.getEventsByTimeline(timelineIdB);
|
|
6454
|
+
eventsA.sort((a, b) => a.created_at - b.created_at);
|
|
6455
|
+
eventsB.sort((a, b) => a.created_at - b.created_at);
|
|
6456
|
+
const maxLen = Math.max(eventsA.length, eventsB.length);
|
|
6457
|
+
const eventPairs = [];
|
|
6458
|
+
let divergencePoint;
|
|
6459
|
+
for (let i = 0; i < maxLen; i++) {
|
|
6460
|
+
const a = eventsA[i];
|
|
6461
|
+
const b = eventsB[i];
|
|
6462
|
+
if (!a || !b) {
|
|
6463
|
+
if (!divergencePoint) {
|
|
6464
|
+
divergencePoint = a?.event_id ?? b?.event_id;
|
|
6465
|
+
}
|
|
6466
|
+
continue;
|
|
6467
|
+
}
|
|
6468
|
+
const match = a.result_hash === b.result_hash;
|
|
6469
|
+
const resultA = a.metadata?.result ?? {};
|
|
6470
|
+
const resultB = b.metadata?.result ?? {};
|
|
6471
|
+
const differences = match ? [] : diffObjects(resultA, resultB);
|
|
6472
|
+
if (!match && !divergencePoint) {
|
|
6473
|
+
divergencePoint = a.event_id;
|
|
6474
|
+
}
|
|
6475
|
+
eventPairs.push({ event_a: a, event_b: b, match, differences });
|
|
6476
|
+
}
|
|
6477
|
+
return {
|
|
6478
|
+
timeline_a: timelineIdA,
|
|
6479
|
+
timeline_b: timelineIdB,
|
|
6480
|
+
event_pairs: eventPairs,
|
|
6481
|
+
divergence_point: divergencePoint
|
|
6482
|
+
};
|
|
6483
|
+
}
|
|
6484
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6485
|
+
// State snapshot management
|
|
6486
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6487
|
+
async createSnapshot(eventId, stateData) {
|
|
6488
|
+
const event = await this.store.getEvent(eventId);
|
|
6489
|
+
if (!event) {
|
|
6490
|
+
throw new Error(`Event ${eventId} not found`);
|
|
6491
|
+
}
|
|
6492
|
+
const snapshot = {
|
|
6493
|
+
snapshot_id: generateId("snap"),
|
|
6494
|
+
timeline_id: event.timeline_id,
|
|
6495
|
+
event_id: eventId,
|
|
6496
|
+
tps_coordinate: event.tps_coordinate,
|
|
6497
|
+
state_hash: hashPayload2(stateData),
|
|
6498
|
+
state_data: stateData,
|
|
6499
|
+
created_at: Date.now()
|
|
6500
|
+
};
|
|
6501
|
+
await this.store.saveSnapshot(snapshot);
|
|
6502
|
+
return snapshot;
|
|
6503
|
+
}
|
|
6504
|
+
async restoreSnapshot(snapshotId) {
|
|
6505
|
+
const snapshot = await this.store.getSnapshot(snapshotId);
|
|
6506
|
+
if (!snapshot) {
|
|
6507
|
+
throw new Error(`Snapshot ${snapshotId} not found`);
|
|
6508
|
+
}
|
|
6509
|
+
return snapshot;
|
|
6510
|
+
}
|
|
6511
|
+
};
|
|
6512
|
+
}
|
|
6513
|
+
});
|
|
6514
|
+
|
|
6515
|
+
// src/timeline/timeline.store.ts
|
|
6516
|
+
var InMemoryTimelineStore;
|
|
6517
|
+
var init_timeline_store = __esm({
|
|
6518
|
+
"src/timeline/timeline.store.ts"() {
|
|
6519
|
+
InMemoryTimelineStore = class {
|
|
6520
|
+
constructor() {
|
|
6521
|
+
this.events = /* @__PURE__ */ new Map();
|
|
6522
|
+
this.branches = /* @__PURE__ */ new Map();
|
|
6523
|
+
this.snapshots = /* @__PURE__ */ new Map();
|
|
6524
|
+
}
|
|
6525
|
+
async saveEvent(event) {
|
|
6526
|
+
this.events.set(event.event_id, event);
|
|
6527
|
+
}
|
|
6528
|
+
async getEvent(eventId) {
|
|
6529
|
+
return this.events.get(eventId) ?? null;
|
|
6530
|
+
}
|
|
6531
|
+
async getEventsByTimeline(timelineId) {
|
|
6532
|
+
return [...this.events.values()].filter((e) => e.timeline_id === timelineId);
|
|
6533
|
+
}
|
|
6534
|
+
async getEventsByBranch(branchId) {
|
|
6535
|
+
return [...this.events.values()].filter((e) => e.branch_id === branchId);
|
|
6536
|
+
}
|
|
6537
|
+
async saveBranch(branch) {
|
|
6538
|
+
this.branches.set(branch.branch_id, branch);
|
|
6539
|
+
}
|
|
6540
|
+
async getBranch(branchId) {
|
|
6541
|
+
return this.branches.get(branchId) ?? null;
|
|
6542
|
+
}
|
|
6543
|
+
async getBranchesByTimeline(timelineId) {
|
|
6544
|
+
return [...this.branches.values()].filter((b) => b.timeline_id === timelineId);
|
|
6545
|
+
}
|
|
6546
|
+
async saveSnapshot(snapshot) {
|
|
6547
|
+
this.snapshots.set(snapshot.snapshot_id, snapshot);
|
|
6548
|
+
}
|
|
6549
|
+
async getSnapshot(snapshotId) {
|
|
6550
|
+
return this.snapshots.get(snapshotId) ?? null;
|
|
6551
|
+
}
|
|
6552
|
+
async getSnapshotByEvent(eventId) {
|
|
6553
|
+
return [...this.snapshots.values()].find((s) => s.event_id === eventId) ?? null;
|
|
6554
|
+
}
|
|
6555
|
+
};
|
|
6556
|
+
}
|
|
6557
|
+
});
|
|
6558
|
+
|
|
6004
6559
|
// src/utils/axis-tlv-codec.ts
|
|
6005
6560
|
function encodeAxisTlvDto(dtoClass, data) {
|
|
6006
6561
|
const schema = (0, import_dto_schema.extractDtoSchema)(dtoClass);
|
|
@@ -6093,95 +6648,1807 @@ var init_loom_types = __esm({
|
|
|
6093
6648
|
}
|
|
6094
6649
|
});
|
|
6095
6650
|
|
|
6096
|
-
// src/
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6651
|
+
// src/loom/loom.engine.ts
|
|
6652
|
+
import { createHash as createHash6, randomBytes as randomBytes7 } from "crypto";
|
|
6653
|
+
import { sign as sign2 } from "tweetnacl";
|
|
6654
|
+
function sha2567(data) {
|
|
6655
|
+
return createHash6("sha256").update(data).digest("hex");
|
|
6656
|
+
}
|
|
6657
|
+
function hexToUint8(hex) {
|
|
6658
|
+
const bytes2 = new Uint8Array(hex.length / 2);
|
|
6659
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
6660
|
+
bytes2[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
6661
|
+
}
|
|
6662
|
+
return bytes2;
|
|
6663
|
+
}
|
|
6664
|
+
function uint8ToHex(bytes2) {
|
|
6665
|
+
return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6666
|
+
}
|
|
6667
|
+
function b64ToUint8(b64) {
|
|
6668
|
+
const bin = Buffer.from(b64, "base64");
|
|
6669
|
+
return new Uint8Array(bin.buffer, bin.byteOffset, bin.byteLength);
|
|
6670
|
+
}
|
|
6671
|
+
function uint8ToB64(bytes2) {
|
|
6672
|
+
return Buffer.from(bytes2).toString("base64");
|
|
6673
|
+
}
|
|
6674
|
+
function createPresenceChallenge(declaration, ttlMs = DEFAULT_PRESENCE_TTL_MS) {
|
|
6675
|
+
const now = Date.now();
|
|
6676
|
+
const nonce = randomBytes7(32).toString("hex");
|
|
6677
|
+
const challengeId = sha2567(`${declaration.softid}:${nonce}:${now}`);
|
|
6678
|
+
return {
|
|
6679
|
+
challenge_id: challengeId,
|
|
6680
|
+
nonce,
|
|
6681
|
+
temporal_anchor: now,
|
|
6682
|
+
ttl_ms: ttlMs,
|
|
6683
|
+
expires_at: now + ttlMs
|
|
6684
|
+
};
|
|
6685
|
+
}
|
|
6686
|
+
function presenceSigningData(challenge, deviceMeta) {
|
|
6687
|
+
return JSON.stringify({
|
|
6688
|
+
nonce: challenge.nonce,
|
|
6689
|
+
temporal_anchor: challenge.temporal_anchor,
|
|
6690
|
+
device_meta: deviceMeta ?? null
|
|
6691
|
+
});
|
|
6692
|
+
}
|
|
6693
|
+
function signPresenceChallenge(challenge, privateKeyHex, publicKeyHex, declaration, kid) {
|
|
6694
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6695
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6696
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6697
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
6698
|
+
return {
|
|
6699
|
+
challenge_id: challenge.challenge_id,
|
|
6700
|
+
signature: uint8ToHex(signature),
|
|
6701
|
+
public_key: publicKeyHex,
|
|
6702
|
+
kid
|
|
6703
|
+
};
|
|
6704
|
+
}
|
|
6705
|
+
function verifyPresenceProof(challenge, proof, declaration, durationMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6706
|
+
if (Date.now() > challenge.expires_at) {
|
|
6707
|
+
return { valid: false, error: "Challenge expired", code: "CHALLENGE_EXPIRED" };
|
|
6708
|
+
}
|
|
6709
|
+
if (proof.challenge_id !== challenge.challenge_id) {
|
|
6710
|
+
return { valid: false, error: "Challenge ID mismatch", code: "CHALLENGE_MISMATCH" };
|
|
6711
|
+
}
|
|
6712
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6713
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6714
|
+
const sigBytes = hexToUint8(proof.signature);
|
|
6715
|
+
const pubBytes = hexToUint8(proof.public_key);
|
|
6716
|
+
let isValid;
|
|
6717
|
+
try {
|
|
6718
|
+
isValid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
6719
|
+
} catch {
|
|
6720
|
+
return { valid: false, error: "Signature verification failed", code: "SIG_INVALID" };
|
|
6721
|
+
}
|
|
6722
|
+
if (!isValid) {
|
|
6723
|
+
return { valid: false, error: "Invalid signature", code: "SIG_INVALID" };
|
|
6724
|
+
}
|
|
6725
|
+
const now = Date.now();
|
|
6726
|
+
const presenceId = sha2567(
|
|
6727
|
+
`${proof.public_key}:${challenge.nonce}:${challenge.temporal_anchor}`
|
|
6728
|
+
);
|
|
6729
|
+
const anchorReflection = sha2567(
|
|
6730
|
+
`ar:openlogs:loom:${proof.public_key}`
|
|
6731
|
+
);
|
|
6732
|
+
const receipt = {
|
|
6733
|
+
presence_id: presenceId,
|
|
6734
|
+
softid: declaration.softid,
|
|
6735
|
+
anchor_reflection: anchorReflection,
|
|
6736
|
+
scope: {
|
|
6737
|
+
device_fingerprint: declaration.device_meta?.fingerprint
|
|
6738
|
+
},
|
|
6739
|
+
issued_at: now,
|
|
6740
|
+
expires_at: now + durationMs
|
|
6741
|
+
};
|
|
6742
|
+
return { valid: true, presence: receipt };
|
|
6743
|
+
}
|
|
6744
|
+
function getPresenceStatus(receipt) {
|
|
6745
|
+
const now = Date.now();
|
|
6746
|
+
if (now > receipt.expires_at) return "expired";
|
|
6747
|
+
return "active";
|
|
6748
|
+
}
|
|
6749
|
+
function renewPresence(receipt, extensionMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6750
|
+
const now = Date.now();
|
|
6751
|
+
return {
|
|
6752
|
+
...receipt,
|
|
6753
|
+
renewed_at: now,
|
|
6754
|
+
expires_at: now + extensionMs
|
|
6755
|
+
};
|
|
6756
|
+
}
|
|
6757
|
+
function createWrit(body, meta, thread, privateKeyHex, kid) {
|
|
6758
|
+
const head = { tid: thread.tid, seq: thread.seq };
|
|
6759
|
+
const writMeta = { ...meta, prev: thread.prevHash };
|
|
6760
|
+
const unsigned = { head, body, meta: writMeta };
|
|
6761
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
6762
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
6763
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6764
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
6765
|
+
const sig = {
|
|
6766
|
+
alg: "ed25519",
|
|
6767
|
+
value: uint8ToB64(signature),
|
|
6768
|
+
kid
|
|
6769
|
+
};
|
|
6770
|
+
return { head, body, meta: writMeta, sig };
|
|
6771
|
+
}
|
|
6772
|
+
function validateWrit(writ, publicKeyHex, threadState, grants) {
|
|
6773
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6774
|
+
if (now < writ.meta.iat) {
|
|
6775
|
+
return {
|
|
6776
|
+
valid: false,
|
|
6777
|
+
error: "Writ not yet valid (iat in future)",
|
|
6778
|
+
code: "TEMPORAL_NOT_YET",
|
|
6779
|
+
gate_failed: "temporal"
|
|
6780
|
+
};
|
|
6781
|
+
}
|
|
6782
|
+
if (now > writ.meta.exp) {
|
|
6783
|
+
return {
|
|
6784
|
+
valid: false,
|
|
6785
|
+
error: "Writ expired",
|
|
6786
|
+
code: "TEMPORAL_EXPIRED",
|
|
6787
|
+
gate_failed: "temporal"
|
|
6788
|
+
};
|
|
6789
|
+
}
|
|
6790
|
+
if (threadState) {
|
|
6791
|
+
if (writ.head.tid !== threadState.thread_id) {
|
|
6792
|
+
return {
|
|
6793
|
+
valid: false,
|
|
6794
|
+
error: "Thread ID mismatch",
|
|
6795
|
+
code: "CAUSAL_TID",
|
|
6796
|
+
gate_failed: "causal"
|
|
6797
|
+
};
|
|
6798
|
+
}
|
|
6799
|
+
if (writ.head.seq !== threadState.sequence + 1) {
|
|
6800
|
+
return {
|
|
6801
|
+
valid: false,
|
|
6802
|
+
error: `Expected seq ${threadState.sequence + 1}, got ${writ.head.seq}`,
|
|
6803
|
+
code: "CAUSAL_SEQ",
|
|
6804
|
+
gate_failed: "causal"
|
|
6805
|
+
};
|
|
6806
|
+
}
|
|
6807
|
+
if (writ.meta.prev !== threadState.last_receipt_hash) {
|
|
6808
|
+
return {
|
|
6809
|
+
valid: false,
|
|
6810
|
+
error: "Previous receipt hash mismatch",
|
|
6811
|
+
code: "CAUSAL_PREV",
|
|
6812
|
+
gate_failed: "causal"
|
|
6813
|
+
};
|
|
6814
|
+
}
|
|
6815
|
+
} else {
|
|
6816
|
+
if (writ.head.seq !== 1) {
|
|
6817
|
+
return {
|
|
6818
|
+
valid: false,
|
|
6819
|
+
error: "First writ in thread must have seq=1",
|
|
6820
|
+
code: "CAUSAL_FIRST_SEQ",
|
|
6821
|
+
gate_failed: "causal"
|
|
6822
|
+
};
|
|
6823
|
+
}
|
|
6824
|
+
if (writ.meta.prev !== "") {
|
|
6825
|
+
return {
|
|
6826
|
+
valid: false,
|
|
6827
|
+
error: "First writ must have empty prev hash",
|
|
6828
|
+
code: "CAUSAL_FIRST_PREV",
|
|
6829
|
+
gate_failed: "causal"
|
|
6830
|
+
};
|
|
6831
|
+
}
|
|
6832
|
+
}
|
|
6833
|
+
if (writ.body.law !== "self") {
|
|
6834
|
+
const matchingGrant = grants.find(
|
|
6835
|
+
(g) => g.grant_id === writ.body.law && g.subject === writ.body.who && grantCoversAction(g, writ.body.act, writ.body.res, now)
|
|
6836
|
+
);
|
|
6837
|
+
if (!matchingGrant) {
|
|
6838
|
+
return {
|
|
6839
|
+
valid: false,
|
|
6840
|
+
error: `No valid grant found for law=${writ.body.law}`,
|
|
6841
|
+
code: "LEGAL_NO_GRANT",
|
|
6842
|
+
gate_failed: "legal"
|
|
6843
|
+
};
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
const unsigned = {
|
|
6847
|
+
head: writ.head,
|
|
6848
|
+
body: writ.body,
|
|
6849
|
+
meta: writ.meta
|
|
6850
|
+
};
|
|
6851
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
6852
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
6853
|
+
const sigBytes = b64ToUint8(writ.sig.value);
|
|
6854
|
+
const pubBytes = hexToUint8(publicKeyHex);
|
|
6855
|
+
let sigValid;
|
|
6856
|
+
try {
|
|
6857
|
+
sigValid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
6858
|
+
} catch {
|
|
6859
|
+
return {
|
|
6860
|
+
valid: false,
|
|
6861
|
+
error: "Signature verification failed",
|
|
6862
|
+
code: "AUTH_SIG_FAIL",
|
|
6863
|
+
gate_failed: "authentic"
|
|
6864
|
+
};
|
|
6865
|
+
}
|
|
6866
|
+
if (!sigValid) {
|
|
6867
|
+
return {
|
|
6868
|
+
valid: false,
|
|
6869
|
+
error: "Invalid signature",
|
|
6870
|
+
code: "AUTH_SIG_INVALID",
|
|
6871
|
+
gate_failed: "authentic"
|
|
6872
|
+
};
|
|
6873
|
+
}
|
|
6874
|
+
return { valid: true, writ };
|
|
6875
|
+
}
|
|
6876
|
+
function grantCoversAction(grant, action, resource, nowUnix) {
|
|
6877
|
+
if (nowUnix < grant.meta.iat || nowUnix > grant.meta.exp) {
|
|
6878
|
+
return false;
|
|
6879
|
+
}
|
|
6880
|
+
return grant.caps.some(
|
|
6881
|
+
(cap) => matchOec(cap.oec, action) && matchScope(cap.scope, resource)
|
|
6882
|
+
);
|
|
6883
|
+
}
|
|
6884
|
+
function matchOec(pattern, action) {
|
|
6885
|
+
if (pattern === "*") return true;
|
|
6886
|
+
if (pattern === action) return true;
|
|
6887
|
+
if (pattern.endsWith(".*")) {
|
|
6888
|
+
const prefix = pattern.slice(0, -2);
|
|
6889
|
+
return action.startsWith(prefix + ".");
|
|
6890
|
+
}
|
|
6891
|
+
return false;
|
|
6892
|
+
}
|
|
6893
|
+
function matchScope(pattern, resource) {
|
|
6894
|
+
if (pattern === "*") return true;
|
|
6895
|
+
if (pattern === resource) return true;
|
|
6896
|
+
if (pattern.includes("*")) {
|
|
6897
|
+
const regex = new RegExp(
|
|
6898
|
+
"^" + pattern.replace(/\./g, "\\.").replace(/\*/g, "[^:]*") + "$"
|
|
6899
|
+
);
|
|
6900
|
+
return regex.test(resource);
|
|
6901
|
+
}
|
|
6902
|
+
return false;
|
|
6903
|
+
}
|
|
6904
|
+
function getGrantStatus(grant, revocations) {
|
|
6905
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6906
|
+
const revoked = revocations.find(
|
|
6907
|
+
(r) => r.target_type === "grant" && r.target_id === grant.grant_id
|
|
6908
|
+
);
|
|
6909
|
+
if (revoked && revoked.effective_at <= now * 1e3) {
|
|
6910
|
+
return "revoked";
|
|
6911
|
+
}
|
|
6912
|
+
if (now > grant.meta.exp) return "expired";
|
|
6913
|
+
return "active";
|
|
6914
|
+
}
|
|
6915
|
+
function validateGrant(grant, issuerPublicKeyHex) {
|
|
6916
|
+
const unsigned = {
|
|
6917
|
+
grant_id: grant.grant_id,
|
|
6918
|
+
issuer: grant.issuer,
|
|
6919
|
+
subject: grant.subject,
|
|
6920
|
+
grant_type: grant.grant_type,
|
|
6921
|
+
caps: grant.caps,
|
|
6922
|
+
meta: grant.meta
|
|
6923
|
+
};
|
|
6924
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
6925
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
6926
|
+
const sigBytes = b64ToUint8(grant.sig.value);
|
|
6927
|
+
const pubBytes = hexToUint8(issuerPublicKeyHex);
|
|
6928
|
+
let valid;
|
|
6929
|
+
try {
|
|
6930
|
+
valid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
6931
|
+
} catch {
|
|
6932
|
+
return { valid: false, error: "Grant signature verification failed", code: "GRANT_SIG_FAIL" };
|
|
6933
|
+
}
|
|
6934
|
+
if (!valid) {
|
|
6935
|
+
return { valid: false, error: "Invalid grant signature", code: "GRANT_SIG_INVALID" };
|
|
6936
|
+
}
|
|
6937
|
+
return { valid: true, grant };
|
|
6938
|
+
}
|
|
6939
|
+
function createGrant(grantId, issuer, subject, grantType, caps, meta, privateKeyHex, kid) {
|
|
6940
|
+
const unsigned = {
|
|
6941
|
+
grant_id: grantId,
|
|
6942
|
+
issuer,
|
|
6943
|
+
subject,
|
|
6944
|
+
grant_type: grantType,
|
|
6945
|
+
caps,
|
|
6946
|
+
meta
|
|
6947
|
+
};
|
|
6948
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
6949
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
6950
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6951
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
6952
|
+
return {
|
|
6953
|
+
...unsigned,
|
|
6954
|
+
sig: {
|
|
6955
|
+
alg: "ed25519",
|
|
6956
|
+
value: uint8ToB64(signature),
|
|
6957
|
+
kid
|
|
6958
|
+
}
|
|
6959
|
+
};
|
|
6960
|
+
}
|
|
6961
|
+
function createReceipt(writ, effect, prevReceipt, metadata) {
|
|
6962
|
+
const now = Date.now();
|
|
6963
|
+
const sequence = prevReceipt ? prevReceipt.sequence + 1 : 1;
|
|
6964
|
+
const prevHash = prevReceipt?.hash ?? null;
|
|
6965
|
+
const writHash = sha2567(canonicalizeWrit({
|
|
6966
|
+
head: writ.head,
|
|
6967
|
+
body: writ.body,
|
|
6968
|
+
meta: writ.meta
|
|
6969
|
+
}));
|
|
6970
|
+
const hashInput = [
|
|
6971
|
+
prevHash ?? "",
|
|
6972
|
+
writHash,
|
|
6973
|
+
writ.head.tid,
|
|
6974
|
+
String(sequence),
|
|
6975
|
+
effect,
|
|
6976
|
+
String(now)
|
|
6977
|
+
].join(":");
|
|
6978
|
+
const receiptHash = sha2567(hashInput);
|
|
6979
|
+
const receiptId = sha2567(`receipt:${receiptHash}:${now}`);
|
|
6980
|
+
return {
|
|
6981
|
+
receipt_id: receiptId,
|
|
6982
|
+
writ_hash: writHash,
|
|
6983
|
+
thread_id: writ.head.tid,
|
|
6984
|
+
sequence,
|
|
6985
|
+
effect,
|
|
6986
|
+
hash: receiptHash,
|
|
6987
|
+
prev_hash: prevHash,
|
|
6988
|
+
executed_at: now,
|
|
6989
|
+
metadata
|
|
6990
|
+
};
|
|
6991
|
+
}
|
|
6992
|
+
function verifyReceiptChain(receipts) {
|
|
6993
|
+
if (receipts.length === 0) return { valid: true };
|
|
6994
|
+
const sorted = [...receipts].sort((a, b) => a.sequence - b.sequence);
|
|
6995
|
+
if (sorted[0].prev_hash !== null) {
|
|
6996
|
+
return {
|
|
6997
|
+
valid: false,
|
|
6998
|
+
brokenAt: 0,
|
|
6999
|
+
error: "First receipt must have null prev_hash"
|
|
7000
|
+
};
|
|
7001
|
+
}
|
|
7002
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
7003
|
+
if (sorted[i].prev_hash !== sorted[i - 1].hash) {
|
|
7004
|
+
return {
|
|
7005
|
+
valid: false,
|
|
7006
|
+
brokenAt: i,
|
|
7007
|
+
error: `Receipt ${i} prev_hash does not match receipt ${i - 1} hash`
|
|
7008
|
+
};
|
|
7009
|
+
}
|
|
7010
|
+
}
|
|
7011
|
+
return { valid: true };
|
|
7012
|
+
}
|
|
7013
|
+
function updateThreadState(receipt, softid) {
|
|
7014
|
+
return {
|
|
7015
|
+
thread_id: receipt.thread_id,
|
|
7016
|
+
softid,
|
|
7017
|
+
last_receipt_hash: receipt.hash,
|
|
7018
|
+
sequence: receipt.sequence,
|
|
7019
|
+
updated_at: receipt.executed_at
|
|
7020
|
+
};
|
|
7021
|
+
}
|
|
7022
|
+
function createRevocation(targetType, targetId, issuerSoftid, privateKeyHex, reason) {
|
|
7023
|
+
const now = Date.now();
|
|
7024
|
+
const revocationId = sha2567(`revoke:${targetType}:${targetId}:${now}`);
|
|
7025
|
+
const payload = JSON.stringify({
|
|
7026
|
+
revocation_id: revocationId,
|
|
7027
|
+
target_type: targetType,
|
|
7028
|
+
target_id: targetId,
|
|
7029
|
+
issuer_softid: issuerSoftid,
|
|
7030
|
+
effective_at: now,
|
|
7031
|
+
reason: reason ?? null
|
|
7032
|
+
});
|
|
7033
|
+
const msgBytes = new TextEncoder().encode(payload);
|
|
7034
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7035
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
7036
|
+
return {
|
|
7037
|
+
revocation_id: revocationId,
|
|
7038
|
+
target_type: targetType,
|
|
7039
|
+
target_id: targetId,
|
|
7040
|
+
issuer_softid: issuerSoftid,
|
|
7041
|
+
reason,
|
|
7042
|
+
effective_at: now,
|
|
7043
|
+
sig_value: uint8ToHex(signature)
|
|
7044
|
+
};
|
|
7045
|
+
}
|
|
7046
|
+
function isRevoked(targetType, targetId, revocations) {
|
|
7047
|
+
const now = Date.now();
|
|
7048
|
+
return revocations.some(
|
|
7049
|
+
(r) => r.target_type === targetType && r.target_id === targetId && r.effective_at <= now
|
|
7050
|
+
);
|
|
7051
|
+
}
|
|
7052
|
+
function executeLoomPipeline(writ, publicKeyHex, presence, threadState, grants, revocations, prevReceipt) {
|
|
7053
|
+
const presenceStatus = getPresenceStatus(presence);
|
|
7054
|
+
if (presenceStatus !== "active") {
|
|
7055
|
+
return { valid: false, error: "Presence not active", code: "PRESENCE_INACTIVE" };
|
|
7056
|
+
}
|
|
7057
|
+
if (isRevoked("presence", presence.presence_id, revocations)) {
|
|
7058
|
+
return { valid: false, error: "Presence revoked", code: "PRESENCE_REVOKED" };
|
|
7059
|
+
}
|
|
7060
|
+
const activeGrants = grants.filter(
|
|
7061
|
+
(g) => getGrantStatus(g, revocations) === "active"
|
|
7062
|
+
);
|
|
7063
|
+
const writResult = validateWrit(writ, publicKeyHex, threadState, activeGrants);
|
|
7064
|
+
if (!writResult.valid) {
|
|
7065
|
+
return { valid: false, error: writResult.error, code: writResult.code };
|
|
7066
|
+
}
|
|
7067
|
+
const receipt = createReceipt(writ, "ALLOW", prevReceipt);
|
|
7068
|
+
const newThreadState = updateThreadState(receipt, writ.body.who);
|
|
7069
|
+
return {
|
|
7070
|
+
receipt,
|
|
7071
|
+
threadState: newThreadState,
|
|
7072
|
+
writValidation: writResult
|
|
7073
|
+
};
|
|
7074
|
+
}
|
|
7075
|
+
var DEFAULT_PRESENCE_TTL_MS, DEFAULT_PRESENCE_DURATION_MS;
|
|
7076
|
+
var init_loom_engine = __esm({
|
|
7077
|
+
"src/loom/loom.engine.ts"() {
|
|
7078
|
+
init_loom_types();
|
|
7079
|
+
DEFAULT_PRESENCE_TTL_MS = 5e3;
|
|
7080
|
+
DEFAULT_PRESENCE_DURATION_MS = 30 * 60 * 1e3;
|
|
7081
|
+
}
|
|
7082
|
+
});
|
|
7083
|
+
|
|
7084
|
+
// src/idel/idel.compiler.ts
|
|
7085
|
+
function validateType(value, expectedType) {
|
|
7086
|
+
switch (expectedType) {
|
|
7087
|
+
case "string":
|
|
7088
|
+
return typeof value === "string";
|
|
7089
|
+
case "number":
|
|
7090
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
7091
|
+
case "boolean":
|
|
7092
|
+
return typeof value === "boolean";
|
|
7093
|
+
case "object":
|
|
7094
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7095
|
+
case "array":
|
|
7096
|
+
return Array.isArray(value);
|
|
7097
|
+
default:
|
|
7098
|
+
return true;
|
|
7099
|
+
}
|
|
7100
|
+
}
|
|
7101
|
+
function assessRisk(schema, proposal, constraints) {
|
|
7102
|
+
const factors = [];
|
|
7103
|
+
let score = 0;
|
|
7104
|
+
const baseRiskMap = {
|
|
7105
|
+
none: 0,
|
|
7106
|
+
low: 0.1,
|
|
7107
|
+
medium: 0.3,
|
|
7108
|
+
high: 0.6,
|
|
7109
|
+
critical: 0.9
|
|
7110
|
+
};
|
|
7111
|
+
score = baseRiskMap[schema.risk_level] ?? 0;
|
|
7112
|
+
if (schema.risk_level !== "none") {
|
|
7113
|
+
factors.push(`Base risk: ${schema.risk_level}`);
|
|
7114
|
+
}
|
|
7115
|
+
if (schema.has_side_effects) {
|
|
7116
|
+
score += 0.1;
|
|
7117
|
+
factors.push("Has side effects");
|
|
7118
|
+
}
|
|
7119
|
+
if (!schema.reversible) {
|
|
7120
|
+
score += 0.1;
|
|
7121
|
+
factors.push("Not reversible");
|
|
7122
|
+
}
|
|
7123
|
+
const failed = constraints.filter((c) => !c.satisfied);
|
|
7124
|
+
if (failed.length > 0) {
|
|
7125
|
+
score += 0.05 * failed.length;
|
|
7126
|
+
factors.push(`${failed.length} unsatisfied constraint(s)`);
|
|
7127
|
+
}
|
|
7128
|
+
score = Math.min(score, 1);
|
|
7129
|
+
let level;
|
|
7130
|
+
if (score <= 0) level = "none";
|
|
7131
|
+
else if (score <= 0.2) level = "low";
|
|
7132
|
+
else if (score <= 0.5) level = "medium";
|
|
7133
|
+
else if (score <= 0.8) level = "high";
|
|
7134
|
+
else level = "critical";
|
|
7135
|
+
return { level, score, factors };
|
|
7136
|
+
}
|
|
7137
|
+
var IdelSchemaRegistry, IdelCompiler;
|
|
7138
|
+
var init_idel_compiler = __esm({
|
|
7139
|
+
"src/idel/idel.compiler.ts"() {
|
|
7140
|
+
IdelSchemaRegistry = class {
|
|
7141
|
+
constructor() {
|
|
7142
|
+
this.schemas = /* @__PURE__ */ new Map();
|
|
7143
|
+
this.aliases = /* @__PURE__ */ new Map();
|
|
7144
|
+
}
|
|
7145
|
+
register(schema) {
|
|
7146
|
+
this.schemas.set(schema.intent, schema);
|
|
7147
|
+
}
|
|
7148
|
+
registerAlias(alias, intent) {
|
|
7149
|
+
this.aliases.set(alias.toLowerCase(), intent);
|
|
7150
|
+
}
|
|
7151
|
+
get(intent) {
|
|
7152
|
+
return this.schemas.get(intent);
|
|
7153
|
+
}
|
|
7154
|
+
resolve(raw) {
|
|
7155
|
+
const exact = this.schemas.get(raw);
|
|
7156
|
+
if (exact) return exact;
|
|
7157
|
+
const aliased = this.aliases.get(raw.toLowerCase());
|
|
7158
|
+
if (aliased) return this.schemas.get(aliased);
|
|
7159
|
+
const candidates = [...this.schemas.keys()].filter(
|
|
7160
|
+
(k) => k.startsWith(raw + ".") || k.toLowerCase().includes(raw.toLowerCase())
|
|
7161
|
+
);
|
|
7162
|
+
if (candidates.length === 1) {
|
|
7163
|
+
return this.schemas.get(candidates[0]);
|
|
7164
|
+
}
|
|
7165
|
+
return void 0;
|
|
7166
|
+
}
|
|
7167
|
+
/**
|
|
7168
|
+
* Find all schemas that partially match the raw input.
|
|
7169
|
+
* Returns scored candidates for ambiguity resolution.
|
|
7170
|
+
*/
|
|
7171
|
+
findCandidates(raw) {
|
|
7172
|
+
const normalized = raw.toLowerCase().trim();
|
|
7173
|
+
const results = [];
|
|
7174
|
+
for (const [key, schema] of this.schemas) {
|
|
7175
|
+
let score = 0;
|
|
7176
|
+
if (key === raw) {
|
|
7177
|
+
score = 1;
|
|
7178
|
+
} else if (key.toLowerCase() === normalized) {
|
|
7179
|
+
score = 0.95;
|
|
7180
|
+
} else if (this.aliases.get(normalized) === key) {
|
|
7181
|
+
score = 0.9;
|
|
7182
|
+
} else if (key.toLowerCase().startsWith(normalized)) {
|
|
7183
|
+
score = 0.7;
|
|
7184
|
+
} else if (key.toLowerCase().includes(normalized)) {
|
|
7185
|
+
score = 0.5;
|
|
7186
|
+
} else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {
|
|
7187
|
+
score = 0.4;
|
|
7188
|
+
} else if (schema.description.toLowerCase().includes(normalized)) {
|
|
7189
|
+
score = 0.3;
|
|
7190
|
+
}
|
|
7191
|
+
if (score > 0) {
|
|
7192
|
+
results.push({ schema, score });
|
|
7193
|
+
}
|
|
7194
|
+
}
|
|
7195
|
+
return results.sort((a, b) => b.score - a.score);
|
|
7196
|
+
}
|
|
7197
|
+
list() {
|
|
7198
|
+
return [...this.schemas.values()];
|
|
7199
|
+
}
|
|
7200
|
+
};
|
|
7201
|
+
IdelCompiler = class {
|
|
7202
|
+
constructor(registry) {
|
|
7203
|
+
this.registry = registry;
|
|
7204
|
+
}
|
|
7205
|
+
/**
|
|
7206
|
+
* Compile a raw intent proposal into a validated, executable structure.
|
|
7207
|
+
*/
|
|
7208
|
+
compile(proposal) {
|
|
7209
|
+
const errors = [];
|
|
7210
|
+
const candidates = this.registry.findCandidates(proposal.raw);
|
|
7211
|
+
if (candidates.length === 0) {
|
|
7212
|
+
return {
|
|
7213
|
+
ok: false,
|
|
7214
|
+
errors: [{
|
|
7215
|
+
code: "IDEL_UNKNOWN_INTENT",
|
|
7216
|
+
message: `No intent found matching '${proposal.raw}'`
|
|
7217
|
+
}]
|
|
7218
|
+
};
|
|
7219
|
+
}
|
|
7220
|
+
const best = candidates[0];
|
|
7221
|
+
const schema = best.schema;
|
|
7222
|
+
const alternatives = candidates.slice(1, 4).filter((c) => c.score >= 0.3).map((c) => ({
|
|
7223
|
+
intent: c.schema.intent,
|
|
7224
|
+
confidence: c.score,
|
|
7225
|
+
reason: c.schema.description
|
|
7226
|
+
}));
|
|
7227
|
+
const constraints = [];
|
|
7228
|
+
const clarifications = [];
|
|
7229
|
+
const params = { ...proposal.params };
|
|
7230
|
+
for (const paramSchema of schema.params) {
|
|
7231
|
+
const value = params[paramSchema.name];
|
|
7232
|
+
if (paramSchema.required && value === void 0) {
|
|
7233
|
+
if (paramSchema.default !== void 0) {
|
|
7234
|
+
params[paramSchema.name] = paramSchema.default;
|
|
7235
|
+
constraints.push({
|
|
7236
|
+
kind: "required_param",
|
|
7237
|
+
field: paramSchema.name,
|
|
7238
|
+
description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,
|
|
7239
|
+
satisfied: true,
|
|
7240
|
+
value: paramSchema.default
|
|
7241
|
+
});
|
|
7242
|
+
} else {
|
|
7243
|
+
constraints.push({
|
|
7244
|
+
kind: "required_param",
|
|
7245
|
+
field: paramSchema.name,
|
|
7246
|
+
description: `Required parameter '${paramSchema.name}' is missing`,
|
|
7247
|
+
satisfied: false
|
|
7248
|
+
});
|
|
7249
|
+
clarifications.push({
|
|
7250
|
+
id: `clarify_${paramSchema.name}`,
|
|
7251
|
+
question: paramSchema.description ?? `What is the ${paramSchema.name}?`,
|
|
7252
|
+
field: paramSchema.name,
|
|
7253
|
+
options: paramSchema.enum?.map(String),
|
|
7254
|
+
required: true
|
|
7255
|
+
});
|
|
7256
|
+
}
|
|
7257
|
+
continue;
|
|
7258
|
+
}
|
|
7259
|
+
if (value === void 0) continue;
|
|
7260
|
+
const typeValid = validateType(value, paramSchema.type);
|
|
7261
|
+
constraints.push({
|
|
7262
|
+
kind: "type_check",
|
|
7263
|
+
field: paramSchema.name,
|
|
7264
|
+
description: `Must be ${paramSchema.type}`,
|
|
7265
|
+
satisfied: typeValid,
|
|
7266
|
+
value,
|
|
7267
|
+
expected: paramSchema.type
|
|
7268
|
+
});
|
|
7269
|
+
if (!typeValid) {
|
|
7270
|
+
errors.push({
|
|
7271
|
+
code: "IDEL_TYPE_ERROR",
|
|
7272
|
+
message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,
|
|
7273
|
+
field: paramSchema.name
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
if (paramSchema.min !== void 0 || paramSchema.max !== void 0) {
|
|
7277
|
+
const numVal = typeof value === "number" ? value : Number(value);
|
|
7278
|
+
const inRange = (paramSchema.min === void 0 || numVal >= paramSchema.min) && (paramSchema.max === void 0 || numVal <= paramSchema.max);
|
|
7279
|
+
constraints.push({
|
|
7280
|
+
kind: "range",
|
|
7281
|
+
field: paramSchema.name,
|
|
7282
|
+
description: `Must be between ${paramSchema.min ?? "-\u221E"} and ${paramSchema.max ?? "\u221E"}`,
|
|
7283
|
+
satisfied: inRange,
|
|
7284
|
+
value: numVal
|
|
7285
|
+
});
|
|
7286
|
+
}
|
|
7287
|
+
if (paramSchema.pattern) {
|
|
7288
|
+
const matches = new RegExp(paramSchema.pattern).test(String(value));
|
|
7289
|
+
constraints.push({
|
|
7290
|
+
kind: "pattern",
|
|
7291
|
+
field: paramSchema.name,
|
|
7292
|
+
description: `Must match ${paramSchema.pattern}`,
|
|
7293
|
+
satisfied: matches,
|
|
7294
|
+
value,
|
|
7295
|
+
expected: paramSchema.pattern
|
|
7296
|
+
});
|
|
7297
|
+
}
|
|
7298
|
+
if (paramSchema.enum) {
|
|
7299
|
+
const inEnum = paramSchema.enum.some(
|
|
7300
|
+
(e) => JSON.stringify(e) === JSON.stringify(value)
|
|
7301
|
+
);
|
|
7302
|
+
constraints.push({
|
|
7303
|
+
kind: "custom",
|
|
7304
|
+
field: paramSchema.name,
|
|
7305
|
+
description: `Must be one of: ${paramSchema.enum.join(", ")}`,
|
|
7306
|
+
satisfied: inEnum,
|
|
7307
|
+
value,
|
|
7308
|
+
expected: paramSchema.enum
|
|
7309
|
+
});
|
|
7310
|
+
}
|
|
7311
|
+
}
|
|
7312
|
+
const risk = assessRisk(schema, proposal, constraints);
|
|
7313
|
+
const unsatisfied = constraints.filter((c) => !c.satisfied);
|
|
7314
|
+
const needsClarification = clarifications.length > 0;
|
|
7315
|
+
let confidence = best.score;
|
|
7316
|
+
if (unsatisfied.length > 0) {
|
|
7317
|
+
confidence *= 1 - unsatisfied.length / Math.max(constraints.length, 1) * 0.5;
|
|
7318
|
+
}
|
|
7319
|
+
if (errors.length > 0) {
|
|
7320
|
+
confidence *= 0.5;
|
|
7321
|
+
}
|
|
7322
|
+
const compiled = {
|
|
7323
|
+
intent: schema.intent,
|
|
7324
|
+
actor_id: proposal.actor_id,
|
|
7325
|
+
target: proposal.target,
|
|
7326
|
+
params,
|
|
7327
|
+
constraints,
|
|
7328
|
+
confidence,
|
|
7329
|
+
alternatives,
|
|
7330
|
+
needs_clarification: needsClarification,
|
|
7331
|
+
clarifications,
|
|
7332
|
+
expected_outcome: schema.description,
|
|
7333
|
+
fallback: schema.related?.[0],
|
|
7334
|
+
risk,
|
|
7335
|
+
metadata: {
|
|
7336
|
+
schema_intent: schema.intent,
|
|
7337
|
+
resolved_from: proposal.raw,
|
|
7338
|
+
has_side_effects: schema.has_side_effects,
|
|
7339
|
+
reversible: schema.reversible
|
|
7340
|
+
}
|
|
7341
|
+
};
|
|
7342
|
+
return {
|
|
7343
|
+
ok: errors.length === 0 && !needsClarification,
|
|
7344
|
+
compiled,
|
|
7345
|
+
errors
|
|
7346
|
+
};
|
|
7347
|
+
}
|
|
7348
|
+
/**
|
|
7349
|
+
* Apply clarification answers and re-compile.
|
|
7350
|
+
*/
|
|
7351
|
+
applyClarifications(compiled, answers) {
|
|
7352
|
+
const proposal = {
|
|
7353
|
+
raw: compiled.intent,
|
|
7354
|
+
actor_id: compiled.actor_id,
|
|
7355
|
+
target: compiled.target,
|
|
7356
|
+
params: { ...compiled.params, ...answers }
|
|
7357
|
+
};
|
|
7358
|
+
return this.compile(proposal);
|
|
7359
|
+
}
|
|
7360
|
+
};
|
|
7361
|
+
}
|
|
7362
|
+
});
|
|
7363
|
+
|
|
7364
|
+
// src/needle/needle.engine.ts
|
|
7365
|
+
import { randomBytes as randomBytes8 } from "crypto";
|
|
7366
|
+
function assembleNeedle(params) {
|
|
7367
|
+
return {
|
|
7368
|
+
needle_id: randomBytes8(16).toString("hex"),
|
|
7369
|
+
phase: "created",
|
|
7370
|
+
tps_coordinate: params.tps_coordinate,
|
|
7371
|
+
intent: params.intent,
|
|
7372
|
+
presence: params.presence,
|
|
7373
|
+
writ: params.writ,
|
|
7374
|
+
grants: params.grants,
|
|
7375
|
+
created_at: Date.now()
|
|
7376
|
+
};
|
|
7377
|
+
}
|
|
7378
|
+
function classifyStitch(observation, verdict) {
|
|
7379
|
+
if (verdict.status === "failed" || verdict.status === "disputed") {
|
|
7380
|
+
return "torn";
|
|
7381
|
+
}
|
|
7382
|
+
if (observation.decision === "DENY") {
|
|
7383
|
+
return "silent";
|
|
7384
|
+
}
|
|
7385
|
+
if (verdict.isDeed) {
|
|
7386
|
+
return "deed";
|
|
7387
|
+
}
|
|
7388
|
+
return "silent";
|
|
7389
|
+
}
|
|
7390
|
+
function formStitch(needle, observation, verdict, receipt) {
|
|
7391
|
+
return {
|
|
7392
|
+
stitch_id: needle.needle_id,
|
|
7393
|
+
kind: classifyStitch(observation, verdict),
|
|
7394
|
+
intent: needle.intent.intent,
|
|
7395
|
+
actor_id: needle.intent.actor_id,
|
|
7396
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7397
|
+
observation,
|
|
7398
|
+
verdict,
|
|
7399
|
+
receipt,
|
|
7400
|
+
thread_id: receipt.thread_id,
|
|
7401
|
+
sequence: receipt.sequence,
|
|
7402
|
+
stitched_at: Date.now()
|
|
7403
|
+
};
|
|
7404
|
+
}
|
|
7405
|
+
async function runNeedlePipeline(needle, config, threadState, prevReceipt, expectedOutcome) {
|
|
7406
|
+
const obs = createObservation("http");
|
|
7407
|
+
obs.intent = needle.intent.intent;
|
|
7408
|
+
obs.actorId = needle.intent.actor_id;
|
|
7409
|
+
needle.phase = "validated";
|
|
7410
|
+
let stage = startStage(obs, "loom.validate");
|
|
7411
|
+
const validation = validateWrit(
|
|
7412
|
+
needle.writ,
|
|
7413
|
+
config.public_key,
|
|
7414
|
+
threadState,
|
|
7415
|
+
needle.grants
|
|
7416
|
+
);
|
|
7417
|
+
if (!validation.valid) {
|
|
7418
|
+
endStage(stage, "fail", validation.error);
|
|
7419
|
+
return failNeedle(needle, obs, "validated", "LOOM_VALIDATION_FAILED", validation.error ?? "Writ validation failed");
|
|
7420
|
+
}
|
|
7421
|
+
endStage(stage, "ok");
|
|
7422
|
+
if (config.sensors && config.sensors.length > 0) {
|
|
7423
|
+
stage = startStage(obs, "sensors.evaluate");
|
|
7424
|
+
const sensorInput = {
|
|
7425
|
+
intent: needle.intent.intent,
|
|
7426
|
+
actorId: needle.intent.actor_id,
|
|
7427
|
+
metadata: {
|
|
7428
|
+
observation: obs,
|
|
7429
|
+
needle_id: needle.needle_id,
|
|
7430
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7431
|
+
writ: needle.writ,
|
|
7432
|
+
grants: needle.grants,
|
|
7433
|
+
params: needle.intent.params
|
|
7434
|
+
}
|
|
7435
|
+
};
|
|
7436
|
+
for (const sensor of config.sensors) {
|
|
7437
|
+
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
7438
|
+
const t0 = Date.now();
|
|
7439
|
+
let decision;
|
|
7440
|
+
try {
|
|
7441
|
+
const rawDecision = await sensor.run(sensorInput);
|
|
7442
|
+
decision = normalizeSensorDecision(rawDecision);
|
|
7443
|
+
} catch (err) {
|
|
7444
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7445
|
+
recordSensor(obs, sensor.name, false, 100, Date.now() - t0, [`sensor_error:${msg}`]);
|
|
7446
|
+
endStage(stage, "fail", `Sensor ${sensor.name} threw: ${msg}`);
|
|
7447
|
+
return failNeedle(needle, obs, "validated", "SENSOR_ERROR", `Sensor ${sensor.name} failed: ${msg}`);
|
|
7448
|
+
}
|
|
7449
|
+
recordSensor(obs, sensor.name, decision.allow, decision.riskScore, Date.now() - t0, decision.reasons);
|
|
7450
|
+
if (!decision.allow) {
|
|
7451
|
+
endStage(stage, "fail", `Sensor ${sensor.name} denied`);
|
|
7452
|
+
return failNeedle(needle, obs, "validated", "SENSOR_DENY", decision.reasons[0] ?? `Denied by ${sensor.name}`);
|
|
7453
|
+
}
|
|
7454
|
+
}
|
|
7455
|
+
endStage(stage, "ok");
|
|
7456
|
+
}
|
|
7457
|
+
needle.phase = "executing";
|
|
7458
|
+
stage = startStage(obs, "handler.execute");
|
|
7459
|
+
const handler = config.handlers.get(needle.intent.intent);
|
|
7460
|
+
if (!handler) {
|
|
7461
|
+
endStage(stage, "fail", `No handler for intent '${needle.intent.intent}'`);
|
|
7462
|
+
return failNeedle(needle, obs, "executing", "NO_HANDLER", `No handler registered for intent '${needle.intent.intent}'`);
|
|
7463
|
+
}
|
|
7464
|
+
const handlerCtx = {
|
|
7465
|
+
needle_id: needle.needle_id,
|
|
7466
|
+
actor_id: needle.intent.actor_id,
|
|
7467
|
+
presence_id: needle.presence.presence_id,
|
|
7468
|
+
writ: needle.writ,
|
|
7469
|
+
grants: needle.grants,
|
|
7470
|
+
tps_coordinate: needle.tps_coordinate
|
|
7471
|
+
};
|
|
7472
|
+
let handlerResult;
|
|
7473
|
+
try {
|
|
7474
|
+
handlerResult = await handler(needle.intent, handlerCtx);
|
|
7475
|
+
} catch (err) {
|
|
7476
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7477
|
+
endStage(stage, "fail", msg);
|
|
7478
|
+
return failNeedle(needle, obs, "executing", "HANDLER_ERROR", msg);
|
|
7479
|
+
}
|
|
7480
|
+
if (!handlerResult.ok) {
|
|
7481
|
+
endStage(stage, "fail", handlerResult.effect);
|
|
7482
|
+
obs.decision = "DENY";
|
|
7483
|
+
obs.resultCode = handlerResult.effect;
|
|
7484
|
+
obs.statusCode = handlerResult.status_code ?? 400;
|
|
7485
|
+
} else {
|
|
7486
|
+
endStage(stage, "ok");
|
|
7487
|
+
obs.decision = "ALLOW";
|
|
7488
|
+
obs.resultCode = handlerResult.effect;
|
|
7489
|
+
obs.statusCode = handlerResult.status_code ?? 200;
|
|
7490
|
+
}
|
|
7491
|
+
if (handlerResult.data) {
|
|
7492
|
+
obs.facts = { ...obs.facts, ...handlerResult.data };
|
|
7493
|
+
}
|
|
7494
|
+
needle.phase = "observed";
|
|
7495
|
+
finalizeObservation(obs, obs.decision ?? "DENY", obs.statusCode ?? 500, obs.resultCode);
|
|
7496
|
+
needle.observation = obs;
|
|
7497
|
+
const verdict = scoreTruth(obs, expectedOutcome);
|
|
7498
|
+
needle.verdict = verdict;
|
|
7499
|
+
needle.phase = "stitched";
|
|
7500
|
+
stage = startStage(obs, "stitch.form");
|
|
7501
|
+
const receipt = createReceipt(
|
|
7502
|
+
needle.writ,
|
|
7503
|
+
obs.decision ?? "DENY",
|
|
7504
|
+
prevReceipt
|
|
7505
|
+
);
|
|
7506
|
+
needle.receipt = receipt;
|
|
7507
|
+
const newThreadState = updateThreadState(
|
|
7508
|
+
receipt,
|
|
7509
|
+
needle.intent.actor_id
|
|
7510
|
+
);
|
|
7511
|
+
const stitch = formStitch(needle, obs, verdict, receipt);
|
|
7512
|
+
needle.completed_at = Date.now();
|
|
7513
|
+
endStage(stage, "ok");
|
|
7514
|
+
return {
|
|
7515
|
+
ok: handlerResult.ok,
|
|
7516
|
+
needle,
|
|
7517
|
+
stitch,
|
|
7518
|
+
thread_state: newThreadState
|
|
7519
|
+
};
|
|
7520
|
+
}
|
|
7521
|
+
function failNeedle(needle, obs, phase, code, message) {
|
|
7522
|
+
needle.phase = "failed";
|
|
7523
|
+
needle.error = { phase, code, message };
|
|
7524
|
+
needle.completed_at = Date.now();
|
|
7525
|
+
obs.decision = obs.decision ?? "DENY";
|
|
7526
|
+
obs.statusCode = obs.statusCode ?? 500;
|
|
7527
|
+
finalizeObservation(obs, obs.decision, obs.statusCode, obs.resultCode);
|
|
7528
|
+
needle.observation = obs;
|
|
7529
|
+
const verdict = scoreTruth(obs);
|
|
7530
|
+
needle.verdict = verdict;
|
|
7531
|
+
return {
|
|
7532
|
+
ok: false,
|
|
7533
|
+
needle
|
|
7534
|
+
};
|
|
7535
|
+
}
|
|
7536
|
+
var init_needle_engine = __esm({
|
|
7537
|
+
"src/needle/needle.engine.ts"() {
|
|
7538
|
+
init_axis_observation();
|
|
7539
|
+
init_truth_scoring();
|
|
7540
|
+
init_loom_engine();
|
|
7541
|
+
init_axis_sensor();
|
|
7542
|
+
}
|
|
7543
|
+
});
|
|
7544
|
+
|
|
7545
|
+
// src/needle/knot.engine.ts
|
|
7546
|
+
import { createHash as createHash8, randomBytes as randomBytes9 } from "crypto";
|
|
7547
|
+
function openKnot(params) {
|
|
7548
|
+
const isIrreversible = params.type === "irreversible";
|
|
7549
|
+
return {
|
|
7550
|
+
knot_id: `knot_${randomBytes9(16).toString("hex")}`,
|
|
7551
|
+
type: params.type,
|
|
7552
|
+
status: "open",
|
|
7553
|
+
stitch_ids: [],
|
|
7554
|
+
thread_id: params.thread_id,
|
|
7555
|
+
tps_anchor: params.tps_anchor,
|
|
7556
|
+
irreversible: isIrreversible,
|
|
7557
|
+
capsule_id: params.capsule_id,
|
|
7558
|
+
law_ref: params.law_ref,
|
|
7559
|
+
branch_ids: [],
|
|
7560
|
+
required_count: params.required_count,
|
|
7561
|
+
all_or_nothing: params.all_or_nothing ?? (params.type === "authority" || isIrreversible),
|
|
7562
|
+
actor_id: params.actor_id,
|
|
7563
|
+
created_at: Date.now()
|
|
7564
|
+
};
|
|
7565
|
+
}
|
|
7566
|
+
function addStitchToKnot(knot, stitch) {
|
|
7567
|
+
if (knot.status !== "open") {
|
|
7568
|
+
return `Knot ${knot.knot_id} is ${knot.status}, cannot add stitches`;
|
|
7569
|
+
}
|
|
7570
|
+
if (stitch.thread_id !== knot.thread_id) {
|
|
7571
|
+
return `Stitch thread ${stitch.thread_id} does not match knot thread ${knot.thread_id}`;
|
|
7572
|
+
}
|
|
7573
|
+
if (knot.stitch_ids.includes(stitch.stitch_id)) {
|
|
7574
|
+
return `Stitch ${stitch.stitch_id} already in knot`;
|
|
7575
|
+
}
|
|
7576
|
+
if (knot.type === "authority" && knot.capsule_id) {
|
|
7577
|
+
if (stitch.observation.capsuleId && stitch.observation.capsuleId !== knot.capsule_id) {
|
|
7578
|
+
return `Stitch capsule ${stitch.observation.capsuleId} does not match knot capsule ${knot.capsule_id}`;
|
|
7579
|
+
}
|
|
7580
|
+
}
|
|
7581
|
+
knot.stitch_ids.push(stitch.stitch_id);
|
|
7582
|
+
return null;
|
|
7583
|
+
}
|
|
7584
|
+
function validateKnot(knot, stitches) {
|
|
7585
|
+
const errors = [];
|
|
7586
|
+
const passedIds = [];
|
|
7587
|
+
const failedIds = [];
|
|
7588
|
+
const stitchMap = new Map(stitches.map((s) => [s.stitch_id, s]));
|
|
7589
|
+
for (const sid of knot.stitch_ids) {
|
|
7590
|
+
const stitch = stitchMap.get(sid);
|
|
7591
|
+
if (!stitch) {
|
|
7592
|
+
failedIds.push(sid);
|
|
7593
|
+
errors.push({
|
|
7594
|
+
code: "KNOT_MISSING_STITCH",
|
|
7595
|
+
message: `Stitch ${sid} not found`,
|
|
7596
|
+
stitch_id: sid
|
|
7597
|
+
});
|
|
7598
|
+
continue;
|
|
7599
|
+
}
|
|
7600
|
+
if (stitch.kind === "torn") {
|
|
7601
|
+
failedIds.push(sid);
|
|
7602
|
+
errors.push({
|
|
7603
|
+
code: "KNOT_TORN_STITCH",
|
|
7604
|
+
message: `Stitch ${sid} is torn (failed/disputed)`,
|
|
7605
|
+
stitch_id: sid
|
|
7606
|
+
});
|
|
7607
|
+
continue;
|
|
7608
|
+
}
|
|
7609
|
+
if (knot.type === "irreversible" && stitch.kind !== "deed") {
|
|
7610
|
+
failedIds.push(sid);
|
|
7611
|
+
errors.push({
|
|
7612
|
+
code: "KNOT_REQUIRES_DEED",
|
|
7613
|
+
message: `Irreversible knot requires deed stitch, got '${stitch.kind}'`,
|
|
7614
|
+
stitch_id: sid
|
|
7615
|
+
});
|
|
7616
|
+
continue;
|
|
7617
|
+
}
|
|
7618
|
+
passedIds.push(sid);
|
|
7619
|
+
}
|
|
7620
|
+
if (knot.required_count !== void 0 && knot.stitch_ids.length < knot.required_count) {
|
|
7621
|
+
errors.push({
|
|
7622
|
+
code: "KNOT_INSUFFICIENT_STITCHES",
|
|
7623
|
+
message: `Knot requires ${knot.required_count} stitches, has ${knot.stitch_ids.length}`
|
|
7624
|
+
});
|
|
7625
|
+
}
|
|
7626
|
+
const allPassed = failedIds.length === 0;
|
|
7627
|
+
const canTie = knot.all_or_nothing ? allPassed && (knot.required_count === void 0 || knot.stitch_ids.length >= knot.required_count) : passedIds.length > 0 && (knot.required_count === void 0 || passedIds.length >= knot.required_count);
|
|
7628
|
+
return {
|
|
7629
|
+
valid: allPassed && errors.length === 0,
|
|
7630
|
+
passed_stitch_ids: passedIds,
|
|
7631
|
+
failed_stitch_ids: failedIds,
|
|
7632
|
+
can_tie: canTie,
|
|
7633
|
+
errors
|
|
7634
|
+
};
|
|
7635
|
+
}
|
|
7636
|
+
function tieKnot(knot, stitches) {
|
|
7637
|
+
const validation = validateKnot(knot, stitches);
|
|
7638
|
+
if (!validation.can_tie) {
|
|
7639
|
+
return { ...validation, knot };
|
|
7640
|
+
}
|
|
7641
|
+
const receiptHashes = validation.passed_stitch_ids.map((sid) => stitches.find((s) => s.stitch_id === sid)).sort((a, b) => a.sequence - b.sequence).map((s) => s.receipt.hash);
|
|
7642
|
+
const witnessPayload = receiptHashes.join(":");
|
|
7643
|
+
knot.witness_hash = createHash8("sha256").update(witnessPayload).digest("hex");
|
|
7644
|
+
knot.status = "tied";
|
|
7645
|
+
knot.tied_at = Date.now();
|
|
7646
|
+
return { ...validation, knot };
|
|
7647
|
+
}
|
|
7648
|
+
function breakKnot(knot, request) {
|
|
7649
|
+
if (knot.status === "broken") {
|
|
7650
|
+
return { ok: false, error: "Knot is already broken" };
|
|
7651
|
+
}
|
|
7652
|
+
if (knot.status === "open") {
|
|
7653
|
+
knot.status = "broken";
|
|
7654
|
+
knot.broken_at = Date.now();
|
|
7655
|
+
knot.break_reason = request.reason;
|
|
7656
|
+
return { ok: true };
|
|
7657
|
+
}
|
|
7658
|
+
if (knot.status === "tied") {
|
|
7659
|
+
if (!request.reason) {
|
|
7660
|
+
return { ok: false, error: "Breaking a tied knot requires a reason" };
|
|
7661
|
+
}
|
|
7662
|
+
if ((knot.irreversible || knot.type === "law") && !request.override_grant_id) {
|
|
7663
|
+
return {
|
|
7664
|
+
ok: false,
|
|
7665
|
+
error: `Breaking ${knot.type} knot requires override_grant_id from higher authority`
|
|
7666
|
+
};
|
|
7667
|
+
}
|
|
7668
|
+
knot.status = "broken";
|
|
7669
|
+
knot.broken_at = Date.now();
|
|
7670
|
+
knot.break_reason = request.reason;
|
|
7671
|
+
return { ok: true };
|
|
7672
|
+
}
|
|
7673
|
+
return { ok: false, error: `Cannot break knot in status '${knot.status}'` };
|
|
7674
|
+
}
|
|
7675
|
+
function forkFromKnot(knot, branchId, decisionStitchId) {
|
|
7676
|
+
if (knot.status !== "tied" && knot.status !== "open") {
|
|
7677
|
+
return { ok: false, error: `Cannot fork from knot in status '${knot.status}'` };
|
|
7678
|
+
}
|
|
7679
|
+
if (decisionStitchId) {
|
|
7680
|
+
if (!knot.stitch_ids.includes(decisionStitchId)) {
|
|
7681
|
+
return { ok: false, error: `Decision stitch ${decisionStitchId} is not part of this knot` };
|
|
7682
|
+
}
|
|
7683
|
+
knot.decision_stitch_id = decisionStitchId;
|
|
7684
|
+
}
|
|
7685
|
+
knot.branch_ids.push(branchId);
|
|
7686
|
+
knot.status = "forked";
|
|
7687
|
+
return { ok: true };
|
|
7688
|
+
}
|
|
7689
|
+
function isKnotOpen(knot) {
|
|
7690
|
+
return knot.status === "open";
|
|
7691
|
+
}
|
|
7692
|
+
function isPointOfNoReturn(knot) {
|
|
7693
|
+
return knot.irreversible && knot.status === "tied";
|
|
7694
|
+
}
|
|
7695
|
+
function findKnotsForStitch(stitchId, knots) {
|
|
7696
|
+
return knots.filter((k) => k.stitch_ids.includes(stitchId));
|
|
7697
|
+
}
|
|
7698
|
+
function getIrreversibleKnots(knots) {
|
|
7699
|
+
return knots.filter((k) => k.irreversible && k.status === "tied");
|
|
7700
|
+
}
|
|
7701
|
+
function getDecisionPoints(knots) {
|
|
7702
|
+
return knots.filter((k) => k.type === "decision" || k.status === "forked");
|
|
7703
|
+
}
|
|
7704
|
+
var init_knot_engine = __esm({
|
|
7705
|
+
"src/needle/knot.engine.ts"() {
|
|
7706
|
+
}
|
|
7707
|
+
});
|
|
7708
|
+
|
|
7709
|
+
// src/needle/fabric.engine.ts
|
|
7710
|
+
import { createHash as createHash9, randomBytes as randomBytes10 } from "crypto";
|
|
7711
|
+
function createFabric() {
|
|
7712
|
+
return {
|
|
7713
|
+
fabric_id: `fab_${randomBytes10(16).toString("hex")}`,
|
|
7714
|
+
state_hash: hashState(/* @__PURE__ */ new Map()),
|
|
7715
|
+
cells: /* @__PURE__ */ new Map(),
|
|
7716
|
+
thread_ids: [],
|
|
7717
|
+
stitch_count: 0,
|
|
7718
|
+
knot_count: 0,
|
|
7719
|
+
computed_at: Date.now(),
|
|
7720
|
+
version: 0
|
|
7721
|
+
};
|
|
7722
|
+
}
|
|
7723
|
+
function applyStitch(fabric, stitch, effect) {
|
|
7724
|
+
for (const [key, value] of Object.entries(effect.mutations)) {
|
|
7725
|
+
if (value === null) {
|
|
7726
|
+
fabric.cells.delete(key);
|
|
7727
|
+
} else {
|
|
7728
|
+
const existing = fabric.cells.get(key);
|
|
7729
|
+
if (existing?.locked) {
|
|
7730
|
+
continue;
|
|
7731
|
+
}
|
|
7732
|
+
fabric.cells.set(key, {
|
|
7733
|
+
key,
|
|
7734
|
+
value,
|
|
7735
|
+
last_stitch_id: stitch.stitch_id,
|
|
7736
|
+
last_tps: stitch.tps_coordinate,
|
|
7737
|
+
write_count: (existing?.write_count ?? 0) + 1,
|
|
7738
|
+
locked: false
|
|
7739
|
+
});
|
|
7740
|
+
}
|
|
7741
|
+
}
|
|
7742
|
+
if (!fabric.thread_ids.includes(stitch.thread_id)) {
|
|
7743
|
+
fabric.thread_ids.push(stitch.thread_id);
|
|
7744
|
+
}
|
|
7745
|
+
fabric.stitch_count++;
|
|
7746
|
+
fabric.version++;
|
|
7747
|
+
fabric.projected_at_tps = stitch.tps_coordinate ?? fabric.projected_at_tps;
|
|
7748
|
+
fabric.computed_at = Date.now();
|
|
7749
|
+
fabric.state_hash = hashState(fabric.cells);
|
|
7750
|
+
}
|
|
7751
|
+
function weave(stitches, resolver, knots) {
|
|
7752
|
+
const fabric = createFabric();
|
|
7753
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
7754
|
+
for (const stitch of sorted) {
|
|
7755
|
+
if (stitch.kind === "torn") continue;
|
|
7756
|
+
const effect = resolver(stitch);
|
|
7757
|
+
applyStitch(fabric, stitch, effect);
|
|
7758
|
+
}
|
|
7759
|
+
if (knots) {
|
|
7760
|
+
for (const knot of knots) {
|
|
7761
|
+
if (knot.irreversible && knot.status === "tied") {
|
|
7762
|
+
lockCellsByKnot(fabric, knot, stitches, resolver);
|
|
7763
|
+
fabric.knot_count++;
|
|
7764
|
+
}
|
|
7765
|
+
}
|
|
7766
|
+
}
|
|
7767
|
+
return fabric;
|
|
7768
|
+
}
|
|
7769
|
+
function projectAt(stitches, resolver, tpsFilter, knots) {
|
|
7770
|
+
const filtered = stitches.filter((s) => tpsFilter(s.tps_coordinate));
|
|
7771
|
+
return weave(filtered, resolver, knots);
|
|
7772
|
+
}
|
|
7773
|
+
function lockCellsByKnot(fabric, knot, stitches, resolver) {
|
|
7774
|
+
const knotStitchIds = new Set(knot.stitch_ids);
|
|
7775
|
+
const knotStitches = stitches.filter((s) => knotStitchIds.has(s.stitch_id));
|
|
7776
|
+
for (const stitch of knotStitches) {
|
|
7777
|
+
const effect = resolver(stitch);
|
|
7778
|
+
for (const key of Object.keys(effect.mutations)) {
|
|
7779
|
+
const cell = fabric.cells.get(key);
|
|
7780
|
+
if (cell) {
|
|
7781
|
+
cell.locked = true;
|
|
7782
|
+
cell.locked_by_knot = knot.knot_id;
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7787
|
+
function lockCells(fabric, keys, knotId) {
|
|
7788
|
+
for (const key of keys) {
|
|
7789
|
+
const cell = fabric.cells.get(key);
|
|
7790
|
+
if (cell) {
|
|
7791
|
+
cell.locked = true;
|
|
7792
|
+
cell.locked_by_knot = knotId;
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
function queryFabric(fabric, query) {
|
|
7797
|
+
let results = [...fabric.cells.values()];
|
|
7798
|
+
if (query.keys) {
|
|
7799
|
+
const keySet = new Set(query.keys);
|
|
7800
|
+
results = results.filter((c) => keySet.has(c.key));
|
|
7801
|
+
}
|
|
7802
|
+
if (query.prefix) {
|
|
7803
|
+
const prefix = query.prefix;
|
|
7804
|
+
results = results.filter((c) => c.key.startsWith(prefix));
|
|
7805
|
+
}
|
|
7806
|
+
if (query.locked_only) {
|
|
7807
|
+
results = results.filter((c) => c.locked);
|
|
7808
|
+
}
|
|
7809
|
+
return results;
|
|
7810
|
+
}
|
|
7811
|
+
function getFabricValue(fabric, key) {
|
|
7812
|
+
return fabric.cells.get(key)?.value;
|
|
7813
|
+
}
|
|
7814
|
+
function diffFabrics(a, b) {
|
|
7815
|
+
const entries = [];
|
|
7816
|
+
let added = 0;
|
|
7817
|
+
let modified = 0;
|
|
7818
|
+
let deleted = 0;
|
|
7819
|
+
for (const [key, cellB] of b.cells) {
|
|
7820
|
+
const cellA = a.cells.get(key);
|
|
7821
|
+
if (!cellA) {
|
|
7822
|
+
entries.push({
|
|
7823
|
+
key,
|
|
7824
|
+
kind: "added",
|
|
7825
|
+
after: cellB.value,
|
|
7826
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
7827
|
+
});
|
|
7828
|
+
added++;
|
|
7829
|
+
} else if (JSON.stringify(cellA.value) !== JSON.stringify(cellB.value)) {
|
|
7830
|
+
entries.push({
|
|
7831
|
+
key,
|
|
7832
|
+
kind: "modified",
|
|
7833
|
+
before: cellA.value,
|
|
7834
|
+
after: cellB.value,
|
|
7835
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
7836
|
+
});
|
|
7837
|
+
modified++;
|
|
7838
|
+
}
|
|
7839
|
+
}
|
|
7840
|
+
for (const [key, cellA] of a.cells) {
|
|
7841
|
+
if (!b.cells.has(key)) {
|
|
7842
|
+
entries.push({
|
|
7843
|
+
key,
|
|
7844
|
+
kind: "deleted",
|
|
7845
|
+
before: cellA.value
|
|
7846
|
+
});
|
|
7847
|
+
deleted++;
|
|
7848
|
+
}
|
|
7849
|
+
}
|
|
7850
|
+
return {
|
|
7851
|
+
from_fabric_id: a.fabric_id,
|
|
7852
|
+
to_fabric_id: b.fabric_id,
|
|
7853
|
+
entries,
|
|
7854
|
+
added_count: added,
|
|
7855
|
+
modified_count: modified,
|
|
7856
|
+
deleted_count: deleted
|
|
7857
|
+
};
|
|
7858
|
+
}
|
|
7859
|
+
function hashState(cells) {
|
|
7860
|
+
const keys = [...cells.keys()].sort();
|
|
7861
|
+
const payload = keys.map((k) => `${k}=${JSON.stringify(cells.get(k).value)}`).join("\n");
|
|
7862
|
+
return createHash9("sha256").update(payload).digest("hex");
|
|
7863
|
+
}
|
|
7864
|
+
var init_fabric_engine = __esm({
|
|
7865
|
+
"src/needle/fabric.engine.ts"() {
|
|
7866
|
+
}
|
|
7867
|
+
});
|
|
7868
|
+
|
|
7869
|
+
// src/needle/pattern.engine.ts
|
|
7870
|
+
import { randomBytes as randomBytes11 } from "crypto";
|
|
7871
|
+
function detectSequencePatterns(stitches, windowSize, minOccurrences) {
|
|
7872
|
+
if (stitches.length < windowSize || windowSize < 2) return [];
|
|
7873
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
7874
|
+
const sequenceCounts = /* @__PURE__ */ new Map();
|
|
7875
|
+
for (let i = 0; i <= sorted.length - windowSize; i++) {
|
|
7876
|
+
const window = sorted.slice(i, i + windowSize);
|
|
7877
|
+
const key = window.map((s) => s.intent).join("\u2192");
|
|
7878
|
+
const ids = window.map((s) => s.stitch_id);
|
|
7879
|
+
const existing = sequenceCounts.get(key);
|
|
7880
|
+
if (existing) {
|
|
7881
|
+
existing.count++;
|
|
7882
|
+
existing.stitch_ids.push(ids);
|
|
7883
|
+
} else {
|
|
7884
|
+
sequenceCounts.set(key, { count: 1, stitch_ids: [ids] });
|
|
7885
|
+
}
|
|
7886
|
+
}
|
|
7887
|
+
const patterns = [];
|
|
7888
|
+
const now = Date.now();
|
|
7889
|
+
for (const [key, data] of sequenceCounts) {
|
|
7890
|
+
if (data.count < minOccurrences) continue;
|
|
7891
|
+
const intents = key.split("\u2192");
|
|
7892
|
+
const confidence = Math.min(data.count / (minOccurrences * 2), 1);
|
|
7893
|
+
patterns.push({
|
|
7894
|
+
pattern_id: `pat_seq_${randomBytes11(8).toString("hex")}`,
|
|
7895
|
+
kind: "sequence",
|
|
7896
|
+
name: `Sequence: ${intents.join(" \u2192 ")}`,
|
|
7897
|
+
signature: {
|
|
7898
|
+
intent_sequence: intents,
|
|
7899
|
+
min_length: windowSize,
|
|
7900
|
+
max_length: windowSize
|
|
7901
|
+
},
|
|
7902
|
+
confidence,
|
|
7903
|
+
occurrence_count: data.count,
|
|
7904
|
+
first_seen_at: now,
|
|
7905
|
+
last_seen_at: now,
|
|
7906
|
+
seen_in_threads: [...new Set(
|
|
7907
|
+
data.stitch_ids.flatMap(
|
|
7908
|
+
(ids) => ids.map((id) => sorted.find((s) => s.stitch_id === id)?.thread_id).filter(Boolean)
|
|
7909
|
+
)
|
|
7910
|
+
)],
|
|
7911
|
+
classification: "unclassified"
|
|
7912
|
+
});
|
|
7913
|
+
}
|
|
7914
|
+
return patterns;
|
|
7915
|
+
}
|
|
7916
|
+
function detectKnotPatterns(knots, minOccurrences) {
|
|
7917
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7918
|
+
for (const knot of knots) {
|
|
7919
|
+
if (knot.status !== "tied") continue;
|
|
7920
|
+
const key = `${knot.type}:${knot.stitch_ids.length}`;
|
|
7921
|
+
const group = groups.get(key) ?? [];
|
|
7922
|
+
group.push(knot);
|
|
7923
|
+
groups.set(key, group);
|
|
7924
|
+
}
|
|
7925
|
+
const patterns = [];
|
|
7926
|
+
const now = Date.now();
|
|
7927
|
+
for (const [key, group] of groups) {
|
|
7928
|
+
if (group.length < minOccurrences) continue;
|
|
7929
|
+
const [type, sizeStr] = key.split(":");
|
|
7930
|
+
const size = parseInt(sizeStr, 10);
|
|
7931
|
+
const confidence = Math.min(group.length / (minOccurrences * 2), 1);
|
|
7932
|
+
patterns.push({
|
|
7933
|
+
pattern_id: `pat_knot_${randomBytes11(8).toString("hex")}`,
|
|
7934
|
+
kind: "knot",
|
|
7935
|
+
name: `Knot: ${type} (${size} stitches)`,
|
|
7936
|
+
signature: {
|
|
7937
|
+
knot_type: type,
|
|
7938
|
+
knot_size: size
|
|
7939
|
+
},
|
|
7940
|
+
confidence,
|
|
7941
|
+
occurrence_count: group.length,
|
|
7942
|
+
first_seen_at: now,
|
|
7943
|
+
last_seen_at: now,
|
|
7944
|
+
seen_in_threads: [...new Set(group.map((k) => k.thread_id))],
|
|
7945
|
+
classification: "unclassified"
|
|
7946
|
+
});
|
|
7947
|
+
}
|
|
7948
|
+
return patterns;
|
|
7949
|
+
}
|
|
7950
|
+
function matchPatterns(stitches, patterns) {
|
|
7951
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
7952
|
+
const matches = [];
|
|
7953
|
+
const now = Date.now();
|
|
7954
|
+
for (const pattern of patterns) {
|
|
7955
|
+
if (pattern.kind === "sequence" && pattern.signature.intent_sequence) {
|
|
7956
|
+
const seq = pattern.signature.intent_sequence;
|
|
7957
|
+
const seqLen = seq.length;
|
|
7958
|
+
for (let i = 0; i <= sorted.length - seqLen; i++) {
|
|
7959
|
+
const window = sorted.slice(i, i + seqLen);
|
|
7960
|
+
const windowIntents = window.map((s) => s.intent);
|
|
7961
|
+
if (windowIntents.every((intent, idx) => intent === seq[idx])) {
|
|
7962
|
+
matches.push({
|
|
7963
|
+
pattern_id: pattern.pattern_id,
|
|
7964
|
+
matched_stitch_ids: window.map((s) => s.stitch_id),
|
|
7965
|
+
match_score: 1,
|
|
7966
|
+
thread_id: window[0].thread_id,
|
|
7967
|
+
detected_at: now
|
|
7968
|
+
});
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
}
|
|
7973
|
+
return matches;
|
|
7974
|
+
}
|
|
7975
|
+
function recordOccurrence(pattern, threadId) {
|
|
7976
|
+
pattern.occurrence_count++;
|
|
7977
|
+
pattern.last_seen_at = Date.now();
|
|
7978
|
+
pattern.confidence = 1 - 1 / (1 + pattern.occurrence_count * 0.5);
|
|
7979
|
+
if (!pattern.seen_in_threads.includes(threadId)) {
|
|
7980
|
+
pattern.seen_in_threads.push(threadId);
|
|
7981
|
+
}
|
|
7982
|
+
}
|
|
7983
|
+
function detectAnomalies(recentStitches, knownPatterns, threshold = 0.7) {
|
|
7984
|
+
const anomalies = [];
|
|
7985
|
+
const sorted = [...recentStitches].sort((a, b) => a.sequence - b.sequence);
|
|
7986
|
+
const now = Date.now();
|
|
7987
|
+
for (const pattern of knownPatterns) {
|
|
7988
|
+
if (pattern.kind !== "sequence" || !pattern.signature.intent_sequence) continue;
|
|
7989
|
+
if (pattern.confidence < threshold) continue;
|
|
7990
|
+
const seq = pattern.signature.intent_sequence;
|
|
7991
|
+
if (sorted.length >= 1 && sorted.length < seq.length) {
|
|
7992
|
+
const partialMatch = sorted.every(
|
|
7993
|
+
(s, i) => i < seq.length && s.intent === seq[i]
|
|
7994
|
+
);
|
|
7995
|
+
if (partialMatch) {
|
|
7996
|
+
const expectedNext = seq[sorted.length];
|
|
7997
|
+
const lastStitch = sorted[sorted.length - 1];
|
|
7998
|
+
if (pattern.occurrence_count >= 3) {
|
|
7999
|
+
anomalies.push({
|
|
8000
|
+
pattern_id: `pat_anom_${randomBytes11(8).toString("hex")}`,
|
|
8001
|
+
kind: "anomaly",
|
|
8002
|
+
name: `Incomplete: ${pattern.name}`,
|
|
8003
|
+
description: `Expected '${expectedNext}' after '${lastStitch.intent}' based on pattern '${pattern.name}'`,
|
|
8004
|
+
signature: pattern.signature,
|
|
8005
|
+
confidence: pattern.confidence * 0.8,
|
|
8006
|
+
occurrence_count: 1,
|
|
8007
|
+
first_seen_at: now,
|
|
8008
|
+
last_seen_at: now,
|
|
8009
|
+
seen_in_threads: [lastStitch.thread_id],
|
|
8010
|
+
classification: "anomalous"
|
|
8011
|
+
});
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8015
|
+
}
|
|
8016
|
+
return anomalies;
|
|
8017
|
+
}
|
|
8018
|
+
var InMemoryPatternStore;
|
|
8019
|
+
var init_pattern_engine = __esm({
|
|
8020
|
+
"src/needle/pattern.engine.ts"() {
|
|
8021
|
+
InMemoryPatternStore = class {
|
|
8022
|
+
constructor() {
|
|
8023
|
+
this.patterns = /* @__PURE__ */ new Map();
|
|
8024
|
+
}
|
|
8025
|
+
save(pattern) {
|
|
8026
|
+
this.patterns.set(pattern.pattern_id, pattern);
|
|
8027
|
+
}
|
|
8028
|
+
get(patternId) {
|
|
8029
|
+
return this.patterns.get(patternId);
|
|
8030
|
+
}
|
|
8031
|
+
findByKind(kind) {
|
|
8032
|
+
return [...this.patterns.values()].filter((p) => p.kind === kind);
|
|
8033
|
+
}
|
|
8034
|
+
findByIntent(intent) {
|
|
8035
|
+
return [...this.patterns.values()].filter(
|
|
8036
|
+
(p) => p.signature.intent_sequence?.includes(intent)
|
|
8037
|
+
);
|
|
8038
|
+
}
|
|
8039
|
+
all() {
|
|
8040
|
+
return [...this.patterns.values()];
|
|
8041
|
+
}
|
|
8042
|
+
};
|
|
8043
|
+
}
|
|
8044
|
+
});
|
|
8045
|
+
|
|
8046
|
+
// src/sensors/tps.sensor.ts
|
|
8047
|
+
var require_tps_sensor = __commonJS({
|
|
8048
|
+
"src/sensors/tps.sensor.ts"(exports) {
|
|
8049
|
+
"use strict";
|
|
8050
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8051
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8052
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8053
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8054
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8055
|
+
};
|
|
8056
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8057
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8058
|
+
};
|
|
8059
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8060
|
+
exports.TpsSensor = void 0;
|
|
8061
|
+
var common_1 = __require("@nestjs/common");
|
|
8062
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8063
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8064
|
+
var TPS_EPOCH_MS = 9343548e5;
|
|
8065
|
+
function parseINotation(tps) {
|
|
8066
|
+
if (!tps.startsWith("i"))
|
|
8067
|
+
return null;
|
|
8068
|
+
const num = Number(tps.slice(1));
|
|
8069
|
+
if (!Number.isFinite(num))
|
|
8070
|
+
return null;
|
|
8071
|
+
return TPS_EPOCH_MS + num;
|
|
8072
|
+
}
|
|
8073
|
+
var TpsSensor2 = class TpsSensor {
|
|
8074
|
+
constructor(options = {}) {
|
|
8075
|
+
this.name = "TpsSensor";
|
|
8076
|
+
this.order = sensor_bands_1.BAND.POLICY + 2;
|
|
8077
|
+
this.maxDriftMs = options.maxDriftMs ?? 3e4;
|
|
8078
|
+
this.resolver = options.resolver ?? parseINotation;
|
|
8079
|
+
}
|
|
8080
|
+
supports(input) {
|
|
8081
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8082
|
+
return typeof tps === "string" && tps.length > 0;
|
|
8083
|
+
}
|
|
8084
|
+
async run(input) {
|
|
8085
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8086
|
+
const resolved = this.resolver(tps);
|
|
8087
|
+
if (resolved === null) {
|
|
8088
|
+
return {
|
|
8089
|
+
allow: false,
|
|
8090
|
+
riskScore: 80,
|
|
8091
|
+
reasons: [`TPS coordinate '${tps}' is structurally invalid`],
|
|
8092
|
+
code: "TPS_INVALID_FORMAT"
|
|
8093
|
+
};
|
|
8094
|
+
}
|
|
8095
|
+
const now = Date.now();
|
|
8096
|
+
const drift = Math.abs(now - resolved);
|
|
8097
|
+
if (drift > this.maxDriftMs) {
|
|
8098
|
+
const direction = resolved > now ? "future" : "past";
|
|
8099
|
+
return {
|
|
8100
|
+
allow: false,
|
|
8101
|
+
riskScore: 70,
|
|
8102
|
+
reasons: [
|
|
8103
|
+
`TPS drift ${drift}ms exceeds max ${this.maxDriftMs}ms (${direction})`
|
|
8104
|
+
],
|
|
8105
|
+
code: "TPS_DRIFT_EXCEEDED",
|
|
8106
|
+
tags: { tpsDriftMs: drift, tpsDirection: direction }
|
|
8107
|
+
};
|
|
8108
|
+
}
|
|
8109
|
+
return {
|
|
8110
|
+
allow: true,
|
|
8111
|
+
riskScore: 0,
|
|
8112
|
+
reasons: [],
|
|
8113
|
+
tags: {
|
|
8114
|
+
tpsResolved: resolved,
|
|
8115
|
+
tpsDriftMs: drift
|
|
8116
|
+
}
|
|
8117
|
+
};
|
|
8118
|
+
}
|
|
8119
|
+
};
|
|
8120
|
+
exports.TpsSensor = TpsSensor2;
|
|
8121
|
+
exports.TpsSensor = TpsSensor2 = __decorate([
|
|
8122
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8123
|
+
(0, common_1.Injectable)(),
|
|
8124
|
+
__metadata("design:paramtypes", [Object])
|
|
8125
|
+
], TpsSensor2);
|
|
8126
|
+
}
|
|
8127
|
+
});
|
|
8128
|
+
|
|
8129
|
+
// src/sensors/risk-gate.sensor.ts
|
|
8130
|
+
var require_risk_gate_sensor = __commonJS({
|
|
8131
|
+
"src/sensors/risk-gate.sensor.ts"(exports) {
|
|
8132
|
+
"use strict";
|
|
8133
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8134
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8135
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8136
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8137
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8138
|
+
};
|
|
8139
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8140
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8141
|
+
};
|
|
8142
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8143
|
+
exports.RiskGateSensor = void 0;
|
|
8144
|
+
var common_1 = __require("@nestjs/common");
|
|
8145
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8146
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8147
|
+
var risk_1 = (init_risk(), __toCommonJS(risk_exports));
|
|
8148
|
+
var SEVERITY_WEIGHT = {
|
|
8149
|
+
low: 10,
|
|
8150
|
+
medium: 25,
|
|
8151
|
+
high: 50,
|
|
8152
|
+
critical: 100
|
|
8153
|
+
};
|
|
8154
|
+
var RiskGateSensor2 = class RiskGateSensor {
|
|
8155
|
+
constructor(options) {
|
|
8156
|
+
this.name = "RiskGateSensor";
|
|
8157
|
+
this.order = sensor_bands_1.BAND.BUSINESS + 10;
|
|
8158
|
+
this.collectors = options.collectors;
|
|
8159
|
+
this.denyThreshold = options.denyThreshold ?? 75;
|
|
8160
|
+
this.flagThreshold = options.flagThreshold ?? 40;
|
|
8161
|
+
}
|
|
8162
|
+
async run(input) {
|
|
8163
|
+
const results = await Promise.all(this.collectors.map((c) => c(input)));
|
|
8164
|
+
const signals = results.flat();
|
|
8165
|
+
let totalWeight = 0;
|
|
8166
|
+
let weightedSum = 0;
|
|
8167
|
+
for (const signal of signals) {
|
|
8168
|
+
const w = SEVERITY_WEIGHT[signal.severity];
|
|
8169
|
+
totalWeight += 1;
|
|
8170
|
+
weightedSum += w;
|
|
8171
|
+
}
|
|
8172
|
+
const aggregateScore = totalWeight > 0 ? Math.min(100, Math.round(weightedSum / totalWeight)) : 0;
|
|
8173
|
+
const evaluation = this.evaluate(aggregateScore, signals);
|
|
8174
|
+
input.metadata = {
|
|
8175
|
+
...input.metadata ?? {},
|
|
8176
|
+
riskEvaluation: evaluation
|
|
8177
|
+
};
|
|
8178
|
+
if (evaluation.decision === risk_1.RiskDecision.DENY) {
|
|
8179
|
+
return {
|
|
8180
|
+
allow: false,
|
|
8181
|
+
riskScore: aggregateScore,
|
|
8182
|
+
reasons: signals.map((s) => s.message),
|
|
8183
|
+
code: "RISK_GATE_DENY",
|
|
8184
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8185
|
+
};
|
|
8186
|
+
}
|
|
8187
|
+
if (evaluation.decision === risk_1.RiskDecision.THROTTLE) {
|
|
8188
|
+
return {
|
|
8189
|
+
allow: false,
|
|
8190
|
+
riskScore: aggregateScore,
|
|
8191
|
+
reasons: signals.map((s) => s.message),
|
|
8192
|
+
code: "RISK_GATE_THROTTLE",
|
|
8193
|
+
retryAfterMs: evaluation.retryAfterMs,
|
|
8194
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8195
|
+
};
|
|
8196
|
+
}
|
|
8197
|
+
return {
|
|
8198
|
+
allow: true,
|
|
8199
|
+
riskScore: aggregateScore,
|
|
8200
|
+
reasons: signals.filter((s) => s.severity === "medium" || s.severity === "high").map((s) => s.message),
|
|
8201
|
+
tags: {
|
|
8202
|
+
riskDecision: evaluation.decision,
|
|
8203
|
+
signalCount: signals.length
|
|
8204
|
+
}
|
|
8205
|
+
};
|
|
8206
|
+
}
|
|
8207
|
+
evaluate(score, signals) {
|
|
8208
|
+
const hasCritical = signals.some((s) => s.severity === "critical");
|
|
8209
|
+
if (hasCritical) {
|
|
8210
|
+
return {
|
|
8211
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8212
|
+
reason: "Critical risk signal detected",
|
|
8213
|
+
confidence: 1,
|
|
8214
|
+
signals
|
|
8215
|
+
};
|
|
8216
|
+
}
|
|
8217
|
+
if (score >= this.denyThreshold) {
|
|
8218
|
+
return {
|
|
8219
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8220
|
+
reason: `Aggregate risk score ${score} exceeds deny threshold ${this.denyThreshold}`,
|
|
8221
|
+
confidence: score / 100,
|
|
8222
|
+
signals
|
|
8223
|
+
};
|
|
8224
|
+
}
|
|
8225
|
+
if (score >= this.flagThreshold) {
|
|
8226
|
+
return {
|
|
8227
|
+
decision: risk_1.RiskDecision.STEP_UP,
|
|
8228
|
+
reason: `Aggregate risk score ${score} exceeds flag threshold ${this.flagThreshold}`,
|
|
8229
|
+
confidence: score / 100,
|
|
8230
|
+
signals
|
|
8231
|
+
};
|
|
8232
|
+
}
|
|
8233
|
+
return {
|
|
8234
|
+
decision: risk_1.RiskDecision.ALLOW,
|
|
8235
|
+
confidence: 1 - score / 100,
|
|
8236
|
+
signals
|
|
8237
|
+
};
|
|
8238
|
+
}
|
|
8239
|
+
};
|
|
8240
|
+
exports.RiskGateSensor = RiskGateSensor2;
|
|
8241
|
+
exports.RiskGateSensor = RiskGateSensor2 = __decorate([
|
|
8242
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8243
|
+
(0, common_1.Injectable)(),
|
|
8244
|
+
__metadata("design:paramtypes", [Object])
|
|
8245
|
+
], RiskGateSensor2);
|
|
8246
|
+
}
|
|
8247
|
+
});
|
|
8248
|
+
|
|
8249
|
+
// src/sensors/tickauth.sensor.ts
|
|
8250
|
+
var require_tickauth_sensor = __commonJS({
|
|
8251
|
+
"src/sensors/tickauth.sensor.ts"(exports) {
|
|
8252
|
+
"use strict";
|
|
8253
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8254
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8255
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8256
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8257
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8258
|
+
};
|
|
8259
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8260
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8261
|
+
};
|
|
8262
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8263
|
+
exports.TickAuthSensor = void 0;
|
|
8264
|
+
var common_1 = __require("@nestjs/common");
|
|
8265
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8266
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8267
|
+
var TickAuthSensor2 = class TickAuthSensor {
|
|
8268
|
+
constructor(options = {}) {
|
|
8269
|
+
this.name = "TickAuthSensor";
|
|
8270
|
+
this.order = sensor_bands_1.BAND.IDENTITY + 40;
|
|
8271
|
+
this.verifier = options.verifier;
|
|
8272
|
+
this.matchIntent = options.matchIntent ?? true;
|
|
8273
|
+
this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
|
|
8274
|
+
}
|
|
8275
|
+
supports(input) {
|
|
8276
|
+
return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
|
|
8277
|
+
}
|
|
8278
|
+
async run(input) {
|
|
8279
|
+
const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
|
|
8280
|
+
if (!capsule) {
|
|
8281
|
+
return {
|
|
8282
|
+
allow: false,
|
|
8283
|
+
riskScore: 90,
|
|
8284
|
+
reasons: ["TickAuth capsule not found"],
|
|
8285
|
+
code: "TICKAUTH_MISSING"
|
|
8286
|
+
};
|
|
8287
|
+
}
|
|
8288
|
+
if (!capsule.capsule_id || typeof capsule.capsule_id !== "string") {
|
|
8289
|
+
return {
|
|
8290
|
+
allow: false,
|
|
8291
|
+
riskScore: 100,
|
|
8292
|
+
reasons: ["TickAuth capsule has no valid capsule_id"],
|
|
8293
|
+
code: "TICKAUTH_INVALID_ID"
|
|
8294
|
+
};
|
|
8295
|
+
}
|
|
8296
|
+
const status = capsule.verification?.status;
|
|
8297
|
+
if (status && status !== "approved") {
|
|
8298
|
+
return {
|
|
8299
|
+
allow: false,
|
|
8300
|
+
riskScore: 100,
|
|
8301
|
+
reasons: [
|
|
8302
|
+
`TickAuth capsule status is '${status}'${capsule.verification?.reason ? `: ${capsule.verification.reason}` : ""}`
|
|
8303
|
+
],
|
|
8304
|
+
code: `TICKAUTH_STATUS_${status.toUpperCase()}`
|
|
8305
|
+
};
|
|
8306
|
+
}
|
|
8307
|
+
if (this.acceptTypes && capsule.capsule_type) {
|
|
8308
|
+
if (!this.acceptTypes.has(capsule.capsule_type)) {
|
|
8309
|
+
return {
|
|
8310
|
+
allow: false,
|
|
8311
|
+
riskScore: 80,
|
|
8312
|
+
reasons: [
|
|
8313
|
+
`TickAuth capsule type '${capsule.capsule_type}' is not in accept list`
|
|
8314
|
+
],
|
|
8315
|
+
code: "TICKAUTH_TYPE_REJECTED"
|
|
8316
|
+
};
|
|
8317
|
+
}
|
|
8318
|
+
}
|
|
8319
|
+
if (this.matchIntent && input.intent && capsule.intent) {
|
|
8320
|
+
if (capsule.intent !== input.intent) {
|
|
8321
|
+
return {
|
|
8322
|
+
allow: false,
|
|
8323
|
+
riskScore: 80,
|
|
8324
|
+
reasons: [
|
|
8325
|
+
`TickAuth capsule intent '${capsule.intent}' does not match AXIS intent '${input.intent}'`
|
|
8326
|
+
],
|
|
8327
|
+
code: "TICKAUTH_INTENT_MISMATCH"
|
|
8328
|
+
};
|
|
8329
|
+
}
|
|
8330
|
+
}
|
|
8331
|
+
if (this.verifier) {
|
|
8332
|
+
const error = await this.verifier(capsule, input);
|
|
8333
|
+
if (error) {
|
|
8334
|
+
return {
|
|
8335
|
+
allow: false,
|
|
8336
|
+
riskScore: 90,
|
|
8337
|
+
reasons: [`TickAuth verification failed: ${error}`],
|
|
8338
|
+
code: "TICKAUTH_VERIFY_FAILED"
|
|
8339
|
+
};
|
|
8340
|
+
}
|
|
8341
|
+
}
|
|
8342
|
+
return {
|
|
8343
|
+
allow: true,
|
|
8344
|
+
riskScore: 0,
|
|
8345
|
+
reasons: [],
|
|
8346
|
+
tags: {
|
|
8347
|
+
tickauthCapsuleId: capsule.capsule_id,
|
|
8348
|
+
tickauthMode: capsule.mode,
|
|
8349
|
+
tickauthSingleUse: capsule.single_use
|
|
8350
|
+
}
|
|
8351
|
+
};
|
|
8352
|
+
}
|
|
8353
|
+
};
|
|
8354
|
+
exports.TickAuthSensor = TickAuthSensor2;
|
|
8355
|
+
exports.TickAuthSensor = TickAuthSensor2 = __decorate([
|
|
8356
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8357
|
+
(0, common_1.Injectable)(),
|
|
8358
|
+
__metadata("design:paramtypes", [Object])
|
|
8359
|
+
], TickAuthSensor2);
|
|
8360
|
+
}
|
|
8361
|
+
});
|
|
8362
|
+
|
|
8363
|
+
// src/cce/sensors/cce-envelope-validation.sensor.ts
|
|
8364
|
+
var REQUIRED_FIELDS, CceEnvelopeValidationSensor;
|
|
8365
|
+
var init_cce_envelope_validation_sensor = __esm({
|
|
8366
|
+
"src/cce/sensors/cce-envelope-validation.sensor.ts"() {
|
|
8367
|
+
init_axis_sensor();
|
|
8368
|
+
init_cce_types();
|
|
8369
|
+
REQUIRED_FIELDS = [
|
|
8370
|
+
"ver",
|
|
8371
|
+
"request_id",
|
|
8372
|
+
"correlation_id",
|
|
8373
|
+
"client_kid",
|
|
8374
|
+
"capsule",
|
|
8375
|
+
"encrypted_key",
|
|
8376
|
+
"encrypted_payload",
|
|
8377
|
+
"request_nonce",
|
|
8378
|
+
"client_sig",
|
|
8379
|
+
"content_type",
|
|
8380
|
+
"algorithms"
|
|
8381
|
+
];
|
|
8382
|
+
CceEnvelopeValidationSensor = class {
|
|
8383
|
+
constructor() {
|
|
8384
|
+
this.name = "cce.envelope.validation";
|
|
8385
|
+
this.order = 5;
|
|
8386
|
+
this.phase = "PRE_DECODE";
|
|
8387
|
+
}
|
|
8388
|
+
supports(input) {
|
|
8389
|
+
return input.metadata?.cce === true || input.metadata?.contentType === "application/axis-cce";
|
|
8390
|
+
}
|
|
8391
|
+
async run(input) {
|
|
8392
|
+
const envelope = input.metadata?.cceEnvelope;
|
|
8393
|
+
if (!envelope) {
|
|
8394
|
+
return {
|
|
8395
|
+
allow: false,
|
|
8396
|
+
riskScore: 100,
|
|
8397
|
+
reasons: [CCE_ERROR.INVALID_ENVELOPE],
|
|
8398
|
+
code: CCE_ERROR.INVALID_ENVELOPE
|
|
8399
|
+
};
|
|
8400
|
+
}
|
|
8401
|
+
for (const field of REQUIRED_FIELDS) {
|
|
8402
|
+
if (envelope[field] === void 0 || envelope[field] === null) {
|
|
8403
|
+
return {
|
|
8404
|
+
allow: false,
|
|
8405
|
+
riskScore: 100,
|
|
8406
|
+
reasons: [`${CCE_ERROR.INVALID_ENVELOPE}: missing ${field}`],
|
|
8407
|
+
code: CCE_ERROR.INVALID_ENVELOPE
|
|
8408
|
+
};
|
|
8409
|
+
}
|
|
8410
|
+
}
|
|
8411
|
+
if (envelope.ver !== CCE_PROTOCOL_VERSION) {
|
|
8412
|
+
return {
|
|
8413
|
+
allow: false,
|
|
8414
|
+
riskScore: 100,
|
|
8415
|
+
reasons: [`${CCE_ERROR.UNSUPPORTED_VERSION}: ${envelope.ver}`],
|
|
8416
|
+
code: CCE_ERROR.UNSUPPORTED_VERSION
|
|
8417
|
+
};
|
|
8418
|
+
}
|
|
8419
|
+
if (!/^[0-9a-f]+$/i.test(envelope.request_nonce)) {
|
|
8420
|
+
return {
|
|
8421
|
+
allow: false,
|
|
8422
|
+
riskScore: 100,
|
|
8423
|
+
reasons: [
|
|
8424
|
+
`${CCE_ERROR.INVALID_ENVELOPE}: invalid request_nonce format`
|
|
8425
|
+
],
|
|
8426
|
+
code: CCE_ERROR.INVALID_ENVELOPE
|
|
8427
|
+
};
|
|
8428
|
+
}
|
|
8429
|
+
if (envelope.request_nonce.length !== CCE_NONCE_BYTES * 2) {
|
|
8430
|
+
return {
|
|
8431
|
+
allow: false,
|
|
8432
|
+
riskScore: 100,
|
|
8433
|
+
reasons: [`${CCE_ERROR.INVALID_ENVELOPE}: request_nonce wrong length`],
|
|
8434
|
+
code: CCE_ERROR.INVALID_ENVELOPE
|
|
8435
|
+
};
|
|
8436
|
+
}
|
|
8437
|
+
const capsule = envelope.capsule;
|
|
8438
|
+
if (!capsule.capsule_id || !capsule.ver || !capsule.sub || !capsule.kid || !capsule.intent || !capsule.aud || !capsule.issuer_sig) {
|
|
8439
|
+
return {
|
|
8440
|
+
allow: false,
|
|
8441
|
+
riskScore: 100,
|
|
8442
|
+
reasons: [`${CCE_ERROR.MISSING_CAPSULE}: incomplete capsule claims`],
|
|
8443
|
+
code: CCE_ERROR.MISSING_CAPSULE
|
|
8444
|
+
};
|
|
8445
|
+
}
|
|
8446
|
+
if (!envelope.encrypted_key.ciphertext || !envelope.encrypted_key.alg) {
|
|
8447
|
+
return {
|
|
8448
|
+
allow: false,
|
|
8449
|
+
riskScore: 100,
|
|
8450
|
+
reasons: [
|
|
8451
|
+
`${CCE_ERROR.MISSING_ENCRYPTED_KEY}: incomplete encrypted_key`
|
|
6185
8452
|
],
|
|
6186
8453
|
code: CCE_ERROR.MISSING_ENCRYPTED_KEY
|
|
6187
8454
|
};
|
|
@@ -6901,94 +9168,19 @@ var init_cce = __esm({
|
|
|
6901
9168
|
// src/core/index.ts
|
|
6902
9169
|
var core_exports = {};
|
|
6903
9170
|
__export(core_exports, {
|
|
6904
|
-
AXIS_MAGIC: () => AXIS_MAGIC,
|
|
6905
|
-
AXIS_VERSION: () => AXIS_VERSION,
|
|
6906
9171
|
AxisError: () => AxisError,
|
|
6907
9172
|
AxisFrameZ: () => AxisFrameZ,
|
|
6908
|
-
BodyProfile: () => BodyProfile,
|
|
6909
|
-
ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
|
|
6910
|
-
ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
|
|
6911
|
-
ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
|
|
6912
|
-
ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
|
|
6913
|
-
FLAG_BODY_TLV: () => FLAG_BODY_TLV,
|
|
6914
|
-
FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
|
|
6915
|
-
FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
|
|
6916
|
-
MAX_BODY_LEN: () => MAX_BODY_LEN,
|
|
6917
|
-
MAX_FRAME_LEN: () => MAX_FRAME_LEN,
|
|
6918
|
-
MAX_HDR_LEN: () => MAX_HDR_LEN,
|
|
6919
|
-
MAX_SIG_LEN: () => MAX_SIG_LEN,
|
|
6920
|
-
NCERT_ALG: () => NCERT_ALG,
|
|
6921
|
-
NCERT_EXP: () => NCERT_EXP,
|
|
6922
|
-
NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
|
|
6923
|
-
NCERT_KID: () => NCERT_KID,
|
|
6924
|
-
NCERT_NBF: () => NCERT_NBF,
|
|
6925
|
-
NCERT_NODE_ID: () => NCERT_NODE_ID,
|
|
6926
|
-
NCERT_PAYLOAD: () => NCERT_PAYLOAD,
|
|
6927
|
-
NCERT_PUB: () => NCERT_PUB,
|
|
6928
|
-
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
6929
|
-
NCERT_SIG: () => NCERT_SIG,
|
|
6930
|
-
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
6931
|
-
PROOF_JWT: () => PROOF_JWT,
|
|
6932
|
-
PROOF_LOOM: () => PROOF_LOOM,
|
|
6933
|
-
PROOF_MTLS: () => PROOF_MTLS,
|
|
6934
|
-
PROOF_NONE: () => PROOF_NONE,
|
|
6935
|
-
PROOF_WITNESS: () => PROOF_WITNESS,
|
|
6936
|
-
ProofType: () => ProofType,
|
|
6937
|
-
TLV: () => TLV,
|
|
6938
|
-
TLV_ACTOR_ID: () => TLV_ACTOR_ID,
|
|
6939
|
-
TLV_AUD: () => TLV_AUD,
|
|
6940
|
-
TLV_BODY_ARR: () => TLV_BODY_ARR,
|
|
6941
|
-
TLV_BODY_OBJ: () => TLV_BODY_OBJ,
|
|
6942
|
-
TLV_CAPSULE: () => TLV_CAPSULE,
|
|
6943
|
-
TLV_EFFECT: () => TLV_EFFECT,
|
|
6944
|
-
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
6945
|
-
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
6946
|
-
TLV_INDEX: () => TLV_INDEX,
|
|
6947
|
-
TLV_INTENT: () => TLV_INTENT,
|
|
6948
|
-
TLV_KID: () => TLV_KID,
|
|
6949
|
-
TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
|
|
6950
|
-
TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
|
|
6951
|
-
TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
|
|
6952
|
-
TLV_NODE: () => TLV_NODE,
|
|
6953
|
-
TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
|
|
6954
|
-
TLV_NODE_KID: () => TLV_NODE_KID,
|
|
6955
|
-
TLV_NONCE: () => TLV_NONCE,
|
|
6956
|
-
TLV_OFFSET: () => TLV_OFFSET,
|
|
6957
|
-
TLV_OK: () => TLV_OK,
|
|
6958
|
-
TLV_PID: () => TLV_PID,
|
|
6959
|
-
TLV_PREV_HASH: () => TLV_PREV_HASH,
|
|
6960
|
-
TLV_PROOF_REF: () => TLV_PROOF_REF,
|
|
6961
|
-
TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
|
|
6962
|
-
TLV_REALM: () => TLV_REALM,
|
|
6963
|
-
TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
|
|
6964
|
-
TLV_RID: () => TLV_RID,
|
|
6965
|
-
TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
|
|
6966
|
-
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
6967
|
-
TLV_TS: () => TLV_TS,
|
|
6968
|
-
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
6969
9173
|
computeReceiptHash: () => computeReceiptHash,
|
|
6970
9174
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
6971
|
-
decodeArray: () => decodeArray,
|
|
6972
|
-
decodeFrame: () => decodeFrame,
|
|
6973
|
-
decodeObject: () => decodeObject,
|
|
6974
|
-
decodeTLVs: () => decodeTLVs,
|
|
6975
|
-
decodeTLVsList: () => decodeTLVsList,
|
|
6976
|
-
decodeVarint: () => decodeVarint,
|
|
6977
|
-
encodeFrame: () => encodeFrame,
|
|
6978
|
-
encodeTLVs: () => encodeTLVs,
|
|
6979
|
-
encodeVarint: () => encodeVarint,
|
|
6980
9175
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
6981
|
-
getSignTarget: () => getSignTarget,
|
|
6982
9176
|
sha256: () => sha2564,
|
|
6983
9177
|
signFrame: () => signFrame,
|
|
6984
|
-
varintLength: () => varintLength,
|
|
6985
9178
|
verifyFrameSignature: () => verifyFrameSignature
|
|
6986
9179
|
});
|
|
9180
|
+
import * as axis_protocol_star from "@nextera.one/axis-protocol";
|
|
6987
9181
|
var init_core = __esm({
|
|
6988
9182
|
"src/core/index.ts"() {
|
|
6989
|
-
|
|
6990
|
-
init_varint();
|
|
6991
|
-
init_tlv();
|
|
9183
|
+
__reExport(core_exports, axis_protocol_star);
|
|
6992
9184
|
init_axis_bin();
|
|
6993
9185
|
init_signature();
|
|
6994
9186
|
init_axis_error();
|
|
@@ -7243,14 +9435,6 @@ __export(decorators_exports, {
|
|
|
7243
9435
|
Observer: () => Observer,
|
|
7244
9436
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
7245
9437
|
Sensor: () => Sensor,
|
|
7246
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
7247
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
7248
|
-
TlvEnum: () => TlvEnum,
|
|
7249
|
-
TlvField: () => TlvField,
|
|
7250
|
-
TlvMinLen: () => TlvMinLen,
|
|
7251
|
-
TlvRange: () => TlvRange,
|
|
7252
|
-
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
7253
|
-
TlvValidate: () => TlvValidate,
|
|
7254
9438
|
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
7255
9439
|
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
7256
9440
|
});
|
|
@@ -7266,7 +9450,7 @@ var init_decorators = __esm({
|
|
|
7266
9450
|
init_intent_decorator();
|
|
7267
9451
|
init_observer_decorator();
|
|
7268
9452
|
init_sensor_decorator();
|
|
7269
|
-
|
|
9453
|
+
__reExport(decorators_exports, __toESM(require_tlv_field_decorator()));
|
|
7270
9454
|
}
|
|
7271
9455
|
});
|
|
7272
9456
|
|
|
@@ -7367,6 +9551,25 @@ var init_engine = __esm({
|
|
|
7367
9551
|
}
|
|
7368
9552
|
});
|
|
7369
9553
|
|
|
9554
|
+
// src/idel/idel.types.ts
|
|
9555
|
+
var init_idel_types = __esm({
|
|
9556
|
+
"src/idel/idel.types.ts"() {
|
|
9557
|
+
}
|
|
9558
|
+
});
|
|
9559
|
+
|
|
9560
|
+
// src/idel/index.ts
|
|
9561
|
+
var idel_exports = {};
|
|
9562
|
+
__export(idel_exports, {
|
|
9563
|
+
IdelCompiler: () => IdelCompiler,
|
|
9564
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry
|
|
9565
|
+
});
|
|
9566
|
+
var init_idel = __esm({
|
|
9567
|
+
"src/idel/index.ts"() {
|
|
9568
|
+
init_idel_types();
|
|
9569
|
+
init_idel_compiler();
|
|
9570
|
+
}
|
|
9571
|
+
});
|
|
9572
|
+
|
|
7370
9573
|
// src/loom/index.ts
|
|
7371
9574
|
var loom_exports = {};
|
|
7372
9575
|
__export(loom_exports, {
|
|
@@ -7376,11 +9579,98 @@ __export(loom_exports, {
|
|
|
7376
9579
|
TLV_WRIT: () => TLV_LOOM_WRIT,
|
|
7377
9580
|
canonicalizeGrant: () => canonicalizeGrant,
|
|
7378
9581
|
canonicalizeWrit: () => canonicalizeWrit,
|
|
7379
|
-
|
|
9582
|
+
createGrant: () => createGrant,
|
|
9583
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
9584
|
+
createReceipt: () => createReceipt,
|
|
9585
|
+
createRevocation: () => createRevocation,
|
|
9586
|
+
createWrit: () => createWrit,
|
|
9587
|
+
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
9588
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9589
|
+
getGrantStatus: () => getGrantStatus,
|
|
9590
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
9591
|
+
grantCoversAction: () => grantCoversAction,
|
|
9592
|
+
isRevoked: () => isRevoked,
|
|
9593
|
+
renewPresence: () => renewPresence,
|
|
9594
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9595
|
+
updateThreadState: () => updateThreadState,
|
|
9596
|
+
validateGrant: () => validateGrant,
|
|
9597
|
+
validateWrit: () => validateWrit,
|
|
9598
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
9599
|
+
verifyReceiptChain: () => verifyReceiptChain
|
|
7380
9600
|
});
|
|
7381
9601
|
var init_loom = __esm({
|
|
7382
9602
|
"src/loom/index.ts"() {
|
|
7383
9603
|
init_loom_types();
|
|
9604
|
+
init_loom_engine();
|
|
9605
|
+
}
|
|
9606
|
+
});
|
|
9607
|
+
|
|
9608
|
+
// src/needle/needle.types.ts
|
|
9609
|
+
var init_needle_types = __esm({
|
|
9610
|
+
"src/needle/needle.types.ts"() {
|
|
9611
|
+
}
|
|
9612
|
+
});
|
|
9613
|
+
|
|
9614
|
+
// src/needle/knot.types.ts
|
|
9615
|
+
var init_knot_types = __esm({
|
|
9616
|
+
"src/needle/knot.types.ts"() {
|
|
9617
|
+
}
|
|
9618
|
+
});
|
|
9619
|
+
|
|
9620
|
+
// src/needle/fabric.types.ts
|
|
9621
|
+
var init_fabric_types = __esm({
|
|
9622
|
+
"src/needle/fabric.types.ts"() {
|
|
9623
|
+
}
|
|
9624
|
+
});
|
|
9625
|
+
|
|
9626
|
+
// src/needle/pattern.types.ts
|
|
9627
|
+
var init_pattern_types = __esm({
|
|
9628
|
+
"src/needle/pattern.types.ts"() {
|
|
9629
|
+
}
|
|
9630
|
+
});
|
|
9631
|
+
|
|
9632
|
+
// src/needle/index.ts
|
|
9633
|
+
var needle_exports = {};
|
|
9634
|
+
__export(needle_exports, {
|
|
9635
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
9636
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
9637
|
+
applyStitch: () => applyStitch,
|
|
9638
|
+
assembleNeedle: () => assembleNeedle,
|
|
9639
|
+
breakKnot: () => breakKnot,
|
|
9640
|
+
createFabric: () => createFabric,
|
|
9641
|
+
detectAnomalies: () => detectAnomalies,
|
|
9642
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
9643
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
9644
|
+
diffFabrics: () => diffFabrics,
|
|
9645
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
9646
|
+
forkFromKnot: () => forkFromKnot,
|
|
9647
|
+
formStitch: () => formStitch,
|
|
9648
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
9649
|
+
getFabricValue: () => getFabricValue,
|
|
9650
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
9651
|
+
isKnotOpen: () => isKnotOpen,
|
|
9652
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
9653
|
+
lockCells: () => lockCells,
|
|
9654
|
+
matchPatterns: () => matchPatterns,
|
|
9655
|
+
openKnot: () => openKnot,
|
|
9656
|
+
projectAt: () => projectAt,
|
|
9657
|
+
queryFabric: () => queryFabric,
|
|
9658
|
+
recordOccurrence: () => recordOccurrence,
|
|
9659
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9660
|
+
tieKnot: () => tieKnot,
|
|
9661
|
+
validateKnot: () => validateKnot,
|
|
9662
|
+
weave: () => weave
|
|
9663
|
+
});
|
|
9664
|
+
var init_needle = __esm({
|
|
9665
|
+
"src/needle/index.ts"() {
|
|
9666
|
+
init_needle_types();
|
|
9667
|
+
init_needle_engine();
|
|
9668
|
+
init_knot_types();
|
|
9669
|
+
init_knot_engine();
|
|
9670
|
+
init_fabric_types();
|
|
9671
|
+
init_fabric_engine();
|
|
9672
|
+
init_pattern_types();
|
|
9673
|
+
init_pattern_engine();
|
|
7384
9674
|
}
|
|
7385
9675
|
});
|
|
7386
9676
|
|
|
@@ -8666,6 +10956,143 @@ var require_intent_registry_sensor = __commonJS({
|
|
|
8666
10956
|
}
|
|
8667
10957
|
});
|
|
8668
10958
|
|
|
10959
|
+
// src/sensors/law-evaluation.sensor.ts
|
|
10960
|
+
var require_law_evaluation_sensor = __commonJS({
|
|
10961
|
+
"src/sensors/law-evaluation.sensor.ts"(exports) {
|
|
10962
|
+
"use strict";
|
|
10963
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
10964
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10965
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10966
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10967
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10968
|
+
};
|
|
10969
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
10970
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10971
|
+
};
|
|
10972
|
+
var LawEvaluationSensor_1;
|
|
10973
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10974
|
+
exports.LawEvaluationSensor = void 0;
|
|
10975
|
+
var common_1 = __require("@nestjs/common");
|
|
10976
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
10977
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
10978
|
+
var law_1 = (init_law(), __toCommonJS(law_exports));
|
|
10979
|
+
var LawEvaluationSensor = LawEvaluationSensor_1 = class LawEvaluationSensor {
|
|
10980
|
+
constructor(options = {}) {
|
|
10981
|
+
this.options = options;
|
|
10982
|
+
this.logger = new common_1.Logger(LawEvaluationSensor_1.name);
|
|
10983
|
+
this.name = "LawEvaluationSensor";
|
|
10984
|
+
this.order = sensor_bands_1.BAND.POLICY + 5;
|
|
10985
|
+
}
|
|
10986
|
+
supports(input) {
|
|
10987
|
+
return !!this.options.evaluator && !!input.intent;
|
|
10988
|
+
}
|
|
10989
|
+
async run(input) {
|
|
10990
|
+
const evaluator = this.options.evaluator;
|
|
10991
|
+
if (!evaluator) {
|
|
10992
|
+
return { action: "ALLOW" };
|
|
10993
|
+
}
|
|
10994
|
+
const context = (0, law_1.buildAxisLawEvaluationContext)(input);
|
|
10995
|
+
let result;
|
|
10996
|
+
try {
|
|
10997
|
+
result = await evaluator(context);
|
|
10998
|
+
} catch (error) {
|
|
10999
|
+
const message = error instanceof Error ? error.message : "Unknown law evaluation error";
|
|
11000
|
+
this.logger.error(`Law evaluation failed for ${input.intent}: ${message}`);
|
|
11001
|
+
input.metadata = {
|
|
11002
|
+
...input.metadata ?? {},
|
|
11003
|
+
lawEvaluation: {
|
|
11004
|
+
decision: "deny",
|
|
11005
|
+
reason: "Law evaluation failed",
|
|
11006
|
+
explanation: message
|
|
11007
|
+
}
|
|
11008
|
+
};
|
|
11009
|
+
return {
|
|
11010
|
+
action: "DENY",
|
|
11011
|
+
code: "LAW_EVALUATION_ERROR",
|
|
11012
|
+
reason: message,
|
|
11013
|
+
meta: { lawDecision: "deny" }
|
|
11014
|
+
};
|
|
11015
|
+
}
|
|
11016
|
+
input.metadata = {
|
|
11017
|
+
...input.metadata ?? {},
|
|
11018
|
+
lawEvaluation: {
|
|
11019
|
+
...result,
|
|
11020
|
+
context: sanitizeLawContext(context)
|
|
11021
|
+
}
|
|
11022
|
+
};
|
|
11023
|
+
if (result.decision === "allow") {
|
|
11024
|
+
return {
|
|
11025
|
+
allow: true,
|
|
11026
|
+
riskScore: 0,
|
|
11027
|
+
reasons: result.reason ? [result.reason] : [],
|
|
11028
|
+
tags: {
|
|
11029
|
+
lawDecision: "allow",
|
|
11030
|
+
...result.applicable ? { lawApplicableArticles: result.applicable.length } : {}
|
|
11031
|
+
},
|
|
11032
|
+
meta: result
|
|
11033
|
+
};
|
|
11034
|
+
}
|
|
11035
|
+
if (result.decision === "conditional") {
|
|
11036
|
+
const mode = this.options.conditionalDecision ?? "deny";
|
|
11037
|
+
const reasons = [result.reason, result.explanation].filter(Boolean);
|
|
11038
|
+
if (mode === "allow") {
|
|
11039
|
+
return {
|
|
11040
|
+
allow: true,
|
|
11041
|
+
riskScore: 0,
|
|
11042
|
+
reasons,
|
|
11043
|
+
tags: {
|
|
11044
|
+
lawDecision: "conditional"
|
|
11045
|
+
},
|
|
11046
|
+
meta: result
|
|
11047
|
+
};
|
|
11048
|
+
}
|
|
11049
|
+
if (mode === "flag") {
|
|
11050
|
+
return {
|
|
11051
|
+
action: "FLAG",
|
|
11052
|
+
scoreDelta: 25,
|
|
11053
|
+
reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
|
|
11054
|
+
meta: result
|
|
11055
|
+
};
|
|
11056
|
+
}
|
|
11057
|
+
return {
|
|
11058
|
+
action: "DENY",
|
|
11059
|
+
code: "LAW_CONDITIONAL",
|
|
11060
|
+
reason: reasons.join(" | ") || "Execution is conditionally permitted pending additional requirements",
|
|
11061
|
+
meta: { lawDecision: "conditional", evaluation: result }
|
|
11062
|
+
};
|
|
11063
|
+
}
|
|
11064
|
+
return {
|
|
11065
|
+
action: "DENY",
|
|
11066
|
+
code: "LAW_DENIED",
|
|
11067
|
+
reason: [result.reason, result.explanation].filter(Boolean).join(" | ") || "Execution denied by law evaluation",
|
|
11068
|
+
meta: { lawDecision: "deny", evaluation: result }
|
|
11069
|
+
};
|
|
11070
|
+
}
|
|
11071
|
+
};
|
|
11072
|
+
exports.LawEvaluationSensor = LawEvaluationSensor;
|
|
11073
|
+
exports.LawEvaluationSensor = LawEvaluationSensor = LawEvaluationSensor_1 = __decorate([
|
|
11074
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
11075
|
+
(0, common_1.Injectable)(),
|
|
11076
|
+
__metadata("design:paramtypes", [Object])
|
|
11077
|
+
], LawEvaluationSensor);
|
|
11078
|
+
function sanitizeLawContext(context) {
|
|
11079
|
+
return {
|
|
11080
|
+
actorId: context.actorId,
|
|
11081
|
+
intent: context.intent,
|
|
11082
|
+
audience: context.audience,
|
|
11083
|
+
tps: context.tps,
|
|
11084
|
+
country: context.country,
|
|
11085
|
+
ip: context.ip,
|
|
11086
|
+
path: context.path,
|
|
11087
|
+
clientId: context.clientId,
|
|
11088
|
+
deviceId: context.deviceId,
|
|
11089
|
+
sessionId: context.sessionId,
|
|
11090
|
+
capsuleId: context.capsuleId
|
|
11091
|
+
};
|
|
11092
|
+
}
|
|
11093
|
+
}
|
|
11094
|
+
});
|
|
11095
|
+
|
|
8669
11096
|
// src/sensors/proof-presence.sensor.ts
|
|
8670
11097
|
var require_proof_presence_sensor = __commonJS({
|
|
8671
11098
|
"src/sensors/proof-presence.sensor.ts"(exports) {
|
|
@@ -9373,16 +11800,40 @@ var init_sensors2 = __esm({
|
|
|
9373
11800
|
__reExport(sensors_exports, __toESM(require_header_tlv_limit_sensor()));
|
|
9374
11801
|
__reExport(sensors_exports, __toESM(require_intent_allowlist_sensor()));
|
|
9375
11802
|
__reExport(sensors_exports, __toESM(require_intent_registry_sensor()));
|
|
11803
|
+
__reExport(sensors_exports, __toESM(require_law_evaluation_sensor()));
|
|
9376
11804
|
__reExport(sensors_exports, __toESM(require_proof_presence_sensor()));
|
|
9377
11805
|
__reExport(sensors_exports, __toESM(require_protocol_strict_sensor()));
|
|
9378
11806
|
__reExport(sensors_exports, __toESM(require_receipt_policy_sensor()));
|
|
11807
|
+
__reExport(sensors_exports, __toESM(require_risk_gate_sensor()));
|
|
9379
11808
|
__reExport(sensors_exports, __toESM(require_schema_validation_sensor()));
|
|
9380
11809
|
__reExport(sensors_exports, __toESM(require_stream_scope_sensor()));
|
|
11810
|
+
__reExport(sensors_exports, __toESM(require_tickauth_sensor()));
|
|
9381
11811
|
__reExport(sensors_exports, __toESM(require_tlv_parse_sensor()));
|
|
11812
|
+
__reExport(sensors_exports, __toESM(require_tps_sensor()));
|
|
9382
11813
|
__reExport(sensors_exports, __toESM(require_varint_hardening_sensor()));
|
|
9383
11814
|
}
|
|
9384
11815
|
});
|
|
9385
11816
|
|
|
11817
|
+
// src/timeline/timeline.types.ts
|
|
11818
|
+
var init_timeline_types = __esm({
|
|
11819
|
+
"src/timeline/timeline.types.ts"() {
|
|
11820
|
+
}
|
|
11821
|
+
});
|
|
11822
|
+
|
|
11823
|
+
// src/timeline/index.ts
|
|
11824
|
+
var timeline_exports = {};
|
|
11825
|
+
__export(timeline_exports, {
|
|
11826
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
11827
|
+
TimelineEngine: () => TimelineEngine
|
|
11828
|
+
});
|
|
11829
|
+
var init_timeline = __esm({
|
|
11830
|
+
"src/timeline/index.ts"() {
|
|
11831
|
+
init_timeline_types();
|
|
11832
|
+
init_timeline_store();
|
|
11833
|
+
init_timeline_engine();
|
|
11834
|
+
}
|
|
11835
|
+
});
|
|
11836
|
+
|
|
9386
11837
|
// src/utils/index.ts
|
|
9387
11838
|
var utils_exports = {};
|
|
9388
11839
|
__export(utils_exports, {
|
|
@@ -9459,6 +11910,10 @@ __export(index_exports, {
|
|
|
9459
11910
|
INTENT_SENSITIVITY_MAP: () => INTENT_SENSITIVITY_MAP,
|
|
9460
11911
|
INTENT_SENSORS_KEY: () => INTENT_SENSORS_KEY,
|
|
9461
11912
|
INTENT_TIMEOUTS: () => INTENT_TIMEOUTS,
|
|
11913
|
+
IdelCompiler: () => IdelCompiler,
|
|
11914
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry,
|
|
11915
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
11916
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
9462
11917
|
Intent: () => Intent,
|
|
9463
11918
|
IntentBody: () => IntentBody,
|
|
9464
11919
|
IntentRouter: () => import_intent2.IntentRouter,
|
|
@@ -9500,6 +11955,7 @@ __export(index_exports, {
|
|
|
9500
11955
|
RESPONSE_TAG_UPDATED_BY: () => import_axis_response.RESPONSE_TAG_UPDATED_BY,
|
|
9501
11956
|
ResponseObserver: () => ResponseObserver,
|
|
9502
11957
|
RiskDecision: () => RiskDecision,
|
|
11958
|
+
RiskGateSensor: () => import_risk_gate.RiskGateSensor,
|
|
9503
11959
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
9504
11960
|
Schema2002_PasskeyLoginOptionsRes: () => Schema2002_PasskeyLoginOptionsRes,
|
|
9505
11961
|
Schema2011_PasskeyLoginVerifyReq: () => Schema2011_PasskeyLoginVerifyReq,
|
|
@@ -9518,7 +11974,7 @@ __export(index_exports, {
|
|
|
9518
11974
|
TLV_EFFECT: () => TLV_EFFECT,
|
|
9519
11975
|
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
9520
11976
|
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
9521
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
11977
|
+
TLV_FIELDS_KEY: () => import_tlv_field2.TLV_FIELDS_KEY,
|
|
9522
11978
|
TLV_INDEX: () => TLV_INDEX,
|
|
9523
11979
|
TLV_INTENT: () => TLV_INTENT,
|
|
9524
11980
|
TLV_KID: () => TLV_KID,
|
|
@@ -9544,20 +12000,28 @@ __export(index_exports, {
|
|
|
9544
12000
|
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
9545
12001
|
TLV_TS: () => TLV_TS,
|
|
9546
12002
|
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
9547
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
12003
|
+
TLV_VALIDATORS_KEY: () => import_tlv_field2.TLV_VALIDATORS_KEY,
|
|
9548
12004
|
TLV_WRIT: () => TLV_LOOM_WRIT,
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
12005
|
+
TickAuthSensor: () => import_tickauth.TickAuthSensor,
|
|
12006
|
+
TimelineEngine: () => TimelineEngine,
|
|
12007
|
+
TlvEnum: () => import_tlv_field2.TlvEnum,
|
|
12008
|
+
TlvField: () => import_tlv_field2.TlvField,
|
|
12009
|
+
TlvMinLen: () => import_tlv_field2.TlvMinLen,
|
|
12010
|
+
TlvRange: () => import_tlv_field2.TlvRange,
|
|
12011
|
+
TlvUtf8Pattern: () => import_tlv_field2.TlvUtf8Pattern,
|
|
12012
|
+
TlvValidate: () => import_tlv_field2.TlvValidate,
|
|
12013
|
+
TpsSensor: () => import_tps.TpsSensor,
|
|
12014
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
12015
|
+
applyStitch: () => applyStitch,
|
|
12016
|
+
assembleNeedle: () => assembleNeedle,
|
|
9555
12017
|
axis1SigningBytes: () => axis1SigningBytes,
|
|
9556
12018
|
b64urlDecode: () => b64urlDecode,
|
|
9557
12019
|
b64urlDecodeString: () => b64urlDecodeString,
|
|
9558
12020
|
b64urlEncode: () => b64urlEncode,
|
|
9559
12021
|
b64urlEncodeString: () => b64urlEncodeString,
|
|
12022
|
+
breakKnot: () => breakKnot,
|
|
9560
12023
|
buildAts1Hdr: () => buildAts1Hdr,
|
|
12024
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext,
|
|
9561
12025
|
buildDtoDecoder: () => import_dto_schema.buildDtoDecoder,
|
|
9562
12026
|
buildPacket: () => buildPacket,
|
|
9563
12027
|
buildQueueMessage: () => buildQueueMessage,
|
|
@@ -9576,7 +12040,13 @@ __export(index_exports, {
|
|
|
9576
12040
|
computeReceiptHash: () => computeReceiptHash,
|
|
9577
12041
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
9578
12042
|
core: () => core_exports,
|
|
12043
|
+
createFabric: () => createFabric,
|
|
12044
|
+
createGrant: () => createGrant,
|
|
9579
12045
|
createObservation: () => createObservation,
|
|
12046
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
12047
|
+
createReceipt: () => createReceipt,
|
|
12048
|
+
createRevocation: () => createRevocation,
|
|
12049
|
+
createWrit: () => createWrit,
|
|
9580
12050
|
crypto: () => crypto_exports,
|
|
9581
12051
|
decodeArray: () => decodeArray,
|
|
9582
12052
|
decodeAxis1Frame: () => decodeAxis1Frame,
|
|
@@ -9588,6 +12058,10 @@ __export(index_exports, {
|
|
|
9588
12058
|
decodeVarint: () => decodeVarint,
|
|
9589
12059
|
decorators: () => decorators_exports,
|
|
9590
12060
|
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
12061
|
+
detectAnomalies: () => detectAnomalies,
|
|
12062
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
12063
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
12064
|
+
diffFabrics: () => diffFabrics,
|
|
9591
12065
|
encVarint: () => encVarint,
|
|
9592
12066
|
encodeAxis1Frame: () => encodeAxis1Frame,
|
|
9593
12067
|
encodeAxisTlvDto: () => encodeAxisTlvDto,
|
|
@@ -9598,20 +12072,38 @@ __export(index_exports, {
|
|
|
9598
12072
|
endStage: () => endStage,
|
|
9599
12073
|
engine: () => engine_exports,
|
|
9600
12074
|
executeCcePipeline: () => executeCcePipeline,
|
|
12075
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9601
12076
|
extractDtoSchema: () => import_dto_schema.extractDtoSchema,
|
|
9602
12077
|
finalizeObservation: () => finalizeObservation,
|
|
12078
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
12079
|
+
forkFromKnot: () => forkFromKnot,
|
|
12080
|
+
formStitch: () => formStitch,
|
|
9603
12081
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
9604
12082
|
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
12083
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
12084
|
+
getFabricValue: () => getFabricValue,
|
|
12085
|
+
getGrantStatus: () => getGrantStatus,
|
|
12086
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
12087
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
9605
12088
|
getSignTarget: () => getSignTarget,
|
|
12089
|
+
grantCoversAction: () => grantCoversAction,
|
|
9606
12090
|
hasScope: () => hasScope,
|
|
9607
12091
|
hashObservation: () => hashObservation,
|
|
12092
|
+
idel: () => idel_exports,
|
|
9608
12093
|
isAdminOpcode: () => isAdminOpcode,
|
|
12094
|
+
isKnotOpen: () => isKnotOpen,
|
|
9609
12095
|
isKnownOpcode: () => isKnownOpcode,
|
|
12096
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
12097
|
+
isRevoked: () => isRevoked,
|
|
9610
12098
|
isTimestampValid: () => isTimestampValid,
|
|
12099
|
+
lockCells: () => lockCells,
|
|
9611
12100
|
loom: () => loom_exports,
|
|
12101
|
+
matchPatterns: () => matchPatterns,
|
|
9612
12102
|
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
12103
|
+
needle: () => needle_exports,
|
|
9613
12104
|
nonce16: () => nonce16,
|
|
9614
12105
|
normalizeSensorDecision: () => normalizeSensorDecision,
|
|
12106
|
+
openKnot: () => openKnot,
|
|
9615
12107
|
packPasskeyLoginOptionsReq: () => packPasskeyLoginOptionsReq,
|
|
9616
12108
|
packPasskeyLoginOptionsRes: () => packPasskeyLoginOptionsRes,
|
|
9617
12109
|
packPasskeyLoginVerifyReq: () => packPasskeyLoginVerifyReq,
|
|
@@ -9620,31 +12112,48 @@ __export(index_exports, {
|
|
|
9620
12112
|
parseAutoClaimEntries: () => parseAutoClaimEntries,
|
|
9621
12113
|
parseScope: () => parseScope,
|
|
9622
12114
|
parseStreamEntries: () => parseStreamEntries,
|
|
12115
|
+
projectAt: () => projectAt,
|
|
12116
|
+
queryFabric: () => queryFabric,
|
|
12117
|
+
recordOccurrence: () => recordOccurrence,
|
|
9623
12118
|
recordSensor: () => recordSensor,
|
|
12119
|
+
renewPresence: () => renewPresence,
|
|
9624
12120
|
resolveTimeout: () => resolveTimeout,
|
|
12121
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9625
12122
|
schemas: () => schemas_exports,
|
|
12123
|
+
scoreTruth: () => scoreTruth,
|
|
9626
12124
|
security: () => security_exports,
|
|
9627
12125
|
sensitivityName: () => sensitivityName,
|
|
9628
12126
|
sensors: () => sensors_exports,
|
|
9629
12127
|
sha256: () => sha2564,
|
|
9630
12128
|
signFrame: () => signFrame,
|
|
12129
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9631
12130
|
stableJsonStringify: () => stableJsonStringify,
|
|
9632
12131
|
startStage: () => startStage,
|
|
12132
|
+
tieKnot: () => tieKnot,
|
|
12133
|
+
timeline: () => timeline_exports,
|
|
9633
12134
|
tlv: () => tlv,
|
|
9634
12135
|
u64be: () => u64be,
|
|
9635
12136
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
9636
12137
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
9637
12138
|
unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
|
|
12139
|
+
updateThreadState: () => updateThreadState,
|
|
9638
12140
|
utf8: () => utf8,
|
|
9639
12141
|
utils: () => utils_exports,
|
|
9640
12142
|
validateFrameShape: () => validateFrameShape,
|
|
12143
|
+
validateGrant: () => validateGrant,
|
|
12144
|
+
validateKnot: () => validateKnot,
|
|
12145
|
+
validateWrit: () => validateWrit,
|
|
9641
12146
|
varintLength: () => varintLength,
|
|
9642
12147
|
varintU: () => varintU,
|
|
9643
12148
|
verifyFrameSignature: () => verifyFrameSignature,
|
|
12149
|
+
verifyObservation: () => verifyObservation,
|
|
12150
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
12151
|
+
verifyReceiptChain: () => verifyReceiptChain,
|
|
9644
12152
|
verifyResponse: () => verifyResponse,
|
|
12153
|
+
weave: () => weave,
|
|
9645
12154
|
withAxisExecutionContext: () => withAxisExecutionContext
|
|
9646
12155
|
});
|
|
9647
|
-
var import_dto_schema, import_axis_id, import_axis_response, import_axis_chain, import_intent2, import_axis_files, import_axis_request, import_observer_discovery, import_observer_dispatcher, import_handler_discovery, import_sensor_discovery, import_observer2, import_sensor2, import_axis_sensor_chain;
|
|
12156
|
+
var import_tlv_field2, import_dto_schema, import_axis_id, import_axis_response, import_axis_chain, import_intent2, import_axis_files, import_axis_request, import_observer_discovery, import_observer_dispatcher, import_handler_discovery, import_sensor_discovery, import_observer2, import_sensor2, import_axis_sensor_chain, import_tps, import_risk_gate, import_tickauth;
|
|
9648
12157
|
var init_index = __esm({
|
|
9649
12158
|
"src/index.ts"() {
|
|
9650
12159
|
init_chain_decorator();
|
|
@@ -9656,7 +12165,7 @@ var init_index = __esm({
|
|
|
9656
12165
|
init_observer_decorator();
|
|
9657
12166
|
init_handler_sensors_decorator();
|
|
9658
12167
|
init_sensor_decorator();
|
|
9659
|
-
|
|
12168
|
+
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
9660
12169
|
import_dto_schema = __toESM(require_dto_schema_util());
|
|
9661
12170
|
init_axis_tlv_dto();
|
|
9662
12171
|
import_axis_id = __toESM(require_axis_id_dto());
|
|
@@ -9669,6 +12178,7 @@ var init_index = __esm({
|
|
|
9669
12178
|
init_stable_json();
|
|
9670
12179
|
init_observation_queue_codec();
|
|
9671
12180
|
init_observation_hash();
|
|
12181
|
+
init_truth_scoring();
|
|
9672
12182
|
init_response_observer();
|
|
9673
12183
|
init_constants();
|
|
9674
12184
|
init_varint();
|
|
@@ -9690,6 +12200,7 @@ var init_index = __esm({
|
|
|
9690
12200
|
init_axis_sensor();
|
|
9691
12201
|
init_scopes();
|
|
9692
12202
|
init_capabilities();
|
|
12203
|
+
init_law();
|
|
9693
12204
|
init_risk();
|
|
9694
12205
|
init_opcodes();
|
|
9695
12206
|
init_receipt();
|
|
@@ -9709,19 +12220,33 @@ var init_index = __esm({
|
|
|
9709
12220
|
import_sensor2 = __toESM(require_sensor_registry());
|
|
9710
12221
|
init_axis_observation();
|
|
9711
12222
|
import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
|
|
12223
|
+
init_timeline_engine();
|
|
12224
|
+
init_timeline_store();
|
|
9712
12225
|
init_cce_pipeline();
|
|
9713
12226
|
init_cce_types();
|
|
9714
12227
|
init_axis_tlv_codec();
|
|
9715
12228
|
init_loom_types();
|
|
12229
|
+
init_loom_engine();
|
|
12230
|
+
init_idel_compiler();
|
|
12231
|
+
init_needle_engine();
|
|
12232
|
+
init_knot_engine();
|
|
12233
|
+
init_fabric_engine();
|
|
12234
|
+
init_pattern_engine();
|
|
12235
|
+
import_tps = __toESM(require_tps_sensor());
|
|
12236
|
+
import_risk_gate = __toESM(require_risk_gate_sensor());
|
|
12237
|
+
import_tickauth = __toESM(require_tickauth_sensor());
|
|
9716
12238
|
init_cce();
|
|
9717
12239
|
init_core();
|
|
9718
12240
|
init_crypto();
|
|
9719
12241
|
init_decorators();
|
|
9720
12242
|
init_engine();
|
|
12243
|
+
init_idel();
|
|
9721
12244
|
init_loom();
|
|
12245
|
+
init_needle();
|
|
9722
12246
|
init_schemas();
|
|
9723
12247
|
init_security();
|
|
9724
12248
|
init_sensors2();
|
|
12249
|
+
init_timeline();
|
|
9725
12250
|
init_utils();
|
|
9726
12251
|
}
|
|
9727
12252
|
});
|
|
@@ -9747,8 +12272,19 @@ var export_RESPONSE_TAG_CREATED_BY = import_axis_response.RESPONSE_TAG_CREATED_B
|
|
|
9747
12272
|
var export_RESPONSE_TAG_ID = import_axis_response.RESPONSE_TAG_ID;
|
|
9748
12273
|
var export_RESPONSE_TAG_UPDATED_AT = import_axis_response.RESPONSE_TAG_UPDATED_AT;
|
|
9749
12274
|
var export_RESPONSE_TAG_UPDATED_BY = import_axis_response.RESPONSE_TAG_UPDATED_BY;
|
|
12275
|
+
var export_RiskGateSensor = import_risk_gate.RiskGateSensor;
|
|
9750
12276
|
var export_SensorDiscoveryService = import_sensor_discovery.SensorDiscoveryService;
|
|
9751
12277
|
var export_SensorRegistry = import_sensor2.SensorRegistry;
|
|
12278
|
+
var export_TLV_FIELDS_KEY = import_tlv_field2.TLV_FIELDS_KEY;
|
|
12279
|
+
var export_TLV_VALIDATORS_KEY = import_tlv_field2.TLV_VALIDATORS_KEY;
|
|
12280
|
+
var export_TickAuthSensor = import_tickauth.TickAuthSensor;
|
|
12281
|
+
var export_TlvEnum = import_tlv_field2.TlvEnum;
|
|
12282
|
+
var export_TlvField = import_tlv_field2.TlvField;
|
|
12283
|
+
var export_TlvMinLen = import_tlv_field2.TlvMinLen;
|
|
12284
|
+
var export_TlvRange = import_tlv_field2.TlvRange;
|
|
12285
|
+
var export_TlvUtf8Pattern = import_tlv_field2.TlvUtf8Pattern;
|
|
12286
|
+
var export_TlvValidate = import_tlv_field2.TlvValidate;
|
|
12287
|
+
var export_TpsSensor = import_tps.TpsSensor;
|
|
9752
12288
|
var export_buildDtoDecoder = import_dto_schema.buildDtoDecoder;
|
|
9753
12289
|
var export_extractDtoSchema = import_dto_schema.extractDtoSchema;
|
|
9754
12290
|
export {
|
|
@@ -9814,6 +12350,10 @@ export {
|
|
|
9814
12350
|
INTENT_SENSITIVITY_MAP,
|
|
9815
12351
|
INTENT_SENSORS_KEY,
|
|
9816
12352
|
INTENT_TIMEOUTS,
|
|
12353
|
+
IdelCompiler,
|
|
12354
|
+
IdelSchemaRegistry,
|
|
12355
|
+
InMemoryPatternStore,
|
|
12356
|
+
InMemoryTimelineStore,
|
|
9817
12357
|
Intent,
|
|
9818
12358
|
IntentBody,
|
|
9819
12359
|
export_IntentRouter as IntentRouter,
|
|
@@ -9855,6 +12395,7 @@ export {
|
|
|
9855
12395
|
export_RESPONSE_TAG_UPDATED_BY as RESPONSE_TAG_UPDATED_BY,
|
|
9856
12396
|
ResponseObserver,
|
|
9857
12397
|
RiskDecision,
|
|
12398
|
+
export_RiskGateSensor as RiskGateSensor,
|
|
9858
12399
|
SENSOR_METADATA_KEY,
|
|
9859
12400
|
Schema2002_PasskeyLoginOptionsRes,
|
|
9860
12401
|
Schema2011_PasskeyLoginVerifyReq,
|
|
@@ -9873,7 +12414,7 @@ export {
|
|
|
9873
12414
|
TLV_EFFECT,
|
|
9874
12415
|
TLV_ERROR_CODE,
|
|
9875
12416
|
TLV_ERROR_MSG,
|
|
9876
|
-
TLV_FIELDS_KEY,
|
|
12417
|
+
export_TLV_FIELDS_KEY as TLV_FIELDS_KEY,
|
|
9877
12418
|
TLV_INDEX,
|
|
9878
12419
|
TLV_INTENT,
|
|
9879
12420
|
TLV_KID,
|
|
@@ -9899,20 +12440,28 @@ export {
|
|
|
9899
12440
|
TLV_TRACE_ID,
|
|
9900
12441
|
TLV_TS,
|
|
9901
12442
|
TLV_UPLOAD_ID,
|
|
9902
|
-
TLV_VALIDATORS_KEY,
|
|
12443
|
+
export_TLV_VALIDATORS_KEY as TLV_VALIDATORS_KEY,
|
|
9903
12444
|
TLV_LOOM_WRIT as TLV_WRIT,
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
12445
|
+
export_TickAuthSensor as TickAuthSensor,
|
|
12446
|
+
TimelineEngine,
|
|
12447
|
+
export_TlvEnum as TlvEnum,
|
|
12448
|
+
export_TlvField as TlvField,
|
|
12449
|
+
export_TlvMinLen as TlvMinLen,
|
|
12450
|
+
export_TlvRange as TlvRange,
|
|
12451
|
+
export_TlvUtf8Pattern as TlvUtf8Pattern,
|
|
12452
|
+
export_TlvValidate as TlvValidate,
|
|
12453
|
+
export_TpsSensor as TpsSensor,
|
|
12454
|
+
addStitchToKnot,
|
|
12455
|
+
applyStitch,
|
|
12456
|
+
assembleNeedle,
|
|
9910
12457
|
axis1SigningBytes,
|
|
9911
12458
|
b64urlDecode,
|
|
9912
12459
|
b64urlDecodeString,
|
|
9913
12460
|
b64urlEncode,
|
|
9914
12461
|
b64urlEncodeString,
|
|
12462
|
+
breakKnot,
|
|
9915
12463
|
buildAts1Hdr,
|
|
12464
|
+
buildAxisLawEvaluationContext,
|
|
9916
12465
|
export_buildDtoDecoder as buildDtoDecoder,
|
|
9917
12466
|
buildPacket,
|
|
9918
12467
|
buildQueueMessage,
|
|
@@ -9931,7 +12480,13 @@ export {
|
|
|
9931
12480
|
computeReceiptHash,
|
|
9932
12481
|
computeSignaturePayload,
|
|
9933
12482
|
core_exports as core,
|
|
12483
|
+
createFabric,
|
|
12484
|
+
createGrant,
|
|
9934
12485
|
createObservation,
|
|
12486
|
+
createPresenceChallenge,
|
|
12487
|
+
createReceipt,
|
|
12488
|
+
createRevocation,
|
|
12489
|
+
createWrit,
|
|
9935
12490
|
crypto_exports as crypto,
|
|
9936
12491
|
decodeArray,
|
|
9937
12492
|
decodeAxis1Frame,
|
|
@@ -9943,6 +12498,10 @@ export {
|
|
|
9943
12498
|
decodeVarint,
|
|
9944
12499
|
decorators_exports as decorators,
|
|
9945
12500
|
deriveAnchorReflection,
|
|
12501
|
+
detectAnomalies,
|
|
12502
|
+
detectKnotPatterns,
|
|
12503
|
+
detectSequencePatterns,
|
|
12504
|
+
diffFabrics,
|
|
9946
12505
|
encVarint,
|
|
9947
12506
|
encodeAxis1Frame,
|
|
9948
12507
|
encodeAxisTlvDto,
|
|
@@ -9953,20 +12512,38 @@ export {
|
|
|
9953
12512
|
endStage,
|
|
9954
12513
|
engine_exports as engine,
|
|
9955
12514
|
executeCcePipeline,
|
|
12515
|
+
executeLoomPipeline,
|
|
9956
12516
|
export_extractDtoSchema as extractDtoSchema,
|
|
9957
12517
|
finalizeObservation,
|
|
12518
|
+
findKnotsForStitch,
|
|
12519
|
+
forkFromKnot,
|
|
12520
|
+
formStitch,
|
|
9958
12521
|
generateEd25519KeyPair,
|
|
9959
12522
|
getAxisExecutionContext,
|
|
12523
|
+
getDecisionPoints,
|
|
12524
|
+
getFabricValue,
|
|
12525
|
+
getGrantStatus,
|
|
12526
|
+
getIrreversibleKnots,
|
|
12527
|
+
getPresenceStatus,
|
|
9960
12528
|
getSignTarget,
|
|
12529
|
+
grantCoversAction,
|
|
9961
12530
|
hasScope,
|
|
9962
12531
|
hashObservation,
|
|
12532
|
+
idel_exports as idel,
|
|
9963
12533
|
isAdminOpcode,
|
|
12534
|
+
isKnotOpen,
|
|
9964
12535
|
isKnownOpcode,
|
|
12536
|
+
isPointOfNoReturn,
|
|
12537
|
+
isRevoked,
|
|
9965
12538
|
isTimestampValid,
|
|
12539
|
+
lockCells,
|
|
9966
12540
|
loom_exports as loom,
|
|
12541
|
+
matchPatterns,
|
|
9967
12542
|
mergeAxisExecutionContext,
|
|
12543
|
+
needle_exports as needle,
|
|
9968
12544
|
nonce16,
|
|
9969
12545
|
normalizeSensorDecision,
|
|
12546
|
+
openKnot,
|
|
9970
12547
|
packPasskeyLoginOptionsReq,
|
|
9971
12548
|
packPasskeyLoginOptionsRes,
|
|
9972
12549
|
packPasskeyLoginVerifyReq,
|
|
@@ -9975,28 +12552,45 @@ export {
|
|
|
9975
12552
|
parseAutoClaimEntries,
|
|
9976
12553
|
parseScope,
|
|
9977
12554
|
parseStreamEntries,
|
|
12555
|
+
projectAt,
|
|
12556
|
+
queryFabric,
|
|
12557
|
+
recordOccurrence,
|
|
9978
12558
|
recordSensor,
|
|
12559
|
+
renewPresence,
|
|
9979
12560
|
resolveTimeout,
|
|
12561
|
+
runNeedlePipeline,
|
|
9980
12562
|
schemas_exports as schemas,
|
|
12563
|
+
scoreTruth,
|
|
9981
12564
|
security_exports as security,
|
|
9982
12565
|
sensitivityName,
|
|
9983
12566
|
sensors_exports as sensors,
|
|
9984
12567
|
sha2564 as sha256,
|
|
9985
12568
|
signFrame,
|
|
12569
|
+
signPresenceChallenge,
|
|
9986
12570
|
stableJsonStringify,
|
|
9987
12571
|
startStage,
|
|
12572
|
+
tieKnot,
|
|
12573
|
+
timeline_exports as timeline,
|
|
9988
12574
|
tlv,
|
|
9989
12575
|
u64be,
|
|
9990
12576
|
unpackPasskeyLoginOptionsReq,
|
|
9991
12577
|
unpackPasskeyLoginVerifyReq,
|
|
9992
12578
|
unpackPasskeyRegisterOptionsReq,
|
|
12579
|
+
updateThreadState,
|
|
9993
12580
|
utf8,
|
|
9994
12581
|
utils_exports as utils,
|
|
9995
12582
|
validateFrameShape,
|
|
12583
|
+
validateGrant,
|
|
12584
|
+
validateKnot,
|
|
12585
|
+
validateWrit,
|
|
9996
12586
|
varintLength,
|
|
9997
12587
|
varintU,
|
|
9998
12588
|
verifyFrameSignature,
|
|
12589
|
+
verifyObservation,
|
|
12590
|
+
verifyPresenceProof,
|
|
12591
|
+
verifyReceiptChain,
|
|
9999
12592
|
verifyResponse,
|
|
12593
|
+
weave,
|
|
10000
12594
|
withAxisExecutionContext
|
|
10001
12595
|
};
|
|
10002
12596
|
//# sourceMappingURL=index.mjs.map
|