arkgate 4.8.25 → 4.8.27

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +2 -2
  3. package/bin/ark-layer-match.mjs +23 -0
  4. package/bin/ark-mcp-runtime.mjs +45 -4
  5. package/bin/ark-mcp.mjs +9 -3
  6. package/bin/ark.mjs +27 -1
  7. package/bin/lib/analysis-engine.mjs +10 -10
  8. package/bin/lib/arkrules-sensors.mjs +9 -4
  9. package/bin/lib/class-source-scan.mjs +1 -1
  10. package/bin/lib/config-contract.mjs +5 -0
  11. package/bin/lib/policy-delta-io.mjs +5 -4
  12. package/bin/lib/prepare-change.mjs +10 -6
  13. package/bin/lib/prepare-write.mjs +7 -0
  14. package/bin/lib/project-root.mjs +12 -23
  15. package/bin/lib/remediation.mjs +84 -0
  16. package/bin/lib/resolved-candidate-facts.mjs +19 -2
  17. package/bin/lib/snippet-analysis.mjs +82 -1
  18. package/dist/chunk-A5EIY3HI.cjs +3 -3
  19. package/dist/chunk-H5I3GARV.js +16 -0
  20. package/dist/chunk-QQ4SJEJ7.cjs +16 -0
  21. package/dist/chunk-SVSQVGFJ.js +3 -3
  22. package/dist/{configTypes-GPvvdleM.d.cts → configTypes-D1oxws6x.d.cts} +6 -0
  23. package/dist/{configTypes-GPvvdleM.d.ts → configTypes-D1oxws6x.d.ts} +6 -0
  24. package/dist/eslint/index.cjs +11 -12
  25. package/dist/eslint/index.d.cts +7 -1
  26. package/dist/eslint/index.d.ts +7 -1
  27. package/dist/eslint/index.js +11 -11
  28. package/dist/index.cjs +32 -32
  29. package/dist/index.d.cts +13 -2
  30. package/dist/index.d.ts +13 -2
  31. package/dist/index.js +32 -32
  32. package/dist/inspectorListen-6DQVJ4DC.js +2 -1
  33. package/dist/inspectorListen-KGMIQ2TF.cjs +2 -1
  34. package/dist/nestjs/index.cjs +1 -1
  35. package/dist/nestjs/index.d.cts +1 -1
  36. package/dist/nestjs/index.d.ts +1 -1
  37. package/dist/nestjs/index.js +1 -1
  38. package/dist/order/index.cjs +1 -1
  39. package/dist/order/index.js +1 -1
  40. package/dist/runtime/index.cjs +10 -10
  41. package/dist/runtime/index.d.cts +4 -3
  42. package/dist/runtime/index.d.ts +4 -3
  43. package/dist/runtime/index.js +10 -10
  44. package/dist/{types-CnauMQQL.d.cts → types-DBiqlOWZ.d.cts} +6 -0
  45. package/dist/{types-CnauMQQL.d.ts → types-DBiqlOWZ.d.ts} +6 -0
  46. package/docs/README.md +3 -1
  47. package/docs/agent-guide.md +9 -6
  48. package/docs/ai-gates.md +1 -1
  49. package/docs/configuration.md +11 -0
  50. package/docs/diagnostics.md +1 -1
  51. package/docs/package-surface.md +2 -1
  52. package/docs/product-voice.md +1 -1
  53. package/package.json +1 -1
  54. package/schemas/ark.config.schema.json +10 -0
  55. package/server.json +2 -2
  56. package/templates/agent-skills/README.md +1 -1
  57. package/templates/agent-skills/ark-adopt/SKILL.md +6 -0
  58. package/templates/agent-skills/ark-autopilot/SKILL.md +1 -1
  59. package/templates/agent-skills/ark-place/SKILL.md +4 -0
  60. package/templates/skills/ark-adopt.md +6 -0
  61. package/templates/skills/ark-autopilot.md +1 -1
  62. package/templates/skills/ark-place.md +4 -0
  63. package/dist/chunk-AHACEKSV.js +0 -16
  64. package/dist/chunk-UN5EH4QV.cjs +0 -16
