@nextera.one/axis-server-sdk 2.1.6 → 2.1.8
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 -267
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +8 -260
- 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 +1407 -523
- package/dist/index.d.ts +1407 -523
- package/dist/index.js +3088 -438
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3094 -430
- 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-DXHfWxLG.d.mts +0 -133
- package/dist/index-DXHfWxLG.d.ts +0 -133
package/dist/index.mjs
CHANGED
|
@@ -334,12 +334,16 @@ __export(intent_decorator_exports, {
|
|
|
334
334
|
import "reflect-metadata";
|
|
335
335
|
function Intent(action, options) {
|
|
336
336
|
return (target, propertyKey) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
const metadata = { intent: action, ...options };
|
|
338
|
+
Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
|
|
339
|
+
if (options?.sensitivity) {
|
|
340
|
+
Reflect.defineMetadata(
|
|
341
|
+
SENSITIVITY_METADATA_KEY,
|
|
342
|
+
options.sensitivity,
|
|
343
|
+
target,
|
|
344
|
+
propertyKey
|
|
345
|
+
);
|
|
346
|
+
}
|
|
343
347
|
const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
|
|
344
348
|
routes.push({
|
|
345
349
|
action,
|
|
@@ -347,10 +351,12 @@ function Intent(action, options) {
|
|
|
347
351
|
absolute: options?.absolute,
|
|
348
352
|
frame: options?.frame,
|
|
349
353
|
kind: options?.kind,
|
|
354
|
+
sensitivity: options?.sensitivity,
|
|
350
355
|
chain: options?.chain,
|
|
351
356
|
bodyProfile: options?.bodyProfile,
|
|
352
357
|
tlv: options?.tlv,
|
|
353
|
-
dto: options?.dto
|
|
358
|
+
dto: options?.dto,
|
|
359
|
+
is: options?.is
|
|
354
360
|
});
|
|
355
361
|
Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
|
|
356
362
|
};
|
|
@@ -358,6 +364,7 @@ function Intent(action, options) {
|
|
|
358
364
|
var INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
|
|
359
365
|
var init_intent_decorator = __esm({
|
|
360
366
|
"src/decorators/intent.decorator.ts"() {
|
|
367
|
+
init_intent_policy_decorator();
|
|
361
368
|
INTENT_METADATA_KEY = "axis:intent";
|
|
362
369
|
INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
363
370
|
}
|
|
@@ -505,76 +512,90 @@ var init_sensor_decorator = __esm({
|
|
|
505
512
|
});
|
|
506
513
|
|
|
507
514
|
// src/decorators/tlv-field.decorator.ts
|
|
508
|
-
var
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
existing
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return (target, propertyKey) => {
|
|
533
|
-
const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
534
|
-
const prop = String(propertyKey);
|
|
535
|
-
let entry = existing.find((e) => e.property === prop);
|
|
536
|
-
if (!entry) {
|
|
537
|
-
entry = { property: prop, tag: 0, validators: [] };
|
|
538
|
-
existing.push(entry);
|
|
515
|
+
var require_tlv_field_decorator = __commonJS({
|
|
516
|
+
"src/decorators/tlv-field.decorator.ts"(exports) {
|
|
517
|
+
"use strict";
|
|
518
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
519
|
+
exports.TLV_VALIDATORS_KEY = exports.TLV_FIELDS_KEY = void 0;
|
|
520
|
+
exports.TlvField = TlvField2;
|
|
521
|
+
exports.TlvValidate = TlvValidate2;
|
|
522
|
+
exports.TlvUtf8Pattern = TlvUtf8Pattern2;
|
|
523
|
+
exports.TlvMinLen = TlvMinLen2;
|
|
524
|
+
exports.TlvEnum = TlvEnum2;
|
|
525
|
+
exports.TlvRange = TlvRange2;
|
|
526
|
+
__require("reflect-metadata");
|
|
527
|
+
exports.TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
528
|
+
exports.TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
529
|
+
var textDecoder = new TextDecoder();
|
|
530
|
+
function assertUniqueFieldMetadata(existing, property, tag) {
|
|
531
|
+
const duplicateProperty = existing.find((item) => item.property === property);
|
|
532
|
+
if (duplicateProperty) {
|
|
533
|
+
throw new Error(`Duplicate @TlvField for property ${property}`);
|
|
534
|
+
}
|
|
535
|
+
const duplicateTag = existing.find((item) => item.tag === tag);
|
|
536
|
+
if (duplicateTag) {
|
|
537
|
+
throw new Error(`Duplicate @TlvField tag ${tag} for ${property}; already used by ${duplicateTag.property}`);
|
|
538
|
+
}
|
|
539
539
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return
|
|
540
|
+
function TlvField2(tag, options) {
|
|
541
|
+
return (target, propertyKey) => {
|
|
542
|
+
const existing = Reflect.getOwnMetadata(exports.TLV_FIELDS_KEY, target.constructor) || [];
|
|
543
|
+
const property = String(propertyKey);
|
|
544
|
+
assertUniqueFieldMetadata(existing, property, tag);
|
|
545
|
+
existing.push({
|
|
546
|
+
property,
|
|
547
|
+
tag,
|
|
548
|
+
options
|
|
549
|
+
});
|
|
550
|
+
Reflect.defineMetadata(exports.TLV_FIELDS_KEY, existing, target.constructor);
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function TlvValidate2(validator) {
|
|
554
|
+
return (target, propertyKey) => {
|
|
555
|
+
const existing = Reflect.getOwnMetadata(exports.TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
556
|
+
const prop = String(propertyKey);
|
|
557
|
+
let entry = existing.find((e) => e.property === prop);
|
|
558
|
+
if (!entry) {
|
|
559
|
+
entry = { property: prop, tag: 0, validators: [] };
|
|
560
|
+
existing.push(entry);
|
|
561
|
+
}
|
|
562
|
+
entry.validators.push(validator);
|
|
563
|
+
Reflect.defineMetadata(exports.TLV_VALIDATORS_KEY, existing, target.constructor);
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
function TlvUtf8Pattern2(pattern, message) {
|
|
567
|
+
const matcher = new RegExp(pattern.source, pattern.flags);
|
|
568
|
+
return TlvValidate2((val, prop) => {
|
|
569
|
+
const str = textDecoder.decode(val);
|
|
570
|
+
matcher.lastIndex = 0;
|
|
571
|
+
return matcher.test(str) ? null : message || `${prop}: failed pattern check`;
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function TlvMinLen2(min, message) {
|
|
575
|
+
return TlvValidate2((val, prop) => {
|
|
576
|
+
return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
function TlvEnum2(allowed, message) {
|
|
580
|
+
const set = new Set(allowed);
|
|
581
|
+
return TlvValidate2((val, prop) => {
|
|
582
|
+
const str = textDecoder.decode(val);
|
|
583
|
+
return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
function TlvRange2(min, max, message) {
|
|
587
|
+
return TlvValidate2((val, prop) => {
|
|
588
|
+
if (val.length !== 8)
|
|
589
|
+
return `${prop}: u64 must be 8 bytes`;
|
|
590
|
+
let n = 0n;
|
|
591
|
+
for (const b of val)
|
|
592
|
+
n = n << 8n | BigInt(b);
|
|
593
|
+
if (n < min || n > max) {
|
|
594
|
+
return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
|
|
595
|
+
}
|
|
596
|
+
return null;
|
|
597
|
+
});
|
|
569
598
|
}
|
|
570
|
-
return null;
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
var TLV_FIELDS_KEY, TLV_VALIDATORS_KEY;
|
|
574
|
-
var init_tlv_field_decorator = __esm({
|
|
575
|
-
"src/decorators/tlv-field.decorator.ts"() {
|
|
576
|
-
TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
577
|
-
TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
578
599
|
}
|
|
579
600
|
});
|
|
580
601
|
|
|
@@ -609,7 +630,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
609
630
|
exports.extractDtoSchema = extractDtoSchema2;
|
|
610
631
|
exports.buildDtoDecoder = buildDtoDecoder2;
|
|
611
632
|
__require("reflect-metadata");
|
|
612
|
-
var tlv_field_decorator_1 = (
|
|
633
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
613
634
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
614
635
|
function extractDtoSchema2(dto) {
|
|
615
636
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
@@ -718,7 +739,7 @@ var require_axis_id_dto = __commonJS({
|
|
|
718
739
|
};
|
|
719
740
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
720
741
|
exports.AxisIdDto = void 0;
|
|
721
|
-
var tlv_field_decorator_1 = (
|
|
742
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
722
743
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
723
744
|
var AxisIdDto2 = class extends axis_tlv_dto_1.AxisTlvDto {
|
|
724
745
|
};
|
|
@@ -736,25 +757,26 @@ import "reflect-metadata";
|
|
|
736
757
|
function AxisPartialType(BaseDto) {
|
|
737
758
|
class PartialDto extends BaseDto {
|
|
738
759
|
}
|
|
739
|
-
const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
|
|
760
|
+
const fields = Reflect.getOwnMetadata(import_tlv_field.TLV_FIELDS_KEY, BaseDto) || [];
|
|
740
761
|
const partialFields = fields.map((f) => ({
|
|
741
762
|
property: f.property,
|
|
742
763
|
tag: f.tag,
|
|
743
764
|
options: { ...f.options, required: false }
|
|
744
765
|
}));
|
|
745
|
-
Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
746
|
-
const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
766
|
+
Reflect.defineMetadata(import_tlv_field.TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
767
|
+
const validators = Reflect.getOwnMetadata(import_tlv_field.TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
747
768
|
if (validators.length > 0) {
|
|
748
|
-
Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
769
|
+
Reflect.defineMetadata(import_tlv_field.TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
749
770
|
}
|
|
750
771
|
Object.defineProperty(PartialDto, "name", {
|
|
751
772
|
value: `Partial${BaseDto.name}`
|
|
752
773
|
});
|
|
753
774
|
return PartialDto;
|
|
754
775
|
}
|
|
776
|
+
var import_tlv_field;
|
|
755
777
|
var init_axis_partial_type = __esm({
|
|
756
778
|
"src/base/axis-partial-type.ts"() {
|
|
757
|
-
|
|
779
|
+
import_tlv_field = __toESM(require_tlv_field_decorator());
|
|
758
780
|
}
|
|
759
781
|
});
|
|
760
782
|
|
|
@@ -773,7 +795,7 @@ var require_axis_response_dto = __commonJS({
|
|
|
773
795
|
};
|
|
774
796
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
775
797
|
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;
|
|
776
|
-
var tlv_field_decorator_1 = (
|
|
798
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
777
799
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
778
800
|
exports.RESPONSE_TAG_ID = 1;
|
|
779
801
|
exports.RESPONSE_TAG_CREATED_AT = 2;
|
|
@@ -2139,6 +2161,121 @@ var init_inline_capsule = __esm({
|
|
|
2139
2161
|
}
|
|
2140
2162
|
});
|
|
2141
2163
|
|
|
2164
|
+
// src/engine/registry/sensor.registry.ts
|
|
2165
|
+
var require_sensor_registry = __commonJS({
|
|
2166
|
+
"src/engine/registry/sensor.registry.ts"(exports) {
|
|
2167
|
+
"use strict";
|
|
2168
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
2169
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2170
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2171
|
+
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;
|
|
2172
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2173
|
+
};
|
|
2174
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
2175
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2176
|
+
};
|
|
2177
|
+
var SensorRegistry_1;
|
|
2178
|
+
var _a;
|
|
2179
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2180
|
+
exports.SensorRegistry = void 0;
|
|
2181
|
+
var common_1 = __require("@nestjs/common");
|
|
2182
|
+
var config_1 = __require("@nestjs/config");
|
|
2183
|
+
var SensorRegistry2 = SensorRegistry_1 = class SensorRegistry {
|
|
2184
|
+
constructor(configService) {
|
|
2185
|
+
this.configService = configService;
|
|
2186
|
+
this.sensors = [];
|
|
2187
|
+
this.sensorsByName = /* @__PURE__ */ new Map();
|
|
2188
|
+
this.sensorsByType = /* @__PURE__ */ new Map();
|
|
2189
|
+
this.logger = new common_1.Logger(SensorRegistry_1.name);
|
|
2190
|
+
}
|
|
2191
|
+
register(sensor) {
|
|
2192
|
+
if (!sensor.name) {
|
|
2193
|
+
throw new Error("AxisSensor must have a name");
|
|
2194
|
+
}
|
|
2195
|
+
const enabledSensorsStr = this.configService.get("ENABLED_SENSORS");
|
|
2196
|
+
const disabledSensorsStr = this.configService.get("DISABLED_SENSORS");
|
|
2197
|
+
const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
|
|
2198
|
+
const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
|
|
2199
|
+
if (enabledSensors && !enabledSensors.includes(sensor.name)) {
|
|
2200
|
+
this.logger.log(`Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`);
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
if (disabledSensors.includes(sensor.name)) {
|
|
2204
|
+
this.logger.log(`Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
if (sensor.order === void 0) {
|
|
2208
|
+
throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
|
|
2209
|
+
}
|
|
2210
|
+
const isPreDecodeSensor = this.isPreDecodeSensor(sensor);
|
|
2211
|
+
const isPostDecodeSensor = this.isPostDecodeSensor(sensor);
|
|
2212
|
+
if (isPreDecodeSensor && sensor.order >= 40) {
|
|
2213
|
+
this.logger.warn(`AxisSensor "${sensor.name}" is marked as PRE_DECODE but has order ${sensor.order} (should be < 40)`);
|
|
2214
|
+
}
|
|
2215
|
+
if (isPostDecodeSensor && sensor.order < 40) {
|
|
2216
|
+
this.logger.warn(`AxisSensor "${sensor.name}" is marked as POST_DECODE but has order ${sensor.order} (should be >= 40)`);
|
|
2217
|
+
}
|
|
2218
|
+
this.sensors.push(sensor);
|
|
2219
|
+
this.indexSensor(sensor);
|
|
2220
|
+
const phaseLabel = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase || "UNKNOWN";
|
|
2221
|
+
this.logger.debug(`Registered sensor: ${sensor.name} (order: ${sensor.order}, phase: ${phaseLabel})`);
|
|
2222
|
+
}
|
|
2223
|
+
list() {
|
|
2224
|
+
return [...this.sensors].sort((a, b) => (a.order ?? 999) - (b.order ?? 999));
|
|
2225
|
+
}
|
|
2226
|
+
resolve(ref) {
|
|
2227
|
+
if (typeof ref === "string") {
|
|
2228
|
+
return this.sensorsByName.get(ref);
|
|
2229
|
+
}
|
|
2230
|
+
return this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
|
|
2231
|
+
}
|
|
2232
|
+
getByName(name) {
|
|
2233
|
+
return this.sensorsByName.get(name);
|
|
2234
|
+
}
|
|
2235
|
+
getPreDecodeSensors() {
|
|
2236
|
+
return this.list().filter((s) => (s.order ?? 999) < 40);
|
|
2237
|
+
}
|
|
2238
|
+
getPostDecodeSensors() {
|
|
2239
|
+
return this.list().filter((s) => (s.order ?? 999) >= 40);
|
|
2240
|
+
}
|
|
2241
|
+
isPreDecodeSensor(sensor) {
|
|
2242
|
+
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
2243
|
+
return phase === "PRE_DECODE" || (sensor.order ?? 999) < 40;
|
|
2244
|
+
}
|
|
2245
|
+
isPostDecodeSensor(sensor) {
|
|
2246
|
+
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
2247
|
+
return phase === "POST_DECODE" || (sensor.order ?? 999) >= 40;
|
|
2248
|
+
}
|
|
2249
|
+
getSensorCountByPhase() {
|
|
2250
|
+
return {
|
|
2251
|
+
preDecodeCount: this.getPreDecodeSensors().length,
|
|
2252
|
+
postDecodeCount: this.getPostDecodeSensors().length
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
clear() {
|
|
2256
|
+
this.sensors = [];
|
|
2257
|
+
this.sensorsByName.clear();
|
|
2258
|
+
this.sensorsByType.clear();
|
|
2259
|
+
}
|
|
2260
|
+
indexSensor(sensor) {
|
|
2261
|
+
this.sensorsByName.set(sensor.name, sensor);
|
|
2262
|
+
const sensorType = sensor.constructor;
|
|
2263
|
+
if (!sensorType)
|
|
2264
|
+
return;
|
|
2265
|
+
this.sensorsByType.set(sensorType, sensor);
|
|
2266
|
+
if (!this.sensorsByName.has(sensorType.name)) {
|
|
2267
|
+
this.sensorsByName.set(sensorType.name, sensor);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
exports.SensorRegistry = SensorRegistry2;
|
|
2272
|
+
exports.SensorRegistry = SensorRegistry2 = SensorRegistry_1 = __decorate([
|
|
2273
|
+
(0, common_1.Injectable)(),
|
|
2274
|
+
__metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
|
|
2275
|
+
], SensorRegistry2);
|
|
2276
|
+
}
|
|
2277
|
+
});
|
|
2278
|
+
|
|
2142
2279
|
// src/engine/intent.router.ts
|
|
2143
2280
|
var require_intent_router = __commonJS({
|
|
2144
2281
|
"src/engine/intent.router.ts"(exports) {
|
|
@@ -2160,6 +2297,7 @@ var require_intent_router = __commonJS({
|
|
|
2160
2297
|
var IntentRouter_1;
|
|
2161
2298
|
var _a;
|
|
2162
2299
|
var _b;
|
|
2300
|
+
var _c;
|
|
2163
2301
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2164
2302
|
exports.IntentRouter = void 0;
|
|
2165
2303
|
var common_1 = __require("@nestjs/common");
|
|
@@ -2180,11 +2318,33 @@ var require_intent_router = __commonJS({
|
|
|
2180
2318
|
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
2181
2319
|
var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
|
|
2182
2320
|
var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
|
|
2321
|
+
var sensor_registry_1 = require_sensor_registry();
|
|
2183
2322
|
var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
|
|
2184
2323
|
var observer_dispatcher_service_1 = require_observer_dispatcher_service();
|
|
2185
2324
|
function observerRefKey(ref) {
|
|
2186
2325
|
return typeof ref === "string" ? ref : ref.name;
|
|
2187
2326
|
}
|
|
2327
|
+
function sensorRefKey(ref) {
|
|
2328
|
+
return typeof ref === "string" ? ref : ref.name;
|
|
2329
|
+
}
|
|
2330
|
+
function mergeIntentSensorRefs(...sensorGroups) {
|
|
2331
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2332
|
+
for (const group of sensorGroups) {
|
|
2333
|
+
if (!Array.isArray(group))
|
|
2334
|
+
continue;
|
|
2335
|
+
for (const ref of group) {
|
|
2336
|
+
const key = sensorRefKey(ref);
|
|
2337
|
+
const existing = merged.get(key);
|
|
2338
|
+
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2339
|
+
merged.set(key, ref);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
return Array.from(merged.values());
|
|
2344
|
+
}
|
|
2345
|
+
function isAxisSensorInstance(value) {
|
|
2346
|
+
return !!value && typeof value.name === "string" && typeof value.run === "function";
|
|
2347
|
+
}
|
|
2188
2348
|
function mergeObserverBindings(bindings) {
|
|
2189
2349
|
const merged = /* @__PURE__ */ new Map();
|
|
2190
2350
|
for (const binding of bindings) {
|
|
@@ -2221,9 +2381,10 @@ var require_intent_router = __commonJS({
|
|
|
2221
2381
|
};
|
|
2222
2382
|
}
|
|
2223
2383
|
var IntentRouter2 = IntentRouter_1 = class IntentRouter {
|
|
2224
|
-
constructor(moduleRef, observerDispatcher) {
|
|
2384
|
+
constructor(moduleRef, observerDispatcher, sensorRegistry) {
|
|
2225
2385
|
this.moduleRef = moduleRef;
|
|
2226
2386
|
this.observerDispatcher = observerDispatcher;
|
|
2387
|
+
this.sensorRegistry = sensorRegistry;
|
|
2227
2388
|
this.logger = new common_1.Logger(IntentRouter_1.name);
|
|
2228
2389
|
this.decoder = new TextDecoder();
|
|
2229
2390
|
this.encoder = new TextEncoder();
|
|
@@ -2391,9 +2552,9 @@ var require_intent_router = __commonJS({
|
|
|
2391
2552
|
if (!handler) {
|
|
2392
2553
|
throw new Error(`Intent not found: ${intent}`);
|
|
2393
2554
|
}
|
|
2394
|
-
const
|
|
2395
|
-
if (
|
|
2396
|
-
await this.runIntentSensors(
|
|
2555
|
+
const sensorRefs = this.intentSensors.get(intent);
|
|
2556
|
+
if (sensorRefs && sensorRefs.length > 0) {
|
|
2557
|
+
await this.runIntentSensors(sensorRefs, intent, frame);
|
|
2397
2558
|
}
|
|
2398
2559
|
const decoder = this.intentDecoders.get(intent);
|
|
2399
2560
|
let decodedBody = frame.body;
|
|
@@ -2464,10 +2625,8 @@ var require_intent_router = __commonJS({
|
|
|
2464
2625
|
this.intentDecoders.set(intent, decoder);
|
|
2465
2626
|
}
|
|
2466
2627
|
const intentSensors = Reflect.getMetadata(intent_sensors_decorator_1.INTENT_SENSORS_KEY, proto, methodName);
|
|
2467
|
-
const
|
|
2468
|
-
|
|
2469
|
-
...Array.isArray(intentSensors) ? intentSensors : []
|
|
2470
|
-
];
|
|
2628
|
+
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
2629
|
+
const combined = mergeIntentSensorRefs(handlerSensors, Array.isArray(intentSensors) ? intentSensors : void 0, Array.isArray(meta?.is) ? meta.is : void 0);
|
|
2471
2630
|
if (combined.length > 0) {
|
|
2472
2631
|
this.intentSensors.set(intent, combined);
|
|
2473
2632
|
}
|
|
@@ -2485,7 +2644,6 @@ var require_intent_router = __commonJS({
|
|
|
2485
2644
|
if (capsulePolicy) {
|
|
2486
2645
|
this.intentCapsulePolicies.set(intent, capsulePolicy);
|
|
2487
2646
|
}
|
|
2488
|
-
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
2489
2647
|
if (meta) {
|
|
2490
2648
|
this.storeSchema({ ...meta, intent });
|
|
2491
2649
|
if (meta.kind) {
|
|
@@ -2499,7 +2657,7 @@ var require_intent_router = __commonJS({
|
|
|
2499
2657
|
}
|
|
2500
2658
|
const methodSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto, methodName);
|
|
2501
2659
|
const classSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto.constructor);
|
|
2502
|
-
const sensitivity = methodSensitivity ?? classSensitivity;
|
|
2660
|
+
const sensitivity = meta?.sensitivity ?? methodSensitivity ?? classSensitivity;
|
|
2503
2661
|
if (sensitivity) {
|
|
2504
2662
|
this.intentSensitivity.set(intent, sensitivity);
|
|
2505
2663
|
}
|
|
@@ -2553,23 +2711,26 @@ var require_intent_router = __commonJS({
|
|
|
2553
2711
|
return;
|
|
2554
2712
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
2555
2713
|
}
|
|
2556
|
-
async runIntentSensors(
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
} catch {
|
|
2564
|
-
this.logger.warn(`@IntentSensors: could not resolve ${SensorClass.name} for ${intent}`);
|
|
2565
|
-
continue;
|
|
2714
|
+
async runIntentSensors(sensorRefs, intent, frame) {
|
|
2715
|
+
for (const sensorRef of sensorRefs) {
|
|
2716
|
+
const sensor = this.resolveIntentSensor(sensorRef);
|
|
2717
|
+
const sensorName = sensorRefKey(sensorRef);
|
|
2718
|
+
if (!sensor) {
|
|
2719
|
+
this.logger.error(`Intent sensor ${sensorName} is not registered for ${intent}`);
|
|
2720
|
+
throw new Error(`SENSOR_MISSING:${sensorName}`);
|
|
2566
2721
|
}
|
|
2567
2722
|
const sensorInput = {
|
|
2568
2723
|
rawBytes: frame.body,
|
|
2569
2724
|
intent,
|
|
2570
2725
|
body: frame.body,
|
|
2571
2726
|
headerTLVs: frame.headers,
|
|
2572
|
-
|
|
2727
|
+
frameBody: frame.body,
|
|
2728
|
+
metadata: {
|
|
2729
|
+
phase: "intent",
|
|
2730
|
+
intent,
|
|
2731
|
+
schema: this.getSchema(intent),
|
|
2732
|
+
validators: this.getValidators(intent)
|
|
2733
|
+
}
|
|
2573
2734
|
};
|
|
2574
2735
|
if (sensor.supports && !sensor.supports(sensorInput))
|
|
2575
2736
|
continue;
|
|
@@ -2581,6 +2742,21 @@ var require_intent_router = __commonJS({
|
|
|
2581
2742
|
}
|
|
2582
2743
|
}
|
|
2583
2744
|
}
|
|
2745
|
+
resolveIntentSensor(ref) {
|
|
2746
|
+
const registered = this.sensorRegistry?.resolve(ref);
|
|
2747
|
+
if (registered) {
|
|
2748
|
+
return registered;
|
|
2749
|
+
}
|
|
2750
|
+
if (!this.moduleRef || typeof ref === "string") {
|
|
2751
|
+
return void 0;
|
|
2752
|
+
}
|
|
2753
|
+
try {
|
|
2754
|
+
const resolved = this.moduleRef.get(ref, { strict: false });
|
|
2755
|
+
return isAxisSensorInstance(resolved) ? resolved : void 0;
|
|
2756
|
+
} catch {
|
|
2757
|
+
return void 0;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2584
2760
|
getEffectiveCapsulePolicy(intent, frame) {
|
|
2585
2761
|
const registeredPolicy = this.intentCapsulePolicies.get(intent);
|
|
2586
2762
|
const chainConfig = this.intentChains.get(intent);
|
|
@@ -2896,7 +3072,8 @@ var require_intent_router = __commonJS({
|
|
|
2896
3072
|
(0, common_1.Injectable)(),
|
|
2897
3073
|
__param(0, (0, common_1.Optional)()),
|
|
2898
3074
|
__param(1, (0, common_1.Optional)()),
|
|
2899
|
-
|
|
3075
|
+
__param(2, (0, common_1.Optional)()),
|
|
3076
|
+
__metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object, typeof (_b = typeof observer_dispatcher_service_1.ObserverDispatcherService !== "undefined" && observer_dispatcher_service_1.ObserverDispatcherService) === "function" ? _b : Object, typeof (_c = typeof sensor_registry_1.SensorRegistry !== "undefined" && sensor_registry_1.SensorRegistry) === "function" ? _c : Object])
|
|
2900
3077
|
], IntentRouter2);
|
|
2901
3078
|
}
|
|
2902
3079
|
});
|
|
@@ -3534,6 +3711,213 @@ var init_observation_hash = __esm({
|
|
|
3534
3711
|
}
|
|
3535
3712
|
});
|
|
3536
3713
|
|
|
3714
|
+
// src/engine/observation/truth-scoring.ts
|
|
3715
|
+
function scoreTruth(obs, expected) {
|
|
3716
|
+
const anomalies = [];
|
|
3717
|
+
let passedChecks = 0;
|
|
3718
|
+
let totalChecks = 0;
|
|
3719
|
+
totalChecks++;
|
|
3720
|
+
if (obs.endMs && obs.decision) {
|
|
3721
|
+
passedChecks++;
|
|
3722
|
+
} else {
|
|
3723
|
+
anomalies.push({
|
|
3724
|
+
code: "OBS_NOT_FINALIZED",
|
|
3725
|
+
level: "critical",
|
|
3726
|
+
message: "Observation was not finalized"
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
totalChecks++;
|
|
3730
|
+
if (obs.stages.length > 0) {
|
|
3731
|
+
passedChecks++;
|
|
3732
|
+
} else {
|
|
3733
|
+
anomalies.push({
|
|
3734
|
+
code: "OBS_NO_STAGES",
|
|
3735
|
+
level: "warning",
|
|
3736
|
+
message: "Observation has no execution stages"
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
totalChecks++;
|
|
3740
|
+
const failedStages = obs.stages.filter((s) => s.status === "fail");
|
|
3741
|
+
if (failedStages.length === 0 || obs.decision === "DENY") {
|
|
3742
|
+
passedChecks++;
|
|
3743
|
+
} else {
|
|
3744
|
+
for (const stage of failedStages) {
|
|
3745
|
+
anomalies.push({
|
|
3746
|
+
code: "STAGE_FAILED",
|
|
3747
|
+
level: "warning",
|
|
3748
|
+
message: `Stage '${stage.name}' failed: ${stage.reason ?? "unknown"}`,
|
|
3749
|
+
field: `stages.${stage.name}`
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
totalChecks++;
|
|
3754
|
+
const invalidSensors = obs.sensors.filter((s) => s.durationMs < 0);
|
|
3755
|
+
if (invalidSensors.length === 0) {
|
|
3756
|
+
passedChecks++;
|
|
3757
|
+
} else {
|
|
3758
|
+
anomalies.push({
|
|
3759
|
+
code: "SENSOR_INVALID_TIMING",
|
|
3760
|
+
level: "warning",
|
|
3761
|
+
message: `${invalidSensors.length} sensor(s) have negative duration`
|
|
3762
|
+
});
|
|
3763
|
+
}
|
|
3764
|
+
totalChecks++;
|
|
3765
|
+
if (obs.durationMs !== void 0 && obs.durationMs >= 0 && obs.durationMs < 3e5) {
|
|
3766
|
+
passedChecks++;
|
|
3767
|
+
} else {
|
|
3768
|
+
anomalies.push({
|
|
3769
|
+
code: "OBS_DURATION_ANOMALY",
|
|
3770
|
+
level: "warning",
|
|
3771
|
+
message: `Observation duration ${obs.durationMs}ms is suspicious`,
|
|
3772
|
+
actual: obs.durationMs
|
|
3773
|
+
});
|
|
3774
|
+
}
|
|
3775
|
+
if (expected) {
|
|
3776
|
+
if (expected.decision !== void 0) {
|
|
3777
|
+
totalChecks++;
|
|
3778
|
+
if (obs.decision === expected.decision) {
|
|
3779
|
+
passedChecks++;
|
|
3780
|
+
} else {
|
|
3781
|
+
anomalies.push({
|
|
3782
|
+
code: "DECISION_MISMATCH",
|
|
3783
|
+
level: "critical",
|
|
3784
|
+
message: `Expected decision '${expected.decision}', got '${obs.decision}'`,
|
|
3785
|
+
field: "decision",
|
|
3786
|
+
expected: expected.decision,
|
|
3787
|
+
actual: obs.decision
|
|
3788
|
+
});
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
if (expected.statusCode !== void 0) {
|
|
3792
|
+
totalChecks++;
|
|
3793
|
+
if (obs.statusCode === expected.statusCode) {
|
|
3794
|
+
passedChecks++;
|
|
3795
|
+
} else {
|
|
3796
|
+
anomalies.push({
|
|
3797
|
+
code: "STATUS_MISMATCH",
|
|
3798
|
+
level: "warning",
|
|
3799
|
+
message: `Expected status ${expected.statusCode}, got ${obs.statusCode}`,
|
|
3800
|
+
field: "statusCode",
|
|
3801
|
+
expected: expected.statusCode,
|
|
3802
|
+
actual: obs.statusCode
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
if (expected.effect !== void 0) {
|
|
3807
|
+
totalChecks++;
|
|
3808
|
+
if (obs.resultCode === expected.effect || obs.facts?.effect === expected.effect) {
|
|
3809
|
+
passedChecks++;
|
|
3810
|
+
} else {
|
|
3811
|
+
anomalies.push({
|
|
3812
|
+
code: "EFFECT_MISMATCH",
|
|
3813
|
+
level: "warning",
|
|
3814
|
+
message: `Expected effect '${expected.effect}', got '${obs.resultCode}'`,
|
|
3815
|
+
field: "resultCode",
|
|
3816
|
+
expected: expected.effect,
|
|
3817
|
+
actual: obs.resultCode
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
if (expected.maxDurationMs !== void 0) {
|
|
3822
|
+
totalChecks++;
|
|
3823
|
+
if (obs.durationMs !== void 0 && obs.durationMs <= expected.maxDurationMs) {
|
|
3824
|
+
passedChecks++;
|
|
3825
|
+
} else {
|
|
3826
|
+
anomalies.push({
|
|
3827
|
+
code: "DURATION_EXCEEDED",
|
|
3828
|
+
level: "warning",
|
|
3829
|
+
message: `Execution took ${obs.durationMs}ms, max allowed ${expected.maxDurationMs}ms`,
|
|
3830
|
+
field: "durationMs",
|
|
3831
|
+
expected: expected.maxDurationMs,
|
|
3832
|
+
actual: obs.durationMs
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
if (expected.minSensorsPassed !== void 0) {
|
|
3837
|
+
totalChecks++;
|
|
3838
|
+
const passed = obs.sensors.filter((s) => s.allowed).length;
|
|
3839
|
+
if (passed >= expected.minSensorsPassed) {
|
|
3840
|
+
passedChecks++;
|
|
3841
|
+
} else {
|
|
3842
|
+
anomalies.push({
|
|
3843
|
+
code: "INSUFFICIENT_SENSORS",
|
|
3844
|
+
level: "warning",
|
|
3845
|
+
message: `Only ${passed} sensors passed, minimum required ${expected.minSensorsPassed}`,
|
|
3846
|
+
field: "sensors",
|
|
3847
|
+
expected: expected.minSensorsPassed,
|
|
3848
|
+
actual: passed
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
if (expected.assertions) {
|
|
3853
|
+
for (const [key, expectedValue] of Object.entries(expected.assertions)) {
|
|
3854
|
+
totalChecks++;
|
|
3855
|
+
const actualValue = obs.facts[key];
|
|
3856
|
+
if (deepEqual(actualValue, expectedValue)) {
|
|
3857
|
+
passedChecks++;
|
|
3858
|
+
} else {
|
|
3859
|
+
anomalies.push({
|
|
3860
|
+
code: "ASSERTION_FAILED",
|
|
3861
|
+
level: "warning",
|
|
3862
|
+
message: `Assertion failed for facts.${key}`,
|
|
3863
|
+
field: `facts.${key}`,
|
|
3864
|
+
expected: expectedValue,
|
|
3865
|
+
actual: actualValue
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
const confidence = totalChecks > 0 ? passedChecks / totalChecks : 0;
|
|
3872
|
+
const hasCritical = anomalies.some((a) => a.level === "critical");
|
|
3873
|
+
const status = computeTruthStatus(confidence, hasCritical, anomalies.length);
|
|
3874
|
+
const isDeed = status === "confirmed" || status === "partial" && !hasCritical;
|
|
3875
|
+
return {
|
|
3876
|
+
status,
|
|
3877
|
+
confidence,
|
|
3878
|
+
anomalies,
|
|
3879
|
+
passedChecks,
|
|
3880
|
+
totalChecks,
|
|
3881
|
+
verifiedAt: Date.now(),
|
|
3882
|
+
isDeed
|
|
3883
|
+
};
|
|
3884
|
+
}
|
|
3885
|
+
function computeTruthStatus(confidence, hasCritical, anomalyCount) {
|
|
3886
|
+
if (hasCritical) return "failed";
|
|
3887
|
+
if (confidence === 1) return "confirmed";
|
|
3888
|
+
if (confidence >= 0.8) return "partial";
|
|
3889
|
+
if (confidence >= 0.5) return "uncertain";
|
|
3890
|
+
return "disputed";
|
|
3891
|
+
}
|
|
3892
|
+
function verifyObservation(obs, expected) {
|
|
3893
|
+
const verdict = scoreTruth(obs, expected);
|
|
3894
|
+
return { observation: obs, verdict };
|
|
3895
|
+
}
|
|
3896
|
+
function deepEqual(a, b) {
|
|
3897
|
+
if (a === b) return true;
|
|
3898
|
+
if (a === null || b === null) return false;
|
|
3899
|
+
if (typeof a !== typeof b) return false;
|
|
3900
|
+
if (typeof a !== "object") return String(a) === String(b);
|
|
3901
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
3902
|
+
if (a.length !== b.length) return false;
|
|
3903
|
+
return a.every((v, i) => deepEqual(v, b[i]));
|
|
3904
|
+
}
|
|
3905
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
3906
|
+
const aKeys = Object.keys(a);
|
|
3907
|
+
const bKeys = Object.keys(b);
|
|
3908
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
3909
|
+
return aKeys.every(
|
|
3910
|
+
(key) => deepEqual(
|
|
3911
|
+
a[key],
|
|
3912
|
+
b[key]
|
|
3913
|
+
)
|
|
3914
|
+
);
|
|
3915
|
+
}
|
|
3916
|
+
var init_truth_scoring = __esm({
|
|
3917
|
+
"src/engine/observation/truth-scoring.ts"() {
|
|
3918
|
+
}
|
|
3919
|
+
});
|
|
3920
|
+
|
|
3537
3921
|
// src/engine/observation/response-observer.ts
|
|
3538
3922
|
function verifyResponse(ctx, response) {
|
|
3539
3923
|
if (!response.effect || typeof response.effect !== "string") {
|
|
@@ -3608,92 +3992,14 @@ __export(axis_bin_exports, {
|
|
|
3608
3992
|
getSignTarget: () => getSignTarget
|
|
3609
3993
|
});
|
|
3610
3994
|
import * as z from "zod";
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
}))
|
|
3617
|
-
);
|
|
3618
|
-
if (hdrBytes.length > MAX_HDR_LEN) throw new Error("Header too large");
|
|
3619
|
-
if (frame.body.length > MAX_BODY_LEN) throw new Error("Body too large");
|
|
3620
|
-
if (frame.sig.length > MAX_SIG_LEN) throw new Error("Signature too large");
|
|
3621
|
-
const hdrLenBytes = encodeVarint(hdrBytes.length);
|
|
3622
|
-
const bodyLenBytes = encodeVarint(frame.body.length);
|
|
3623
|
-
const sigLenBytes = encodeVarint(frame.sig.length);
|
|
3624
|
-
const totalLen = 5 + // Magic (AXIS1)
|
|
3625
|
-
1 + // Version
|
|
3626
|
-
1 + // Flags
|
|
3627
|
-
hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
|
|
3628
|
-
if (totalLen > MAX_FRAME_LEN) throw new Error("Total frame too large");
|
|
3629
|
-
const buf = new Uint8Array(totalLen);
|
|
3630
|
-
let offset = 0;
|
|
3631
|
-
buf.set(AXIS_MAGIC, offset);
|
|
3632
|
-
offset += 5;
|
|
3633
|
-
buf[offset++] = AXIS_VERSION;
|
|
3634
|
-
buf[offset++] = frame.flags;
|
|
3635
|
-
buf.set(hdrLenBytes, offset);
|
|
3636
|
-
offset += hdrLenBytes.length;
|
|
3637
|
-
buf.set(bodyLenBytes, offset);
|
|
3638
|
-
offset += bodyLenBytes.length;
|
|
3639
|
-
buf.set(sigLenBytes, offset);
|
|
3640
|
-
offset += sigLenBytes.length;
|
|
3641
|
-
buf.set(hdrBytes, offset);
|
|
3642
|
-
offset += hdrBytes.length;
|
|
3643
|
-
buf.set(frame.body, offset);
|
|
3644
|
-
offset += frame.body.length;
|
|
3645
|
-
buf.set(frame.sig, offset);
|
|
3646
|
-
offset += frame.sig.length;
|
|
3647
|
-
return buf;
|
|
3648
|
-
}
|
|
3649
|
-
function decodeFrame(buf) {
|
|
3650
|
-
let offset = 0;
|
|
3651
|
-
if (offset + 5 > buf.length) throw new Error("Packet too short");
|
|
3652
|
-
for (let i = 0; i < 5; i++) {
|
|
3653
|
-
if (buf[offset + i] !== AXIS_MAGIC[i]) throw new Error("Invalid Magic");
|
|
3654
|
-
}
|
|
3655
|
-
offset += 5;
|
|
3656
|
-
const ver = buf[offset++];
|
|
3657
|
-
if (ver !== AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
|
|
3658
|
-
const flags = buf[offset++];
|
|
3659
|
-
const { value: hdrLen, length: hlLen } = decodeVarint(buf, offset);
|
|
3660
|
-
offset += hlLen;
|
|
3661
|
-
if (hdrLen > MAX_HDR_LEN) throw new Error("Header limit exceeded");
|
|
3662
|
-
const { value: bodyLen, length: blLen } = decodeVarint(buf, offset);
|
|
3663
|
-
offset += blLen;
|
|
3664
|
-
if (bodyLen > MAX_BODY_LEN) throw new Error("Body limit exceeded");
|
|
3665
|
-
const { value: sigLen, length: slLen } = decodeVarint(buf, offset);
|
|
3666
|
-
offset += slLen;
|
|
3667
|
-
if (sigLen > MAX_SIG_LEN) throw new Error("Signature limit exceeded");
|
|
3668
|
-
if (offset + hdrLen + bodyLen + sigLen > buf.length) {
|
|
3669
|
-
throw new Error("Frame truncated");
|
|
3670
|
-
}
|
|
3671
|
-
const hdrBytes = buf.slice(offset, offset + hdrLen);
|
|
3672
|
-
offset += hdrLen;
|
|
3673
|
-
const bodyBytes = buf.slice(offset, offset + bodyLen);
|
|
3674
|
-
offset += bodyLen;
|
|
3675
|
-
const sigBytes = buf.slice(offset, offset + sigLen);
|
|
3676
|
-
offset += sigLen;
|
|
3677
|
-
const headers = decodeTLVs(hdrBytes);
|
|
3678
|
-
return {
|
|
3679
|
-
flags,
|
|
3680
|
-
headers,
|
|
3681
|
-
body: bodyBytes,
|
|
3682
|
-
sig: sigBytes
|
|
3683
|
-
};
|
|
3684
|
-
}
|
|
3685
|
-
function getSignTarget(frame) {
|
|
3686
|
-
return encodeFrame({
|
|
3687
|
-
...frame,
|
|
3688
|
-
sig: new Uint8Array(0)
|
|
3689
|
-
});
|
|
3690
|
-
}
|
|
3995
|
+
import {
|
|
3996
|
+
decodeFrame,
|
|
3997
|
+
encodeFrame,
|
|
3998
|
+
getSignTarget
|
|
3999
|
+
} from "@nextera.one/axis-protocol";
|
|
3691
4000
|
var AxisFrameZ;
|
|
3692
4001
|
var init_axis_bin = __esm({
|
|
3693
4002
|
"src/core/axis-bin.ts"() {
|
|
3694
|
-
init_constants();
|
|
3695
|
-
init_tlv();
|
|
3696
|
-
init_varint();
|
|
3697
4003
|
AxisFrameZ = z.object({
|
|
3698
4004
|
/** Flag bits for protocol control (e.g., encryption, compression) */
|
|
3699
4005
|
flags: z.number().int().nonnegative(),
|
|
@@ -3713,12 +4019,7 @@ var init_axis_bin = __esm({
|
|
|
3713
4019
|
// src/core/signature.ts
|
|
3714
4020
|
import * as crypto2 from "crypto";
|
|
3715
4021
|
function computeSignaturePayload(frame) {
|
|
3716
|
-
|
|
3717
|
-
...frame,
|
|
3718
|
-
sig: new Uint8Array(0)
|
|
3719
|
-
};
|
|
3720
|
-
const encoded = encodeFrame(frameWithoutSig);
|
|
3721
|
-
return Buffer.from(encoded);
|
|
4022
|
+
return Buffer.from(getSignTarget(frame));
|
|
3722
4023
|
}
|
|
3723
4024
|
function signFrame(frame, privateKey) {
|
|
3724
4025
|
const payload = computeSignaturePayload(frame);
|
|
@@ -4599,11 +4900,12 @@ var init_tlv_encode = __esm({
|
|
|
4599
4900
|
});
|
|
4600
4901
|
|
|
4601
4902
|
// src/codec/axis1.encode.ts
|
|
4903
|
+
import { AXIS_MAGIC as AXIS_MAGIC2, AXIS_VERSION as AXIS_VERSION2 } from "@nextera.one/axis-protocol";
|
|
4602
4904
|
function encodeAxis1Frame(f) {
|
|
4603
4905
|
if (!Buffer.isBuffer(f.hdr) || !Buffer.isBuffer(f.body) || !Buffer.isBuffer(f.sig)) {
|
|
4604
4906
|
throw new Error("AXIS1_BAD_BUFFERS");
|
|
4605
4907
|
}
|
|
4606
|
-
if (f.ver !==
|
|
4908
|
+
if (f.ver !== AXIS_VERSION2) throw new Error("AXIS1_BAD_VER");
|
|
4607
4909
|
const hdrLen = encVarint(BigInt(f.hdr.length));
|
|
4608
4910
|
const bodyLen = encVarint(BigInt(f.body.length));
|
|
4609
4911
|
const sigLen = encVarint(BigInt(f.sig.length));
|
|
@@ -4623,13 +4925,14 @@ var MAGIC;
|
|
|
4623
4925
|
var init_axis1_encode = __esm({
|
|
4624
4926
|
"src/codec/axis1.encode.ts"() {
|
|
4625
4927
|
init_tlv_encode();
|
|
4626
|
-
MAGIC = Buffer.from(
|
|
4928
|
+
MAGIC = Buffer.from(AXIS_MAGIC2);
|
|
4627
4929
|
}
|
|
4628
4930
|
});
|
|
4629
4931
|
|
|
4630
4932
|
// src/codec/axis1.signing.ts
|
|
4933
|
+
import { AXIS_MAGIC as AXIS_MAGIC3, AXIS_VERSION as AXIS_VERSION3 } from "@nextera.one/axis-protocol";
|
|
4631
4934
|
function axis1SigningBytes(params) {
|
|
4632
|
-
if (params.ver !==
|
|
4935
|
+
if (params.ver !== AXIS_VERSION3) throw new Error("AXIS1_BAD_VER");
|
|
4633
4936
|
const hdrLen = encVarint(BigInt(params.hdr.length));
|
|
4634
4937
|
const bodyLen = encVarint(BigInt(params.body.length));
|
|
4635
4938
|
const sigLenZero = encVarint(0n);
|
|
@@ -4648,7 +4951,7 @@ var MAGIC2;
|
|
|
4648
4951
|
var init_axis1_signing = __esm({
|
|
4649
4952
|
"src/codec/axis1.signing.ts"() {
|
|
4650
4953
|
init_tlv_encode();
|
|
4651
|
-
MAGIC2 = Buffer.from(
|
|
4954
|
+
MAGIC2 = Buffer.from(AXIS_MAGIC3);
|
|
4652
4955
|
}
|
|
4653
4956
|
});
|
|
4654
4957
|
|
|
@@ -4948,6 +5251,7 @@ var init_tlv2 = __esm({
|
|
|
4948
5251
|
});
|
|
4949
5252
|
|
|
4950
5253
|
// src/types/frame.ts
|
|
5254
|
+
import { AXIS_MAGIC as AXIS_MAGIC4 } from "@nextera.one/axis-protocol";
|
|
4951
5255
|
function decodeAxis1Frame(buf) {
|
|
4952
5256
|
let off = 0;
|
|
4953
5257
|
const magic = buf.subarray(off, off + 5);
|
|
@@ -4982,7 +5286,7 @@ var MAGIC3;
|
|
|
4982
5286
|
var init_frame = __esm({
|
|
4983
5287
|
"src/types/frame.ts"() {
|
|
4984
5288
|
init_tlv2();
|
|
4985
|
-
MAGIC3 = Buffer.from(
|
|
5289
|
+
MAGIC3 = Buffer.from(AXIS_MAGIC4);
|
|
4986
5290
|
}
|
|
4987
5291
|
});
|
|
4988
5292
|
|
|
@@ -5105,7 +5409,52 @@ var init_capabilities = __esm({
|
|
|
5105
5409
|
}
|
|
5106
5410
|
});
|
|
5107
5411
|
|
|
5412
|
+
// src/law/law.types.ts
|
|
5413
|
+
function buildAxisLawEvaluationContext(input) {
|
|
5414
|
+
const metadata = input.metadata ?? {};
|
|
5415
|
+
const packet = input.packet;
|
|
5416
|
+
const packetBody = input.frameBody ?? packet?.body ?? packet?.args ?? void 0;
|
|
5417
|
+
const capsuleId = metadata.capsule_id ?? metadata.capsuleId ?? packet?.capsuleId ?? input.clientId;
|
|
5418
|
+
const audience = input.aud ?? metadata.audience ?? packet?.aud;
|
|
5419
|
+
const tps = metadata.tps ?? packet?.tps ?? packet?.tickTps;
|
|
5420
|
+
return {
|
|
5421
|
+
actorId: input.actorId,
|
|
5422
|
+
intent: input.intent,
|
|
5423
|
+
audience,
|
|
5424
|
+
tps,
|
|
5425
|
+
country: input.country,
|
|
5426
|
+
ip: input.ip,
|
|
5427
|
+
path: input.path,
|
|
5428
|
+
clientId: input.clientId,
|
|
5429
|
+
deviceId: input.deviceId,
|
|
5430
|
+
sessionId: input.sessionId,
|
|
5431
|
+
capsuleId,
|
|
5432
|
+
metadata,
|
|
5433
|
+
packet,
|
|
5434
|
+
frameBody: packetBody
|
|
5435
|
+
};
|
|
5436
|
+
}
|
|
5437
|
+
var init_law_types = __esm({
|
|
5438
|
+
"src/law/law.types.ts"() {
|
|
5439
|
+
}
|
|
5440
|
+
});
|
|
5441
|
+
|
|
5442
|
+
// src/law/index.ts
|
|
5443
|
+
var law_exports = {};
|
|
5444
|
+
__export(law_exports, {
|
|
5445
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext
|
|
5446
|
+
});
|
|
5447
|
+
var init_law = __esm({
|
|
5448
|
+
"src/law/index.ts"() {
|
|
5449
|
+
init_law_types();
|
|
5450
|
+
}
|
|
5451
|
+
});
|
|
5452
|
+
|
|
5108
5453
|
// src/risk/index.ts
|
|
5454
|
+
var risk_exports = {};
|
|
5455
|
+
__export(risk_exports, {
|
|
5456
|
+
RiskDecision: () => RiskDecision
|
|
5457
|
+
});
|
|
5109
5458
|
var RiskDecision;
|
|
5110
5459
|
var init_risk = __esm({
|
|
5111
5460
|
"src/risk/index.ts"() {
|
|
@@ -5848,100 +6197,9 @@ var require_handler_discovery_service = __commonJS({
|
|
|
5848
6197
|
}
|
|
5849
6198
|
});
|
|
5850
6199
|
|
|
5851
|
-
// src/engine/
|
|
5852
|
-
var
|
|
5853
|
-
"src/engine/
|
|
5854
|
-
"use strict";
|
|
5855
|
-
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
5856
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5857
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5858
|
-
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;
|
|
5859
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5860
|
-
};
|
|
5861
|
-
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
5862
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5863
|
-
};
|
|
5864
|
-
var SensorRegistry_1;
|
|
5865
|
-
var _a;
|
|
5866
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5867
|
-
exports.SensorRegistry = void 0;
|
|
5868
|
-
var common_1 = __require("@nestjs/common");
|
|
5869
|
-
var config_1 = __require("@nestjs/config");
|
|
5870
|
-
var SensorRegistry2 = SensorRegistry_1 = class SensorRegistry {
|
|
5871
|
-
constructor(configService) {
|
|
5872
|
-
this.configService = configService;
|
|
5873
|
-
this.sensors = [];
|
|
5874
|
-
this.logger = new common_1.Logger(SensorRegistry_1.name);
|
|
5875
|
-
}
|
|
5876
|
-
register(sensor) {
|
|
5877
|
-
if (!sensor.name) {
|
|
5878
|
-
throw new Error("AxisSensor must have a name");
|
|
5879
|
-
}
|
|
5880
|
-
const enabledSensorsStr = this.configService.get("ENABLED_SENSORS");
|
|
5881
|
-
const disabledSensorsStr = this.configService.get("DISABLED_SENSORS");
|
|
5882
|
-
const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
|
|
5883
|
-
const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
|
|
5884
|
-
if (enabledSensors && !enabledSensors.includes(sensor.name)) {
|
|
5885
|
-
this.logger.log(`Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`);
|
|
5886
|
-
return;
|
|
5887
|
-
}
|
|
5888
|
-
if (disabledSensors.includes(sensor.name)) {
|
|
5889
|
-
this.logger.log(`Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`);
|
|
5890
|
-
return;
|
|
5891
|
-
}
|
|
5892
|
-
if (sensor.order === void 0) {
|
|
5893
|
-
throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
|
|
5894
|
-
}
|
|
5895
|
-
const isPreDecodeSensor = this.isPreDecodeSensor(sensor);
|
|
5896
|
-
const isPostDecodeSensor = this.isPostDecodeSensor(sensor);
|
|
5897
|
-
if (isPreDecodeSensor && sensor.order >= 40) {
|
|
5898
|
-
this.logger.warn(`AxisSensor "${sensor.name}" is marked as PRE_DECODE but has order ${sensor.order} (should be < 40)`);
|
|
5899
|
-
}
|
|
5900
|
-
if (isPostDecodeSensor && sensor.order < 40) {
|
|
5901
|
-
this.logger.warn(`AxisSensor "${sensor.name}" is marked as POST_DECODE but has order ${sensor.order} (should be >= 40)`);
|
|
5902
|
-
}
|
|
5903
|
-
this.sensors.push(sensor);
|
|
5904
|
-
const phaseLabel = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase || "UNKNOWN";
|
|
5905
|
-
this.logger.debug(`Registered sensor: ${sensor.name} (order: ${sensor.order}, phase: ${phaseLabel})`);
|
|
5906
|
-
}
|
|
5907
|
-
list() {
|
|
5908
|
-
return [...this.sensors].sort((a, b) => (a.order ?? 999) - (b.order ?? 999));
|
|
5909
|
-
}
|
|
5910
|
-
getPreDecodeSensors() {
|
|
5911
|
-
return this.list().filter((s) => (s.order ?? 999) < 40);
|
|
5912
|
-
}
|
|
5913
|
-
getPostDecodeSensors() {
|
|
5914
|
-
return this.list().filter((s) => (s.order ?? 999) >= 40);
|
|
5915
|
-
}
|
|
5916
|
-
isPreDecodeSensor(sensor) {
|
|
5917
|
-
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
5918
|
-
return phase === "PRE_DECODE" || (sensor.order ?? 999) < 40;
|
|
5919
|
-
}
|
|
5920
|
-
isPostDecodeSensor(sensor) {
|
|
5921
|
-
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
5922
|
-
return phase === "POST_DECODE" || (sensor.order ?? 999) >= 40;
|
|
5923
|
-
}
|
|
5924
|
-
getSensorCountByPhase() {
|
|
5925
|
-
return {
|
|
5926
|
-
preDecodeCount: this.getPreDecodeSensors().length,
|
|
5927
|
-
postDecodeCount: this.getPostDecodeSensors().length
|
|
5928
|
-
};
|
|
5929
|
-
}
|
|
5930
|
-
clear() {
|
|
5931
|
-
this.sensors = [];
|
|
5932
|
-
}
|
|
5933
|
-
};
|
|
5934
|
-
exports.SensorRegistry = SensorRegistry2;
|
|
5935
|
-
exports.SensorRegistry = SensorRegistry2 = SensorRegistry_1 = __decorate([
|
|
5936
|
-
(0, common_1.Injectable)(),
|
|
5937
|
-
__metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
|
|
5938
|
-
], SensorRegistry2);
|
|
5939
|
-
}
|
|
5940
|
-
});
|
|
5941
|
-
|
|
5942
|
-
// src/engine/sensor-discovery.service.ts
|
|
5943
|
-
var require_sensor_discovery_service = __commonJS({
|
|
5944
|
-
"src/engine/sensor-discovery.service.ts"(exports) {
|
|
6200
|
+
// src/engine/sensor-discovery.service.ts
|
|
6201
|
+
var require_sensor_discovery_service = __commonJS({
|
|
6202
|
+
"src/engine/sensor-discovery.service.ts"(exports) {
|
|
5945
6203
|
"use strict";
|
|
5946
6204
|
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
5947
6205
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6176,6 +6434,374 @@ var require_axis_sensor_chain_service = __commonJS({
|
|
|
6176
6434
|
}
|
|
6177
6435
|
});
|
|
6178
6436
|
|
|
6437
|
+
// src/timeline/timeline.engine.ts
|
|
6438
|
+
import { createHash as createHash5, randomBytes as randomBytes6 } from "crypto";
|
|
6439
|
+
function generateId(prefix) {
|
|
6440
|
+
return `${prefix}_${randomBytes6(16).toString("hex")}`;
|
|
6441
|
+
}
|
|
6442
|
+
function sha2566(data) {
|
|
6443
|
+
return createHash5("sha256").update(data).digest("hex");
|
|
6444
|
+
}
|
|
6445
|
+
function hashPayload2(payload) {
|
|
6446
|
+
return sha2566(JSON.stringify(payload));
|
|
6447
|
+
}
|
|
6448
|
+
function diffObjects(a, b) {
|
|
6449
|
+
const diffs = [];
|
|
6450
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
6451
|
+
for (const key of allKeys) {
|
|
6452
|
+
const va = a[key];
|
|
6453
|
+
const vb = b[key];
|
|
6454
|
+
if (JSON.stringify(va) !== JSON.stringify(vb)) {
|
|
6455
|
+
diffs.push({ field: key, original: va, replayed: vb });
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6458
|
+
return diffs;
|
|
6459
|
+
}
|
|
6460
|
+
var TimelineEngine;
|
|
6461
|
+
var init_timeline_engine = __esm({
|
|
6462
|
+
"src/timeline/timeline.engine.ts"() {
|
|
6463
|
+
TimelineEngine = class {
|
|
6464
|
+
constructor(store) {
|
|
6465
|
+
this.store = store;
|
|
6466
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
6467
|
+
}
|
|
6468
|
+
/** Register an intent handler for timeline execution */
|
|
6469
|
+
registerHandler(handler) {
|
|
6470
|
+
this.handlers.set(handler.intent, handler);
|
|
6471
|
+
}
|
|
6472
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6473
|
+
// Record (store a real execution as a timeline event)
|
|
6474
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6475
|
+
async recordEvent(intent, actorId, payload, result, options = {}) {
|
|
6476
|
+
const event = {
|
|
6477
|
+
event_id: generateId("evt"),
|
|
6478
|
+
timeline_id: options.timelineId ?? "prime",
|
|
6479
|
+
branch_id: options.branchId ?? "main",
|
|
6480
|
+
parent_event_id: options.parentEventId ?? null,
|
|
6481
|
+
intent,
|
|
6482
|
+
actor_id: actorId,
|
|
6483
|
+
capsule_id: options.capsuleId,
|
|
6484
|
+
tps_coordinate: options.tpsCoordinate,
|
|
6485
|
+
payload_hash: hashPayload2(payload),
|
|
6486
|
+
result_hash: hashPayload2(result),
|
|
6487
|
+
status: "executed",
|
|
6488
|
+
domain: "prime",
|
|
6489
|
+
determinism: options.determinism ?? "deterministic",
|
|
6490
|
+
witness_id: options.witnessId,
|
|
6491
|
+
created_at: Date.now(),
|
|
6492
|
+
metadata: { payload, result }
|
|
6493
|
+
};
|
|
6494
|
+
await this.store.saveEvent(event);
|
|
6495
|
+
return event;
|
|
6496
|
+
}
|
|
6497
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6498
|
+
// Replay
|
|
6499
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6500
|
+
async replay(request) {
|
|
6501
|
+
const originalEvent = await this.store.getEvent(request.source_event_id);
|
|
6502
|
+
if (!originalEvent) {
|
|
6503
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6504
|
+
}
|
|
6505
|
+
const handler = this.handlers.get(originalEvent.intent);
|
|
6506
|
+
if (!handler) {
|
|
6507
|
+
throw new Error(`No handler registered for intent '${originalEvent.intent}'`);
|
|
6508
|
+
}
|
|
6509
|
+
const originalPayload = originalEvent.metadata?.payload ?? {};
|
|
6510
|
+
const replayPayload = request.mode === "analytical" && request.override_payload ? request.override_payload : originalPayload;
|
|
6511
|
+
const snapshot = await this.store.getSnapshotByEvent(originalEvent.event_id);
|
|
6512
|
+
const context = {
|
|
6513
|
+
event_id: generateId("evt"),
|
|
6514
|
+
timeline_id: originalEvent.timeline_id,
|
|
6515
|
+
branch_id: `replay_${originalEvent.branch_id}`,
|
|
6516
|
+
domain: "audit",
|
|
6517
|
+
actor_id: originalEvent.actor_id,
|
|
6518
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6519
|
+
snapshot: snapshot ?? void 0,
|
|
6520
|
+
is_replay: true,
|
|
6521
|
+
is_simulation: false
|
|
6522
|
+
};
|
|
6523
|
+
const startMs = Date.now();
|
|
6524
|
+
const handlerResult = await handler.execute(replayPayload, context);
|
|
6525
|
+
const durationMs = Date.now() - startMs;
|
|
6526
|
+
const replayedEvent = {
|
|
6527
|
+
event_id: context.event_id,
|
|
6528
|
+
timeline_id: originalEvent.timeline_id,
|
|
6529
|
+
branch_id: context.branch_id,
|
|
6530
|
+
parent_event_id: originalEvent.event_id,
|
|
6531
|
+
intent: originalEvent.intent,
|
|
6532
|
+
actor_id: originalEvent.actor_id,
|
|
6533
|
+
capsule_id: originalEvent.capsule_id,
|
|
6534
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6535
|
+
payload_hash: hashPayload2(replayPayload),
|
|
6536
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6537
|
+
status: "replayed",
|
|
6538
|
+
domain: "audit",
|
|
6539
|
+
determinism: originalEvent.determinism,
|
|
6540
|
+
created_at: Date.now(),
|
|
6541
|
+
metadata: { payload: replayPayload, result: handlerResult.result_data }
|
|
6542
|
+
};
|
|
6543
|
+
await this.store.saveEvent(replayedEvent);
|
|
6544
|
+
const originalResult = originalEvent.metadata?.result ?? {};
|
|
6545
|
+
const differences = diffObjects(originalResult, handlerResult.result_data);
|
|
6546
|
+
const deterministicMatch = originalEvent.result_hash === replayedEvent.result_hash;
|
|
6547
|
+
return {
|
|
6548
|
+
original_event: originalEvent,
|
|
6549
|
+
replayed_event: replayedEvent,
|
|
6550
|
+
mode: request.mode,
|
|
6551
|
+
deterministic_match: deterministicMatch,
|
|
6552
|
+
differences,
|
|
6553
|
+
duration_ms: durationMs
|
|
6554
|
+
};
|
|
6555
|
+
}
|
|
6556
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6557
|
+
// Fork
|
|
6558
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6559
|
+
async fork(request) {
|
|
6560
|
+
const sourceEvent = await this.store.getEvent(request.source_event_id);
|
|
6561
|
+
if (!sourceEvent) {
|
|
6562
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6563
|
+
}
|
|
6564
|
+
const handler = this.handlers.get(sourceEvent.intent);
|
|
6565
|
+
if (!handler) {
|
|
6566
|
+
throw new Error(`No handler registered for intent '${sourceEvent.intent}'`);
|
|
6567
|
+
}
|
|
6568
|
+
const branch = {
|
|
6569
|
+
branch_id: generateId("branch"),
|
|
6570
|
+
timeline_id: generateId("timeline"),
|
|
6571
|
+
origin_timeline_id: sourceEvent.timeline_id,
|
|
6572
|
+
origin_event_id: sourceEvent.event_id,
|
|
6573
|
+
branch_type: "fork",
|
|
6574
|
+
creator_subject_id: request.actor_id,
|
|
6575
|
+
purpose: request.purpose,
|
|
6576
|
+
status: "active"
|
|
6577
|
+
};
|
|
6578
|
+
await this.store.saveBranch(branch);
|
|
6579
|
+
const snapshot = {
|
|
6580
|
+
snapshot_id: generateId("snap"),
|
|
6581
|
+
timeline_id: sourceEvent.timeline_id,
|
|
6582
|
+
event_id: sourceEvent.event_id,
|
|
6583
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6584
|
+
state_hash: hashPayload2(
|
|
6585
|
+
sourceEvent.metadata?.result ?? {}
|
|
6586
|
+
),
|
|
6587
|
+
state_data: sourceEvent.metadata?.result ?? {},
|
|
6588
|
+
created_at: Date.now()
|
|
6589
|
+
};
|
|
6590
|
+
await this.store.saveSnapshot(snapshot);
|
|
6591
|
+
const context = {
|
|
6592
|
+
event_id: generateId("evt"),
|
|
6593
|
+
timeline_id: branch.timeline_id,
|
|
6594
|
+
branch_id: branch.branch_id,
|
|
6595
|
+
domain: "fork",
|
|
6596
|
+
actor_id: request.actor_id,
|
|
6597
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6598
|
+
snapshot,
|
|
6599
|
+
is_replay: false,
|
|
6600
|
+
is_simulation: false
|
|
6601
|
+
};
|
|
6602
|
+
const handlerResult = await handler.execute(request.new_payload, context);
|
|
6603
|
+
const forkedEvent = {
|
|
6604
|
+
event_id: context.event_id,
|
|
6605
|
+
timeline_id: branch.timeline_id,
|
|
6606
|
+
branch_id: branch.branch_id,
|
|
6607
|
+
parent_event_id: sourceEvent.event_id,
|
|
6608
|
+
intent: sourceEvent.intent,
|
|
6609
|
+
actor_id: request.actor_id,
|
|
6610
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6611
|
+
payload_hash: hashPayload2(request.new_payload),
|
|
6612
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6613
|
+
status: "forked",
|
|
6614
|
+
domain: "fork",
|
|
6615
|
+
determinism: sourceEvent.determinism,
|
|
6616
|
+
created_at: Date.now(),
|
|
6617
|
+
metadata: {
|
|
6618
|
+
payload: request.new_payload,
|
|
6619
|
+
result: handlerResult.result_data
|
|
6620
|
+
}
|
|
6621
|
+
};
|
|
6622
|
+
await this.store.saveEvent(forkedEvent);
|
|
6623
|
+
return { branch, forked_event: forkedEvent, snapshot };
|
|
6624
|
+
}
|
|
6625
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6626
|
+
// Simulate
|
|
6627
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6628
|
+
async simulate(request) {
|
|
6629
|
+
const handler = this.handlers.get(request.intent);
|
|
6630
|
+
if (!handler) {
|
|
6631
|
+
throw new Error(`No handler registered for intent '${request.intent}'`);
|
|
6632
|
+
}
|
|
6633
|
+
let snapshot;
|
|
6634
|
+
if (request.from_snapshot_id) {
|
|
6635
|
+
const loaded = await this.store.getSnapshot(request.from_snapshot_id);
|
|
6636
|
+
if (!loaded) {
|
|
6637
|
+
throw new Error(`Snapshot ${request.from_snapshot_id} not found`);
|
|
6638
|
+
}
|
|
6639
|
+
snapshot = loaded;
|
|
6640
|
+
}
|
|
6641
|
+
const branch = {
|
|
6642
|
+
branch_id: generateId("branch"),
|
|
6643
|
+
timeline_id: generateId("timeline"),
|
|
6644
|
+
origin_timeline_id: "prime",
|
|
6645
|
+
origin_event_id: "simulation_origin",
|
|
6646
|
+
branch_type: "simulation",
|
|
6647
|
+
created_at_tps: request.at_tps,
|
|
6648
|
+
creator_subject_id: request.actor_id,
|
|
6649
|
+
purpose: request.purpose,
|
|
6650
|
+
status: "active"
|
|
6651
|
+
};
|
|
6652
|
+
await this.store.saveBranch(branch);
|
|
6653
|
+
const context = {
|
|
6654
|
+
event_id: generateId("evt"),
|
|
6655
|
+
timeline_id: branch.timeline_id,
|
|
6656
|
+
branch_id: branch.branch_id,
|
|
6657
|
+
domain: "shadow",
|
|
6658
|
+
actor_id: request.actor_id,
|
|
6659
|
+
tps_coordinate: request.at_tps,
|
|
6660
|
+
snapshot,
|
|
6661
|
+
is_replay: false,
|
|
6662
|
+
is_simulation: true
|
|
6663
|
+
};
|
|
6664
|
+
const startMs = Date.now();
|
|
6665
|
+
const handlerResult = await handler.execute(request.payload, context);
|
|
6666
|
+
const durationMs = Date.now() - startMs;
|
|
6667
|
+
const simulatedEvent = {
|
|
6668
|
+
event_id: context.event_id,
|
|
6669
|
+
timeline_id: branch.timeline_id,
|
|
6670
|
+
branch_id: branch.branch_id,
|
|
6671
|
+
parent_event_id: null,
|
|
6672
|
+
intent: request.intent,
|
|
6673
|
+
actor_id: request.actor_id,
|
|
6674
|
+
tps_coordinate: request.at_tps,
|
|
6675
|
+
payload_hash: hashPayload2(request.payload),
|
|
6676
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6677
|
+
status: "simulated",
|
|
6678
|
+
domain: "shadow",
|
|
6679
|
+
determinism: "bounded_nondeterministic",
|
|
6680
|
+
created_at: Date.now(),
|
|
6681
|
+
metadata: { payload: request.payload, result: handlerResult.result_data }
|
|
6682
|
+
};
|
|
6683
|
+
await this.store.saveEvent(simulatedEvent);
|
|
6684
|
+
branch.status = "completed";
|
|
6685
|
+
await this.store.saveBranch(branch);
|
|
6686
|
+
return {
|
|
6687
|
+
branch,
|
|
6688
|
+
simulated_event: simulatedEvent,
|
|
6689
|
+
predicted_outcome: handlerResult.result_data,
|
|
6690
|
+
side_effects: handlerResult.side_effects ?? [],
|
|
6691
|
+
duration_ms: durationMs
|
|
6692
|
+
};
|
|
6693
|
+
}
|
|
6694
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6695
|
+
// Compare timelines
|
|
6696
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6697
|
+
async compare(timelineIdA, timelineIdB) {
|
|
6698
|
+
const eventsA = await this.store.getEventsByTimeline(timelineIdA);
|
|
6699
|
+
const eventsB = await this.store.getEventsByTimeline(timelineIdB);
|
|
6700
|
+
eventsA.sort((a, b) => a.created_at - b.created_at);
|
|
6701
|
+
eventsB.sort((a, b) => a.created_at - b.created_at);
|
|
6702
|
+
const maxLen = Math.max(eventsA.length, eventsB.length);
|
|
6703
|
+
const eventPairs = [];
|
|
6704
|
+
let divergencePoint;
|
|
6705
|
+
for (let i = 0; i < maxLen; i++) {
|
|
6706
|
+
const a = eventsA[i];
|
|
6707
|
+
const b = eventsB[i];
|
|
6708
|
+
if (!a || !b) {
|
|
6709
|
+
if (!divergencePoint) {
|
|
6710
|
+
divergencePoint = a?.event_id ?? b?.event_id;
|
|
6711
|
+
}
|
|
6712
|
+
continue;
|
|
6713
|
+
}
|
|
6714
|
+
const match = a.result_hash === b.result_hash;
|
|
6715
|
+
const resultA = a.metadata?.result ?? {};
|
|
6716
|
+
const resultB = b.metadata?.result ?? {};
|
|
6717
|
+
const differences = match ? [] : diffObjects(resultA, resultB);
|
|
6718
|
+
if (!match && !divergencePoint) {
|
|
6719
|
+
divergencePoint = a.event_id;
|
|
6720
|
+
}
|
|
6721
|
+
eventPairs.push({ event_a: a, event_b: b, match, differences });
|
|
6722
|
+
}
|
|
6723
|
+
return {
|
|
6724
|
+
timeline_a: timelineIdA,
|
|
6725
|
+
timeline_b: timelineIdB,
|
|
6726
|
+
event_pairs: eventPairs,
|
|
6727
|
+
divergence_point: divergencePoint
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6731
|
+
// State snapshot management
|
|
6732
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6733
|
+
async createSnapshot(eventId, stateData) {
|
|
6734
|
+
const event = await this.store.getEvent(eventId);
|
|
6735
|
+
if (!event) {
|
|
6736
|
+
throw new Error(`Event ${eventId} not found`);
|
|
6737
|
+
}
|
|
6738
|
+
const snapshot = {
|
|
6739
|
+
snapshot_id: generateId("snap"),
|
|
6740
|
+
timeline_id: event.timeline_id,
|
|
6741
|
+
event_id: eventId,
|
|
6742
|
+
tps_coordinate: event.tps_coordinate,
|
|
6743
|
+
state_hash: hashPayload2(stateData),
|
|
6744
|
+
state_data: stateData,
|
|
6745
|
+
created_at: Date.now()
|
|
6746
|
+
};
|
|
6747
|
+
await this.store.saveSnapshot(snapshot);
|
|
6748
|
+
return snapshot;
|
|
6749
|
+
}
|
|
6750
|
+
async restoreSnapshot(snapshotId) {
|
|
6751
|
+
const snapshot = await this.store.getSnapshot(snapshotId);
|
|
6752
|
+
if (!snapshot) {
|
|
6753
|
+
throw new Error(`Snapshot ${snapshotId} not found`);
|
|
6754
|
+
}
|
|
6755
|
+
return snapshot;
|
|
6756
|
+
}
|
|
6757
|
+
};
|
|
6758
|
+
}
|
|
6759
|
+
});
|
|
6760
|
+
|
|
6761
|
+
// src/timeline/timeline.store.ts
|
|
6762
|
+
var InMemoryTimelineStore;
|
|
6763
|
+
var init_timeline_store = __esm({
|
|
6764
|
+
"src/timeline/timeline.store.ts"() {
|
|
6765
|
+
InMemoryTimelineStore = class {
|
|
6766
|
+
constructor() {
|
|
6767
|
+
this.events = /* @__PURE__ */ new Map();
|
|
6768
|
+
this.branches = /* @__PURE__ */ new Map();
|
|
6769
|
+
this.snapshots = /* @__PURE__ */ new Map();
|
|
6770
|
+
}
|
|
6771
|
+
async saveEvent(event) {
|
|
6772
|
+
this.events.set(event.event_id, event);
|
|
6773
|
+
}
|
|
6774
|
+
async getEvent(eventId) {
|
|
6775
|
+
return this.events.get(eventId) ?? null;
|
|
6776
|
+
}
|
|
6777
|
+
async getEventsByTimeline(timelineId) {
|
|
6778
|
+
return [...this.events.values()].filter((e) => e.timeline_id === timelineId);
|
|
6779
|
+
}
|
|
6780
|
+
async getEventsByBranch(branchId) {
|
|
6781
|
+
return [...this.events.values()].filter((e) => e.branch_id === branchId);
|
|
6782
|
+
}
|
|
6783
|
+
async saveBranch(branch) {
|
|
6784
|
+
this.branches.set(branch.branch_id, branch);
|
|
6785
|
+
}
|
|
6786
|
+
async getBranch(branchId) {
|
|
6787
|
+
return this.branches.get(branchId) ?? null;
|
|
6788
|
+
}
|
|
6789
|
+
async getBranchesByTimeline(timelineId) {
|
|
6790
|
+
return [...this.branches.values()].filter((b) => b.timeline_id === timelineId);
|
|
6791
|
+
}
|
|
6792
|
+
async saveSnapshot(snapshot) {
|
|
6793
|
+
this.snapshots.set(snapshot.snapshot_id, snapshot);
|
|
6794
|
+
}
|
|
6795
|
+
async getSnapshot(snapshotId) {
|
|
6796
|
+
return this.snapshots.get(snapshotId) ?? null;
|
|
6797
|
+
}
|
|
6798
|
+
async getSnapshotByEvent(eventId) {
|
|
6799
|
+
return [...this.snapshots.values()].find((s) => s.event_id === eventId) ?? null;
|
|
6800
|
+
}
|
|
6801
|
+
};
|
|
6802
|
+
}
|
|
6803
|
+
});
|
|
6804
|
+
|
|
6179
6805
|
// src/utils/axis-tlv-codec.ts
|
|
6180
6806
|
function encodeAxisTlvDto(dtoClass, data) {
|
|
6181
6807
|
const schema = (0, import_dto_schema.extractDtoSchema)(dtoClass);
|
|
@@ -6234,37 +6860,1749 @@ var init_axis_tlv_codec = __esm({
|
|
|
6234
6860
|
}
|
|
6235
6861
|
});
|
|
6236
6862
|
|
|
6237
|
-
// src/loom/loom.types.ts
|
|
6238
|
-
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
6239
|
-
return `ar:${context}:${scope}:${softid}`;
|
|
6240
|
-
}
|
|
6241
|
-
function canonicalizeWrit(writ) {
|
|
6242
|
-
const ordered = {
|
|
6243
|
-
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
6244
|
-
body: {
|
|
6245
|
-
who: writ.body.who,
|
|
6246
|
-
act: writ.body.act,
|
|
6247
|
-
res: writ.body.res,
|
|
6248
|
-
law: writ.body.law
|
|
6249
|
-
},
|
|
6250
|
-
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
6251
|
-
};
|
|
6252
|
-
return JSON.stringify(ordered);
|
|
6253
|
-
}
|
|
6254
|
-
function canonicalizeGrant(grant) {
|
|
6255
|
-
const ordered = {
|
|
6256
|
-
grant_id: grant.grant_id,
|
|
6257
|
-
issuer: grant.issuer,
|
|
6258
|
-
subject: grant.subject,
|
|
6259
|
-
grant_type: grant.grant_type,
|
|
6260
|
-
caps: grant.caps,
|
|
6261
|
-
meta: grant.meta
|
|
6262
|
-
};
|
|
6263
|
-
return JSON.stringify(ordered);
|
|
6264
|
-
}
|
|
6265
|
-
var init_loom_types = __esm({
|
|
6266
|
-
"src/loom/loom.types.ts"() {
|
|
6267
|
-
init_constants();
|
|
6863
|
+
// src/loom/loom.types.ts
|
|
6864
|
+
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
6865
|
+
return `ar:${context}:${scope}:${softid}`;
|
|
6866
|
+
}
|
|
6867
|
+
function canonicalizeWrit(writ) {
|
|
6868
|
+
const ordered = {
|
|
6869
|
+
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
6870
|
+
body: {
|
|
6871
|
+
who: writ.body.who,
|
|
6872
|
+
act: writ.body.act,
|
|
6873
|
+
res: writ.body.res,
|
|
6874
|
+
law: writ.body.law
|
|
6875
|
+
},
|
|
6876
|
+
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
6877
|
+
};
|
|
6878
|
+
return JSON.stringify(ordered);
|
|
6879
|
+
}
|
|
6880
|
+
function canonicalizeGrant(grant) {
|
|
6881
|
+
const ordered = {
|
|
6882
|
+
grant_id: grant.grant_id,
|
|
6883
|
+
issuer: grant.issuer,
|
|
6884
|
+
subject: grant.subject,
|
|
6885
|
+
grant_type: grant.grant_type,
|
|
6886
|
+
caps: grant.caps,
|
|
6887
|
+
meta: grant.meta
|
|
6888
|
+
};
|
|
6889
|
+
return JSON.stringify(ordered);
|
|
6890
|
+
}
|
|
6891
|
+
var init_loom_types = __esm({
|
|
6892
|
+
"src/loom/loom.types.ts"() {
|
|
6893
|
+
init_constants();
|
|
6894
|
+
}
|
|
6895
|
+
});
|
|
6896
|
+
|
|
6897
|
+
// src/loom/loom.engine.ts
|
|
6898
|
+
import { createHash as createHash6, randomBytes as randomBytes7 } from "crypto";
|
|
6899
|
+
import { sign as sign2 } from "tweetnacl";
|
|
6900
|
+
function sha2567(data) {
|
|
6901
|
+
return createHash6("sha256").update(data).digest("hex");
|
|
6902
|
+
}
|
|
6903
|
+
function hexToUint8(hex) {
|
|
6904
|
+
const bytes2 = new Uint8Array(hex.length / 2);
|
|
6905
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
6906
|
+
bytes2[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
6907
|
+
}
|
|
6908
|
+
return bytes2;
|
|
6909
|
+
}
|
|
6910
|
+
function uint8ToHex(bytes2) {
|
|
6911
|
+
return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6912
|
+
}
|
|
6913
|
+
function b64ToUint8(b64) {
|
|
6914
|
+
const bin = Buffer.from(b64, "base64");
|
|
6915
|
+
return new Uint8Array(bin.buffer, bin.byteOffset, bin.byteLength);
|
|
6916
|
+
}
|
|
6917
|
+
function uint8ToB64(bytes2) {
|
|
6918
|
+
return Buffer.from(bytes2).toString("base64");
|
|
6919
|
+
}
|
|
6920
|
+
function createPresenceChallenge(declaration, ttlMs = DEFAULT_PRESENCE_TTL_MS) {
|
|
6921
|
+
const now = Date.now();
|
|
6922
|
+
const nonce = randomBytes7(32).toString("hex");
|
|
6923
|
+
const challengeId = sha2567(`${declaration.softid}:${nonce}:${now}`);
|
|
6924
|
+
return {
|
|
6925
|
+
challenge_id: challengeId,
|
|
6926
|
+
nonce,
|
|
6927
|
+
temporal_anchor: now,
|
|
6928
|
+
ttl_ms: ttlMs,
|
|
6929
|
+
expires_at: now + ttlMs
|
|
6930
|
+
};
|
|
6931
|
+
}
|
|
6932
|
+
function presenceSigningData(challenge, deviceMeta) {
|
|
6933
|
+
return JSON.stringify({
|
|
6934
|
+
nonce: challenge.nonce,
|
|
6935
|
+
temporal_anchor: challenge.temporal_anchor,
|
|
6936
|
+
device_meta: deviceMeta ?? null
|
|
6937
|
+
});
|
|
6938
|
+
}
|
|
6939
|
+
function signPresenceChallenge(challenge, privateKeyHex, publicKeyHex, declaration, kid) {
|
|
6940
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6941
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6942
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6943
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
6944
|
+
return {
|
|
6945
|
+
challenge_id: challenge.challenge_id,
|
|
6946
|
+
signature: uint8ToHex(signature),
|
|
6947
|
+
public_key: publicKeyHex,
|
|
6948
|
+
kid
|
|
6949
|
+
};
|
|
6950
|
+
}
|
|
6951
|
+
function verifyPresenceProof(challenge, proof, declaration, durationMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6952
|
+
if (Date.now() > challenge.expires_at) {
|
|
6953
|
+
return { valid: false, error: "Challenge expired", code: "CHALLENGE_EXPIRED" };
|
|
6954
|
+
}
|
|
6955
|
+
if (proof.challenge_id !== challenge.challenge_id) {
|
|
6956
|
+
return { valid: false, error: "Challenge ID mismatch", code: "CHALLENGE_MISMATCH" };
|
|
6957
|
+
}
|
|
6958
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6959
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6960
|
+
const sigBytes = hexToUint8(proof.signature);
|
|
6961
|
+
const pubBytes = hexToUint8(proof.public_key);
|
|
6962
|
+
let isValid;
|
|
6963
|
+
try {
|
|
6964
|
+
isValid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
6965
|
+
} catch {
|
|
6966
|
+
return { valid: false, error: "Signature verification failed", code: "SIG_INVALID" };
|
|
6967
|
+
}
|
|
6968
|
+
if (!isValid) {
|
|
6969
|
+
return { valid: false, error: "Invalid signature", code: "SIG_INVALID" };
|
|
6970
|
+
}
|
|
6971
|
+
const now = Date.now();
|
|
6972
|
+
const presenceId = sha2567(
|
|
6973
|
+
`${proof.public_key}:${challenge.nonce}:${challenge.temporal_anchor}`
|
|
6974
|
+
);
|
|
6975
|
+
const anchorReflection = sha2567(
|
|
6976
|
+
`ar:openlogs:loom:${proof.public_key}`
|
|
6977
|
+
);
|
|
6978
|
+
const receipt = {
|
|
6979
|
+
presence_id: presenceId,
|
|
6980
|
+
softid: declaration.softid,
|
|
6981
|
+
anchor_reflection: anchorReflection,
|
|
6982
|
+
scope: {
|
|
6983
|
+
device_fingerprint: declaration.device_meta?.fingerprint
|
|
6984
|
+
},
|
|
6985
|
+
issued_at: now,
|
|
6986
|
+
expires_at: now + durationMs
|
|
6987
|
+
};
|
|
6988
|
+
return { valid: true, presence: receipt };
|
|
6989
|
+
}
|
|
6990
|
+
function getPresenceStatus(receipt) {
|
|
6991
|
+
const now = Date.now();
|
|
6992
|
+
if (now > receipt.expires_at) return "expired";
|
|
6993
|
+
return "active";
|
|
6994
|
+
}
|
|
6995
|
+
function renewPresence(receipt, extensionMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6996
|
+
const now = Date.now();
|
|
6997
|
+
return {
|
|
6998
|
+
...receipt,
|
|
6999
|
+
renewed_at: now,
|
|
7000
|
+
expires_at: now + extensionMs
|
|
7001
|
+
};
|
|
7002
|
+
}
|
|
7003
|
+
function createWrit(body, meta, thread, privateKeyHex, kid) {
|
|
7004
|
+
const head = { tid: thread.tid, seq: thread.seq };
|
|
7005
|
+
const writMeta = { ...meta, prev: thread.prevHash };
|
|
7006
|
+
const unsigned = { head, body, meta: writMeta };
|
|
7007
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
7008
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7009
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7010
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
7011
|
+
const sig = {
|
|
7012
|
+
alg: "ed25519",
|
|
7013
|
+
value: uint8ToB64(signature),
|
|
7014
|
+
kid
|
|
7015
|
+
};
|
|
7016
|
+
return { head, body, meta: writMeta, sig };
|
|
7017
|
+
}
|
|
7018
|
+
function validateWrit(writ, publicKeyHex, threadState, grants) {
|
|
7019
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
7020
|
+
if (now < writ.meta.iat) {
|
|
7021
|
+
return {
|
|
7022
|
+
valid: false,
|
|
7023
|
+
error: "Writ not yet valid (iat in future)",
|
|
7024
|
+
code: "TEMPORAL_NOT_YET",
|
|
7025
|
+
gate_failed: "temporal"
|
|
7026
|
+
};
|
|
7027
|
+
}
|
|
7028
|
+
if (now > writ.meta.exp) {
|
|
7029
|
+
return {
|
|
7030
|
+
valid: false,
|
|
7031
|
+
error: "Writ expired",
|
|
7032
|
+
code: "TEMPORAL_EXPIRED",
|
|
7033
|
+
gate_failed: "temporal"
|
|
7034
|
+
};
|
|
7035
|
+
}
|
|
7036
|
+
if (threadState) {
|
|
7037
|
+
if (writ.head.tid !== threadState.thread_id) {
|
|
7038
|
+
return {
|
|
7039
|
+
valid: false,
|
|
7040
|
+
error: "Thread ID mismatch",
|
|
7041
|
+
code: "CAUSAL_TID",
|
|
7042
|
+
gate_failed: "causal"
|
|
7043
|
+
};
|
|
7044
|
+
}
|
|
7045
|
+
if (writ.head.seq !== threadState.sequence + 1) {
|
|
7046
|
+
return {
|
|
7047
|
+
valid: false,
|
|
7048
|
+
error: `Expected seq ${threadState.sequence + 1}, got ${writ.head.seq}`,
|
|
7049
|
+
code: "CAUSAL_SEQ",
|
|
7050
|
+
gate_failed: "causal"
|
|
7051
|
+
};
|
|
7052
|
+
}
|
|
7053
|
+
if (writ.meta.prev !== threadState.last_receipt_hash) {
|
|
7054
|
+
return {
|
|
7055
|
+
valid: false,
|
|
7056
|
+
error: "Previous receipt hash mismatch",
|
|
7057
|
+
code: "CAUSAL_PREV",
|
|
7058
|
+
gate_failed: "causal"
|
|
7059
|
+
};
|
|
7060
|
+
}
|
|
7061
|
+
} else {
|
|
7062
|
+
if (writ.head.seq !== 1) {
|
|
7063
|
+
return {
|
|
7064
|
+
valid: false,
|
|
7065
|
+
error: "First writ in thread must have seq=1",
|
|
7066
|
+
code: "CAUSAL_FIRST_SEQ",
|
|
7067
|
+
gate_failed: "causal"
|
|
7068
|
+
};
|
|
7069
|
+
}
|
|
7070
|
+
if (writ.meta.prev !== "") {
|
|
7071
|
+
return {
|
|
7072
|
+
valid: false,
|
|
7073
|
+
error: "First writ must have empty prev hash",
|
|
7074
|
+
code: "CAUSAL_FIRST_PREV",
|
|
7075
|
+
gate_failed: "causal"
|
|
7076
|
+
};
|
|
7077
|
+
}
|
|
7078
|
+
}
|
|
7079
|
+
if (writ.body.law !== "self") {
|
|
7080
|
+
const matchingGrant = grants.find(
|
|
7081
|
+
(g) => g.grant_id === writ.body.law && g.subject === writ.body.who && grantCoversAction(g, writ.body.act, writ.body.res, now)
|
|
7082
|
+
);
|
|
7083
|
+
if (!matchingGrant) {
|
|
7084
|
+
return {
|
|
7085
|
+
valid: false,
|
|
7086
|
+
error: `No valid grant found for law=${writ.body.law}`,
|
|
7087
|
+
code: "LEGAL_NO_GRANT",
|
|
7088
|
+
gate_failed: "legal"
|
|
7089
|
+
};
|
|
7090
|
+
}
|
|
7091
|
+
}
|
|
7092
|
+
const unsigned = {
|
|
7093
|
+
head: writ.head,
|
|
7094
|
+
body: writ.body,
|
|
7095
|
+
meta: writ.meta
|
|
7096
|
+
};
|
|
7097
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
7098
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7099
|
+
const sigBytes = b64ToUint8(writ.sig.value);
|
|
7100
|
+
const pubBytes = hexToUint8(publicKeyHex);
|
|
7101
|
+
let sigValid;
|
|
7102
|
+
try {
|
|
7103
|
+
sigValid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
7104
|
+
} catch {
|
|
7105
|
+
return {
|
|
7106
|
+
valid: false,
|
|
7107
|
+
error: "Signature verification failed",
|
|
7108
|
+
code: "AUTH_SIG_FAIL",
|
|
7109
|
+
gate_failed: "authentic"
|
|
7110
|
+
};
|
|
7111
|
+
}
|
|
7112
|
+
if (!sigValid) {
|
|
7113
|
+
return {
|
|
7114
|
+
valid: false,
|
|
7115
|
+
error: "Invalid signature",
|
|
7116
|
+
code: "AUTH_SIG_INVALID",
|
|
7117
|
+
gate_failed: "authentic"
|
|
7118
|
+
};
|
|
7119
|
+
}
|
|
7120
|
+
return { valid: true, writ };
|
|
7121
|
+
}
|
|
7122
|
+
function grantCoversAction(grant, action, resource, nowUnix) {
|
|
7123
|
+
if (nowUnix < grant.meta.iat || nowUnix > grant.meta.exp) {
|
|
7124
|
+
return false;
|
|
7125
|
+
}
|
|
7126
|
+
return grant.caps.some(
|
|
7127
|
+
(cap) => matchOec(cap.oec, action) && matchScope(cap.scope, resource)
|
|
7128
|
+
);
|
|
7129
|
+
}
|
|
7130
|
+
function matchOec(pattern, action) {
|
|
7131
|
+
if (pattern === "*") return true;
|
|
7132
|
+
if (pattern === action) return true;
|
|
7133
|
+
if (pattern.endsWith(".*")) {
|
|
7134
|
+
const prefix = pattern.slice(0, -2);
|
|
7135
|
+
return action.startsWith(prefix + ".");
|
|
7136
|
+
}
|
|
7137
|
+
return false;
|
|
7138
|
+
}
|
|
7139
|
+
function matchScope(pattern, resource) {
|
|
7140
|
+
if (pattern === "*") return true;
|
|
7141
|
+
if (pattern === resource) return true;
|
|
7142
|
+
if (pattern.includes("*")) {
|
|
7143
|
+
const regex = new RegExp(
|
|
7144
|
+
"^" + pattern.replace(/\./g, "\\.").replace(/\*/g, "[^:]*") + "$"
|
|
7145
|
+
);
|
|
7146
|
+
return regex.test(resource);
|
|
7147
|
+
}
|
|
7148
|
+
return false;
|
|
7149
|
+
}
|
|
7150
|
+
function getGrantStatus(grant, revocations) {
|
|
7151
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
7152
|
+
const revoked = revocations.find(
|
|
7153
|
+
(r) => r.target_type === "grant" && r.target_id === grant.grant_id
|
|
7154
|
+
);
|
|
7155
|
+
if (revoked && revoked.effective_at <= now * 1e3) {
|
|
7156
|
+
return "revoked";
|
|
7157
|
+
}
|
|
7158
|
+
if (now > grant.meta.exp) return "expired";
|
|
7159
|
+
return "active";
|
|
7160
|
+
}
|
|
7161
|
+
function validateGrant(grant, issuerPublicKeyHex) {
|
|
7162
|
+
const unsigned = {
|
|
7163
|
+
grant_id: grant.grant_id,
|
|
7164
|
+
issuer: grant.issuer,
|
|
7165
|
+
subject: grant.subject,
|
|
7166
|
+
grant_type: grant.grant_type,
|
|
7167
|
+
caps: grant.caps,
|
|
7168
|
+
meta: grant.meta
|
|
7169
|
+
};
|
|
7170
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
7171
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7172
|
+
const sigBytes = b64ToUint8(grant.sig.value);
|
|
7173
|
+
const pubBytes = hexToUint8(issuerPublicKeyHex);
|
|
7174
|
+
let valid;
|
|
7175
|
+
try {
|
|
7176
|
+
valid = sign2.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
7177
|
+
} catch {
|
|
7178
|
+
return { valid: false, error: "Grant signature verification failed", code: "GRANT_SIG_FAIL" };
|
|
7179
|
+
}
|
|
7180
|
+
if (!valid) {
|
|
7181
|
+
return { valid: false, error: "Invalid grant signature", code: "GRANT_SIG_INVALID" };
|
|
7182
|
+
}
|
|
7183
|
+
return { valid: true, grant };
|
|
7184
|
+
}
|
|
7185
|
+
function createGrant(grantId, issuer, subject, grantType, caps, meta, privateKeyHex, kid) {
|
|
7186
|
+
const unsigned = {
|
|
7187
|
+
grant_id: grantId,
|
|
7188
|
+
issuer,
|
|
7189
|
+
subject,
|
|
7190
|
+
grant_type: grantType,
|
|
7191
|
+
caps,
|
|
7192
|
+
meta
|
|
7193
|
+
};
|
|
7194
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
7195
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7196
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7197
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
7198
|
+
return {
|
|
7199
|
+
...unsigned,
|
|
7200
|
+
sig: {
|
|
7201
|
+
alg: "ed25519",
|
|
7202
|
+
value: uint8ToB64(signature),
|
|
7203
|
+
kid
|
|
7204
|
+
}
|
|
7205
|
+
};
|
|
7206
|
+
}
|
|
7207
|
+
function createReceipt(writ, effect, prevReceipt, metadata) {
|
|
7208
|
+
const now = Date.now();
|
|
7209
|
+
const sequence = prevReceipt ? prevReceipt.sequence + 1 : 1;
|
|
7210
|
+
const prevHash = prevReceipt?.hash ?? null;
|
|
7211
|
+
const writHash = sha2567(canonicalizeWrit({
|
|
7212
|
+
head: writ.head,
|
|
7213
|
+
body: writ.body,
|
|
7214
|
+
meta: writ.meta
|
|
7215
|
+
}));
|
|
7216
|
+
const hashInput = [
|
|
7217
|
+
prevHash ?? "",
|
|
7218
|
+
writHash,
|
|
7219
|
+
writ.head.tid,
|
|
7220
|
+
String(sequence),
|
|
7221
|
+
effect,
|
|
7222
|
+
String(now)
|
|
7223
|
+
].join(":");
|
|
7224
|
+
const receiptHash = sha2567(hashInput);
|
|
7225
|
+
const receiptId = sha2567(`receipt:${receiptHash}:${now}`);
|
|
7226
|
+
return {
|
|
7227
|
+
receipt_id: receiptId,
|
|
7228
|
+
writ_hash: writHash,
|
|
7229
|
+
thread_id: writ.head.tid,
|
|
7230
|
+
sequence,
|
|
7231
|
+
effect,
|
|
7232
|
+
hash: receiptHash,
|
|
7233
|
+
prev_hash: prevHash,
|
|
7234
|
+
executed_at: now,
|
|
7235
|
+
metadata
|
|
7236
|
+
};
|
|
7237
|
+
}
|
|
7238
|
+
function verifyReceiptChain(receipts) {
|
|
7239
|
+
if (receipts.length === 0) return { valid: true };
|
|
7240
|
+
const sorted = [...receipts].sort((a, b) => a.sequence - b.sequence);
|
|
7241
|
+
if (sorted[0].prev_hash !== null) {
|
|
7242
|
+
return {
|
|
7243
|
+
valid: false,
|
|
7244
|
+
brokenAt: 0,
|
|
7245
|
+
error: "First receipt must have null prev_hash"
|
|
7246
|
+
};
|
|
7247
|
+
}
|
|
7248
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
7249
|
+
if (sorted[i].prev_hash !== sorted[i - 1].hash) {
|
|
7250
|
+
return {
|
|
7251
|
+
valid: false,
|
|
7252
|
+
brokenAt: i,
|
|
7253
|
+
error: `Receipt ${i} prev_hash does not match receipt ${i - 1} hash`
|
|
7254
|
+
};
|
|
7255
|
+
}
|
|
7256
|
+
}
|
|
7257
|
+
return { valid: true };
|
|
7258
|
+
}
|
|
7259
|
+
function updateThreadState(receipt, softid) {
|
|
7260
|
+
return {
|
|
7261
|
+
thread_id: receipt.thread_id,
|
|
7262
|
+
softid,
|
|
7263
|
+
last_receipt_hash: receipt.hash,
|
|
7264
|
+
sequence: receipt.sequence,
|
|
7265
|
+
updated_at: receipt.executed_at
|
|
7266
|
+
};
|
|
7267
|
+
}
|
|
7268
|
+
function createRevocation(targetType, targetId, issuerSoftid, privateKeyHex, reason) {
|
|
7269
|
+
const now = Date.now();
|
|
7270
|
+
const revocationId = sha2567(`revoke:${targetType}:${targetId}:${now}`);
|
|
7271
|
+
const payload = JSON.stringify({
|
|
7272
|
+
revocation_id: revocationId,
|
|
7273
|
+
target_type: targetType,
|
|
7274
|
+
target_id: targetId,
|
|
7275
|
+
issuer_softid: issuerSoftid,
|
|
7276
|
+
effective_at: now,
|
|
7277
|
+
reason: reason ?? null
|
|
7278
|
+
});
|
|
7279
|
+
const msgBytes = new TextEncoder().encode(payload);
|
|
7280
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7281
|
+
const signature = sign2.detached(msgBytes, secretKey);
|
|
7282
|
+
return {
|
|
7283
|
+
revocation_id: revocationId,
|
|
7284
|
+
target_type: targetType,
|
|
7285
|
+
target_id: targetId,
|
|
7286
|
+
issuer_softid: issuerSoftid,
|
|
7287
|
+
reason,
|
|
7288
|
+
effective_at: now,
|
|
7289
|
+
sig_value: uint8ToHex(signature)
|
|
7290
|
+
};
|
|
7291
|
+
}
|
|
7292
|
+
function isRevoked(targetType, targetId, revocations) {
|
|
7293
|
+
const now = Date.now();
|
|
7294
|
+
return revocations.some(
|
|
7295
|
+
(r) => r.target_type === targetType && r.target_id === targetId && r.effective_at <= now
|
|
7296
|
+
);
|
|
7297
|
+
}
|
|
7298
|
+
function executeLoomPipeline(writ, publicKeyHex, presence, threadState, grants, revocations, prevReceipt) {
|
|
7299
|
+
const presenceStatus = getPresenceStatus(presence);
|
|
7300
|
+
if (presenceStatus !== "active") {
|
|
7301
|
+
return { valid: false, error: "Presence not active", code: "PRESENCE_INACTIVE" };
|
|
7302
|
+
}
|
|
7303
|
+
if (isRevoked("presence", presence.presence_id, revocations)) {
|
|
7304
|
+
return { valid: false, error: "Presence revoked", code: "PRESENCE_REVOKED" };
|
|
7305
|
+
}
|
|
7306
|
+
const activeGrants = grants.filter(
|
|
7307
|
+
(g) => getGrantStatus(g, revocations) === "active"
|
|
7308
|
+
);
|
|
7309
|
+
const writResult = validateWrit(writ, publicKeyHex, threadState, activeGrants);
|
|
7310
|
+
if (!writResult.valid) {
|
|
7311
|
+
return { valid: false, error: writResult.error, code: writResult.code };
|
|
7312
|
+
}
|
|
7313
|
+
const receipt = createReceipt(writ, "ALLOW", prevReceipt);
|
|
7314
|
+
const newThreadState = updateThreadState(receipt, writ.body.who);
|
|
7315
|
+
return {
|
|
7316
|
+
receipt,
|
|
7317
|
+
threadState: newThreadState,
|
|
7318
|
+
writValidation: writResult
|
|
7319
|
+
};
|
|
7320
|
+
}
|
|
7321
|
+
var DEFAULT_PRESENCE_TTL_MS, DEFAULT_PRESENCE_DURATION_MS;
|
|
7322
|
+
var init_loom_engine = __esm({
|
|
7323
|
+
"src/loom/loom.engine.ts"() {
|
|
7324
|
+
init_loom_types();
|
|
7325
|
+
DEFAULT_PRESENCE_TTL_MS = 5e3;
|
|
7326
|
+
DEFAULT_PRESENCE_DURATION_MS = 30 * 60 * 1e3;
|
|
7327
|
+
}
|
|
7328
|
+
});
|
|
7329
|
+
|
|
7330
|
+
// src/idel/idel.compiler.ts
|
|
7331
|
+
function validateType(value, expectedType) {
|
|
7332
|
+
switch (expectedType) {
|
|
7333
|
+
case "string":
|
|
7334
|
+
return typeof value === "string";
|
|
7335
|
+
case "number":
|
|
7336
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
7337
|
+
case "boolean":
|
|
7338
|
+
return typeof value === "boolean";
|
|
7339
|
+
case "object":
|
|
7340
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7341
|
+
case "array":
|
|
7342
|
+
return Array.isArray(value);
|
|
7343
|
+
default:
|
|
7344
|
+
return true;
|
|
7345
|
+
}
|
|
7346
|
+
}
|
|
7347
|
+
function assessRisk(schema, proposal, constraints) {
|
|
7348
|
+
const factors = [];
|
|
7349
|
+
let score = 0;
|
|
7350
|
+
const baseRiskMap = {
|
|
7351
|
+
none: 0,
|
|
7352
|
+
low: 0.1,
|
|
7353
|
+
medium: 0.3,
|
|
7354
|
+
high: 0.6,
|
|
7355
|
+
critical: 0.9
|
|
7356
|
+
};
|
|
7357
|
+
score = baseRiskMap[schema.risk_level] ?? 0;
|
|
7358
|
+
if (schema.risk_level !== "none") {
|
|
7359
|
+
factors.push(`Base risk: ${schema.risk_level}`);
|
|
7360
|
+
}
|
|
7361
|
+
if (schema.has_side_effects) {
|
|
7362
|
+
score += 0.1;
|
|
7363
|
+
factors.push("Has side effects");
|
|
7364
|
+
}
|
|
7365
|
+
if (!schema.reversible) {
|
|
7366
|
+
score += 0.1;
|
|
7367
|
+
factors.push("Not reversible");
|
|
7368
|
+
}
|
|
7369
|
+
const failed = constraints.filter((c) => !c.satisfied);
|
|
7370
|
+
if (failed.length > 0) {
|
|
7371
|
+
score += 0.05 * failed.length;
|
|
7372
|
+
factors.push(`${failed.length} unsatisfied constraint(s)`);
|
|
7373
|
+
}
|
|
7374
|
+
score = Math.min(score, 1);
|
|
7375
|
+
let level;
|
|
7376
|
+
if (score <= 0) level = "none";
|
|
7377
|
+
else if (score <= 0.2) level = "low";
|
|
7378
|
+
else if (score <= 0.5) level = "medium";
|
|
7379
|
+
else if (score <= 0.8) level = "high";
|
|
7380
|
+
else level = "critical";
|
|
7381
|
+
return { level, score, factors };
|
|
7382
|
+
}
|
|
7383
|
+
var IdelSchemaRegistry, IdelCompiler;
|
|
7384
|
+
var init_idel_compiler = __esm({
|
|
7385
|
+
"src/idel/idel.compiler.ts"() {
|
|
7386
|
+
IdelSchemaRegistry = class {
|
|
7387
|
+
constructor() {
|
|
7388
|
+
this.schemas = /* @__PURE__ */ new Map();
|
|
7389
|
+
this.aliases = /* @__PURE__ */ new Map();
|
|
7390
|
+
}
|
|
7391
|
+
register(schema) {
|
|
7392
|
+
this.schemas.set(schema.intent, schema);
|
|
7393
|
+
}
|
|
7394
|
+
registerAlias(alias, intent) {
|
|
7395
|
+
this.aliases.set(alias.toLowerCase(), intent);
|
|
7396
|
+
}
|
|
7397
|
+
get(intent) {
|
|
7398
|
+
return this.schemas.get(intent);
|
|
7399
|
+
}
|
|
7400
|
+
resolve(raw) {
|
|
7401
|
+
const exact = this.schemas.get(raw);
|
|
7402
|
+
if (exact) return exact;
|
|
7403
|
+
const aliased = this.aliases.get(raw.toLowerCase());
|
|
7404
|
+
if (aliased) return this.schemas.get(aliased);
|
|
7405
|
+
const candidates = [...this.schemas.keys()].filter(
|
|
7406
|
+
(k) => k.startsWith(raw + ".") || k.toLowerCase().includes(raw.toLowerCase())
|
|
7407
|
+
);
|
|
7408
|
+
if (candidates.length === 1) {
|
|
7409
|
+
return this.schemas.get(candidates[0]);
|
|
7410
|
+
}
|
|
7411
|
+
return void 0;
|
|
7412
|
+
}
|
|
7413
|
+
/**
|
|
7414
|
+
* Find all schemas that partially match the raw input.
|
|
7415
|
+
* Returns scored candidates for ambiguity resolution.
|
|
7416
|
+
*/
|
|
7417
|
+
findCandidates(raw) {
|
|
7418
|
+
const normalized = raw.toLowerCase().trim();
|
|
7419
|
+
const results = [];
|
|
7420
|
+
for (const [key, schema] of this.schemas) {
|
|
7421
|
+
let score = 0;
|
|
7422
|
+
if (key === raw) {
|
|
7423
|
+
score = 1;
|
|
7424
|
+
} else if (key.toLowerCase() === normalized) {
|
|
7425
|
+
score = 0.95;
|
|
7426
|
+
} else if (this.aliases.get(normalized) === key) {
|
|
7427
|
+
score = 0.9;
|
|
7428
|
+
} else if (key.toLowerCase().startsWith(normalized)) {
|
|
7429
|
+
score = 0.7;
|
|
7430
|
+
} else if (key.toLowerCase().includes(normalized)) {
|
|
7431
|
+
score = 0.5;
|
|
7432
|
+
} else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {
|
|
7433
|
+
score = 0.4;
|
|
7434
|
+
} else if (schema.description.toLowerCase().includes(normalized)) {
|
|
7435
|
+
score = 0.3;
|
|
7436
|
+
}
|
|
7437
|
+
if (score > 0) {
|
|
7438
|
+
results.push({ schema, score });
|
|
7439
|
+
}
|
|
7440
|
+
}
|
|
7441
|
+
return results.sort((a, b) => b.score - a.score);
|
|
7442
|
+
}
|
|
7443
|
+
list() {
|
|
7444
|
+
return [...this.schemas.values()];
|
|
7445
|
+
}
|
|
7446
|
+
};
|
|
7447
|
+
IdelCompiler = class {
|
|
7448
|
+
constructor(registry) {
|
|
7449
|
+
this.registry = registry;
|
|
7450
|
+
}
|
|
7451
|
+
/**
|
|
7452
|
+
* Compile a raw intent proposal into a validated, executable structure.
|
|
7453
|
+
*/
|
|
7454
|
+
compile(proposal) {
|
|
7455
|
+
const errors = [];
|
|
7456
|
+
const candidates = this.registry.findCandidates(proposal.raw);
|
|
7457
|
+
if (candidates.length === 0) {
|
|
7458
|
+
return {
|
|
7459
|
+
ok: false,
|
|
7460
|
+
errors: [{
|
|
7461
|
+
code: "IDEL_UNKNOWN_INTENT",
|
|
7462
|
+
message: `No intent found matching '${proposal.raw}'`
|
|
7463
|
+
}]
|
|
7464
|
+
};
|
|
7465
|
+
}
|
|
7466
|
+
const best = candidates[0];
|
|
7467
|
+
const schema = best.schema;
|
|
7468
|
+
const alternatives = candidates.slice(1, 4).filter((c) => c.score >= 0.3).map((c) => ({
|
|
7469
|
+
intent: c.schema.intent,
|
|
7470
|
+
confidence: c.score,
|
|
7471
|
+
reason: c.schema.description
|
|
7472
|
+
}));
|
|
7473
|
+
const constraints = [];
|
|
7474
|
+
const clarifications = [];
|
|
7475
|
+
const params = { ...proposal.params };
|
|
7476
|
+
for (const paramSchema of schema.params) {
|
|
7477
|
+
const value = params[paramSchema.name];
|
|
7478
|
+
if (paramSchema.required && value === void 0) {
|
|
7479
|
+
if (paramSchema.default !== void 0) {
|
|
7480
|
+
params[paramSchema.name] = paramSchema.default;
|
|
7481
|
+
constraints.push({
|
|
7482
|
+
kind: "required_param",
|
|
7483
|
+
field: paramSchema.name,
|
|
7484
|
+
description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,
|
|
7485
|
+
satisfied: true,
|
|
7486
|
+
value: paramSchema.default
|
|
7487
|
+
});
|
|
7488
|
+
} else {
|
|
7489
|
+
constraints.push({
|
|
7490
|
+
kind: "required_param",
|
|
7491
|
+
field: paramSchema.name,
|
|
7492
|
+
description: `Required parameter '${paramSchema.name}' is missing`,
|
|
7493
|
+
satisfied: false
|
|
7494
|
+
});
|
|
7495
|
+
clarifications.push({
|
|
7496
|
+
id: `clarify_${paramSchema.name}`,
|
|
7497
|
+
question: paramSchema.description ?? `What is the ${paramSchema.name}?`,
|
|
7498
|
+
field: paramSchema.name,
|
|
7499
|
+
options: paramSchema.enum?.map(String),
|
|
7500
|
+
required: true
|
|
7501
|
+
});
|
|
7502
|
+
}
|
|
7503
|
+
continue;
|
|
7504
|
+
}
|
|
7505
|
+
if (value === void 0) continue;
|
|
7506
|
+
const typeValid = validateType(value, paramSchema.type);
|
|
7507
|
+
constraints.push({
|
|
7508
|
+
kind: "type_check",
|
|
7509
|
+
field: paramSchema.name,
|
|
7510
|
+
description: `Must be ${paramSchema.type}`,
|
|
7511
|
+
satisfied: typeValid,
|
|
7512
|
+
value,
|
|
7513
|
+
expected: paramSchema.type
|
|
7514
|
+
});
|
|
7515
|
+
if (!typeValid) {
|
|
7516
|
+
errors.push({
|
|
7517
|
+
code: "IDEL_TYPE_ERROR",
|
|
7518
|
+
message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,
|
|
7519
|
+
field: paramSchema.name
|
|
7520
|
+
});
|
|
7521
|
+
}
|
|
7522
|
+
if (paramSchema.min !== void 0 || paramSchema.max !== void 0) {
|
|
7523
|
+
const numVal = typeof value === "number" ? value : Number(value);
|
|
7524
|
+
const inRange = (paramSchema.min === void 0 || numVal >= paramSchema.min) && (paramSchema.max === void 0 || numVal <= paramSchema.max);
|
|
7525
|
+
constraints.push({
|
|
7526
|
+
kind: "range",
|
|
7527
|
+
field: paramSchema.name,
|
|
7528
|
+
description: `Must be between ${paramSchema.min ?? "-\u221E"} and ${paramSchema.max ?? "\u221E"}`,
|
|
7529
|
+
satisfied: inRange,
|
|
7530
|
+
value: numVal
|
|
7531
|
+
});
|
|
7532
|
+
}
|
|
7533
|
+
if (paramSchema.pattern) {
|
|
7534
|
+
const matches = new RegExp(paramSchema.pattern).test(String(value));
|
|
7535
|
+
constraints.push({
|
|
7536
|
+
kind: "pattern",
|
|
7537
|
+
field: paramSchema.name,
|
|
7538
|
+
description: `Must match ${paramSchema.pattern}`,
|
|
7539
|
+
satisfied: matches,
|
|
7540
|
+
value,
|
|
7541
|
+
expected: paramSchema.pattern
|
|
7542
|
+
});
|
|
7543
|
+
}
|
|
7544
|
+
if (paramSchema.enum) {
|
|
7545
|
+
const inEnum = paramSchema.enum.some(
|
|
7546
|
+
(e) => JSON.stringify(e) === JSON.stringify(value)
|
|
7547
|
+
);
|
|
7548
|
+
constraints.push({
|
|
7549
|
+
kind: "custom",
|
|
7550
|
+
field: paramSchema.name,
|
|
7551
|
+
description: `Must be one of: ${paramSchema.enum.join(", ")}`,
|
|
7552
|
+
satisfied: inEnum,
|
|
7553
|
+
value,
|
|
7554
|
+
expected: paramSchema.enum
|
|
7555
|
+
});
|
|
7556
|
+
}
|
|
7557
|
+
}
|
|
7558
|
+
const risk = assessRisk(schema, proposal, constraints);
|
|
7559
|
+
const unsatisfied = constraints.filter((c) => !c.satisfied);
|
|
7560
|
+
const needsClarification = clarifications.length > 0;
|
|
7561
|
+
let confidence = best.score;
|
|
7562
|
+
if (unsatisfied.length > 0) {
|
|
7563
|
+
confidence *= 1 - unsatisfied.length / Math.max(constraints.length, 1) * 0.5;
|
|
7564
|
+
}
|
|
7565
|
+
if (errors.length > 0) {
|
|
7566
|
+
confidence *= 0.5;
|
|
7567
|
+
}
|
|
7568
|
+
const compiled = {
|
|
7569
|
+
intent: schema.intent,
|
|
7570
|
+
actor_id: proposal.actor_id,
|
|
7571
|
+
target: proposal.target,
|
|
7572
|
+
params,
|
|
7573
|
+
constraints,
|
|
7574
|
+
confidence,
|
|
7575
|
+
alternatives,
|
|
7576
|
+
needs_clarification: needsClarification,
|
|
7577
|
+
clarifications,
|
|
7578
|
+
expected_outcome: schema.description,
|
|
7579
|
+
fallback: schema.related?.[0],
|
|
7580
|
+
risk,
|
|
7581
|
+
metadata: {
|
|
7582
|
+
schema_intent: schema.intent,
|
|
7583
|
+
resolved_from: proposal.raw,
|
|
7584
|
+
has_side_effects: schema.has_side_effects,
|
|
7585
|
+
reversible: schema.reversible
|
|
7586
|
+
}
|
|
7587
|
+
};
|
|
7588
|
+
return {
|
|
7589
|
+
ok: errors.length === 0 && !needsClarification,
|
|
7590
|
+
compiled,
|
|
7591
|
+
errors
|
|
7592
|
+
};
|
|
7593
|
+
}
|
|
7594
|
+
/**
|
|
7595
|
+
* Apply clarification answers and re-compile.
|
|
7596
|
+
*/
|
|
7597
|
+
applyClarifications(compiled, answers) {
|
|
7598
|
+
const proposal = {
|
|
7599
|
+
raw: compiled.intent,
|
|
7600
|
+
actor_id: compiled.actor_id,
|
|
7601
|
+
target: compiled.target,
|
|
7602
|
+
params: { ...compiled.params, ...answers }
|
|
7603
|
+
};
|
|
7604
|
+
return this.compile(proposal);
|
|
7605
|
+
}
|
|
7606
|
+
};
|
|
7607
|
+
}
|
|
7608
|
+
});
|
|
7609
|
+
|
|
7610
|
+
// src/needle/needle.engine.ts
|
|
7611
|
+
import { randomBytes as randomBytes8 } from "crypto";
|
|
7612
|
+
function assembleNeedle(params) {
|
|
7613
|
+
return {
|
|
7614
|
+
needle_id: randomBytes8(16).toString("hex"),
|
|
7615
|
+
phase: "created",
|
|
7616
|
+
tps_coordinate: params.tps_coordinate,
|
|
7617
|
+
intent: params.intent,
|
|
7618
|
+
presence: params.presence,
|
|
7619
|
+
writ: params.writ,
|
|
7620
|
+
grants: params.grants,
|
|
7621
|
+
created_at: Date.now()
|
|
7622
|
+
};
|
|
7623
|
+
}
|
|
7624
|
+
function classifyStitch(observation, verdict) {
|
|
7625
|
+
if (verdict.status === "failed" || verdict.status === "disputed") {
|
|
7626
|
+
return "torn";
|
|
7627
|
+
}
|
|
7628
|
+
if (observation.decision === "DENY") {
|
|
7629
|
+
return "silent";
|
|
7630
|
+
}
|
|
7631
|
+
if (verdict.isDeed) {
|
|
7632
|
+
return "deed";
|
|
7633
|
+
}
|
|
7634
|
+
return "silent";
|
|
7635
|
+
}
|
|
7636
|
+
function formStitch(needle, observation, verdict, receipt) {
|
|
7637
|
+
return {
|
|
7638
|
+
stitch_id: needle.needle_id,
|
|
7639
|
+
kind: classifyStitch(observation, verdict),
|
|
7640
|
+
intent: needle.intent.intent,
|
|
7641
|
+
actor_id: needle.intent.actor_id,
|
|
7642
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7643
|
+
observation,
|
|
7644
|
+
verdict,
|
|
7645
|
+
receipt,
|
|
7646
|
+
thread_id: receipt.thread_id,
|
|
7647
|
+
sequence: receipt.sequence,
|
|
7648
|
+
stitched_at: Date.now()
|
|
7649
|
+
};
|
|
7650
|
+
}
|
|
7651
|
+
async function runNeedlePipeline(needle, config, threadState, prevReceipt, expectedOutcome) {
|
|
7652
|
+
const obs = createObservation("http");
|
|
7653
|
+
obs.intent = needle.intent.intent;
|
|
7654
|
+
obs.actorId = needle.intent.actor_id;
|
|
7655
|
+
needle.phase = "validated";
|
|
7656
|
+
let stage = startStage(obs, "loom.validate");
|
|
7657
|
+
const validation = validateWrit(
|
|
7658
|
+
needle.writ,
|
|
7659
|
+
config.public_key,
|
|
7660
|
+
threadState,
|
|
7661
|
+
needle.grants
|
|
7662
|
+
);
|
|
7663
|
+
if (!validation.valid) {
|
|
7664
|
+
endStage(stage, "fail", validation.error);
|
|
7665
|
+
return failNeedle(needle, obs, "validated", "LOOM_VALIDATION_FAILED", validation.error ?? "Writ validation failed");
|
|
7666
|
+
}
|
|
7667
|
+
endStage(stage, "ok");
|
|
7668
|
+
if (config.sensors && config.sensors.length > 0) {
|
|
7669
|
+
stage = startStage(obs, "sensors.evaluate");
|
|
7670
|
+
const sensorInput = {
|
|
7671
|
+
intent: needle.intent.intent,
|
|
7672
|
+
actorId: needle.intent.actor_id,
|
|
7673
|
+
metadata: {
|
|
7674
|
+
observation: obs,
|
|
7675
|
+
needle_id: needle.needle_id,
|
|
7676
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7677
|
+
writ: needle.writ,
|
|
7678
|
+
grants: needle.grants,
|
|
7679
|
+
params: needle.intent.params
|
|
7680
|
+
}
|
|
7681
|
+
};
|
|
7682
|
+
for (const sensor of config.sensors) {
|
|
7683
|
+
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
7684
|
+
const t0 = Date.now();
|
|
7685
|
+
let decision;
|
|
7686
|
+
try {
|
|
7687
|
+
const rawDecision = await sensor.run(sensorInput);
|
|
7688
|
+
decision = normalizeSensorDecision(rawDecision);
|
|
7689
|
+
} catch (err) {
|
|
7690
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7691
|
+
recordSensor(obs, sensor.name, false, 100, Date.now() - t0, [`sensor_error:${msg}`]);
|
|
7692
|
+
endStage(stage, "fail", `Sensor ${sensor.name} threw: ${msg}`);
|
|
7693
|
+
return failNeedle(needle, obs, "validated", "SENSOR_ERROR", `Sensor ${sensor.name} failed: ${msg}`);
|
|
7694
|
+
}
|
|
7695
|
+
recordSensor(obs, sensor.name, decision.allow, decision.riskScore, Date.now() - t0, decision.reasons);
|
|
7696
|
+
if (!decision.allow) {
|
|
7697
|
+
endStage(stage, "fail", `Sensor ${sensor.name} denied`);
|
|
7698
|
+
return failNeedle(needle, obs, "validated", "SENSOR_DENY", decision.reasons[0] ?? `Denied by ${sensor.name}`);
|
|
7699
|
+
}
|
|
7700
|
+
}
|
|
7701
|
+
endStage(stage, "ok");
|
|
7702
|
+
}
|
|
7703
|
+
needle.phase = "executing";
|
|
7704
|
+
stage = startStage(obs, "handler.execute");
|
|
7705
|
+
const handler = config.handlers.get(needle.intent.intent);
|
|
7706
|
+
if (!handler) {
|
|
7707
|
+
endStage(stage, "fail", `No handler for intent '${needle.intent.intent}'`);
|
|
7708
|
+
return failNeedle(needle, obs, "executing", "NO_HANDLER", `No handler registered for intent '${needle.intent.intent}'`);
|
|
7709
|
+
}
|
|
7710
|
+
const handlerCtx = {
|
|
7711
|
+
needle_id: needle.needle_id,
|
|
7712
|
+
actor_id: needle.intent.actor_id,
|
|
7713
|
+
presence_id: needle.presence.presence_id,
|
|
7714
|
+
writ: needle.writ,
|
|
7715
|
+
grants: needle.grants,
|
|
7716
|
+
tps_coordinate: needle.tps_coordinate
|
|
7717
|
+
};
|
|
7718
|
+
let handlerResult;
|
|
7719
|
+
try {
|
|
7720
|
+
handlerResult = await handler(needle.intent, handlerCtx);
|
|
7721
|
+
} catch (err) {
|
|
7722
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7723
|
+
endStage(stage, "fail", msg);
|
|
7724
|
+
return failNeedle(needle, obs, "executing", "HANDLER_ERROR", msg);
|
|
7725
|
+
}
|
|
7726
|
+
if (!handlerResult.ok) {
|
|
7727
|
+
endStage(stage, "fail", handlerResult.effect);
|
|
7728
|
+
obs.decision = "DENY";
|
|
7729
|
+
obs.resultCode = handlerResult.effect;
|
|
7730
|
+
obs.statusCode = handlerResult.status_code ?? 400;
|
|
7731
|
+
} else {
|
|
7732
|
+
endStage(stage, "ok");
|
|
7733
|
+
obs.decision = "ALLOW";
|
|
7734
|
+
obs.resultCode = handlerResult.effect;
|
|
7735
|
+
obs.statusCode = handlerResult.status_code ?? 200;
|
|
7736
|
+
}
|
|
7737
|
+
if (handlerResult.data) {
|
|
7738
|
+
obs.facts = { ...obs.facts, ...handlerResult.data };
|
|
7739
|
+
}
|
|
7740
|
+
needle.phase = "observed";
|
|
7741
|
+
finalizeObservation(obs, obs.decision ?? "DENY", obs.statusCode ?? 500, obs.resultCode);
|
|
7742
|
+
needle.observation = obs;
|
|
7743
|
+
const verdict = scoreTruth(obs, expectedOutcome);
|
|
7744
|
+
needle.verdict = verdict;
|
|
7745
|
+
needle.phase = "stitched";
|
|
7746
|
+
stage = startStage(obs, "stitch.form");
|
|
7747
|
+
const receipt = createReceipt(
|
|
7748
|
+
needle.writ,
|
|
7749
|
+
obs.decision ?? "DENY",
|
|
7750
|
+
prevReceipt
|
|
7751
|
+
);
|
|
7752
|
+
needle.receipt = receipt;
|
|
7753
|
+
const newThreadState = updateThreadState(
|
|
7754
|
+
receipt,
|
|
7755
|
+
needle.intent.actor_id
|
|
7756
|
+
);
|
|
7757
|
+
const stitch = formStitch(needle, obs, verdict, receipt);
|
|
7758
|
+
needle.completed_at = Date.now();
|
|
7759
|
+
endStage(stage, "ok");
|
|
7760
|
+
return {
|
|
7761
|
+
ok: handlerResult.ok,
|
|
7762
|
+
needle,
|
|
7763
|
+
stitch,
|
|
7764
|
+
thread_state: newThreadState
|
|
7765
|
+
};
|
|
7766
|
+
}
|
|
7767
|
+
function failNeedle(needle, obs, phase, code, message) {
|
|
7768
|
+
needle.phase = "failed";
|
|
7769
|
+
needle.error = { phase, code, message };
|
|
7770
|
+
needle.completed_at = Date.now();
|
|
7771
|
+
obs.decision = obs.decision ?? "DENY";
|
|
7772
|
+
obs.statusCode = obs.statusCode ?? 500;
|
|
7773
|
+
finalizeObservation(obs, obs.decision, obs.statusCode, obs.resultCode);
|
|
7774
|
+
needle.observation = obs;
|
|
7775
|
+
const verdict = scoreTruth(obs);
|
|
7776
|
+
needle.verdict = verdict;
|
|
7777
|
+
return {
|
|
7778
|
+
ok: false,
|
|
7779
|
+
needle
|
|
7780
|
+
};
|
|
7781
|
+
}
|
|
7782
|
+
var init_needle_engine = __esm({
|
|
7783
|
+
"src/needle/needle.engine.ts"() {
|
|
7784
|
+
init_axis_observation();
|
|
7785
|
+
init_truth_scoring();
|
|
7786
|
+
init_loom_engine();
|
|
7787
|
+
init_axis_sensor();
|
|
7788
|
+
}
|
|
7789
|
+
});
|
|
7790
|
+
|
|
7791
|
+
// src/needle/knot.engine.ts
|
|
7792
|
+
import { createHash as createHash8, randomBytes as randomBytes9 } from "crypto";
|
|
7793
|
+
function openKnot(params) {
|
|
7794
|
+
const isIrreversible = params.type === "irreversible";
|
|
7795
|
+
return {
|
|
7796
|
+
knot_id: `knot_${randomBytes9(16).toString("hex")}`,
|
|
7797
|
+
type: params.type,
|
|
7798
|
+
status: "open",
|
|
7799
|
+
stitch_ids: [],
|
|
7800
|
+
thread_id: params.thread_id,
|
|
7801
|
+
tps_anchor: params.tps_anchor,
|
|
7802
|
+
irreversible: isIrreversible,
|
|
7803
|
+
capsule_id: params.capsule_id,
|
|
7804
|
+
law_ref: params.law_ref,
|
|
7805
|
+
branch_ids: [],
|
|
7806
|
+
required_count: params.required_count,
|
|
7807
|
+
all_or_nothing: params.all_or_nothing ?? (params.type === "authority" || isIrreversible),
|
|
7808
|
+
actor_id: params.actor_id,
|
|
7809
|
+
created_at: Date.now()
|
|
7810
|
+
};
|
|
7811
|
+
}
|
|
7812
|
+
function addStitchToKnot(knot, stitch) {
|
|
7813
|
+
if (knot.status !== "open") {
|
|
7814
|
+
return `Knot ${knot.knot_id} is ${knot.status}, cannot add stitches`;
|
|
7815
|
+
}
|
|
7816
|
+
if (stitch.thread_id !== knot.thread_id) {
|
|
7817
|
+
return `Stitch thread ${stitch.thread_id} does not match knot thread ${knot.thread_id}`;
|
|
7818
|
+
}
|
|
7819
|
+
if (knot.stitch_ids.includes(stitch.stitch_id)) {
|
|
7820
|
+
return `Stitch ${stitch.stitch_id} already in knot`;
|
|
7821
|
+
}
|
|
7822
|
+
if (knot.type === "authority" && knot.capsule_id) {
|
|
7823
|
+
if (stitch.observation.capsuleId && stitch.observation.capsuleId !== knot.capsule_id) {
|
|
7824
|
+
return `Stitch capsule ${stitch.observation.capsuleId} does not match knot capsule ${knot.capsule_id}`;
|
|
7825
|
+
}
|
|
7826
|
+
}
|
|
7827
|
+
knot.stitch_ids.push(stitch.stitch_id);
|
|
7828
|
+
return null;
|
|
7829
|
+
}
|
|
7830
|
+
function validateKnot(knot, stitches) {
|
|
7831
|
+
const errors = [];
|
|
7832
|
+
const passedIds = [];
|
|
7833
|
+
const failedIds = [];
|
|
7834
|
+
const stitchMap = new Map(stitches.map((s) => [s.stitch_id, s]));
|
|
7835
|
+
for (const sid of knot.stitch_ids) {
|
|
7836
|
+
const stitch = stitchMap.get(sid);
|
|
7837
|
+
if (!stitch) {
|
|
7838
|
+
failedIds.push(sid);
|
|
7839
|
+
errors.push({
|
|
7840
|
+
code: "KNOT_MISSING_STITCH",
|
|
7841
|
+
message: `Stitch ${sid} not found`,
|
|
7842
|
+
stitch_id: sid
|
|
7843
|
+
});
|
|
7844
|
+
continue;
|
|
7845
|
+
}
|
|
7846
|
+
if (stitch.kind === "torn") {
|
|
7847
|
+
failedIds.push(sid);
|
|
7848
|
+
errors.push({
|
|
7849
|
+
code: "KNOT_TORN_STITCH",
|
|
7850
|
+
message: `Stitch ${sid} is torn (failed/disputed)`,
|
|
7851
|
+
stitch_id: sid
|
|
7852
|
+
});
|
|
7853
|
+
continue;
|
|
7854
|
+
}
|
|
7855
|
+
if (knot.type === "irreversible" && stitch.kind !== "deed") {
|
|
7856
|
+
failedIds.push(sid);
|
|
7857
|
+
errors.push({
|
|
7858
|
+
code: "KNOT_REQUIRES_DEED",
|
|
7859
|
+
message: `Irreversible knot requires deed stitch, got '${stitch.kind}'`,
|
|
7860
|
+
stitch_id: sid
|
|
7861
|
+
});
|
|
7862
|
+
continue;
|
|
7863
|
+
}
|
|
7864
|
+
passedIds.push(sid);
|
|
7865
|
+
}
|
|
7866
|
+
if (knot.required_count !== void 0 && knot.stitch_ids.length < knot.required_count) {
|
|
7867
|
+
errors.push({
|
|
7868
|
+
code: "KNOT_INSUFFICIENT_STITCHES",
|
|
7869
|
+
message: `Knot requires ${knot.required_count} stitches, has ${knot.stitch_ids.length}`
|
|
7870
|
+
});
|
|
7871
|
+
}
|
|
7872
|
+
const allPassed = failedIds.length === 0;
|
|
7873
|
+
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);
|
|
7874
|
+
return {
|
|
7875
|
+
valid: allPassed && errors.length === 0,
|
|
7876
|
+
passed_stitch_ids: passedIds,
|
|
7877
|
+
failed_stitch_ids: failedIds,
|
|
7878
|
+
can_tie: canTie,
|
|
7879
|
+
errors
|
|
7880
|
+
};
|
|
7881
|
+
}
|
|
7882
|
+
function tieKnot(knot, stitches) {
|
|
7883
|
+
const validation = validateKnot(knot, stitches);
|
|
7884
|
+
if (!validation.can_tie) {
|
|
7885
|
+
return { ...validation, knot };
|
|
7886
|
+
}
|
|
7887
|
+
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);
|
|
7888
|
+
const witnessPayload = receiptHashes.join(":");
|
|
7889
|
+
knot.witness_hash = createHash8("sha256").update(witnessPayload).digest("hex");
|
|
7890
|
+
knot.status = "tied";
|
|
7891
|
+
knot.tied_at = Date.now();
|
|
7892
|
+
return { ...validation, knot };
|
|
7893
|
+
}
|
|
7894
|
+
function breakKnot(knot, request) {
|
|
7895
|
+
if (knot.status === "broken") {
|
|
7896
|
+
return { ok: false, error: "Knot is already broken" };
|
|
7897
|
+
}
|
|
7898
|
+
if (knot.status === "open") {
|
|
7899
|
+
knot.status = "broken";
|
|
7900
|
+
knot.broken_at = Date.now();
|
|
7901
|
+
knot.break_reason = request.reason;
|
|
7902
|
+
return { ok: true };
|
|
7903
|
+
}
|
|
7904
|
+
if (knot.status === "tied") {
|
|
7905
|
+
if (!request.reason) {
|
|
7906
|
+
return { ok: false, error: "Breaking a tied knot requires a reason" };
|
|
7907
|
+
}
|
|
7908
|
+
if ((knot.irreversible || knot.type === "law") && !request.override_grant_id) {
|
|
7909
|
+
return {
|
|
7910
|
+
ok: false,
|
|
7911
|
+
error: `Breaking ${knot.type} knot requires override_grant_id from higher authority`
|
|
7912
|
+
};
|
|
7913
|
+
}
|
|
7914
|
+
knot.status = "broken";
|
|
7915
|
+
knot.broken_at = Date.now();
|
|
7916
|
+
knot.break_reason = request.reason;
|
|
7917
|
+
return { ok: true };
|
|
7918
|
+
}
|
|
7919
|
+
return { ok: false, error: `Cannot break knot in status '${knot.status}'` };
|
|
7920
|
+
}
|
|
7921
|
+
function forkFromKnot(knot, branchId, decisionStitchId) {
|
|
7922
|
+
if (knot.status !== "tied" && knot.status !== "open") {
|
|
7923
|
+
return { ok: false, error: `Cannot fork from knot in status '${knot.status}'` };
|
|
7924
|
+
}
|
|
7925
|
+
if (decisionStitchId) {
|
|
7926
|
+
if (!knot.stitch_ids.includes(decisionStitchId)) {
|
|
7927
|
+
return { ok: false, error: `Decision stitch ${decisionStitchId} is not part of this knot` };
|
|
7928
|
+
}
|
|
7929
|
+
knot.decision_stitch_id = decisionStitchId;
|
|
7930
|
+
}
|
|
7931
|
+
knot.branch_ids.push(branchId);
|
|
7932
|
+
knot.status = "forked";
|
|
7933
|
+
return { ok: true };
|
|
7934
|
+
}
|
|
7935
|
+
function isKnotOpen(knot) {
|
|
7936
|
+
return knot.status === "open";
|
|
7937
|
+
}
|
|
7938
|
+
function isPointOfNoReturn(knot) {
|
|
7939
|
+
return knot.irreversible && knot.status === "tied";
|
|
7940
|
+
}
|
|
7941
|
+
function findKnotsForStitch(stitchId, knots) {
|
|
7942
|
+
return knots.filter((k) => k.stitch_ids.includes(stitchId));
|
|
7943
|
+
}
|
|
7944
|
+
function getIrreversibleKnots(knots) {
|
|
7945
|
+
return knots.filter((k) => k.irreversible && k.status === "tied");
|
|
7946
|
+
}
|
|
7947
|
+
function getDecisionPoints(knots) {
|
|
7948
|
+
return knots.filter((k) => k.type === "decision" || k.status === "forked");
|
|
7949
|
+
}
|
|
7950
|
+
var init_knot_engine = __esm({
|
|
7951
|
+
"src/needle/knot.engine.ts"() {
|
|
7952
|
+
}
|
|
7953
|
+
});
|
|
7954
|
+
|
|
7955
|
+
// src/needle/fabric.engine.ts
|
|
7956
|
+
import { createHash as createHash9, randomBytes as randomBytes10 } from "crypto";
|
|
7957
|
+
function createFabric() {
|
|
7958
|
+
return {
|
|
7959
|
+
fabric_id: `fab_${randomBytes10(16).toString("hex")}`,
|
|
7960
|
+
state_hash: hashState(/* @__PURE__ */ new Map()),
|
|
7961
|
+
cells: /* @__PURE__ */ new Map(),
|
|
7962
|
+
thread_ids: [],
|
|
7963
|
+
stitch_count: 0,
|
|
7964
|
+
knot_count: 0,
|
|
7965
|
+
computed_at: Date.now(),
|
|
7966
|
+
version: 0
|
|
7967
|
+
};
|
|
7968
|
+
}
|
|
7969
|
+
function applyStitch(fabric, stitch, effect) {
|
|
7970
|
+
for (const [key, value] of Object.entries(effect.mutations)) {
|
|
7971
|
+
if (value === null) {
|
|
7972
|
+
fabric.cells.delete(key);
|
|
7973
|
+
} else {
|
|
7974
|
+
const existing = fabric.cells.get(key);
|
|
7975
|
+
if (existing?.locked) {
|
|
7976
|
+
continue;
|
|
7977
|
+
}
|
|
7978
|
+
fabric.cells.set(key, {
|
|
7979
|
+
key,
|
|
7980
|
+
value,
|
|
7981
|
+
last_stitch_id: stitch.stitch_id,
|
|
7982
|
+
last_tps: stitch.tps_coordinate,
|
|
7983
|
+
write_count: (existing?.write_count ?? 0) + 1,
|
|
7984
|
+
locked: false
|
|
7985
|
+
});
|
|
7986
|
+
}
|
|
7987
|
+
}
|
|
7988
|
+
if (!fabric.thread_ids.includes(stitch.thread_id)) {
|
|
7989
|
+
fabric.thread_ids.push(stitch.thread_id);
|
|
7990
|
+
}
|
|
7991
|
+
fabric.stitch_count++;
|
|
7992
|
+
fabric.version++;
|
|
7993
|
+
fabric.projected_at_tps = stitch.tps_coordinate ?? fabric.projected_at_tps;
|
|
7994
|
+
fabric.computed_at = Date.now();
|
|
7995
|
+
fabric.state_hash = hashState(fabric.cells);
|
|
7996
|
+
}
|
|
7997
|
+
function weave(stitches, resolver, knots) {
|
|
7998
|
+
const fabric = createFabric();
|
|
7999
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
8000
|
+
for (const stitch of sorted) {
|
|
8001
|
+
if (stitch.kind === "torn") continue;
|
|
8002
|
+
const effect = resolver(stitch);
|
|
8003
|
+
applyStitch(fabric, stitch, effect);
|
|
8004
|
+
}
|
|
8005
|
+
if (knots) {
|
|
8006
|
+
for (const knot of knots) {
|
|
8007
|
+
if (knot.irreversible && knot.status === "tied") {
|
|
8008
|
+
lockCellsByKnot(fabric, knot, stitches, resolver);
|
|
8009
|
+
fabric.knot_count++;
|
|
8010
|
+
}
|
|
8011
|
+
}
|
|
8012
|
+
}
|
|
8013
|
+
return fabric;
|
|
8014
|
+
}
|
|
8015
|
+
function projectAt(stitches, resolver, tpsFilter, knots) {
|
|
8016
|
+
const filtered = stitches.filter((s) => tpsFilter(s.tps_coordinate));
|
|
8017
|
+
return weave(filtered, resolver, knots);
|
|
8018
|
+
}
|
|
8019
|
+
function lockCellsByKnot(fabric, knot, stitches, resolver) {
|
|
8020
|
+
const knotStitchIds = new Set(knot.stitch_ids);
|
|
8021
|
+
const knotStitches = stitches.filter((s) => knotStitchIds.has(s.stitch_id));
|
|
8022
|
+
for (const stitch of knotStitches) {
|
|
8023
|
+
const effect = resolver(stitch);
|
|
8024
|
+
for (const key of Object.keys(effect.mutations)) {
|
|
8025
|
+
const cell = fabric.cells.get(key);
|
|
8026
|
+
if (cell) {
|
|
8027
|
+
cell.locked = true;
|
|
8028
|
+
cell.locked_by_knot = knot.knot_id;
|
|
8029
|
+
}
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
function lockCells(fabric, keys, knotId) {
|
|
8034
|
+
for (const key of keys) {
|
|
8035
|
+
const cell = fabric.cells.get(key);
|
|
8036
|
+
if (cell) {
|
|
8037
|
+
cell.locked = true;
|
|
8038
|
+
cell.locked_by_knot = knotId;
|
|
8039
|
+
}
|
|
8040
|
+
}
|
|
8041
|
+
}
|
|
8042
|
+
function queryFabric(fabric, query) {
|
|
8043
|
+
let results = [...fabric.cells.values()];
|
|
8044
|
+
if (query.keys) {
|
|
8045
|
+
const keySet = new Set(query.keys);
|
|
8046
|
+
results = results.filter((c) => keySet.has(c.key));
|
|
8047
|
+
}
|
|
8048
|
+
if (query.prefix) {
|
|
8049
|
+
const prefix = query.prefix;
|
|
8050
|
+
results = results.filter((c) => c.key.startsWith(prefix));
|
|
8051
|
+
}
|
|
8052
|
+
if (query.locked_only) {
|
|
8053
|
+
results = results.filter((c) => c.locked);
|
|
8054
|
+
}
|
|
8055
|
+
return results;
|
|
8056
|
+
}
|
|
8057
|
+
function getFabricValue(fabric, key) {
|
|
8058
|
+
return fabric.cells.get(key)?.value;
|
|
8059
|
+
}
|
|
8060
|
+
function diffFabrics(a, b) {
|
|
8061
|
+
const entries = [];
|
|
8062
|
+
let added = 0;
|
|
8063
|
+
let modified = 0;
|
|
8064
|
+
let deleted = 0;
|
|
8065
|
+
for (const [key, cellB] of b.cells) {
|
|
8066
|
+
const cellA = a.cells.get(key);
|
|
8067
|
+
if (!cellA) {
|
|
8068
|
+
entries.push({
|
|
8069
|
+
key,
|
|
8070
|
+
kind: "added",
|
|
8071
|
+
after: cellB.value,
|
|
8072
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
8073
|
+
});
|
|
8074
|
+
added++;
|
|
8075
|
+
} else if (JSON.stringify(cellA.value) !== JSON.stringify(cellB.value)) {
|
|
8076
|
+
entries.push({
|
|
8077
|
+
key,
|
|
8078
|
+
kind: "modified",
|
|
8079
|
+
before: cellA.value,
|
|
8080
|
+
after: cellB.value,
|
|
8081
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
8082
|
+
});
|
|
8083
|
+
modified++;
|
|
8084
|
+
}
|
|
8085
|
+
}
|
|
8086
|
+
for (const [key, cellA] of a.cells) {
|
|
8087
|
+
if (!b.cells.has(key)) {
|
|
8088
|
+
entries.push({
|
|
8089
|
+
key,
|
|
8090
|
+
kind: "deleted",
|
|
8091
|
+
before: cellA.value
|
|
8092
|
+
});
|
|
8093
|
+
deleted++;
|
|
8094
|
+
}
|
|
8095
|
+
}
|
|
8096
|
+
return {
|
|
8097
|
+
from_fabric_id: a.fabric_id,
|
|
8098
|
+
to_fabric_id: b.fabric_id,
|
|
8099
|
+
entries,
|
|
8100
|
+
added_count: added,
|
|
8101
|
+
modified_count: modified,
|
|
8102
|
+
deleted_count: deleted
|
|
8103
|
+
};
|
|
8104
|
+
}
|
|
8105
|
+
function hashState(cells) {
|
|
8106
|
+
const keys = [...cells.keys()].sort();
|
|
8107
|
+
const payload = keys.map((k) => `${k}=${JSON.stringify(cells.get(k).value)}`).join("\n");
|
|
8108
|
+
return createHash9("sha256").update(payload).digest("hex");
|
|
8109
|
+
}
|
|
8110
|
+
var init_fabric_engine = __esm({
|
|
8111
|
+
"src/needle/fabric.engine.ts"() {
|
|
8112
|
+
}
|
|
8113
|
+
});
|
|
8114
|
+
|
|
8115
|
+
// src/needle/pattern.engine.ts
|
|
8116
|
+
import { randomBytes as randomBytes11 } from "crypto";
|
|
8117
|
+
function detectSequencePatterns(stitches, windowSize, minOccurrences) {
|
|
8118
|
+
if (stitches.length < windowSize || windowSize < 2) return [];
|
|
8119
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
8120
|
+
const sequenceCounts = /* @__PURE__ */ new Map();
|
|
8121
|
+
for (let i = 0; i <= sorted.length - windowSize; i++) {
|
|
8122
|
+
const window = sorted.slice(i, i + windowSize);
|
|
8123
|
+
const key = window.map((s) => s.intent).join("\u2192");
|
|
8124
|
+
const ids = window.map((s) => s.stitch_id);
|
|
8125
|
+
const existing = sequenceCounts.get(key);
|
|
8126
|
+
if (existing) {
|
|
8127
|
+
existing.count++;
|
|
8128
|
+
existing.stitch_ids.push(ids);
|
|
8129
|
+
} else {
|
|
8130
|
+
sequenceCounts.set(key, { count: 1, stitch_ids: [ids] });
|
|
8131
|
+
}
|
|
8132
|
+
}
|
|
8133
|
+
const patterns = [];
|
|
8134
|
+
const now = Date.now();
|
|
8135
|
+
for (const [key, data] of sequenceCounts) {
|
|
8136
|
+
if (data.count < minOccurrences) continue;
|
|
8137
|
+
const intents = key.split("\u2192");
|
|
8138
|
+
const confidence = Math.min(data.count / (minOccurrences * 2), 1);
|
|
8139
|
+
patterns.push({
|
|
8140
|
+
pattern_id: `pat_seq_${randomBytes11(8).toString("hex")}`,
|
|
8141
|
+
kind: "sequence",
|
|
8142
|
+
name: `Sequence: ${intents.join(" \u2192 ")}`,
|
|
8143
|
+
signature: {
|
|
8144
|
+
intent_sequence: intents,
|
|
8145
|
+
min_length: windowSize,
|
|
8146
|
+
max_length: windowSize
|
|
8147
|
+
},
|
|
8148
|
+
confidence,
|
|
8149
|
+
occurrence_count: data.count,
|
|
8150
|
+
first_seen_at: now,
|
|
8151
|
+
last_seen_at: now,
|
|
8152
|
+
seen_in_threads: [...new Set(
|
|
8153
|
+
data.stitch_ids.flatMap(
|
|
8154
|
+
(ids) => ids.map((id) => sorted.find((s) => s.stitch_id === id)?.thread_id).filter(Boolean)
|
|
8155
|
+
)
|
|
8156
|
+
)],
|
|
8157
|
+
classification: "unclassified"
|
|
8158
|
+
});
|
|
8159
|
+
}
|
|
8160
|
+
return patterns;
|
|
8161
|
+
}
|
|
8162
|
+
function detectKnotPatterns(knots, minOccurrences) {
|
|
8163
|
+
const groups = /* @__PURE__ */ new Map();
|
|
8164
|
+
for (const knot of knots) {
|
|
8165
|
+
if (knot.status !== "tied") continue;
|
|
8166
|
+
const key = `${knot.type}:${knot.stitch_ids.length}`;
|
|
8167
|
+
const group = groups.get(key) ?? [];
|
|
8168
|
+
group.push(knot);
|
|
8169
|
+
groups.set(key, group);
|
|
8170
|
+
}
|
|
8171
|
+
const patterns = [];
|
|
8172
|
+
const now = Date.now();
|
|
8173
|
+
for (const [key, group] of groups) {
|
|
8174
|
+
if (group.length < minOccurrences) continue;
|
|
8175
|
+
const [type, sizeStr] = key.split(":");
|
|
8176
|
+
const size = parseInt(sizeStr, 10);
|
|
8177
|
+
const confidence = Math.min(group.length / (minOccurrences * 2), 1);
|
|
8178
|
+
patterns.push({
|
|
8179
|
+
pattern_id: `pat_knot_${randomBytes11(8).toString("hex")}`,
|
|
8180
|
+
kind: "knot",
|
|
8181
|
+
name: `Knot: ${type} (${size} stitches)`,
|
|
8182
|
+
signature: {
|
|
8183
|
+
knot_type: type,
|
|
8184
|
+
knot_size: size
|
|
8185
|
+
},
|
|
8186
|
+
confidence,
|
|
8187
|
+
occurrence_count: group.length,
|
|
8188
|
+
first_seen_at: now,
|
|
8189
|
+
last_seen_at: now,
|
|
8190
|
+
seen_in_threads: [...new Set(group.map((k) => k.thread_id))],
|
|
8191
|
+
classification: "unclassified"
|
|
8192
|
+
});
|
|
8193
|
+
}
|
|
8194
|
+
return patterns;
|
|
8195
|
+
}
|
|
8196
|
+
function matchPatterns(stitches, patterns) {
|
|
8197
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
8198
|
+
const matches = [];
|
|
8199
|
+
const now = Date.now();
|
|
8200
|
+
for (const pattern of patterns) {
|
|
8201
|
+
if (pattern.kind === "sequence" && pattern.signature.intent_sequence) {
|
|
8202
|
+
const seq = pattern.signature.intent_sequence;
|
|
8203
|
+
const seqLen = seq.length;
|
|
8204
|
+
for (let i = 0; i <= sorted.length - seqLen; i++) {
|
|
8205
|
+
const window = sorted.slice(i, i + seqLen);
|
|
8206
|
+
const windowIntents = window.map((s) => s.intent);
|
|
8207
|
+
if (windowIntents.every((intent, idx) => intent === seq[idx])) {
|
|
8208
|
+
matches.push({
|
|
8209
|
+
pattern_id: pattern.pattern_id,
|
|
8210
|
+
matched_stitch_ids: window.map((s) => s.stitch_id),
|
|
8211
|
+
match_score: 1,
|
|
8212
|
+
thread_id: window[0].thread_id,
|
|
8213
|
+
detected_at: now
|
|
8214
|
+
});
|
|
8215
|
+
}
|
|
8216
|
+
}
|
|
8217
|
+
}
|
|
8218
|
+
}
|
|
8219
|
+
return matches;
|
|
8220
|
+
}
|
|
8221
|
+
function recordOccurrence(pattern, threadId) {
|
|
8222
|
+
pattern.occurrence_count++;
|
|
8223
|
+
pattern.last_seen_at = Date.now();
|
|
8224
|
+
pattern.confidence = 1 - 1 / (1 + pattern.occurrence_count * 0.5);
|
|
8225
|
+
if (!pattern.seen_in_threads.includes(threadId)) {
|
|
8226
|
+
pattern.seen_in_threads.push(threadId);
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
function detectAnomalies(recentStitches, knownPatterns, threshold = 0.7) {
|
|
8230
|
+
const anomalies = [];
|
|
8231
|
+
const sorted = [...recentStitches].sort((a, b) => a.sequence - b.sequence);
|
|
8232
|
+
const now = Date.now();
|
|
8233
|
+
for (const pattern of knownPatterns) {
|
|
8234
|
+
if (pattern.kind !== "sequence" || !pattern.signature.intent_sequence) continue;
|
|
8235
|
+
if (pattern.confidence < threshold) continue;
|
|
8236
|
+
const seq = pattern.signature.intent_sequence;
|
|
8237
|
+
if (sorted.length >= 1 && sorted.length < seq.length) {
|
|
8238
|
+
const partialMatch = sorted.every(
|
|
8239
|
+
(s, i) => i < seq.length && s.intent === seq[i]
|
|
8240
|
+
);
|
|
8241
|
+
if (partialMatch) {
|
|
8242
|
+
const expectedNext = seq[sorted.length];
|
|
8243
|
+
const lastStitch = sorted[sorted.length - 1];
|
|
8244
|
+
if (pattern.occurrence_count >= 3) {
|
|
8245
|
+
anomalies.push({
|
|
8246
|
+
pattern_id: `pat_anom_${randomBytes11(8).toString("hex")}`,
|
|
8247
|
+
kind: "anomaly",
|
|
8248
|
+
name: `Incomplete: ${pattern.name}`,
|
|
8249
|
+
description: `Expected '${expectedNext}' after '${lastStitch.intent}' based on pattern '${pattern.name}'`,
|
|
8250
|
+
signature: pattern.signature,
|
|
8251
|
+
confidence: pattern.confidence * 0.8,
|
|
8252
|
+
occurrence_count: 1,
|
|
8253
|
+
first_seen_at: now,
|
|
8254
|
+
last_seen_at: now,
|
|
8255
|
+
seen_in_threads: [lastStitch.thread_id],
|
|
8256
|
+
classification: "anomalous"
|
|
8257
|
+
});
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
}
|
|
8261
|
+
}
|
|
8262
|
+
return anomalies;
|
|
8263
|
+
}
|
|
8264
|
+
var InMemoryPatternStore;
|
|
8265
|
+
var init_pattern_engine = __esm({
|
|
8266
|
+
"src/needle/pattern.engine.ts"() {
|
|
8267
|
+
InMemoryPatternStore = class {
|
|
8268
|
+
constructor() {
|
|
8269
|
+
this.patterns = /* @__PURE__ */ new Map();
|
|
8270
|
+
}
|
|
8271
|
+
save(pattern) {
|
|
8272
|
+
this.patterns.set(pattern.pattern_id, pattern);
|
|
8273
|
+
}
|
|
8274
|
+
get(patternId) {
|
|
8275
|
+
return this.patterns.get(patternId);
|
|
8276
|
+
}
|
|
8277
|
+
findByKind(kind) {
|
|
8278
|
+
return [...this.patterns.values()].filter((p) => p.kind === kind);
|
|
8279
|
+
}
|
|
8280
|
+
findByIntent(intent) {
|
|
8281
|
+
return [...this.patterns.values()].filter(
|
|
8282
|
+
(p) => p.signature.intent_sequence?.includes(intent)
|
|
8283
|
+
);
|
|
8284
|
+
}
|
|
8285
|
+
all() {
|
|
8286
|
+
return [...this.patterns.values()];
|
|
8287
|
+
}
|
|
8288
|
+
};
|
|
8289
|
+
}
|
|
8290
|
+
});
|
|
8291
|
+
|
|
8292
|
+
// src/sensors/tps.sensor.ts
|
|
8293
|
+
var require_tps_sensor = __commonJS({
|
|
8294
|
+
"src/sensors/tps.sensor.ts"(exports) {
|
|
8295
|
+
"use strict";
|
|
8296
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8297
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8298
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8299
|
+
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;
|
|
8300
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8301
|
+
};
|
|
8302
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8303
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8304
|
+
};
|
|
8305
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8306
|
+
exports.TpsSensor = void 0;
|
|
8307
|
+
var common_1 = __require("@nestjs/common");
|
|
8308
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8309
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8310
|
+
var TPS_EPOCH_MS = 9343548e5;
|
|
8311
|
+
function parseINotation(tps) {
|
|
8312
|
+
if (!tps.startsWith("i"))
|
|
8313
|
+
return null;
|
|
8314
|
+
const num = Number(tps.slice(1));
|
|
8315
|
+
if (!Number.isFinite(num))
|
|
8316
|
+
return null;
|
|
8317
|
+
return TPS_EPOCH_MS + num;
|
|
8318
|
+
}
|
|
8319
|
+
var TpsSensor2 = class TpsSensor {
|
|
8320
|
+
constructor(options = {}) {
|
|
8321
|
+
this.name = "TpsSensor";
|
|
8322
|
+
this.order = sensor_bands_1.BAND.POLICY + 2;
|
|
8323
|
+
this.maxDriftMs = options.maxDriftMs ?? 3e4;
|
|
8324
|
+
this.resolver = options.resolver ?? parseINotation;
|
|
8325
|
+
}
|
|
8326
|
+
supports(input) {
|
|
8327
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8328
|
+
return typeof tps === "string" && tps.length > 0;
|
|
8329
|
+
}
|
|
8330
|
+
async run(input) {
|
|
8331
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8332
|
+
const resolved = this.resolver(tps);
|
|
8333
|
+
if (resolved === null) {
|
|
8334
|
+
return {
|
|
8335
|
+
allow: false,
|
|
8336
|
+
riskScore: 80,
|
|
8337
|
+
reasons: [`TPS coordinate '${tps}' is structurally invalid`],
|
|
8338
|
+
code: "TPS_INVALID_FORMAT"
|
|
8339
|
+
};
|
|
8340
|
+
}
|
|
8341
|
+
const now = Date.now();
|
|
8342
|
+
const drift = Math.abs(now - resolved);
|
|
8343
|
+
if (drift > this.maxDriftMs) {
|
|
8344
|
+
const direction = resolved > now ? "future" : "past";
|
|
8345
|
+
return {
|
|
8346
|
+
allow: false,
|
|
8347
|
+
riskScore: 70,
|
|
8348
|
+
reasons: [
|
|
8349
|
+
`TPS drift ${drift}ms exceeds max ${this.maxDriftMs}ms (${direction})`
|
|
8350
|
+
],
|
|
8351
|
+
code: "TPS_DRIFT_EXCEEDED",
|
|
8352
|
+
tags: { tpsDriftMs: drift, tpsDirection: direction }
|
|
8353
|
+
};
|
|
8354
|
+
}
|
|
8355
|
+
return {
|
|
8356
|
+
allow: true,
|
|
8357
|
+
riskScore: 0,
|
|
8358
|
+
reasons: [],
|
|
8359
|
+
tags: {
|
|
8360
|
+
tpsResolved: resolved,
|
|
8361
|
+
tpsDriftMs: drift
|
|
8362
|
+
}
|
|
8363
|
+
};
|
|
8364
|
+
}
|
|
8365
|
+
};
|
|
8366
|
+
exports.TpsSensor = TpsSensor2;
|
|
8367
|
+
exports.TpsSensor = TpsSensor2 = __decorate([
|
|
8368
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8369
|
+
(0, common_1.Injectable)(),
|
|
8370
|
+
__metadata("design:paramtypes", [Object])
|
|
8371
|
+
], TpsSensor2);
|
|
8372
|
+
}
|
|
8373
|
+
});
|
|
8374
|
+
|
|
8375
|
+
// src/sensors/risk-gate.sensor.ts
|
|
8376
|
+
var require_risk_gate_sensor = __commonJS({
|
|
8377
|
+
"src/sensors/risk-gate.sensor.ts"(exports) {
|
|
8378
|
+
"use strict";
|
|
8379
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8380
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8381
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8382
|
+
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;
|
|
8383
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8384
|
+
};
|
|
8385
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8386
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8387
|
+
};
|
|
8388
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8389
|
+
exports.RiskGateSensor = void 0;
|
|
8390
|
+
var common_1 = __require("@nestjs/common");
|
|
8391
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8392
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8393
|
+
var risk_1 = (init_risk(), __toCommonJS(risk_exports));
|
|
8394
|
+
var SEVERITY_WEIGHT = {
|
|
8395
|
+
low: 10,
|
|
8396
|
+
medium: 25,
|
|
8397
|
+
high: 50,
|
|
8398
|
+
critical: 100
|
|
8399
|
+
};
|
|
8400
|
+
var RiskGateSensor2 = class RiskGateSensor {
|
|
8401
|
+
constructor(options) {
|
|
8402
|
+
this.name = "RiskGateSensor";
|
|
8403
|
+
this.order = sensor_bands_1.BAND.BUSINESS + 10;
|
|
8404
|
+
this.collectors = options.collectors;
|
|
8405
|
+
this.denyThreshold = options.denyThreshold ?? 75;
|
|
8406
|
+
this.flagThreshold = options.flagThreshold ?? 40;
|
|
8407
|
+
}
|
|
8408
|
+
async run(input) {
|
|
8409
|
+
const results = await Promise.all(this.collectors.map((c) => c(input)));
|
|
8410
|
+
const signals = results.flat();
|
|
8411
|
+
let totalWeight = 0;
|
|
8412
|
+
let weightedSum = 0;
|
|
8413
|
+
for (const signal of signals) {
|
|
8414
|
+
const w = SEVERITY_WEIGHT[signal.severity];
|
|
8415
|
+
totalWeight += 1;
|
|
8416
|
+
weightedSum += w;
|
|
8417
|
+
}
|
|
8418
|
+
const aggregateScore = totalWeight > 0 ? Math.min(100, Math.round(weightedSum / totalWeight)) : 0;
|
|
8419
|
+
const evaluation = this.evaluate(aggregateScore, signals);
|
|
8420
|
+
input.metadata = {
|
|
8421
|
+
...input.metadata ?? {},
|
|
8422
|
+
riskEvaluation: evaluation
|
|
8423
|
+
};
|
|
8424
|
+
if (evaluation.decision === risk_1.RiskDecision.DENY) {
|
|
8425
|
+
return {
|
|
8426
|
+
allow: false,
|
|
8427
|
+
riskScore: aggregateScore,
|
|
8428
|
+
reasons: signals.map((s) => s.message),
|
|
8429
|
+
code: "RISK_GATE_DENY",
|
|
8430
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8431
|
+
};
|
|
8432
|
+
}
|
|
8433
|
+
if (evaluation.decision === risk_1.RiskDecision.THROTTLE) {
|
|
8434
|
+
return {
|
|
8435
|
+
allow: false,
|
|
8436
|
+
riskScore: aggregateScore,
|
|
8437
|
+
reasons: signals.map((s) => s.message),
|
|
8438
|
+
code: "RISK_GATE_THROTTLE",
|
|
8439
|
+
retryAfterMs: evaluation.retryAfterMs,
|
|
8440
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8441
|
+
};
|
|
8442
|
+
}
|
|
8443
|
+
return {
|
|
8444
|
+
allow: true,
|
|
8445
|
+
riskScore: aggregateScore,
|
|
8446
|
+
reasons: signals.filter((s) => s.severity === "medium" || s.severity === "high").map((s) => s.message),
|
|
8447
|
+
tags: {
|
|
8448
|
+
riskDecision: evaluation.decision,
|
|
8449
|
+
signalCount: signals.length
|
|
8450
|
+
}
|
|
8451
|
+
};
|
|
8452
|
+
}
|
|
8453
|
+
evaluate(score, signals) {
|
|
8454
|
+
const hasCritical = signals.some((s) => s.severity === "critical");
|
|
8455
|
+
if (hasCritical) {
|
|
8456
|
+
return {
|
|
8457
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8458
|
+
reason: "Critical risk signal detected",
|
|
8459
|
+
confidence: 1,
|
|
8460
|
+
signals
|
|
8461
|
+
};
|
|
8462
|
+
}
|
|
8463
|
+
if (score >= this.denyThreshold) {
|
|
8464
|
+
return {
|
|
8465
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8466
|
+
reason: `Aggregate risk score ${score} exceeds deny threshold ${this.denyThreshold}`,
|
|
8467
|
+
confidence: score / 100,
|
|
8468
|
+
signals
|
|
8469
|
+
};
|
|
8470
|
+
}
|
|
8471
|
+
if (score >= this.flagThreshold) {
|
|
8472
|
+
return {
|
|
8473
|
+
decision: risk_1.RiskDecision.STEP_UP,
|
|
8474
|
+
reason: `Aggregate risk score ${score} exceeds flag threshold ${this.flagThreshold}`,
|
|
8475
|
+
confidence: score / 100,
|
|
8476
|
+
signals
|
|
8477
|
+
};
|
|
8478
|
+
}
|
|
8479
|
+
return {
|
|
8480
|
+
decision: risk_1.RiskDecision.ALLOW,
|
|
8481
|
+
confidence: 1 - score / 100,
|
|
8482
|
+
signals
|
|
8483
|
+
};
|
|
8484
|
+
}
|
|
8485
|
+
};
|
|
8486
|
+
exports.RiskGateSensor = RiskGateSensor2;
|
|
8487
|
+
exports.RiskGateSensor = RiskGateSensor2 = __decorate([
|
|
8488
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8489
|
+
(0, common_1.Injectable)(),
|
|
8490
|
+
__metadata("design:paramtypes", [Object])
|
|
8491
|
+
], RiskGateSensor2);
|
|
8492
|
+
}
|
|
8493
|
+
});
|
|
8494
|
+
|
|
8495
|
+
// src/sensors/tickauth.sensor.ts
|
|
8496
|
+
var require_tickauth_sensor = __commonJS({
|
|
8497
|
+
"src/sensors/tickauth.sensor.ts"(exports) {
|
|
8498
|
+
"use strict";
|
|
8499
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
8500
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8501
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8502
|
+
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;
|
|
8503
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8504
|
+
};
|
|
8505
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
8506
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8507
|
+
};
|
|
8508
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8509
|
+
exports.TickAuthSensor = void 0;
|
|
8510
|
+
var common_1 = __require("@nestjs/common");
|
|
8511
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8512
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8513
|
+
var TickAuthSensor2 = class TickAuthSensor {
|
|
8514
|
+
constructor(options = {}) {
|
|
8515
|
+
this.name = "TickAuthSensor";
|
|
8516
|
+
this.order = sensor_bands_1.BAND.IDENTITY + 40;
|
|
8517
|
+
this.verifier = options.verifier;
|
|
8518
|
+
this.matchIntent = options.matchIntent ?? true;
|
|
8519
|
+
this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
|
|
8520
|
+
}
|
|
8521
|
+
supports(input) {
|
|
8522
|
+
return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
|
|
8523
|
+
}
|
|
8524
|
+
async run(input) {
|
|
8525
|
+
const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
|
|
8526
|
+
if (!capsule) {
|
|
8527
|
+
return {
|
|
8528
|
+
allow: false,
|
|
8529
|
+
riskScore: 90,
|
|
8530
|
+
reasons: ["TickAuth capsule not found"],
|
|
8531
|
+
code: "TICKAUTH_MISSING"
|
|
8532
|
+
};
|
|
8533
|
+
}
|
|
8534
|
+
if (!capsule.capsule_id || typeof capsule.capsule_id !== "string") {
|
|
8535
|
+
return {
|
|
8536
|
+
allow: false,
|
|
8537
|
+
riskScore: 100,
|
|
8538
|
+
reasons: ["TickAuth capsule has no valid capsule_id"],
|
|
8539
|
+
code: "TICKAUTH_INVALID_ID"
|
|
8540
|
+
};
|
|
8541
|
+
}
|
|
8542
|
+
const status = capsule.verification?.status;
|
|
8543
|
+
if (status && status !== "approved") {
|
|
8544
|
+
return {
|
|
8545
|
+
allow: false,
|
|
8546
|
+
riskScore: 100,
|
|
8547
|
+
reasons: [
|
|
8548
|
+
`TickAuth capsule status is '${status}'${capsule.verification?.reason ? `: ${capsule.verification.reason}` : ""}`
|
|
8549
|
+
],
|
|
8550
|
+
code: `TICKAUTH_STATUS_${status.toUpperCase()}`
|
|
8551
|
+
};
|
|
8552
|
+
}
|
|
8553
|
+
if (this.acceptTypes && capsule.capsule_type) {
|
|
8554
|
+
if (!this.acceptTypes.has(capsule.capsule_type)) {
|
|
8555
|
+
return {
|
|
8556
|
+
allow: false,
|
|
8557
|
+
riskScore: 80,
|
|
8558
|
+
reasons: [
|
|
8559
|
+
`TickAuth capsule type '${capsule.capsule_type}' is not in accept list`
|
|
8560
|
+
],
|
|
8561
|
+
code: "TICKAUTH_TYPE_REJECTED"
|
|
8562
|
+
};
|
|
8563
|
+
}
|
|
8564
|
+
}
|
|
8565
|
+
if (this.matchIntent && input.intent && capsule.intent) {
|
|
8566
|
+
if (capsule.intent !== input.intent) {
|
|
8567
|
+
return {
|
|
8568
|
+
allow: false,
|
|
8569
|
+
riskScore: 80,
|
|
8570
|
+
reasons: [
|
|
8571
|
+
`TickAuth capsule intent '${capsule.intent}' does not match AXIS intent '${input.intent}'`
|
|
8572
|
+
],
|
|
8573
|
+
code: "TICKAUTH_INTENT_MISMATCH"
|
|
8574
|
+
};
|
|
8575
|
+
}
|
|
8576
|
+
}
|
|
8577
|
+
if (this.verifier) {
|
|
8578
|
+
const error = await this.verifier(capsule, input);
|
|
8579
|
+
if (error) {
|
|
8580
|
+
return {
|
|
8581
|
+
allow: false,
|
|
8582
|
+
riskScore: 90,
|
|
8583
|
+
reasons: [`TickAuth verification failed: ${error}`],
|
|
8584
|
+
code: "TICKAUTH_VERIFY_FAILED"
|
|
8585
|
+
};
|
|
8586
|
+
}
|
|
8587
|
+
}
|
|
8588
|
+
return {
|
|
8589
|
+
allow: true,
|
|
8590
|
+
riskScore: 0,
|
|
8591
|
+
reasons: [],
|
|
8592
|
+
tags: {
|
|
8593
|
+
tickauthCapsuleId: capsule.capsule_id,
|
|
8594
|
+
tickauthMode: capsule.mode,
|
|
8595
|
+
tickauthSingleUse: capsule.single_use
|
|
8596
|
+
}
|
|
8597
|
+
};
|
|
8598
|
+
}
|
|
8599
|
+
};
|
|
8600
|
+
exports.TickAuthSensor = TickAuthSensor2;
|
|
8601
|
+
exports.TickAuthSensor = TickAuthSensor2 = __decorate([
|
|
8602
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8603
|
+
(0, common_1.Injectable)(),
|
|
8604
|
+
__metadata("design:paramtypes", [Object])
|
|
8605
|
+
], TickAuthSensor2);
|
|
6268
8606
|
}
|
|
6269
8607
|
});
|
|
6270
8608
|
|
|
@@ -7076,95 +9414,19 @@ var init_cce = __esm({
|
|
|
7076
9414
|
// src/core/index.ts
|
|
7077
9415
|
var core_exports = {};
|
|
7078
9416
|
__export(core_exports, {
|
|
7079
|
-
AXIS_MAGIC: () => AXIS_MAGIC,
|
|
7080
|
-
AXIS_VERSION: () => AXIS_VERSION,
|
|
7081
9417
|
AxisError: () => AxisError,
|
|
7082
9418
|
AxisFrameZ: () => AxisFrameZ,
|
|
7083
|
-
AxisMediaTypes: () => AxisMediaTypes,
|
|
7084
|
-
BodyProfile: () => BodyProfile,
|
|
7085
|
-
ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
|
|
7086
|
-
ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
|
|
7087
|
-
ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
|
|
7088
|
-
ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
|
|
7089
|
-
FLAG_BODY_TLV: () => FLAG_BODY_TLV,
|
|
7090
|
-
FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
|
|
7091
|
-
FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
|
|
7092
|
-
MAX_BODY_LEN: () => MAX_BODY_LEN,
|
|
7093
|
-
MAX_FRAME_LEN: () => MAX_FRAME_LEN,
|
|
7094
|
-
MAX_HDR_LEN: () => MAX_HDR_LEN,
|
|
7095
|
-
MAX_SIG_LEN: () => MAX_SIG_LEN,
|
|
7096
|
-
NCERT_ALG: () => NCERT_ALG,
|
|
7097
|
-
NCERT_EXP: () => NCERT_EXP,
|
|
7098
|
-
NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
|
|
7099
|
-
NCERT_KID: () => NCERT_KID,
|
|
7100
|
-
NCERT_NBF: () => NCERT_NBF,
|
|
7101
|
-
NCERT_NODE_ID: () => NCERT_NODE_ID,
|
|
7102
|
-
NCERT_PAYLOAD: () => NCERT_PAYLOAD,
|
|
7103
|
-
NCERT_PUB: () => NCERT_PUB,
|
|
7104
|
-
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
7105
|
-
NCERT_SIG: () => NCERT_SIG,
|
|
7106
|
-
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
7107
|
-
PROOF_JWT: () => PROOF_JWT,
|
|
7108
|
-
PROOF_LOOM: () => PROOF_LOOM,
|
|
7109
|
-
PROOF_MTLS: () => PROOF_MTLS,
|
|
7110
|
-
PROOF_NONE: () => PROOF_NONE,
|
|
7111
|
-
PROOF_WITNESS: () => PROOF_WITNESS,
|
|
7112
|
-
ProofType: () => ProofType,
|
|
7113
|
-
TLV: () => TLV,
|
|
7114
|
-
TLV_ACTOR_ID: () => TLV_ACTOR_ID,
|
|
7115
|
-
TLV_AUD: () => TLV_AUD,
|
|
7116
|
-
TLV_BODY_ARR: () => TLV_BODY_ARR,
|
|
7117
|
-
TLV_BODY_OBJ: () => TLV_BODY_OBJ,
|
|
7118
|
-
TLV_CAPSULE: () => TLV_CAPSULE,
|
|
7119
|
-
TLV_EFFECT: () => TLV_EFFECT,
|
|
7120
|
-
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
7121
|
-
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
7122
|
-
TLV_INDEX: () => TLV_INDEX,
|
|
7123
|
-
TLV_INTENT: () => TLV_INTENT,
|
|
7124
|
-
TLV_KID: () => TLV_KID,
|
|
7125
|
-
TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
|
|
7126
|
-
TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
|
|
7127
|
-
TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
|
|
7128
|
-
TLV_NODE: () => TLV_NODE,
|
|
7129
|
-
TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
|
|
7130
|
-
TLV_NODE_KID: () => TLV_NODE_KID,
|
|
7131
|
-
TLV_NONCE: () => TLV_NONCE,
|
|
7132
|
-
TLV_OFFSET: () => TLV_OFFSET,
|
|
7133
|
-
TLV_OK: () => TLV_OK,
|
|
7134
|
-
TLV_PID: () => TLV_PID,
|
|
7135
|
-
TLV_PREV_HASH: () => TLV_PREV_HASH,
|
|
7136
|
-
TLV_PROOF_REF: () => TLV_PROOF_REF,
|
|
7137
|
-
TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
|
|
7138
|
-
TLV_REALM: () => TLV_REALM,
|
|
7139
|
-
TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
|
|
7140
|
-
TLV_RID: () => TLV_RID,
|
|
7141
|
-
TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
|
|
7142
|
-
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
7143
|
-
TLV_TS: () => TLV_TS,
|
|
7144
|
-
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
7145
9419
|
computeReceiptHash: () => computeReceiptHash,
|
|
7146
9420
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
7147
|
-
decodeArray: () => decodeArray,
|
|
7148
|
-
decodeFrame: () => decodeFrame,
|
|
7149
|
-
decodeObject: () => decodeObject,
|
|
7150
|
-
decodeTLVs: () => decodeTLVs,
|
|
7151
|
-
decodeTLVsList: () => decodeTLVsList,
|
|
7152
|
-
decodeVarint: () => decodeVarint,
|
|
7153
|
-
encodeFrame: () => encodeFrame,
|
|
7154
|
-
encodeTLVs: () => encodeTLVs,
|
|
7155
|
-
encodeVarint: () => encodeVarint,
|
|
7156
9421
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
7157
|
-
getSignTarget: () => getSignTarget,
|
|
7158
9422
|
sha256: () => sha2564,
|
|
7159
9423
|
signFrame: () => signFrame,
|
|
7160
|
-
varintLength: () => varintLength,
|
|
7161
9424
|
verifyFrameSignature: () => verifyFrameSignature
|
|
7162
9425
|
});
|
|
9426
|
+
import * as axis_protocol_star from "@nextera.one/axis-protocol";
|
|
7163
9427
|
var init_core = __esm({
|
|
7164
9428
|
"src/core/index.ts"() {
|
|
7165
|
-
|
|
7166
|
-
init_varint();
|
|
7167
|
-
init_tlv();
|
|
9429
|
+
__reExport(core_exports, axis_protocol_star);
|
|
7168
9430
|
init_axis_bin();
|
|
7169
9431
|
init_signature();
|
|
7170
9432
|
init_axis_error();
|
|
@@ -7397,14 +9659,6 @@ __export(decorators_exports, {
|
|
|
7397
9659
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
7398
9660
|
Sensitivity: () => Sensitivity,
|
|
7399
9661
|
Sensor: () => Sensor,
|
|
7400
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
7401
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
7402
|
-
TlvEnum: () => TlvEnum,
|
|
7403
|
-
TlvField: () => TlvField,
|
|
7404
|
-
TlvMinLen: () => TlvMinLen,
|
|
7405
|
-
TlvRange: () => TlvRange,
|
|
7406
|
-
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
7407
|
-
TlvValidate: () => TlvValidate,
|
|
7408
9662
|
Witness: () => Witness,
|
|
7409
9663
|
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
7410
9664
|
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
@@ -7422,7 +9676,7 @@ var init_decorators = __esm({
|
|
|
7422
9676
|
init_intent_decorator();
|
|
7423
9677
|
init_observer_decorator();
|
|
7424
9678
|
init_sensor_decorator();
|
|
7425
|
-
|
|
9679
|
+
__reExport(decorators_exports, __toESM(require_tlv_field_decorator()));
|
|
7426
9680
|
}
|
|
7427
9681
|
});
|
|
7428
9682
|
|
|
@@ -7523,6 +9777,25 @@ var init_engine = __esm({
|
|
|
7523
9777
|
}
|
|
7524
9778
|
});
|
|
7525
9779
|
|
|
9780
|
+
// src/idel/idel.types.ts
|
|
9781
|
+
var init_idel_types = __esm({
|
|
9782
|
+
"src/idel/idel.types.ts"() {
|
|
9783
|
+
}
|
|
9784
|
+
});
|
|
9785
|
+
|
|
9786
|
+
// src/idel/index.ts
|
|
9787
|
+
var idel_exports = {};
|
|
9788
|
+
__export(idel_exports, {
|
|
9789
|
+
IdelCompiler: () => IdelCompiler,
|
|
9790
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry
|
|
9791
|
+
});
|
|
9792
|
+
var init_idel = __esm({
|
|
9793
|
+
"src/idel/index.ts"() {
|
|
9794
|
+
init_idel_types();
|
|
9795
|
+
init_idel_compiler();
|
|
9796
|
+
}
|
|
9797
|
+
});
|
|
9798
|
+
|
|
7526
9799
|
// src/loom/index.ts
|
|
7527
9800
|
var loom_exports = {};
|
|
7528
9801
|
__export(loom_exports, {
|
|
@@ -7532,11 +9805,98 @@ __export(loom_exports, {
|
|
|
7532
9805
|
TLV_WRIT: () => TLV_LOOM_WRIT,
|
|
7533
9806
|
canonicalizeGrant: () => canonicalizeGrant,
|
|
7534
9807
|
canonicalizeWrit: () => canonicalizeWrit,
|
|
7535
|
-
|
|
9808
|
+
createGrant: () => createGrant,
|
|
9809
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
9810
|
+
createReceipt: () => createReceipt,
|
|
9811
|
+
createRevocation: () => createRevocation,
|
|
9812
|
+
createWrit: () => createWrit,
|
|
9813
|
+
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
9814
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9815
|
+
getGrantStatus: () => getGrantStatus,
|
|
9816
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
9817
|
+
grantCoversAction: () => grantCoversAction,
|
|
9818
|
+
isRevoked: () => isRevoked,
|
|
9819
|
+
renewPresence: () => renewPresence,
|
|
9820
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9821
|
+
updateThreadState: () => updateThreadState,
|
|
9822
|
+
validateGrant: () => validateGrant,
|
|
9823
|
+
validateWrit: () => validateWrit,
|
|
9824
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
9825
|
+
verifyReceiptChain: () => verifyReceiptChain
|
|
7536
9826
|
});
|
|
7537
9827
|
var init_loom = __esm({
|
|
7538
9828
|
"src/loom/index.ts"() {
|
|
7539
9829
|
init_loom_types();
|
|
9830
|
+
init_loom_engine();
|
|
9831
|
+
}
|
|
9832
|
+
});
|
|
9833
|
+
|
|
9834
|
+
// src/needle/needle.types.ts
|
|
9835
|
+
var init_needle_types = __esm({
|
|
9836
|
+
"src/needle/needle.types.ts"() {
|
|
9837
|
+
}
|
|
9838
|
+
});
|
|
9839
|
+
|
|
9840
|
+
// src/needle/knot.types.ts
|
|
9841
|
+
var init_knot_types = __esm({
|
|
9842
|
+
"src/needle/knot.types.ts"() {
|
|
9843
|
+
}
|
|
9844
|
+
});
|
|
9845
|
+
|
|
9846
|
+
// src/needle/fabric.types.ts
|
|
9847
|
+
var init_fabric_types = __esm({
|
|
9848
|
+
"src/needle/fabric.types.ts"() {
|
|
9849
|
+
}
|
|
9850
|
+
});
|
|
9851
|
+
|
|
9852
|
+
// src/needle/pattern.types.ts
|
|
9853
|
+
var init_pattern_types = __esm({
|
|
9854
|
+
"src/needle/pattern.types.ts"() {
|
|
9855
|
+
}
|
|
9856
|
+
});
|
|
9857
|
+
|
|
9858
|
+
// src/needle/index.ts
|
|
9859
|
+
var needle_exports = {};
|
|
9860
|
+
__export(needle_exports, {
|
|
9861
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
9862
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
9863
|
+
applyStitch: () => applyStitch,
|
|
9864
|
+
assembleNeedle: () => assembleNeedle,
|
|
9865
|
+
breakKnot: () => breakKnot,
|
|
9866
|
+
createFabric: () => createFabric,
|
|
9867
|
+
detectAnomalies: () => detectAnomalies,
|
|
9868
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
9869
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
9870
|
+
diffFabrics: () => diffFabrics,
|
|
9871
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
9872
|
+
forkFromKnot: () => forkFromKnot,
|
|
9873
|
+
formStitch: () => formStitch,
|
|
9874
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
9875
|
+
getFabricValue: () => getFabricValue,
|
|
9876
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
9877
|
+
isKnotOpen: () => isKnotOpen,
|
|
9878
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
9879
|
+
lockCells: () => lockCells,
|
|
9880
|
+
matchPatterns: () => matchPatterns,
|
|
9881
|
+
openKnot: () => openKnot,
|
|
9882
|
+
projectAt: () => projectAt,
|
|
9883
|
+
queryFabric: () => queryFabric,
|
|
9884
|
+
recordOccurrence: () => recordOccurrence,
|
|
9885
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9886
|
+
tieKnot: () => tieKnot,
|
|
9887
|
+
validateKnot: () => validateKnot,
|
|
9888
|
+
weave: () => weave
|
|
9889
|
+
});
|
|
9890
|
+
var init_needle = __esm({
|
|
9891
|
+
"src/needle/index.ts"() {
|
|
9892
|
+
init_needle_types();
|
|
9893
|
+
init_needle_engine();
|
|
9894
|
+
init_knot_types();
|
|
9895
|
+
init_knot_engine();
|
|
9896
|
+
init_fabric_types();
|
|
9897
|
+
init_fabric_engine();
|
|
9898
|
+
init_pattern_types();
|
|
9899
|
+
init_pattern_engine();
|
|
7540
9900
|
}
|
|
7541
9901
|
});
|
|
7542
9902
|
|
|
@@ -8785,6 +11145,143 @@ var require_intent_registry_sensor = __commonJS({
|
|
|
8785
11145
|
}
|
|
8786
11146
|
});
|
|
8787
11147
|
|
|
11148
|
+
// src/sensors/law-evaluation.sensor.ts
|
|
11149
|
+
var require_law_evaluation_sensor = __commonJS({
|
|
11150
|
+
"src/sensors/law-evaluation.sensor.ts"(exports) {
|
|
11151
|
+
"use strict";
|
|
11152
|
+
var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
|
|
11153
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11154
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11155
|
+
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;
|
|
11156
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11157
|
+
};
|
|
11158
|
+
var __metadata = exports && exports.__metadata || function(k, v) {
|
|
11159
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11160
|
+
};
|
|
11161
|
+
var LawEvaluationSensor_1;
|
|
11162
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11163
|
+
exports.LawEvaluationSensor = void 0;
|
|
11164
|
+
var common_1 = __require("@nestjs/common");
|
|
11165
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
11166
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
11167
|
+
var law_1 = (init_law(), __toCommonJS(law_exports));
|
|
11168
|
+
var LawEvaluationSensor = LawEvaluationSensor_1 = class LawEvaluationSensor {
|
|
11169
|
+
constructor(options = {}) {
|
|
11170
|
+
this.options = options;
|
|
11171
|
+
this.logger = new common_1.Logger(LawEvaluationSensor_1.name);
|
|
11172
|
+
this.name = "LawEvaluationSensor";
|
|
11173
|
+
this.order = sensor_bands_1.BAND.POLICY + 5;
|
|
11174
|
+
}
|
|
11175
|
+
supports(input) {
|
|
11176
|
+
return !!this.options.evaluator && !!input.intent;
|
|
11177
|
+
}
|
|
11178
|
+
async run(input) {
|
|
11179
|
+
const evaluator = this.options.evaluator;
|
|
11180
|
+
if (!evaluator) {
|
|
11181
|
+
return { action: "ALLOW" };
|
|
11182
|
+
}
|
|
11183
|
+
const context = (0, law_1.buildAxisLawEvaluationContext)(input);
|
|
11184
|
+
let result;
|
|
11185
|
+
try {
|
|
11186
|
+
result = await evaluator(context);
|
|
11187
|
+
} catch (error) {
|
|
11188
|
+
const message = error instanceof Error ? error.message : "Unknown law evaluation error";
|
|
11189
|
+
this.logger.error(`Law evaluation failed for ${input.intent}: ${message}`);
|
|
11190
|
+
input.metadata = {
|
|
11191
|
+
...input.metadata ?? {},
|
|
11192
|
+
lawEvaluation: {
|
|
11193
|
+
decision: "deny",
|
|
11194
|
+
reason: "Law evaluation failed",
|
|
11195
|
+
explanation: message
|
|
11196
|
+
}
|
|
11197
|
+
};
|
|
11198
|
+
return {
|
|
11199
|
+
action: "DENY",
|
|
11200
|
+
code: "LAW_EVALUATION_ERROR",
|
|
11201
|
+
reason: message,
|
|
11202
|
+
meta: { lawDecision: "deny" }
|
|
11203
|
+
};
|
|
11204
|
+
}
|
|
11205
|
+
input.metadata = {
|
|
11206
|
+
...input.metadata ?? {},
|
|
11207
|
+
lawEvaluation: {
|
|
11208
|
+
...result,
|
|
11209
|
+
context: sanitizeLawContext(context)
|
|
11210
|
+
}
|
|
11211
|
+
};
|
|
11212
|
+
if (result.decision === "allow") {
|
|
11213
|
+
return {
|
|
11214
|
+
allow: true,
|
|
11215
|
+
riskScore: 0,
|
|
11216
|
+
reasons: result.reason ? [result.reason] : [],
|
|
11217
|
+
tags: {
|
|
11218
|
+
lawDecision: "allow",
|
|
11219
|
+
...result.applicable ? { lawApplicableArticles: result.applicable.length } : {}
|
|
11220
|
+
},
|
|
11221
|
+
meta: result
|
|
11222
|
+
};
|
|
11223
|
+
}
|
|
11224
|
+
if (result.decision === "conditional") {
|
|
11225
|
+
const mode = this.options.conditionalDecision ?? "deny";
|
|
11226
|
+
const reasons = [result.reason, result.explanation].filter(Boolean);
|
|
11227
|
+
if (mode === "allow") {
|
|
11228
|
+
return {
|
|
11229
|
+
allow: true,
|
|
11230
|
+
riskScore: 0,
|
|
11231
|
+
reasons,
|
|
11232
|
+
tags: {
|
|
11233
|
+
lawDecision: "conditional"
|
|
11234
|
+
},
|
|
11235
|
+
meta: result
|
|
11236
|
+
};
|
|
11237
|
+
}
|
|
11238
|
+
if (mode === "flag") {
|
|
11239
|
+
return {
|
|
11240
|
+
action: "FLAG",
|
|
11241
|
+
scoreDelta: 25,
|
|
11242
|
+
reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
|
|
11243
|
+
meta: result
|
|
11244
|
+
};
|
|
11245
|
+
}
|
|
11246
|
+
return {
|
|
11247
|
+
action: "DENY",
|
|
11248
|
+
code: "LAW_CONDITIONAL",
|
|
11249
|
+
reason: reasons.join(" | ") || "Execution is conditionally permitted pending additional requirements",
|
|
11250
|
+
meta: { lawDecision: "conditional", evaluation: result }
|
|
11251
|
+
};
|
|
11252
|
+
}
|
|
11253
|
+
return {
|
|
11254
|
+
action: "DENY",
|
|
11255
|
+
code: "LAW_DENIED",
|
|
11256
|
+
reason: [result.reason, result.explanation].filter(Boolean).join(" | ") || "Execution denied by law evaluation",
|
|
11257
|
+
meta: { lawDecision: "deny", evaluation: result }
|
|
11258
|
+
};
|
|
11259
|
+
}
|
|
11260
|
+
};
|
|
11261
|
+
exports.LawEvaluationSensor = LawEvaluationSensor;
|
|
11262
|
+
exports.LawEvaluationSensor = LawEvaluationSensor = LawEvaluationSensor_1 = __decorate([
|
|
11263
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
11264
|
+
(0, common_1.Injectable)(),
|
|
11265
|
+
__metadata("design:paramtypes", [Object])
|
|
11266
|
+
], LawEvaluationSensor);
|
|
11267
|
+
function sanitizeLawContext(context) {
|
|
11268
|
+
return {
|
|
11269
|
+
actorId: context.actorId,
|
|
11270
|
+
intent: context.intent,
|
|
11271
|
+
audience: context.audience,
|
|
11272
|
+
tps: context.tps,
|
|
11273
|
+
country: context.country,
|
|
11274
|
+
ip: context.ip,
|
|
11275
|
+
path: context.path,
|
|
11276
|
+
clientId: context.clientId,
|
|
11277
|
+
deviceId: context.deviceId,
|
|
11278
|
+
sessionId: context.sessionId,
|
|
11279
|
+
capsuleId: context.capsuleId
|
|
11280
|
+
};
|
|
11281
|
+
}
|
|
11282
|
+
}
|
|
11283
|
+
});
|
|
11284
|
+
|
|
8788
11285
|
// src/sensors/proof-presence.sensor.ts
|
|
8789
11286
|
var require_proof_presence_sensor = __commonJS({
|
|
8790
11287
|
"src/sensors/proof-presence.sensor.ts"(exports) {
|
|
@@ -9487,16 +11984,40 @@ var init_sensors2 = __esm({
|
|
|
9487
11984
|
__reExport(sensors_exports, __toESM(require_header_tlv_limit_sensor()));
|
|
9488
11985
|
__reExport(sensors_exports, __toESM(require_intent_allowlist_sensor()));
|
|
9489
11986
|
__reExport(sensors_exports, __toESM(require_intent_registry_sensor()));
|
|
11987
|
+
__reExport(sensors_exports, __toESM(require_law_evaluation_sensor()));
|
|
9490
11988
|
__reExport(sensors_exports, __toESM(require_proof_presence_sensor()));
|
|
9491
11989
|
__reExport(sensors_exports, __toESM(require_protocol_strict_sensor()));
|
|
9492
11990
|
__reExport(sensors_exports, __toESM(require_receipt_policy_sensor()));
|
|
11991
|
+
__reExport(sensors_exports, __toESM(require_risk_gate_sensor()));
|
|
9493
11992
|
__reExport(sensors_exports, __toESM(require_schema_validation_sensor()));
|
|
9494
11993
|
__reExport(sensors_exports, __toESM(require_stream_scope_sensor()));
|
|
11994
|
+
__reExport(sensors_exports, __toESM(require_tickauth_sensor()));
|
|
9495
11995
|
__reExport(sensors_exports, __toESM(require_tlv_parse_sensor()));
|
|
11996
|
+
__reExport(sensors_exports, __toESM(require_tps_sensor()));
|
|
9496
11997
|
__reExport(sensors_exports, __toESM(require_varint_hardening_sensor()));
|
|
9497
11998
|
}
|
|
9498
11999
|
});
|
|
9499
12000
|
|
|
12001
|
+
// src/timeline/timeline.types.ts
|
|
12002
|
+
var init_timeline_types = __esm({
|
|
12003
|
+
"src/timeline/timeline.types.ts"() {
|
|
12004
|
+
}
|
|
12005
|
+
});
|
|
12006
|
+
|
|
12007
|
+
// src/timeline/index.ts
|
|
12008
|
+
var timeline_exports = {};
|
|
12009
|
+
__export(timeline_exports, {
|
|
12010
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
12011
|
+
TimelineEngine: () => TimelineEngine
|
|
12012
|
+
});
|
|
12013
|
+
var init_timeline = __esm({
|
|
12014
|
+
"src/timeline/index.ts"() {
|
|
12015
|
+
init_timeline_types();
|
|
12016
|
+
init_timeline_store();
|
|
12017
|
+
init_timeline_engine();
|
|
12018
|
+
}
|
|
12019
|
+
});
|
|
12020
|
+
|
|
9500
12021
|
// src/utils/index.ts
|
|
9501
12022
|
var utils_exports = {};
|
|
9502
12023
|
__export(utils_exports, {
|
|
@@ -9585,6 +12106,10 @@ __export(index_exports, {
|
|
|
9585
12106
|
INTENT_SENSITIVITY_MAP: () => INTENT_SENSITIVITY_MAP,
|
|
9586
12107
|
INTENT_SENSORS_KEY: () => INTENT_SENSORS_KEY,
|
|
9587
12108
|
INTENT_TIMEOUTS: () => INTENT_TIMEOUTS,
|
|
12109
|
+
IdelCompiler: () => IdelCompiler,
|
|
12110
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry,
|
|
12111
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
12112
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
9588
12113
|
Intent: () => Intent,
|
|
9589
12114
|
IntentBody: () => IntentBody,
|
|
9590
12115
|
IntentRouter: () => import_intent2.IntentRouter,
|
|
@@ -9628,6 +12153,7 @@ __export(index_exports, {
|
|
|
9628
12153
|
RequiredProof: () => RequiredProof,
|
|
9629
12154
|
ResponseObserver: () => ResponseObserver,
|
|
9630
12155
|
RiskDecision: () => RiskDecision,
|
|
12156
|
+
RiskGateSensor: () => import_risk_gate.RiskGateSensor,
|
|
9631
12157
|
SENSITIVITY_METADATA_KEY: () => SENSITIVITY_METADATA_KEY,
|
|
9632
12158
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
9633
12159
|
Schema2002_PasskeyLoginOptionsRes: () => Schema2002_PasskeyLoginOptionsRes,
|
|
@@ -9648,7 +12174,7 @@ __export(index_exports, {
|
|
|
9648
12174
|
TLV_EFFECT: () => TLV_EFFECT,
|
|
9649
12175
|
TLV_ERROR_CODE: () => TLV_ERROR_CODE,
|
|
9650
12176
|
TLV_ERROR_MSG: () => TLV_ERROR_MSG,
|
|
9651
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
12177
|
+
TLV_FIELDS_KEY: () => import_tlv_field2.TLV_FIELDS_KEY,
|
|
9652
12178
|
TLV_INDEX: () => TLV_INDEX,
|
|
9653
12179
|
TLV_INTENT: () => TLV_INTENT,
|
|
9654
12180
|
TLV_KID: () => TLV_KID,
|
|
@@ -9674,21 +12200,29 @@ __export(index_exports, {
|
|
|
9674
12200
|
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
9675
12201
|
TLV_TS: () => TLV_TS,
|
|
9676
12202
|
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
9677
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
12203
|
+
TLV_VALIDATORS_KEY: () => import_tlv_field2.TLV_VALIDATORS_KEY,
|
|
9678
12204
|
TLV_WRIT: () => TLV_LOOM_WRIT,
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
12205
|
+
TickAuthSensor: () => import_tickauth.TickAuthSensor,
|
|
12206
|
+
TimelineEngine: () => TimelineEngine,
|
|
12207
|
+
TlvEnum: () => import_tlv_field2.TlvEnum,
|
|
12208
|
+
TlvField: () => import_tlv_field2.TlvField,
|
|
12209
|
+
TlvMinLen: () => import_tlv_field2.TlvMinLen,
|
|
12210
|
+
TlvRange: () => import_tlv_field2.TlvRange,
|
|
12211
|
+
TlvUtf8Pattern: () => import_tlv_field2.TlvUtf8Pattern,
|
|
12212
|
+
TlvValidate: () => import_tlv_field2.TlvValidate,
|
|
12213
|
+
TpsSensor: () => import_tps.TpsSensor,
|
|
9685
12214
|
Witness: () => Witness,
|
|
12215
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
12216
|
+
applyStitch: () => applyStitch,
|
|
12217
|
+
assembleNeedle: () => assembleNeedle,
|
|
9686
12218
|
axis1SigningBytes: () => axis1SigningBytes,
|
|
9687
12219
|
b64urlDecode: () => b64urlDecode,
|
|
9688
12220
|
b64urlDecodeString: () => b64urlDecodeString,
|
|
9689
12221
|
b64urlEncode: () => b64urlEncode,
|
|
9690
12222
|
b64urlEncodeString: () => b64urlEncodeString,
|
|
12223
|
+
breakKnot: () => breakKnot,
|
|
9691
12224
|
buildAts1Hdr: () => buildAts1Hdr,
|
|
12225
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext,
|
|
9692
12226
|
buildDtoDecoder: () => import_dto_schema.buildDtoDecoder,
|
|
9693
12227
|
buildPacket: () => buildPacket,
|
|
9694
12228
|
buildQueueMessage: () => buildQueueMessage,
|
|
@@ -9707,7 +12241,13 @@ __export(index_exports, {
|
|
|
9707
12241
|
computeReceiptHash: () => computeReceiptHash,
|
|
9708
12242
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
9709
12243
|
core: () => core_exports,
|
|
12244
|
+
createFabric: () => createFabric,
|
|
12245
|
+
createGrant: () => createGrant,
|
|
9710
12246
|
createObservation: () => createObservation,
|
|
12247
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
12248
|
+
createReceipt: () => createReceipt,
|
|
12249
|
+
createRevocation: () => createRevocation,
|
|
12250
|
+
createWrit: () => createWrit,
|
|
9711
12251
|
crypto: () => crypto_exports,
|
|
9712
12252
|
decodeArray: () => decodeArray,
|
|
9713
12253
|
decodeAxis1Frame: () => decodeAxis1Frame,
|
|
@@ -9719,6 +12259,10 @@ __export(index_exports, {
|
|
|
9719
12259
|
decodeVarint: () => decodeVarint,
|
|
9720
12260
|
decorators: () => decorators_exports,
|
|
9721
12261
|
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
12262
|
+
detectAnomalies: () => detectAnomalies,
|
|
12263
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
12264
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
12265
|
+
diffFabrics: () => diffFabrics,
|
|
9722
12266
|
encVarint: () => encVarint,
|
|
9723
12267
|
encodeAxis1Frame: () => encodeAxis1Frame,
|
|
9724
12268
|
encodeAxisTlvDto: () => encodeAxisTlvDto,
|
|
@@ -9729,20 +12273,38 @@ __export(index_exports, {
|
|
|
9729
12273
|
endStage: () => endStage,
|
|
9730
12274
|
engine: () => engine_exports,
|
|
9731
12275
|
executeCcePipeline: () => executeCcePipeline,
|
|
12276
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9732
12277
|
extractDtoSchema: () => import_dto_schema.extractDtoSchema,
|
|
9733
12278
|
finalizeObservation: () => finalizeObservation,
|
|
12279
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
12280
|
+
forkFromKnot: () => forkFromKnot,
|
|
12281
|
+
formStitch: () => formStitch,
|
|
9734
12282
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
9735
12283
|
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
12284
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
12285
|
+
getFabricValue: () => getFabricValue,
|
|
12286
|
+
getGrantStatus: () => getGrantStatus,
|
|
12287
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
12288
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
9736
12289
|
getSignTarget: () => getSignTarget,
|
|
12290
|
+
grantCoversAction: () => grantCoversAction,
|
|
9737
12291
|
hasScope: () => hasScope,
|
|
9738
12292
|
hashObservation: () => hashObservation,
|
|
12293
|
+
idel: () => idel_exports,
|
|
9739
12294
|
isAdminOpcode: () => isAdminOpcode,
|
|
12295
|
+
isKnotOpen: () => isKnotOpen,
|
|
9740
12296
|
isKnownOpcode: () => isKnownOpcode,
|
|
12297
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
12298
|
+
isRevoked: () => isRevoked,
|
|
9741
12299
|
isTimestampValid: () => isTimestampValid,
|
|
12300
|
+
lockCells: () => lockCells,
|
|
9742
12301
|
loom: () => loom_exports,
|
|
12302
|
+
matchPatterns: () => matchPatterns,
|
|
9743
12303
|
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
12304
|
+
needle: () => needle_exports,
|
|
9744
12305
|
nonce16: () => nonce16,
|
|
9745
12306
|
normalizeSensorDecision: () => normalizeSensorDecision,
|
|
12307
|
+
openKnot: () => openKnot,
|
|
9746
12308
|
packPasskeyLoginOptionsReq: () => packPasskeyLoginOptionsReq,
|
|
9747
12309
|
packPasskeyLoginOptionsRes: () => packPasskeyLoginOptionsRes,
|
|
9748
12310
|
packPasskeyLoginVerifyReq: () => packPasskeyLoginVerifyReq,
|
|
@@ -9751,31 +12313,48 @@ __export(index_exports, {
|
|
|
9751
12313
|
parseAutoClaimEntries: () => parseAutoClaimEntries,
|
|
9752
12314
|
parseScope: () => parseScope,
|
|
9753
12315
|
parseStreamEntries: () => parseStreamEntries,
|
|
12316
|
+
projectAt: () => projectAt,
|
|
12317
|
+
queryFabric: () => queryFabric,
|
|
12318
|
+
recordOccurrence: () => recordOccurrence,
|
|
9754
12319
|
recordSensor: () => recordSensor,
|
|
12320
|
+
renewPresence: () => renewPresence,
|
|
9755
12321
|
resolveTimeout: () => resolveTimeout,
|
|
12322
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9756
12323
|
schemas: () => schemas_exports,
|
|
12324
|
+
scoreTruth: () => scoreTruth,
|
|
9757
12325
|
security: () => security_exports,
|
|
9758
12326
|
sensitivityName: () => sensitivityName,
|
|
9759
12327
|
sensors: () => sensors_exports,
|
|
9760
12328
|
sha256: () => sha2564,
|
|
9761
12329
|
signFrame: () => signFrame,
|
|
12330
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9762
12331
|
stableJsonStringify: () => stableJsonStringify,
|
|
9763
12332
|
startStage: () => startStage,
|
|
12333
|
+
tieKnot: () => tieKnot,
|
|
12334
|
+
timeline: () => timeline_exports,
|
|
9764
12335
|
tlv: () => tlv,
|
|
9765
12336
|
u64be: () => u64be,
|
|
9766
12337
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
9767
12338
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
9768
12339
|
unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
|
|
12340
|
+
updateThreadState: () => updateThreadState,
|
|
9769
12341
|
utf8: () => utf8,
|
|
9770
12342
|
utils: () => utils_exports,
|
|
9771
12343
|
validateFrameShape: () => validateFrameShape,
|
|
12344
|
+
validateGrant: () => validateGrant,
|
|
12345
|
+
validateKnot: () => validateKnot,
|
|
12346
|
+
validateWrit: () => validateWrit,
|
|
9772
12347
|
varintLength: () => varintLength,
|
|
9773
12348
|
varintU: () => varintU,
|
|
9774
12349
|
verifyFrameSignature: () => verifyFrameSignature,
|
|
12350
|
+
verifyObservation: () => verifyObservation,
|
|
12351
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
12352
|
+
verifyReceiptChain: () => verifyReceiptChain,
|
|
9775
12353
|
verifyResponse: () => verifyResponse,
|
|
12354
|
+
weave: () => weave,
|
|
9776
12355
|
withAxisExecutionContext: () => withAxisExecutionContext
|
|
9777
12356
|
});
|
|
9778
|
-
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;
|
|
12357
|
+
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;
|
|
9779
12358
|
var init_index = __esm({
|
|
9780
12359
|
"src/index.ts"() {
|
|
9781
12360
|
init_chain_decorator();
|
|
@@ -9788,7 +12367,7 @@ var init_index = __esm({
|
|
|
9788
12367
|
init_observer_decorator();
|
|
9789
12368
|
init_handler_sensors_decorator();
|
|
9790
12369
|
init_sensor_decorator();
|
|
9791
|
-
|
|
12370
|
+
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
9792
12371
|
import_dto_schema = __toESM(require_dto_schema_util());
|
|
9793
12372
|
init_axis_tlv_dto();
|
|
9794
12373
|
import_axis_id = __toESM(require_axis_id_dto());
|
|
@@ -9801,6 +12380,7 @@ var init_index = __esm({
|
|
|
9801
12380
|
init_stable_json();
|
|
9802
12381
|
init_observation_queue_codec();
|
|
9803
12382
|
init_observation_hash();
|
|
12383
|
+
init_truth_scoring();
|
|
9804
12384
|
init_response_observer();
|
|
9805
12385
|
init_constants();
|
|
9806
12386
|
init_varint();
|
|
@@ -9822,6 +12402,7 @@ var init_index = __esm({
|
|
|
9822
12402
|
init_axis_sensor();
|
|
9823
12403
|
init_scopes();
|
|
9824
12404
|
init_capabilities();
|
|
12405
|
+
init_law();
|
|
9825
12406
|
init_risk();
|
|
9826
12407
|
init_opcodes();
|
|
9827
12408
|
init_receipt();
|
|
@@ -9841,19 +12422,33 @@ var init_index = __esm({
|
|
|
9841
12422
|
import_sensor2 = __toESM(require_sensor_registry());
|
|
9842
12423
|
init_axis_observation();
|
|
9843
12424
|
import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
|
|
12425
|
+
init_timeline_engine();
|
|
12426
|
+
init_timeline_store();
|
|
9844
12427
|
init_cce_pipeline();
|
|
9845
12428
|
init_cce_types();
|
|
9846
12429
|
init_axis_tlv_codec();
|
|
9847
12430
|
init_loom_types();
|
|
12431
|
+
init_loom_engine();
|
|
12432
|
+
init_idel_compiler();
|
|
12433
|
+
init_needle_engine();
|
|
12434
|
+
init_knot_engine();
|
|
12435
|
+
init_fabric_engine();
|
|
12436
|
+
init_pattern_engine();
|
|
12437
|
+
import_tps = __toESM(require_tps_sensor());
|
|
12438
|
+
import_risk_gate = __toESM(require_risk_gate_sensor());
|
|
12439
|
+
import_tickauth = __toESM(require_tickauth_sensor());
|
|
9848
12440
|
init_cce();
|
|
9849
12441
|
init_core();
|
|
9850
12442
|
init_crypto();
|
|
9851
12443
|
init_decorators();
|
|
9852
12444
|
init_engine();
|
|
12445
|
+
init_idel();
|
|
9853
12446
|
init_loom();
|
|
12447
|
+
init_needle();
|
|
9854
12448
|
init_schemas();
|
|
9855
12449
|
init_security();
|
|
9856
12450
|
init_sensors2();
|
|
12451
|
+
init_timeline();
|
|
9857
12452
|
init_utils();
|
|
9858
12453
|
}
|
|
9859
12454
|
});
|
|
@@ -9879,8 +12474,19 @@ var export_RESPONSE_TAG_CREATED_BY = import_axis_response.RESPONSE_TAG_CREATED_B
|
|
|
9879
12474
|
var export_RESPONSE_TAG_ID = import_axis_response.RESPONSE_TAG_ID;
|
|
9880
12475
|
var export_RESPONSE_TAG_UPDATED_AT = import_axis_response.RESPONSE_TAG_UPDATED_AT;
|
|
9881
12476
|
var export_RESPONSE_TAG_UPDATED_BY = import_axis_response.RESPONSE_TAG_UPDATED_BY;
|
|
12477
|
+
var export_RiskGateSensor = import_risk_gate.RiskGateSensor;
|
|
9882
12478
|
var export_SensorDiscoveryService = import_sensor_discovery.SensorDiscoveryService;
|
|
9883
12479
|
var export_SensorRegistry = import_sensor2.SensorRegistry;
|
|
12480
|
+
var export_TLV_FIELDS_KEY = import_tlv_field2.TLV_FIELDS_KEY;
|
|
12481
|
+
var export_TLV_VALIDATORS_KEY = import_tlv_field2.TLV_VALIDATORS_KEY;
|
|
12482
|
+
var export_TickAuthSensor = import_tickauth.TickAuthSensor;
|
|
12483
|
+
var export_TlvEnum = import_tlv_field2.TlvEnum;
|
|
12484
|
+
var export_TlvField = import_tlv_field2.TlvField;
|
|
12485
|
+
var export_TlvMinLen = import_tlv_field2.TlvMinLen;
|
|
12486
|
+
var export_TlvRange = import_tlv_field2.TlvRange;
|
|
12487
|
+
var export_TlvUtf8Pattern = import_tlv_field2.TlvUtf8Pattern;
|
|
12488
|
+
var export_TlvValidate = import_tlv_field2.TlvValidate;
|
|
12489
|
+
var export_TpsSensor = import_tps.TpsSensor;
|
|
9884
12490
|
var export_buildDtoDecoder = import_dto_schema.buildDtoDecoder;
|
|
9885
12491
|
var export_extractDtoSchema = import_dto_schema.extractDtoSchema;
|
|
9886
12492
|
export {
|
|
@@ -9958,6 +12564,10 @@ export {
|
|
|
9958
12564
|
INTENT_SENSITIVITY_MAP,
|
|
9959
12565
|
INTENT_SENSORS_KEY,
|
|
9960
12566
|
INTENT_TIMEOUTS,
|
|
12567
|
+
IdelCompiler,
|
|
12568
|
+
IdelSchemaRegistry,
|
|
12569
|
+
InMemoryPatternStore,
|
|
12570
|
+
InMemoryTimelineStore,
|
|
9961
12571
|
Intent,
|
|
9962
12572
|
IntentBody,
|
|
9963
12573
|
export_IntentRouter as IntentRouter,
|
|
@@ -10001,6 +12611,7 @@ export {
|
|
|
10001
12611
|
RequiredProof,
|
|
10002
12612
|
ResponseObserver,
|
|
10003
12613
|
RiskDecision,
|
|
12614
|
+
export_RiskGateSensor as RiskGateSensor,
|
|
10004
12615
|
SENSITIVITY_METADATA_KEY,
|
|
10005
12616
|
SENSOR_METADATA_KEY,
|
|
10006
12617
|
Schema2002_PasskeyLoginOptionsRes,
|
|
@@ -10021,7 +12632,7 @@ export {
|
|
|
10021
12632
|
TLV_EFFECT,
|
|
10022
12633
|
TLV_ERROR_CODE,
|
|
10023
12634
|
TLV_ERROR_MSG,
|
|
10024
|
-
TLV_FIELDS_KEY,
|
|
12635
|
+
export_TLV_FIELDS_KEY as TLV_FIELDS_KEY,
|
|
10025
12636
|
TLV_INDEX,
|
|
10026
12637
|
TLV_INTENT,
|
|
10027
12638
|
TLV_KID,
|
|
@@ -10047,21 +12658,29 @@ export {
|
|
|
10047
12658
|
TLV_TRACE_ID,
|
|
10048
12659
|
TLV_TS,
|
|
10049
12660
|
TLV_UPLOAD_ID,
|
|
10050
|
-
TLV_VALIDATORS_KEY,
|
|
12661
|
+
export_TLV_VALIDATORS_KEY as TLV_VALIDATORS_KEY,
|
|
10051
12662
|
TLV_LOOM_WRIT as TLV_WRIT,
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
12663
|
+
export_TickAuthSensor as TickAuthSensor,
|
|
12664
|
+
TimelineEngine,
|
|
12665
|
+
export_TlvEnum as TlvEnum,
|
|
12666
|
+
export_TlvField as TlvField,
|
|
12667
|
+
export_TlvMinLen as TlvMinLen,
|
|
12668
|
+
export_TlvRange as TlvRange,
|
|
12669
|
+
export_TlvUtf8Pattern as TlvUtf8Pattern,
|
|
12670
|
+
export_TlvValidate as TlvValidate,
|
|
12671
|
+
export_TpsSensor as TpsSensor,
|
|
10058
12672
|
Witness,
|
|
12673
|
+
addStitchToKnot,
|
|
12674
|
+
applyStitch,
|
|
12675
|
+
assembleNeedle,
|
|
10059
12676
|
axis1SigningBytes,
|
|
10060
12677
|
b64urlDecode,
|
|
10061
12678
|
b64urlDecodeString,
|
|
10062
12679
|
b64urlEncode,
|
|
10063
12680
|
b64urlEncodeString,
|
|
12681
|
+
breakKnot,
|
|
10064
12682
|
buildAts1Hdr,
|
|
12683
|
+
buildAxisLawEvaluationContext,
|
|
10065
12684
|
export_buildDtoDecoder as buildDtoDecoder,
|
|
10066
12685
|
buildPacket,
|
|
10067
12686
|
buildQueueMessage,
|
|
@@ -10080,7 +12699,13 @@ export {
|
|
|
10080
12699
|
computeReceiptHash,
|
|
10081
12700
|
computeSignaturePayload,
|
|
10082
12701
|
core_exports as core,
|
|
12702
|
+
createFabric,
|
|
12703
|
+
createGrant,
|
|
10083
12704
|
createObservation,
|
|
12705
|
+
createPresenceChallenge,
|
|
12706
|
+
createReceipt,
|
|
12707
|
+
createRevocation,
|
|
12708
|
+
createWrit,
|
|
10084
12709
|
crypto_exports as crypto,
|
|
10085
12710
|
decodeArray,
|
|
10086
12711
|
decodeAxis1Frame,
|
|
@@ -10092,6 +12717,10 @@ export {
|
|
|
10092
12717
|
decodeVarint,
|
|
10093
12718
|
decorators_exports as decorators,
|
|
10094
12719
|
deriveAnchorReflection,
|
|
12720
|
+
detectAnomalies,
|
|
12721
|
+
detectKnotPatterns,
|
|
12722
|
+
detectSequencePatterns,
|
|
12723
|
+
diffFabrics,
|
|
10095
12724
|
encVarint,
|
|
10096
12725
|
encodeAxis1Frame,
|
|
10097
12726
|
encodeAxisTlvDto,
|
|
@@ -10102,20 +12731,38 @@ export {
|
|
|
10102
12731
|
endStage,
|
|
10103
12732
|
engine_exports as engine,
|
|
10104
12733
|
executeCcePipeline,
|
|
12734
|
+
executeLoomPipeline,
|
|
10105
12735
|
export_extractDtoSchema as extractDtoSchema,
|
|
10106
12736
|
finalizeObservation,
|
|
12737
|
+
findKnotsForStitch,
|
|
12738
|
+
forkFromKnot,
|
|
12739
|
+
formStitch,
|
|
10107
12740
|
generateEd25519KeyPair,
|
|
10108
12741
|
getAxisExecutionContext,
|
|
12742
|
+
getDecisionPoints,
|
|
12743
|
+
getFabricValue,
|
|
12744
|
+
getGrantStatus,
|
|
12745
|
+
getIrreversibleKnots,
|
|
12746
|
+
getPresenceStatus,
|
|
10109
12747
|
getSignTarget,
|
|
12748
|
+
grantCoversAction,
|
|
10110
12749
|
hasScope,
|
|
10111
12750
|
hashObservation,
|
|
12751
|
+
idel_exports as idel,
|
|
10112
12752
|
isAdminOpcode,
|
|
12753
|
+
isKnotOpen,
|
|
10113
12754
|
isKnownOpcode,
|
|
12755
|
+
isPointOfNoReturn,
|
|
12756
|
+
isRevoked,
|
|
10114
12757
|
isTimestampValid,
|
|
12758
|
+
lockCells,
|
|
10115
12759
|
loom_exports as loom,
|
|
12760
|
+
matchPatterns,
|
|
10116
12761
|
mergeAxisExecutionContext,
|
|
12762
|
+
needle_exports as needle,
|
|
10117
12763
|
nonce16,
|
|
10118
12764
|
normalizeSensorDecision,
|
|
12765
|
+
openKnot,
|
|
10119
12766
|
packPasskeyLoginOptionsReq,
|
|
10120
12767
|
packPasskeyLoginOptionsRes,
|
|
10121
12768
|
packPasskeyLoginVerifyReq,
|
|
@@ -10124,28 +12771,45 @@ export {
|
|
|
10124
12771
|
parseAutoClaimEntries,
|
|
10125
12772
|
parseScope,
|
|
10126
12773
|
parseStreamEntries,
|
|
12774
|
+
projectAt,
|
|
12775
|
+
queryFabric,
|
|
12776
|
+
recordOccurrence,
|
|
10127
12777
|
recordSensor,
|
|
12778
|
+
renewPresence,
|
|
10128
12779
|
resolveTimeout,
|
|
12780
|
+
runNeedlePipeline,
|
|
10129
12781
|
schemas_exports as schemas,
|
|
12782
|
+
scoreTruth,
|
|
10130
12783
|
security_exports as security,
|
|
10131
12784
|
sensitivityName,
|
|
10132
12785
|
sensors_exports as sensors,
|
|
10133
12786
|
sha2564 as sha256,
|
|
10134
12787
|
signFrame,
|
|
12788
|
+
signPresenceChallenge,
|
|
10135
12789
|
stableJsonStringify,
|
|
10136
12790
|
startStage,
|
|
12791
|
+
tieKnot,
|
|
12792
|
+
timeline_exports as timeline,
|
|
10137
12793
|
tlv,
|
|
10138
12794
|
u64be,
|
|
10139
12795
|
unpackPasskeyLoginOptionsReq,
|
|
10140
12796
|
unpackPasskeyLoginVerifyReq,
|
|
10141
12797
|
unpackPasskeyRegisterOptionsReq,
|
|
12798
|
+
updateThreadState,
|
|
10142
12799
|
utf8,
|
|
10143
12800
|
utils_exports as utils,
|
|
10144
12801
|
validateFrameShape,
|
|
12802
|
+
validateGrant,
|
|
12803
|
+
validateKnot,
|
|
12804
|
+
validateWrit,
|
|
10145
12805
|
varintLength,
|
|
10146
12806
|
varintU,
|
|
10147
12807
|
verifyFrameSignature,
|
|
12808
|
+
verifyObservation,
|
|
12809
|
+
verifyPresenceProof,
|
|
12810
|
+
verifyReceiptChain,
|
|
10148
12811
|
verifyResponse,
|
|
12812
|
+
weave,
|
|
10149
12813
|
withAxisExecutionContext
|
|
10150
12814
|
};
|
|
10151
12815
|
//# sourceMappingURL=index.mjs.map
|