@nextera.one/axis-server-sdk 2.1.6 → 2.1.7
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 +1404 -522
- package/dist/index.d.ts +1404 -522
- package/dist/index.js +3076 -432
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3085 -427
- 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.js
CHANGED
|
@@ -343,7 +343,8 @@ function Intent(action, options) {
|
|
|
343
343
|
chain: options?.chain,
|
|
344
344
|
bodyProfile: options?.bodyProfile,
|
|
345
345
|
tlv: options?.tlv,
|
|
346
|
-
dto: options?.dto
|
|
346
|
+
dto: options?.dto,
|
|
347
|
+
is: options?.is
|
|
347
348
|
});
|
|
348
349
|
Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
|
|
349
350
|
};
|
|
@@ -499,76 +500,90 @@ var init_sensor_decorator = __esm({
|
|
|
499
500
|
});
|
|
500
501
|
|
|
501
502
|
// src/decorators/tlv-field.decorator.ts
|
|
502
|
-
var
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const existing = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
527
|
-
const prop = String(propertyKey);
|
|
528
|
-
let entry = existing.find((e) => e.property === prop);
|
|
529
|
-
if (!entry) {
|
|
530
|
-
entry = { property: prop, tag: 0, validators: [] };
|
|
531
|
-
existing.push(entry);
|
|
503
|
+
var require_tlv_field_decorator = __commonJS({
|
|
504
|
+
"src/decorators/tlv-field.decorator.ts"(exports2) {
|
|
505
|
+
"use strict";
|
|
506
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
507
|
+
exports2.TLV_VALIDATORS_KEY = exports2.TLV_FIELDS_KEY = void 0;
|
|
508
|
+
exports2.TlvField = TlvField2;
|
|
509
|
+
exports2.TlvValidate = TlvValidate2;
|
|
510
|
+
exports2.TlvUtf8Pattern = TlvUtf8Pattern2;
|
|
511
|
+
exports2.TlvMinLen = TlvMinLen2;
|
|
512
|
+
exports2.TlvEnum = TlvEnum2;
|
|
513
|
+
exports2.TlvRange = TlvRange2;
|
|
514
|
+
require("reflect-metadata");
|
|
515
|
+
exports2.TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
516
|
+
exports2.TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
517
|
+
var textDecoder = new TextDecoder();
|
|
518
|
+
function assertUniqueFieldMetadata(existing, property, tag) {
|
|
519
|
+
const duplicateProperty = existing.find((item) => item.property === property);
|
|
520
|
+
if (duplicateProperty) {
|
|
521
|
+
throw new Error(`Duplicate @TlvField for property ${property}`);
|
|
522
|
+
}
|
|
523
|
+
const duplicateTag = existing.find((item) => item.tag === tag);
|
|
524
|
+
if (duplicateTag) {
|
|
525
|
+
throw new Error(`Duplicate @TlvField tag ${tag} for ${property}; already used by ${duplicateTag.property}`);
|
|
526
|
+
}
|
|
532
527
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return
|
|
528
|
+
function TlvField2(tag, options) {
|
|
529
|
+
return (target, propertyKey) => {
|
|
530
|
+
const existing = Reflect.getOwnMetadata(exports2.TLV_FIELDS_KEY, target.constructor) || [];
|
|
531
|
+
const property = String(propertyKey);
|
|
532
|
+
assertUniqueFieldMetadata(existing, property, tag);
|
|
533
|
+
existing.push({
|
|
534
|
+
property,
|
|
535
|
+
tag,
|
|
536
|
+
options
|
|
537
|
+
});
|
|
538
|
+
Reflect.defineMetadata(exports2.TLV_FIELDS_KEY, existing, target.constructor);
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function TlvValidate2(validator) {
|
|
542
|
+
return (target, propertyKey) => {
|
|
543
|
+
const existing = Reflect.getOwnMetadata(exports2.TLV_VALIDATORS_KEY, target.constructor) || [];
|
|
544
|
+
const prop = String(propertyKey);
|
|
545
|
+
let entry = existing.find((e) => e.property === prop);
|
|
546
|
+
if (!entry) {
|
|
547
|
+
entry = { property: prop, tag: 0, validators: [] };
|
|
548
|
+
existing.push(entry);
|
|
549
|
+
}
|
|
550
|
+
entry.validators.push(validator);
|
|
551
|
+
Reflect.defineMetadata(exports2.TLV_VALIDATORS_KEY, existing, target.constructor);
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
function TlvUtf8Pattern2(pattern, message) {
|
|
555
|
+
const matcher = new RegExp(pattern.source, pattern.flags);
|
|
556
|
+
return TlvValidate2((val, prop) => {
|
|
557
|
+
const str = textDecoder.decode(val);
|
|
558
|
+
matcher.lastIndex = 0;
|
|
559
|
+
return matcher.test(str) ? null : message || `${prop}: failed pattern check`;
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
function TlvMinLen2(min, message) {
|
|
563
|
+
return TlvValidate2((val, prop) => {
|
|
564
|
+
return val.length >= min ? null : message || `${prop}: too short (${val.length} < ${min})`;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function TlvEnum2(allowed, message) {
|
|
568
|
+
const set = new Set(allowed);
|
|
569
|
+
return TlvValidate2((val, prop) => {
|
|
570
|
+
const str = textDecoder.decode(val);
|
|
571
|
+
return set.has(str) ? null : message || `${prop}: must be one of [${allowed.join(", ")}]`;
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function TlvRange2(min, max, message) {
|
|
575
|
+
return TlvValidate2((val, prop) => {
|
|
576
|
+
if (val.length !== 8)
|
|
577
|
+
return `${prop}: u64 must be 8 bytes`;
|
|
578
|
+
let n = 0n;
|
|
579
|
+
for (const b of val)
|
|
580
|
+
n = n << 8n | BigInt(b);
|
|
581
|
+
if (n < min || n > max) {
|
|
582
|
+
return message || `${prop}: value ${n} out of range [${min}, ${max}]`;
|
|
583
|
+
}
|
|
584
|
+
return null;
|
|
585
|
+
});
|
|
562
586
|
}
|
|
563
|
-
return null;
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
var import_reflect_metadata9, TLV_FIELDS_KEY, TLV_VALIDATORS_KEY;
|
|
567
|
-
var init_tlv_field_decorator = __esm({
|
|
568
|
-
"src/decorators/tlv-field.decorator.ts"() {
|
|
569
|
-
import_reflect_metadata9 = require("reflect-metadata");
|
|
570
|
-
TLV_FIELDS_KEY = "axis:tlv:fields";
|
|
571
|
-
TLV_VALIDATORS_KEY = "axis:tlv:validators";
|
|
572
587
|
}
|
|
573
588
|
});
|
|
574
589
|
|
|
@@ -597,7 +612,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
597
612
|
exports2.extractDtoSchema = extractDtoSchema2;
|
|
598
613
|
exports2.buildDtoDecoder = buildDtoDecoder2;
|
|
599
614
|
require("reflect-metadata");
|
|
600
|
-
var tlv_field_decorator_1 = (
|
|
615
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
601
616
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
602
617
|
function extractDtoSchema2(dto) {
|
|
603
618
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
@@ -706,7 +721,7 @@ var require_axis_id_dto = __commonJS({
|
|
|
706
721
|
};
|
|
707
722
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
708
723
|
exports2.AxisIdDto = void 0;
|
|
709
|
-
var tlv_field_decorator_1 = (
|
|
724
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
710
725
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
711
726
|
var AxisIdDto2 = class extends axis_tlv_dto_1.AxisTlvDto {
|
|
712
727
|
};
|
|
@@ -723,27 +738,27 @@ var require_axis_id_dto = __commonJS({
|
|
|
723
738
|
function AxisPartialType(BaseDto) {
|
|
724
739
|
class PartialDto extends BaseDto {
|
|
725
740
|
}
|
|
726
|
-
const fields = Reflect.getOwnMetadata(TLV_FIELDS_KEY, BaseDto) || [];
|
|
741
|
+
const fields = Reflect.getOwnMetadata(import_tlv_field.TLV_FIELDS_KEY, BaseDto) || [];
|
|
727
742
|
const partialFields = fields.map((f) => ({
|
|
728
743
|
property: f.property,
|
|
729
744
|
tag: f.tag,
|
|
730
745
|
options: { ...f.options, required: false }
|
|
731
746
|
}));
|
|
732
|
-
Reflect.defineMetadata(TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
733
|
-
const validators = Reflect.getOwnMetadata(TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
747
|
+
Reflect.defineMetadata(import_tlv_field.TLV_FIELDS_KEY, partialFields, PartialDto);
|
|
748
|
+
const validators = Reflect.getOwnMetadata(import_tlv_field.TLV_VALIDATORS_KEY, BaseDto) || [];
|
|
734
749
|
if (validators.length > 0) {
|
|
735
|
-
Reflect.defineMetadata(TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
750
|
+
Reflect.defineMetadata(import_tlv_field.TLV_VALIDATORS_KEY, [...validators], PartialDto);
|
|
736
751
|
}
|
|
737
752
|
Object.defineProperty(PartialDto, "name", {
|
|
738
753
|
value: `Partial${BaseDto.name}`
|
|
739
754
|
});
|
|
740
755
|
return PartialDto;
|
|
741
756
|
}
|
|
742
|
-
var
|
|
757
|
+
var import_reflect_metadata9, import_tlv_field;
|
|
743
758
|
var init_axis_partial_type = __esm({
|
|
744
759
|
"src/base/axis-partial-type.ts"() {
|
|
745
|
-
|
|
746
|
-
|
|
760
|
+
import_reflect_metadata9 = require("reflect-metadata");
|
|
761
|
+
import_tlv_field = __toESM(require_tlv_field_decorator());
|
|
747
762
|
}
|
|
748
763
|
});
|
|
749
764
|
|
|
@@ -762,7 +777,7 @@ var require_axis_response_dto = __commonJS({
|
|
|
762
777
|
};
|
|
763
778
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
764
779
|
exports2.AxisResponseDto = exports2.RESPONSE_TAG_UPDATED_BY = exports2.RESPONSE_TAG_CREATED_BY = exports2.RESPONSE_TAG_UPDATED_AT = exports2.RESPONSE_TAG_CREATED_AT = exports2.RESPONSE_TAG_ID = void 0;
|
|
765
|
-
var tlv_field_decorator_1 = (
|
|
780
|
+
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
766
781
|
var axis_tlv_dto_1 = (init_axis_tlv_dto(), __toCommonJS(axis_tlv_dto_exports));
|
|
767
782
|
exports2.RESPONSE_TAG_ID = 1;
|
|
768
783
|
exports2.RESPONSE_TAG_CREATED_AT = 2;
|
|
@@ -2067,6 +2082,121 @@ var init_inline_capsule = __esm({
|
|
|
2067
2082
|
}
|
|
2068
2083
|
});
|
|
2069
2084
|
|
|
2085
|
+
// src/engine/registry/sensor.registry.ts
|
|
2086
|
+
var require_sensor_registry = __commonJS({
|
|
2087
|
+
"src/engine/registry/sensor.registry.ts"(exports2) {
|
|
2088
|
+
"use strict";
|
|
2089
|
+
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
2090
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2091
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2092
|
+
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;
|
|
2093
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2094
|
+
};
|
|
2095
|
+
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
2096
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2097
|
+
};
|
|
2098
|
+
var SensorRegistry_1;
|
|
2099
|
+
var _a;
|
|
2100
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2101
|
+
exports2.SensorRegistry = void 0;
|
|
2102
|
+
var common_1 = require("@nestjs/common");
|
|
2103
|
+
var config_1 = require("@nestjs/config");
|
|
2104
|
+
var SensorRegistry2 = SensorRegistry_1 = class SensorRegistry {
|
|
2105
|
+
constructor(configService) {
|
|
2106
|
+
this.configService = configService;
|
|
2107
|
+
this.sensors = [];
|
|
2108
|
+
this.sensorsByName = /* @__PURE__ */ new Map();
|
|
2109
|
+
this.sensorsByType = /* @__PURE__ */ new Map();
|
|
2110
|
+
this.logger = new common_1.Logger(SensorRegistry_1.name);
|
|
2111
|
+
}
|
|
2112
|
+
register(sensor) {
|
|
2113
|
+
if (!sensor.name) {
|
|
2114
|
+
throw new Error("AxisSensor must have a name");
|
|
2115
|
+
}
|
|
2116
|
+
const enabledSensorsStr = this.configService.get("ENABLED_SENSORS");
|
|
2117
|
+
const disabledSensorsStr = this.configService.get("DISABLED_SENSORS");
|
|
2118
|
+
const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
|
|
2119
|
+
const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
|
|
2120
|
+
if (enabledSensors && !enabledSensors.includes(sensor.name)) {
|
|
2121
|
+
this.logger.log(`Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`);
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
if (disabledSensors.includes(sensor.name)) {
|
|
2125
|
+
this.logger.log(`Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`);
|
|
2126
|
+
return;
|
|
2127
|
+
}
|
|
2128
|
+
if (sensor.order === void 0) {
|
|
2129
|
+
throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
|
|
2130
|
+
}
|
|
2131
|
+
const isPreDecodeSensor = this.isPreDecodeSensor(sensor);
|
|
2132
|
+
const isPostDecodeSensor = this.isPostDecodeSensor(sensor);
|
|
2133
|
+
if (isPreDecodeSensor && sensor.order >= 40) {
|
|
2134
|
+
this.logger.warn(`AxisSensor "${sensor.name}" is marked as PRE_DECODE but has order ${sensor.order} (should be < 40)`);
|
|
2135
|
+
}
|
|
2136
|
+
if (isPostDecodeSensor && sensor.order < 40) {
|
|
2137
|
+
this.logger.warn(`AxisSensor "${sensor.name}" is marked as POST_DECODE but has order ${sensor.order} (should be >= 40)`);
|
|
2138
|
+
}
|
|
2139
|
+
this.sensors.push(sensor);
|
|
2140
|
+
this.indexSensor(sensor);
|
|
2141
|
+
const phaseLabel = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase || "UNKNOWN";
|
|
2142
|
+
this.logger.debug(`Registered sensor: ${sensor.name} (order: ${sensor.order}, phase: ${phaseLabel})`);
|
|
2143
|
+
}
|
|
2144
|
+
list() {
|
|
2145
|
+
return [...this.sensors].sort((a, b) => (a.order ?? 999) - (b.order ?? 999));
|
|
2146
|
+
}
|
|
2147
|
+
resolve(ref) {
|
|
2148
|
+
if (typeof ref === "string") {
|
|
2149
|
+
return this.sensorsByName.get(ref);
|
|
2150
|
+
}
|
|
2151
|
+
return this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
|
|
2152
|
+
}
|
|
2153
|
+
getByName(name) {
|
|
2154
|
+
return this.sensorsByName.get(name);
|
|
2155
|
+
}
|
|
2156
|
+
getPreDecodeSensors() {
|
|
2157
|
+
return this.list().filter((s) => (s.order ?? 999) < 40);
|
|
2158
|
+
}
|
|
2159
|
+
getPostDecodeSensors() {
|
|
2160
|
+
return this.list().filter((s) => (s.order ?? 999) >= 40);
|
|
2161
|
+
}
|
|
2162
|
+
isPreDecodeSensor(sensor) {
|
|
2163
|
+
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
2164
|
+
return phase === "PRE_DECODE" || (sensor.order ?? 999) < 40;
|
|
2165
|
+
}
|
|
2166
|
+
isPostDecodeSensor(sensor) {
|
|
2167
|
+
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
2168
|
+
return phase === "POST_DECODE" || (sensor.order ?? 999) >= 40;
|
|
2169
|
+
}
|
|
2170
|
+
getSensorCountByPhase() {
|
|
2171
|
+
return {
|
|
2172
|
+
preDecodeCount: this.getPreDecodeSensors().length,
|
|
2173
|
+
postDecodeCount: this.getPostDecodeSensors().length
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
clear() {
|
|
2177
|
+
this.sensors = [];
|
|
2178
|
+
this.sensorsByName.clear();
|
|
2179
|
+
this.sensorsByType.clear();
|
|
2180
|
+
}
|
|
2181
|
+
indexSensor(sensor) {
|
|
2182
|
+
this.sensorsByName.set(sensor.name, sensor);
|
|
2183
|
+
const sensorType = sensor.constructor;
|
|
2184
|
+
if (!sensorType)
|
|
2185
|
+
return;
|
|
2186
|
+
this.sensorsByType.set(sensorType, sensor);
|
|
2187
|
+
if (!this.sensorsByName.has(sensorType.name)) {
|
|
2188
|
+
this.sensorsByName.set(sensorType.name, sensor);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
exports2.SensorRegistry = SensorRegistry2;
|
|
2193
|
+
exports2.SensorRegistry = SensorRegistry2 = SensorRegistry_1 = __decorate([
|
|
2194
|
+
(0, common_1.Injectable)(),
|
|
2195
|
+
__metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
|
|
2196
|
+
], SensorRegistry2);
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
|
|
2070
2200
|
// src/engine/intent.router.ts
|
|
2071
2201
|
var require_intent_router = __commonJS({
|
|
2072
2202
|
"src/engine/intent.router.ts"(exports2) {
|
|
@@ -2088,6 +2218,7 @@ var require_intent_router = __commonJS({
|
|
|
2088
2218
|
var IntentRouter_1;
|
|
2089
2219
|
var _a;
|
|
2090
2220
|
var _b;
|
|
2221
|
+
var _c;
|
|
2091
2222
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2092
2223
|
exports2.IntentRouter = void 0;
|
|
2093
2224
|
var common_1 = require("@nestjs/common");
|
|
@@ -2108,11 +2239,33 @@ var require_intent_router = __commonJS({
|
|
|
2108
2239
|
var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
|
|
2109
2240
|
var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
|
|
2110
2241
|
var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
|
|
2242
|
+
var sensor_registry_1 = require_sensor_registry();
|
|
2111
2243
|
var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
|
|
2112
2244
|
var observer_dispatcher_service_1 = require_observer_dispatcher_service();
|
|
2113
2245
|
function observerRefKey(ref) {
|
|
2114
2246
|
return typeof ref === "string" ? ref : ref.name;
|
|
2115
2247
|
}
|
|
2248
|
+
function sensorRefKey(ref) {
|
|
2249
|
+
return typeof ref === "string" ? ref : ref.name;
|
|
2250
|
+
}
|
|
2251
|
+
function mergeIntentSensorRefs(...sensorGroups) {
|
|
2252
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2253
|
+
for (const group of sensorGroups) {
|
|
2254
|
+
if (!Array.isArray(group))
|
|
2255
|
+
continue;
|
|
2256
|
+
for (const ref of group) {
|
|
2257
|
+
const key = sensorRefKey(ref);
|
|
2258
|
+
const existing = merged.get(key);
|
|
2259
|
+
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2260
|
+
merged.set(key, ref);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
return Array.from(merged.values());
|
|
2265
|
+
}
|
|
2266
|
+
function isAxisSensorInstance(value) {
|
|
2267
|
+
return !!value && typeof value.name === "string" && typeof value.run === "function";
|
|
2268
|
+
}
|
|
2116
2269
|
function mergeObserverBindings(bindings) {
|
|
2117
2270
|
const merged = /* @__PURE__ */ new Map();
|
|
2118
2271
|
for (const binding of bindings) {
|
|
@@ -2149,9 +2302,10 @@ var require_intent_router = __commonJS({
|
|
|
2149
2302
|
};
|
|
2150
2303
|
}
|
|
2151
2304
|
var IntentRouter2 = IntentRouter_1 = class IntentRouter {
|
|
2152
|
-
constructor(moduleRef, observerDispatcher) {
|
|
2305
|
+
constructor(moduleRef, observerDispatcher, sensorRegistry) {
|
|
2153
2306
|
this.moduleRef = moduleRef;
|
|
2154
2307
|
this.observerDispatcher = observerDispatcher;
|
|
2308
|
+
this.sensorRegistry = sensorRegistry;
|
|
2155
2309
|
this.logger = new common_1.Logger(IntentRouter_1.name);
|
|
2156
2310
|
this.decoder = new TextDecoder();
|
|
2157
2311
|
this.encoder = new TextEncoder();
|
|
@@ -2319,9 +2473,9 @@ var require_intent_router = __commonJS({
|
|
|
2319
2473
|
if (!handler) {
|
|
2320
2474
|
throw new Error(`Intent not found: ${intent}`);
|
|
2321
2475
|
}
|
|
2322
|
-
const
|
|
2323
|
-
if (
|
|
2324
|
-
await this.runIntentSensors(
|
|
2476
|
+
const sensorRefs = this.intentSensors.get(intent);
|
|
2477
|
+
if (sensorRefs && sensorRefs.length > 0) {
|
|
2478
|
+
await this.runIntentSensors(sensorRefs, intent, frame);
|
|
2325
2479
|
}
|
|
2326
2480
|
const decoder = this.intentDecoders.get(intent);
|
|
2327
2481
|
let decodedBody = frame.body;
|
|
@@ -2392,10 +2546,8 @@ var require_intent_router = __commonJS({
|
|
|
2392
2546
|
this.intentDecoders.set(intent, decoder);
|
|
2393
2547
|
}
|
|
2394
2548
|
const intentSensors = Reflect.getMetadata(intent_sensors_decorator_1.INTENT_SENSORS_KEY, proto, methodName);
|
|
2395
|
-
const
|
|
2396
|
-
|
|
2397
|
-
...Array.isArray(intentSensors) ? intentSensors : []
|
|
2398
|
-
];
|
|
2549
|
+
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
2550
|
+
const combined = mergeIntentSensorRefs(handlerSensors, Array.isArray(intentSensors) ? intentSensors : void 0, Array.isArray(meta?.is) ? meta.is : void 0);
|
|
2399
2551
|
if (combined.length > 0) {
|
|
2400
2552
|
this.intentSensors.set(intent, combined);
|
|
2401
2553
|
}
|
|
@@ -2413,7 +2565,6 @@ var require_intent_router = __commonJS({
|
|
|
2413
2565
|
if (capsulePolicy) {
|
|
2414
2566
|
this.intentCapsulePolicies.set(intent, capsulePolicy);
|
|
2415
2567
|
}
|
|
2416
|
-
const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
|
|
2417
2568
|
if (meta) {
|
|
2418
2569
|
this.storeSchema({ ...meta, intent });
|
|
2419
2570
|
if (meta.kind) {
|
|
@@ -2481,23 +2632,26 @@ var require_intent_router = __commonJS({
|
|
|
2481
2632
|
return;
|
|
2482
2633
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
2483
2634
|
}
|
|
2484
|
-
async runIntentSensors(
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
} catch {
|
|
2492
|
-
this.logger.warn(`@IntentSensors: could not resolve ${SensorClass.name} for ${intent}`);
|
|
2493
|
-
continue;
|
|
2635
|
+
async runIntentSensors(sensorRefs, intent, frame) {
|
|
2636
|
+
for (const sensorRef of sensorRefs) {
|
|
2637
|
+
const sensor = this.resolveIntentSensor(sensorRef);
|
|
2638
|
+
const sensorName = sensorRefKey(sensorRef);
|
|
2639
|
+
if (!sensor) {
|
|
2640
|
+
this.logger.error(`Intent sensor ${sensorName} is not registered for ${intent}`);
|
|
2641
|
+
throw new Error(`SENSOR_MISSING:${sensorName}`);
|
|
2494
2642
|
}
|
|
2495
2643
|
const sensorInput = {
|
|
2496
2644
|
rawBytes: frame.body,
|
|
2497
2645
|
intent,
|
|
2498
2646
|
body: frame.body,
|
|
2499
2647
|
headerTLVs: frame.headers,
|
|
2500
|
-
|
|
2648
|
+
frameBody: frame.body,
|
|
2649
|
+
metadata: {
|
|
2650
|
+
phase: "intent",
|
|
2651
|
+
intent,
|
|
2652
|
+
schema: this.getSchema(intent),
|
|
2653
|
+
validators: this.getValidators(intent)
|
|
2654
|
+
}
|
|
2501
2655
|
};
|
|
2502
2656
|
if (sensor.supports && !sensor.supports(sensorInput))
|
|
2503
2657
|
continue;
|
|
@@ -2509,6 +2663,21 @@ var require_intent_router = __commonJS({
|
|
|
2509
2663
|
}
|
|
2510
2664
|
}
|
|
2511
2665
|
}
|
|
2666
|
+
resolveIntentSensor(ref) {
|
|
2667
|
+
const registered = this.sensorRegistry?.resolve(ref);
|
|
2668
|
+
if (registered) {
|
|
2669
|
+
return registered;
|
|
2670
|
+
}
|
|
2671
|
+
if (!this.moduleRef || typeof ref === "string") {
|
|
2672
|
+
return void 0;
|
|
2673
|
+
}
|
|
2674
|
+
try {
|
|
2675
|
+
const resolved = this.moduleRef.get(ref, { strict: false });
|
|
2676
|
+
return isAxisSensorInstance(resolved) ? resolved : void 0;
|
|
2677
|
+
} catch {
|
|
2678
|
+
return void 0;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2512
2681
|
getEffectiveCapsulePolicy(intent, frame) {
|
|
2513
2682
|
const registeredPolicy = this.intentCapsulePolicies.get(intent);
|
|
2514
2683
|
const chainConfig = this.intentChains.get(intent);
|
|
@@ -2824,7 +2993,8 @@ var require_intent_router = __commonJS({
|
|
|
2824
2993
|
(0, common_1.Injectable)(),
|
|
2825
2994
|
__param(0, (0, common_1.Optional)()),
|
|
2826
2995
|
__param(1, (0, common_1.Optional)()),
|
|
2827
|
-
|
|
2996
|
+
__param(2, (0, common_1.Optional)()),
|
|
2997
|
+
__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])
|
|
2828
2998
|
], IntentRouter2);
|
|
2829
2999
|
}
|
|
2830
3000
|
});
|
|
@@ -3463,6 +3633,213 @@ var init_observation_hash = __esm({
|
|
|
3463
3633
|
}
|
|
3464
3634
|
});
|
|
3465
3635
|
|
|
3636
|
+
// src/engine/observation/truth-scoring.ts
|
|
3637
|
+
function scoreTruth(obs, expected) {
|
|
3638
|
+
const anomalies = [];
|
|
3639
|
+
let passedChecks = 0;
|
|
3640
|
+
let totalChecks = 0;
|
|
3641
|
+
totalChecks++;
|
|
3642
|
+
if (obs.endMs && obs.decision) {
|
|
3643
|
+
passedChecks++;
|
|
3644
|
+
} else {
|
|
3645
|
+
anomalies.push({
|
|
3646
|
+
code: "OBS_NOT_FINALIZED",
|
|
3647
|
+
level: "critical",
|
|
3648
|
+
message: "Observation was not finalized"
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
totalChecks++;
|
|
3652
|
+
if (obs.stages.length > 0) {
|
|
3653
|
+
passedChecks++;
|
|
3654
|
+
} else {
|
|
3655
|
+
anomalies.push({
|
|
3656
|
+
code: "OBS_NO_STAGES",
|
|
3657
|
+
level: "warning",
|
|
3658
|
+
message: "Observation has no execution stages"
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
totalChecks++;
|
|
3662
|
+
const failedStages = obs.stages.filter((s) => s.status === "fail");
|
|
3663
|
+
if (failedStages.length === 0 || obs.decision === "DENY") {
|
|
3664
|
+
passedChecks++;
|
|
3665
|
+
} else {
|
|
3666
|
+
for (const stage of failedStages) {
|
|
3667
|
+
anomalies.push({
|
|
3668
|
+
code: "STAGE_FAILED",
|
|
3669
|
+
level: "warning",
|
|
3670
|
+
message: `Stage '${stage.name}' failed: ${stage.reason ?? "unknown"}`,
|
|
3671
|
+
field: `stages.${stage.name}`
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
totalChecks++;
|
|
3676
|
+
const invalidSensors = obs.sensors.filter((s) => s.durationMs < 0);
|
|
3677
|
+
if (invalidSensors.length === 0) {
|
|
3678
|
+
passedChecks++;
|
|
3679
|
+
} else {
|
|
3680
|
+
anomalies.push({
|
|
3681
|
+
code: "SENSOR_INVALID_TIMING",
|
|
3682
|
+
level: "warning",
|
|
3683
|
+
message: `${invalidSensors.length} sensor(s) have negative duration`
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
totalChecks++;
|
|
3687
|
+
if (obs.durationMs !== void 0 && obs.durationMs >= 0 && obs.durationMs < 3e5) {
|
|
3688
|
+
passedChecks++;
|
|
3689
|
+
} else {
|
|
3690
|
+
anomalies.push({
|
|
3691
|
+
code: "OBS_DURATION_ANOMALY",
|
|
3692
|
+
level: "warning",
|
|
3693
|
+
message: `Observation duration ${obs.durationMs}ms is suspicious`,
|
|
3694
|
+
actual: obs.durationMs
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
if (expected) {
|
|
3698
|
+
if (expected.decision !== void 0) {
|
|
3699
|
+
totalChecks++;
|
|
3700
|
+
if (obs.decision === expected.decision) {
|
|
3701
|
+
passedChecks++;
|
|
3702
|
+
} else {
|
|
3703
|
+
anomalies.push({
|
|
3704
|
+
code: "DECISION_MISMATCH",
|
|
3705
|
+
level: "critical",
|
|
3706
|
+
message: `Expected decision '${expected.decision}', got '${obs.decision}'`,
|
|
3707
|
+
field: "decision",
|
|
3708
|
+
expected: expected.decision,
|
|
3709
|
+
actual: obs.decision
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
if (expected.statusCode !== void 0) {
|
|
3714
|
+
totalChecks++;
|
|
3715
|
+
if (obs.statusCode === expected.statusCode) {
|
|
3716
|
+
passedChecks++;
|
|
3717
|
+
} else {
|
|
3718
|
+
anomalies.push({
|
|
3719
|
+
code: "STATUS_MISMATCH",
|
|
3720
|
+
level: "warning",
|
|
3721
|
+
message: `Expected status ${expected.statusCode}, got ${obs.statusCode}`,
|
|
3722
|
+
field: "statusCode",
|
|
3723
|
+
expected: expected.statusCode,
|
|
3724
|
+
actual: obs.statusCode
|
|
3725
|
+
});
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
if (expected.effect !== void 0) {
|
|
3729
|
+
totalChecks++;
|
|
3730
|
+
if (obs.resultCode === expected.effect || obs.facts?.effect === expected.effect) {
|
|
3731
|
+
passedChecks++;
|
|
3732
|
+
} else {
|
|
3733
|
+
anomalies.push({
|
|
3734
|
+
code: "EFFECT_MISMATCH",
|
|
3735
|
+
level: "warning",
|
|
3736
|
+
message: `Expected effect '${expected.effect}', got '${obs.resultCode}'`,
|
|
3737
|
+
field: "resultCode",
|
|
3738
|
+
expected: expected.effect,
|
|
3739
|
+
actual: obs.resultCode
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
if (expected.maxDurationMs !== void 0) {
|
|
3744
|
+
totalChecks++;
|
|
3745
|
+
if (obs.durationMs !== void 0 && obs.durationMs <= expected.maxDurationMs) {
|
|
3746
|
+
passedChecks++;
|
|
3747
|
+
} else {
|
|
3748
|
+
anomalies.push({
|
|
3749
|
+
code: "DURATION_EXCEEDED",
|
|
3750
|
+
level: "warning",
|
|
3751
|
+
message: `Execution took ${obs.durationMs}ms, max allowed ${expected.maxDurationMs}ms`,
|
|
3752
|
+
field: "durationMs",
|
|
3753
|
+
expected: expected.maxDurationMs,
|
|
3754
|
+
actual: obs.durationMs
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
if (expected.minSensorsPassed !== void 0) {
|
|
3759
|
+
totalChecks++;
|
|
3760
|
+
const passed = obs.sensors.filter((s) => s.allowed).length;
|
|
3761
|
+
if (passed >= expected.minSensorsPassed) {
|
|
3762
|
+
passedChecks++;
|
|
3763
|
+
} else {
|
|
3764
|
+
anomalies.push({
|
|
3765
|
+
code: "INSUFFICIENT_SENSORS",
|
|
3766
|
+
level: "warning",
|
|
3767
|
+
message: `Only ${passed} sensors passed, minimum required ${expected.minSensorsPassed}`,
|
|
3768
|
+
field: "sensors",
|
|
3769
|
+
expected: expected.minSensorsPassed,
|
|
3770
|
+
actual: passed
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
if (expected.assertions) {
|
|
3775
|
+
for (const [key, expectedValue] of Object.entries(expected.assertions)) {
|
|
3776
|
+
totalChecks++;
|
|
3777
|
+
const actualValue = obs.facts[key];
|
|
3778
|
+
if (deepEqual(actualValue, expectedValue)) {
|
|
3779
|
+
passedChecks++;
|
|
3780
|
+
} else {
|
|
3781
|
+
anomalies.push({
|
|
3782
|
+
code: "ASSERTION_FAILED",
|
|
3783
|
+
level: "warning",
|
|
3784
|
+
message: `Assertion failed for facts.${key}`,
|
|
3785
|
+
field: `facts.${key}`,
|
|
3786
|
+
expected: expectedValue,
|
|
3787
|
+
actual: actualValue
|
|
3788
|
+
});
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
const confidence = totalChecks > 0 ? passedChecks / totalChecks : 0;
|
|
3794
|
+
const hasCritical = anomalies.some((a) => a.level === "critical");
|
|
3795
|
+
const status = computeTruthStatus(confidence, hasCritical, anomalies.length);
|
|
3796
|
+
const isDeed = status === "confirmed" || status === "partial" && !hasCritical;
|
|
3797
|
+
return {
|
|
3798
|
+
status,
|
|
3799
|
+
confidence,
|
|
3800
|
+
anomalies,
|
|
3801
|
+
passedChecks,
|
|
3802
|
+
totalChecks,
|
|
3803
|
+
verifiedAt: Date.now(),
|
|
3804
|
+
isDeed
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
function computeTruthStatus(confidence, hasCritical, anomalyCount) {
|
|
3808
|
+
if (hasCritical) return "failed";
|
|
3809
|
+
if (confidence === 1) return "confirmed";
|
|
3810
|
+
if (confidence >= 0.8) return "partial";
|
|
3811
|
+
if (confidence >= 0.5) return "uncertain";
|
|
3812
|
+
return "disputed";
|
|
3813
|
+
}
|
|
3814
|
+
function verifyObservation(obs, expected) {
|
|
3815
|
+
const verdict = scoreTruth(obs, expected);
|
|
3816
|
+
return { observation: obs, verdict };
|
|
3817
|
+
}
|
|
3818
|
+
function deepEqual(a, b) {
|
|
3819
|
+
if (a === b) return true;
|
|
3820
|
+
if (a === null || b === null) return false;
|
|
3821
|
+
if (typeof a !== typeof b) return false;
|
|
3822
|
+
if (typeof a !== "object") return String(a) === String(b);
|
|
3823
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
3824
|
+
if (a.length !== b.length) return false;
|
|
3825
|
+
return a.every((v, i) => deepEqual(v, b[i]));
|
|
3826
|
+
}
|
|
3827
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
3828
|
+
const aKeys = Object.keys(a);
|
|
3829
|
+
const bKeys = Object.keys(b);
|
|
3830
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
3831
|
+
return aKeys.every(
|
|
3832
|
+
(key) => deepEqual(
|
|
3833
|
+
a[key],
|
|
3834
|
+
b[key]
|
|
3835
|
+
)
|
|
3836
|
+
);
|
|
3837
|
+
}
|
|
3838
|
+
var init_truth_scoring = __esm({
|
|
3839
|
+
"src/engine/observation/truth-scoring.ts"() {
|
|
3840
|
+
}
|
|
3841
|
+
});
|
|
3842
|
+
|
|
3466
3843
|
// src/engine/observation/response-observer.ts
|
|
3467
3844
|
function verifyResponse(ctx, response) {
|
|
3468
3845
|
if (!response.effect || typeof response.effect !== "string") {
|
|
@@ -3533,97 +3910,15 @@ var init_varint = __esm({
|
|
|
3533
3910
|
var axis_bin_exports = {};
|
|
3534
3911
|
__export(axis_bin_exports, {
|
|
3535
3912
|
AxisFrameZ: () => AxisFrameZ,
|
|
3536
|
-
decodeFrame: () => decodeFrame,
|
|
3537
|
-
encodeFrame: () => encodeFrame,
|
|
3538
|
-
getSignTarget: () => getSignTarget
|
|
3539
|
-
});
|
|
3540
|
-
|
|
3541
|
-
const hdrBytes = (0, import_axis_protocol.encodeTLVs)(
|
|
3542
|
-
Array.from(frame.headers.entries()).map(([t, v]) => ({
|
|
3543
|
-
type: t,
|
|
3544
|
-
value: v
|
|
3545
|
-
}))
|
|
3546
|
-
);
|
|
3547
|
-
if (hdrBytes.length > import_axis_protocol2.MAX_HDR_LEN) throw new Error("Header too large");
|
|
3548
|
-
if (frame.body.length > import_axis_protocol2.MAX_BODY_LEN) throw new Error("Body too large");
|
|
3549
|
-
if (frame.sig.length > import_axis_protocol2.MAX_SIG_LEN) throw new Error("Signature too large");
|
|
3550
|
-
const hdrLenBytes = (0, import_axis_protocol3.encodeVarint)(hdrBytes.length);
|
|
3551
|
-
const bodyLenBytes = (0, import_axis_protocol3.encodeVarint)(frame.body.length);
|
|
3552
|
-
const sigLenBytes = (0, import_axis_protocol3.encodeVarint)(frame.sig.length);
|
|
3553
|
-
const totalLen = 5 + // Magic (AXIS1)
|
|
3554
|
-
1 + // Version
|
|
3555
|
-
1 + // Flags
|
|
3556
|
-
hdrLenBytes.length + bodyLenBytes.length + sigLenBytes.length + hdrBytes.length + frame.body.length + frame.sig.length;
|
|
3557
|
-
if (totalLen > import_axis_protocol2.MAX_FRAME_LEN) throw new Error("Total frame too large");
|
|
3558
|
-
const buf = new Uint8Array(totalLen);
|
|
3559
|
-
let offset = 0;
|
|
3560
|
-
buf.set(import_axis_protocol2.AXIS_MAGIC, offset);
|
|
3561
|
-
offset += 5;
|
|
3562
|
-
buf[offset++] = import_axis_protocol2.AXIS_VERSION;
|
|
3563
|
-
buf[offset++] = frame.flags;
|
|
3564
|
-
buf.set(hdrLenBytes, offset);
|
|
3565
|
-
offset += hdrLenBytes.length;
|
|
3566
|
-
buf.set(bodyLenBytes, offset);
|
|
3567
|
-
offset += bodyLenBytes.length;
|
|
3568
|
-
buf.set(sigLenBytes, offset);
|
|
3569
|
-
offset += sigLenBytes.length;
|
|
3570
|
-
buf.set(hdrBytes, offset);
|
|
3571
|
-
offset += hdrBytes.length;
|
|
3572
|
-
buf.set(frame.body, offset);
|
|
3573
|
-
offset += frame.body.length;
|
|
3574
|
-
buf.set(frame.sig, offset);
|
|
3575
|
-
offset += frame.sig.length;
|
|
3576
|
-
return buf;
|
|
3577
|
-
}
|
|
3578
|
-
function decodeFrame(buf) {
|
|
3579
|
-
let offset = 0;
|
|
3580
|
-
if (offset + 5 > buf.length) throw new Error("Packet too short");
|
|
3581
|
-
for (let i = 0; i < 5; i++) {
|
|
3582
|
-
if (buf[offset + i] !== import_axis_protocol2.AXIS_MAGIC[i]) throw new Error("Invalid Magic");
|
|
3583
|
-
}
|
|
3584
|
-
offset += 5;
|
|
3585
|
-
const ver = buf[offset++];
|
|
3586
|
-
if (ver !== import_axis_protocol2.AXIS_VERSION) throw new Error(`Unsupported version: ${ver}`);
|
|
3587
|
-
const flags = buf[offset++];
|
|
3588
|
-
const { value: hdrLen, length: hlLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
|
|
3589
|
-
offset += hlLen;
|
|
3590
|
-
if (hdrLen > import_axis_protocol2.MAX_HDR_LEN) throw new Error("Header limit exceeded");
|
|
3591
|
-
const { value: bodyLen, length: blLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
|
|
3592
|
-
offset += blLen;
|
|
3593
|
-
if (bodyLen > import_axis_protocol2.MAX_BODY_LEN) throw new Error("Body limit exceeded");
|
|
3594
|
-
const { value: sigLen, length: slLen } = (0, import_axis_protocol3.decodeVarint)(buf, offset);
|
|
3595
|
-
offset += slLen;
|
|
3596
|
-
if (sigLen > import_axis_protocol2.MAX_SIG_LEN) throw new Error("Signature limit exceeded");
|
|
3597
|
-
if (offset + hdrLen + bodyLen + sigLen > buf.length) {
|
|
3598
|
-
throw new Error("Frame truncated");
|
|
3599
|
-
}
|
|
3600
|
-
const hdrBytes = buf.slice(offset, offset + hdrLen);
|
|
3601
|
-
offset += hdrLen;
|
|
3602
|
-
const bodyBytes = buf.slice(offset, offset + bodyLen);
|
|
3603
|
-
offset += bodyLen;
|
|
3604
|
-
const sigBytes = buf.slice(offset, offset + sigLen);
|
|
3605
|
-
offset += sigLen;
|
|
3606
|
-
const headers = (0, import_axis_protocol.decodeTLVs)(hdrBytes);
|
|
3607
|
-
return {
|
|
3608
|
-
flags,
|
|
3609
|
-
headers,
|
|
3610
|
-
body: bodyBytes,
|
|
3611
|
-
sig: sigBytes
|
|
3612
|
-
};
|
|
3613
|
-
}
|
|
3614
|
-
function getSignTarget(frame) {
|
|
3615
|
-
return encodeFrame({
|
|
3616
|
-
...frame,
|
|
3617
|
-
sig: new Uint8Array(0)
|
|
3618
|
-
});
|
|
3619
|
-
}
|
|
3620
|
-
var z, AxisFrameZ;
|
|
3913
|
+
decodeFrame: () => import_axis_protocol4.decodeFrame,
|
|
3914
|
+
encodeFrame: () => import_axis_protocol4.encodeFrame,
|
|
3915
|
+
getSignTarget: () => import_axis_protocol4.getSignTarget
|
|
3916
|
+
});
|
|
3917
|
+
var z, import_axis_protocol4, AxisFrameZ;
|
|
3621
3918
|
var init_axis_bin = __esm({
|
|
3622
3919
|
"src/core/axis-bin.ts"() {
|
|
3623
3920
|
z = __toESM(require("zod"));
|
|
3624
|
-
|
|
3625
|
-
init_tlv();
|
|
3626
|
-
init_varint();
|
|
3921
|
+
import_axis_protocol4 = require("@nextera.one/axis-protocol");
|
|
3627
3922
|
AxisFrameZ = z.object({
|
|
3628
3923
|
/** Flag bits for protocol control (e.g., encryption, compression) */
|
|
3629
3924
|
flags: z.number().int().nonnegative(),
|
|
@@ -3642,12 +3937,7 @@ var init_axis_bin = __esm({
|
|
|
3642
3937
|
|
|
3643
3938
|
// src/core/signature.ts
|
|
3644
3939
|
function computeSignaturePayload(frame) {
|
|
3645
|
-
|
|
3646
|
-
...frame,
|
|
3647
|
-
sig: new Uint8Array(0)
|
|
3648
|
-
};
|
|
3649
|
-
const encoded = encodeFrame(frameWithoutSig);
|
|
3650
|
-
return Buffer.from(encoded);
|
|
3940
|
+
return Buffer.from((0, import_axis_protocol4.getSignTarget)(frame));
|
|
3651
3941
|
}
|
|
3652
3942
|
function signFrame(frame, privateKey) {
|
|
3653
3943
|
const payload = computeSignaturePayload(frame);
|
|
@@ -4535,7 +4825,7 @@ function encodeAxis1Frame(f) {
|
|
|
4535
4825
|
if (!Buffer.isBuffer(f.hdr) || !Buffer.isBuffer(f.body) || !Buffer.isBuffer(f.sig)) {
|
|
4536
4826
|
throw new Error("AXIS1_BAD_BUFFERS");
|
|
4537
4827
|
}
|
|
4538
|
-
if (f.ver !==
|
|
4828
|
+
if (f.ver !== import_axis_protocol5.AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
|
|
4539
4829
|
const hdrLen = encVarint(BigInt(f.hdr.length));
|
|
4540
4830
|
const bodyLen = encVarint(BigInt(f.body.length));
|
|
4541
4831
|
const sigLen = encVarint(BigInt(f.sig.length));
|
|
@@ -4551,17 +4841,18 @@ function encodeAxis1Frame(f) {
|
|
|
4551
4841
|
f.sig
|
|
4552
4842
|
]);
|
|
4553
4843
|
}
|
|
4554
|
-
var MAGIC;
|
|
4844
|
+
var import_axis_protocol5, MAGIC;
|
|
4555
4845
|
var init_axis1_encode = __esm({
|
|
4556
4846
|
"src/codec/axis1.encode.ts"() {
|
|
4847
|
+
import_axis_protocol5 = require("@nextera.one/axis-protocol");
|
|
4557
4848
|
init_tlv_encode();
|
|
4558
|
-
MAGIC = Buffer.from(
|
|
4849
|
+
MAGIC = Buffer.from(import_axis_protocol5.AXIS_MAGIC);
|
|
4559
4850
|
}
|
|
4560
4851
|
});
|
|
4561
4852
|
|
|
4562
4853
|
// src/codec/axis1.signing.ts
|
|
4563
4854
|
function axis1SigningBytes(params) {
|
|
4564
|
-
if (params.ver !==
|
|
4855
|
+
if (params.ver !== import_axis_protocol6.AXIS_VERSION) throw new Error("AXIS1_BAD_VER");
|
|
4565
4856
|
const hdrLen = encVarint(BigInt(params.hdr.length));
|
|
4566
4857
|
const bodyLen = encVarint(BigInt(params.body.length));
|
|
4567
4858
|
const sigLenZero = encVarint(0n);
|
|
@@ -4576,11 +4867,12 @@ function axis1SigningBytes(params) {
|
|
|
4576
4867
|
params.body
|
|
4577
4868
|
]);
|
|
4578
4869
|
}
|
|
4579
|
-
var MAGIC2;
|
|
4870
|
+
var import_axis_protocol6, MAGIC2;
|
|
4580
4871
|
var init_axis1_signing = __esm({
|
|
4581
4872
|
"src/codec/axis1.signing.ts"() {
|
|
4873
|
+
import_axis_protocol6 = require("@nextera.one/axis-protocol");
|
|
4582
4874
|
init_tlv_encode();
|
|
4583
|
-
MAGIC2 = Buffer.from(
|
|
4875
|
+
MAGIC2 = Buffer.from(import_axis_protocol6.AXIS_MAGIC);
|
|
4584
4876
|
}
|
|
4585
4877
|
});
|
|
4586
4878
|
|
|
@@ -4910,11 +5202,12 @@ function decodeAxis1Frame(buf) {
|
|
|
4910
5202
|
if (off !== buf.length) throw new Error("AXIS1_TRAILING_BYTES");
|
|
4911
5203
|
return { ver, flags, hdr, body, sig, frameSize: buf.length };
|
|
4912
5204
|
}
|
|
4913
|
-
var MAGIC3;
|
|
5205
|
+
var import_axis_protocol7, MAGIC3;
|
|
4914
5206
|
var init_frame = __esm({
|
|
4915
5207
|
"src/types/frame.ts"() {
|
|
5208
|
+
import_axis_protocol7 = require("@nextera.one/axis-protocol");
|
|
4916
5209
|
init_tlv2();
|
|
4917
|
-
MAGIC3 = Buffer.from(
|
|
5210
|
+
MAGIC3 = Buffer.from(import_axis_protocol7.AXIS_MAGIC);
|
|
4918
5211
|
}
|
|
4919
5212
|
});
|
|
4920
5213
|
|
|
@@ -5037,7 +5330,52 @@ var init_capabilities = __esm({
|
|
|
5037
5330
|
}
|
|
5038
5331
|
});
|
|
5039
5332
|
|
|
5333
|
+
// src/law/law.types.ts
|
|
5334
|
+
function buildAxisLawEvaluationContext(input) {
|
|
5335
|
+
const metadata = input.metadata ?? {};
|
|
5336
|
+
const packet = input.packet;
|
|
5337
|
+
const packetBody = input.frameBody ?? packet?.body ?? packet?.args ?? void 0;
|
|
5338
|
+
const capsuleId = metadata.capsule_id ?? metadata.capsuleId ?? packet?.capsuleId ?? input.clientId;
|
|
5339
|
+
const audience = input.aud ?? metadata.audience ?? packet?.aud;
|
|
5340
|
+
const tps = metadata.tps ?? packet?.tps ?? packet?.tickTps;
|
|
5341
|
+
return {
|
|
5342
|
+
actorId: input.actorId,
|
|
5343
|
+
intent: input.intent,
|
|
5344
|
+
audience,
|
|
5345
|
+
tps,
|
|
5346
|
+
country: input.country,
|
|
5347
|
+
ip: input.ip,
|
|
5348
|
+
path: input.path,
|
|
5349
|
+
clientId: input.clientId,
|
|
5350
|
+
deviceId: input.deviceId,
|
|
5351
|
+
sessionId: input.sessionId,
|
|
5352
|
+
capsuleId,
|
|
5353
|
+
metadata,
|
|
5354
|
+
packet,
|
|
5355
|
+
frameBody: packetBody
|
|
5356
|
+
};
|
|
5357
|
+
}
|
|
5358
|
+
var init_law_types = __esm({
|
|
5359
|
+
"src/law/law.types.ts"() {
|
|
5360
|
+
}
|
|
5361
|
+
});
|
|
5362
|
+
|
|
5363
|
+
// src/law/index.ts
|
|
5364
|
+
var law_exports = {};
|
|
5365
|
+
__export(law_exports, {
|
|
5366
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext
|
|
5367
|
+
});
|
|
5368
|
+
var init_law = __esm({
|
|
5369
|
+
"src/law/index.ts"() {
|
|
5370
|
+
init_law_types();
|
|
5371
|
+
}
|
|
5372
|
+
});
|
|
5373
|
+
|
|
5040
5374
|
// src/risk/index.ts
|
|
5375
|
+
var risk_exports = {};
|
|
5376
|
+
__export(risk_exports, {
|
|
5377
|
+
RiskDecision: () => RiskDecision
|
|
5378
|
+
});
|
|
5041
5379
|
var RiskDecision;
|
|
5042
5380
|
var init_risk = __esm({
|
|
5043
5381
|
"src/risk/index.ts"() {
|
|
@@ -5781,9 +6119,9 @@ var require_handler_discovery_service = __commonJS({
|
|
|
5781
6119
|
}
|
|
5782
6120
|
});
|
|
5783
6121
|
|
|
5784
|
-
// src/engine/
|
|
5785
|
-
var
|
|
5786
|
-
"src/engine/
|
|
6122
|
+
// src/engine/sensor-discovery.service.ts
|
|
6123
|
+
var require_sensor_discovery_service = __commonJS({
|
|
6124
|
+
"src/engine/sensor-discovery.service.ts"(exports2) {
|
|
5787
6125
|
"use strict";
|
|
5788
6126
|
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
5789
6127
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5794,103 +6132,12 @@ var require_sensor_registry = __commonJS({
|
|
|
5794
6132
|
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
5795
6133
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5796
6134
|
};
|
|
5797
|
-
var
|
|
6135
|
+
var SensorDiscoveryService_1;
|
|
5798
6136
|
var _a;
|
|
6137
|
+
var _b;
|
|
6138
|
+
var _c;
|
|
5799
6139
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5800
|
-
exports2.
|
|
5801
|
-
var common_1 = require("@nestjs/common");
|
|
5802
|
-
var config_1 = require("@nestjs/config");
|
|
5803
|
-
var SensorRegistry2 = SensorRegistry_1 = class SensorRegistry {
|
|
5804
|
-
constructor(configService) {
|
|
5805
|
-
this.configService = configService;
|
|
5806
|
-
this.sensors = [];
|
|
5807
|
-
this.logger = new common_1.Logger(SensorRegistry_1.name);
|
|
5808
|
-
}
|
|
5809
|
-
register(sensor) {
|
|
5810
|
-
if (!sensor.name) {
|
|
5811
|
-
throw new Error("AxisSensor must have a name");
|
|
5812
|
-
}
|
|
5813
|
-
const enabledSensorsStr = this.configService.get("ENABLED_SENSORS");
|
|
5814
|
-
const disabledSensorsStr = this.configService.get("DISABLED_SENSORS");
|
|
5815
|
-
const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
|
|
5816
|
-
const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
|
|
5817
|
-
if (enabledSensors && !enabledSensors.includes(sensor.name)) {
|
|
5818
|
-
this.logger.log(`Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`);
|
|
5819
|
-
return;
|
|
5820
|
-
}
|
|
5821
|
-
if (disabledSensors.includes(sensor.name)) {
|
|
5822
|
-
this.logger.log(`Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`);
|
|
5823
|
-
return;
|
|
5824
|
-
}
|
|
5825
|
-
if (sensor.order === void 0) {
|
|
5826
|
-
throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
|
|
5827
|
-
}
|
|
5828
|
-
const isPreDecodeSensor = this.isPreDecodeSensor(sensor);
|
|
5829
|
-
const isPostDecodeSensor = this.isPostDecodeSensor(sensor);
|
|
5830
|
-
if (isPreDecodeSensor && sensor.order >= 40) {
|
|
5831
|
-
this.logger.warn(`AxisSensor "${sensor.name}" is marked as PRE_DECODE but has order ${sensor.order} (should be < 40)`);
|
|
5832
|
-
}
|
|
5833
|
-
if (isPostDecodeSensor && sensor.order < 40) {
|
|
5834
|
-
this.logger.warn(`AxisSensor "${sensor.name}" is marked as POST_DECODE but has order ${sensor.order} (should be >= 40)`);
|
|
5835
|
-
}
|
|
5836
|
-
this.sensors.push(sensor);
|
|
5837
|
-
const phaseLabel = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase || "UNKNOWN";
|
|
5838
|
-
this.logger.debug(`Registered sensor: ${sensor.name} (order: ${sensor.order}, phase: ${phaseLabel})`);
|
|
5839
|
-
}
|
|
5840
|
-
list() {
|
|
5841
|
-
return [...this.sensors].sort((a, b) => (a.order ?? 999) - (b.order ?? 999));
|
|
5842
|
-
}
|
|
5843
|
-
getPreDecodeSensors() {
|
|
5844
|
-
return this.list().filter((s) => (s.order ?? 999) < 40);
|
|
5845
|
-
}
|
|
5846
|
-
getPostDecodeSensors() {
|
|
5847
|
-
return this.list().filter((s) => (s.order ?? 999) >= 40);
|
|
5848
|
-
}
|
|
5849
|
-
isPreDecodeSensor(sensor) {
|
|
5850
|
-
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
5851
|
-
return phase === "PRE_DECODE" || (sensor.order ?? 999) < 40;
|
|
5852
|
-
}
|
|
5853
|
-
isPostDecodeSensor(sensor) {
|
|
5854
|
-
const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
|
|
5855
|
-
return phase === "POST_DECODE" || (sensor.order ?? 999) >= 40;
|
|
5856
|
-
}
|
|
5857
|
-
getSensorCountByPhase() {
|
|
5858
|
-
return {
|
|
5859
|
-
preDecodeCount: this.getPreDecodeSensors().length,
|
|
5860
|
-
postDecodeCount: this.getPostDecodeSensors().length
|
|
5861
|
-
};
|
|
5862
|
-
}
|
|
5863
|
-
clear() {
|
|
5864
|
-
this.sensors = [];
|
|
5865
|
-
}
|
|
5866
|
-
};
|
|
5867
|
-
exports2.SensorRegistry = SensorRegistry2;
|
|
5868
|
-
exports2.SensorRegistry = SensorRegistry2 = SensorRegistry_1 = __decorate([
|
|
5869
|
-
(0, common_1.Injectable)(),
|
|
5870
|
-
__metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
|
|
5871
|
-
], SensorRegistry2);
|
|
5872
|
-
}
|
|
5873
|
-
});
|
|
5874
|
-
|
|
5875
|
-
// src/engine/sensor-discovery.service.ts
|
|
5876
|
-
var require_sensor_discovery_service = __commonJS({
|
|
5877
|
-
"src/engine/sensor-discovery.service.ts"(exports2) {
|
|
5878
|
-
"use strict";
|
|
5879
|
-
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
5880
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5881
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5882
|
-
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;
|
|
5883
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5884
|
-
};
|
|
5885
|
-
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
5886
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5887
|
-
};
|
|
5888
|
-
var SensorDiscoveryService_1;
|
|
5889
|
-
var _a;
|
|
5890
|
-
var _b;
|
|
5891
|
-
var _c;
|
|
5892
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5893
|
-
exports2.SensorDiscoveryService = void 0;
|
|
6140
|
+
exports2.SensorDiscoveryService = void 0;
|
|
5894
6141
|
var common_1 = require("@nestjs/common");
|
|
5895
6142
|
var core_1 = require("@nestjs/core");
|
|
5896
6143
|
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
@@ -6110,6 +6357,374 @@ var require_axis_sensor_chain_service = __commonJS({
|
|
|
6110
6357
|
}
|
|
6111
6358
|
});
|
|
6112
6359
|
|
|
6360
|
+
// src/timeline/timeline.engine.ts
|
|
6361
|
+
function generateId(prefix) {
|
|
6362
|
+
return `${prefix}_${(0, import_crypto8.randomBytes)(16).toString("hex")}`;
|
|
6363
|
+
}
|
|
6364
|
+
function sha2566(data) {
|
|
6365
|
+
return (0, import_crypto8.createHash)("sha256").update(data).digest("hex");
|
|
6366
|
+
}
|
|
6367
|
+
function hashPayload2(payload) {
|
|
6368
|
+
return sha2566(JSON.stringify(payload));
|
|
6369
|
+
}
|
|
6370
|
+
function diffObjects(a, b) {
|
|
6371
|
+
const diffs = [];
|
|
6372
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
6373
|
+
for (const key of allKeys) {
|
|
6374
|
+
const va = a[key];
|
|
6375
|
+
const vb = b[key];
|
|
6376
|
+
if (JSON.stringify(va) !== JSON.stringify(vb)) {
|
|
6377
|
+
diffs.push({ field: key, original: va, replayed: vb });
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
return diffs;
|
|
6381
|
+
}
|
|
6382
|
+
var import_crypto8, TimelineEngine;
|
|
6383
|
+
var init_timeline_engine = __esm({
|
|
6384
|
+
"src/timeline/timeline.engine.ts"() {
|
|
6385
|
+
import_crypto8 = require("crypto");
|
|
6386
|
+
TimelineEngine = class {
|
|
6387
|
+
constructor(store) {
|
|
6388
|
+
this.store = store;
|
|
6389
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
6390
|
+
}
|
|
6391
|
+
/** Register an intent handler for timeline execution */
|
|
6392
|
+
registerHandler(handler) {
|
|
6393
|
+
this.handlers.set(handler.intent, handler);
|
|
6394
|
+
}
|
|
6395
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6396
|
+
// Record (store a real execution as a timeline event)
|
|
6397
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6398
|
+
async recordEvent(intent, actorId, payload, result, options = {}) {
|
|
6399
|
+
const event = {
|
|
6400
|
+
event_id: generateId("evt"),
|
|
6401
|
+
timeline_id: options.timelineId ?? "prime",
|
|
6402
|
+
branch_id: options.branchId ?? "main",
|
|
6403
|
+
parent_event_id: options.parentEventId ?? null,
|
|
6404
|
+
intent,
|
|
6405
|
+
actor_id: actorId,
|
|
6406
|
+
capsule_id: options.capsuleId,
|
|
6407
|
+
tps_coordinate: options.tpsCoordinate,
|
|
6408
|
+
payload_hash: hashPayload2(payload),
|
|
6409
|
+
result_hash: hashPayload2(result),
|
|
6410
|
+
status: "executed",
|
|
6411
|
+
domain: "prime",
|
|
6412
|
+
determinism: options.determinism ?? "deterministic",
|
|
6413
|
+
witness_id: options.witnessId,
|
|
6414
|
+
created_at: Date.now(),
|
|
6415
|
+
metadata: { payload, result }
|
|
6416
|
+
};
|
|
6417
|
+
await this.store.saveEvent(event);
|
|
6418
|
+
return event;
|
|
6419
|
+
}
|
|
6420
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6421
|
+
// Replay
|
|
6422
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6423
|
+
async replay(request) {
|
|
6424
|
+
const originalEvent = await this.store.getEvent(request.source_event_id);
|
|
6425
|
+
if (!originalEvent) {
|
|
6426
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6427
|
+
}
|
|
6428
|
+
const handler = this.handlers.get(originalEvent.intent);
|
|
6429
|
+
if (!handler) {
|
|
6430
|
+
throw new Error(`No handler registered for intent '${originalEvent.intent}'`);
|
|
6431
|
+
}
|
|
6432
|
+
const originalPayload = originalEvent.metadata?.payload ?? {};
|
|
6433
|
+
const replayPayload = request.mode === "analytical" && request.override_payload ? request.override_payload : originalPayload;
|
|
6434
|
+
const snapshot = await this.store.getSnapshotByEvent(originalEvent.event_id);
|
|
6435
|
+
const context = {
|
|
6436
|
+
event_id: generateId("evt"),
|
|
6437
|
+
timeline_id: originalEvent.timeline_id,
|
|
6438
|
+
branch_id: `replay_${originalEvent.branch_id}`,
|
|
6439
|
+
domain: "audit",
|
|
6440
|
+
actor_id: originalEvent.actor_id,
|
|
6441
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6442
|
+
snapshot: snapshot ?? void 0,
|
|
6443
|
+
is_replay: true,
|
|
6444
|
+
is_simulation: false
|
|
6445
|
+
};
|
|
6446
|
+
const startMs = Date.now();
|
|
6447
|
+
const handlerResult = await handler.execute(replayPayload, context);
|
|
6448
|
+
const durationMs = Date.now() - startMs;
|
|
6449
|
+
const replayedEvent = {
|
|
6450
|
+
event_id: context.event_id,
|
|
6451
|
+
timeline_id: originalEvent.timeline_id,
|
|
6452
|
+
branch_id: context.branch_id,
|
|
6453
|
+
parent_event_id: originalEvent.event_id,
|
|
6454
|
+
intent: originalEvent.intent,
|
|
6455
|
+
actor_id: originalEvent.actor_id,
|
|
6456
|
+
capsule_id: originalEvent.capsule_id,
|
|
6457
|
+
tps_coordinate: originalEvent.tps_coordinate,
|
|
6458
|
+
payload_hash: hashPayload2(replayPayload),
|
|
6459
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6460
|
+
status: "replayed",
|
|
6461
|
+
domain: "audit",
|
|
6462
|
+
determinism: originalEvent.determinism,
|
|
6463
|
+
created_at: Date.now(),
|
|
6464
|
+
metadata: { payload: replayPayload, result: handlerResult.result_data }
|
|
6465
|
+
};
|
|
6466
|
+
await this.store.saveEvent(replayedEvent);
|
|
6467
|
+
const originalResult = originalEvent.metadata?.result ?? {};
|
|
6468
|
+
const differences = diffObjects(originalResult, handlerResult.result_data);
|
|
6469
|
+
const deterministicMatch = originalEvent.result_hash === replayedEvent.result_hash;
|
|
6470
|
+
return {
|
|
6471
|
+
original_event: originalEvent,
|
|
6472
|
+
replayed_event: replayedEvent,
|
|
6473
|
+
mode: request.mode,
|
|
6474
|
+
deterministic_match: deterministicMatch,
|
|
6475
|
+
differences,
|
|
6476
|
+
duration_ms: durationMs
|
|
6477
|
+
};
|
|
6478
|
+
}
|
|
6479
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6480
|
+
// Fork
|
|
6481
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6482
|
+
async fork(request) {
|
|
6483
|
+
const sourceEvent = await this.store.getEvent(request.source_event_id);
|
|
6484
|
+
if (!sourceEvent) {
|
|
6485
|
+
throw new Error(`Event ${request.source_event_id} not found`);
|
|
6486
|
+
}
|
|
6487
|
+
const handler = this.handlers.get(sourceEvent.intent);
|
|
6488
|
+
if (!handler) {
|
|
6489
|
+
throw new Error(`No handler registered for intent '${sourceEvent.intent}'`);
|
|
6490
|
+
}
|
|
6491
|
+
const branch = {
|
|
6492
|
+
branch_id: generateId("branch"),
|
|
6493
|
+
timeline_id: generateId("timeline"),
|
|
6494
|
+
origin_timeline_id: sourceEvent.timeline_id,
|
|
6495
|
+
origin_event_id: sourceEvent.event_id,
|
|
6496
|
+
branch_type: "fork",
|
|
6497
|
+
creator_subject_id: request.actor_id,
|
|
6498
|
+
purpose: request.purpose,
|
|
6499
|
+
status: "active"
|
|
6500
|
+
};
|
|
6501
|
+
await this.store.saveBranch(branch);
|
|
6502
|
+
const snapshot = {
|
|
6503
|
+
snapshot_id: generateId("snap"),
|
|
6504
|
+
timeline_id: sourceEvent.timeline_id,
|
|
6505
|
+
event_id: sourceEvent.event_id,
|
|
6506
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6507
|
+
state_hash: hashPayload2(
|
|
6508
|
+
sourceEvent.metadata?.result ?? {}
|
|
6509
|
+
),
|
|
6510
|
+
state_data: sourceEvent.metadata?.result ?? {},
|
|
6511
|
+
created_at: Date.now()
|
|
6512
|
+
};
|
|
6513
|
+
await this.store.saveSnapshot(snapshot);
|
|
6514
|
+
const context = {
|
|
6515
|
+
event_id: generateId("evt"),
|
|
6516
|
+
timeline_id: branch.timeline_id,
|
|
6517
|
+
branch_id: branch.branch_id,
|
|
6518
|
+
domain: "fork",
|
|
6519
|
+
actor_id: request.actor_id,
|
|
6520
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6521
|
+
snapshot,
|
|
6522
|
+
is_replay: false,
|
|
6523
|
+
is_simulation: false
|
|
6524
|
+
};
|
|
6525
|
+
const handlerResult = await handler.execute(request.new_payload, context);
|
|
6526
|
+
const forkedEvent = {
|
|
6527
|
+
event_id: context.event_id,
|
|
6528
|
+
timeline_id: branch.timeline_id,
|
|
6529
|
+
branch_id: branch.branch_id,
|
|
6530
|
+
parent_event_id: sourceEvent.event_id,
|
|
6531
|
+
intent: sourceEvent.intent,
|
|
6532
|
+
actor_id: request.actor_id,
|
|
6533
|
+
tps_coordinate: sourceEvent.tps_coordinate,
|
|
6534
|
+
payload_hash: hashPayload2(request.new_payload),
|
|
6535
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6536
|
+
status: "forked",
|
|
6537
|
+
domain: "fork",
|
|
6538
|
+
determinism: sourceEvent.determinism,
|
|
6539
|
+
created_at: Date.now(),
|
|
6540
|
+
metadata: {
|
|
6541
|
+
payload: request.new_payload,
|
|
6542
|
+
result: handlerResult.result_data
|
|
6543
|
+
}
|
|
6544
|
+
};
|
|
6545
|
+
await this.store.saveEvent(forkedEvent);
|
|
6546
|
+
return { branch, forked_event: forkedEvent, snapshot };
|
|
6547
|
+
}
|
|
6548
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6549
|
+
// Simulate
|
|
6550
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6551
|
+
async simulate(request) {
|
|
6552
|
+
const handler = this.handlers.get(request.intent);
|
|
6553
|
+
if (!handler) {
|
|
6554
|
+
throw new Error(`No handler registered for intent '${request.intent}'`);
|
|
6555
|
+
}
|
|
6556
|
+
let snapshot;
|
|
6557
|
+
if (request.from_snapshot_id) {
|
|
6558
|
+
const loaded = await this.store.getSnapshot(request.from_snapshot_id);
|
|
6559
|
+
if (!loaded) {
|
|
6560
|
+
throw new Error(`Snapshot ${request.from_snapshot_id} not found`);
|
|
6561
|
+
}
|
|
6562
|
+
snapshot = loaded;
|
|
6563
|
+
}
|
|
6564
|
+
const branch = {
|
|
6565
|
+
branch_id: generateId("branch"),
|
|
6566
|
+
timeline_id: generateId("timeline"),
|
|
6567
|
+
origin_timeline_id: "prime",
|
|
6568
|
+
origin_event_id: "simulation_origin",
|
|
6569
|
+
branch_type: "simulation",
|
|
6570
|
+
created_at_tps: request.at_tps,
|
|
6571
|
+
creator_subject_id: request.actor_id,
|
|
6572
|
+
purpose: request.purpose,
|
|
6573
|
+
status: "active"
|
|
6574
|
+
};
|
|
6575
|
+
await this.store.saveBranch(branch);
|
|
6576
|
+
const context = {
|
|
6577
|
+
event_id: generateId("evt"),
|
|
6578
|
+
timeline_id: branch.timeline_id,
|
|
6579
|
+
branch_id: branch.branch_id,
|
|
6580
|
+
domain: "shadow",
|
|
6581
|
+
actor_id: request.actor_id,
|
|
6582
|
+
tps_coordinate: request.at_tps,
|
|
6583
|
+
snapshot,
|
|
6584
|
+
is_replay: false,
|
|
6585
|
+
is_simulation: true
|
|
6586
|
+
};
|
|
6587
|
+
const startMs = Date.now();
|
|
6588
|
+
const handlerResult = await handler.execute(request.payload, context);
|
|
6589
|
+
const durationMs = Date.now() - startMs;
|
|
6590
|
+
const simulatedEvent = {
|
|
6591
|
+
event_id: context.event_id,
|
|
6592
|
+
timeline_id: branch.timeline_id,
|
|
6593
|
+
branch_id: branch.branch_id,
|
|
6594
|
+
parent_event_id: null,
|
|
6595
|
+
intent: request.intent,
|
|
6596
|
+
actor_id: request.actor_id,
|
|
6597
|
+
tps_coordinate: request.at_tps,
|
|
6598
|
+
payload_hash: hashPayload2(request.payload),
|
|
6599
|
+
result_hash: hashPayload2(handlerResult.result_data),
|
|
6600
|
+
status: "simulated",
|
|
6601
|
+
domain: "shadow",
|
|
6602
|
+
determinism: "bounded_nondeterministic",
|
|
6603
|
+
created_at: Date.now(),
|
|
6604
|
+
metadata: { payload: request.payload, result: handlerResult.result_data }
|
|
6605
|
+
};
|
|
6606
|
+
await this.store.saveEvent(simulatedEvent);
|
|
6607
|
+
branch.status = "completed";
|
|
6608
|
+
await this.store.saveBranch(branch);
|
|
6609
|
+
return {
|
|
6610
|
+
branch,
|
|
6611
|
+
simulated_event: simulatedEvent,
|
|
6612
|
+
predicted_outcome: handlerResult.result_data,
|
|
6613
|
+
side_effects: handlerResult.side_effects ?? [],
|
|
6614
|
+
duration_ms: durationMs
|
|
6615
|
+
};
|
|
6616
|
+
}
|
|
6617
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6618
|
+
// Compare timelines
|
|
6619
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6620
|
+
async compare(timelineIdA, timelineIdB) {
|
|
6621
|
+
const eventsA = await this.store.getEventsByTimeline(timelineIdA);
|
|
6622
|
+
const eventsB = await this.store.getEventsByTimeline(timelineIdB);
|
|
6623
|
+
eventsA.sort((a, b) => a.created_at - b.created_at);
|
|
6624
|
+
eventsB.sort((a, b) => a.created_at - b.created_at);
|
|
6625
|
+
const maxLen = Math.max(eventsA.length, eventsB.length);
|
|
6626
|
+
const eventPairs = [];
|
|
6627
|
+
let divergencePoint;
|
|
6628
|
+
for (let i = 0; i < maxLen; i++) {
|
|
6629
|
+
const a = eventsA[i];
|
|
6630
|
+
const b = eventsB[i];
|
|
6631
|
+
if (!a || !b) {
|
|
6632
|
+
if (!divergencePoint) {
|
|
6633
|
+
divergencePoint = a?.event_id ?? b?.event_id;
|
|
6634
|
+
}
|
|
6635
|
+
continue;
|
|
6636
|
+
}
|
|
6637
|
+
const match = a.result_hash === b.result_hash;
|
|
6638
|
+
const resultA = a.metadata?.result ?? {};
|
|
6639
|
+
const resultB = b.metadata?.result ?? {};
|
|
6640
|
+
const differences = match ? [] : diffObjects(resultA, resultB);
|
|
6641
|
+
if (!match && !divergencePoint) {
|
|
6642
|
+
divergencePoint = a.event_id;
|
|
6643
|
+
}
|
|
6644
|
+
eventPairs.push({ event_a: a, event_b: b, match, differences });
|
|
6645
|
+
}
|
|
6646
|
+
return {
|
|
6647
|
+
timeline_a: timelineIdA,
|
|
6648
|
+
timeline_b: timelineIdB,
|
|
6649
|
+
event_pairs: eventPairs,
|
|
6650
|
+
divergence_point: divergencePoint
|
|
6651
|
+
};
|
|
6652
|
+
}
|
|
6653
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6654
|
+
// State snapshot management
|
|
6655
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
6656
|
+
async createSnapshot(eventId, stateData) {
|
|
6657
|
+
const event = await this.store.getEvent(eventId);
|
|
6658
|
+
if (!event) {
|
|
6659
|
+
throw new Error(`Event ${eventId} not found`);
|
|
6660
|
+
}
|
|
6661
|
+
const snapshot = {
|
|
6662
|
+
snapshot_id: generateId("snap"),
|
|
6663
|
+
timeline_id: event.timeline_id,
|
|
6664
|
+
event_id: eventId,
|
|
6665
|
+
tps_coordinate: event.tps_coordinate,
|
|
6666
|
+
state_hash: hashPayload2(stateData),
|
|
6667
|
+
state_data: stateData,
|
|
6668
|
+
created_at: Date.now()
|
|
6669
|
+
};
|
|
6670
|
+
await this.store.saveSnapshot(snapshot);
|
|
6671
|
+
return snapshot;
|
|
6672
|
+
}
|
|
6673
|
+
async restoreSnapshot(snapshotId) {
|
|
6674
|
+
const snapshot = await this.store.getSnapshot(snapshotId);
|
|
6675
|
+
if (!snapshot) {
|
|
6676
|
+
throw new Error(`Snapshot ${snapshotId} not found`);
|
|
6677
|
+
}
|
|
6678
|
+
return snapshot;
|
|
6679
|
+
}
|
|
6680
|
+
};
|
|
6681
|
+
}
|
|
6682
|
+
});
|
|
6683
|
+
|
|
6684
|
+
// src/timeline/timeline.store.ts
|
|
6685
|
+
var InMemoryTimelineStore;
|
|
6686
|
+
var init_timeline_store = __esm({
|
|
6687
|
+
"src/timeline/timeline.store.ts"() {
|
|
6688
|
+
InMemoryTimelineStore = class {
|
|
6689
|
+
constructor() {
|
|
6690
|
+
this.events = /* @__PURE__ */ new Map();
|
|
6691
|
+
this.branches = /* @__PURE__ */ new Map();
|
|
6692
|
+
this.snapshots = /* @__PURE__ */ new Map();
|
|
6693
|
+
}
|
|
6694
|
+
async saveEvent(event) {
|
|
6695
|
+
this.events.set(event.event_id, event);
|
|
6696
|
+
}
|
|
6697
|
+
async getEvent(eventId) {
|
|
6698
|
+
return this.events.get(eventId) ?? null;
|
|
6699
|
+
}
|
|
6700
|
+
async getEventsByTimeline(timelineId) {
|
|
6701
|
+
return [...this.events.values()].filter((e) => e.timeline_id === timelineId);
|
|
6702
|
+
}
|
|
6703
|
+
async getEventsByBranch(branchId) {
|
|
6704
|
+
return [...this.events.values()].filter((e) => e.branch_id === branchId);
|
|
6705
|
+
}
|
|
6706
|
+
async saveBranch(branch) {
|
|
6707
|
+
this.branches.set(branch.branch_id, branch);
|
|
6708
|
+
}
|
|
6709
|
+
async getBranch(branchId) {
|
|
6710
|
+
return this.branches.get(branchId) ?? null;
|
|
6711
|
+
}
|
|
6712
|
+
async getBranchesByTimeline(timelineId) {
|
|
6713
|
+
return [...this.branches.values()].filter((b) => b.timeline_id === timelineId);
|
|
6714
|
+
}
|
|
6715
|
+
async saveSnapshot(snapshot) {
|
|
6716
|
+
this.snapshots.set(snapshot.snapshot_id, snapshot);
|
|
6717
|
+
}
|
|
6718
|
+
async getSnapshot(snapshotId) {
|
|
6719
|
+
return this.snapshots.get(snapshotId) ?? null;
|
|
6720
|
+
}
|
|
6721
|
+
async getSnapshotByEvent(eventId) {
|
|
6722
|
+
return [...this.snapshots.values()].find((s) => s.event_id === eventId) ?? null;
|
|
6723
|
+
}
|
|
6724
|
+
};
|
|
6725
|
+
}
|
|
6726
|
+
});
|
|
6727
|
+
|
|
6113
6728
|
// src/utils/axis-tlv-codec.ts
|
|
6114
6729
|
function encodeAxisTlvDto(dtoClass, data) {
|
|
6115
6730
|
const schema = (0, import_dto_schema.extractDtoSchema)(dtoClass);
|
|
@@ -6168,37 +6783,1752 @@ var init_axis_tlv_codec = __esm({
|
|
|
6168
6783
|
}
|
|
6169
6784
|
});
|
|
6170
6785
|
|
|
6171
|
-
// src/loom/loom.types.ts
|
|
6172
|
-
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
6173
|
-
return `ar:${context}:${scope}:${softid}`;
|
|
6174
|
-
}
|
|
6175
|
-
function canonicalizeWrit(writ) {
|
|
6176
|
-
const ordered = {
|
|
6177
|
-
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
6178
|
-
body: {
|
|
6179
|
-
who: writ.body.who,
|
|
6180
|
-
act: writ.body.act,
|
|
6181
|
-
res: writ.body.res,
|
|
6182
|
-
law: writ.body.law
|
|
6183
|
-
},
|
|
6184
|
-
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
6185
|
-
};
|
|
6186
|
-
return JSON.stringify(ordered);
|
|
6187
|
-
}
|
|
6188
|
-
function canonicalizeGrant(grant) {
|
|
6189
|
-
const ordered = {
|
|
6190
|
-
grant_id: grant.grant_id,
|
|
6191
|
-
issuer: grant.issuer,
|
|
6192
|
-
subject: grant.subject,
|
|
6193
|
-
grant_type: grant.grant_type,
|
|
6194
|
-
caps: grant.caps,
|
|
6195
|
-
meta: grant.meta
|
|
6196
|
-
};
|
|
6197
|
-
return JSON.stringify(ordered);
|
|
6198
|
-
}
|
|
6199
|
-
var init_loom_types = __esm({
|
|
6200
|
-
"src/loom/loom.types.ts"() {
|
|
6201
|
-
init_constants();
|
|
6786
|
+
// src/loom/loom.types.ts
|
|
6787
|
+
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
6788
|
+
return `ar:${context}:${scope}:${softid}`;
|
|
6789
|
+
}
|
|
6790
|
+
function canonicalizeWrit(writ) {
|
|
6791
|
+
const ordered = {
|
|
6792
|
+
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
6793
|
+
body: {
|
|
6794
|
+
who: writ.body.who,
|
|
6795
|
+
act: writ.body.act,
|
|
6796
|
+
res: writ.body.res,
|
|
6797
|
+
law: writ.body.law
|
|
6798
|
+
},
|
|
6799
|
+
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
6800
|
+
};
|
|
6801
|
+
return JSON.stringify(ordered);
|
|
6802
|
+
}
|
|
6803
|
+
function canonicalizeGrant(grant) {
|
|
6804
|
+
const ordered = {
|
|
6805
|
+
grant_id: grant.grant_id,
|
|
6806
|
+
issuer: grant.issuer,
|
|
6807
|
+
subject: grant.subject,
|
|
6808
|
+
grant_type: grant.grant_type,
|
|
6809
|
+
caps: grant.caps,
|
|
6810
|
+
meta: grant.meta
|
|
6811
|
+
};
|
|
6812
|
+
return JSON.stringify(ordered);
|
|
6813
|
+
}
|
|
6814
|
+
var init_loom_types = __esm({
|
|
6815
|
+
"src/loom/loom.types.ts"() {
|
|
6816
|
+
init_constants();
|
|
6817
|
+
}
|
|
6818
|
+
});
|
|
6819
|
+
|
|
6820
|
+
// src/loom/loom.engine.ts
|
|
6821
|
+
function sha2567(data) {
|
|
6822
|
+
return (0, import_crypto9.createHash)("sha256").update(data).digest("hex");
|
|
6823
|
+
}
|
|
6824
|
+
function hexToUint8(hex) {
|
|
6825
|
+
const bytes2 = new Uint8Array(hex.length / 2);
|
|
6826
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
6827
|
+
bytes2[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
6828
|
+
}
|
|
6829
|
+
return bytes2;
|
|
6830
|
+
}
|
|
6831
|
+
function uint8ToHex(bytes2) {
|
|
6832
|
+
return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6833
|
+
}
|
|
6834
|
+
function b64ToUint8(b64) {
|
|
6835
|
+
const bin = Buffer.from(b64, "base64");
|
|
6836
|
+
return new Uint8Array(bin.buffer, bin.byteOffset, bin.byteLength);
|
|
6837
|
+
}
|
|
6838
|
+
function uint8ToB64(bytes2) {
|
|
6839
|
+
return Buffer.from(bytes2).toString("base64");
|
|
6840
|
+
}
|
|
6841
|
+
function createPresenceChallenge(declaration, ttlMs = DEFAULT_PRESENCE_TTL_MS) {
|
|
6842
|
+
const now = Date.now();
|
|
6843
|
+
const nonce = (0, import_crypto9.randomBytes)(32).toString("hex");
|
|
6844
|
+
const challengeId = sha2567(`${declaration.softid}:${nonce}:${now}`);
|
|
6845
|
+
return {
|
|
6846
|
+
challenge_id: challengeId,
|
|
6847
|
+
nonce,
|
|
6848
|
+
temporal_anchor: now,
|
|
6849
|
+
ttl_ms: ttlMs,
|
|
6850
|
+
expires_at: now + ttlMs
|
|
6851
|
+
};
|
|
6852
|
+
}
|
|
6853
|
+
function presenceSigningData(challenge, deviceMeta) {
|
|
6854
|
+
return JSON.stringify({
|
|
6855
|
+
nonce: challenge.nonce,
|
|
6856
|
+
temporal_anchor: challenge.temporal_anchor,
|
|
6857
|
+
device_meta: deviceMeta ?? null
|
|
6858
|
+
});
|
|
6859
|
+
}
|
|
6860
|
+
function signPresenceChallenge(challenge, privateKeyHex, publicKeyHex, declaration, kid) {
|
|
6861
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6862
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6863
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6864
|
+
const signature = import_tweetnacl.sign.detached(msgBytes, secretKey);
|
|
6865
|
+
return {
|
|
6866
|
+
challenge_id: challenge.challenge_id,
|
|
6867
|
+
signature: uint8ToHex(signature),
|
|
6868
|
+
public_key: publicKeyHex,
|
|
6869
|
+
kid
|
|
6870
|
+
};
|
|
6871
|
+
}
|
|
6872
|
+
function verifyPresenceProof(challenge, proof, declaration, durationMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6873
|
+
if (Date.now() > challenge.expires_at) {
|
|
6874
|
+
return { valid: false, error: "Challenge expired", code: "CHALLENGE_EXPIRED" };
|
|
6875
|
+
}
|
|
6876
|
+
if (proof.challenge_id !== challenge.challenge_id) {
|
|
6877
|
+
return { valid: false, error: "Challenge ID mismatch", code: "CHALLENGE_MISMATCH" };
|
|
6878
|
+
}
|
|
6879
|
+
const data = presenceSigningData(challenge, declaration.device_meta);
|
|
6880
|
+
const msgBytes = new TextEncoder().encode(data);
|
|
6881
|
+
const sigBytes = hexToUint8(proof.signature);
|
|
6882
|
+
const pubBytes = hexToUint8(proof.public_key);
|
|
6883
|
+
let isValid;
|
|
6884
|
+
try {
|
|
6885
|
+
isValid = import_tweetnacl.sign.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
6886
|
+
} catch {
|
|
6887
|
+
return { valid: false, error: "Signature verification failed", code: "SIG_INVALID" };
|
|
6888
|
+
}
|
|
6889
|
+
if (!isValid) {
|
|
6890
|
+
return { valid: false, error: "Invalid signature", code: "SIG_INVALID" };
|
|
6891
|
+
}
|
|
6892
|
+
const now = Date.now();
|
|
6893
|
+
const presenceId = sha2567(
|
|
6894
|
+
`${proof.public_key}:${challenge.nonce}:${challenge.temporal_anchor}`
|
|
6895
|
+
);
|
|
6896
|
+
const anchorReflection = sha2567(
|
|
6897
|
+
`ar:openlogs:loom:${proof.public_key}`
|
|
6898
|
+
);
|
|
6899
|
+
const receipt = {
|
|
6900
|
+
presence_id: presenceId,
|
|
6901
|
+
softid: declaration.softid,
|
|
6902
|
+
anchor_reflection: anchorReflection,
|
|
6903
|
+
scope: {
|
|
6904
|
+
device_fingerprint: declaration.device_meta?.fingerprint
|
|
6905
|
+
},
|
|
6906
|
+
issued_at: now,
|
|
6907
|
+
expires_at: now + durationMs
|
|
6908
|
+
};
|
|
6909
|
+
return { valid: true, presence: receipt };
|
|
6910
|
+
}
|
|
6911
|
+
function getPresenceStatus(receipt) {
|
|
6912
|
+
const now = Date.now();
|
|
6913
|
+
if (now > receipt.expires_at) return "expired";
|
|
6914
|
+
return "active";
|
|
6915
|
+
}
|
|
6916
|
+
function renewPresence(receipt, extensionMs = DEFAULT_PRESENCE_DURATION_MS) {
|
|
6917
|
+
const now = Date.now();
|
|
6918
|
+
return {
|
|
6919
|
+
...receipt,
|
|
6920
|
+
renewed_at: now,
|
|
6921
|
+
expires_at: now + extensionMs
|
|
6922
|
+
};
|
|
6923
|
+
}
|
|
6924
|
+
function createWrit(body, meta, thread, privateKeyHex, kid) {
|
|
6925
|
+
const head = { tid: thread.tid, seq: thread.seq };
|
|
6926
|
+
const writMeta = { ...meta, prev: thread.prevHash };
|
|
6927
|
+
const unsigned = { head, body, meta: writMeta };
|
|
6928
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
6929
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
6930
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
6931
|
+
const signature = import_tweetnacl.sign.detached(msgBytes, secretKey);
|
|
6932
|
+
const sig = {
|
|
6933
|
+
alg: "ed25519",
|
|
6934
|
+
value: uint8ToB64(signature),
|
|
6935
|
+
kid
|
|
6936
|
+
};
|
|
6937
|
+
return { head, body, meta: writMeta, sig };
|
|
6938
|
+
}
|
|
6939
|
+
function validateWrit(writ, publicKeyHex, threadState, grants) {
|
|
6940
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6941
|
+
if (now < writ.meta.iat) {
|
|
6942
|
+
return {
|
|
6943
|
+
valid: false,
|
|
6944
|
+
error: "Writ not yet valid (iat in future)",
|
|
6945
|
+
code: "TEMPORAL_NOT_YET",
|
|
6946
|
+
gate_failed: "temporal"
|
|
6947
|
+
};
|
|
6948
|
+
}
|
|
6949
|
+
if (now > writ.meta.exp) {
|
|
6950
|
+
return {
|
|
6951
|
+
valid: false,
|
|
6952
|
+
error: "Writ expired",
|
|
6953
|
+
code: "TEMPORAL_EXPIRED",
|
|
6954
|
+
gate_failed: "temporal"
|
|
6955
|
+
};
|
|
6956
|
+
}
|
|
6957
|
+
if (threadState) {
|
|
6958
|
+
if (writ.head.tid !== threadState.thread_id) {
|
|
6959
|
+
return {
|
|
6960
|
+
valid: false,
|
|
6961
|
+
error: "Thread ID mismatch",
|
|
6962
|
+
code: "CAUSAL_TID",
|
|
6963
|
+
gate_failed: "causal"
|
|
6964
|
+
};
|
|
6965
|
+
}
|
|
6966
|
+
if (writ.head.seq !== threadState.sequence + 1) {
|
|
6967
|
+
return {
|
|
6968
|
+
valid: false,
|
|
6969
|
+
error: `Expected seq ${threadState.sequence + 1}, got ${writ.head.seq}`,
|
|
6970
|
+
code: "CAUSAL_SEQ",
|
|
6971
|
+
gate_failed: "causal"
|
|
6972
|
+
};
|
|
6973
|
+
}
|
|
6974
|
+
if (writ.meta.prev !== threadState.last_receipt_hash) {
|
|
6975
|
+
return {
|
|
6976
|
+
valid: false,
|
|
6977
|
+
error: "Previous receipt hash mismatch",
|
|
6978
|
+
code: "CAUSAL_PREV",
|
|
6979
|
+
gate_failed: "causal"
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
} else {
|
|
6983
|
+
if (writ.head.seq !== 1) {
|
|
6984
|
+
return {
|
|
6985
|
+
valid: false,
|
|
6986
|
+
error: "First writ in thread must have seq=1",
|
|
6987
|
+
code: "CAUSAL_FIRST_SEQ",
|
|
6988
|
+
gate_failed: "causal"
|
|
6989
|
+
};
|
|
6990
|
+
}
|
|
6991
|
+
if (writ.meta.prev !== "") {
|
|
6992
|
+
return {
|
|
6993
|
+
valid: false,
|
|
6994
|
+
error: "First writ must have empty prev hash",
|
|
6995
|
+
code: "CAUSAL_FIRST_PREV",
|
|
6996
|
+
gate_failed: "causal"
|
|
6997
|
+
};
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
if (writ.body.law !== "self") {
|
|
7001
|
+
const matchingGrant = grants.find(
|
|
7002
|
+
(g) => g.grant_id === writ.body.law && g.subject === writ.body.who && grantCoversAction(g, writ.body.act, writ.body.res, now)
|
|
7003
|
+
);
|
|
7004
|
+
if (!matchingGrant) {
|
|
7005
|
+
return {
|
|
7006
|
+
valid: false,
|
|
7007
|
+
error: `No valid grant found for law=${writ.body.law}`,
|
|
7008
|
+
code: "LEGAL_NO_GRANT",
|
|
7009
|
+
gate_failed: "legal"
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
}
|
|
7013
|
+
const unsigned = {
|
|
7014
|
+
head: writ.head,
|
|
7015
|
+
body: writ.body,
|
|
7016
|
+
meta: writ.meta
|
|
7017
|
+
};
|
|
7018
|
+
const canonical = canonicalizeWrit(unsigned);
|
|
7019
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7020
|
+
const sigBytes = b64ToUint8(writ.sig.value);
|
|
7021
|
+
const pubBytes = hexToUint8(publicKeyHex);
|
|
7022
|
+
let sigValid;
|
|
7023
|
+
try {
|
|
7024
|
+
sigValid = import_tweetnacl.sign.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
7025
|
+
} catch {
|
|
7026
|
+
return {
|
|
7027
|
+
valid: false,
|
|
7028
|
+
error: "Signature verification failed",
|
|
7029
|
+
code: "AUTH_SIG_FAIL",
|
|
7030
|
+
gate_failed: "authentic"
|
|
7031
|
+
};
|
|
7032
|
+
}
|
|
7033
|
+
if (!sigValid) {
|
|
7034
|
+
return {
|
|
7035
|
+
valid: false,
|
|
7036
|
+
error: "Invalid signature",
|
|
7037
|
+
code: "AUTH_SIG_INVALID",
|
|
7038
|
+
gate_failed: "authentic"
|
|
7039
|
+
};
|
|
7040
|
+
}
|
|
7041
|
+
return { valid: true, writ };
|
|
7042
|
+
}
|
|
7043
|
+
function grantCoversAction(grant, action, resource, nowUnix) {
|
|
7044
|
+
if (nowUnix < grant.meta.iat || nowUnix > grant.meta.exp) {
|
|
7045
|
+
return false;
|
|
7046
|
+
}
|
|
7047
|
+
return grant.caps.some(
|
|
7048
|
+
(cap) => matchOec(cap.oec, action) && matchScope(cap.scope, resource)
|
|
7049
|
+
);
|
|
7050
|
+
}
|
|
7051
|
+
function matchOec(pattern, action) {
|
|
7052
|
+
if (pattern === "*") return true;
|
|
7053
|
+
if (pattern === action) return true;
|
|
7054
|
+
if (pattern.endsWith(".*")) {
|
|
7055
|
+
const prefix = pattern.slice(0, -2);
|
|
7056
|
+
return action.startsWith(prefix + ".");
|
|
7057
|
+
}
|
|
7058
|
+
return false;
|
|
7059
|
+
}
|
|
7060
|
+
function matchScope(pattern, resource) {
|
|
7061
|
+
if (pattern === "*") return true;
|
|
7062
|
+
if (pattern === resource) return true;
|
|
7063
|
+
if (pattern.includes("*")) {
|
|
7064
|
+
const regex = new RegExp(
|
|
7065
|
+
"^" + pattern.replace(/\./g, "\\.").replace(/\*/g, "[^:]*") + "$"
|
|
7066
|
+
);
|
|
7067
|
+
return regex.test(resource);
|
|
7068
|
+
}
|
|
7069
|
+
return false;
|
|
7070
|
+
}
|
|
7071
|
+
function getGrantStatus(grant, revocations) {
|
|
7072
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
7073
|
+
const revoked = revocations.find(
|
|
7074
|
+
(r) => r.target_type === "grant" && r.target_id === grant.grant_id
|
|
7075
|
+
);
|
|
7076
|
+
if (revoked && revoked.effective_at <= now * 1e3) {
|
|
7077
|
+
return "revoked";
|
|
7078
|
+
}
|
|
7079
|
+
if (now > grant.meta.exp) return "expired";
|
|
7080
|
+
return "active";
|
|
7081
|
+
}
|
|
7082
|
+
function validateGrant(grant, issuerPublicKeyHex) {
|
|
7083
|
+
const unsigned = {
|
|
7084
|
+
grant_id: grant.grant_id,
|
|
7085
|
+
issuer: grant.issuer,
|
|
7086
|
+
subject: grant.subject,
|
|
7087
|
+
grant_type: grant.grant_type,
|
|
7088
|
+
caps: grant.caps,
|
|
7089
|
+
meta: grant.meta
|
|
7090
|
+
};
|
|
7091
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
7092
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7093
|
+
const sigBytes = b64ToUint8(grant.sig.value);
|
|
7094
|
+
const pubBytes = hexToUint8(issuerPublicKeyHex);
|
|
7095
|
+
let valid;
|
|
7096
|
+
try {
|
|
7097
|
+
valid = import_tweetnacl.sign.detached.verify(msgBytes, sigBytes, pubBytes);
|
|
7098
|
+
} catch {
|
|
7099
|
+
return { valid: false, error: "Grant signature verification failed", code: "GRANT_SIG_FAIL" };
|
|
7100
|
+
}
|
|
7101
|
+
if (!valid) {
|
|
7102
|
+
return { valid: false, error: "Invalid grant signature", code: "GRANT_SIG_INVALID" };
|
|
7103
|
+
}
|
|
7104
|
+
return { valid: true, grant };
|
|
7105
|
+
}
|
|
7106
|
+
function createGrant(grantId, issuer, subject, grantType, caps, meta, privateKeyHex, kid) {
|
|
7107
|
+
const unsigned = {
|
|
7108
|
+
grant_id: grantId,
|
|
7109
|
+
issuer,
|
|
7110
|
+
subject,
|
|
7111
|
+
grant_type: grantType,
|
|
7112
|
+
caps,
|
|
7113
|
+
meta
|
|
7114
|
+
};
|
|
7115
|
+
const canonical = canonicalizeGrant(unsigned);
|
|
7116
|
+
const msgBytes = new TextEncoder().encode(canonical);
|
|
7117
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7118
|
+
const signature = import_tweetnacl.sign.detached(msgBytes, secretKey);
|
|
7119
|
+
return {
|
|
7120
|
+
...unsigned,
|
|
7121
|
+
sig: {
|
|
7122
|
+
alg: "ed25519",
|
|
7123
|
+
value: uint8ToB64(signature),
|
|
7124
|
+
kid
|
|
7125
|
+
}
|
|
7126
|
+
};
|
|
7127
|
+
}
|
|
7128
|
+
function createReceipt(writ, effect, prevReceipt, metadata) {
|
|
7129
|
+
const now = Date.now();
|
|
7130
|
+
const sequence = prevReceipt ? prevReceipt.sequence + 1 : 1;
|
|
7131
|
+
const prevHash = prevReceipt?.hash ?? null;
|
|
7132
|
+
const writHash = sha2567(canonicalizeWrit({
|
|
7133
|
+
head: writ.head,
|
|
7134
|
+
body: writ.body,
|
|
7135
|
+
meta: writ.meta
|
|
7136
|
+
}));
|
|
7137
|
+
const hashInput = [
|
|
7138
|
+
prevHash ?? "",
|
|
7139
|
+
writHash,
|
|
7140
|
+
writ.head.tid,
|
|
7141
|
+
String(sequence),
|
|
7142
|
+
effect,
|
|
7143
|
+
String(now)
|
|
7144
|
+
].join(":");
|
|
7145
|
+
const receiptHash = sha2567(hashInput);
|
|
7146
|
+
const receiptId = sha2567(`receipt:${receiptHash}:${now}`);
|
|
7147
|
+
return {
|
|
7148
|
+
receipt_id: receiptId,
|
|
7149
|
+
writ_hash: writHash,
|
|
7150
|
+
thread_id: writ.head.tid,
|
|
7151
|
+
sequence,
|
|
7152
|
+
effect,
|
|
7153
|
+
hash: receiptHash,
|
|
7154
|
+
prev_hash: prevHash,
|
|
7155
|
+
executed_at: now,
|
|
7156
|
+
metadata
|
|
7157
|
+
};
|
|
7158
|
+
}
|
|
7159
|
+
function verifyReceiptChain(receipts) {
|
|
7160
|
+
if (receipts.length === 0) return { valid: true };
|
|
7161
|
+
const sorted = [...receipts].sort((a, b) => a.sequence - b.sequence);
|
|
7162
|
+
if (sorted[0].prev_hash !== null) {
|
|
7163
|
+
return {
|
|
7164
|
+
valid: false,
|
|
7165
|
+
brokenAt: 0,
|
|
7166
|
+
error: "First receipt must have null prev_hash"
|
|
7167
|
+
};
|
|
7168
|
+
}
|
|
7169
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
7170
|
+
if (sorted[i].prev_hash !== sorted[i - 1].hash) {
|
|
7171
|
+
return {
|
|
7172
|
+
valid: false,
|
|
7173
|
+
brokenAt: i,
|
|
7174
|
+
error: `Receipt ${i} prev_hash does not match receipt ${i - 1} hash`
|
|
7175
|
+
};
|
|
7176
|
+
}
|
|
7177
|
+
}
|
|
7178
|
+
return { valid: true };
|
|
7179
|
+
}
|
|
7180
|
+
function updateThreadState(receipt, softid) {
|
|
7181
|
+
return {
|
|
7182
|
+
thread_id: receipt.thread_id,
|
|
7183
|
+
softid,
|
|
7184
|
+
last_receipt_hash: receipt.hash,
|
|
7185
|
+
sequence: receipt.sequence,
|
|
7186
|
+
updated_at: receipt.executed_at
|
|
7187
|
+
};
|
|
7188
|
+
}
|
|
7189
|
+
function createRevocation(targetType, targetId, issuerSoftid, privateKeyHex, reason) {
|
|
7190
|
+
const now = Date.now();
|
|
7191
|
+
const revocationId = sha2567(`revoke:${targetType}:${targetId}:${now}`);
|
|
7192
|
+
const payload = JSON.stringify({
|
|
7193
|
+
revocation_id: revocationId,
|
|
7194
|
+
target_type: targetType,
|
|
7195
|
+
target_id: targetId,
|
|
7196
|
+
issuer_softid: issuerSoftid,
|
|
7197
|
+
effective_at: now,
|
|
7198
|
+
reason: reason ?? null
|
|
7199
|
+
});
|
|
7200
|
+
const msgBytes = new TextEncoder().encode(payload);
|
|
7201
|
+
const secretKey = hexToUint8(privateKeyHex);
|
|
7202
|
+
const signature = import_tweetnacl.sign.detached(msgBytes, secretKey);
|
|
7203
|
+
return {
|
|
7204
|
+
revocation_id: revocationId,
|
|
7205
|
+
target_type: targetType,
|
|
7206
|
+
target_id: targetId,
|
|
7207
|
+
issuer_softid: issuerSoftid,
|
|
7208
|
+
reason,
|
|
7209
|
+
effective_at: now,
|
|
7210
|
+
sig_value: uint8ToHex(signature)
|
|
7211
|
+
};
|
|
7212
|
+
}
|
|
7213
|
+
function isRevoked(targetType, targetId, revocations) {
|
|
7214
|
+
const now = Date.now();
|
|
7215
|
+
return revocations.some(
|
|
7216
|
+
(r) => r.target_type === targetType && r.target_id === targetId && r.effective_at <= now
|
|
7217
|
+
);
|
|
7218
|
+
}
|
|
7219
|
+
function executeLoomPipeline(writ, publicKeyHex, presence, threadState, grants, revocations, prevReceipt) {
|
|
7220
|
+
const presenceStatus = getPresenceStatus(presence);
|
|
7221
|
+
if (presenceStatus !== "active") {
|
|
7222
|
+
return { valid: false, error: "Presence not active", code: "PRESENCE_INACTIVE" };
|
|
7223
|
+
}
|
|
7224
|
+
if (isRevoked("presence", presence.presence_id, revocations)) {
|
|
7225
|
+
return { valid: false, error: "Presence revoked", code: "PRESENCE_REVOKED" };
|
|
7226
|
+
}
|
|
7227
|
+
const activeGrants = grants.filter(
|
|
7228
|
+
(g) => getGrantStatus(g, revocations) === "active"
|
|
7229
|
+
);
|
|
7230
|
+
const writResult = validateWrit(writ, publicKeyHex, threadState, activeGrants);
|
|
7231
|
+
if (!writResult.valid) {
|
|
7232
|
+
return { valid: false, error: writResult.error, code: writResult.code };
|
|
7233
|
+
}
|
|
7234
|
+
const receipt = createReceipt(writ, "ALLOW", prevReceipt);
|
|
7235
|
+
const newThreadState = updateThreadState(receipt, writ.body.who);
|
|
7236
|
+
return {
|
|
7237
|
+
receipt,
|
|
7238
|
+
threadState: newThreadState,
|
|
7239
|
+
writValidation: writResult
|
|
7240
|
+
};
|
|
7241
|
+
}
|
|
7242
|
+
var import_crypto9, import_tweetnacl, DEFAULT_PRESENCE_TTL_MS, DEFAULT_PRESENCE_DURATION_MS;
|
|
7243
|
+
var init_loom_engine = __esm({
|
|
7244
|
+
"src/loom/loom.engine.ts"() {
|
|
7245
|
+
import_crypto9 = require("crypto");
|
|
7246
|
+
import_tweetnacl = require("tweetnacl");
|
|
7247
|
+
init_loom_types();
|
|
7248
|
+
DEFAULT_PRESENCE_TTL_MS = 5e3;
|
|
7249
|
+
DEFAULT_PRESENCE_DURATION_MS = 30 * 60 * 1e3;
|
|
7250
|
+
}
|
|
7251
|
+
});
|
|
7252
|
+
|
|
7253
|
+
// src/idel/idel.compiler.ts
|
|
7254
|
+
function validateType(value, expectedType) {
|
|
7255
|
+
switch (expectedType) {
|
|
7256
|
+
case "string":
|
|
7257
|
+
return typeof value === "string";
|
|
7258
|
+
case "number":
|
|
7259
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
7260
|
+
case "boolean":
|
|
7261
|
+
return typeof value === "boolean";
|
|
7262
|
+
case "object":
|
|
7263
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7264
|
+
case "array":
|
|
7265
|
+
return Array.isArray(value);
|
|
7266
|
+
default:
|
|
7267
|
+
return true;
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
function assessRisk(schema, proposal, constraints) {
|
|
7271
|
+
const factors = [];
|
|
7272
|
+
let score = 0;
|
|
7273
|
+
const baseRiskMap = {
|
|
7274
|
+
none: 0,
|
|
7275
|
+
low: 0.1,
|
|
7276
|
+
medium: 0.3,
|
|
7277
|
+
high: 0.6,
|
|
7278
|
+
critical: 0.9
|
|
7279
|
+
};
|
|
7280
|
+
score = baseRiskMap[schema.risk_level] ?? 0;
|
|
7281
|
+
if (schema.risk_level !== "none") {
|
|
7282
|
+
factors.push(`Base risk: ${schema.risk_level}`);
|
|
7283
|
+
}
|
|
7284
|
+
if (schema.has_side_effects) {
|
|
7285
|
+
score += 0.1;
|
|
7286
|
+
factors.push("Has side effects");
|
|
7287
|
+
}
|
|
7288
|
+
if (!schema.reversible) {
|
|
7289
|
+
score += 0.1;
|
|
7290
|
+
factors.push("Not reversible");
|
|
7291
|
+
}
|
|
7292
|
+
const failed = constraints.filter((c) => !c.satisfied);
|
|
7293
|
+
if (failed.length > 0) {
|
|
7294
|
+
score += 0.05 * failed.length;
|
|
7295
|
+
factors.push(`${failed.length} unsatisfied constraint(s)`);
|
|
7296
|
+
}
|
|
7297
|
+
score = Math.min(score, 1);
|
|
7298
|
+
let level;
|
|
7299
|
+
if (score <= 0) level = "none";
|
|
7300
|
+
else if (score <= 0.2) level = "low";
|
|
7301
|
+
else if (score <= 0.5) level = "medium";
|
|
7302
|
+
else if (score <= 0.8) level = "high";
|
|
7303
|
+
else level = "critical";
|
|
7304
|
+
return { level, score, factors };
|
|
7305
|
+
}
|
|
7306
|
+
var IdelSchemaRegistry, IdelCompiler;
|
|
7307
|
+
var init_idel_compiler = __esm({
|
|
7308
|
+
"src/idel/idel.compiler.ts"() {
|
|
7309
|
+
IdelSchemaRegistry = class {
|
|
7310
|
+
constructor() {
|
|
7311
|
+
this.schemas = /* @__PURE__ */ new Map();
|
|
7312
|
+
this.aliases = /* @__PURE__ */ new Map();
|
|
7313
|
+
}
|
|
7314
|
+
register(schema) {
|
|
7315
|
+
this.schemas.set(schema.intent, schema);
|
|
7316
|
+
}
|
|
7317
|
+
registerAlias(alias, intent) {
|
|
7318
|
+
this.aliases.set(alias.toLowerCase(), intent);
|
|
7319
|
+
}
|
|
7320
|
+
get(intent) {
|
|
7321
|
+
return this.schemas.get(intent);
|
|
7322
|
+
}
|
|
7323
|
+
resolve(raw) {
|
|
7324
|
+
const exact = this.schemas.get(raw);
|
|
7325
|
+
if (exact) return exact;
|
|
7326
|
+
const aliased = this.aliases.get(raw.toLowerCase());
|
|
7327
|
+
if (aliased) return this.schemas.get(aliased);
|
|
7328
|
+
const candidates = [...this.schemas.keys()].filter(
|
|
7329
|
+
(k) => k.startsWith(raw + ".") || k.toLowerCase().includes(raw.toLowerCase())
|
|
7330
|
+
);
|
|
7331
|
+
if (candidates.length === 1) {
|
|
7332
|
+
return this.schemas.get(candidates[0]);
|
|
7333
|
+
}
|
|
7334
|
+
return void 0;
|
|
7335
|
+
}
|
|
7336
|
+
/**
|
|
7337
|
+
* Find all schemas that partially match the raw input.
|
|
7338
|
+
* Returns scored candidates for ambiguity resolution.
|
|
7339
|
+
*/
|
|
7340
|
+
findCandidates(raw) {
|
|
7341
|
+
const normalized = raw.toLowerCase().trim();
|
|
7342
|
+
const results = [];
|
|
7343
|
+
for (const [key, schema] of this.schemas) {
|
|
7344
|
+
let score = 0;
|
|
7345
|
+
if (key === raw) {
|
|
7346
|
+
score = 1;
|
|
7347
|
+
} else if (key.toLowerCase() === normalized) {
|
|
7348
|
+
score = 0.95;
|
|
7349
|
+
} else if (this.aliases.get(normalized) === key) {
|
|
7350
|
+
score = 0.9;
|
|
7351
|
+
} else if (key.toLowerCase().startsWith(normalized)) {
|
|
7352
|
+
score = 0.7;
|
|
7353
|
+
} else if (key.toLowerCase().includes(normalized)) {
|
|
7354
|
+
score = 0.5;
|
|
7355
|
+
} else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {
|
|
7356
|
+
score = 0.4;
|
|
7357
|
+
} else if (schema.description.toLowerCase().includes(normalized)) {
|
|
7358
|
+
score = 0.3;
|
|
7359
|
+
}
|
|
7360
|
+
if (score > 0) {
|
|
7361
|
+
results.push({ schema, score });
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
7364
|
+
return results.sort((a, b) => b.score - a.score);
|
|
7365
|
+
}
|
|
7366
|
+
list() {
|
|
7367
|
+
return [...this.schemas.values()];
|
|
7368
|
+
}
|
|
7369
|
+
};
|
|
7370
|
+
IdelCompiler = class {
|
|
7371
|
+
constructor(registry) {
|
|
7372
|
+
this.registry = registry;
|
|
7373
|
+
}
|
|
7374
|
+
/**
|
|
7375
|
+
* Compile a raw intent proposal into a validated, executable structure.
|
|
7376
|
+
*/
|
|
7377
|
+
compile(proposal) {
|
|
7378
|
+
const errors = [];
|
|
7379
|
+
const candidates = this.registry.findCandidates(proposal.raw);
|
|
7380
|
+
if (candidates.length === 0) {
|
|
7381
|
+
return {
|
|
7382
|
+
ok: false,
|
|
7383
|
+
errors: [{
|
|
7384
|
+
code: "IDEL_UNKNOWN_INTENT",
|
|
7385
|
+
message: `No intent found matching '${proposal.raw}'`
|
|
7386
|
+
}]
|
|
7387
|
+
};
|
|
7388
|
+
}
|
|
7389
|
+
const best = candidates[0];
|
|
7390
|
+
const schema = best.schema;
|
|
7391
|
+
const alternatives = candidates.slice(1, 4).filter((c) => c.score >= 0.3).map((c) => ({
|
|
7392
|
+
intent: c.schema.intent,
|
|
7393
|
+
confidence: c.score,
|
|
7394
|
+
reason: c.schema.description
|
|
7395
|
+
}));
|
|
7396
|
+
const constraints = [];
|
|
7397
|
+
const clarifications = [];
|
|
7398
|
+
const params = { ...proposal.params };
|
|
7399
|
+
for (const paramSchema of schema.params) {
|
|
7400
|
+
const value = params[paramSchema.name];
|
|
7401
|
+
if (paramSchema.required && value === void 0) {
|
|
7402
|
+
if (paramSchema.default !== void 0) {
|
|
7403
|
+
params[paramSchema.name] = paramSchema.default;
|
|
7404
|
+
constraints.push({
|
|
7405
|
+
kind: "required_param",
|
|
7406
|
+
field: paramSchema.name,
|
|
7407
|
+
description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,
|
|
7408
|
+
satisfied: true,
|
|
7409
|
+
value: paramSchema.default
|
|
7410
|
+
});
|
|
7411
|
+
} else {
|
|
7412
|
+
constraints.push({
|
|
7413
|
+
kind: "required_param",
|
|
7414
|
+
field: paramSchema.name,
|
|
7415
|
+
description: `Required parameter '${paramSchema.name}' is missing`,
|
|
7416
|
+
satisfied: false
|
|
7417
|
+
});
|
|
7418
|
+
clarifications.push({
|
|
7419
|
+
id: `clarify_${paramSchema.name}`,
|
|
7420
|
+
question: paramSchema.description ?? `What is the ${paramSchema.name}?`,
|
|
7421
|
+
field: paramSchema.name,
|
|
7422
|
+
options: paramSchema.enum?.map(String),
|
|
7423
|
+
required: true
|
|
7424
|
+
});
|
|
7425
|
+
}
|
|
7426
|
+
continue;
|
|
7427
|
+
}
|
|
7428
|
+
if (value === void 0) continue;
|
|
7429
|
+
const typeValid = validateType(value, paramSchema.type);
|
|
7430
|
+
constraints.push({
|
|
7431
|
+
kind: "type_check",
|
|
7432
|
+
field: paramSchema.name,
|
|
7433
|
+
description: `Must be ${paramSchema.type}`,
|
|
7434
|
+
satisfied: typeValid,
|
|
7435
|
+
value,
|
|
7436
|
+
expected: paramSchema.type
|
|
7437
|
+
});
|
|
7438
|
+
if (!typeValid) {
|
|
7439
|
+
errors.push({
|
|
7440
|
+
code: "IDEL_TYPE_ERROR",
|
|
7441
|
+
message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,
|
|
7442
|
+
field: paramSchema.name
|
|
7443
|
+
});
|
|
7444
|
+
}
|
|
7445
|
+
if (paramSchema.min !== void 0 || paramSchema.max !== void 0) {
|
|
7446
|
+
const numVal = typeof value === "number" ? value : Number(value);
|
|
7447
|
+
const inRange = (paramSchema.min === void 0 || numVal >= paramSchema.min) && (paramSchema.max === void 0 || numVal <= paramSchema.max);
|
|
7448
|
+
constraints.push({
|
|
7449
|
+
kind: "range",
|
|
7450
|
+
field: paramSchema.name,
|
|
7451
|
+
description: `Must be between ${paramSchema.min ?? "-\u221E"} and ${paramSchema.max ?? "\u221E"}`,
|
|
7452
|
+
satisfied: inRange,
|
|
7453
|
+
value: numVal
|
|
7454
|
+
});
|
|
7455
|
+
}
|
|
7456
|
+
if (paramSchema.pattern) {
|
|
7457
|
+
const matches = new RegExp(paramSchema.pattern).test(String(value));
|
|
7458
|
+
constraints.push({
|
|
7459
|
+
kind: "pattern",
|
|
7460
|
+
field: paramSchema.name,
|
|
7461
|
+
description: `Must match ${paramSchema.pattern}`,
|
|
7462
|
+
satisfied: matches,
|
|
7463
|
+
value,
|
|
7464
|
+
expected: paramSchema.pattern
|
|
7465
|
+
});
|
|
7466
|
+
}
|
|
7467
|
+
if (paramSchema.enum) {
|
|
7468
|
+
const inEnum = paramSchema.enum.some(
|
|
7469
|
+
(e) => JSON.stringify(e) === JSON.stringify(value)
|
|
7470
|
+
);
|
|
7471
|
+
constraints.push({
|
|
7472
|
+
kind: "custom",
|
|
7473
|
+
field: paramSchema.name,
|
|
7474
|
+
description: `Must be one of: ${paramSchema.enum.join(", ")}`,
|
|
7475
|
+
satisfied: inEnum,
|
|
7476
|
+
value,
|
|
7477
|
+
expected: paramSchema.enum
|
|
7478
|
+
});
|
|
7479
|
+
}
|
|
7480
|
+
}
|
|
7481
|
+
const risk = assessRisk(schema, proposal, constraints);
|
|
7482
|
+
const unsatisfied = constraints.filter((c) => !c.satisfied);
|
|
7483
|
+
const needsClarification = clarifications.length > 0;
|
|
7484
|
+
let confidence = best.score;
|
|
7485
|
+
if (unsatisfied.length > 0) {
|
|
7486
|
+
confidence *= 1 - unsatisfied.length / Math.max(constraints.length, 1) * 0.5;
|
|
7487
|
+
}
|
|
7488
|
+
if (errors.length > 0) {
|
|
7489
|
+
confidence *= 0.5;
|
|
7490
|
+
}
|
|
7491
|
+
const compiled = {
|
|
7492
|
+
intent: schema.intent,
|
|
7493
|
+
actor_id: proposal.actor_id,
|
|
7494
|
+
target: proposal.target,
|
|
7495
|
+
params,
|
|
7496
|
+
constraints,
|
|
7497
|
+
confidence,
|
|
7498
|
+
alternatives,
|
|
7499
|
+
needs_clarification: needsClarification,
|
|
7500
|
+
clarifications,
|
|
7501
|
+
expected_outcome: schema.description,
|
|
7502
|
+
fallback: schema.related?.[0],
|
|
7503
|
+
risk,
|
|
7504
|
+
metadata: {
|
|
7505
|
+
schema_intent: schema.intent,
|
|
7506
|
+
resolved_from: proposal.raw,
|
|
7507
|
+
has_side_effects: schema.has_side_effects,
|
|
7508
|
+
reversible: schema.reversible
|
|
7509
|
+
}
|
|
7510
|
+
};
|
|
7511
|
+
return {
|
|
7512
|
+
ok: errors.length === 0 && !needsClarification,
|
|
7513
|
+
compiled,
|
|
7514
|
+
errors
|
|
7515
|
+
};
|
|
7516
|
+
}
|
|
7517
|
+
/**
|
|
7518
|
+
* Apply clarification answers and re-compile.
|
|
7519
|
+
*/
|
|
7520
|
+
applyClarifications(compiled, answers) {
|
|
7521
|
+
const proposal = {
|
|
7522
|
+
raw: compiled.intent,
|
|
7523
|
+
actor_id: compiled.actor_id,
|
|
7524
|
+
target: compiled.target,
|
|
7525
|
+
params: { ...compiled.params, ...answers }
|
|
7526
|
+
};
|
|
7527
|
+
return this.compile(proposal);
|
|
7528
|
+
}
|
|
7529
|
+
};
|
|
7530
|
+
}
|
|
7531
|
+
});
|
|
7532
|
+
|
|
7533
|
+
// src/needle/needle.engine.ts
|
|
7534
|
+
function assembleNeedle(params) {
|
|
7535
|
+
return {
|
|
7536
|
+
needle_id: (0, import_crypto10.randomBytes)(16).toString("hex"),
|
|
7537
|
+
phase: "created",
|
|
7538
|
+
tps_coordinate: params.tps_coordinate,
|
|
7539
|
+
intent: params.intent,
|
|
7540
|
+
presence: params.presence,
|
|
7541
|
+
writ: params.writ,
|
|
7542
|
+
grants: params.grants,
|
|
7543
|
+
created_at: Date.now()
|
|
7544
|
+
};
|
|
7545
|
+
}
|
|
7546
|
+
function classifyStitch(observation, verdict) {
|
|
7547
|
+
if (verdict.status === "failed" || verdict.status === "disputed") {
|
|
7548
|
+
return "torn";
|
|
7549
|
+
}
|
|
7550
|
+
if (observation.decision === "DENY") {
|
|
7551
|
+
return "silent";
|
|
7552
|
+
}
|
|
7553
|
+
if (verdict.isDeed) {
|
|
7554
|
+
return "deed";
|
|
7555
|
+
}
|
|
7556
|
+
return "silent";
|
|
7557
|
+
}
|
|
7558
|
+
function formStitch(needle, observation, verdict, receipt) {
|
|
7559
|
+
return {
|
|
7560
|
+
stitch_id: needle.needle_id,
|
|
7561
|
+
kind: classifyStitch(observation, verdict),
|
|
7562
|
+
intent: needle.intent.intent,
|
|
7563
|
+
actor_id: needle.intent.actor_id,
|
|
7564
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7565
|
+
observation,
|
|
7566
|
+
verdict,
|
|
7567
|
+
receipt,
|
|
7568
|
+
thread_id: receipt.thread_id,
|
|
7569
|
+
sequence: receipt.sequence,
|
|
7570
|
+
stitched_at: Date.now()
|
|
7571
|
+
};
|
|
7572
|
+
}
|
|
7573
|
+
async function runNeedlePipeline(needle, config, threadState, prevReceipt, expectedOutcome) {
|
|
7574
|
+
const obs = createObservation("http");
|
|
7575
|
+
obs.intent = needle.intent.intent;
|
|
7576
|
+
obs.actorId = needle.intent.actor_id;
|
|
7577
|
+
needle.phase = "validated";
|
|
7578
|
+
let stage = startStage(obs, "loom.validate");
|
|
7579
|
+
const validation = validateWrit(
|
|
7580
|
+
needle.writ,
|
|
7581
|
+
config.public_key,
|
|
7582
|
+
threadState,
|
|
7583
|
+
needle.grants
|
|
7584
|
+
);
|
|
7585
|
+
if (!validation.valid) {
|
|
7586
|
+
endStage(stage, "fail", validation.error);
|
|
7587
|
+
return failNeedle(needle, obs, "validated", "LOOM_VALIDATION_FAILED", validation.error ?? "Writ validation failed");
|
|
7588
|
+
}
|
|
7589
|
+
endStage(stage, "ok");
|
|
7590
|
+
if (config.sensors && config.sensors.length > 0) {
|
|
7591
|
+
stage = startStage(obs, "sensors.evaluate");
|
|
7592
|
+
const sensorInput = {
|
|
7593
|
+
intent: needle.intent.intent,
|
|
7594
|
+
actorId: needle.intent.actor_id,
|
|
7595
|
+
metadata: {
|
|
7596
|
+
observation: obs,
|
|
7597
|
+
needle_id: needle.needle_id,
|
|
7598
|
+
tps_coordinate: needle.tps_coordinate,
|
|
7599
|
+
writ: needle.writ,
|
|
7600
|
+
grants: needle.grants,
|
|
7601
|
+
params: needle.intent.params
|
|
7602
|
+
}
|
|
7603
|
+
};
|
|
7604
|
+
for (const sensor of config.sensors) {
|
|
7605
|
+
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
7606
|
+
const t0 = Date.now();
|
|
7607
|
+
let decision;
|
|
7608
|
+
try {
|
|
7609
|
+
const rawDecision = await sensor.run(sensorInput);
|
|
7610
|
+
decision = normalizeSensorDecision(rawDecision);
|
|
7611
|
+
} catch (err) {
|
|
7612
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7613
|
+
recordSensor(obs, sensor.name, false, 100, Date.now() - t0, [`sensor_error:${msg}`]);
|
|
7614
|
+
endStage(stage, "fail", `Sensor ${sensor.name} threw: ${msg}`);
|
|
7615
|
+
return failNeedle(needle, obs, "validated", "SENSOR_ERROR", `Sensor ${sensor.name} failed: ${msg}`);
|
|
7616
|
+
}
|
|
7617
|
+
recordSensor(obs, sensor.name, decision.allow, decision.riskScore, Date.now() - t0, decision.reasons);
|
|
7618
|
+
if (!decision.allow) {
|
|
7619
|
+
endStage(stage, "fail", `Sensor ${sensor.name} denied`);
|
|
7620
|
+
return failNeedle(needle, obs, "validated", "SENSOR_DENY", decision.reasons[0] ?? `Denied by ${sensor.name}`);
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7623
|
+
endStage(stage, "ok");
|
|
7624
|
+
}
|
|
7625
|
+
needle.phase = "executing";
|
|
7626
|
+
stage = startStage(obs, "handler.execute");
|
|
7627
|
+
const handler = config.handlers.get(needle.intent.intent);
|
|
7628
|
+
if (!handler) {
|
|
7629
|
+
endStage(stage, "fail", `No handler for intent '${needle.intent.intent}'`);
|
|
7630
|
+
return failNeedle(needle, obs, "executing", "NO_HANDLER", `No handler registered for intent '${needle.intent.intent}'`);
|
|
7631
|
+
}
|
|
7632
|
+
const handlerCtx = {
|
|
7633
|
+
needle_id: needle.needle_id,
|
|
7634
|
+
actor_id: needle.intent.actor_id,
|
|
7635
|
+
presence_id: needle.presence.presence_id,
|
|
7636
|
+
writ: needle.writ,
|
|
7637
|
+
grants: needle.grants,
|
|
7638
|
+
tps_coordinate: needle.tps_coordinate
|
|
7639
|
+
};
|
|
7640
|
+
let handlerResult;
|
|
7641
|
+
try {
|
|
7642
|
+
handlerResult = await handler(needle.intent, handlerCtx);
|
|
7643
|
+
} catch (err) {
|
|
7644
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7645
|
+
endStage(stage, "fail", msg);
|
|
7646
|
+
return failNeedle(needle, obs, "executing", "HANDLER_ERROR", msg);
|
|
7647
|
+
}
|
|
7648
|
+
if (!handlerResult.ok) {
|
|
7649
|
+
endStage(stage, "fail", handlerResult.effect);
|
|
7650
|
+
obs.decision = "DENY";
|
|
7651
|
+
obs.resultCode = handlerResult.effect;
|
|
7652
|
+
obs.statusCode = handlerResult.status_code ?? 400;
|
|
7653
|
+
} else {
|
|
7654
|
+
endStage(stage, "ok");
|
|
7655
|
+
obs.decision = "ALLOW";
|
|
7656
|
+
obs.resultCode = handlerResult.effect;
|
|
7657
|
+
obs.statusCode = handlerResult.status_code ?? 200;
|
|
7658
|
+
}
|
|
7659
|
+
if (handlerResult.data) {
|
|
7660
|
+
obs.facts = { ...obs.facts, ...handlerResult.data };
|
|
7661
|
+
}
|
|
7662
|
+
needle.phase = "observed";
|
|
7663
|
+
finalizeObservation(obs, obs.decision ?? "DENY", obs.statusCode ?? 500, obs.resultCode);
|
|
7664
|
+
needle.observation = obs;
|
|
7665
|
+
const verdict = scoreTruth(obs, expectedOutcome);
|
|
7666
|
+
needle.verdict = verdict;
|
|
7667
|
+
needle.phase = "stitched";
|
|
7668
|
+
stage = startStage(obs, "stitch.form");
|
|
7669
|
+
const receipt = createReceipt(
|
|
7670
|
+
needle.writ,
|
|
7671
|
+
obs.decision ?? "DENY",
|
|
7672
|
+
prevReceipt
|
|
7673
|
+
);
|
|
7674
|
+
needle.receipt = receipt;
|
|
7675
|
+
const newThreadState = updateThreadState(
|
|
7676
|
+
receipt,
|
|
7677
|
+
needle.intent.actor_id
|
|
7678
|
+
);
|
|
7679
|
+
const stitch = formStitch(needle, obs, verdict, receipt);
|
|
7680
|
+
needle.completed_at = Date.now();
|
|
7681
|
+
endStage(stage, "ok");
|
|
7682
|
+
return {
|
|
7683
|
+
ok: handlerResult.ok,
|
|
7684
|
+
needle,
|
|
7685
|
+
stitch,
|
|
7686
|
+
thread_state: newThreadState
|
|
7687
|
+
};
|
|
7688
|
+
}
|
|
7689
|
+
function failNeedle(needle, obs, phase, code, message) {
|
|
7690
|
+
needle.phase = "failed";
|
|
7691
|
+
needle.error = { phase, code, message };
|
|
7692
|
+
needle.completed_at = Date.now();
|
|
7693
|
+
obs.decision = obs.decision ?? "DENY";
|
|
7694
|
+
obs.statusCode = obs.statusCode ?? 500;
|
|
7695
|
+
finalizeObservation(obs, obs.decision, obs.statusCode, obs.resultCode);
|
|
7696
|
+
needle.observation = obs;
|
|
7697
|
+
const verdict = scoreTruth(obs);
|
|
7698
|
+
needle.verdict = verdict;
|
|
7699
|
+
return {
|
|
7700
|
+
ok: false,
|
|
7701
|
+
needle
|
|
7702
|
+
};
|
|
7703
|
+
}
|
|
7704
|
+
var import_crypto10;
|
|
7705
|
+
var init_needle_engine = __esm({
|
|
7706
|
+
"src/needle/needle.engine.ts"() {
|
|
7707
|
+
import_crypto10 = require("crypto");
|
|
7708
|
+
init_axis_observation();
|
|
7709
|
+
init_truth_scoring();
|
|
7710
|
+
init_loom_engine();
|
|
7711
|
+
init_axis_sensor();
|
|
7712
|
+
}
|
|
7713
|
+
});
|
|
7714
|
+
|
|
7715
|
+
// src/needle/knot.engine.ts
|
|
7716
|
+
function openKnot(params) {
|
|
7717
|
+
const isIrreversible = params.type === "irreversible";
|
|
7718
|
+
return {
|
|
7719
|
+
knot_id: `knot_${(0, import_crypto11.randomBytes)(16).toString("hex")}`,
|
|
7720
|
+
type: params.type,
|
|
7721
|
+
status: "open",
|
|
7722
|
+
stitch_ids: [],
|
|
7723
|
+
thread_id: params.thread_id,
|
|
7724
|
+
tps_anchor: params.tps_anchor,
|
|
7725
|
+
irreversible: isIrreversible,
|
|
7726
|
+
capsule_id: params.capsule_id,
|
|
7727
|
+
law_ref: params.law_ref,
|
|
7728
|
+
branch_ids: [],
|
|
7729
|
+
required_count: params.required_count,
|
|
7730
|
+
all_or_nothing: params.all_or_nothing ?? (params.type === "authority" || isIrreversible),
|
|
7731
|
+
actor_id: params.actor_id,
|
|
7732
|
+
created_at: Date.now()
|
|
7733
|
+
};
|
|
7734
|
+
}
|
|
7735
|
+
function addStitchToKnot(knot, stitch) {
|
|
7736
|
+
if (knot.status !== "open") {
|
|
7737
|
+
return `Knot ${knot.knot_id} is ${knot.status}, cannot add stitches`;
|
|
7738
|
+
}
|
|
7739
|
+
if (stitch.thread_id !== knot.thread_id) {
|
|
7740
|
+
return `Stitch thread ${stitch.thread_id} does not match knot thread ${knot.thread_id}`;
|
|
7741
|
+
}
|
|
7742
|
+
if (knot.stitch_ids.includes(stitch.stitch_id)) {
|
|
7743
|
+
return `Stitch ${stitch.stitch_id} already in knot`;
|
|
7744
|
+
}
|
|
7745
|
+
if (knot.type === "authority" && knot.capsule_id) {
|
|
7746
|
+
if (stitch.observation.capsuleId && stitch.observation.capsuleId !== knot.capsule_id) {
|
|
7747
|
+
return `Stitch capsule ${stitch.observation.capsuleId} does not match knot capsule ${knot.capsule_id}`;
|
|
7748
|
+
}
|
|
7749
|
+
}
|
|
7750
|
+
knot.stitch_ids.push(stitch.stitch_id);
|
|
7751
|
+
return null;
|
|
7752
|
+
}
|
|
7753
|
+
function validateKnot(knot, stitches) {
|
|
7754
|
+
const errors = [];
|
|
7755
|
+
const passedIds = [];
|
|
7756
|
+
const failedIds = [];
|
|
7757
|
+
const stitchMap = new Map(stitches.map((s) => [s.stitch_id, s]));
|
|
7758
|
+
for (const sid of knot.stitch_ids) {
|
|
7759
|
+
const stitch = stitchMap.get(sid);
|
|
7760
|
+
if (!stitch) {
|
|
7761
|
+
failedIds.push(sid);
|
|
7762
|
+
errors.push({
|
|
7763
|
+
code: "KNOT_MISSING_STITCH",
|
|
7764
|
+
message: `Stitch ${sid} not found`,
|
|
7765
|
+
stitch_id: sid
|
|
7766
|
+
});
|
|
7767
|
+
continue;
|
|
7768
|
+
}
|
|
7769
|
+
if (stitch.kind === "torn") {
|
|
7770
|
+
failedIds.push(sid);
|
|
7771
|
+
errors.push({
|
|
7772
|
+
code: "KNOT_TORN_STITCH",
|
|
7773
|
+
message: `Stitch ${sid} is torn (failed/disputed)`,
|
|
7774
|
+
stitch_id: sid
|
|
7775
|
+
});
|
|
7776
|
+
continue;
|
|
7777
|
+
}
|
|
7778
|
+
if (knot.type === "irreversible" && stitch.kind !== "deed") {
|
|
7779
|
+
failedIds.push(sid);
|
|
7780
|
+
errors.push({
|
|
7781
|
+
code: "KNOT_REQUIRES_DEED",
|
|
7782
|
+
message: `Irreversible knot requires deed stitch, got '${stitch.kind}'`,
|
|
7783
|
+
stitch_id: sid
|
|
7784
|
+
});
|
|
7785
|
+
continue;
|
|
7786
|
+
}
|
|
7787
|
+
passedIds.push(sid);
|
|
7788
|
+
}
|
|
7789
|
+
if (knot.required_count !== void 0 && knot.stitch_ids.length < knot.required_count) {
|
|
7790
|
+
errors.push({
|
|
7791
|
+
code: "KNOT_INSUFFICIENT_STITCHES",
|
|
7792
|
+
message: `Knot requires ${knot.required_count} stitches, has ${knot.stitch_ids.length}`
|
|
7793
|
+
});
|
|
7794
|
+
}
|
|
7795
|
+
const allPassed = failedIds.length === 0;
|
|
7796
|
+
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);
|
|
7797
|
+
return {
|
|
7798
|
+
valid: allPassed && errors.length === 0,
|
|
7799
|
+
passed_stitch_ids: passedIds,
|
|
7800
|
+
failed_stitch_ids: failedIds,
|
|
7801
|
+
can_tie: canTie,
|
|
7802
|
+
errors
|
|
7803
|
+
};
|
|
7804
|
+
}
|
|
7805
|
+
function tieKnot(knot, stitches) {
|
|
7806
|
+
const validation = validateKnot(knot, stitches);
|
|
7807
|
+
if (!validation.can_tie) {
|
|
7808
|
+
return { ...validation, knot };
|
|
7809
|
+
}
|
|
7810
|
+
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);
|
|
7811
|
+
const witnessPayload = receiptHashes.join(":");
|
|
7812
|
+
knot.witness_hash = (0, import_crypto11.createHash)("sha256").update(witnessPayload).digest("hex");
|
|
7813
|
+
knot.status = "tied";
|
|
7814
|
+
knot.tied_at = Date.now();
|
|
7815
|
+
return { ...validation, knot };
|
|
7816
|
+
}
|
|
7817
|
+
function breakKnot(knot, request) {
|
|
7818
|
+
if (knot.status === "broken") {
|
|
7819
|
+
return { ok: false, error: "Knot is already broken" };
|
|
7820
|
+
}
|
|
7821
|
+
if (knot.status === "open") {
|
|
7822
|
+
knot.status = "broken";
|
|
7823
|
+
knot.broken_at = Date.now();
|
|
7824
|
+
knot.break_reason = request.reason;
|
|
7825
|
+
return { ok: true };
|
|
7826
|
+
}
|
|
7827
|
+
if (knot.status === "tied") {
|
|
7828
|
+
if (!request.reason) {
|
|
7829
|
+
return { ok: false, error: "Breaking a tied knot requires a reason" };
|
|
7830
|
+
}
|
|
7831
|
+
if ((knot.irreversible || knot.type === "law") && !request.override_grant_id) {
|
|
7832
|
+
return {
|
|
7833
|
+
ok: false,
|
|
7834
|
+
error: `Breaking ${knot.type} knot requires override_grant_id from higher authority`
|
|
7835
|
+
};
|
|
7836
|
+
}
|
|
7837
|
+
knot.status = "broken";
|
|
7838
|
+
knot.broken_at = Date.now();
|
|
7839
|
+
knot.break_reason = request.reason;
|
|
7840
|
+
return { ok: true };
|
|
7841
|
+
}
|
|
7842
|
+
return { ok: false, error: `Cannot break knot in status '${knot.status}'` };
|
|
7843
|
+
}
|
|
7844
|
+
function forkFromKnot(knot, branchId, decisionStitchId) {
|
|
7845
|
+
if (knot.status !== "tied" && knot.status !== "open") {
|
|
7846
|
+
return { ok: false, error: `Cannot fork from knot in status '${knot.status}'` };
|
|
7847
|
+
}
|
|
7848
|
+
if (decisionStitchId) {
|
|
7849
|
+
if (!knot.stitch_ids.includes(decisionStitchId)) {
|
|
7850
|
+
return { ok: false, error: `Decision stitch ${decisionStitchId} is not part of this knot` };
|
|
7851
|
+
}
|
|
7852
|
+
knot.decision_stitch_id = decisionStitchId;
|
|
7853
|
+
}
|
|
7854
|
+
knot.branch_ids.push(branchId);
|
|
7855
|
+
knot.status = "forked";
|
|
7856
|
+
return { ok: true };
|
|
7857
|
+
}
|
|
7858
|
+
function isKnotOpen(knot) {
|
|
7859
|
+
return knot.status === "open";
|
|
7860
|
+
}
|
|
7861
|
+
function isPointOfNoReturn(knot) {
|
|
7862
|
+
return knot.irreversible && knot.status === "tied";
|
|
7863
|
+
}
|
|
7864
|
+
function findKnotsForStitch(stitchId, knots) {
|
|
7865
|
+
return knots.filter((k) => k.stitch_ids.includes(stitchId));
|
|
7866
|
+
}
|
|
7867
|
+
function getIrreversibleKnots(knots) {
|
|
7868
|
+
return knots.filter((k) => k.irreversible && k.status === "tied");
|
|
7869
|
+
}
|
|
7870
|
+
function getDecisionPoints(knots) {
|
|
7871
|
+
return knots.filter((k) => k.type === "decision" || k.status === "forked");
|
|
7872
|
+
}
|
|
7873
|
+
var import_crypto11;
|
|
7874
|
+
var init_knot_engine = __esm({
|
|
7875
|
+
"src/needle/knot.engine.ts"() {
|
|
7876
|
+
import_crypto11 = require("crypto");
|
|
7877
|
+
}
|
|
7878
|
+
});
|
|
7879
|
+
|
|
7880
|
+
// src/needle/fabric.engine.ts
|
|
7881
|
+
function createFabric() {
|
|
7882
|
+
return {
|
|
7883
|
+
fabric_id: `fab_${(0, import_crypto12.randomBytes)(16).toString("hex")}`,
|
|
7884
|
+
state_hash: hashState(/* @__PURE__ */ new Map()),
|
|
7885
|
+
cells: /* @__PURE__ */ new Map(),
|
|
7886
|
+
thread_ids: [],
|
|
7887
|
+
stitch_count: 0,
|
|
7888
|
+
knot_count: 0,
|
|
7889
|
+
computed_at: Date.now(),
|
|
7890
|
+
version: 0
|
|
7891
|
+
};
|
|
7892
|
+
}
|
|
7893
|
+
function applyStitch(fabric, stitch, effect) {
|
|
7894
|
+
for (const [key, value] of Object.entries(effect.mutations)) {
|
|
7895
|
+
if (value === null) {
|
|
7896
|
+
fabric.cells.delete(key);
|
|
7897
|
+
} else {
|
|
7898
|
+
const existing = fabric.cells.get(key);
|
|
7899
|
+
if (existing?.locked) {
|
|
7900
|
+
continue;
|
|
7901
|
+
}
|
|
7902
|
+
fabric.cells.set(key, {
|
|
7903
|
+
key,
|
|
7904
|
+
value,
|
|
7905
|
+
last_stitch_id: stitch.stitch_id,
|
|
7906
|
+
last_tps: stitch.tps_coordinate,
|
|
7907
|
+
write_count: (existing?.write_count ?? 0) + 1,
|
|
7908
|
+
locked: false
|
|
7909
|
+
});
|
|
7910
|
+
}
|
|
7911
|
+
}
|
|
7912
|
+
if (!fabric.thread_ids.includes(stitch.thread_id)) {
|
|
7913
|
+
fabric.thread_ids.push(stitch.thread_id);
|
|
7914
|
+
}
|
|
7915
|
+
fabric.stitch_count++;
|
|
7916
|
+
fabric.version++;
|
|
7917
|
+
fabric.projected_at_tps = stitch.tps_coordinate ?? fabric.projected_at_tps;
|
|
7918
|
+
fabric.computed_at = Date.now();
|
|
7919
|
+
fabric.state_hash = hashState(fabric.cells);
|
|
7920
|
+
}
|
|
7921
|
+
function weave(stitches, resolver, knots) {
|
|
7922
|
+
const fabric = createFabric();
|
|
7923
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
7924
|
+
for (const stitch of sorted) {
|
|
7925
|
+
if (stitch.kind === "torn") continue;
|
|
7926
|
+
const effect = resolver(stitch);
|
|
7927
|
+
applyStitch(fabric, stitch, effect);
|
|
7928
|
+
}
|
|
7929
|
+
if (knots) {
|
|
7930
|
+
for (const knot of knots) {
|
|
7931
|
+
if (knot.irreversible && knot.status === "tied") {
|
|
7932
|
+
lockCellsByKnot(fabric, knot, stitches, resolver);
|
|
7933
|
+
fabric.knot_count++;
|
|
7934
|
+
}
|
|
7935
|
+
}
|
|
7936
|
+
}
|
|
7937
|
+
return fabric;
|
|
7938
|
+
}
|
|
7939
|
+
function projectAt(stitches, resolver, tpsFilter, knots) {
|
|
7940
|
+
const filtered = stitches.filter((s) => tpsFilter(s.tps_coordinate));
|
|
7941
|
+
return weave(filtered, resolver, knots);
|
|
7942
|
+
}
|
|
7943
|
+
function lockCellsByKnot(fabric, knot, stitches, resolver) {
|
|
7944
|
+
const knotStitchIds = new Set(knot.stitch_ids);
|
|
7945
|
+
const knotStitches = stitches.filter((s) => knotStitchIds.has(s.stitch_id));
|
|
7946
|
+
for (const stitch of knotStitches) {
|
|
7947
|
+
const effect = resolver(stitch);
|
|
7948
|
+
for (const key of Object.keys(effect.mutations)) {
|
|
7949
|
+
const cell = fabric.cells.get(key);
|
|
7950
|
+
if (cell) {
|
|
7951
|
+
cell.locked = true;
|
|
7952
|
+
cell.locked_by_knot = knot.knot_id;
|
|
7953
|
+
}
|
|
7954
|
+
}
|
|
7955
|
+
}
|
|
7956
|
+
}
|
|
7957
|
+
function lockCells(fabric, keys, knotId) {
|
|
7958
|
+
for (const key of keys) {
|
|
7959
|
+
const cell = fabric.cells.get(key);
|
|
7960
|
+
if (cell) {
|
|
7961
|
+
cell.locked = true;
|
|
7962
|
+
cell.locked_by_knot = knotId;
|
|
7963
|
+
}
|
|
7964
|
+
}
|
|
7965
|
+
}
|
|
7966
|
+
function queryFabric(fabric, query) {
|
|
7967
|
+
let results = [...fabric.cells.values()];
|
|
7968
|
+
if (query.keys) {
|
|
7969
|
+
const keySet = new Set(query.keys);
|
|
7970
|
+
results = results.filter((c) => keySet.has(c.key));
|
|
7971
|
+
}
|
|
7972
|
+
if (query.prefix) {
|
|
7973
|
+
const prefix = query.prefix;
|
|
7974
|
+
results = results.filter((c) => c.key.startsWith(prefix));
|
|
7975
|
+
}
|
|
7976
|
+
if (query.locked_only) {
|
|
7977
|
+
results = results.filter((c) => c.locked);
|
|
7978
|
+
}
|
|
7979
|
+
return results;
|
|
7980
|
+
}
|
|
7981
|
+
function getFabricValue(fabric, key) {
|
|
7982
|
+
return fabric.cells.get(key)?.value;
|
|
7983
|
+
}
|
|
7984
|
+
function diffFabrics(a, b) {
|
|
7985
|
+
const entries = [];
|
|
7986
|
+
let added = 0;
|
|
7987
|
+
let modified = 0;
|
|
7988
|
+
let deleted = 0;
|
|
7989
|
+
for (const [key, cellB] of b.cells) {
|
|
7990
|
+
const cellA = a.cells.get(key);
|
|
7991
|
+
if (!cellA) {
|
|
7992
|
+
entries.push({
|
|
7993
|
+
key,
|
|
7994
|
+
kind: "added",
|
|
7995
|
+
after: cellB.value,
|
|
7996
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
7997
|
+
});
|
|
7998
|
+
added++;
|
|
7999
|
+
} else if (JSON.stringify(cellA.value) !== JSON.stringify(cellB.value)) {
|
|
8000
|
+
entries.push({
|
|
8001
|
+
key,
|
|
8002
|
+
kind: "modified",
|
|
8003
|
+
before: cellA.value,
|
|
8004
|
+
after: cellB.value,
|
|
8005
|
+
caused_by_stitch: cellB.last_stitch_id
|
|
8006
|
+
});
|
|
8007
|
+
modified++;
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
for (const [key, cellA] of a.cells) {
|
|
8011
|
+
if (!b.cells.has(key)) {
|
|
8012
|
+
entries.push({
|
|
8013
|
+
key,
|
|
8014
|
+
kind: "deleted",
|
|
8015
|
+
before: cellA.value
|
|
8016
|
+
});
|
|
8017
|
+
deleted++;
|
|
8018
|
+
}
|
|
8019
|
+
}
|
|
8020
|
+
return {
|
|
8021
|
+
from_fabric_id: a.fabric_id,
|
|
8022
|
+
to_fabric_id: b.fabric_id,
|
|
8023
|
+
entries,
|
|
8024
|
+
added_count: added,
|
|
8025
|
+
modified_count: modified,
|
|
8026
|
+
deleted_count: deleted
|
|
8027
|
+
};
|
|
8028
|
+
}
|
|
8029
|
+
function hashState(cells) {
|
|
8030
|
+
const keys = [...cells.keys()].sort();
|
|
8031
|
+
const payload = keys.map((k) => `${k}=${JSON.stringify(cells.get(k).value)}`).join("\n");
|
|
8032
|
+
return (0, import_crypto12.createHash)("sha256").update(payload).digest("hex");
|
|
8033
|
+
}
|
|
8034
|
+
var import_crypto12;
|
|
8035
|
+
var init_fabric_engine = __esm({
|
|
8036
|
+
"src/needle/fabric.engine.ts"() {
|
|
8037
|
+
import_crypto12 = require("crypto");
|
|
8038
|
+
}
|
|
8039
|
+
});
|
|
8040
|
+
|
|
8041
|
+
// src/needle/pattern.engine.ts
|
|
8042
|
+
function detectSequencePatterns(stitches, windowSize, minOccurrences) {
|
|
8043
|
+
if (stitches.length < windowSize || windowSize < 2) return [];
|
|
8044
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
8045
|
+
const sequenceCounts = /* @__PURE__ */ new Map();
|
|
8046
|
+
for (let i = 0; i <= sorted.length - windowSize; i++) {
|
|
8047
|
+
const window = sorted.slice(i, i + windowSize);
|
|
8048
|
+
const key = window.map((s) => s.intent).join("\u2192");
|
|
8049
|
+
const ids = window.map((s) => s.stitch_id);
|
|
8050
|
+
const existing = sequenceCounts.get(key);
|
|
8051
|
+
if (existing) {
|
|
8052
|
+
existing.count++;
|
|
8053
|
+
existing.stitch_ids.push(ids);
|
|
8054
|
+
} else {
|
|
8055
|
+
sequenceCounts.set(key, { count: 1, stitch_ids: [ids] });
|
|
8056
|
+
}
|
|
8057
|
+
}
|
|
8058
|
+
const patterns = [];
|
|
8059
|
+
const now = Date.now();
|
|
8060
|
+
for (const [key, data] of sequenceCounts) {
|
|
8061
|
+
if (data.count < minOccurrences) continue;
|
|
8062
|
+
const intents = key.split("\u2192");
|
|
8063
|
+
const confidence = Math.min(data.count / (minOccurrences * 2), 1);
|
|
8064
|
+
patterns.push({
|
|
8065
|
+
pattern_id: `pat_seq_${(0, import_crypto13.randomBytes)(8).toString("hex")}`,
|
|
8066
|
+
kind: "sequence",
|
|
8067
|
+
name: `Sequence: ${intents.join(" \u2192 ")}`,
|
|
8068
|
+
signature: {
|
|
8069
|
+
intent_sequence: intents,
|
|
8070
|
+
min_length: windowSize,
|
|
8071
|
+
max_length: windowSize
|
|
8072
|
+
},
|
|
8073
|
+
confidence,
|
|
8074
|
+
occurrence_count: data.count,
|
|
8075
|
+
first_seen_at: now,
|
|
8076
|
+
last_seen_at: now,
|
|
8077
|
+
seen_in_threads: [...new Set(
|
|
8078
|
+
data.stitch_ids.flatMap(
|
|
8079
|
+
(ids) => ids.map((id) => sorted.find((s) => s.stitch_id === id)?.thread_id).filter(Boolean)
|
|
8080
|
+
)
|
|
8081
|
+
)],
|
|
8082
|
+
classification: "unclassified"
|
|
8083
|
+
});
|
|
8084
|
+
}
|
|
8085
|
+
return patterns;
|
|
8086
|
+
}
|
|
8087
|
+
function detectKnotPatterns(knots, minOccurrences) {
|
|
8088
|
+
const groups = /* @__PURE__ */ new Map();
|
|
8089
|
+
for (const knot of knots) {
|
|
8090
|
+
if (knot.status !== "tied") continue;
|
|
8091
|
+
const key = `${knot.type}:${knot.stitch_ids.length}`;
|
|
8092
|
+
const group = groups.get(key) ?? [];
|
|
8093
|
+
group.push(knot);
|
|
8094
|
+
groups.set(key, group);
|
|
8095
|
+
}
|
|
8096
|
+
const patterns = [];
|
|
8097
|
+
const now = Date.now();
|
|
8098
|
+
for (const [key, group] of groups) {
|
|
8099
|
+
if (group.length < minOccurrences) continue;
|
|
8100
|
+
const [type, sizeStr] = key.split(":");
|
|
8101
|
+
const size = parseInt(sizeStr, 10);
|
|
8102
|
+
const confidence = Math.min(group.length / (minOccurrences * 2), 1);
|
|
8103
|
+
patterns.push({
|
|
8104
|
+
pattern_id: `pat_knot_${(0, import_crypto13.randomBytes)(8).toString("hex")}`,
|
|
8105
|
+
kind: "knot",
|
|
8106
|
+
name: `Knot: ${type} (${size} stitches)`,
|
|
8107
|
+
signature: {
|
|
8108
|
+
knot_type: type,
|
|
8109
|
+
knot_size: size
|
|
8110
|
+
},
|
|
8111
|
+
confidence,
|
|
8112
|
+
occurrence_count: group.length,
|
|
8113
|
+
first_seen_at: now,
|
|
8114
|
+
last_seen_at: now,
|
|
8115
|
+
seen_in_threads: [...new Set(group.map((k) => k.thread_id))],
|
|
8116
|
+
classification: "unclassified"
|
|
8117
|
+
});
|
|
8118
|
+
}
|
|
8119
|
+
return patterns;
|
|
8120
|
+
}
|
|
8121
|
+
function matchPatterns(stitches, patterns) {
|
|
8122
|
+
const sorted = [...stitches].sort((a, b) => a.sequence - b.sequence);
|
|
8123
|
+
const matches = [];
|
|
8124
|
+
const now = Date.now();
|
|
8125
|
+
for (const pattern of patterns) {
|
|
8126
|
+
if (pattern.kind === "sequence" && pattern.signature.intent_sequence) {
|
|
8127
|
+
const seq = pattern.signature.intent_sequence;
|
|
8128
|
+
const seqLen = seq.length;
|
|
8129
|
+
for (let i = 0; i <= sorted.length - seqLen; i++) {
|
|
8130
|
+
const window = sorted.slice(i, i + seqLen);
|
|
8131
|
+
const windowIntents = window.map((s) => s.intent);
|
|
8132
|
+
if (windowIntents.every((intent, idx) => intent === seq[idx])) {
|
|
8133
|
+
matches.push({
|
|
8134
|
+
pattern_id: pattern.pattern_id,
|
|
8135
|
+
matched_stitch_ids: window.map((s) => s.stitch_id),
|
|
8136
|
+
match_score: 1,
|
|
8137
|
+
thread_id: window[0].thread_id,
|
|
8138
|
+
detected_at: now
|
|
8139
|
+
});
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8142
|
+
}
|
|
8143
|
+
}
|
|
8144
|
+
return matches;
|
|
8145
|
+
}
|
|
8146
|
+
function recordOccurrence(pattern, threadId) {
|
|
8147
|
+
pattern.occurrence_count++;
|
|
8148
|
+
pattern.last_seen_at = Date.now();
|
|
8149
|
+
pattern.confidence = 1 - 1 / (1 + pattern.occurrence_count * 0.5);
|
|
8150
|
+
if (!pattern.seen_in_threads.includes(threadId)) {
|
|
8151
|
+
pattern.seen_in_threads.push(threadId);
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
function detectAnomalies(recentStitches, knownPatterns, threshold = 0.7) {
|
|
8155
|
+
const anomalies = [];
|
|
8156
|
+
const sorted = [...recentStitches].sort((a, b) => a.sequence - b.sequence);
|
|
8157
|
+
const now = Date.now();
|
|
8158
|
+
for (const pattern of knownPatterns) {
|
|
8159
|
+
if (pattern.kind !== "sequence" || !pattern.signature.intent_sequence) continue;
|
|
8160
|
+
if (pattern.confidence < threshold) continue;
|
|
8161
|
+
const seq = pattern.signature.intent_sequence;
|
|
8162
|
+
if (sorted.length >= 1 && sorted.length < seq.length) {
|
|
8163
|
+
const partialMatch = sorted.every(
|
|
8164
|
+
(s, i) => i < seq.length && s.intent === seq[i]
|
|
8165
|
+
);
|
|
8166
|
+
if (partialMatch) {
|
|
8167
|
+
const expectedNext = seq[sorted.length];
|
|
8168
|
+
const lastStitch = sorted[sorted.length - 1];
|
|
8169
|
+
if (pattern.occurrence_count >= 3) {
|
|
8170
|
+
anomalies.push({
|
|
8171
|
+
pattern_id: `pat_anom_${(0, import_crypto13.randomBytes)(8).toString("hex")}`,
|
|
8172
|
+
kind: "anomaly",
|
|
8173
|
+
name: `Incomplete: ${pattern.name}`,
|
|
8174
|
+
description: `Expected '${expectedNext}' after '${lastStitch.intent}' based on pattern '${pattern.name}'`,
|
|
8175
|
+
signature: pattern.signature,
|
|
8176
|
+
confidence: pattern.confidence * 0.8,
|
|
8177
|
+
occurrence_count: 1,
|
|
8178
|
+
first_seen_at: now,
|
|
8179
|
+
last_seen_at: now,
|
|
8180
|
+
seen_in_threads: [lastStitch.thread_id],
|
|
8181
|
+
classification: "anomalous"
|
|
8182
|
+
});
|
|
8183
|
+
}
|
|
8184
|
+
}
|
|
8185
|
+
}
|
|
8186
|
+
}
|
|
8187
|
+
return anomalies;
|
|
8188
|
+
}
|
|
8189
|
+
var import_crypto13, InMemoryPatternStore;
|
|
8190
|
+
var init_pattern_engine = __esm({
|
|
8191
|
+
"src/needle/pattern.engine.ts"() {
|
|
8192
|
+
import_crypto13 = require("crypto");
|
|
8193
|
+
InMemoryPatternStore = class {
|
|
8194
|
+
constructor() {
|
|
8195
|
+
this.patterns = /* @__PURE__ */ new Map();
|
|
8196
|
+
}
|
|
8197
|
+
save(pattern) {
|
|
8198
|
+
this.patterns.set(pattern.pattern_id, pattern);
|
|
8199
|
+
}
|
|
8200
|
+
get(patternId) {
|
|
8201
|
+
return this.patterns.get(patternId);
|
|
8202
|
+
}
|
|
8203
|
+
findByKind(kind) {
|
|
8204
|
+
return [...this.patterns.values()].filter((p) => p.kind === kind);
|
|
8205
|
+
}
|
|
8206
|
+
findByIntent(intent) {
|
|
8207
|
+
return [...this.patterns.values()].filter(
|
|
8208
|
+
(p) => p.signature.intent_sequence?.includes(intent)
|
|
8209
|
+
);
|
|
8210
|
+
}
|
|
8211
|
+
all() {
|
|
8212
|
+
return [...this.patterns.values()];
|
|
8213
|
+
}
|
|
8214
|
+
};
|
|
8215
|
+
}
|
|
8216
|
+
});
|
|
8217
|
+
|
|
8218
|
+
// src/sensors/tps.sensor.ts
|
|
8219
|
+
var require_tps_sensor = __commonJS({
|
|
8220
|
+
"src/sensors/tps.sensor.ts"(exports2) {
|
|
8221
|
+
"use strict";
|
|
8222
|
+
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
8223
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8224
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8225
|
+
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;
|
|
8226
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8227
|
+
};
|
|
8228
|
+
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
8229
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8230
|
+
};
|
|
8231
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8232
|
+
exports2.TpsSensor = void 0;
|
|
8233
|
+
var common_1 = require("@nestjs/common");
|
|
8234
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8235
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8236
|
+
var TPS_EPOCH_MS = 9343548e5;
|
|
8237
|
+
function parseINotation(tps) {
|
|
8238
|
+
if (!tps.startsWith("i"))
|
|
8239
|
+
return null;
|
|
8240
|
+
const num = Number(tps.slice(1));
|
|
8241
|
+
if (!Number.isFinite(num))
|
|
8242
|
+
return null;
|
|
8243
|
+
return TPS_EPOCH_MS + num;
|
|
8244
|
+
}
|
|
8245
|
+
var TpsSensor2 = class TpsSensor {
|
|
8246
|
+
constructor(options = {}) {
|
|
8247
|
+
this.name = "TpsSensor";
|
|
8248
|
+
this.order = sensor_bands_1.BAND.POLICY + 2;
|
|
8249
|
+
this.maxDriftMs = options.maxDriftMs ?? 3e4;
|
|
8250
|
+
this.resolver = options.resolver ?? parseINotation;
|
|
8251
|
+
}
|
|
8252
|
+
supports(input) {
|
|
8253
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8254
|
+
return typeof tps === "string" && tps.length > 0;
|
|
8255
|
+
}
|
|
8256
|
+
async run(input) {
|
|
8257
|
+
const tps = input.metadata?.tps_coordinate ?? input.metadata?.tps ?? input.packet?.tps;
|
|
8258
|
+
const resolved = this.resolver(tps);
|
|
8259
|
+
if (resolved === null) {
|
|
8260
|
+
return {
|
|
8261
|
+
allow: false,
|
|
8262
|
+
riskScore: 80,
|
|
8263
|
+
reasons: [`TPS coordinate '${tps}' is structurally invalid`],
|
|
8264
|
+
code: "TPS_INVALID_FORMAT"
|
|
8265
|
+
};
|
|
8266
|
+
}
|
|
8267
|
+
const now = Date.now();
|
|
8268
|
+
const drift = Math.abs(now - resolved);
|
|
8269
|
+
if (drift > this.maxDriftMs) {
|
|
8270
|
+
const direction = resolved > now ? "future" : "past";
|
|
8271
|
+
return {
|
|
8272
|
+
allow: false,
|
|
8273
|
+
riskScore: 70,
|
|
8274
|
+
reasons: [
|
|
8275
|
+
`TPS drift ${drift}ms exceeds max ${this.maxDriftMs}ms (${direction})`
|
|
8276
|
+
],
|
|
8277
|
+
code: "TPS_DRIFT_EXCEEDED",
|
|
8278
|
+
tags: { tpsDriftMs: drift, tpsDirection: direction }
|
|
8279
|
+
};
|
|
8280
|
+
}
|
|
8281
|
+
return {
|
|
8282
|
+
allow: true,
|
|
8283
|
+
riskScore: 0,
|
|
8284
|
+
reasons: [],
|
|
8285
|
+
tags: {
|
|
8286
|
+
tpsResolved: resolved,
|
|
8287
|
+
tpsDriftMs: drift
|
|
8288
|
+
}
|
|
8289
|
+
};
|
|
8290
|
+
}
|
|
8291
|
+
};
|
|
8292
|
+
exports2.TpsSensor = TpsSensor2;
|
|
8293
|
+
exports2.TpsSensor = TpsSensor2 = __decorate([
|
|
8294
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8295
|
+
(0, common_1.Injectable)(),
|
|
8296
|
+
__metadata("design:paramtypes", [Object])
|
|
8297
|
+
], TpsSensor2);
|
|
8298
|
+
}
|
|
8299
|
+
});
|
|
8300
|
+
|
|
8301
|
+
// src/sensors/risk-gate.sensor.ts
|
|
8302
|
+
var require_risk_gate_sensor = __commonJS({
|
|
8303
|
+
"src/sensors/risk-gate.sensor.ts"(exports2) {
|
|
8304
|
+
"use strict";
|
|
8305
|
+
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
8306
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8307
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8308
|
+
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;
|
|
8309
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8310
|
+
};
|
|
8311
|
+
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
8312
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8313
|
+
};
|
|
8314
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8315
|
+
exports2.RiskGateSensor = void 0;
|
|
8316
|
+
var common_1 = require("@nestjs/common");
|
|
8317
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8318
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8319
|
+
var risk_1 = (init_risk(), __toCommonJS(risk_exports));
|
|
8320
|
+
var SEVERITY_WEIGHT = {
|
|
8321
|
+
low: 10,
|
|
8322
|
+
medium: 25,
|
|
8323
|
+
high: 50,
|
|
8324
|
+
critical: 100
|
|
8325
|
+
};
|
|
8326
|
+
var RiskGateSensor2 = class RiskGateSensor {
|
|
8327
|
+
constructor(options) {
|
|
8328
|
+
this.name = "RiskGateSensor";
|
|
8329
|
+
this.order = sensor_bands_1.BAND.BUSINESS + 10;
|
|
8330
|
+
this.collectors = options.collectors;
|
|
8331
|
+
this.denyThreshold = options.denyThreshold ?? 75;
|
|
8332
|
+
this.flagThreshold = options.flagThreshold ?? 40;
|
|
8333
|
+
}
|
|
8334
|
+
async run(input) {
|
|
8335
|
+
const results = await Promise.all(this.collectors.map((c) => c(input)));
|
|
8336
|
+
const signals = results.flat();
|
|
8337
|
+
let totalWeight = 0;
|
|
8338
|
+
let weightedSum = 0;
|
|
8339
|
+
for (const signal of signals) {
|
|
8340
|
+
const w = SEVERITY_WEIGHT[signal.severity];
|
|
8341
|
+
totalWeight += 1;
|
|
8342
|
+
weightedSum += w;
|
|
8343
|
+
}
|
|
8344
|
+
const aggregateScore = totalWeight > 0 ? Math.min(100, Math.round(weightedSum / totalWeight)) : 0;
|
|
8345
|
+
const evaluation = this.evaluate(aggregateScore, signals);
|
|
8346
|
+
input.metadata = {
|
|
8347
|
+
...input.metadata ?? {},
|
|
8348
|
+
riskEvaluation: evaluation
|
|
8349
|
+
};
|
|
8350
|
+
if (evaluation.decision === risk_1.RiskDecision.DENY) {
|
|
8351
|
+
return {
|
|
8352
|
+
allow: false,
|
|
8353
|
+
riskScore: aggregateScore,
|
|
8354
|
+
reasons: signals.map((s) => s.message),
|
|
8355
|
+
code: "RISK_GATE_DENY",
|
|
8356
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8357
|
+
};
|
|
8358
|
+
}
|
|
8359
|
+
if (evaluation.decision === risk_1.RiskDecision.THROTTLE) {
|
|
8360
|
+
return {
|
|
8361
|
+
allow: false,
|
|
8362
|
+
riskScore: aggregateScore,
|
|
8363
|
+
reasons: signals.map((s) => s.message),
|
|
8364
|
+
code: "RISK_GATE_THROTTLE",
|
|
8365
|
+
retryAfterMs: evaluation.retryAfterMs,
|
|
8366
|
+
tags: { riskDecision: evaluation.decision, signalCount: signals.length }
|
|
8367
|
+
};
|
|
8368
|
+
}
|
|
8369
|
+
return {
|
|
8370
|
+
allow: true,
|
|
8371
|
+
riskScore: aggregateScore,
|
|
8372
|
+
reasons: signals.filter((s) => s.severity === "medium" || s.severity === "high").map((s) => s.message),
|
|
8373
|
+
tags: {
|
|
8374
|
+
riskDecision: evaluation.decision,
|
|
8375
|
+
signalCount: signals.length
|
|
8376
|
+
}
|
|
8377
|
+
};
|
|
8378
|
+
}
|
|
8379
|
+
evaluate(score, signals) {
|
|
8380
|
+
const hasCritical = signals.some((s) => s.severity === "critical");
|
|
8381
|
+
if (hasCritical) {
|
|
8382
|
+
return {
|
|
8383
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8384
|
+
reason: "Critical risk signal detected",
|
|
8385
|
+
confidence: 1,
|
|
8386
|
+
signals
|
|
8387
|
+
};
|
|
8388
|
+
}
|
|
8389
|
+
if (score >= this.denyThreshold) {
|
|
8390
|
+
return {
|
|
8391
|
+
decision: risk_1.RiskDecision.DENY,
|
|
8392
|
+
reason: `Aggregate risk score ${score} exceeds deny threshold ${this.denyThreshold}`,
|
|
8393
|
+
confidence: score / 100,
|
|
8394
|
+
signals
|
|
8395
|
+
};
|
|
8396
|
+
}
|
|
8397
|
+
if (score >= this.flagThreshold) {
|
|
8398
|
+
return {
|
|
8399
|
+
decision: risk_1.RiskDecision.STEP_UP,
|
|
8400
|
+
reason: `Aggregate risk score ${score} exceeds flag threshold ${this.flagThreshold}`,
|
|
8401
|
+
confidence: score / 100,
|
|
8402
|
+
signals
|
|
8403
|
+
};
|
|
8404
|
+
}
|
|
8405
|
+
return {
|
|
8406
|
+
decision: risk_1.RiskDecision.ALLOW,
|
|
8407
|
+
confidence: 1 - score / 100,
|
|
8408
|
+
signals
|
|
8409
|
+
};
|
|
8410
|
+
}
|
|
8411
|
+
};
|
|
8412
|
+
exports2.RiskGateSensor = RiskGateSensor2;
|
|
8413
|
+
exports2.RiskGateSensor = RiskGateSensor2 = __decorate([
|
|
8414
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8415
|
+
(0, common_1.Injectable)(),
|
|
8416
|
+
__metadata("design:paramtypes", [Object])
|
|
8417
|
+
], RiskGateSensor2);
|
|
8418
|
+
}
|
|
8419
|
+
});
|
|
8420
|
+
|
|
8421
|
+
// src/sensors/tickauth.sensor.ts
|
|
8422
|
+
var require_tickauth_sensor = __commonJS({
|
|
8423
|
+
"src/sensors/tickauth.sensor.ts"(exports2) {
|
|
8424
|
+
"use strict";
|
|
8425
|
+
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
8426
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8427
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8428
|
+
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;
|
|
8429
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8430
|
+
};
|
|
8431
|
+
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
8432
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
8433
|
+
};
|
|
8434
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8435
|
+
exports2.TickAuthSensor = void 0;
|
|
8436
|
+
var common_1 = require("@nestjs/common");
|
|
8437
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
8438
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
8439
|
+
var TickAuthSensor2 = class TickAuthSensor {
|
|
8440
|
+
constructor(options = {}) {
|
|
8441
|
+
this.name = "TickAuthSensor";
|
|
8442
|
+
this.order = sensor_bands_1.BAND.IDENTITY + 40;
|
|
8443
|
+
this.verifier = options.verifier;
|
|
8444
|
+
this.matchIntent = options.matchIntent ?? true;
|
|
8445
|
+
this.acceptTypes = options.acceptTypes?.length ? new Set(options.acceptTypes) : null;
|
|
8446
|
+
}
|
|
8447
|
+
supports(input) {
|
|
8448
|
+
return !!(input.metadata?.capsule || input.metadata?.tickauthCapsule || input.metadata?.cceEnvelope?.capsule);
|
|
8449
|
+
}
|
|
8450
|
+
async run(input) {
|
|
8451
|
+
const capsule = input.metadata?.capsule ?? input.metadata?.tickauthCapsule ?? input.metadata?.cceEnvelope?.capsule;
|
|
8452
|
+
if (!capsule) {
|
|
8453
|
+
return {
|
|
8454
|
+
allow: false,
|
|
8455
|
+
riskScore: 90,
|
|
8456
|
+
reasons: ["TickAuth capsule not found"],
|
|
8457
|
+
code: "TICKAUTH_MISSING"
|
|
8458
|
+
};
|
|
8459
|
+
}
|
|
8460
|
+
if (!capsule.capsule_id || typeof capsule.capsule_id !== "string") {
|
|
8461
|
+
return {
|
|
8462
|
+
allow: false,
|
|
8463
|
+
riskScore: 100,
|
|
8464
|
+
reasons: ["TickAuth capsule has no valid capsule_id"],
|
|
8465
|
+
code: "TICKAUTH_INVALID_ID"
|
|
8466
|
+
};
|
|
8467
|
+
}
|
|
8468
|
+
const status = capsule.verification?.status;
|
|
8469
|
+
if (status && status !== "approved") {
|
|
8470
|
+
return {
|
|
8471
|
+
allow: false,
|
|
8472
|
+
riskScore: 100,
|
|
8473
|
+
reasons: [
|
|
8474
|
+
`TickAuth capsule status is '${status}'${capsule.verification?.reason ? `: ${capsule.verification.reason}` : ""}`
|
|
8475
|
+
],
|
|
8476
|
+
code: `TICKAUTH_STATUS_${status.toUpperCase()}`
|
|
8477
|
+
};
|
|
8478
|
+
}
|
|
8479
|
+
if (this.acceptTypes && capsule.capsule_type) {
|
|
8480
|
+
if (!this.acceptTypes.has(capsule.capsule_type)) {
|
|
8481
|
+
return {
|
|
8482
|
+
allow: false,
|
|
8483
|
+
riskScore: 80,
|
|
8484
|
+
reasons: [
|
|
8485
|
+
`TickAuth capsule type '${capsule.capsule_type}' is not in accept list`
|
|
8486
|
+
],
|
|
8487
|
+
code: "TICKAUTH_TYPE_REJECTED"
|
|
8488
|
+
};
|
|
8489
|
+
}
|
|
8490
|
+
}
|
|
8491
|
+
if (this.matchIntent && input.intent && capsule.intent) {
|
|
8492
|
+
if (capsule.intent !== input.intent) {
|
|
8493
|
+
return {
|
|
8494
|
+
allow: false,
|
|
8495
|
+
riskScore: 80,
|
|
8496
|
+
reasons: [
|
|
8497
|
+
`TickAuth capsule intent '${capsule.intent}' does not match AXIS intent '${input.intent}'`
|
|
8498
|
+
],
|
|
8499
|
+
code: "TICKAUTH_INTENT_MISMATCH"
|
|
8500
|
+
};
|
|
8501
|
+
}
|
|
8502
|
+
}
|
|
8503
|
+
if (this.verifier) {
|
|
8504
|
+
const error = await this.verifier(capsule, input);
|
|
8505
|
+
if (error) {
|
|
8506
|
+
return {
|
|
8507
|
+
allow: false,
|
|
8508
|
+
riskScore: 90,
|
|
8509
|
+
reasons: [`TickAuth verification failed: ${error}`],
|
|
8510
|
+
code: "TICKAUTH_VERIFY_FAILED"
|
|
8511
|
+
};
|
|
8512
|
+
}
|
|
8513
|
+
}
|
|
8514
|
+
return {
|
|
8515
|
+
allow: true,
|
|
8516
|
+
riskScore: 0,
|
|
8517
|
+
reasons: [],
|
|
8518
|
+
tags: {
|
|
8519
|
+
tickauthCapsuleId: capsule.capsule_id,
|
|
8520
|
+
tickauthMode: capsule.mode,
|
|
8521
|
+
tickauthSingleUse: capsule.single_use
|
|
8522
|
+
}
|
|
8523
|
+
};
|
|
8524
|
+
}
|
|
8525
|
+
};
|
|
8526
|
+
exports2.TickAuthSensor = TickAuthSensor2;
|
|
8527
|
+
exports2.TickAuthSensor = TickAuthSensor2 = __decorate([
|
|
8528
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
8529
|
+
(0, common_1.Injectable)(),
|
|
8530
|
+
__metadata("design:paramtypes", [Object])
|
|
8531
|
+
], TickAuthSensor2);
|
|
6202
8532
|
}
|
|
6203
8533
|
});
|
|
6204
8534
|
|
|
@@ -7010,95 +9340,18 @@ var init_cce = __esm({
|
|
|
7010
9340
|
// src/core/index.ts
|
|
7011
9341
|
var core_exports = {};
|
|
7012
9342
|
__export(core_exports, {
|
|
7013
|
-
AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
|
|
7014
|
-
AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
|
|
7015
9343
|
AxisError: () => AxisError,
|
|
7016
9344
|
AxisFrameZ: () => AxisFrameZ,
|
|
7017
|
-
AxisMediaTypes: () => AxisMediaTypes,
|
|
7018
|
-
BodyProfile: () => import_axis_protocol2.BodyProfile,
|
|
7019
|
-
ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
|
|
7020
|
-
ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
|
|
7021
|
-
ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
|
|
7022
|
-
ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
|
|
7023
|
-
FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
|
|
7024
|
-
FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
|
|
7025
|
-
FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
|
|
7026
|
-
MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
|
|
7027
|
-
MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
|
|
7028
|
-
MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
|
|
7029
|
-
MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
|
|
7030
|
-
NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
|
|
7031
|
-
NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
|
|
7032
|
-
NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
|
|
7033
|
-
NCERT_KID: () => import_axis_protocol2.NCERT_KID,
|
|
7034
|
-
NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
|
|
7035
|
-
NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
|
|
7036
|
-
NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
|
|
7037
|
-
NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
|
|
7038
|
-
NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
|
|
7039
|
-
NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
|
|
7040
|
-
PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
|
|
7041
|
-
PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
|
|
7042
|
-
PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
|
|
7043
|
-
PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
|
|
7044
|
-
PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
|
|
7045
|
-
PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
|
|
7046
|
-
ProofType: () => import_axis_protocol2.ProofType,
|
|
7047
|
-
TLV: () => import_axis_protocol.TLV,
|
|
7048
|
-
TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
|
|
7049
|
-
TLV_AUD: () => import_axis_protocol2.TLV_AUD,
|
|
7050
|
-
TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
|
|
7051
|
-
TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
|
|
7052
|
-
TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
|
|
7053
|
-
TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
|
|
7054
|
-
TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
|
|
7055
|
-
TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
|
|
7056
|
-
TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
|
|
7057
|
-
TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
|
|
7058
|
-
TLV_KID: () => import_axis_protocol2.TLV_KID,
|
|
7059
|
-
TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
|
|
7060
|
-
TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
|
|
7061
|
-
TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
|
|
7062
|
-
TLV_NODE: () => import_axis_protocol2.TLV_NODE,
|
|
7063
|
-
TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
|
|
7064
|
-
TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
|
|
7065
|
-
TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
|
|
7066
|
-
TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
|
|
7067
|
-
TLV_OK: () => import_axis_protocol2.TLV_OK,
|
|
7068
|
-
TLV_PID: () => import_axis_protocol2.TLV_PID,
|
|
7069
|
-
TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
|
|
7070
|
-
TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
|
|
7071
|
-
TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
|
|
7072
|
-
TLV_REALM: () => import_axis_protocol2.TLV_REALM,
|
|
7073
|
-
TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
|
|
7074
|
-
TLV_RID: () => import_axis_protocol2.TLV_RID,
|
|
7075
|
-
TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
|
|
7076
|
-
TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
|
|
7077
|
-
TLV_TS: () => import_axis_protocol2.TLV_TS,
|
|
7078
|
-
TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID,
|
|
7079
9345
|
computeReceiptHash: () => computeReceiptHash,
|
|
7080
9346
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
7081
|
-
decodeArray: () => import_axis_protocol.decodeArray,
|
|
7082
|
-
decodeFrame: () => decodeFrame,
|
|
7083
|
-
decodeObject: () => import_axis_protocol.decodeObject,
|
|
7084
|
-
decodeTLVs: () => import_axis_protocol.decodeTLVs,
|
|
7085
|
-
decodeTLVsList: () => import_axis_protocol.decodeTLVsList,
|
|
7086
|
-
decodeVarint: () => import_axis_protocol3.decodeVarint,
|
|
7087
|
-
encodeFrame: () => encodeFrame,
|
|
7088
|
-
encodeTLVs: () => import_axis_protocol.encodeTLVs,
|
|
7089
|
-
encodeVarint: () => import_axis_protocol3.encodeVarint,
|
|
7090
9347
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
7091
|
-
getSignTarget: () => getSignTarget,
|
|
7092
9348
|
sha256: () => sha2564,
|
|
7093
9349
|
signFrame: () => signFrame,
|
|
7094
|
-
varintLength: () => import_axis_protocol3.varintLength,
|
|
7095
9350
|
verifyFrameSignature: () => verifyFrameSignature
|
|
7096
9351
|
});
|
|
7097
9352
|
var init_core = __esm({
|
|
7098
9353
|
"src/core/index.ts"() {
|
|
7099
|
-
|
|
7100
|
-
init_varint();
|
|
7101
|
-
init_tlv();
|
|
9354
|
+
__reExport(core_exports, require("@nextera.one/axis-protocol"));
|
|
7102
9355
|
init_axis_bin();
|
|
7103
9356
|
init_signature();
|
|
7104
9357
|
init_axis_error();
|
|
@@ -7331,14 +9584,6 @@ __export(decorators_exports, {
|
|
|
7331
9584
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
7332
9585
|
Sensitivity: () => Sensitivity,
|
|
7333
9586
|
Sensor: () => Sensor,
|
|
7334
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
7335
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
7336
|
-
TlvEnum: () => TlvEnum,
|
|
7337
|
-
TlvField: () => TlvField,
|
|
7338
|
-
TlvMinLen: () => TlvMinLen,
|
|
7339
|
-
TlvRange: () => TlvRange,
|
|
7340
|
-
TlvUtf8Pattern: () => TlvUtf8Pattern,
|
|
7341
|
-
TlvValidate: () => TlvValidate,
|
|
7342
9587
|
Witness: () => Witness,
|
|
7343
9588
|
mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
|
|
7344
9589
|
normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
|
|
@@ -7356,7 +9601,7 @@ var init_decorators = __esm({
|
|
|
7356
9601
|
init_intent_decorator();
|
|
7357
9602
|
init_observer_decorator();
|
|
7358
9603
|
init_sensor_decorator();
|
|
7359
|
-
|
|
9604
|
+
__reExport(decorators_exports, __toESM(require_tlv_field_decorator()));
|
|
7360
9605
|
}
|
|
7361
9606
|
});
|
|
7362
9607
|
|
|
@@ -7457,6 +9702,25 @@ var init_engine = __esm({
|
|
|
7457
9702
|
}
|
|
7458
9703
|
});
|
|
7459
9704
|
|
|
9705
|
+
// src/idel/idel.types.ts
|
|
9706
|
+
var init_idel_types = __esm({
|
|
9707
|
+
"src/idel/idel.types.ts"() {
|
|
9708
|
+
}
|
|
9709
|
+
});
|
|
9710
|
+
|
|
9711
|
+
// src/idel/index.ts
|
|
9712
|
+
var idel_exports = {};
|
|
9713
|
+
__export(idel_exports, {
|
|
9714
|
+
IdelCompiler: () => IdelCompiler,
|
|
9715
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry
|
|
9716
|
+
});
|
|
9717
|
+
var init_idel = __esm({
|
|
9718
|
+
"src/idel/index.ts"() {
|
|
9719
|
+
init_idel_types();
|
|
9720
|
+
init_idel_compiler();
|
|
9721
|
+
}
|
|
9722
|
+
});
|
|
9723
|
+
|
|
7460
9724
|
// src/loom/index.ts
|
|
7461
9725
|
var loom_exports = {};
|
|
7462
9726
|
__export(loom_exports, {
|
|
@@ -7466,11 +9730,98 @@ __export(loom_exports, {
|
|
|
7466
9730
|
TLV_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
|
|
7467
9731
|
canonicalizeGrant: () => canonicalizeGrant,
|
|
7468
9732
|
canonicalizeWrit: () => canonicalizeWrit,
|
|
7469
|
-
|
|
9733
|
+
createGrant: () => createGrant,
|
|
9734
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
9735
|
+
createReceipt: () => createReceipt,
|
|
9736
|
+
createRevocation: () => createRevocation,
|
|
9737
|
+
createWrit: () => createWrit,
|
|
9738
|
+
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
9739
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9740
|
+
getGrantStatus: () => getGrantStatus,
|
|
9741
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
9742
|
+
grantCoversAction: () => grantCoversAction,
|
|
9743
|
+
isRevoked: () => isRevoked,
|
|
9744
|
+
renewPresence: () => renewPresence,
|
|
9745
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9746
|
+
updateThreadState: () => updateThreadState,
|
|
9747
|
+
validateGrant: () => validateGrant,
|
|
9748
|
+
validateWrit: () => validateWrit,
|
|
9749
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
9750
|
+
verifyReceiptChain: () => verifyReceiptChain
|
|
7470
9751
|
});
|
|
7471
9752
|
var init_loom = __esm({
|
|
7472
9753
|
"src/loom/index.ts"() {
|
|
7473
9754
|
init_loom_types();
|
|
9755
|
+
init_loom_engine();
|
|
9756
|
+
}
|
|
9757
|
+
});
|
|
9758
|
+
|
|
9759
|
+
// src/needle/needle.types.ts
|
|
9760
|
+
var init_needle_types = __esm({
|
|
9761
|
+
"src/needle/needle.types.ts"() {
|
|
9762
|
+
}
|
|
9763
|
+
});
|
|
9764
|
+
|
|
9765
|
+
// src/needle/knot.types.ts
|
|
9766
|
+
var init_knot_types = __esm({
|
|
9767
|
+
"src/needle/knot.types.ts"() {
|
|
9768
|
+
}
|
|
9769
|
+
});
|
|
9770
|
+
|
|
9771
|
+
// src/needle/fabric.types.ts
|
|
9772
|
+
var init_fabric_types = __esm({
|
|
9773
|
+
"src/needle/fabric.types.ts"() {
|
|
9774
|
+
}
|
|
9775
|
+
});
|
|
9776
|
+
|
|
9777
|
+
// src/needle/pattern.types.ts
|
|
9778
|
+
var init_pattern_types = __esm({
|
|
9779
|
+
"src/needle/pattern.types.ts"() {
|
|
9780
|
+
}
|
|
9781
|
+
});
|
|
9782
|
+
|
|
9783
|
+
// src/needle/index.ts
|
|
9784
|
+
var needle_exports = {};
|
|
9785
|
+
__export(needle_exports, {
|
|
9786
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
9787
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
9788
|
+
applyStitch: () => applyStitch,
|
|
9789
|
+
assembleNeedle: () => assembleNeedle,
|
|
9790
|
+
breakKnot: () => breakKnot,
|
|
9791
|
+
createFabric: () => createFabric,
|
|
9792
|
+
detectAnomalies: () => detectAnomalies,
|
|
9793
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
9794
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
9795
|
+
diffFabrics: () => diffFabrics,
|
|
9796
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
9797
|
+
forkFromKnot: () => forkFromKnot,
|
|
9798
|
+
formStitch: () => formStitch,
|
|
9799
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
9800
|
+
getFabricValue: () => getFabricValue,
|
|
9801
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
9802
|
+
isKnotOpen: () => isKnotOpen,
|
|
9803
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
9804
|
+
lockCells: () => lockCells,
|
|
9805
|
+
matchPatterns: () => matchPatterns,
|
|
9806
|
+
openKnot: () => openKnot,
|
|
9807
|
+
projectAt: () => projectAt,
|
|
9808
|
+
queryFabric: () => queryFabric,
|
|
9809
|
+
recordOccurrence: () => recordOccurrence,
|
|
9810
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9811
|
+
tieKnot: () => tieKnot,
|
|
9812
|
+
validateKnot: () => validateKnot,
|
|
9813
|
+
weave: () => weave
|
|
9814
|
+
});
|
|
9815
|
+
var init_needle = __esm({
|
|
9816
|
+
"src/needle/index.ts"() {
|
|
9817
|
+
init_needle_types();
|
|
9818
|
+
init_needle_engine();
|
|
9819
|
+
init_knot_types();
|
|
9820
|
+
init_knot_engine();
|
|
9821
|
+
init_fabric_types();
|
|
9822
|
+
init_fabric_engine();
|
|
9823
|
+
init_pattern_types();
|
|
9824
|
+
init_pattern_engine();
|
|
7474
9825
|
}
|
|
7475
9826
|
});
|
|
7476
9827
|
|
|
@@ -8719,6 +11070,143 @@ var require_intent_registry_sensor = __commonJS({
|
|
|
8719
11070
|
}
|
|
8720
11071
|
});
|
|
8721
11072
|
|
|
11073
|
+
// src/sensors/law-evaluation.sensor.ts
|
|
11074
|
+
var require_law_evaluation_sensor = __commonJS({
|
|
11075
|
+
"src/sensors/law-evaluation.sensor.ts"(exports2) {
|
|
11076
|
+
"use strict";
|
|
11077
|
+
var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
|
|
11078
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11079
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11080
|
+
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;
|
|
11081
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11082
|
+
};
|
|
11083
|
+
var __metadata = exports2 && exports2.__metadata || function(k, v) {
|
|
11084
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11085
|
+
};
|
|
11086
|
+
var LawEvaluationSensor_1;
|
|
11087
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11088
|
+
exports2.LawEvaluationSensor = void 0;
|
|
11089
|
+
var common_1 = require("@nestjs/common");
|
|
11090
|
+
var sensor_decorator_1 = (init_sensor_decorator(), __toCommonJS(sensor_decorator_exports));
|
|
11091
|
+
var sensor_bands_1 = (init_sensor_bands(), __toCommonJS(sensor_bands_exports));
|
|
11092
|
+
var law_1 = (init_law(), __toCommonJS(law_exports));
|
|
11093
|
+
var LawEvaluationSensor = LawEvaluationSensor_1 = class LawEvaluationSensor {
|
|
11094
|
+
constructor(options = {}) {
|
|
11095
|
+
this.options = options;
|
|
11096
|
+
this.logger = new common_1.Logger(LawEvaluationSensor_1.name);
|
|
11097
|
+
this.name = "LawEvaluationSensor";
|
|
11098
|
+
this.order = sensor_bands_1.BAND.POLICY + 5;
|
|
11099
|
+
}
|
|
11100
|
+
supports(input) {
|
|
11101
|
+
return !!this.options.evaluator && !!input.intent;
|
|
11102
|
+
}
|
|
11103
|
+
async run(input) {
|
|
11104
|
+
const evaluator = this.options.evaluator;
|
|
11105
|
+
if (!evaluator) {
|
|
11106
|
+
return { action: "ALLOW" };
|
|
11107
|
+
}
|
|
11108
|
+
const context = (0, law_1.buildAxisLawEvaluationContext)(input);
|
|
11109
|
+
let result;
|
|
11110
|
+
try {
|
|
11111
|
+
result = await evaluator(context);
|
|
11112
|
+
} catch (error) {
|
|
11113
|
+
const message = error instanceof Error ? error.message : "Unknown law evaluation error";
|
|
11114
|
+
this.logger.error(`Law evaluation failed for ${input.intent}: ${message}`);
|
|
11115
|
+
input.metadata = {
|
|
11116
|
+
...input.metadata ?? {},
|
|
11117
|
+
lawEvaluation: {
|
|
11118
|
+
decision: "deny",
|
|
11119
|
+
reason: "Law evaluation failed",
|
|
11120
|
+
explanation: message
|
|
11121
|
+
}
|
|
11122
|
+
};
|
|
11123
|
+
return {
|
|
11124
|
+
action: "DENY",
|
|
11125
|
+
code: "LAW_EVALUATION_ERROR",
|
|
11126
|
+
reason: message,
|
|
11127
|
+
meta: { lawDecision: "deny" }
|
|
11128
|
+
};
|
|
11129
|
+
}
|
|
11130
|
+
input.metadata = {
|
|
11131
|
+
...input.metadata ?? {},
|
|
11132
|
+
lawEvaluation: {
|
|
11133
|
+
...result,
|
|
11134
|
+
context: sanitizeLawContext(context)
|
|
11135
|
+
}
|
|
11136
|
+
};
|
|
11137
|
+
if (result.decision === "allow") {
|
|
11138
|
+
return {
|
|
11139
|
+
allow: true,
|
|
11140
|
+
riskScore: 0,
|
|
11141
|
+
reasons: result.reason ? [result.reason] : [],
|
|
11142
|
+
tags: {
|
|
11143
|
+
lawDecision: "allow",
|
|
11144
|
+
...result.applicable ? { lawApplicableArticles: result.applicable.length } : {}
|
|
11145
|
+
},
|
|
11146
|
+
meta: result
|
|
11147
|
+
};
|
|
11148
|
+
}
|
|
11149
|
+
if (result.decision === "conditional") {
|
|
11150
|
+
const mode = this.options.conditionalDecision ?? "deny";
|
|
11151
|
+
const reasons = [result.reason, result.explanation].filter(Boolean);
|
|
11152
|
+
if (mode === "allow") {
|
|
11153
|
+
return {
|
|
11154
|
+
allow: true,
|
|
11155
|
+
riskScore: 0,
|
|
11156
|
+
reasons,
|
|
11157
|
+
tags: {
|
|
11158
|
+
lawDecision: "conditional"
|
|
11159
|
+
},
|
|
11160
|
+
meta: result
|
|
11161
|
+
};
|
|
11162
|
+
}
|
|
11163
|
+
if (mode === "flag") {
|
|
11164
|
+
return {
|
|
11165
|
+
action: "FLAG",
|
|
11166
|
+
scoreDelta: 25,
|
|
11167
|
+
reasons: reasons.length > 0 ? reasons : ["Execution is conditionally permitted pending additional requirements"],
|
|
11168
|
+
meta: result
|
|
11169
|
+
};
|
|
11170
|
+
}
|
|
11171
|
+
return {
|
|
11172
|
+
action: "DENY",
|
|
11173
|
+
code: "LAW_CONDITIONAL",
|
|
11174
|
+
reason: reasons.join(" | ") || "Execution is conditionally permitted pending additional requirements",
|
|
11175
|
+
meta: { lawDecision: "conditional", evaluation: result }
|
|
11176
|
+
};
|
|
11177
|
+
}
|
|
11178
|
+
return {
|
|
11179
|
+
action: "DENY",
|
|
11180
|
+
code: "LAW_DENIED",
|
|
11181
|
+
reason: [result.reason, result.explanation].filter(Boolean).join(" | ") || "Execution denied by law evaluation",
|
|
11182
|
+
meta: { lawDecision: "deny", evaluation: result }
|
|
11183
|
+
};
|
|
11184
|
+
}
|
|
11185
|
+
};
|
|
11186
|
+
exports2.LawEvaluationSensor = LawEvaluationSensor;
|
|
11187
|
+
exports2.LawEvaluationSensor = LawEvaluationSensor = LawEvaluationSensor_1 = __decorate([
|
|
11188
|
+
(0, sensor_decorator_1.Sensor)(),
|
|
11189
|
+
(0, common_1.Injectable)(),
|
|
11190
|
+
__metadata("design:paramtypes", [Object])
|
|
11191
|
+
], LawEvaluationSensor);
|
|
11192
|
+
function sanitizeLawContext(context) {
|
|
11193
|
+
return {
|
|
11194
|
+
actorId: context.actorId,
|
|
11195
|
+
intent: context.intent,
|
|
11196
|
+
audience: context.audience,
|
|
11197
|
+
tps: context.tps,
|
|
11198
|
+
country: context.country,
|
|
11199
|
+
ip: context.ip,
|
|
11200
|
+
path: context.path,
|
|
11201
|
+
clientId: context.clientId,
|
|
11202
|
+
deviceId: context.deviceId,
|
|
11203
|
+
sessionId: context.sessionId,
|
|
11204
|
+
capsuleId: context.capsuleId
|
|
11205
|
+
};
|
|
11206
|
+
}
|
|
11207
|
+
}
|
|
11208
|
+
});
|
|
11209
|
+
|
|
8722
11210
|
// src/sensors/proof-presence.sensor.ts
|
|
8723
11211
|
var require_proof_presence_sensor = __commonJS({
|
|
8724
11212
|
"src/sensors/proof-presence.sensor.ts"(exports2) {
|
|
@@ -9421,16 +11909,40 @@ var init_sensors2 = __esm({
|
|
|
9421
11909
|
__reExport(sensors_exports, __toESM(require_header_tlv_limit_sensor()));
|
|
9422
11910
|
__reExport(sensors_exports, __toESM(require_intent_allowlist_sensor()));
|
|
9423
11911
|
__reExport(sensors_exports, __toESM(require_intent_registry_sensor()));
|
|
11912
|
+
__reExport(sensors_exports, __toESM(require_law_evaluation_sensor()));
|
|
9424
11913
|
__reExport(sensors_exports, __toESM(require_proof_presence_sensor()));
|
|
9425
11914
|
__reExport(sensors_exports, __toESM(require_protocol_strict_sensor()));
|
|
9426
11915
|
__reExport(sensors_exports, __toESM(require_receipt_policy_sensor()));
|
|
11916
|
+
__reExport(sensors_exports, __toESM(require_risk_gate_sensor()));
|
|
9427
11917
|
__reExport(sensors_exports, __toESM(require_schema_validation_sensor()));
|
|
9428
11918
|
__reExport(sensors_exports, __toESM(require_stream_scope_sensor()));
|
|
11919
|
+
__reExport(sensors_exports, __toESM(require_tickauth_sensor()));
|
|
9429
11920
|
__reExport(sensors_exports, __toESM(require_tlv_parse_sensor()));
|
|
11921
|
+
__reExport(sensors_exports, __toESM(require_tps_sensor()));
|
|
9430
11922
|
__reExport(sensors_exports, __toESM(require_varint_hardening_sensor()));
|
|
9431
11923
|
}
|
|
9432
11924
|
});
|
|
9433
11925
|
|
|
11926
|
+
// src/timeline/timeline.types.ts
|
|
11927
|
+
var init_timeline_types = __esm({
|
|
11928
|
+
"src/timeline/timeline.types.ts"() {
|
|
11929
|
+
}
|
|
11930
|
+
});
|
|
11931
|
+
|
|
11932
|
+
// src/timeline/index.ts
|
|
11933
|
+
var timeline_exports = {};
|
|
11934
|
+
__export(timeline_exports, {
|
|
11935
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
11936
|
+
TimelineEngine: () => TimelineEngine
|
|
11937
|
+
});
|
|
11938
|
+
var init_timeline = __esm({
|
|
11939
|
+
"src/timeline/index.ts"() {
|
|
11940
|
+
init_timeline_types();
|
|
11941
|
+
init_timeline_store();
|
|
11942
|
+
init_timeline_engine();
|
|
11943
|
+
}
|
|
11944
|
+
});
|
|
11945
|
+
|
|
9434
11946
|
// src/utils/index.ts
|
|
9435
11947
|
var utils_exports = {};
|
|
9436
11948
|
__export(utils_exports, {
|
|
@@ -9519,6 +12031,10 @@ __export(index_exports, {
|
|
|
9519
12031
|
INTENT_SENSITIVITY_MAP: () => INTENT_SENSITIVITY_MAP,
|
|
9520
12032
|
INTENT_SENSORS_KEY: () => INTENT_SENSORS_KEY,
|
|
9521
12033
|
INTENT_TIMEOUTS: () => INTENT_TIMEOUTS,
|
|
12034
|
+
IdelCompiler: () => IdelCompiler,
|
|
12035
|
+
IdelSchemaRegistry: () => IdelSchemaRegistry,
|
|
12036
|
+
InMemoryPatternStore: () => InMemoryPatternStore,
|
|
12037
|
+
InMemoryTimelineStore: () => InMemoryTimelineStore,
|
|
9522
12038
|
Intent: () => Intent,
|
|
9523
12039
|
IntentBody: () => IntentBody,
|
|
9524
12040
|
IntentRouter: () => import_intent2.IntentRouter,
|
|
@@ -9562,6 +12078,7 @@ __export(index_exports, {
|
|
|
9562
12078
|
RequiredProof: () => RequiredProof,
|
|
9563
12079
|
ResponseObserver: () => ResponseObserver,
|
|
9564
12080
|
RiskDecision: () => RiskDecision,
|
|
12081
|
+
RiskGateSensor: () => import_risk_gate.RiskGateSensor,
|
|
9565
12082
|
SENSITIVITY_METADATA_KEY: () => SENSITIVITY_METADATA_KEY,
|
|
9566
12083
|
SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
|
|
9567
12084
|
Schema2002_PasskeyLoginOptionsRes: () => Schema2002_PasskeyLoginOptionsRes,
|
|
@@ -9582,7 +12099,7 @@ __export(index_exports, {
|
|
|
9582
12099
|
TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
|
|
9583
12100
|
TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
|
|
9584
12101
|
TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
|
|
9585
|
-
TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
|
|
12102
|
+
TLV_FIELDS_KEY: () => import_tlv_field2.TLV_FIELDS_KEY,
|
|
9586
12103
|
TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
|
|
9587
12104
|
TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
|
|
9588
12105
|
TLV_KID: () => import_axis_protocol2.TLV_KID,
|
|
@@ -9608,21 +12125,29 @@ __export(index_exports, {
|
|
|
9608
12125
|
TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
|
|
9609
12126
|
TLV_TS: () => import_axis_protocol2.TLV_TS,
|
|
9610
12127
|
TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID,
|
|
9611
|
-
TLV_VALIDATORS_KEY: () => TLV_VALIDATORS_KEY,
|
|
12128
|
+
TLV_VALIDATORS_KEY: () => import_tlv_field2.TLV_VALIDATORS_KEY,
|
|
9612
12129
|
TLV_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
12130
|
+
TickAuthSensor: () => import_tickauth.TickAuthSensor,
|
|
12131
|
+
TimelineEngine: () => TimelineEngine,
|
|
12132
|
+
TlvEnum: () => import_tlv_field2.TlvEnum,
|
|
12133
|
+
TlvField: () => import_tlv_field2.TlvField,
|
|
12134
|
+
TlvMinLen: () => import_tlv_field2.TlvMinLen,
|
|
12135
|
+
TlvRange: () => import_tlv_field2.TlvRange,
|
|
12136
|
+
TlvUtf8Pattern: () => import_tlv_field2.TlvUtf8Pattern,
|
|
12137
|
+
TlvValidate: () => import_tlv_field2.TlvValidate,
|
|
12138
|
+
TpsSensor: () => import_tps.TpsSensor,
|
|
9619
12139
|
Witness: () => Witness,
|
|
12140
|
+
addStitchToKnot: () => addStitchToKnot,
|
|
12141
|
+
applyStitch: () => applyStitch,
|
|
12142
|
+
assembleNeedle: () => assembleNeedle,
|
|
9620
12143
|
axis1SigningBytes: () => axis1SigningBytes,
|
|
9621
12144
|
b64urlDecode: () => b64urlDecode,
|
|
9622
12145
|
b64urlDecodeString: () => b64urlDecodeString,
|
|
9623
12146
|
b64urlEncode: () => b64urlEncode,
|
|
9624
12147
|
b64urlEncodeString: () => b64urlEncodeString,
|
|
12148
|
+
breakKnot: () => breakKnot,
|
|
9625
12149
|
buildAts1Hdr: () => buildAts1Hdr,
|
|
12150
|
+
buildAxisLawEvaluationContext: () => buildAxisLawEvaluationContext,
|
|
9626
12151
|
buildDtoDecoder: () => import_dto_schema.buildDtoDecoder,
|
|
9627
12152
|
buildPacket: () => buildPacket,
|
|
9628
12153
|
buildQueueMessage: () => buildQueueMessage,
|
|
@@ -9641,11 +12166,17 @@ __export(index_exports, {
|
|
|
9641
12166
|
computeReceiptHash: () => computeReceiptHash,
|
|
9642
12167
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
9643
12168
|
core: () => core_exports,
|
|
12169
|
+
createFabric: () => createFabric,
|
|
12170
|
+
createGrant: () => createGrant,
|
|
9644
12171
|
createObservation: () => createObservation,
|
|
12172
|
+
createPresenceChallenge: () => createPresenceChallenge,
|
|
12173
|
+
createReceipt: () => createReceipt,
|
|
12174
|
+
createRevocation: () => createRevocation,
|
|
12175
|
+
createWrit: () => createWrit,
|
|
9645
12176
|
crypto: () => crypto_exports,
|
|
9646
12177
|
decodeArray: () => import_axis_protocol.decodeArray,
|
|
9647
12178
|
decodeAxis1Frame: () => decodeAxis1Frame,
|
|
9648
|
-
decodeFrame: () => decodeFrame,
|
|
12179
|
+
decodeFrame: () => import_axis_protocol4.decodeFrame,
|
|
9649
12180
|
decodeObject: () => import_axis_protocol.decodeObject,
|
|
9650
12181
|
decodeQueueMessage: () => decodeQueueMessage,
|
|
9651
12182
|
decodeTLVs: () => import_axis_protocol.decodeTLVs,
|
|
@@ -9653,30 +12184,52 @@ __export(index_exports, {
|
|
|
9653
12184
|
decodeVarint: () => import_axis_protocol3.decodeVarint,
|
|
9654
12185
|
decorators: () => decorators_exports,
|
|
9655
12186
|
deriveAnchorReflection: () => deriveAnchorReflection,
|
|
12187
|
+
detectAnomalies: () => detectAnomalies,
|
|
12188
|
+
detectKnotPatterns: () => detectKnotPatterns,
|
|
12189
|
+
detectSequencePatterns: () => detectSequencePatterns,
|
|
12190
|
+
diffFabrics: () => diffFabrics,
|
|
9656
12191
|
encVarint: () => encVarint,
|
|
9657
12192
|
encodeAxis1Frame: () => encodeAxis1Frame,
|
|
9658
12193
|
encodeAxisTlvDto: () => encodeAxisTlvDto,
|
|
9659
|
-
encodeFrame: () => encodeFrame,
|
|
12194
|
+
encodeFrame: () => import_axis_protocol4.encodeFrame,
|
|
9660
12195
|
encodeQueueMessage: () => encodeQueueMessage,
|
|
9661
12196
|
encodeTLVs: () => import_axis_protocol.encodeTLVs,
|
|
9662
12197
|
encodeVarint: () => import_axis_protocol3.encodeVarint,
|
|
9663
12198
|
endStage: () => endStage,
|
|
9664
12199
|
engine: () => engine_exports,
|
|
9665
12200
|
executeCcePipeline: () => executeCcePipeline,
|
|
12201
|
+
executeLoomPipeline: () => executeLoomPipeline,
|
|
9666
12202
|
extractDtoSchema: () => import_dto_schema.extractDtoSchema,
|
|
9667
12203
|
finalizeObservation: () => finalizeObservation,
|
|
12204
|
+
findKnotsForStitch: () => findKnotsForStitch,
|
|
12205
|
+
forkFromKnot: () => forkFromKnot,
|
|
12206
|
+
formStitch: () => formStitch,
|
|
9668
12207
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
9669
12208
|
getAxisExecutionContext: () => getAxisExecutionContext,
|
|
9670
|
-
|
|
12209
|
+
getDecisionPoints: () => getDecisionPoints,
|
|
12210
|
+
getFabricValue: () => getFabricValue,
|
|
12211
|
+
getGrantStatus: () => getGrantStatus,
|
|
12212
|
+
getIrreversibleKnots: () => getIrreversibleKnots,
|
|
12213
|
+
getPresenceStatus: () => getPresenceStatus,
|
|
12214
|
+
getSignTarget: () => import_axis_protocol4.getSignTarget,
|
|
12215
|
+
grantCoversAction: () => grantCoversAction,
|
|
9671
12216
|
hasScope: () => hasScope,
|
|
9672
12217
|
hashObservation: () => hashObservation,
|
|
12218
|
+
idel: () => idel_exports,
|
|
9673
12219
|
isAdminOpcode: () => isAdminOpcode,
|
|
12220
|
+
isKnotOpen: () => isKnotOpen,
|
|
9674
12221
|
isKnownOpcode: () => isKnownOpcode,
|
|
12222
|
+
isPointOfNoReturn: () => isPointOfNoReturn,
|
|
12223
|
+
isRevoked: () => isRevoked,
|
|
9675
12224
|
isTimestampValid: () => isTimestampValid,
|
|
12225
|
+
lockCells: () => lockCells,
|
|
9676
12226
|
loom: () => loom_exports,
|
|
12227
|
+
matchPatterns: () => matchPatterns,
|
|
9677
12228
|
mergeAxisExecutionContext: () => mergeAxisExecutionContext,
|
|
12229
|
+
needle: () => needle_exports,
|
|
9678
12230
|
nonce16: () => nonce16,
|
|
9679
12231
|
normalizeSensorDecision: () => normalizeSensorDecision,
|
|
12232
|
+
openKnot: () => openKnot,
|
|
9680
12233
|
packPasskeyLoginOptionsReq: () => packPasskeyLoginOptionsReq,
|
|
9681
12234
|
packPasskeyLoginOptionsRes: () => packPasskeyLoginOptionsRes,
|
|
9682
12235
|
packPasskeyLoginVerifyReq: () => packPasskeyLoginVerifyReq,
|
|
@@ -9685,32 +12238,49 @@ __export(index_exports, {
|
|
|
9685
12238
|
parseAutoClaimEntries: () => parseAutoClaimEntries,
|
|
9686
12239
|
parseScope: () => parseScope,
|
|
9687
12240
|
parseStreamEntries: () => parseStreamEntries,
|
|
12241
|
+
projectAt: () => projectAt,
|
|
12242
|
+
queryFabric: () => queryFabric,
|
|
12243
|
+
recordOccurrence: () => recordOccurrence,
|
|
9688
12244
|
recordSensor: () => recordSensor,
|
|
12245
|
+
renewPresence: () => renewPresence,
|
|
9689
12246
|
resolveTimeout: () => resolveTimeout,
|
|
12247
|
+
runNeedlePipeline: () => runNeedlePipeline,
|
|
9690
12248
|
schemas: () => schemas_exports,
|
|
12249
|
+
scoreTruth: () => scoreTruth,
|
|
9691
12250
|
security: () => security_exports,
|
|
9692
12251
|
sensitivityName: () => sensitivityName,
|
|
9693
12252
|
sensors: () => sensors_exports,
|
|
9694
12253
|
sha256: () => sha2564,
|
|
9695
12254
|
signFrame: () => signFrame,
|
|
12255
|
+
signPresenceChallenge: () => signPresenceChallenge,
|
|
9696
12256
|
stableJsonStringify: () => stableJsonStringify,
|
|
9697
12257
|
startStage: () => startStage,
|
|
12258
|
+
tieKnot: () => tieKnot,
|
|
12259
|
+
timeline: () => timeline_exports,
|
|
9698
12260
|
tlv: () => tlv,
|
|
9699
12261
|
u64be: () => u64be,
|
|
9700
12262
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
9701
12263
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
9702
12264
|
unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
|
|
12265
|
+
updateThreadState: () => updateThreadState,
|
|
9703
12266
|
utf8: () => utf8,
|
|
9704
12267
|
utils: () => utils_exports,
|
|
9705
12268
|
validateFrameShape: () => validateFrameShape,
|
|
12269
|
+
validateGrant: () => validateGrant,
|
|
12270
|
+
validateKnot: () => validateKnot,
|
|
12271
|
+
validateWrit: () => validateWrit,
|
|
9706
12272
|
varintLength: () => import_axis_protocol3.varintLength,
|
|
9707
12273
|
varintU: () => varintU,
|
|
9708
12274
|
verifyFrameSignature: () => verifyFrameSignature,
|
|
12275
|
+
verifyObservation: () => verifyObservation,
|
|
12276
|
+
verifyPresenceProof: () => verifyPresenceProof,
|
|
12277
|
+
verifyReceiptChain: () => verifyReceiptChain,
|
|
9709
12278
|
verifyResponse: () => verifyResponse,
|
|
12279
|
+
weave: () => weave,
|
|
9710
12280
|
withAxisExecutionContext: () => withAxisExecutionContext
|
|
9711
12281
|
});
|
|
9712
12282
|
module.exports = __toCommonJS(index_exports);
|
|
9713
|
-
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;
|
|
12283
|
+
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;
|
|
9714
12284
|
var init_index = __esm({
|
|
9715
12285
|
"src/index.ts"() {
|
|
9716
12286
|
init_chain_decorator();
|
|
@@ -9723,7 +12293,7 @@ var init_index = __esm({
|
|
|
9723
12293
|
init_observer_decorator();
|
|
9724
12294
|
init_handler_sensors_decorator();
|
|
9725
12295
|
init_sensor_decorator();
|
|
9726
|
-
|
|
12296
|
+
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
9727
12297
|
import_dto_schema = __toESM(require_dto_schema_util());
|
|
9728
12298
|
init_axis_tlv_dto();
|
|
9729
12299
|
import_axis_id = __toESM(require_axis_id_dto());
|
|
@@ -9736,6 +12306,7 @@ var init_index = __esm({
|
|
|
9736
12306
|
init_stable_json();
|
|
9737
12307
|
init_observation_queue_codec();
|
|
9738
12308
|
init_observation_hash();
|
|
12309
|
+
init_truth_scoring();
|
|
9739
12310
|
init_response_observer();
|
|
9740
12311
|
init_constants();
|
|
9741
12312
|
init_varint();
|
|
@@ -9757,6 +12328,7 @@ var init_index = __esm({
|
|
|
9757
12328
|
init_axis_sensor();
|
|
9758
12329
|
init_scopes();
|
|
9759
12330
|
init_capabilities();
|
|
12331
|
+
init_law();
|
|
9760
12332
|
init_risk();
|
|
9761
12333
|
init_opcodes();
|
|
9762
12334
|
init_receipt();
|
|
@@ -9776,19 +12348,33 @@ var init_index = __esm({
|
|
|
9776
12348
|
import_sensor2 = __toESM(require_sensor_registry());
|
|
9777
12349
|
init_axis_observation();
|
|
9778
12350
|
import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
|
|
12351
|
+
init_timeline_engine();
|
|
12352
|
+
init_timeline_store();
|
|
9779
12353
|
init_cce_pipeline();
|
|
9780
12354
|
init_cce_types();
|
|
9781
12355
|
init_axis_tlv_codec();
|
|
9782
12356
|
init_loom_types();
|
|
12357
|
+
init_loom_engine();
|
|
12358
|
+
init_idel_compiler();
|
|
12359
|
+
init_needle_engine();
|
|
12360
|
+
init_knot_engine();
|
|
12361
|
+
init_fabric_engine();
|
|
12362
|
+
init_pattern_engine();
|
|
12363
|
+
import_tps = __toESM(require_tps_sensor());
|
|
12364
|
+
import_risk_gate = __toESM(require_risk_gate_sensor());
|
|
12365
|
+
import_tickauth = __toESM(require_tickauth_sensor());
|
|
9783
12366
|
init_cce();
|
|
9784
12367
|
init_core();
|
|
9785
12368
|
init_crypto();
|
|
9786
12369
|
init_decorators();
|
|
9787
12370
|
init_engine();
|
|
12371
|
+
init_idel();
|
|
9788
12372
|
init_loom();
|
|
12373
|
+
init_needle();
|
|
9789
12374
|
init_schemas();
|
|
9790
12375
|
init_security();
|
|
9791
12376
|
init_sensors2();
|
|
12377
|
+
init_timeline();
|
|
9792
12378
|
init_utils();
|
|
9793
12379
|
}
|
|
9794
12380
|
});
|
|
@@ -9869,6 +12455,10 @@ init_index();
|
|
|
9869
12455
|
INTENT_SENSITIVITY_MAP,
|
|
9870
12456
|
INTENT_SENSORS_KEY,
|
|
9871
12457
|
INTENT_TIMEOUTS,
|
|
12458
|
+
IdelCompiler,
|
|
12459
|
+
IdelSchemaRegistry,
|
|
12460
|
+
InMemoryPatternStore,
|
|
12461
|
+
InMemoryTimelineStore,
|
|
9872
12462
|
Intent,
|
|
9873
12463
|
IntentBody,
|
|
9874
12464
|
IntentRouter,
|
|
@@ -9912,6 +12502,7 @@ init_index();
|
|
|
9912
12502
|
RequiredProof,
|
|
9913
12503
|
ResponseObserver,
|
|
9914
12504
|
RiskDecision,
|
|
12505
|
+
RiskGateSensor,
|
|
9915
12506
|
SENSITIVITY_METADATA_KEY,
|
|
9916
12507
|
SENSOR_METADATA_KEY,
|
|
9917
12508
|
Schema2002_PasskeyLoginOptionsRes,
|
|
@@ -9960,19 +12551,27 @@ init_index();
|
|
|
9960
12551
|
TLV_UPLOAD_ID,
|
|
9961
12552
|
TLV_VALIDATORS_KEY,
|
|
9962
12553
|
TLV_WRIT,
|
|
12554
|
+
TickAuthSensor,
|
|
12555
|
+
TimelineEngine,
|
|
9963
12556
|
TlvEnum,
|
|
9964
12557
|
TlvField,
|
|
9965
12558
|
TlvMinLen,
|
|
9966
12559
|
TlvRange,
|
|
9967
12560
|
TlvUtf8Pattern,
|
|
9968
12561
|
TlvValidate,
|
|
12562
|
+
TpsSensor,
|
|
9969
12563
|
Witness,
|
|
12564
|
+
addStitchToKnot,
|
|
12565
|
+
applyStitch,
|
|
12566
|
+
assembleNeedle,
|
|
9970
12567
|
axis1SigningBytes,
|
|
9971
12568
|
b64urlDecode,
|
|
9972
12569
|
b64urlDecodeString,
|
|
9973
12570
|
b64urlEncode,
|
|
9974
12571
|
b64urlEncodeString,
|
|
12572
|
+
breakKnot,
|
|
9975
12573
|
buildAts1Hdr,
|
|
12574
|
+
buildAxisLawEvaluationContext,
|
|
9976
12575
|
buildDtoDecoder,
|
|
9977
12576
|
buildPacket,
|
|
9978
12577
|
buildQueueMessage,
|
|
@@ -9991,7 +12590,13 @@ init_index();
|
|
|
9991
12590
|
computeReceiptHash,
|
|
9992
12591
|
computeSignaturePayload,
|
|
9993
12592
|
core,
|
|
12593
|
+
createFabric,
|
|
12594
|
+
createGrant,
|
|
9994
12595
|
createObservation,
|
|
12596
|
+
createPresenceChallenge,
|
|
12597
|
+
createReceipt,
|
|
12598
|
+
createRevocation,
|
|
12599
|
+
createWrit,
|
|
9995
12600
|
crypto,
|
|
9996
12601
|
decodeArray,
|
|
9997
12602
|
decodeAxis1Frame,
|
|
@@ -10003,6 +12608,10 @@ init_index();
|
|
|
10003
12608
|
decodeVarint,
|
|
10004
12609
|
decorators,
|
|
10005
12610
|
deriveAnchorReflection,
|
|
12611
|
+
detectAnomalies,
|
|
12612
|
+
detectKnotPatterns,
|
|
12613
|
+
detectSequencePatterns,
|
|
12614
|
+
diffFabrics,
|
|
10006
12615
|
encVarint,
|
|
10007
12616
|
encodeAxis1Frame,
|
|
10008
12617
|
encodeAxisTlvDto,
|
|
@@ -10013,20 +12622,38 @@ init_index();
|
|
|
10013
12622
|
endStage,
|
|
10014
12623
|
engine,
|
|
10015
12624
|
executeCcePipeline,
|
|
12625
|
+
executeLoomPipeline,
|
|
10016
12626
|
extractDtoSchema,
|
|
10017
12627
|
finalizeObservation,
|
|
12628
|
+
findKnotsForStitch,
|
|
12629
|
+
forkFromKnot,
|
|
12630
|
+
formStitch,
|
|
10018
12631
|
generateEd25519KeyPair,
|
|
10019
12632
|
getAxisExecutionContext,
|
|
12633
|
+
getDecisionPoints,
|
|
12634
|
+
getFabricValue,
|
|
12635
|
+
getGrantStatus,
|
|
12636
|
+
getIrreversibleKnots,
|
|
12637
|
+
getPresenceStatus,
|
|
10020
12638
|
getSignTarget,
|
|
12639
|
+
grantCoversAction,
|
|
10021
12640
|
hasScope,
|
|
10022
12641
|
hashObservation,
|
|
12642
|
+
idel,
|
|
10023
12643
|
isAdminOpcode,
|
|
12644
|
+
isKnotOpen,
|
|
10024
12645
|
isKnownOpcode,
|
|
12646
|
+
isPointOfNoReturn,
|
|
12647
|
+
isRevoked,
|
|
10025
12648
|
isTimestampValid,
|
|
12649
|
+
lockCells,
|
|
10026
12650
|
loom,
|
|
12651
|
+
matchPatterns,
|
|
10027
12652
|
mergeAxisExecutionContext,
|
|
12653
|
+
needle,
|
|
10028
12654
|
nonce16,
|
|
10029
12655
|
normalizeSensorDecision,
|
|
12656
|
+
openKnot,
|
|
10030
12657
|
packPasskeyLoginOptionsReq,
|
|
10031
12658
|
packPasskeyLoginOptionsRes,
|
|
10032
12659
|
packPasskeyLoginVerifyReq,
|
|
@@ -10035,28 +12662,45 @@ init_index();
|
|
|
10035
12662
|
parseAutoClaimEntries,
|
|
10036
12663
|
parseScope,
|
|
10037
12664
|
parseStreamEntries,
|
|
12665
|
+
projectAt,
|
|
12666
|
+
queryFabric,
|
|
12667
|
+
recordOccurrence,
|
|
10038
12668
|
recordSensor,
|
|
12669
|
+
renewPresence,
|
|
10039
12670
|
resolveTimeout,
|
|
12671
|
+
runNeedlePipeline,
|
|
10040
12672
|
schemas,
|
|
12673
|
+
scoreTruth,
|
|
10041
12674
|
security,
|
|
10042
12675
|
sensitivityName,
|
|
10043
12676
|
sensors,
|
|
10044
12677
|
sha256,
|
|
10045
12678
|
signFrame,
|
|
12679
|
+
signPresenceChallenge,
|
|
10046
12680
|
stableJsonStringify,
|
|
10047
12681
|
startStage,
|
|
12682
|
+
tieKnot,
|
|
12683
|
+
timeline,
|
|
10048
12684
|
tlv,
|
|
10049
12685
|
u64be,
|
|
10050
12686
|
unpackPasskeyLoginOptionsReq,
|
|
10051
12687
|
unpackPasskeyLoginVerifyReq,
|
|
10052
12688
|
unpackPasskeyRegisterOptionsReq,
|
|
12689
|
+
updateThreadState,
|
|
10053
12690
|
utf8,
|
|
10054
12691
|
utils,
|
|
10055
12692
|
validateFrameShape,
|
|
12693
|
+
validateGrant,
|
|
12694
|
+
validateKnot,
|
|
12695
|
+
validateWrit,
|
|
10056
12696
|
varintLength,
|
|
10057
12697
|
varintU,
|
|
10058
12698
|
verifyFrameSignature,
|
|
12699
|
+
verifyObservation,
|
|
12700
|
+
verifyPresenceProof,
|
|
12701
|
+
verifyReceiptChain,
|
|
10059
12702
|
verifyResponse,
|
|
12703
|
+
weave,
|
|
10060
12704
|
withAxisExecutionContext
|
|
10061
12705
|
});
|
|
10062
12706
|
//# sourceMappingURL=index.js.map
|