@@ -1 +1,2 @@
1
- import{B as I,C as m,D as w,E as A,F as g,I as v,K as R,M as O,O as l,R as _,S as x,T as M,U as T,W as b,a,n as S,p as E}from"./chunk-SVSQVGFJ.js";function U(){return{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}}a(U,"jsonHeaders");function N(){return{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-store",connection:"keep-alive","x-accel-buffering":"no"}}a(N,"sseHeaders");function H(r){let n=(r&&r.length>0?r:"/").replace(/^\/+/,"/");return new URL(n,"http://127.0.0.1")}a(H,"requestUrl");function u(r,n,c){if(!(r.writableEnded||r.destroyed))try{r.writeHead(n,U()),r.end(JSON.stringify(c))}catch{}}a(u,"writeJson");function G(r,n){let c=r.address();if(c===null||typeof c=="string")throw new R(n.host);if(!O(c.address))throw new R(c.address);return{host:n.host,port:c.port}}a(G,"boundAddress");async function L(r){if(typeof r.listInspectorOutbox=="function")return r.listInspectorOutbox();let n=r.outbox??r.eventBuffer;if(!n||typeof n.list!="function")return x();let[c,d]=await Promise.all([n.list("pending"),n.list("failed")]);return _([...c??[],...d??[]],{sampleLimit:v})}a(L,"resolveOutboxMonitor");async function W(r){return typeof r.listInspectorWorkflows=="function"?r.listInspectorWorkflows():!r.workflowEngine||typeof r.workflowEngine.list!="function"?T():M(await r.workflowEngine.list(),{sampleLimit:v})}a(W,"resolveWorkflowsMonitor");async function C(r,n){let c=await import("http"),d=new Set,h=new Set,y=typeof n.sseIntervalMs=="number"&&Number.isFinite(n.sseIntervalMs)?Math.max(0,n.sseIntervalMs):1e3,s=n.bind,k=a(()=>r.getInspectorSnapshot(s),"snapshot"),f=c.createServer((o,t)=>{let i=H(o.url),p=i.pathname;if(o.method==="GET"&&(p==="/"||p===I)){u(t,200,k());return}if(o.method==="GET"&&p===w){try{u(t,200,r.requestGraph(E({slice:i.searchParams.get("slice"),nodeIds:i.searchParams.get("nodeIds"),degreesOfSeparation:i.searchParams.get("degreesOfSeparation"),include:i.searchParams.get("include"),exclude:i.searchParams.get("exclude")})))}catch(e){if(e instanceof S){u(t,400,{error:e.message,option:e.option});return}throw e}return}if(o.method==="GET"&&p===A){L(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"outbox monitor failed"})});return}if(o.method==="GET"&&p===g){W(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"workflows monitor failed"})});return}if(o.method==="GET"&&p===m){t.writeHead(200,N()),t.flushHeaders(),t.write(b(k())),d.add(t);let e=y>0?setInterval(()=>{t.write(b(k()))},y):void 0;e&&h.add(e);let P=a(()=>{d.delete(t),e&&(clearInterval(e),h.delete(e))},"drop");o.on("close",P),t.on("close",P);return}u(t,404,{error:"not found"})});try{await new Promise((o,t)=>{let i=a(p=>t(p),"onError");f.once("error",i),f.listen({host:n.bind.host,port:n.bind.port},()=>{f.off("error",i);try{s=G(f,n.bind),o()}catch(p){t(p instanceof Error?p:new R(n.bind.host))}})})}catch(o){throw await new Promise(t=>{f.close(()=>t())}),o}return{host:s.host,port:s.port,url:l(s.host,s.port,"/"),snapshotUrl:l(s.host,s.port,I),eventsUrl:l(s.host,s.port,m),graphUrl:l(s.host,s.port,w),outboxUrl:l(s.host,s.port,A),workflowsUrl:l(s.host,s.port,g),close(){for(let o of h)clearInterval(o);h.clear();for(let o of d)o.end();return d.clear(),new Promise((o,t)=>{f.close(i=>{i?t(i):o()})})}}}a(C,"listenArkRunInspector");export{C as listenArkRunInspector};
1
+ import {a,K,M,S,R,I,U as U$1,T,B,D,p,n,E,F,C as C$1,W as W$1,O}from'./chunk-SVSQVGFJ.js';function U(){return {"content-type":"application/json; charset=utf-8","cache-control":"no-store"}}a(U,"jsonHeaders");function N(){return {"content-type":"text/event-stream; charset=utf-8","cache-control":"no-store",connection:"keep-alive","x-accel-buffering":"no"}}a(N,"sseHeaders");function H(r){let n=(r&&r.length>0?r:"/").replace(/^\/+/,"/");return new URL(n,"http://127.0.0.1")}a(H,"requestUrl");function u(r,n,c){if(!(r.writableEnded||r.destroyed))try{r.writeHead(n,U()),r.end(JSON.stringify(c));}catch{}}a(u,"writeJson");function G(r,n){let c=r.address();if(c===null||typeof c=="string")throw new K(n.host);if(!M(c.address))throw new K(c.address);return {host:n.host,port:c.port}}a(G,"boundAddress");async function L(r){if(typeof r.listInspectorOutbox=="function")return r.listInspectorOutbox();let n=r.outbox??r.eventBuffer;if(!n||typeof n.list!="function")return S();let[c,d]=await Promise.all([n.list("pending"),n.list("failed")]);return R([...c??[],...d??[]],{sampleLimit:I})}a(L,"resolveOutboxMonitor");async function W(r){return typeof r.listInspectorWorkflows=="function"?r.listInspectorWorkflows():!r.workflowEngine||typeof r.workflowEngine.list!="function"?U$1():T(await r.workflowEngine.list(),{sampleLimit:I})}a(W,"resolveWorkflowsMonitor");async function C(r,n$1){let c=await import('http'),d=new Set,h=new Set,y=typeof n$1.sseIntervalMs=="number"&&Number.isFinite(n$1.sseIntervalMs)?Math.max(0,n$1.sseIntervalMs):1e3,s=n$1.bind,k=a(()=>r.getInspectorSnapshot(s),"snapshot"),f=c.createServer((o,t)=>{let i=H(o.url),p$1=i.pathname;if(o.method==="GET"&&(p$1==="/"||p$1===B)){u(t,200,k());return}if(o.method==="GET"&&p$1===D){try{u(t,200,r.requestGraph(p({slice:i.searchParams.get("slice"),nodeIds:i.searchParams.get("nodeIds"),degreesOfSeparation:i.searchParams.get("degreesOfSeparation"),include:i.searchParams.get("include"),exclude:i.searchParams.get("exclude")})));}catch(e){if(e instanceof n){u(t,400,{error:e.message,option:e.option});return}throw e}return}if(o.method==="GET"&&p$1===E){L(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"outbox monitor failed"});});return}if(o.method==="GET"&&p$1===F){W(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"workflows monitor failed"});});return}if(o.method==="GET"&&p$1===C$1){t.writeHead(200,N()),t.flushHeaders(),t.write(W$1(k())),d.add(t);let e=y>0?setInterval(()=>{t.write(W$1(k()));},y):void 0;e&&h.add(e);let P=a(()=>{d.delete(t),e&&(clearInterval(e),h.delete(e));},"drop");o.on("close",P),t.on("close",P);return}u(t,404,{error:"not found"});});try{await new Promise((o,t)=>{let i=a(p=>t(p),"onError");f.once("error",i),f.listen({host:n$1.bind.host,port:n$1.bind.port},()=>{f.off("error",i);try{s=G(f,n$1.bind),o();}catch(p){t(p instanceof Error?p:new K(n$1.bind.host));}});});}catch(o){throw await new Promise(t=>{f.close(()=>t());}),o}return {host:s.host,port:s.port,url:O(s.host,s.port,"/"),snapshotUrl:O(s.host,s.port,B),eventsUrl:O(s.host,s.port,C$1),graphUrl:O(s.host,s.port,D),outboxUrl:O(s.host,s.port,E),workflowsUrl:O(s.host,s.port,F),close(){for(let o of h)clearInterval(o);h.clear();for(let o of d)o.end();return d.clear(),new Promise((o,t)=>{f.close(i=>{i?t(i):o();});})}}}a(C,"listenArkRunInspector");
2
+ export{C as listenArkRunInspector};
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkA5EIY3HIcjs = require('./chunk-A5EIY3HI.cjs');function U(){return{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}}_chunkA5EIY3HIcjs.a.call(void 0, U,"jsonHeaders");function N(){return{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-store",connection:"keep-alive","x-accel-buffering":"no"}}_chunkA5EIY3HIcjs.a.call(void 0, N,"sseHeaders");function H(r){let n=(r&&r.length>0?r:"/").replace(/^\/+/,"/");return new URL(n,"http://127.0.0.1")}_chunkA5EIY3HIcjs.a.call(void 0, H,"requestUrl");function u(r,n,c){if(!(r.writableEnded||r.destroyed))try{r.writeHead(n,U()),r.end(JSON.stringify(c))}catch (e2){}}_chunkA5EIY3HIcjs.a.call(void 0, u,"writeJson");function G(r,n){let c=r.address();if(c===null||typeof c=="string")throw new (0, _chunkA5EIY3HIcjs.K)(n.host);if(!_chunkA5EIY3HIcjs.M.call(void 0, c.address))throw new (0, _chunkA5EIY3HIcjs.K)(c.address);return{host:n.host,port:c.port}}_chunkA5EIY3HIcjs.a.call(void 0, G,"boundAddress");async function L(r){if(typeof r.listInspectorOutbox=="function")return r.listInspectorOutbox();let n=_nullishCoalesce(r.outbox, () => (r.eventBuffer));if(!n||typeof n.list!="function")return _chunkA5EIY3HIcjs.S.call(void 0, );let[c,d]=await Promise.all([n.list("pending"),n.list("failed")]);return _chunkA5EIY3HIcjs.R.call(void 0, [..._nullishCoalesce(c, () => ([])),..._nullishCoalesce(d, () => ([]))],{sampleLimit:_chunkA5EIY3HIcjs.I})}_chunkA5EIY3HIcjs.a.call(void 0, L,"resolveOutboxMonitor");async function W(r){return typeof r.listInspectorWorkflows=="function"?r.listInspectorWorkflows():!r.workflowEngine||typeof r.workflowEngine.list!="function"?_chunkA5EIY3HIcjs.U.call(void 0, ):_chunkA5EIY3HIcjs.T.call(void 0, await r.workflowEngine.list(),{sampleLimit:_chunkA5EIY3HIcjs.I})}_chunkA5EIY3HIcjs.a.call(void 0, W,"resolveWorkflowsMonitor");async function C(r,n){let c=await Promise.resolve().then(() => _interopRequireWildcard(require("http"))),d=new Set,h=new Set,y=typeof n.sseIntervalMs=="number"&&Number.isFinite(n.sseIntervalMs)?Math.max(0,n.sseIntervalMs):1e3,s=n.bind,k=_chunkA5EIY3HIcjs.a.call(void 0, ()=>r.getInspectorSnapshot(s),"snapshot"),f=c.createServer((o,t)=>{let i=H(o.url),p=i.pathname;if(o.method==="GET"&&(p==="/"||p===_chunkA5EIY3HIcjs.B)){u(t,200,k());return}if(o.method==="GET"&&p===_chunkA5EIY3HIcjs.D){try{u(t,200,r.requestGraph(_chunkA5EIY3HIcjs.p.call(void 0, {slice:i.searchParams.get("slice"),nodeIds:i.searchParams.get("nodeIds"),degreesOfSeparation:i.searchParams.get("degreesOfSeparation"),include:i.searchParams.get("include"),exclude:i.searchParams.get("exclude")})))}catch(e){if(e instanceof _chunkA5EIY3HIcjs.n){u(t,400,{error:e.message,option:e.option});return}throw e}return}if(o.method==="GET"&&p===_chunkA5EIY3HIcjs.E){L(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"outbox monitor failed"})});return}if(o.method==="GET"&&p===_chunkA5EIY3HIcjs.F){W(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"workflows monitor failed"})});return}if(o.method==="GET"&&p===_chunkA5EIY3HIcjs.C){t.writeHead(200,N()),t.flushHeaders(),t.write(_chunkA5EIY3HIcjs.W.call(void 0, k())),d.add(t);let e=y>0?setInterval(()=>{t.write(_chunkA5EIY3HIcjs.W.call(void 0, k()))},y):void 0;e&&h.add(e);let P=_chunkA5EIY3HIcjs.a.call(void 0, ()=>{d.delete(t),e&&(clearInterval(e),h.delete(e))},"drop");o.on("close",P),t.on("close",P);return}u(t,404,{error:"not found"})});try{await new Promise((o,t)=>{let i=_chunkA5EIY3HIcjs.a.call(void 0, p=>t(p),"onError");f.once("error",i),f.listen({host:n.bind.host,port:n.bind.port},()=>{f.off("error",i);try{s=G(f,n.bind),o()}catch(p){t(p instanceof Error?p:new (0, _chunkA5EIY3HIcjs.K)(n.bind.host))}})})}catch(o){throw await new Promise(t=>{f.close(()=>t())}),o}return{host:s.host,port:s.port,url:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,"/"),snapshotUrl:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,_chunkA5EIY3HIcjs.B),eventsUrl:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,_chunkA5EIY3HIcjs.C),graphUrl:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,_chunkA5EIY3HIcjs.D),outboxUrl:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,_chunkA5EIY3HIcjs.E),workflowsUrl:_chunkA5EIY3HIcjs.O.call(void 0, s.host,s.port,_chunkA5EIY3HIcjs.F),close(){for(let o of h)clearInterval(o);h.clear();for(let o of d)o.end();return d.clear(),new Promise((o,t)=>{f.close(i=>{i?t(i):o()})})}}}_chunkA5EIY3HIcjs.a.call(void 0, C,"listenArkRunInspector");exports.listenArkRunInspector = C;
1
+ 'use strict';var chunkA5EIY3HI_cjs=require('./chunk-A5EIY3HI.cjs');function U(){return {"content-type":"application/json; charset=utf-8","cache-control":"no-store"}}chunkA5EIY3HI_cjs.a(U,"jsonHeaders");function N(){return {"content-type":"text/event-stream; charset=utf-8","cache-control":"no-store",connection:"keep-alive","x-accel-buffering":"no"}}chunkA5EIY3HI_cjs.a(N,"sseHeaders");function H(r){let n=(r&&r.length>0?r:"/").replace(/^\/+/,"/");return new URL(n,"http://127.0.0.1")}chunkA5EIY3HI_cjs.a(H,"requestUrl");function u(r,n,c){if(!(r.writableEnded||r.destroyed))try{r.writeHead(n,U()),r.end(JSON.stringify(c));}catch{}}chunkA5EIY3HI_cjs.a(u,"writeJson");function G(r,n){let c=r.address();if(c===null||typeof c=="string")throw new chunkA5EIY3HI_cjs.K(n.host);if(!chunkA5EIY3HI_cjs.M(c.address))throw new chunkA5EIY3HI_cjs.K(c.address);return {host:n.host,port:c.port}}chunkA5EIY3HI_cjs.a(G,"boundAddress");async function L(r){if(typeof r.listInspectorOutbox=="function")return r.listInspectorOutbox();let n=r.outbox??r.eventBuffer;if(!n||typeof n.list!="function")return chunkA5EIY3HI_cjs.S();let[c,d]=await Promise.all([n.list("pending"),n.list("failed")]);return chunkA5EIY3HI_cjs.R([...c??[],...d??[]],{sampleLimit:chunkA5EIY3HI_cjs.I})}chunkA5EIY3HI_cjs.a(L,"resolveOutboxMonitor");async function W(r){return typeof r.listInspectorWorkflows=="function"?r.listInspectorWorkflows():!r.workflowEngine||typeof r.workflowEngine.list!="function"?chunkA5EIY3HI_cjs.U():chunkA5EIY3HI_cjs.T(await r.workflowEngine.list(),{sampleLimit:chunkA5EIY3HI_cjs.I})}chunkA5EIY3HI_cjs.a(W,"resolveWorkflowsMonitor");async function C(r,n){let c=await import('http'),d=new Set,h=new Set,y=typeof n.sseIntervalMs=="number"&&Number.isFinite(n.sseIntervalMs)?Math.max(0,n.sseIntervalMs):1e3,s=n.bind,k=chunkA5EIY3HI_cjs.a(()=>r.getInspectorSnapshot(s),"snapshot"),f=c.createServer((o,t)=>{let i=H(o.url),p=i.pathname;if(o.method==="GET"&&(p==="/"||p===chunkA5EIY3HI_cjs.B)){u(t,200,k());return}if(o.method==="GET"&&p===chunkA5EIY3HI_cjs.D){try{u(t,200,r.requestGraph(chunkA5EIY3HI_cjs.p({slice:i.searchParams.get("slice"),nodeIds:i.searchParams.get("nodeIds"),degreesOfSeparation:i.searchParams.get("degreesOfSeparation"),include:i.searchParams.get("include"),exclude:i.searchParams.get("exclude")})));}catch(e){if(e instanceof chunkA5EIY3HI_cjs.n){u(t,400,{error:e.message,option:e.option});return}throw e}return}if(o.method==="GET"&&p===chunkA5EIY3HI_cjs.E){L(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"outbox monitor failed"});});return}if(o.method==="GET"&&p===chunkA5EIY3HI_cjs.F){W(r).then(e=>u(t,200,e)).catch(e=>{u(t,500,{error:e instanceof Error?e.message:"workflows monitor failed"});});return}if(o.method==="GET"&&p===chunkA5EIY3HI_cjs.C){t.writeHead(200,N()),t.flushHeaders(),t.write(chunkA5EIY3HI_cjs.W(k())),d.add(t);let e=y>0?setInterval(()=>{t.write(chunkA5EIY3HI_cjs.W(k()));},y):void 0;e&&h.add(e);let P=chunkA5EIY3HI_cjs.a(()=>{d.delete(t),e&&(clearInterval(e),h.delete(e));},"drop");o.on("close",P),t.on("close",P);return}u(t,404,{error:"not found"});});try{await new Promise((o,t)=>{let i=chunkA5EIY3HI_cjs.a(p=>t(p),"onError");f.once("error",i),f.listen({host:n.bind.host,port:n.bind.port},()=>{f.off("error",i);try{s=G(f,n.bind),o();}catch(p){t(p instanceof Error?p:new chunkA5EIY3HI_cjs.K(n.bind.host));}});});}catch(o){throw await new Promise(t=>{f.close(()=>t());}),o}return {host:s.host,port:s.port,url:chunkA5EIY3HI_cjs.O(s.host,s.port,"/"),snapshotUrl:chunkA5EIY3HI_cjs.O(s.host,s.port,chunkA5EIY3HI_cjs.B),eventsUrl:chunkA5EIY3HI_cjs.O(s.host,s.port,chunkA5EIY3HI_cjs.C),graphUrl:chunkA5EIY3HI_cjs.O(s.host,s.port,chunkA5EIY3HI_cjs.D),outboxUrl:chunkA5EIY3HI_cjs.O(s.host,s.port,chunkA5EIY3HI_cjs.E),workflowsUrl:chunkA5EIY3HI_cjs.O(s.host,s.port,chunkA5EIY3HI_cjs.F),close(){for(let o of h)clearInterval(o);h.clear();for(let o of d)o.end();return d.clear(),new Promise((o,t)=>{f.close(i=>{i?t(i):o();});})}}}chunkA5EIY3HI_cjs.a(C,"listenArkRunInspector");
2
+ exports.listenArkRunInspector=C;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkUN5EH4QVcjs = require('../chunk-UN5EH4QV.cjs');var _chunkA5EIY3HIcjs = require('../chunk-A5EIY3HI.cjs');var _common = require('@nestjs/common');var t=Symbol("ARK_KERNEL"),y= exports.InjectArk =_chunkA5EIY3HIcjs.a.call(void 0, ()=>_common.Inject.call(void 0, t),"InjectArk"),e= exports.ArkModule =class{static forRoot(r){let i=r&&"registry"in r?r:_chunkUN5EH4QVcjs.va.call(void 0, r);return{module:e,global:!0,providers:[{provide:t,useValue:i}],exports:[t]}}static forRootAsync(r){return{module:e,global:!0,providers:[{provide:t,useFactory:r.useFactory,inject:_nullishCoalesce(r.inject, () => ([]))}],exports:[t]}}};_chunkA5EIY3HIcjs.a.call(void 0, e,"ArkModule"),e= exports.ArkModule =_chunkA5EIY3HIcjs.b.call(void 0, [_common.Module.call(void 0, {})],e);exports.ARK_KERNEL = t; exports.ArkModule = e; exports.InjectArk = y;
1
+ 'use strict';var chunkQQ4SJEJ7_cjs=require('../chunk-QQ4SJEJ7.cjs'),chunkA5EIY3HI_cjs=require('../chunk-A5EIY3HI.cjs'),common=require('@nestjs/common');var t=Symbol("ARK_KERNEL"),y=chunkA5EIY3HI_cjs.a(()=>common.Inject(t),"InjectArk");exports.ArkModule=class e{static forRoot(r){let i=r&&"registry"in r?r:chunkQQ4SJEJ7_cjs.va(r);return {module:exports.ArkModule,global:true,providers:[{provide:t,useValue:i}],exports:[t]}}static forRootAsync(r){return {module:exports.ArkModule,global:true,providers:[{provide:t,useFactory:r.useFactory,inject:r.inject??[]}],exports:[t]}}};chunkA5EIY3HI_cjs.a(exports.ArkModule,"ArkModule"),exports.ArkModule=chunkA5EIY3HI_cjs.b([common.Module({})],exports.ArkModule);exports.ARK_KERNEL=t;exports.InjectArk=y;
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
2
- import { A as ArkKernel, C as CreateArkKernelOptions } from '../types-CnauMQQL.cjs';
2
+ import { A as ArkKernel, C as CreateArkKernelOptions } from '../types-DBiqlOWZ.cjs';
3
3
 
