@zortexhq/indra-v2.5 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/auto-sync.js +1 -1
- package/dist/connector-worker.js +1 -1
- package/dist/content-find.js +8 -2
- package/dist/gateway.js +1 -1
- package/dist/local-cloud-policy.js +1 -1
- package/dist/local-cloud.js +1 -1
- package/dist/mcp.js +1 -1
- package/dist/public-tool.js +1 -1
- package/dist/resident-ensure-ready.js +1 -1
- package/dist/resident-host.js +2 -2
- package/dist/resident-jobs.js +1 -1
- package/dist/resident-platform.js +1 -1
- package/dist/source-data.js +1 -0
- package/dist/supervised-sync.js +1 -1
- package/dist/worker-google-auth.js +1 -0
- package/node_modules/@zortexhq/plugin-connector-calendar/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-drive/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-framework/dist/manifest.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-framework/dist/runtime.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-gmail/dist/brokered.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-gmail/dist/gmail-source.js +2 -2
- package/node_modules/@zortexhq/plugin-connector-gmail/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-history/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-outlook/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-slack/dist/provider.js +1 -1
- package/node_modules/@zortexhq/plugin-connector-youtube/dist/source.js +1 -1
- package/node_modules/@zortexhq/plugin-device-auth/dist/authority.js +1 -1
- package/node_modules/@zortexhq/plugin-google-auth/dist/index.js +1 -1
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/api/index.js +1 -1
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/api/source-sync.js +1 -0
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/current-records.js +1 -0
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/index.js +1 -1
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/record-rules.js +1 -1
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/schema.js +8 -0
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/snapshot-tables.js +1 -1
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/source-sync.js +1 -0
- package/node_modules/@zortexhq/plugin-vault-sqlite/dist/sql-worker.js +1 -1
- package/node_modules/@zortexhq/rooktrail/dist/record-rules.js +1 -1
- package/node_modules/@zortexhq/rooktrail/dist/registry.js +1 -1
- package/package.json +6 -6
- package/release-provenance.json +21 -21
- package/update-manifest.json +125 -95
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildStreamMap,streamKey}from"./registry.js";import{cachedQuery,insertEventRow,projectEvent}from"./effects.js";import{CANON_PROFILE_VERSION,compareRevsWithConflicts,contentHash,errResult,isOk,makeUlidFactory,mintConflictRev,noneSourceId,ok,parseConflictRev,toRfc3339UtcMillis,validateOrigin,validateProtoEvent,validateIdentityRebindPayload}from"./contracts/index.js";const MAX_BATCH=500;function err(code,message,retryability="non-retryable",layer="storage"){return errResult({code,layer,retryability,message})}function stampTrust(origin,nk){if(origin.kind==="connector")return{level:"untrusted",sources:[nk.source]};if(origin.kind==="user")return{level:"user",sources:[]};return{level:"system",sources:[]}}function numericThenLex(a,b){const na=Number(a);const nb=Number(b);if(Number.isFinite(na)&&Number.isFinite(nb)&&na!==nb)return na<nb?-1:1;if(Number.isFinite(na)&&Number.isFinite(nb))return 0;return a<b?-1:a>b?1:0}function lex(a,b){return a<b?-1:a>b?1:0}class CheckpointAuthorityConflictError extends Error{}class RecordHookError extends Error{error;constructor(error){super(error.message);this.error=error}}export class LiftedRecordRules{db;now;table;kinds;policy;streams;declarations;ulid;policyVersion=()=>1;registerStream(registration){const key=streamKey(registration.source,registration.stream),snapshot={...registration};this.declarations.set(key,snapshot);this.streams.set(key,snapshot)}constructor(db,streams,now,table,kinds,policy={}){this.db=db;this.now=now;this.table=table;this.kinds=kinds;this.policy=policy;this.declarations=new Map(streams.map(row=>[streamKey(row.source,row.stream),{...row}]));this.streams=this.makeStreams(streams);this.ulid=makeUlidFactory({now:()=>Date.parse(now())})}makeStreams(streams){return(this.policy.buildStreams??buildStreamMap)(streams)}lookupKind(kind){return typeof this.kinds==="function"?this.kinds(kind):this.kinds.get(kind)}appendCore(batch,origin,internal=false,transaction,withinTransaction=false){if(!Array.isArray(batch))return err("invalid_argument","append: batch must be an array");if(batch.length===0)return transaction?err("invalid_argument","Guarded append requires a fact."):ok([]);if(batch.length>MAX_BATCH)return err("invalid_argument",`append: batch exceeds the txn unit (${MAX_BATCH})`);const originV=validateOrigin(origin);if(!isOk(originV))return originV;try{this.refreshStreams()}catch{return err("data_loss","Stored stream declarations are invalid.")}for(const proto of batch){const hard=this.validateHard(proto,origin,internal,false);if(hard!==null)return{err:hard}}const results=[],toWrite=[];const rollback=()=>this.db.exec(withinTransaction?"ROLLBACK TO rooktrail_page_append; RELEASE rooktrail_page_append":"ROLLBACK");try{this.db.exec(withinTransaction?"SAVEPOINT rooktrail_page_append":"BEGIN IMMEDIATE")}catch{return err("unavailable","SQLite writer busy","transient")}try{this.refreshStreams();for(const proto of batch){const hard=this.validateHard(proto,origin,internal);if(hard!==null){rollback();return{err:hard}}}if(origin.kind==="connector"&&this.policy.authorizeConnector){const admitted=this.policy.authorizeConnector(origin);if(!isOk(admitted)||admitted.ok!==true){rollback();return"err"in admitted?admitted:err("permission_denied","Connector authority was not confirmed.")}}if(transaction){const check=transaction.before();if(!isOk(check)||check.ok!==true){rollback();return"err"in check?check:err("permission_denied","Checkpoint authority was not confirmed.")}}const stampAndInsert=(ev,uniqueNk,table=this.table)=>{insertEventRow(this.db,ev,"",0,uniqueNk,table);toWrite.push(ev);projectEvent(this.db,ev);if(this.policy.afterInsert){const result=this.policy.afterInsert(ev,table);if(!isOk(result)||result.ok!==true)throw new RecordHookError("err"in result?result.err:{code:"data_loss",layer:"storage",retryability:"non-retryable",message:"Host record effect was not confirmed."})}};const sideEvent=(kind,payload,sideOrigin={kind:"kernel"})=>{const ev=this.stampInternal({kind,payload,origin:sideOrigin});stampAndInsert(ev,true,"system_events");return ev};for(const proto of batch){const reg=this.streams.get(streamKey(proto.nk.source,proto.nk.stream));const hash=contentHash({kind:proto.kind,body:proto.body,...proto.payload===void 0?{}:{payload:proto.payload},...proto.blobs===void 0?{}:{blobs:proto.blobs}});let sourceId;let rev;let headCompare=false;if(reg?.quality==="none"){sourceId=noneSourceId(reg.noneIdentity??"occurrence",hash,proto.ts);rev="0"}else{sourceId=proto.nk.sourceId;const draftRev=proto.nk.rev??"";if(reg?.revOrder==="head-compare"||reg===void 0&&draftRev===""){rev=hash;headCompare=true}else if(reg?.revOrder==="event-ts"){rev=toRfc3339UtcMillis(proto.ts)}else{rev=draftRev}}const nk={source:proto.nk.source,stream:proto.nk.stream,sourceId,rev};const phase=proto.coverage?.phase??"live";const suppression=this.checkTombstones(nk,hash,sideEvent);if(suppression!==null){results.push(suppression);continue}let outcome=null;let conflictAnomaly=null;if(!headCompare){const existing=cachedQuery(this.db,`SELECT id, content_hash FROM ${this.table} WHERE source = ? AND stream = ? AND source_id = ? AND rev = ?`).get(nk.source,nk.stream,nk.sourceId,nk.rev);if(existing!==null){if(existing.content_hash===hash){results.push({id:existing.id,outcome:"duplicate"});continue}if(this.lookupKind(proto.kind)?.conflictIsDataLoss===true){throw new CheckpointAuthorityConflictError(`authority kind '${proto.kind}' reused an NK with changed bytes`)}const sibling=this.conflictSiblingWithHash(nk,rev,hash);if(sibling!==null){results.push({id:sibling.id,outcome:"duplicate"});continue}const n=this.nextConflictN(nk);conflictAnomaly={existingId:existing.id,existingHash:existing.content_hash};nk.rev=mintConflictRev(rev,n)}}else{const chainRows=this.chainRowsForBase({source:nk.source,stream:nk.stream,sourceId:nk.sourceId});const live=chainRows.filter(r=>r.erased===0);const head=live.length>0?live[live.length-1]:null;if(phase==="live"){if(head!==null&&head.content_hash===hash){results.push({id:head.id,outcome:"head-noop"});continue}}else if(live.some(r=>r.content_hash===hash)){results.push({id:head.id,outcome:"head-noop"});continue}}const ev={id:this.nextEventId(),nk,contentHash:hash,canon:CANON_PROFILE_VERSION,ts:proto.ts,observedTs:this.now(),trust:stampTrust(origin,nk),origin,tier:proto.tier,kind:proto.kind,schemaVersion:proto.schemaVersion,policyVersion:this.policyVersion(),mentions:proto.mentions,body:proto.body};if(proto.coverage!==void 0)ev.coverage=proto.coverage;if(proto.lang!==void 0)ev.lang=proto.lang;if(proto.payload!==void 0)ev.payload=proto.payload;if(proto.blobs!==void 0)ev.blobs=proto.blobs;if(proto.refs!==void 0)ev.refs=proto.refs;const rebindConflict=this.detectRebindConflict(ev);stampAndInsert(ev,!headCompare);if(conflictAnomaly!==null){const anomaly=sideEvent("ingest.anomaly",{class:"nk-conflict",nk:{source:nk.source,stream:nk.stream,sourceId:nk.sourceId,rev},existingId:conflictAnomaly.existingId,newId:ev.id,hashes:[conflictAnomaly.existingHash,hash]});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else if(rebindConflict!==null){const anomaly=sideEvent("ingest.anomaly",{class:"rebind-conflict",...rebindConflict,eventId:ev.id});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else{const kindEntry=this.lookupKind(ev.kind);if(kindEntry===void 0){const seen=this.db.query(`SELECT 1 AS x FROM unknown_kinds WHERE source = ? AND kind = ?`).get(nk.source,ev.kind);if(seen===null){sideEvent("ingest.unknown-kind",{source:nk.source,kind:ev.kind,firstEventId:ev.id})}outcome={id:ev.id,outcome:"appended"}}else if(kindEntry.validatePayload!==void 0){const v=kindEntry.validatePayload(ev.payload);if(!isOk(v)){const detail="err"in v?v.err.message:"payload empty";const anomaly=sideEvent("ingest.anomaly",{class:"schema-violation",eventId:ev.id,kind:ev.kind,detail});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else{outcome={id:ev.id,outcome:"appended"}}}else{outcome={id:ev.id,outcome:"appended"}}}results.push(outcome)}if(transaction){const check=transaction.after(results);if(!isOk(check)||check.ok!==true){rollback();return"err"in check?check:err("data_loss","Checkpoint fact was not committed.")}}if(toWrite.length)this.db.query("INSERT OR REPLACE INTO meta(key,value) VALUES ('watermark',?)").run(toWrite[toWrite.length-1].id);this.db.exec(withinTransaction?"RELEASE rooktrail_page_append":"COMMIT");return ok(results)}catch(failure){try{rollback()}catch{throw new AggregateError([failure],"SQLite append rollback failed")}if(failure instanceof RecordHookError)return{err:failure.error};if(failure instanceof CheckpointAuthorityConflictError)return err("data_loss",failure.message);return err("internal","SQLite record transaction rolled back","transient")}}refreshStreams(){const rows=this.db.query("SELECT definition FROM source_streams ORDER BY source,stream").all();const latest=this.makeStreams([...this.declarations.values(),...rows.map(row=>JSON.parse(row.definition))]);this.streams.clear();for(const[key,declaration]of latest)this.streams.set(key,declaration)}validateHard(proto,origin,internal,eventValidation=true){if(proto===null||typeof proto!=="object"){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:"protoEvent: expected an object"}}const reg=this.streams.get(streamKey(proto.nk?.source,proto.nk?.stream));const ctx=reg===void 0?void 0:{revOrder:reg.revOrder,...reg.quality!==void 0&®.quality!=="synthetic"?{quality:reg.quality}:{}};const v=validateProtoEvent(proto,ctx);if(!isOk(v))return v.err;const sourceId=proto.nk.sourceId??"";if(reg?.quality==="synthetic"&&sourceId===""){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`nk.sourceId: quality 'synthetic' stream reached the appender un-synthesized \u2014 the host's '${reg.stream}' synthesizer runs BEFORE append`}}if(reg===void 0&&sourceId===""){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`nk.sourceId: undeclared stream '${proto.nk.source}/${proto.nk.stream}' cannot synthesize identity \u2014 declare the stream identity quality`}}if(origin.kind==="connector"&&proto.nk.source!==origin.source){return{code:"permission_denied",layer:"storage",retryability:"non-retryable",message:`origin 'connector:${origin.source}' may append only nk.source == its own source; got '${proto.nk.source}'`}}const kindEntry=this.lookupKind(proto.kind);if(kindEntry!==void 0){const forgedInternal=kindEntry.internalOnly===true&&!internal;const aclViolation=!kindEntry.allowedOrigins.includes(origin.kind);if(forgedInternal||aclViolation){const incident=this.policy.authorityIncident?.(proto.kind,origin)??(kindEntry.reportForgery===true?{class:"write-authority",kind:proto.kind,origin:origin.kind}:void 0);if(incident!==void 0)this.recordWriteAuthorityIncident(incident);return{code:"permission_denied",layer:"storage",retryability:"non-retryable",message:forgedInternal?`kind '${proto.kind}' is appender/erasure-job emitted only \u2014 a caller append is a forgery`:`kind '${proto.kind}' allows origins [${kindEntry.allowedOrigins.join(", ")}]; origin '${origin.kind}' denied`}}if(eventValidation&&kindEntry.validateEvent!==void 0){const validated=kindEntry.validateEvent({nk:proto.nk,payload:proto.payload});if(!isOk(validated))return"err"in validated?validated.err:{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`kind '${proto.kind}' event validation checked empty`}}}return null}checkTombstones(nk,hash,sideEvent){const sameContent=cachedQuery(this.db,`SELECT tomb_id FROM tombstones WHERE source = ? AND stream = ? AND source_id = ? AND content_hash = ?`).get(nk.source,nk.stream,nk.sourceId,hash);if(sameContent!==null)return{id:sameContent.tomb_id,outcome:"erased-suppressed"};const ban=cachedQuery(this.db,`SELECT tomb_id FROM tombstones WHERE source = ? AND stream = ? AND source_id = ? AND future_too = 1`).get(nk.source,nk.stream,nk.sourceId);if(ban!==null){const marker=this.db.query(`SELECT id FROM system_events
|
|
1
|
+
import{buildStreamMap,streamKey}from"./registry.js";import{cachedQuery,insertEventRow,projectEvent}from"./effects.js";import{CANON_PROFILE_VERSION,compareRevsWithConflicts,contentHash,errResult,isOk,makeUlidFactory,mintConflictRev,noneSourceId,ok,parseConflictRev,toRfc3339UtcMillis,validateOrigin,validateProtoEvent,validateIdentityRebindPayload}from"./contracts/index.js";const MAX_BATCH=500;function err(code,message,retryability="non-retryable",layer="storage"){return errResult({code,layer,retryability,message})}function stampTrust(origin,nk){if(origin.kind==="connector")return{level:"untrusted",sources:[nk.source]};if(origin.kind==="user")return{level:"user",sources:[]};return{level:"system",sources:[]}}function numericThenLex(a,b){const na=Number(a);const nb=Number(b);if(Number.isFinite(na)&&Number.isFinite(nb)&&na!==nb)return na<nb?-1:1;if(Number.isFinite(na)&&Number.isFinite(nb))return 0;return a<b?-1:a>b?1:0}function lex(a,b){return a<b?-1:a>b?1:0}class CheckpointAuthorityConflictError extends Error{}class RecordHookError extends Error{error;constructor(error){super(error.message);this.error=error}}export class LiftedRecordRules{db;now;table;kinds;policy;streams;declarations;ulid;policyVersion=()=>1;registerStream(registration){const key=streamKey(registration.source,registration.stream),snapshot={...registration};this.declarations.set(key,snapshot);this.streams.set(key,snapshot)}constructor(db,streams,now,table,kinds,policy={}){this.db=db;this.now=now;this.table=table;this.kinds=kinds;this.policy=policy;this.declarations=new Map(streams.map(row=>[streamKey(row.source,row.stream),{...row}]));this.streams=this.makeStreams(streams);this.ulid=makeUlidFactory({now:()=>Date.parse(now())})}currentChain(base){this.refreshStreams();return{identities:this.rebindClosure(base),head:this.chainRowsForBase(base).at(-1)??null}}makeStreams(streams){return(this.policy.buildStreams??buildStreamMap)(streams)}lookupKind(kind){return typeof this.kinds==="function"?this.kinds(kind):this.kinds.get(kind)}appendCore(batch,origin,internal=false,transaction,withinTransaction=false){if(!Array.isArray(batch))return err("invalid_argument","append: batch must be an array");if(batch.length===0)return transaction?err("invalid_argument","Guarded append requires a fact."):ok([]);if(batch.length>MAX_BATCH)return err("invalid_argument",`append: batch exceeds the txn unit (${MAX_BATCH})`);const originV=validateOrigin(origin);if(!isOk(originV))return originV;try{this.refreshStreams()}catch{return err("data_loss","Stored stream declarations are invalid.")}for(const proto of batch){const hard=this.validateHard(proto,origin,internal,false);if(hard!==null)return{err:hard}}const results=[],toWrite=[];const rollback=()=>this.db.exec(withinTransaction?"ROLLBACK TO rooktrail_page_append; RELEASE rooktrail_page_append":"ROLLBACK");try{this.db.exec(withinTransaction?"SAVEPOINT rooktrail_page_append":"BEGIN IMMEDIATE")}catch{return err("unavailable","SQLite writer busy","transient")}try{this.refreshStreams();for(const proto of batch){const hard=this.validateHard(proto,origin,internal);if(hard!==null){rollback();return{err:hard}}}if(origin.kind==="connector"&&this.policy.authorizeConnector){const admitted=this.policy.authorizeConnector(origin);if(!isOk(admitted)||admitted.ok!==true){rollback();return"err"in admitted?admitted:err("permission_denied","Connector authority was not confirmed.")}}if(transaction){const check=transaction.before();if(!isOk(check)||check.ok!==true){rollback();return"err"in check?check:err("permission_denied","Checkpoint authority was not confirmed.")}}const stampAndInsert=(ev,uniqueNk,table=this.table)=>{insertEventRow(this.db,ev,"",0,uniqueNk,table);toWrite.push(ev);projectEvent(this.db,ev);if(this.policy.afterInsert){const result=this.policy.afterInsert(ev,table);if(!isOk(result)||result.ok!==true)throw new RecordHookError("err"in result?result.err:{code:"data_loss",layer:"storage",retryability:"non-retryable",message:"Host record effect was not confirmed."})}};const sideEvent=(kind,payload,sideOrigin={kind:"kernel"})=>{const ev=this.stampInternal({kind,payload,origin:sideOrigin});stampAndInsert(ev,true,"system_events");return ev};for(const proto of batch){const reg=this.streams.get(streamKey(proto.nk.source,proto.nk.stream));const hash=contentHash({kind:proto.kind,body:proto.body,...proto.payload===void 0?{}:{payload:proto.payload},...proto.blobs===void 0?{}:{blobs:proto.blobs}});let sourceId;let rev;let headCompare=false;if(reg?.quality==="none"){sourceId=noneSourceId(reg.noneIdentity??"occurrence",hash,proto.ts);rev="0"}else{sourceId=proto.nk.sourceId;const draftRev=proto.nk.rev??"";if(reg?.revOrder==="head-compare"||reg===void 0&&draftRev===""){rev=hash;headCompare=true}else if(reg?.revOrder==="event-ts"){rev=toRfc3339UtcMillis(proto.ts)}else{rev=draftRev}}const nk={source:proto.nk.source,stream:proto.nk.stream,sourceId,rev};const phase=proto.coverage?.phase??"live";const suppression=this.checkTombstones(nk,hash,sideEvent);if(suppression!==null){results.push(suppression);continue}let outcome=null;let conflictAnomaly=null;if(!headCompare){const existing=cachedQuery(this.db,`SELECT id, content_hash FROM ${this.table} WHERE source = ? AND stream = ? AND source_id = ? AND rev = ?`).get(nk.source,nk.stream,nk.sourceId,nk.rev);if(existing!==null){if(existing.content_hash===hash){results.push({id:existing.id,outcome:"duplicate"});continue}if(this.lookupKind(proto.kind)?.conflictIsDataLoss===true){throw new CheckpointAuthorityConflictError(`authority kind '${proto.kind}' reused an NK with changed bytes`)}const sibling=this.conflictSiblingWithHash(nk,rev,hash);if(sibling!==null){results.push({id:sibling.id,outcome:"duplicate"});continue}const n=this.nextConflictN(nk);conflictAnomaly={existingId:existing.id,existingHash:existing.content_hash};nk.rev=mintConflictRev(rev,n)}}else{const chainRows=this.chainRowsForBase({source:nk.source,stream:nk.stream,sourceId:nk.sourceId});const live=chainRows.filter(r=>r.erased===0);const head=live.length>0?live[live.length-1]:null;if(phase==="live"){if(head!==null&&head.content_hash===hash){results.push({id:head.id,outcome:"head-noop"});continue}}else if(live.some(r=>r.content_hash===hash)){results.push({id:head.id,outcome:"head-noop"});continue}}const ev={id:this.nextEventId(),nk,contentHash:hash,canon:CANON_PROFILE_VERSION,ts:proto.ts,observedTs:this.now(),trust:stampTrust(origin,nk),origin,tier:proto.tier,kind:proto.kind,schemaVersion:proto.schemaVersion,policyVersion:this.policyVersion(),mentions:proto.mentions,body:proto.body};if(proto.coverage!==void 0)ev.coverage=proto.coverage;if(proto.lang!==void 0)ev.lang=proto.lang;if(proto.payload!==void 0)ev.payload=proto.payload;if(proto.blobs!==void 0)ev.blobs=proto.blobs;if(proto.refs!==void 0)ev.refs=proto.refs;const rebindConflict=this.detectRebindConflict(ev);stampAndInsert(ev,!headCompare);if(conflictAnomaly!==null){const anomaly=sideEvent("ingest.anomaly",{class:"nk-conflict",nk:{source:nk.source,stream:nk.stream,sourceId:nk.sourceId,rev},existingId:conflictAnomaly.existingId,newId:ev.id,hashes:[conflictAnomaly.existingHash,hash]});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else if(rebindConflict!==null){const anomaly=sideEvent("ingest.anomaly",{class:"rebind-conflict",...rebindConflict,eventId:ev.id});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else{const kindEntry=this.lookupKind(ev.kind);if(kindEntry===void 0){const seen=this.db.query(`SELECT 1 AS x FROM unknown_kinds WHERE source = ? AND kind = ?`).get(nk.source,ev.kind);if(seen===null){sideEvent("ingest.unknown-kind",{source:nk.source,kind:ev.kind,firstEventId:ev.id})}outcome={id:ev.id,outcome:"appended"}}else if(kindEntry.validatePayload!==void 0){const v=kindEntry.validatePayload(ev.payload);if(!isOk(v)){const detail="err"in v?v.err.message:"payload empty";const anomaly=sideEvent("ingest.anomaly",{class:"schema-violation",eventId:ev.id,kind:ev.kind,detail});outcome={id:ev.id,outcome:"anomaly",anomalyId:anomaly.id}}else{outcome={id:ev.id,outcome:"appended"}}}else{outcome={id:ev.id,outcome:"appended"}}}results.push(outcome)}if(transaction){const check=transaction.after(results);if(!isOk(check)||check.ok!==true){rollback();return"err"in check?check:err("data_loss","Checkpoint fact was not committed.")}}if(toWrite.length)this.db.query("INSERT OR REPLACE INTO meta(key,value) VALUES ('watermark',?)").run(toWrite[toWrite.length-1].id);this.db.exec(withinTransaction?"RELEASE rooktrail_page_append":"COMMIT");return ok(results)}catch(failure){try{rollback()}catch{throw new AggregateError([failure],"SQLite append rollback failed")}if(failure instanceof RecordHookError)return{err:failure.error};if(failure instanceof CheckpointAuthorityConflictError)return err("data_loss",failure.message);return err("internal","SQLite record transaction rolled back","transient")}}refreshStreams(){const rows=this.db.query("SELECT definition FROM source_streams ORDER BY source,stream").all();const latest=this.makeStreams([...this.declarations.values(),...rows.map(row=>JSON.parse(row.definition))]);this.streams.clear();for(const[key,declaration]of latest)this.streams.set(key,declaration)}validateHard(proto,origin,internal,eventValidation=true){if(proto===null||typeof proto!=="object"){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:"protoEvent: expected an object"}}const reg=this.streams.get(streamKey(proto.nk?.source,proto.nk?.stream));const ctx=reg===void 0?void 0:{revOrder:reg.revOrder,...reg.quality!==void 0&®.quality!=="synthetic"?{quality:reg.quality}:{}};const v=validateProtoEvent(proto,ctx);if(!isOk(v))return v.err;const sourceId=proto.nk.sourceId??"";if(reg?.quality==="synthetic"&&sourceId===""){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`nk.sourceId: quality 'synthetic' stream reached the appender un-synthesized \u2014 the host's '${reg.stream}' synthesizer runs BEFORE append`}}if(reg===void 0&&sourceId===""){return{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`nk.sourceId: undeclared stream '${proto.nk.source}/${proto.nk.stream}' cannot synthesize identity \u2014 declare the stream identity quality`}}if(origin.kind==="connector"&&proto.nk.source!==origin.source){return{code:"permission_denied",layer:"storage",retryability:"non-retryable",message:`origin 'connector:${origin.source}' may append only nk.source == its own source; got '${proto.nk.source}'`}}const kindEntry=this.lookupKind(proto.kind);if(kindEntry!==void 0){const forgedInternal=kindEntry.internalOnly===true&&!internal;const aclViolation=!kindEntry.allowedOrigins.includes(origin.kind);if(forgedInternal||aclViolation){const incident=this.policy.authorityIncident?.(proto.kind,origin)??(kindEntry.reportForgery===true?{class:"write-authority",kind:proto.kind,origin:origin.kind}:void 0);if(incident!==void 0)this.recordWriteAuthorityIncident(incident);return{code:"permission_denied",layer:"storage",retryability:"non-retryable",message:forgedInternal?`kind '${proto.kind}' is appender/erasure-job emitted only \u2014 a caller append is a forgery`:`kind '${proto.kind}' allows origins [${kindEntry.allowedOrigins.join(", ")}]; origin '${origin.kind}' denied`}}if(eventValidation&&kindEntry.validateEvent!==void 0){const validated=kindEntry.validateEvent({nk:proto.nk,payload:proto.payload});if(!isOk(validated))return"err"in validated?validated.err:{code:"invalid_argument",layer:"storage",retryability:"non-retryable",message:`kind '${proto.kind}' event validation checked empty`}}}return null}checkTombstones(nk,hash,sideEvent){const sameContent=cachedQuery(this.db,`SELECT tomb_id FROM tombstones WHERE source = ? AND stream = ? AND source_id = ? AND content_hash = ?`).get(nk.source,nk.stream,nk.sourceId,hash);if(sameContent!==null)return{id:sameContent.tomb_id,outcome:"erased-suppressed"};const ban=cachedQuery(this.db,`SELECT tomb_id FROM tombstones WHERE source = ? AND stream = ? AND source_id = ? AND future_too = 1`).get(nk.source,nk.stream,nk.sourceId);if(ban!==null){const marker=this.db.query(`SELECT id FROM system_events
|
|
2
2
|
WHERE kind = 'erasure.suppressed' AND erased = 0
|
|
3
3
|
AND json_extract(payload, '$.tomb') = ?
|
|
4
4
|
AND json_extract(payload, '$.nk.source') = ?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DECLARABLE_IDENTITY_QUALITIES,ORIGIN_KINDS,REV_ORDERS,validateIdentityRebindPayload}from"./contracts/index.js";const SYSTEM_STREAMS=["identity","ingest","erasure","security","system"].map(stream=>({source:"rooktrail",stream,revOrder:"upstream-version",quality:"none",noneIdentity:"occurrence"}));const STORAGE_KINDS={"identity.rebind":{allowedOrigins:["kernel","derivation"],validatePayload:validateIdentityRebindPayload},"ingest.anomaly":{allowedOrigins:["kernel"],internalOnly:true},"ingest.unknown-kind":{allowedOrigins:["kernel"],internalOnly:true},"erasure.tombstone":{allowedOrigins:["kernel"],internalOnly:true,reportForgery:true},"erasure.suppressed":{allowedOrigins:["kernel"],internalOnly:true,reportForgery:true},"security.incident":{allowedOrigins:["kernel"],internalOnly:true}};export function streamKey(source,stream){return`${source}\0${stream}`}export function validateStream(row){const name=value=>typeof value==="string"&&value.length>0&&value.length<=1024&&!value.includes("\0");if(!row||Object.keys(row).some(key=>!["source","stream","revOrder","comparator","quality","noneIdentity"].includes(key))||!name(row.source)||!name(row.stream)||row.source==="rooktrail"||!REV_ORDERS.includes(row.revOrder)||row.comparator!==void 0&&!["numeric","lex"].includes(row.comparator)||row.quality!==void 0&&!DECLARABLE_IDENTITY_QUALITIES.includes(row.quality)||row.quality==="none"&&!["state","occurrence"].includes(row.noneIdentity??"")||row.quality!=="none"&&row.noneIdentity!==void 0){throw new TypeError("Invalid stream declaration. The rooktrail source is reserved for storage facts.")}}export function buildStreamMap(registrations){const map=new Map;for(const row of SYSTEM_STREAMS)map.set(streamKey(row.source,row.stream),{...row});for(const row of registrations){validateStream(row);map.set(streamKey(row.source,row.stream),{...row})}return map}export function buildKindMap(registrations={}){const map=new Map;for(const[name,entry]of Object.entries(STORAGE_KINDS))map.set(name,Object.freeze({...entry,allowedOrigins:Object.freeze([...entry.allowedOrigins])}));for(const[name,entry]of Object.entries(registrations)){if(map.has(name))throw new TypeError(`Storage kind '${name}' cannot be overridden.`);if(!name||!entry||Object.keys(entry).some(key=>!["allowedOrigins","validatePayload","validateEvent","conflictIsDataLoss"].includes(key))||!Array.isArray(entry.allowedOrigins)||entry.allowedOrigins.length===0||entry.allowedOrigins.some(origin=>!ORIGIN_KINDS.includes(origin))||entry.validatePayload!==void 0&&typeof entry.validatePayload!=="function"||entry.validateEvent!==void 0&&typeof entry.validateEvent!=="function"||entry.conflictIsDataLoss!==void 0&&typeof entry.conflictIsDataLoss!=="boolean"){throw new TypeError(`Invalid registration for kind '${name}'.`)}map.set(name,Object.freeze({...entry,allowedOrigins:Object.freeze([...entry.allowedOrigins])}))}return map}export function streamJson(row){return{...row}}
|
|
1
|
+
import{DECLARABLE_IDENTITY_QUALITIES,ORIGIN_KINDS,REV_ORDERS,validateIdentityRebindPayload}from"./contracts/index.js";const SYSTEM_STREAMS=["identity","ingest","erasure","security","system"].map(stream=>({source:"rooktrail",stream,revOrder:"upstream-version",quality:"none",noneIdentity:"occurrence"}));const STORAGE_KINDS={"identity.rebind":{allowedOrigins:["kernel","derivation"],validatePayload:validateIdentityRebindPayload},"ingest.anomaly":{allowedOrigins:["kernel"],internalOnly:true},"ingest.unknown-kind":{allowedOrigins:["kernel"],internalOnly:true},"erasure.tombstone":{allowedOrigins:["kernel"],internalOnly:true,reportForgery:true},"erasure.suppressed":{allowedOrigins:["kernel"],internalOnly:true,reportForgery:true},"security.incident":{allowedOrigins:["kernel"],internalOnly:true}};export function streamKey(source,stream){return`${source}\0${stream}`}export function validateStream(row){const name=value=>typeof value==="string"&&value.length>0&&value.length<=1024&&!value.includes("\0");if(!row||Object.keys(row).some(key=>!["source","stream","revOrder","comparator","quality","noneIdentity","deleteKind"].includes(key))||row.deleteKind!==void 0&&!name(row.deleteKind)||!name(row.source)||!name(row.stream)||row.source==="rooktrail"||!REV_ORDERS.includes(row.revOrder)||row.comparator!==void 0&&!["numeric","lex"].includes(row.comparator)||row.quality!==void 0&&!DECLARABLE_IDENTITY_QUALITIES.includes(row.quality)||row.quality==="none"&&!["state","occurrence"].includes(row.noneIdentity??"")||row.quality!=="none"&&row.noneIdentity!==void 0){throw new TypeError("Invalid stream declaration. The rooktrail source is reserved for storage facts.")}}export function buildStreamMap(registrations){const map=new Map;for(const row of SYSTEM_STREAMS)map.set(streamKey(row.source,row.stream),{...row});for(const row of registrations){validateStream(row);map.set(streamKey(row.source,row.stream),{...row})}return map}export function buildKindMap(registrations={}){const map=new Map;for(const[name,entry]of Object.entries(STORAGE_KINDS))map.set(name,Object.freeze({...entry,allowedOrigins:Object.freeze([...entry.allowedOrigins])}));for(const[name,entry]of Object.entries(registrations)){if(map.has(name))throw new TypeError(`Storage kind '${name}' cannot be overridden.`);if(!name||!entry||Object.keys(entry).some(key=>!["allowedOrigins","validatePayload","validateEvent","conflictIsDataLoss"].includes(key))||!Array.isArray(entry.allowedOrigins)||entry.allowedOrigins.length===0||entry.allowedOrigins.some(origin=>!ORIGIN_KINDS.includes(origin))||entry.validatePayload!==void 0&&typeof entry.validatePayload!=="function"||entry.validateEvent!==void 0&&typeof entry.validateEvent!=="function"||entry.conflictIsDataLoss!==void 0&&typeof entry.conflictIsDataLoss!=="boolean"){throw new TypeError(`Invalid registration for kind '${name}'.`)}map.set(name,Object.freeze({...entry,allowedOrigins:Object.freeze([...entry.allowedOrigins])}))}return map}export function streamJson(row){return{...row}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zortexhq/indra-v2.5",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"tag": "next"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
|
-
"description": "Zortex daily 2026-11-
|
|
12
|
+
"description": "Zortex daily 2026-11-24 (source 0.2.0)",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "https://github.com/ZortexHQ/indra-v2.git",
|
|
@@ -1013,9 +1013,9 @@
|
|
|
1013
1013
|
"zortexRelease": {
|
|
1014
1014
|
"schemaVersion": 1,
|
|
1015
1015
|
"sourceVersion": "0.2.0",
|
|
1016
|
-
"sourceSha": "
|
|
1017
|
-
"sourceDate": "2026-11-
|
|
1018
|
-
"version": "0.2.
|
|
1016
|
+
"sourceSha": "b92fbe04080a4da65f2f1fd9a0ab224c3f623b35",
|
|
1017
|
+
"sourceDate": "2026-11-24T16:30:23.000Z",
|
|
1018
|
+
"version": "0.2.8"
|
|
1019
1019
|
},
|
|
1020
1020
|
"zortex": {
|
|
1021
1021
|
"role": "app"
|
|
@@ -1026,6 +1026,6 @@
|
|
|
1026
1026
|
"zortexUpdate": {
|
|
1027
1027
|
"schemaVersion": 1,
|
|
1028
1028
|
"manifest": "update-manifest.json",
|
|
1029
|
-
"sha256": "
|
|
1029
|
+
"sha256": "372eb1c634673bab3094ba9af57d98c786e800ea2f30febce78704e77f3068bc"
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
package/release-provenance.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 3,
|
|
3
3
|
"name": "@zortexhq/indra-v2.5",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"platforms": [
|
|
6
6
|
"win32-x64",
|
|
7
7
|
"win32-arm64",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"sharp"
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
|
-
"commit": "
|
|
18
|
+
"commit": "b92fbe04080a4da65f2f1fd9a0ab224c3f623b35",
|
|
19
19
|
"lockSha256": "9cd89f60594bd55d2f422e016d0b6cf36d01fda8bfc2c8f4ea80796195a40626",
|
|
20
20
|
"platform": "linux",
|
|
21
21
|
"arch": "x64",
|
|
22
22
|
"zortexRelease": {
|
|
23
23
|
"schemaVersion": 1,
|
|
24
24
|
"sourceVersion": "0.2.0",
|
|
25
|
-
"sourceSha": "
|
|
26
|
-
"sourceDate": "2026-11-
|
|
27
|
-
"version": "0.2.
|
|
25
|
+
"sourceSha": "b92fbe04080a4da65f2f1fd9a0ab224c3f623b35",
|
|
26
|
+
"sourceDate": "2026-11-24T16:30:23.000Z",
|
|
27
|
+
"version": "0.2.8"
|
|
28
28
|
},
|
|
29
29
|
"npm": {
|
|
30
30
|
"externalDependencies": {
|
|
@@ -904,10 +904,10 @@
|
|
|
904
904
|
"packages": [
|
|
905
905
|
{
|
|
906
906
|
"name": "@zortexhq/indra-v2.5",
|
|
907
|
-
"version": "0.2.
|
|
907
|
+
"version": "0.2.8",
|
|
908
908
|
"target": "",
|
|
909
|
-
"fileCount":
|
|
910
|
-
"filesSha256": "
|
|
909
|
+
"fileCount": 127,
|
|
910
|
+
"filesSha256": "8b9c2e746c0f28d5de8145cffc934b02ee1a7900630ec277e08adaa419b55881"
|
|
911
911
|
},
|
|
912
912
|
{
|
|
913
913
|
"name": "@abd-enterprises/zendesk-mcp",
|
|
@@ -970,7 +970,7 @@
|
|
|
970
970
|
"version": "0.1.0",
|
|
971
971
|
"target": "node_modules/@zortexhq/plugin-connector-calendar",
|
|
972
972
|
"fileCount": 13,
|
|
973
|
-
"filesSha256": "
|
|
973
|
+
"filesSha256": "884809c1026d5276ac973d0b09305e61f4b6fa106e46c7b8b58d5ea507c34269"
|
|
974
974
|
},
|
|
975
975
|
{
|
|
976
976
|
"name": "@zortexhq/plugin-connector-chrome-history",
|
|
@@ -991,7 +991,7 @@
|
|
|
991
991
|
"version": "0.1.0",
|
|
992
992
|
"target": "node_modules/@zortexhq/plugin-connector-drive",
|
|
993
993
|
"fileCount": 15,
|
|
994
|
-
"filesSha256": "
|
|
994
|
+
"filesSha256": "9f84f7159e010ef733c2dd535c8add9201ca06b18824499cd843a2fc7654017b"
|
|
995
995
|
},
|
|
996
996
|
{
|
|
997
997
|
"name": "@zortexhq/plugin-connector-fleet",
|
|
@@ -1005,14 +1005,14 @@
|
|
|
1005
1005
|
"version": "0.1.0",
|
|
1006
1006
|
"target": "node_modules/@zortexhq/plugin-connector-framework",
|
|
1007
1007
|
"fileCount": 120,
|
|
1008
|
-
"filesSha256": "
|
|
1008
|
+
"filesSha256": "016d6ffc477e4050a34a79a92d0e9eb4f7bc8a2962ba248e03a1995c72e7861f"
|
|
1009
1009
|
},
|
|
1010
1010
|
{
|
|
1011
1011
|
"name": "@zortexhq/plugin-connector-gmail",
|
|
1012
1012
|
"version": "0.1.0",
|
|
1013
1013
|
"target": "node_modules/@zortexhq/plugin-connector-gmail",
|
|
1014
1014
|
"fileCount": 13,
|
|
1015
|
-
"filesSha256": "
|
|
1015
|
+
"filesSha256": "b191c1db7e79cd3a86693e77dd1739f3279a80a99229f84071126b5369b0e63e"
|
|
1016
1016
|
},
|
|
1017
1017
|
{
|
|
1018
1018
|
"name": "@zortexhq/plugin-connector-google-tasks",
|
|
@@ -1026,7 +1026,7 @@
|
|
|
1026
1026
|
"version": "0.1.0",
|
|
1027
1027
|
"target": "node_modules/@zortexhq/plugin-connector-history",
|
|
1028
1028
|
"fileCount": 6,
|
|
1029
|
-
"filesSha256": "
|
|
1029
|
+
"filesSha256": "13e4fd216ef6810a1c09f3ea1bc54cb73ea8741c99cbb86f8171bd5e13e3495c"
|
|
1030
1030
|
},
|
|
1031
1031
|
{
|
|
1032
1032
|
"name": "@zortexhq/plugin-connector-level1",
|
|
@@ -1054,14 +1054,14 @@
|
|
|
1054
1054
|
"version": "0.1.0",
|
|
1055
1055
|
"target": "node_modules/@zortexhq/plugin-connector-outlook",
|
|
1056
1056
|
"fileCount": 8,
|
|
1057
|
-
"filesSha256": "
|
|
1057
|
+
"filesSha256": "6e8b71c7acf499f243f94b1084fd0b34a39d805ffd325c4b9868a94d98677fb5"
|
|
1058
1058
|
},
|
|
1059
1059
|
{
|
|
1060
1060
|
"name": "@zortexhq/plugin-connector-slack",
|
|
1061
1061
|
"version": "0.1.0",
|
|
1062
1062
|
"target": "node_modules/@zortexhq/plugin-connector-slack",
|
|
1063
1063
|
"fileCount": 7,
|
|
1064
|
-
"filesSha256": "
|
|
1064
|
+
"filesSha256": "46e6979fb3ec6fab0299b85fa2748197f47a19618bacbe6c2bfb7cec57821100"
|
|
1065
1065
|
},
|
|
1066
1066
|
{
|
|
1067
1067
|
"name": "@zortexhq/plugin-connector-steam",
|
|
@@ -1096,7 +1096,7 @@
|
|
|
1096
1096
|
"version": "0.1.0",
|
|
1097
1097
|
"target": "node_modules/@zortexhq/plugin-connector-youtube",
|
|
1098
1098
|
"fileCount": 10,
|
|
1099
|
-
"filesSha256": "
|
|
1099
|
+
"filesSha256": "226df67934f3b0fc3d4394093267c00c053582cf7954e2c3e7608193fc20d863"
|
|
1100
1100
|
},
|
|
1101
1101
|
{
|
|
1102
1102
|
"name": "@zortexhq/plugin-context-share",
|
|
@@ -1110,7 +1110,7 @@
|
|
|
1110
1110
|
"version": "0.1.0",
|
|
1111
1111
|
"target": "node_modules/@zortexhq/plugin-device-auth",
|
|
1112
1112
|
"fileCount": 6,
|
|
1113
|
-
"filesSha256": "
|
|
1113
|
+
"filesSha256": "12128126d36bbc7c7329470d4f0614459381bc0ca0ae2173904af8a84ee72565"
|
|
1114
1114
|
},
|
|
1115
1115
|
{
|
|
1116
1116
|
"name": "@zortexhq/plugin-drive-content",
|
|
@@ -1131,7 +1131,7 @@
|
|
|
1131
1131
|
"version": "0.1.0",
|
|
1132
1132
|
"target": "node_modules/@zortexhq/plugin-google-auth",
|
|
1133
1133
|
"fileCount": 4,
|
|
1134
|
-
"filesSha256": "
|
|
1134
|
+
"filesSha256": "30a7bdfc4b6b243e5df0839104abeab0f831d6daa174588d038cc0785c3173b4"
|
|
1135
1135
|
},
|
|
1136
1136
|
{
|
|
1137
1137
|
"name": "@zortexhq/plugin-local-source-access",
|
|
@@ -1179,15 +1179,15 @@
|
|
|
1179
1179
|
"name": "@zortexhq/plugin-vault-sqlite",
|
|
1180
1180
|
"version": "0.1.0",
|
|
1181
1181
|
"target": "node_modules/@zortexhq/plugin-vault-sqlite",
|
|
1182
|
-
"fileCount":
|
|
1183
|
-
"filesSha256": "
|
|
1182
|
+
"fileCount": 45,
|
|
1183
|
+
"filesSha256": "7c28acbfe70d01350b4479550b3e15b63f9ca7f79e9af63f349d7b39aef55899"
|
|
1184
1184
|
},
|
|
1185
1185
|
{
|
|
1186
1186
|
"name": "@zortexhq/rooktrail",
|
|
1187
1187
|
"version": "0.1.0",
|
|
1188
1188
|
"target": "node_modules/@zortexhq/rooktrail",
|
|
1189
1189
|
"fileCount": 23,
|
|
1190
|
-
"filesSha256": "
|
|
1190
|
+
"filesSha256": "367116045e34b9d638209a4f472aeb2fe20217e6a2f9606d286e63ac518f0f84"
|
|
1191
1191
|
},
|
|
1192
1192
|
{
|
|
1193
1193
|
"name": "commander",
|