4
4
  /** Injection token for the Ark kernel instance. */
5
5
  declare const ARK_KERNEL: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
2
- import { A as ArkKernel, C as CreateArkKernelOptions } from '../types-CnauMQQL.js';
2
+ import { A as ArkKernel, C as CreateArkKernelOptions } from '../types-DBiqlOWZ.js';
3
3
 
4
4
  /** Injection token for the Ark kernel instance. */
5
5
  declare const ARK_KERNEL: unique symbol;
@@ -1 +1 @@
1
- import{va as c}from"../chunk-AHACEKSV.js";import{a as o,b as n}from"../chunk-SVSQVGFJ.js";import{Inject as p,Module as s}from"@nestjs/common";var t=Symbol("ARK_KERNEL"),y=o(()=>p(t),"InjectArk"),e=class{static forRoot(r){let i=r&&"registry"in r?r:c(r);return{module:e,global:!0,providers:[{provide:t,useValue:i}],exports:[t]}}static forRootAsync(r){return{module:e,global:!0,providers:[{provide:t,useFactory:r.useFactory,inject:r.inject??[]}],exports:[t]}}};o(e,"ArkModule"),e=n([s({})],e);export{t as ARK_KERNEL,e as ArkModule,y as InjectArk};
1
+ import {va}from'../chunk-H5I3GARV.js';import {a,b}from'../chunk-SVSQVGFJ.js';import {Inject,Module}from'@nestjs/common';var t=Symbol("ARK_KERNEL"),y=a(()=>Inject(t),"InjectArk"),e=class{static forRoot(r){let i=r&&"registry"in r?r:va(r);return {module:e,global:true,providers:[{provide:t,useValue:i}],exports:[t]}}static forRootAsync(r){return {module:e,global:true,providers:[{provide:t,useFactory:r.useFactory,inject:r.inject??[]}],exports:[t]}}};a(e,"ArkModule"),e=b([Module({})],e);export{t as ARK_KERNEL,e as ArkModule,y as InjectArk};
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var o=(e,r)=>b(e,"name",{value:r,configurable:!0});var se=(e,r)=>{for(var n in r)b(e,n,{get:r[n],enumerable:!0})},ie=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of oe(r))!ae.call(e,t)&&t!==n&&b(e,t,{get:()=>r[t],enumerable:!(s=te(r,t))||s.enumerable});return e};var ce=e=>ie(b({},"__esModule",{value:!0}),e);var ye={};se(ye,{ArkOrderError:()=>c,CAPACITY_OPS:()=>k,DEFAULT_MAX_XI_KEYS:()=>E,createMemoryReleaseStore:()=>ne,createOrderPlane:()=>re,hashOf:()=>h,hashReleasePayload:()=>h,ingestTravelAction:()=>Y});module.exports=ce(ye);var c=class extends Error{static{o(this,"ArkOrderError")}code;constructor(r,n){super(n),this.name="ArkOrderError",this.code=r}};var E=7,B=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var k=["lte","lt","gte","gt"];function y(e){let r=2166136261;for(let n=0;n<e.length;n+=1)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return`fnv1a-${(r>>>0).toString(16).padStart(8,"0")}`}o(y,"deterministicHash");function p(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(p).join(",")}]`;let r=e;return`{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${p(r[n])}`).join(",")}}`}o(p,"stableSerialize");function Y(e){return e.kind==="absorb"?"send":e.kind==="escalate_up"&&e.target==="human"?"raises":"none"}o(Y,"ingestTravelAction");var le=["update","patch","set","mutate"];function U(e){return le.includes(e)}o(U,"isForbiddenPlaneMethod");function de(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean"}o(de,"isPrimitive");function m(e,r){let n=Object.keys(e);if(n.length===0&&r==="\u03BE")throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");let s={};for(let t of n.sort()){let a=e[t];if(typeof a=="number"&&!Number.isFinite(a))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(t)} is a non-finite number (NaN/\xB1Infinity has no stable identity)`);if(!de(a))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(t)} is not a slow primitive (nested values are microstate)`);s[t]=Object.is(a,-0)?0:a}return Object.freeze(s)}o(m,"freezeRecord");function X(e,r){let n=Object.keys(e).length;if(n===0)throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");if(n>r)throw new c("ARKORDER_TOO_MANY_PARAMS",`\u03BE has ${n} keys; maxXiKeys is ${r} (Haken: few slow modes)`)}o(X,"assertXiKeyCap");function D(e,r){if(!r)return;let n=r.properties??{},s=r.additionalProperties!==!1;for(let t of Object.keys(e)){let a=n[t];if(!a){if(!s)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(t)} is not in xiSchema.properties`);continue}if(a.enum&&!a.enum.some(d=>d===e[t]))throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(t)} value is not in enum`);if(a.type==="null"&&e[t]!==null)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(t)} must be null`);if(a.type&&a.type!=="null"&&typeof e[t]!==a.type)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(t)} must be ${a.type}`)}}o(D,"assertXiSchema");function z(e,r){if(typeof r=="string"&&Object.prototype.hasOwnProperty.call(e,"catalogReleaseId"))return r}o(z,"catalogDigestFor");function h(e,r,n){let s=z(e,n);return s!==void 0?y(p({xi:e,sigma:r,catalogDigest:s})):y(p({xi:e,sigma:r}))}o(h,"hashReleasePayload");function T(e,r){let n=z(e,r);return n!==void 0?y(p({xi:e,catalogDigest:n})):y(p({xi:e}))}o(T,"hashXiIdentity");function _(e){return y(p({sigma:e}))}o(_,"hashSigmaIdentity");function J(e,r){return p(e)===p(r)}o(J,"xiRecordsEqual");function K(e,r){if(e&&!J(e.xi,r))throw new c("ARKORDER_UNVALVED_RELEASE","\u03BE is frozen; change the pattern with proposeRelease then apply(ProposeResult)")}o(K,"assertUnvalvedRelease");function j(e){X(e.xi,e.maxXiKeys);let r=m(e.xi,"\u03BE");C(r),D(r,e.xiSchema);let n=m(e.sigma??{},"\u03C3");return Object.freeze({version:e.version,hash:h(r,n,e.catalogDigest),xiHash:T(r,e.catalogDigest),sigmaHash:_(n),xi:r,sigma:n,releasedAt:e.now})}o(j,"createFrozenRelease");function V(e){let r=m(e.sigma,"\u03C3");return Object.freeze({version:e.current.version,hash:h(e.current.xi,r,e.catalogDigest),xiHash:e.current.xiHash,sigmaHash:_(r),xi:e.current.xi,sigma:r,releasedAt:e.now})}o(V,"refreshSigmaRecord");function C(e){for(let r of Object.keys(e))if(B.test(r))throw new c("ARKORDER_XI_TTL",`\u03BE key ${JSON.stringify(r)} is a freshness field; TTL belongs on \u03C3, never on \u03BE`)}o(C,"assertXiHasNoTtl");function w(e,r){if(!r||r.cannotObserve.length===0)return;let n=new Set(r.cannotObserve);for(let s of e.allowedKinds)if(n.has(s))throw new c("ARKORDER_INFORMATION_BUDGET",`projection allows ${JSON.stringify(s)}; informationBudget.cannotObserve forbids it`)}o(w,"assertInformationBudget");function G(e){let r=e.sigma.freshUntil;if(typeof r=="number"){if(e.now>r)throw new c("ARKORDER_STALE_SIGMA","\u03C3 freshUntil has elapsed; \u03BE does not TTL");return}if(e.maxAgeMs===void 0)return;let n=typeof e.sigma.releasedAt=="number"?e.sigma.releasedAt:e.releasedAt;if(typeof n=="number"&&e.now-n>e.maxAgeMs)throw new c("ARKORDER_STALE_SIGMA","\u03C3 is older than sigmaMaxAgeMs; \u03BE does not TTL")}o(G,"assertSigmaFresh");function v(e){return y(p({kind:e.kind,payload:e.payload??null}))}o(v,"fieldEventIdentity");function ue(e,r){return{event:e,xiHash:r,eventId:v(e)}}o(ue,"bindResidual");var ge=new Set(k);function fe(e){return typeof e=="string"&&ge.has(e)}o(fe,"isCapacityOp");function L(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}o(L,"numericLeaf");function pe(e,r,n){return r==="lte"?e<=n:r==="lt"?e<n:r==="gte"?e>=n:e>n}o(pe,"compareCapacity");function O(e){return typeof e=="function"?!0:e===null||typeof e!="object"?!1:Array.isArray(e)?e.some(O):Object.values(e).some(O)}o(O,"packHasFunction");function Re(e,r,n){let s=n.capacity??[];for(let t of s){if(O(t)||!fe(t.op))return"pack";if(t.kind!==e.kind)continue;let a=e.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?L(e.payload[t.payloadKey]):void 0,d=L(r[t.sigmaKey]);if(a===void 0||d===void 0)return"pack";if(!pe(a,t.op,d))return"capacity"}return"ok"}o(Re,"evaluateCapacity");function q(e,r,n=[],s="",t=Object.freeze({})){let a=r.kind,d=ue(r,s);for(let u of n){if(O(u.capacity)||O(u.escalateKinds))return{...d,kind:"hold",reasonCode:"pack",reason:`pack ${u.id} is not data-only; user predicates are forbidden`};if(u.escalateKinds?.includes(a)){let l=u.escalateTarget??"human";return{...d,kind:"escalate_up",reasonCode:"pack",reason:`pack ${u.id} slaves kind ${JSON.stringify(a)} to a pattern change`,target:l}}}if(!e.allowedKinds.includes(a))return{...d,kind:"escalate_up",reasonCode:"not-in-pattern",reason:`kind ${JSON.stringify(a)} is not allowed by h(\u03BE); field cannot rewrite the pattern`,target:"human"};for(let u of n){let l=Re(r,t,u);if(l!=="ok")return{...d,kind:"hold",reasonCode:l,reason:l==="capacity"?`pack ${u.id} capacity ${JSON.stringify(r.kind)} does not hold`:`pack ${u.id} capacity is not numeric data`}}return{...d,kind:"absorb"}}o(q,"classifyIngest");function me(e,r){let n=new Set(e.allowedKinds),s=new Set(r.allowedKinds),t=new Set;for(let a of n)s.has(a)||t.add(a);for(let a of s)n.has(a)||t.add(a);for(let a of r.invalidated)t.add(a);return{blastRadius:[...t].sort(),invalidations:[...r.invalidated].sort()}}o(me,"blastRadiusOf");function W(e,r){return j({xi:r,sigma:{...e.current.sigma},version:e.current.version+1,now:e.now,maxXiKeys:e.maxXiKeys,xiSchema:e.xiSchema,catalogDigest:e.catalogDigest})}o(W,"successorRelease");function Q(e,r){let n=e.projector(e.current,e.current.sigma),s=e.projector(r,r.sigma);w(s,e.informationBudget);let{blastRadius:t,invalidations:a}=me(n,s);if(t.length===0)throw new c("ARKORDER_EMPTY_BLAST","pattern change has empty blast radius; that key is not an order parameter");return{blastRadius:t,invalidations:a}}o(Q,"transitionBlast");function Z(e){let r={...e.current.xi};for(let[a,d]of Object.entries(e.delta)){if(d===void 0){delete r[a];continue}r[a]=d}let n=W(e,r);if(n.hash===e.current.hash)throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:t}=Q(e,n);return{nextXi:n.xi,blastRadius:s,invalidations:t,baseXiHash:e.current.xiHash,baseVersion:e.current.version}}o(Z,"proposePatternChange");function F(e,r){return!Array.isArray(e)||e.length!==r.length?!1:[...e].map(String).sort().every((s,t)=>s===r[t])}o(F,"sameSortedList");function I(e){return new c("ARKORDER_STALE_PROPOSAL",`${e}; re-run proposeRelease against the current Release and review the new blast radius`)}o(I,"staleProposal");function ee(e){let r=e.proposal;if(!r||typeof r!="object"||!r.nextXi||typeof r.nextXi!="object")throw I("apply() requires a ProposeResult from proposeRelease");if(r.baseXiHash!==e.current.xiHash||r.baseVersion!==e.current.version)throw I(`proposal was computed against a different Release (base v${String(r.baseVersion)}, current v${e.current.version})`);let n=W(e,{...e.proposal.nextXi});if(J(n.xi,e.current.xi))throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:t}=Q(e,n);if(!F(r.blastRadius,s)||!F(r.invalidations,t))throw I("the reviewed blast radius is not the transition apply() would commit");return n}o(ee,"applyProposedRelease");function A(e,r=""){return new c("ARKORDER_SCHEMA",`${e} requires a valid Release${r}; hash is the identity (not durable, not K01)`)}o(A,"closed");function N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(N,"isPlainRecord");function M(e,r,n="restore()"){if(!N(e)||!N(e.xi))throw A(n);let s=e.sigma??{};if(!N(s))throw A(n);let{version:t,hash:a,xiHash:d,sigmaHash:u,releasedAt:l}=e;if(typeof t!="number"||!Number.isInteger(t)||t<1||typeof a!="string"||a.length===0||typeof d!="string"||typeof u!="string"||typeof l!="number"||!Number.isFinite(l))throw A(n);if(l>r.now)throw A(n,` (releasedAt ${l} is after the plane clock ${r.now})`);X(e.xi,r.maxXiKeys);let R=m(e.xi,"\u03BE"),f=m(s,"\u03C3");if(C(R),D(R,r.xiSchema),typeof f.releasedAt=="number"&&f.releasedAt>r.now)throw A(n,` (\u03C3.releasedAt ${f.releasedAt} is after the plane clock ${r.now})`);if(a!==h(R,f,r.catalogDigest)||d!==T(R,r.catalogDigest)||u!==_(f))throw A(n);return Object.freeze({version:t,hash:a,xiHash:d,sigmaHash:u,xi:R,sigma:f,releasedAt:l})}o(M,"rehydrateRelease");function re(e){if(typeof e?.projector!="function")throw new c("ARKORDER_SCHEMA","createOrderPlane requires a consumer projector h(\u03BE)");let r=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7,n=e.packs??[],s=e.clocks??{now(){return Date.now()}},t=e.store,a=e.catalogDigest,d=o(i=>({maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:a,now:i}),"integrity"),u=t?t.load():null,l=u==null?null:M(u,d(s.now()),"ReleaseStore.load()"),R=l?.version??0;function f(i){return t?.save(i),l=i,R=i.version,i}o(f,"persist");function P(i){return w(e.projector(i,i.sigma),e.informationBudget),i}o(P,"withinBudget");function S(){if(!l)throw new c("ARKORDER_NO_RELEASE","no pattern is frozen; call release(\u03BE) first");return l}o(S,"requireCurrent");let H={release(i,g){return l&&K(l,m(i,"\u03BE")),f(P(j({xi:i,sigma:g,version:R+1,now:s.now(),maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:a})))},project(){let i=S(),g=e.projector(i,i.sigma);return w(g,e.informationBudget),g},ingest(i){let g=S();try{G({sigma:g.sigma,now:s.now(),maxAgeMs:e.sigmaMaxAgeMs,releasedAt:g.releasedAt})}catch(x){if(x instanceof c&&x.code==="ARKORDER_STALE_SIGMA")return{kind:"hold",event:i,xiHash:g.xiHash,eventId:v(i),reasonCode:"stale-sigma",reason:x.message};throw x}let $=e.projector(g,g.sigma);return w($,e.informationBudget),q($,i,n,g.xiHash,g.sigma)},proposeRelease(i){return Z({current:S(),delta:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:a,informationBudget:e.informationBudget})},apply(i){return f(ee({current:S(),proposal:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:a,informationBudget:e.informationBudget}))},refreshSigma(i){return f(P(V({current:S(),sigma:i,now:s.now(),catalogDigest:a})))},restore(i){let g=M(i,d(s.now()));if(l&&(K(l,g.xi),g.version<l.version||g.version>l.version+1))throw new c("ARKORDER_UNVALVED_RELEASE",`restore() on a live plane accepts version ${l.version} or ${l.version+1}, got ${g.version}; change the pattern with proposeRelease then apply`);return f(P(g))},current(){return l}};for(let i of["update","patch","set","mutate"])Object.defineProperty(H,i,{enumerable:!1,configurable:!1,get(){throw new c("ARKORDER_FORBIDDEN_METHOD",`${i}() is not a Haken operation; freeze a pattern with release() or proposeRelease()`)}});return Object.freeze(H)}o(re,"createOrderPlane");function ne(e){let r=e??null;return{load(){return r},save(n){r=n}}}o(ne,"createMemoryReleaseStore");0&&(module.exports={ArkOrderError,CAPACITY_OPS,DEFAULT_MAX_XI_KEYS,createMemoryReleaseStore,createOrderPlane,hashOf,hashReleasePayload,ingestTravelAction});
1
+ 'use strict';var Z=Object.defineProperty;var t=(e,r)=>Z(e,"name",{value:r,configurable:true});var c=class extends Error{static{t(this,"ArkOrderError");}code;constructor(r,n){super(n),this.name="ArkOrderError",this.code=r;}};var x=7,$=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var _=["lte","lt","gte","gt"];function y(e){let r=2166136261;for(let n=0;n<e.length;n+=1)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return `fnv1a-${(r>>>0).toString(16).padStart(8,"0")}`}t(y,"deterministicHash");function p(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(p).join(",")}]`;let r=e;return `{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${p(r[n])}`).join(",")}}`}t(p,"stableSerialize");function ee(e){return e.kind==="absorb"?"send":e.kind==="escalate_up"&&e.target==="human"?"raises":"none"}t(ee,"ingestTravelAction");var re=["update","patch","set","mutate"];function F(e){return re.includes(e)}t(F,"isForbiddenPlaneMethod");function ne(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean"}t(ne,"isPrimitive");function m(e,r){let n=Object.keys(e);if(n.length===0&&r==="\u03BE")throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");let s={};for(let a of n.sort()){let o=e[a];if(typeof o=="number"&&!Number.isFinite(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is a non-finite number (NaN/\xB1Infinity has no stable identity)`);if(!ne(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is not a slow primitive (nested values are microstate)`);s[a]=Object.is(o,-0)?0:o;}return Object.freeze(s)}t(m,"freezeRecord");function I(e,r){let n=Object.keys(e).length;if(n===0)throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");if(n>r)throw new c("ARKORDER_TOO_MANY_PARAMS",`\u03BE has ${n} keys; maxXiKeys is ${r} (Haken: few slow modes)`)}t(I,"assertXiKeyCap");function X(e,r){if(!r)return;let n=r.properties??{},s=r.additionalProperties!==false;for(let a of Object.keys(e)){let o=n[a];if(!o){if(!s)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} is not in xiSchema.properties`);continue}if(o.enum&&!o.enum.some(d=>d===e[a]))throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} value is not in enum`);if(o.type==="null"&&e[a]!==null)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be null`);if(o.type&&o.type!=="null"&&typeof e[a]!==o.type)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be ${o.type}`)}}t(X,"assertXiSchema");function Y(e,r){if(typeof r=="string"&&Object.prototype.hasOwnProperty.call(e,"catalogReleaseId"))return r}t(Y,"catalogDigestFor");function h(e,r,n){let s=Y(e,n);return s!==void 0?y(p({xi:e,sigma:r,catalogDigest:s})):y(p({xi:e,sigma:r}))}t(h,"hashReleasePayload");function D(e,r){let n=Y(e,r);return n!==void 0?y(p({xi:e,catalogDigest:n})):y(p({xi:e}))}t(D,"hashXiIdentity");function b(e){return y(p({sigma:e}))}t(b,"hashSigmaIdentity");function U(e,r){return p(e)===p(r)}t(U,"xiRecordsEqual");function T(e,r){if(e&&!U(e.xi,r))throw new c("ARKORDER_UNVALVED_RELEASE","\u03BE is frozen; change the pattern with proposeRelease then apply(ProposeResult)")}t(T,"assertUnvalvedRelease");function K(e){I(e.xi,e.maxXiKeys);let r=m(e.xi,"\u03BE");j(r),X(r,e.xiSchema);let n=m(e.sigma??{},"\u03C3");return Object.freeze({version:e.version,hash:h(r,n,e.catalogDigest),xiHash:D(r,e.catalogDigest),sigmaHash:b(n),xi:r,sigma:n,releasedAt:e.now})}t(K,"createFrozenRelease");function z(e){let r=m(e.sigma,"\u03C3");return Object.freeze({version:e.current.version,hash:h(e.current.xi,r,e.catalogDigest),xiHash:e.current.xiHash,sigmaHash:b(r),xi:e.current.xi,sigma:r,releasedAt:e.now})}t(z,"refreshSigmaRecord");function j(e){for(let r of Object.keys(e))if($.test(r))throw new c("ARKORDER_XI_TTL",`\u03BE key ${JSON.stringify(r)} is a freshness field; TTL belongs on \u03C3, never on \u03BE`)}t(j,"assertXiHasNoTtl");function O(e,r){if(!r||r.cannotObserve.length===0)return;let n=new Set(r.cannotObserve);for(let s of e.allowedKinds)if(n.has(s))throw new c("ARKORDER_INFORMATION_BUDGET",`projection allows ${JSON.stringify(s)}; informationBudget.cannotObserve forbids it`)}t(O,"assertInformationBudget");function J(e){let r=e.sigma.freshUntil;if(typeof r=="number"){if(e.now>r)throw new c("ARKORDER_STALE_SIGMA","\u03C3 freshUntil has elapsed; \u03BE does not TTL");return}if(e.maxAgeMs===void 0)return;let n=typeof e.sigma.releasedAt=="number"?e.sigma.releasedAt:e.releasedAt;if(typeof n=="number"&&e.now-n>e.maxAgeMs)throw new c("ARKORDER_STALE_SIGMA","\u03C3 is older than sigmaMaxAgeMs; \u03BE does not TTL")}t(J,"assertSigmaFresh");function C(e){return y(p({kind:e.kind,payload:e.payload??null}))}t(C,"fieldEventIdentity");function te(e,r){return {event:e,xiHash:r,eventId:C(e)}}t(te,"bindResidual");var oe=new Set(_);function ae(e){return typeof e=="string"&&oe.has(e)}t(ae,"isCapacityOp");function B(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}t(B,"numericLeaf");function se(e,r,n){return r==="lte"?e<=n:r==="lt"?e<n:r==="gte"?e>=n:e>n}t(se,"compareCapacity");function E(e){return typeof e=="function"?true:e===null||typeof e!="object"?false:Array.isArray(e)?e.some(E):Object.values(e).some(E)}t(E,"packHasFunction");function ie(e,r,n){let s=n.capacity??[];for(let a of s){if(E(a)||!ae(a.op))return "pack";if(a.kind!==e.kind)continue;let o=e.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?B(e.payload[a.payloadKey]):void 0,d=B(r[a.sigmaKey]);if(o===void 0||d===void 0)return "pack";if(!se(o,a.op,d))return "capacity"}return "ok"}t(ie,"evaluateCapacity");function V(e,r,n=[],s="",a=Object.freeze({})){let o=r.kind,d=te(r,s);for(let u of n){if(E(u.capacity)||E(u.escalateKinds))return {...d,kind:"hold",reasonCode:"pack",reason:`pack ${u.id} is not data-only; user predicates are forbidden`};if(u.escalateKinds?.includes(o)){let l=u.escalateTarget??"human";return {...d,kind:"escalate_up",reasonCode:"pack",reason:`pack ${u.id} slaves kind ${JSON.stringify(o)} to a pattern change`,target:l}}}if(!e.allowedKinds.includes(o))return {...d,kind:"escalate_up",reasonCode:"not-in-pattern",reason:`kind ${JSON.stringify(o)} is not allowed by h(\u03BE); field cannot rewrite the pattern`,target:"human"};for(let u of n){let l=ie(r,a,u);if(l!=="ok")return {...d,kind:"hold",reasonCode:l,reason:l==="capacity"?`pack ${u.id} capacity ${JSON.stringify(r.kind)} does not hold`:`pack ${u.id} capacity is not numeric data`}}return {...d,kind:"absorb"}}t(V,"classifyIngest");function ce(e,r){let n=new Set(e.allowedKinds),s=new Set(r.allowedKinds),a=new Set;for(let o of n)s.has(o)||a.add(o);for(let o of s)n.has(o)||a.add(o);for(let o of r.invalidated)a.add(o);return {blastRadius:[...a].sort(),invalidations:[...r.invalidated].sort()}}t(ce,"blastRadiusOf");function G(e,r){return K({xi:r,sigma:{...e.current.sigma},version:e.current.version+1,now:e.now,maxXiKeys:e.maxXiKeys,xiSchema:e.xiSchema,catalogDigest:e.catalogDigest})}t(G,"successorRelease");function q(e,r){let n=e.projector(e.current,e.current.sigma),s=e.projector(r,r.sigma);O(s,e.informationBudget);let{blastRadius:a,invalidations:o}=ce(n,s);if(a.length===0)throw new c("ARKORDER_EMPTY_BLAST","pattern change has empty blast radius; that key is not an order parameter");return {blastRadius:a,invalidations:o}}t(q,"transitionBlast");function W(e){let r={...e.current.xi};for(let[o,d]of Object.entries(e.delta)){if(d===void 0){delete r[o];continue}r[o]=d;}let n=G(e,r);if(n.hash===e.current.hash)throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);return {nextXi:n.xi,blastRadius:s,invalidations:a,baseXiHash:e.current.xiHash,baseVersion:e.current.version}}t(W,"proposePatternChange");function L(e,r){return !Array.isArray(e)||e.length!==r.length?false:[...e].map(String).sort().every((s,a)=>s===r[a])}t(L,"sameSortedList");function P(e){return new c("ARKORDER_STALE_PROPOSAL",`${e}; re-run proposeRelease against the current Release and review the new blast radius`)}t(P,"staleProposal");function Q(e){let r=e.proposal;if(!r||typeof r!="object"||!r.nextXi||typeof r.nextXi!="object")throw P("apply() requires a ProposeResult from proposeRelease");if(r.baseXiHash!==e.current.xiHash||r.baseVersion!==e.current.version)throw P(`proposal was computed against a different Release (base v${String(r.baseVersion)}, current v${e.current.version})`);let n=G(e,{...e.proposal.nextXi});if(U(n.xi,e.current.xi))throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);if(!L(r.blastRadius,s)||!L(r.invalidations,a))throw P("the reviewed blast radius is not the transition apply() would commit");return n}t(Q,"applyProposedRelease");function A(e,r=""){return new c("ARKORDER_SCHEMA",`${e} requires a valid Release${r}; hash is the identity (not durable, not K01)`)}t(A,"closed");function v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}t(v,"isPlainRecord");function N(e,r,n="restore()"){if(!v(e)||!v(e.xi))throw A(n);let s=e.sigma??{};if(!v(s))throw A(n);let{version:a,hash:o,xiHash:d,sigmaHash:u,releasedAt:l}=e;if(typeof a!="number"||!Number.isInteger(a)||a<1||typeof o!="string"||o.length===0||typeof d!="string"||typeof u!="string"||typeof l!="number"||!Number.isFinite(l))throw A(n);if(l>r.now)throw A(n,` (releasedAt ${l} is after the plane clock ${r.now})`);I(e.xi,r.maxXiKeys);let R=m(e.xi,"\u03BE"),f=m(s,"\u03C3");if(j(R),X(R,r.xiSchema),typeof f.releasedAt=="number"&&f.releasedAt>r.now)throw A(n,` (\u03C3.releasedAt ${f.releasedAt} is after the plane clock ${r.now})`);if(o!==h(R,f,r.catalogDigest)||d!==D(R,r.catalogDigest)||u!==b(f))throw A(n);return Object.freeze({version:a,hash:o,xiHash:d,sigmaHash:u,xi:R,sigma:f,releasedAt:l})}t(N,"rehydrateRelease");function le(e){if(typeof e?.projector!="function")throw new c("ARKORDER_SCHEMA","createOrderPlane requires a consumer projector h(\u03BE)");let r=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7,n=e.packs??[],s=e.clocks??{now(){return Date.now()}},a=e.store,o=e.catalogDigest,d=t(i=>({maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o,now:i}),"integrity"),u=a?a.load():null,l=u==null?null:N(u,d(s.now()),"ReleaseStore.load()"),R=l?.version??0;function f(i){return a?.save(i),l=i,R=i.version,i}t(f,"persist");function k(i){return O(e.projector(i,i.sigma),e.informationBudget),i}t(k,"withinBudget");function S(){if(!l)throw new c("ARKORDER_NO_RELEASE","no pattern is frozen; call release(\u03BE) first");return l}t(S,"requireCurrent");let M={release(i,g){return l&&T(l,m(i,"\u03BE")),f(k(K({xi:i,sigma:g,version:R+1,now:s.now(),maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o})))},project(){let i=S(),g=e.projector(i,i.sigma);return O(g,e.informationBudget),g},ingest(i){let g=S();try{J({sigma:g.sigma,now:s.now(),maxAgeMs:e.sigmaMaxAgeMs,releasedAt:g.releasedAt});}catch(w){if(w instanceof c&&w.code==="ARKORDER_STALE_SIGMA")return {kind:"hold",event:i,xiHash:g.xiHash,eventId:C(i),reasonCode:"stale-sigma",reason:w.message};throw w}let H=e.projector(g,g.sigma);return O(H,e.informationBudget),V(H,i,n,g.xiHash,g.sigma)},proposeRelease(i){return W({current:S(),delta:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget})},apply(i){return f(Q({current:S(),proposal:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget}))},refreshSigma(i){return f(k(z({current:S(),sigma:i,now:s.now(),catalogDigest:o})))},restore(i){let g=N(i,d(s.now()));if(l&&(T(l,g.xi),g.version<l.version||g.version>l.version+1))throw new c("ARKORDER_UNVALVED_RELEASE",`restore() on a live plane accepts version ${l.version} or ${l.version+1}, got ${g.version}; change the pattern with proposeRelease then apply`);return f(k(g))},current(){return l}};for(let i of ["update","patch","set","mutate"])Object.defineProperty(M,i,{enumerable:false,configurable:false,get(){throw new c("ARKORDER_FORBIDDEN_METHOD",`${i}() is not a Haken operation; freeze a pattern with release() or proposeRelease()`)}});return Object.freeze(M)}t(le,"createOrderPlane");function de(e){let r=e??null;return {load(){return r},save(n){r=n;}}}t(de,"createMemoryReleaseStore");exports.ArkOrderError=c;exports.CAPACITY_OPS=_;exports.DEFAULT_MAX_XI_KEYS=x;exports.createMemoryReleaseStore=de;exports.createOrderPlane=le;exports.hashOf=h;exports.hashReleasePayload=h;exports.ingestTravelAction=ee;
@@ -1 +1 @@
1
- var Z=Object.defineProperty;var t=(e,r)=>Z(e,"name",{value:r,configurable:!0});var c=class extends Error{static{t(this,"ArkOrderError")}code;constructor(r,n){super(n),this.name="ArkOrderError",this.code=r}};var x=7,$=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var _=["lte","lt","gte","gt"];function y(e){let r=2166136261;for(let n=0;n<e.length;n+=1)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return`fnv1a-${(r>>>0).toString(16).padStart(8,"0")}`}t(y,"deterministicHash");function p(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(p).join(",")}]`;let r=e;return`{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${p(r[n])}`).join(",")}}`}t(p,"stableSerialize");function ee(e){return e.kind==="absorb"?"send":e.kind==="escalate_up"&&e.target==="human"?"raises":"none"}t(ee,"ingestTravelAction");var re=["update","patch","set","mutate"];function F(e){return re.includes(e)}t(F,"isForbiddenPlaneMethod");function ne(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean"}t(ne,"isPrimitive");function m(e,r){let n=Object.keys(e);if(n.length===0&&r==="\u03BE")throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");let s={};for(let a of n.sort()){let o=e[a];if(typeof o=="number"&&!Number.isFinite(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is a non-finite number (NaN/\xB1Infinity has no stable identity)`);if(!ne(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is not a slow primitive (nested values are microstate)`);s[a]=Object.is(o,-0)?0:o}return Object.freeze(s)}t(m,"freezeRecord");function I(e,r){let n=Object.keys(e).length;if(n===0)throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");if(n>r)throw new c("ARKORDER_TOO_MANY_PARAMS",`\u03BE has ${n} keys; maxXiKeys is ${r} (Haken: few slow modes)`)}t(I,"assertXiKeyCap");function X(e,r){if(!r)return;let n=r.properties??{},s=r.additionalProperties!==!1;for(let a of Object.keys(e)){let o=n[a];if(!o){if(!s)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} is not in xiSchema.properties`);continue}if(o.enum&&!o.enum.some(d=>d===e[a]))throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} value is not in enum`);if(o.type==="null"&&e[a]!==null)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be null`);if(o.type&&o.type!=="null"&&typeof e[a]!==o.type)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be ${o.type}`)}}t(X,"assertXiSchema");function Y(e,r){if(typeof r=="string"&&Object.prototype.hasOwnProperty.call(e,"catalogReleaseId"))return r}t(Y,"catalogDigestFor");function h(e,r,n){let s=Y(e,n);return s!==void 0?y(p({xi:e,sigma:r,catalogDigest:s})):y(p({xi:e,sigma:r}))}t(h,"hashReleasePayload");function D(e,r){let n=Y(e,r);return n!==void 0?y(p({xi:e,catalogDigest:n})):y(p({xi:e}))}t(D,"hashXiIdentity");function b(e){return y(p({sigma:e}))}t(b,"hashSigmaIdentity");function U(e,r){return p(e)===p(r)}t(U,"xiRecordsEqual");function T(e,r){if(e&&!U(e.xi,r))throw new c("ARKORDER_UNVALVED_RELEASE","\u03BE is frozen; change the pattern with proposeRelease then apply(ProposeResult)")}t(T,"assertUnvalvedRelease");function K(e){I(e.xi,e.maxXiKeys);let r=m(e.xi,"\u03BE");j(r),X(r,e.xiSchema);let n=m(e.sigma??{},"\u03C3");return Object.freeze({version:e.version,hash:h(r,n,e.catalogDigest),xiHash:D(r,e.catalogDigest),sigmaHash:b(n),xi:r,sigma:n,releasedAt:e.now})}t(K,"createFrozenRelease");function z(e){let r=m(e.sigma,"\u03C3");return Object.freeze({version:e.current.version,hash:h(e.current.xi,r,e.catalogDigest),xiHash:e.current.xiHash,sigmaHash:b(r),xi:e.current.xi,sigma:r,releasedAt:e.now})}t(z,"refreshSigmaRecord");function j(e){for(let r of Object.keys(e))if($.test(r))throw new c("ARKORDER_XI_TTL",`\u03BE key ${JSON.stringify(r)} is a freshness field; TTL belongs on \u03C3, never on \u03BE`)}t(j,"assertXiHasNoTtl");function O(e,r){if(!r||r.cannotObserve.length===0)return;let n=new Set(r.cannotObserve);for(let s of e.allowedKinds)if(n.has(s))throw new c("ARKORDER_INFORMATION_BUDGET",`projection allows ${JSON.stringify(s)}; informationBudget.cannotObserve forbids it`)}t(O,"assertInformationBudget");function J(e){let r=e.sigma.freshUntil;if(typeof r=="number"){if(e.now>r)throw new c("ARKORDER_STALE_SIGMA","\u03C3 freshUntil has elapsed; \u03BE does not TTL");return}if(e.maxAgeMs===void 0)return;let n=typeof e.sigma.releasedAt=="number"?e.sigma.releasedAt:e.releasedAt;if(typeof n=="number"&&e.now-n>e.maxAgeMs)throw new c("ARKORDER_STALE_SIGMA","\u03C3 is older than sigmaMaxAgeMs; \u03BE does not TTL")}t(J,"assertSigmaFresh");function C(e){return y(p({kind:e.kind,payload:e.payload??null}))}t(C,"fieldEventIdentity");function te(e,r){return{event:e,xiHash:r,eventId:C(e)}}t(te,"bindResidual");var oe=new Set(_);function ae(e){return typeof e=="string"&&oe.has(e)}t(ae,"isCapacityOp");function B(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}t(B,"numericLeaf");function se(e,r,n){return r==="lte"?e<=n:r==="lt"?e<n:r==="gte"?e>=n:e>n}t(se,"compareCapacity");function E(e){return typeof e=="function"?!0:e===null||typeof e!="object"?!1:Array.isArray(e)?e.some(E):Object.values(e).some(E)}t(E,"packHasFunction");function ie(e,r,n){let s=n.capacity??[];for(let a of s){if(E(a)||!ae(a.op))return"pack";if(a.kind!==e.kind)continue;let o=e.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?B(e.payload[a.payloadKey]):void 0,d=B(r[a.sigmaKey]);if(o===void 0||d===void 0)return"pack";if(!se(o,a.op,d))return"capacity"}return"ok"}t(ie,"evaluateCapacity");function V(e,r,n=[],s="",a=Object.freeze({})){let o=r.kind,d=te(r,s);for(let u of n){if(E(u.capacity)||E(u.escalateKinds))return{...d,kind:"hold",reasonCode:"pack",reason:`pack ${u.id} is not data-only; user predicates are forbidden`};if(u.escalateKinds?.includes(o)){let l=u.escalateTarget??"human";return{...d,kind:"escalate_up",reasonCode:"pack",reason:`pack ${u.id} slaves kind ${JSON.stringify(o)} to a pattern change`,target:l}}}if(!e.allowedKinds.includes(o))return{...d,kind:"escalate_up",reasonCode:"not-in-pattern",reason:`kind ${JSON.stringify(o)} is not allowed by h(\u03BE); field cannot rewrite the pattern`,target:"human"};for(let u of n){let l=ie(r,a,u);if(l!=="ok")return{...d,kind:"hold",reasonCode:l,reason:l==="capacity"?`pack ${u.id} capacity ${JSON.stringify(r.kind)} does not hold`:`pack ${u.id} capacity is not numeric data`}}return{...d,kind:"absorb"}}t(V,"classifyIngest");function ce(e,r){let n=new Set(e.allowedKinds),s=new Set(r.allowedKinds),a=new Set;for(let o of n)s.has(o)||a.add(o);for(let o of s)n.has(o)||a.add(o);for(let o of r.invalidated)a.add(o);return{blastRadius:[...a].sort(),invalidations:[...r.invalidated].sort()}}t(ce,"blastRadiusOf");function G(e,r){return K({xi:r,sigma:{...e.current.sigma},version:e.current.version+1,now:e.now,maxXiKeys:e.maxXiKeys,xiSchema:e.xiSchema,catalogDigest:e.catalogDigest})}t(G,"successorRelease");function q(e,r){let n=e.projector(e.current,e.current.sigma),s=e.projector(r,r.sigma);O(s,e.informationBudget);let{blastRadius:a,invalidations:o}=ce(n,s);if(a.length===0)throw new c("ARKORDER_EMPTY_BLAST","pattern change has empty blast radius; that key is not an order parameter");return{blastRadius:a,invalidations:o}}t(q,"transitionBlast");function W(e){let r={...e.current.xi};for(let[o,d]of Object.entries(e.delta)){if(d===void 0){delete r[o];continue}r[o]=d}let n=G(e,r);if(n.hash===e.current.hash)throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);return{nextXi:n.xi,blastRadius:s,invalidations:a,baseXiHash:e.current.xiHash,baseVersion:e.current.version}}t(W,"proposePatternChange");function L(e,r){return!Array.isArray(e)||e.length!==r.length?!1:[...e].map(String).sort().every((s,a)=>s===r[a])}t(L,"sameSortedList");function P(e){return new c("ARKORDER_STALE_PROPOSAL",`${e}; re-run proposeRelease against the current Release and review the new blast radius`)}t(P,"staleProposal");function Q(e){let r=e.proposal;if(!r||typeof r!="object"||!r.nextXi||typeof r.nextXi!="object")throw P("apply() requires a ProposeResult from proposeRelease");if(r.baseXiHash!==e.current.xiHash||r.baseVersion!==e.current.version)throw P(`proposal was computed against a different Release (base v${String(r.baseVersion)}, current v${e.current.version})`);let n=G(e,{...e.proposal.nextXi});if(U(n.xi,e.current.xi))throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);if(!L(r.blastRadius,s)||!L(r.invalidations,a))throw P("the reviewed blast radius is not the transition apply() would commit");return n}t(Q,"applyProposedRelease");function A(e,r=""){return new c("ARKORDER_SCHEMA",`${e} requires a valid Release${r}; hash is the identity (not durable, not K01)`)}t(A,"closed");function v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}t(v,"isPlainRecord");function N(e,r,n="restore()"){if(!v(e)||!v(e.xi))throw A(n);let s=e.sigma??{};if(!v(s))throw A(n);let{version:a,hash:o,xiHash:d,sigmaHash:u,releasedAt:l}=e;if(typeof a!="number"||!Number.isInteger(a)||a<1||typeof o!="string"||o.length===0||typeof d!="string"||typeof u!="string"||typeof l!="number"||!Number.isFinite(l))throw A(n);if(l>r.now)throw A(n,` (releasedAt ${l} is after the plane clock ${r.now})`);I(e.xi,r.maxXiKeys);let R=m(e.xi,"\u03BE"),f=m(s,"\u03C3");if(j(R),X(R,r.xiSchema),typeof f.releasedAt=="number"&&f.releasedAt>r.now)throw A(n,` (\u03C3.releasedAt ${f.releasedAt} is after the plane clock ${r.now})`);if(o!==h(R,f,r.catalogDigest)||d!==D(R,r.catalogDigest)||u!==b(f))throw A(n);return Object.freeze({version:a,hash:o,xiHash:d,sigmaHash:u,xi:R,sigma:f,releasedAt:l})}t(N,"rehydrateRelease");function le(e){if(typeof e?.projector!="function")throw new c("ARKORDER_SCHEMA","createOrderPlane requires a consumer projector h(\u03BE)");let r=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7,n=e.packs??[],s=e.clocks??{now(){return Date.now()}},a=e.store,o=e.catalogDigest,d=t(i=>({maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o,now:i}),"integrity"),u=a?a.load():null,l=u==null?null:N(u,d(s.now()),"ReleaseStore.load()"),R=l?.version??0;function f(i){return a?.save(i),l=i,R=i.version,i}t(f,"persist");function k(i){return O(e.projector(i,i.sigma),e.informationBudget),i}t(k,"withinBudget");function S(){if(!l)throw new c("ARKORDER_NO_RELEASE","no pattern is frozen; call release(\u03BE) first");return l}t(S,"requireCurrent");let M={release(i,g){return l&&T(l,m(i,"\u03BE")),f(k(K({xi:i,sigma:g,version:R+1,now:s.now(),maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o})))},project(){let i=S(),g=e.projector(i,i.sigma);return O(g,e.informationBudget),g},ingest(i){let g=S();try{J({sigma:g.sigma,now:s.now(),maxAgeMs:e.sigmaMaxAgeMs,releasedAt:g.releasedAt})}catch(w){if(w instanceof c&&w.code==="ARKORDER_STALE_SIGMA")return{kind:"hold",event:i,xiHash:g.xiHash,eventId:C(i),reasonCode:"stale-sigma",reason:w.message};throw w}let H=e.projector(g,g.sigma);return O(H,e.informationBudget),V(H,i,n,g.xiHash,g.sigma)},proposeRelease(i){return W({current:S(),delta:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget})},apply(i){return f(Q({current:S(),proposal:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget}))},refreshSigma(i){return f(k(z({current:S(),sigma:i,now:s.now(),catalogDigest:o})))},restore(i){let g=N(i,d(s.now()));if(l&&(T(l,g.xi),g.version<l.version||g.version>l.version+1))throw new c("ARKORDER_UNVALVED_RELEASE",`restore() on a live plane accepts version ${l.version} or ${l.version+1}, got ${g.version}; change the pattern with proposeRelease then apply`);return f(k(g))},current(){return l}};for(let i of["update","patch","set","mutate"])Object.defineProperty(M,i,{enumerable:!1,configurable:!1,get(){throw new c("ARKORDER_FORBIDDEN_METHOD",`${i}() is not a Haken operation; freeze a pattern with release() or proposeRelease()`)}});return Object.freeze(M)}t(le,"createOrderPlane");function de(e){let r=e??null;return{load(){return r},save(n){r=n}}}t(de,"createMemoryReleaseStore");export{c as ArkOrderError,_ as CAPACITY_OPS,x as DEFAULT_MAX_XI_KEYS,de as createMemoryReleaseStore,le as createOrderPlane,h as hashOf,h as hashReleasePayload,ee as ingestTravelAction};
1
+ var Z=Object.defineProperty;var t=(e,r)=>Z(e,"name",{value:r,configurable:true});var c=class extends Error{static{t(this,"ArkOrderError");}code;constructor(r,n){super(n),this.name="ArkOrderError",this.code=r;}};var x=7,$=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var _=["lte","lt","gte","gt"];function y(e){let r=2166136261;for(let n=0;n<e.length;n+=1)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return `fnv1a-${(r>>>0).toString(16).padStart(8,"0")}`}t(y,"deterministicHash");function p(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(p).join(",")}]`;let r=e;return `{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${p(r[n])}`).join(",")}}`}t(p,"stableSerialize");function ee(e){return e.kind==="absorb"?"send":e.kind==="escalate_up"&&e.target==="human"?"raises":"none"}t(ee,"ingestTravelAction");var re=["update","patch","set","mutate"];function F(e){return re.includes(e)}t(F,"isForbiddenPlaneMethod");function ne(e){return e===null||typeof e=="string"||typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean"}t(ne,"isPrimitive");function m(e,r){let n=Object.keys(e);if(n.length===0&&r==="\u03BE")throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");let s={};for(let a of n.sort()){let o=e[a];if(typeof o=="number"&&!Number.isFinite(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is a non-finite number (NaN/\xB1Infinity has no stable identity)`);if(!ne(o))throw new c("ARKORDER_NESTED_XI",`${r} key ${JSON.stringify(a)} is not a slow primitive (nested values are microstate)`);s[a]=Object.is(o,-0)?0:o;}return Object.freeze(s)}t(m,"freezeRecord");function I(e,r){let n=Object.keys(e).length;if(n===0)throw new c("ARKORDER_EMPTY_XI","\u03BE must name at least one slow mode");if(n>r)throw new c("ARKORDER_TOO_MANY_PARAMS",`\u03BE has ${n} keys; maxXiKeys is ${r} (Haken: few slow modes)`)}t(I,"assertXiKeyCap");function X(e,r){if(!r)return;let n=r.properties??{},s=r.additionalProperties!==false;for(let a of Object.keys(e)){let o=n[a];if(!o){if(!s)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} is not in xiSchema.properties`);continue}if(o.enum&&!o.enum.some(d=>d===e[a]))throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} value is not in enum`);if(o.type==="null"&&e[a]!==null)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be null`);if(o.type&&o.type!=="null"&&typeof e[a]!==o.type)throw new c("ARKORDER_SCHEMA",`\u03BE key ${JSON.stringify(a)} must be ${o.type}`)}}t(X,"assertXiSchema");function Y(e,r){if(typeof r=="string"&&Object.prototype.hasOwnProperty.call(e,"catalogReleaseId"))return r}t(Y,"catalogDigestFor");function h(e,r,n){let s=Y(e,n);return s!==void 0?y(p({xi:e,sigma:r,catalogDigest:s})):y(p({xi:e,sigma:r}))}t(h,"hashReleasePayload");function D(e,r){let n=Y(e,r);return n!==void 0?y(p({xi:e,catalogDigest:n})):y(p({xi:e}))}t(D,"hashXiIdentity");function b(e){return y(p({sigma:e}))}t(b,"hashSigmaIdentity");function U(e,r){return p(e)===p(r)}t(U,"xiRecordsEqual");function T(e,r){if(e&&!U(e.xi,r))throw new c("ARKORDER_UNVALVED_RELEASE","\u03BE is frozen; change the pattern with proposeRelease then apply(ProposeResult)")}t(T,"assertUnvalvedRelease");function K(e){I(e.xi,e.maxXiKeys);let r=m(e.xi,"\u03BE");j(r),X(r,e.xiSchema);let n=m(e.sigma??{},"\u03C3");return Object.freeze({version:e.version,hash:h(r,n,e.catalogDigest),xiHash:D(r,e.catalogDigest),sigmaHash:b(n),xi:r,sigma:n,releasedAt:e.now})}t(K,"createFrozenRelease");function z(e){let r=m(e.sigma,"\u03C3");return Object.freeze({version:e.current.version,hash:h(e.current.xi,r,e.catalogDigest),xiHash:e.current.xiHash,sigmaHash:b(r),xi:e.current.xi,sigma:r,releasedAt:e.now})}t(z,"refreshSigmaRecord");function j(e){for(let r of Object.keys(e))if($.test(r))throw new c("ARKORDER_XI_TTL",`\u03BE key ${JSON.stringify(r)} is a freshness field; TTL belongs on \u03C3, never on \u03BE`)}t(j,"assertXiHasNoTtl");function O(e,r){if(!r||r.cannotObserve.length===0)return;let n=new Set(r.cannotObserve);for(let s of e.allowedKinds)if(n.has(s))throw new c("ARKORDER_INFORMATION_BUDGET",`projection allows ${JSON.stringify(s)}; informationBudget.cannotObserve forbids it`)}t(O,"assertInformationBudget");function J(e){let r=e.sigma.freshUntil;if(typeof r=="number"){if(e.now>r)throw new c("ARKORDER_STALE_SIGMA","\u03C3 freshUntil has elapsed; \u03BE does not TTL");return}if(e.maxAgeMs===void 0)return;let n=typeof e.sigma.releasedAt=="number"?e.sigma.releasedAt:e.releasedAt;if(typeof n=="number"&&e.now-n>e.maxAgeMs)throw new c("ARKORDER_STALE_SIGMA","\u03C3 is older than sigmaMaxAgeMs; \u03BE does not TTL")}t(J,"assertSigmaFresh");function C(e){return y(p({kind:e.kind,payload:e.payload??null}))}t(C,"fieldEventIdentity");function te(e,r){return {event:e,xiHash:r,eventId:C(e)}}t(te,"bindResidual");var oe=new Set(_);function ae(e){return typeof e=="string"&&oe.has(e)}t(ae,"isCapacityOp");function B(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}t(B,"numericLeaf");function se(e,r,n){return r==="lte"?e<=n:r==="lt"?e<n:r==="gte"?e>=n:e>n}t(se,"compareCapacity");function E(e){return typeof e=="function"?true:e===null||typeof e!="object"?false:Array.isArray(e)?e.some(E):Object.values(e).some(E)}t(E,"packHasFunction");function ie(e,r,n){let s=n.capacity??[];for(let a of s){if(E(a)||!ae(a.op))return "pack";if(a.kind!==e.kind)continue;let o=e.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?B(e.payload[a.payloadKey]):void 0,d=B(r[a.sigmaKey]);if(o===void 0||d===void 0)return "pack";if(!se(o,a.op,d))return "capacity"}return "ok"}t(ie,"evaluateCapacity");function V(e,r,n=[],s="",a=Object.freeze({})){let o=r.kind,d=te(r,s);for(let u of n){if(E(u.capacity)||E(u.escalateKinds))return {...d,kind:"hold",reasonCode:"pack",reason:`pack ${u.id} is not data-only; user predicates are forbidden`};if(u.escalateKinds?.includes(o)){let l=u.escalateTarget??"human";return {...d,kind:"escalate_up",reasonCode:"pack",reason:`pack ${u.id} slaves kind ${JSON.stringify(o)} to a pattern change`,target:l}}}if(!e.allowedKinds.includes(o))return {...d,kind:"escalate_up",reasonCode:"not-in-pattern",reason:`kind ${JSON.stringify(o)} is not allowed by h(\u03BE); field cannot rewrite the pattern`,target:"human"};for(let u of n){let l=ie(r,a,u);if(l!=="ok")return {...d,kind:"hold",reasonCode:l,reason:l==="capacity"?`pack ${u.id} capacity ${JSON.stringify(r.kind)} does not hold`:`pack ${u.id} capacity is not numeric data`}}return {...d,kind:"absorb"}}t(V,"classifyIngest");function ce(e,r){let n=new Set(e.allowedKinds),s=new Set(r.allowedKinds),a=new Set;for(let o of n)s.has(o)||a.add(o);for(let o of s)n.has(o)||a.add(o);for(let o of r.invalidated)a.add(o);return {blastRadius:[...a].sort(),invalidations:[...r.invalidated].sort()}}t(ce,"blastRadiusOf");function G(e,r){return K({xi:r,sigma:{...e.current.sigma},version:e.current.version+1,now:e.now,maxXiKeys:e.maxXiKeys,xiSchema:e.xiSchema,catalogDigest:e.catalogDigest})}t(G,"successorRelease");function q(e,r){let n=e.projector(e.current,e.current.sigma),s=e.projector(r,r.sigma);O(s,e.informationBudget);let{blastRadius:a,invalidations:o}=ce(n,s);if(a.length===0)throw new c("ARKORDER_EMPTY_BLAST","pattern change has empty blast radius; that key is not an order parameter");return {blastRadius:a,invalidations:o}}t(q,"transitionBlast");function W(e){let r={...e.current.xi};for(let[o,d]of Object.entries(e.delta)){if(d===void 0){delete r[o];continue}r[o]=d;}let n=G(e,r);if(n.hash===e.current.hash)throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);return {nextXi:n.xi,blastRadius:s,invalidations:a,baseXiHash:e.current.xiHash,baseVersion:e.current.version}}t(W,"proposePatternChange");function L(e,r){return !Array.isArray(e)||e.length!==r.length?false:[...e].map(String).sort().every((s,a)=>s===r[a])}t(L,"sameSortedList");function P(e){return new c("ARKORDER_STALE_PROPOSAL",`${e}; re-run proposeRelease against the current Release and review the new blast radius`)}t(P,"staleProposal");function Q(e){let r=e.proposal;if(!r||typeof r!="object"||!r.nextXi||typeof r.nextXi!="object")throw P("apply() requires a ProposeResult from proposeRelease");if(r.baseXiHash!==e.current.xiHash||r.baseVersion!==e.current.version)throw P(`proposal was computed against a different Release (base v${String(r.baseVersion)}, current v${e.current.version})`);let n=G(e,{...e.proposal.nextXi});if(U(n.xi,e.current.xi))throw new c("ARKORDER_EMPTY_BLAST","delta does not change \u03BE; that is not a pattern change");let{blastRadius:s,invalidations:a}=q(e,n);if(!L(r.blastRadius,s)||!L(r.invalidations,a))throw P("the reviewed blast radius is not the transition apply() would commit");return n}t(Q,"applyProposedRelease");function A(e,r=""){return new c("ARKORDER_SCHEMA",`${e} requires a valid Release${r}; hash is the identity (not durable, not K01)`)}t(A,"closed");function v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}t(v,"isPlainRecord");function N(e,r,n="restore()"){if(!v(e)||!v(e.xi))throw A(n);let s=e.sigma??{};if(!v(s))throw A(n);let{version:a,hash:o,xiHash:d,sigmaHash:u,releasedAt:l}=e;if(typeof a!="number"||!Number.isInteger(a)||a<1||typeof o!="string"||o.length===0||typeof d!="string"||typeof u!="string"||typeof l!="number"||!Number.isFinite(l))throw A(n);if(l>r.now)throw A(n,` (releasedAt ${l} is after the plane clock ${r.now})`);I(e.xi,r.maxXiKeys);let R=m(e.xi,"\u03BE"),f=m(s,"\u03C3");if(j(R),X(R,r.xiSchema),typeof f.releasedAt=="number"&&f.releasedAt>r.now)throw A(n,` (\u03C3.releasedAt ${f.releasedAt} is after the plane clock ${r.now})`);if(o!==h(R,f,r.catalogDigest)||d!==D(R,r.catalogDigest)||u!==b(f))throw A(n);return Object.freeze({version:a,hash:o,xiHash:d,sigmaHash:u,xi:R,sigma:f,releasedAt:l})}t(N,"rehydrateRelease");function le(e){if(typeof e?.projector!="function")throw new c("ARKORDER_SCHEMA","createOrderPlane requires a consumer projector h(\u03BE)");let r=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7,n=e.packs??[],s=e.clocks??{now(){return Date.now()}},a=e.store,o=e.catalogDigest,d=t(i=>({maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o,now:i}),"integrity"),u=a?a.load():null,l=u==null?null:N(u,d(s.now()),"ReleaseStore.load()"),R=l?.version??0;function f(i){return a?.save(i),l=i,R=i.version,i}t(f,"persist");function k(i){return O(e.projector(i,i.sigma),e.informationBudget),i}t(k,"withinBudget");function S(){if(!l)throw new c("ARKORDER_NO_RELEASE","no pattern is frozen; call release(\u03BE) first");return l}t(S,"requireCurrent");let M={release(i,g){return l&&T(l,m(i,"\u03BE")),f(k(K({xi:i,sigma:g,version:R+1,now:s.now(),maxXiKeys:r,xiSchema:e.xiSchema,catalogDigest:o})))},project(){let i=S(),g=e.projector(i,i.sigma);return O(g,e.informationBudget),g},ingest(i){let g=S();try{J({sigma:g.sigma,now:s.now(),maxAgeMs:e.sigmaMaxAgeMs,releasedAt:g.releasedAt});}catch(w){if(w instanceof c&&w.code==="ARKORDER_STALE_SIGMA")return {kind:"hold",event:i,xiHash:g.xiHash,eventId:C(i),reasonCode:"stale-sigma",reason:w.message};throw w}let H=e.projector(g,g.sigma);return O(H,e.informationBudget),V(H,i,n,g.xiHash,g.sigma)},proposeRelease(i){return W({current:S(),delta:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget})},apply(i){return f(Q({current:S(),proposal:i,projector:e.projector,maxXiKeys:r,xiSchema:e.xiSchema,now:s.now(),catalogDigest:o,informationBudget:e.informationBudget}))},refreshSigma(i){return f(k(z({current:S(),sigma:i,now:s.now(),catalogDigest:o})))},restore(i){let g=N(i,d(s.now()));if(l&&(T(l,g.xi),g.version<l.version||g.version>l.version+1))throw new c("ARKORDER_UNVALVED_RELEASE",`restore() on a live plane accepts version ${l.version} or ${l.version+1}, got ${g.version}; change the pattern with proposeRelease then apply`);return f(k(g))},current(){return l}};for(let i of ["update","patch","set","mutate"])Object.defineProperty(M,i,{enumerable:false,configurable:false,get(){throw new c("ARKORDER_FORBIDDEN_METHOD",`${i}() is not a Haken operation; freeze a pattern with release() or proposeRelease()`)}});return Object.freeze(M)}t(le,"createOrderPlane");function de(e){let r=e??null;return {load(){return r},save(n){r=n;}}}t(de,"createMemoryReleaseStore");export{c as ArkOrderError,_ as CAPACITY_OPS,x as DEFAULT_MAX_XI_KEYS,de as createMemoryReleaseStore,le as createOrderPlane,h as hashOf,h as hashReleasePayload,ee as ingestTravelAction};