pi-mega-compact 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/vector-cortex/encoder-v1/manifest.json +1 -0
- package/assets/vector-cortex/encoder-v1/model-card.json +1 -0
- package/assets/vector-cortex/encoder-v1/model.onnx +0 -0
- package/assets/vector-cortex/encoder-v1/tokenizer.json +1 -0
- package/dist/config/vector-cortex.js +19 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +2 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-eval.js +49 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-health.js +233 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-ledger.js +82 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-shared.js +46 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-topology.js +68 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex.js +12 -285
- package/dist/extensions/dashboard-server/routes.js +1 -1
- package/dist/extensions/dashboard-server/server.js +3 -1
- package/dist/src/config/vector-cortex.js +19 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/cortex/sqlite.js +393 -0
- package/dist/src/vector-cortex/cortex/store.js +139 -0
- package/dist/src/vector-cortex/cortex/types.js +44 -0
- package/dist/src/vector-cortex/encoder/calibrate.js +174 -0
- package/dist/src/vector-cortex/encoder/emit-vc2c.js +59 -0
- package/dist/src/vector-cortex/encoder/fallback.js +62 -0
- package/dist/src/vector-cortex/encoder/select.js +172 -0
- package/dist/src/vector-cortex/encoder/types.js +31 -0
- package/dist/vector-cortex/cortex/sqlite.js +393 -0
- package/dist/vector-cortex/cortex/store.js +139 -0
- package/dist/vector-cortex/cortex/types.js +44 -0
- package/dist/vector-cortex/encoder/calibrate.js +174 -0
- package/dist/vector-cortex/encoder/emit-vc2c.js +59 -0
- package/dist/vector-cortex/encoder/fallback.js +62 -0
- package/dist/vector-cortex/encoder/select.js +172 -0
- package/dist/vector-cortex/encoder/types.js +31 -0
- package/extensions/dashboard-client/dist/assets/{AreaChart-BQXFF7UI.js → AreaChart-B9KYKrUE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-BQXFF7UI.js.map → AreaChart-B9KYKrUE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-BVtoz9Eg.js → BarChart-D1sWkR6j.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-BVtoz9Eg.js.map → BarChart-D1sWkR6j.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-trI2TIGy.js → CacheTab-BR8MYcJq.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-trI2TIGy.js.map → CacheTab-BR8MYcJq.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-CNUbk9__.js → EventsTab-BRNpDMvP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-CNUbk9__.js.map → EventsTab-BRNpDMvP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-K-bd_CM-.js → HealthTab-rr5nXpjq.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-K-bd_CM-.js.map → HealthTab-rr5nXpjq.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CoEioKzx.js → MaintenanceTab-CtjPWnzN.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CoEioKzx.js.map → MaintenanceTab-CtjPWnzN.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CJo24ulv.js → MemoryMapTab-5SnFDIYc.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CJo24ulv.js.map → MemoryMapTab-5SnFDIYc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DCNlQWWP.js → MetricsTab-4MZfwRhq.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DCNlQWWP.js.map → MetricsTab-4MZfwRhq.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-CQQlyIQ6.js → OverviewTab-BAKENnbk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-CQQlyIQ6.js.map → OverviewTab-BAKENnbk.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-Cqm82_yn.js → ReposTab-7-z_OmZo.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-Cqm82_yn.js.map → ReposTab-7-z_OmZo.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-A8xTAdET.js → SessionsTab-D_r2ki0y.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-A8xTAdET.js.map → SessionsTab-D_r2ki0y.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-CqaSgaZl.js → SetupTab-DPujtYgv.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-CqaSgaZl.js.map → SetupTab-DPujtYgv.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-C_f3q8GR.js → TimeSavedCard-CLHy30t6.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-C_f3q8GR.js.map → TimeSavedCard-CLHy30t6.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-BEsafACo.js → TurnsTab-Coul6CHc.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-BEsafACo.js.map → TurnsTab-Coul6CHc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-rqBpWc7A.js +2 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-rqBpWc7A.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{WikiTab-Bf01M2_Z.js → WikiTab-hryG5oyY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-Bf01M2_Z.js.map → WikiTab-hryG5oyY.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-BEJPTk_E.js → button-Dxo95lRI.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-BEJPTk_E.js.map → button-Dxo95lRI.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-DK1V382s.js → card-FXwhLF_u.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-DK1V382s.js.map → card-FXwhLF_u.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CRtaPphL.js → generateCategoricalChart-M-GeRM8U.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CRtaPphL.js.map → generateCategoricalChart-M-GeRM8U.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-CB6BslE4.js → index-BIZZXvoy.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-CB6BslE4.js.map → index-BIZZXvoy.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/index-CYpzq9Lm.css +1 -0
- package/extensions/dashboard-client/dist/assets/{switch-C4FV6B9k.js → switch-C-d4tkN1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-C4FV6B9k.js.map → switch-C-d4tkN1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-GBmeENMd.js → toggle-Bfmucdcl.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-GBmeENMd.js.map → toggle-Bfmucdcl.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-BOKZGSn1.js → useSSE-CxK_wdmk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BOKZGSn1.js.map → useSSE-CxK_wdmk.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +2 -2
- package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +36 -0
- package/extensions/dashboard-client/src/types/vector-cortex.ts +26 -0
- package/extensions/dashboard-server/api-contracts/vector-cortex.ts +34 -0
- package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
- package/extensions/dashboard-server/routes-vector-cortex-eval.ts +59 -0
- package/extensions/dashboard-server/routes-vector-cortex-health.ts +273 -0
- package/extensions/dashboard-server/routes-vector-cortex-ledger.ts +92 -0
- package/extensions/dashboard-server/routes-vector-cortex-shared.ts +53 -0
- package/extensions/dashboard-server/routes-vector-cortex-topology.ts +83 -0
- package/extensions/dashboard-server/routes-vector-cortex.ts +12 -324
- package/extensions/dashboard-server/routes.ts +1 -0
- package/extensions/dashboard-server/server.ts +2 -0
- package/package.json +2 -1
- package/src/config/vector-cortex.ts +21 -0
- package/src/config.ts +2 -0
- package/src/vector-cortex/cortex/sqlite.ts +489 -0
- package/src/vector-cortex/cortex/store.ts +202 -0
- package/src/vector-cortex/cortex/types.ts +194 -0
- package/src/vector-cortex/encoder/calibrate.ts +225 -0
- package/src/vector-cortex/encoder/emit-vc2c.ts +70 -0
- package/src/vector-cortex/encoder/fallback.ts +99 -0
- package/src/vector-cortex/encoder/select.ts +237 -0
- package/src/vector-cortex/encoder/types.ts +116 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD1CMK80.js +0 -2
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD1CMK80.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-CfvziyBi.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"batch":1,"heads":{"cacheStability":64,"contradiction":128,"dependency":128,"payloadRouting":32,"semantic":384},"hiddenWidth":384,"maxTokens":512,"modelVersion":"encoder-v1-placeholder","onnx":{"bytes":42,"path":"model.onnx","sha256":"01cbed8b0b301609542ff8c392c3e7d927b0d848ac53a768dfffd33bfe6005ff"},"opset":17,"platform":"linux-x64","schema":"model-manifest-v1","semanticWidth":384,"tokenizer":{"bytes":8518,"path":"tokenizer.json","sha256":"ada18e5c4dfcb5c369c05f4ffc10bc40298ce707e78f16135c6d33019f6db8cd"},"totalBytes":8560,"trainingManifestDigest":"e9b2550dbb79141af84440dda65ca21d3509904b2c09a89316145137a5b5e3de"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"accepted":"local offline deterministic projection over verified asset (V1); trained weights + evaluation land in VC2B/VC2C","comparison":[{"candidate":"MiniLM-class transformer","latencyMs":8,"license":"permissive","offlineNode":"no (native addon)","quality":"high","sizeMB":120},{"candidate":"small BERT","latencyMs":10,"license":"permissive","offlineNode":"partial","quality":"high","sizeMB":110},{"candidate":"bag/subword baseline","latencyMs":1,"license":"permissive","offlineNode":"yes","quality":"medium","sizeMB":4}],"note":"placeholder asset — replaced by the VC2C export pipeline","reprintPermission":true,"schema":"model-card-v1"}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"maxTokens":512,"schema":"wordpiece-tokenizer-v1","specialTokens":{"cls":2,"mask":4,"pad":0,"sep":3,"unk":1},"truncation":{"keepFirst":128,"keepLast":384},"vocab":[["[PAD]",0],["[UNK]",1],["[CLS]",2],["[SEP]",3],["[MASK]",4],["##tok0",5],["##tok1",6],["##tok2",7],["##tok3",8],["##tok4",9],["##tok5",10],["##tok6",11],["##tok7",12],["##tok8",13],["##tok9",14],["##tok10",15],["##tok11",16],["##tok12",17],["##tok13",18],["##tok14",19],["##tok15",20],["##tok16",21],["##tok17",22],["##tok18",23],["##tok19",24],["##tok20",25],["##tok21",26],["##tok22",27],["##tok23",28],["##tok24",29],["##tok25",30],["##tok26",31],["##tok27",32],["##tok28",33],["##tok29",34],["##tok30",35],["##tok31",36],["##tok32",37],["##tok33",38],["##tok34",39],["##tok35",40],["##tok36",41],["##tok37",42],["##tok38",43],["##tok39",44],["##tok40",45],["##tok41",46],["##tok42",47],["##tok43",48],["##tok44",49],["##tok45",50],["##tok46",51],["##tok47",52],["##tok48",53],["##tok49",54],["##tok50",55],["##tok51",56],["##tok52",57],["##tok53",58],["##tok54",59],["##tok55",60],["##tok56",61],["##tok57",62],["##tok58",63],["##tok59",64],["##tok60",65],["##tok61",66],["##tok62",67],["##tok63",68],["##tok64",69],["##tok65",70],["##tok66",71],["##tok67",72],["##tok68",73],["##tok69",74],["##tok70",75],["##tok71",76],["##tok72",77],["##tok73",78],["##tok74",79],["##tok75",80],["##tok76",81],["##tok77",82],["##tok78",83],["##tok79",84],["##tok80",85],["##tok81",86],["##tok82",87],["##tok83",88],["##tok84",89],["##tok85",90],["##tok86",91],["##tok87",92],["##tok88",93],["##tok89",94],["##tok90",95],["##tok91",96],["##tok92",97],["##tok93",98],["##tok94",99],["##tok95",100],["##tok96",101],["##tok97",102],["##tok98",103],["##tok99",104],["##tok100",105],["##tok101",106],["##tok102",107],["##tok103",108],["##tok104",109],["##tok105",110],["##tok106",111],["##tok107",112],["##tok108",113],["##tok109",114],["##tok110",115],["##tok111",116],["##tok112",117],["##tok113",118],["##tok114",119],["##tok115",120],["##tok116",121],["##tok117",122],["##tok118",123],["##tok119",124],["##tok120",125],["##tok121",126],["##tok122",127],["##tok123",128],["##tok124",129],["##tok125",130],["##tok126",131],["##tok127",132],["##tok128",133],["##tok129",134],["##tok130",135],["##tok131",136],["##tok132",137],["##tok133",138],["##tok134",139],["##tok135",140],["##tok136",141],["##tok137",142],["##tok138",143],["##tok139",144],["##tok140",145],["##tok141",146],["##tok142",147],["##tok143",148],["##tok144",149],["##tok145",150],["##tok146",151],["##tok147",152],["##tok148",153],["##tok149",154],["##tok150",155],["##tok151",156],["##tok152",157],["##tok153",158],["##tok154",159],["##tok155",160],["##tok156",161],["##tok157",162],["##tok158",163],["##tok159",164],["##tok160",165],["##tok161",166],["##tok162",167],["##tok163",168],["##tok164",169],["##tok165",170],["##tok166",171],["##tok167",172],["##tok168",173],["##tok169",174],["##tok170",175],["##tok171",176],["##tok172",177],["##tok173",178],["##tok174",179],["##tok175",180],["##tok176",181],["##tok177",182],["##tok178",183],["##tok179",184],["##tok180",185],["##tok181",186],["##tok182",187],["##tok183",188],["##tok184",189],["##tok185",190],["##tok186",191],["##tok187",192],["##tok188",193],["##tok189",194],["##tok190",195],["##tok191",196],["##tok192",197],["##tok193",198],["##tok194",199],["##tok195",200],["##tok196",201],["##tok197",202],["##tok198",203],["##tok199",204],["##tok200",205],["##tok201",206],["##tok202",207],["##tok203",208],["##tok204",209],["##tok205",210],["##tok206",211],["##tok207",212],["##tok208",213],["##tok209",214],["##tok210",215],["##tok211",216],["##tok212",217],["##tok213",218],["##tok214",219],["##tok215",220],["##tok216",221],["##tok217",222],["##tok218",223],["##tok219",224],["##tok220",225],["##tok221",226],["##tok222",227],["##tok223",228],["##tok224",229],["##tok225",230],["##tok226",231],["##tok227",232],["##tok228",233],["##tok229",234],["##tok230",235],["##tok231",236],["##tok232",237],["##tok233",238],["##tok234",239],["##tok235",240],["##tok236",241],["##tok237",242],["##tok238",243],["##tok239",244],["##tok240",245],["##tok241",246],["##tok242",247],["##tok243",248],["##tok244",249],["##tok245",250],["##tok246",251],["##tok247",252],["##tok248",253],["##tok249",254],["##tok250",255],["##tok251",256],["##tok252",257],["##tok253",258],["##tok254",259],["##tok255",260],["##tok256",261],["##tok257",262],["##tok258",263],["##tok259",264],["##tok260",265],["##tok261",266],["##tok262",267],["##tok263",268],["##tok264",269],["##tok265",270],["##tok266",271],["##tok267",272],["##tok268",273],["##tok269",274],["##tok270",275],["##tok271",276],["##tok272",277],["##tok273",278],["##tok274",279],["##tok275",280],["##tok276",281],["##tok277",282],["##tok278",283],["##tok279",284],["##tok280",285],["##tok281",286],["##tok282",287],["##tok283",288],["##tok284",289],["##tok285",290],["##tok286",291],["##tok287",292],["##tok288",293],["##tok289",294],["##tok290",295],["##tok291",296],["##tok292",297],["##tok293",298],["##tok294",299],["##tok295",300],["##tok296",301],["##tok297",302],["##tok298",303],["##tok299",304],["##tok300",305],["##tok301",306],["##tok302",307],["##tok303",308],["##tok304",309],["##tok305",310],["##tok306",311],["##tok307",312],["##tok308",313],["##tok309",314],["##tok310",315],["##tok311",316],["##tok312",317],["##tok313",318],["##tok314",319],["##tok315",320],["##tok316",321],["##tok317",322],["##tok318",323],["##tok319",324],["##tok320",325],["##tok321",326],["##tok322",327],["##tok323",328],["##tok324",329],["##tok325",330],["##tok326",331],["##tok327",332],["##tok328",333],["##tok329",334],["##tok330",335],["##tok331",336],["##tok332",337],["##tok333",338],["##tok334",339],["##tok335",340],["##tok336",341],["##tok337",342],["##tok338",343],["##tok339",344],["##tok340",345],["##tok341",346],["##tok342",347],["##tok343",348],["##tok344",349],["##tok345",350],["##tok346",351],["##tok347",352],["##tok348",353],["##tok349",354],["##tok350",355],["##tok351",356],["##tok352",357],["##tok353",358],["##tok354",359],["##tok355",360],["##tok356",361],["##tok357",362],["##tok358",363],["##tok359",364],["##tok360",365],["##tok361",366],["##tok362",367],["##tok363",368],["##tok364",369],["##tok365",370],["##tok366",371],["##tok367",372],["##tok368",373],["##tok369",374],["##tok370",375],["##tok371",376],["##tok372",377],["##tok373",378],["##tok374",379],["##tok375",380],["##tok376",381],["##tok377",382],["##tok378",383],["##tok379",384],["##tok380",385],["##tok381",386],["##tok382",387],["##tok383",388],["##tok384",389],["##tok385",390],["##tok386",391],["##tok387",392],["##tok388",393],["##tok389",394],["##tok390",395],["##tok391",396],["##tok392",397],["##tok393",398],["##tok394",399],["##tok395",400],["##tok396",401],["##tok397",402],["##tok398",403],["##tok399",404],["##tok400",405],["##tok401",406],["##tok402",407],["##tok403",408],["##tok404",409],["##tok405",410],["##tok406",411],["##tok407",412],["##tok408",413],["##tok409",414],["##tok410",415],["##tok411",416],["##tok412",417],["##tok413",418],["##tok414",419],["##tok415",420],["##tok416",421],["##tok417",422],["##tok418",423],["##tok419",424],["##tok420",425],["##tok421",426],["##tok422",427],["##tok423",428],["##tok424",429],["##tok425",430],["##tok426",431],["##tok427",432],["##tok428",433],["##tok429",434],["##tok430",435],["##tok431",436],["##tok432",437],["##tok433",438],["##tok434",439],["##tok435",440],["##tok436",441],["##tok437",442],["##tok438",443],["##tok439",444],["##tok440",445],["##tok441",446],["##tok442",447],["##tok443",448],["##tok444",449],["##tok445",450],["##tok446",451],["##tok447",452],["##tok448",453],["##tok449",454],["##tok450",455],["##tok451",456],["##tok452",457],["##tok453",458],["##tok454",459],["##tok455",460],["##tok456",461],["##tok457",462],["##tok458",463],["##tok459",464],["##tok460",465],["##tok461",466],["##tok462",467],["##tok463",468],["##tok464",469],["##tok465",470],["##tok466",471],["##tok467",472],["##tok468",473],["##tok469",474],["##tok470",475],["##tok471",476],["##tok472",477],["##tok473",478],["##tok474",479],["##tok475",480],["##tok476",481],["##tok477",482],["##tok478",483],["##tok479",484],["##tok480",485],["##tok481",486],["##tok482",487],["##tok483",488],["##tok484",489],["##tok485",490],["##tok486",491],["##tok487",492],["##tok488",493],["##tok489",494],["##tok490",495],["##tok491",496],["##tok492",497],["##tok493",498],["##tok494",499],["##tok495",500],["##tok496",501],["##tok497",502],["##tok498",503],["##tok499",504]]}
|
|
@@ -82,6 +82,25 @@ export const VC2A_ENABLED = () => sprintFlag("MEGACOMPACT_VC2A");
|
|
|
82
82
|
* emit seam and the multi-head encoder producers (heads/trigram/lexical).
|
|
83
83
|
*/
|
|
84
84
|
export const VC2B_ENABLED = () => sprintFlag("MEGACOMPACT_VC2B");
|
|
85
|
+
/**
|
|
86
|
+
* VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
|
|
87
|
+
* Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
|
|
88
|
+
* predecessor (mode C: no qualification manifest is read or selected, the
|
|
89
|
+
* calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
|
|
90
|
+
* emissions; the trigram/lexical paths are unchanged). The real consumers are
|
|
91
|
+
* the encoder-qualification emit seam and the calibrate/select seams.
|
|
92
|
+
*/
|
|
93
|
+
export const VC2C_ENABLED = () => sprintFlag("MEGACOMPACT_VC2C");
|
|
94
|
+
/**
|
|
95
|
+
* VC3A — capability-gated cortex store (CortexReader/Writer/Admin, CortexRecordV1).
|
|
96
|
+
* Default ON. `MEGACOMPACT_VC3A=0` disables and is byte-identical to the
|
|
97
|
+
* predecessor (mode C: the derived cortex store is absent, mode B in-memory is
|
|
98
|
+
* not consulted, zero `vector_cortex_record_append_failed` /
|
|
99
|
+
* `vector_cortex_generation_rebuilt` emissions; the predecessor derived pointer
|
|
100
|
+
* and goldens are unchanged). The real consumers are the cortex append seam, the
|
|
101
|
+
* cortex rebuild/admin seam and the reader-only topology summary seam.
|
|
102
|
+
*/
|
|
103
|
+
export const VC3A_ENABLED = () => sprintFlag("MEGACOMPACT_VC3A");
|
|
85
104
|
// ---------------------------------------------------------------------------
|
|
86
105
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
|
|
87
106
|
// Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
|
package/dist/config.js
CHANGED
|
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
|
|
|
114
114
|
// default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
|
|
115
115
|
// so root consumers share one source of truth.
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
|
-
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
117
|
+
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
@@ -142,6 +142,8 @@ export const SETTINGS = [
|
|
|
142
142
|
boolDirect("MEGACOMPACT_VC1C", "VC1C Cross-Language Conformance v2", "FixtureManifestV2 canonical manifest validator + DowngradeReport deterministic downgrade export + MinHashV2 exact big-integer signatures and the M4 copy/validate/switch minhash-v2 migration (seed table frozen, cross-language byte-exact). OFF = mode C, v1 sync dedup scan unchanged, byte-identical.", true),
|
|
143
143
|
boolDirect("MEGACOMPACT_VC2A", "VC2A Offline Model Runtime", "ModelManifestV1 digest-before-load ONNX runtime (opset17/batch1/max512) + asset-free trigram demotion. Asset path assets/vector-cortex/encoder-v1 is immutable/digest-pinned. OFF = mode C, byte-identical to predecessor.", true),
|
|
144
144
|
boolDirect("MEGACOMPACT_VC2B", "VC2B Multi-Head Encoder", "VectorSetV1 five L2-normalized heads (384/128/128/64/32) with head-calibration draft + asset-free trigram B (512d) and lexical C fallbacks, plus the per-head emit seam. OFF = mode C, no per-head vectors emitted, byte-identical predecessor.", true),
|
|
145
|
+
boolDirect("MEGACOMPACT_VC2C", "VC2C Encoder Qualification + Calibration", "QualifiedEncoderV1/CalibrationV1: calibration fit on the calibration split only (held-out labels prohibited) + atomic selection across MODEL_ASSET and per-head EVALUATION thresholds (any field failure demotes all of A). OFF = mode C, no qualification/calibration selection, byte-identical predecessor.", true),
|
|
146
|
+
boolDirect("MEGACOMPACT_VC3A", "VC3A Cortex Store", "Capability-gated derived cortex store (CortexReader/Writer/Admin + CortexRecordV1): additive, keyed (sourceHighWater, algorithmVersion, id), immutable records, deterministic generation rebuild + one root digest. OFF = mode C, no cortex records written, byte-identical predecessor.", true),
|
|
145
147
|
],
|
|
146
148
|
},
|
|
147
149
|
{
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-eval.ts — VC0A vector-cortex evaluation
|
|
3
|
+
* dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* A single reader-only GET /api/vector-cortex/evaluation that aggregates redacted
|
|
6
|
+
* evaluation rows (persisted JSONL under the state dir) via the reader. No
|
|
7
|
+
* writable capability — no reset/mutation here.
|
|
8
|
+
*
|
|
9
|
+
* Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
|
|
10
|
+
* `any`), reader-only aggregate (never payloads/prompts/ledger — EVAL-REDACT-002).
|
|
11
|
+
*/
|
|
12
|
+
import { VC0A_ENABLED } from "../../src/config.js";
|
|
13
|
+
import { readEvalRows } from "../../src/vector-cortex/eval/persist.js";
|
|
14
|
+
import { summarizeEvalRows } from "../../src/vector-cortex/eval/reader.js";
|
|
15
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
16
|
+
/** Reader-only aggregate GET /api/vector-cortex/evaluation. */
|
|
17
|
+
export function handleVectorCortexEvaluation(req, res, ctx) {
|
|
18
|
+
const url = req.url ?? "";
|
|
19
|
+
if (url !== "/api/vector-cortex/evaluation")
|
|
20
|
+
return false;
|
|
21
|
+
if (req.method !== "GET") {
|
|
22
|
+
// Reader-only: no mutation endpoints exist on this path.
|
|
23
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
const enabled = VC0A_ENABLED();
|
|
27
|
+
const rows = enabled ? readEvalRows(ctx.stateDir) : [];
|
|
28
|
+
const summary = summarizeEvalRows(rows);
|
|
29
|
+
const body = {
|
|
30
|
+
enabled,
|
|
31
|
+
mode: enabled ? "A" : "C",
|
|
32
|
+
samples: summary.samples,
|
|
33
|
+
byMode: {
|
|
34
|
+
A: summary.byMode.A,
|
|
35
|
+
B: summary.byMode.B,
|
|
36
|
+
C: summary.byMode.C,
|
|
37
|
+
},
|
|
38
|
+
histogram: {
|
|
39
|
+
edges: [...summary.histogram.edges],
|
|
40
|
+
cells: [...summary.histogram.cells],
|
|
41
|
+
overflow: summary.histogram.overflow,
|
|
42
|
+
total: summary.histogram.total,
|
|
43
|
+
},
|
|
44
|
+
rejects: [], // VC0C wires live breaker/reject telemetry here
|
|
45
|
+
updatedAt: new Date().toISOString(),
|
|
46
|
+
};
|
|
47
|
+
sendJson(res, 200, body);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-health.ts — VC0C vector-cortex breaker
|
|
3
|
+
* health + reset routes (plus the VC2C encoder-health facts they surface).
|
|
4
|
+
*
|
|
5
|
+
* GET /api/vector-cortex/health — reader-only aggregate health card
|
|
6
|
+
* POST /api/vector-cortex/breakers/reset — explicit admin capability
|
|
7
|
+
*
|
|
8
|
+
* Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
|
|
9
|
+
* `any`), reader-only aggregate (never payloads/prompts/ledger — EVAL-REDACT-002).
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { readFileSync, statSync } from "node:fs";
|
|
13
|
+
import { join, dirname } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { VC0C_ENABLED, VC2C_ENABLED } from "../../src/config.js";
|
|
16
|
+
import { createVectorCortexSafety } from "../mega-runtime/vector-cortex-safety.js";
|
|
17
|
+
import { readEncoderManifest, verifyEncoderAsset, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
|
|
18
|
+
import { sendJson, readJsonBody } from "./routes-vector-cortex-shared.js";
|
|
19
|
+
/** Resolve the committed encoder-v1 asset dir by walking up to the repo root. */
|
|
20
|
+
function encoderAssetDir() {
|
|
21
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const rel = join("assets", "vector-cortex", "encoder-v1");
|
|
23
|
+
for (let i = 0; i < 8; i++) {
|
|
24
|
+
const candidate = join(dir, rel);
|
|
25
|
+
try {
|
|
26
|
+
// guardrails-allow PREVENT-PI-004: local asset filesystem read (loopback)
|
|
27
|
+
readFileSync(join(candidate, "manifest.json"));
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
/* keep walking */
|
|
32
|
+
}
|
|
33
|
+
const next = dirname(dir);
|
|
34
|
+
if (next === dir)
|
|
35
|
+
break;
|
|
36
|
+
dir = next;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
let healthCache = null;
|
|
41
|
+
/** Stable cache key: manifest bytes + (size,mtime) of the asset files + platform. */
|
|
42
|
+
function healthFactCacheKey(dir, manifestPath) {
|
|
43
|
+
const platform = detectPlatform();
|
|
44
|
+
if (!platform)
|
|
45
|
+
return null;
|
|
46
|
+
const parts = [platform];
|
|
47
|
+
try {
|
|
48
|
+
for (const p of [manifestPath, join(dir, "model.onnx"), join(dir, "tokenizer.json")]) {
|
|
49
|
+
const s = statSync(p);
|
|
50
|
+
parts.push(`${s.size}:${s.mtimeMs}`);
|
|
51
|
+
}
|
|
52
|
+
// guardrails-allow PREVENT-PI-004: local manifest filesystem read (loopback)
|
|
53
|
+
parts.push(createHash("sha256").update(readFileSync(manifestPath)).digest("hex"));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return parts.join("|");
|
|
59
|
+
}
|
|
60
|
+
function computeEncoderHealthFacts(dir) {
|
|
61
|
+
const manifest = readEncoderManifest(dir);
|
|
62
|
+
if (manifest === null)
|
|
63
|
+
return { assetDigest: null, mode: "C" };
|
|
64
|
+
const manifestPath = join(dir, "manifest.json");
|
|
65
|
+
const key = healthFactCacheKey(dir, manifestPath);
|
|
66
|
+
if (key === null)
|
|
67
|
+
return null;
|
|
68
|
+
if (healthCache !== null && healthCache.key === key)
|
|
69
|
+
return healthCache.facts;
|
|
70
|
+
let digest;
|
|
71
|
+
try {
|
|
72
|
+
// guardrails-allow PREVENT-PI-004: local manifest filesystem read (loopback)
|
|
73
|
+
digest = createHash("sha256").update(readFileSync(manifestPath)).digest("hex");
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { assetDigest: null, mode: "B" };
|
|
77
|
+
}
|
|
78
|
+
const verify = verifyEncoderAsset(dir, manifest, detectPlatform());
|
|
79
|
+
const facts = { assetDigest: digest, mode: verify.ok ? "A" : "B" };
|
|
80
|
+
healthCache = { key, facts };
|
|
81
|
+
return facts;
|
|
82
|
+
}
|
|
83
|
+
function encoderHealthFacts() {
|
|
84
|
+
if (!VC2C_ENABLED()) {
|
|
85
|
+
// Rollback: MEGACOMPACT_VC2C=0 selects C — report the inactive (flag-gated)
|
|
86
|
+
// mode with no asset digest rather than an on-disk-computed A/B.
|
|
87
|
+
return { assetDigest: null, mode: "C" };
|
|
88
|
+
}
|
|
89
|
+
const dir = encoderAssetDir();
|
|
90
|
+
if (dir === null)
|
|
91
|
+
return { assetDigest: null, mode: "C" };
|
|
92
|
+
const facts = computeEncoderHealthFacts(dir);
|
|
93
|
+
if (facts === null)
|
|
94
|
+
return { assetDigest: null, mode: "C" };
|
|
95
|
+
return facts;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Reader-only GET /api/vector-cortex/health (VC0C).
|
|
99
|
+
*
|
|
100
|
+
* Aggregate health card: breaker state (window/probe/backoff), durable spool
|
|
101
|
+
* frontier/authority/lag, and a worst-state aggregate. Constructs the safety
|
|
102
|
+
* adapter over the state dir — durable spool state (frontier-frozen, lag) is
|
|
103
|
+
* read from disk, so it reflects restart. Purely read: no mutation, never
|
|
104
|
+
* payloads/prompts/ledger.
|
|
105
|
+
*/
|
|
106
|
+
export function handleVectorCortexHealth(req, res, ctx) {
|
|
107
|
+
const url = req.url ?? "";
|
|
108
|
+
if (url !== "/api/vector-cortex/health")
|
|
109
|
+
return false;
|
|
110
|
+
if (req.method !== "GET") {
|
|
111
|
+
// Reader-only path: no mutation endpoint lives at /health.
|
|
112
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const enabled = VC0C_ENABLED();
|
|
116
|
+
const safety = enabled ? createVectorCortexSafety({ stateDir: ctx.stateDir }) : null;
|
|
117
|
+
const card = safety ? safety.health() : null;
|
|
118
|
+
const enc = encoderHealthFacts();
|
|
119
|
+
const fallback = {
|
|
120
|
+
enabled: false,
|
|
121
|
+
mode: "C",
|
|
122
|
+
state: "CLOSED_A",
|
|
123
|
+
subsystem: "provider",
|
|
124
|
+
sinceMs: 0,
|
|
125
|
+
windowMs: 0,
|
|
126
|
+
probeCount: 0,
|
|
127
|
+
backoffDelayMs: 0,
|
|
128
|
+
frontierFrozen: false,
|
|
129
|
+
authorityOutage: false,
|
|
130
|
+
spoolLag: 0,
|
|
131
|
+
attempts: 0,
|
|
132
|
+
failures: 0,
|
|
133
|
+
p95Ms: 0,
|
|
134
|
+
failureRate: 0,
|
|
135
|
+
updatedAt: new Date().toISOString(),
|
|
136
|
+
aggregate: "CLOSED_A",
|
|
137
|
+
stateSource: "ephemeral",
|
|
138
|
+
encoderAssetDigest: enc.assetDigest,
|
|
139
|
+
encoderMode: enc.mode,
|
|
140
|
+
};
|
|
141
|
+
if (!card) {
|
|
142
|
+
sendJson(res, 200, fallback);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
const mode = card.state === "CLOSED_A" ? "A" : card.state === "MANUAL_HALT" ? "C" : "B";
|
|
146
|
+
const aggregate = card.state === "MANUAL_HALT"
|
|
147
|
+
? "MANUAL_HALT"
|
|
148
|
+
: card.state === "OPEN_C"
|
|
149
|
+
? "OPEN_C"
|
|
150
|
+
: card.state === "OPEN_B"
|
|
151
|
+
? "OPEN_B"
|
|
152
|
+
: card.state === "PROBE_B" || card.state === "PROBE_A"
|
|
153
|
+
? "PROBE"
|
|
154
|
+
: "CLOSED_A";
|
|
155
|
+
const body = {
|
|
156
|
+
enabled,
|
|
157
|
+
mode,
|
|
158
|
+
state: card.state,
|
|
159
|
+
subsystem: card.subsystem,
|
|
160
|
+
sinceMs: card.sinceMs,
|
|
161
|
+
reason: card.reason,
|
|
162
|
+
windowMs: card.windowMs,
|
|
163
|
+
probeCount: card.probeCount,
|
|
164
|
+
backoffDelayMs: card.backoffDelayMs,
|
|
165
|
+
frontierFrozen: card.frontierFrozen,
|
|
166
|
+
authorityOutage: card.authorityOutage,
|
|
167
|
+
spoolLag: card.spoolLag,
|
|
168
|
+
attempts: card.attempts,
|
|
169
|
+
failures: card.failures,
|
|
170
|
+
p95Ms: card.p95Ms,
|
|
171
|
+
failureRate: card.failureRate,
|
|
172
|
+
updatedAt: new Date().toISOString(),
|
|
173
|
+
aggregate,
|
|
174
|
+
stateSource: card.stateSource,
|
|
175
|
+
encoderAssetDigest: enc.assetDigest,
|
|
176
|
+
encoderMode: enc.mode,
|
|
177
|
+
};
|
|
178
|
+
sendJson(res, 200, body);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Admin POST /api/vector-cortex/breakers/reset (VC0C).
|
|
183
|
+
*
|
|
184
|
+
* Explicit admin capability (separate from the reader GET). Clears a breaker's
|
|
185
|
+
* cooldown — or unwires a MANUAL_HALT — but NEVER evidence (attempts/failures
|
|
186
|
+
* are retained, per TRIAD_RESILIENCE). The subsystem is actor-supplied via the
|
|
187
|
+
* JSON body `{ subsystem }`. Every reset is documented in the returned record
|
|
188
|
+
* (state, retained evidence, updatedAt) — an auditable mutation surface; the
|
|
189
|
+
* GET path can never mutate.
|
|
190
|
+
*/
|
|
191
|
+
export function handleVectorCortexBreakersReset(req, res, ctx) {
|
|
192
|
+
const url = req.url ?? "";
|
|
193
|
+
if (url !== "/api/vector-cortex/breakers/reset")
|
|
194
|
+
return false;
|
|
195
|
+
if (req.method !== "POST") {
|
|
196
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (!VC0C_ENABLED()) {
|
|
200
|
+
sendJson(res, 409, { error: "vco_c_disabled" });
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
readJsonBody(req, (parsed) => {
|
|
204
|
+
if (!parsed.ok) {
|
|
205
|
+
sendJson(res, 400, { error: parsed.error });
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const subsystem = parsed.value.subsystem;
|
|
209
|
+
if (typeof subsystem !== "string" || subsystem.length === 0) {
|
|
210
|
+
sendJson(res, 400, { error: "subsystem_required" });
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const safety = createVectorCortexSafety({ stateDir: ctx.stateDir });
|
|
215
|
+
const rec = safety.reset(subsystem);
|
|
216
|
+
const body = {
|
|
217
|
+
subsystem: rec.subsystem,
|
|
218
|
+
state: rec.state,
|
|
219
|
+
cooldownCleared: true,
|
|
220
|
+
attempts: rec.attempts,
|
|
221
|
+
failures: rec.failures,
|
|
222
|
+
probeCount: rec.probeCount,
|
|
223
|
+
manualReason: rec.manualReason,
|
|
224
|
+
updatedAt: rec.updatedAt,
|
|
225
|
+
};
|
|
226
|
+
sendJson(res, 200, body);
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
sendJson(res, 500, { error: "reset_failed" });
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-ledger.ts — VC1B vector-cortex ledger
|
|
3
|
+
* dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* Reader-only GET /api/vector-cortex/ledger built on the LedgerReader capability:
|
|
6
|
+
* opens the occurrence-v2 ledger for this repo's state dir and returns the
|
|
7
|
+
* session's occurrence IDENTITY rows (seq/eventId/kind/digest/toolCallId) plus
|
|
8
|
+
* high-water/count. NEVER ships sourceBytes or prompt text (reader-only
|
|
9
|
+
* no-ledger-text rule). Optional `?session=<id>` query selects the session.
|
|
10
|
+
*
|
|
11
|
+
* Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
|
|
12
|
+
* `any`), reader-only aggregate/identity only.
|
|
13
|
+
*/
|
|
14
|
+
import { VC1B_ENABLED } from "../../src/config.js";
|
|
15
|
+
import { createLedgerStore } from "../../src/vector-cortex/ledger/store.js";
|
|
16
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
17
|
+
/**
|
|
18
|
+
* Reader-only GET /api/vector-cortex/ledger (VC1B).
|
|
19
|
+
*/
|
|
20
|
+
export function handleVectorCortexLedger(req, res, ctx) {
|
|
21
|
+
const url = req.url ?? "";
|
|
22
|
+
const path = url.split("?")[0] ?? url;
|
|
23
|
+
if (path !== "/api/vector-cortex/ledger")
|
|
24
|
+
return false;
|
|
25
|
+
if (req.method !== "GET") {
|
|
26
|
+
// Reader-only path: no mutation endpoint lives at /ledger.
|
|
27
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// Parse the optional session query parameter.
|
|
31
|
+
let session = "default";
|
|
32
|
+
const qs = url.split("?")[1];
|
|
33
|
+
if (qs !== undefined) {
|
|
34
|
+
for (const pair of qs.split("&")) {
|
|
35
|
+
const [k, v] = pair.split("=");
|
|
36
|
+
if (k === "session" && v !== undefined && v.length > 0) {
|
|
37
|
+
session = decodeURIComponent(v);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const enabled = VC1B_ENABLED();
|
|
42
|
+
let active = enabled;
|
|
43
|
+
let highWater = "0";
|
|
44
|
+
let count = 0;
|
|
45
|
+
let occurrences = [];
|
|
46
|
+
if (enabled) {
|
|
47
|
+
try {
|
|
48
|
+
const store = createLedgerStore({ stateDir: ctx.stateDir });
|
|
49
|
+
try {
|
|
50
|
+
const reader = store.reader();
|
|
51
|
+
highWater = reader.highWater(session).toString();
|
|
52
|
+
const rows = reader.readSession(session);
|
|
53
|
+
count = rows.length;
|
|
54
|
+
// Identity only: never sourceBytes or prompt text (reader-only rule).
|
|
55
|
+
occurrences = rows.slice(-500).map((occ) => ({
|
|
56
|
+
seq: occ.seq.toString(),
|
|
57
|
+
eventId: occ.eventId,
|
|
58
|
+
kind: occ.kind,
|
|
59
|
+
digest: occ.digest,
|
|
60
|
+
...(occ.toolCallId !== undefined ? { toolCallId: occ.toolCallId } : {}),
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
store.close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Non-fatal: a missing/corrupt ledger DB degrades to `enabled:false`.
|
|
69
|
+
active = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const body = {
|
|
73
|
+
enabled: active,
|
|
74
|
+
session,
|
|
75
|
+
highWater,
|
|
76
|
+
count,
|
|
77
|
+
occurrences,
|
|
78
|
+
updatedAt: new Date().toISOString(),
|
|
79
|
+
};
|
|
80
|
+
sendJson(res, 200, body);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-shared.ts — shared HTTP helpers for the
|
|
3
|
+
* per-feature vector-cortex route modules.
|
|
4
|
+
*
|
|
5
|
+
* Homes the small request/response helpers used across the VC0A/VC0C/VC1B/VC3A
|
|
6
|
+
* handler modules (`sendJson`, `readJsonBody`) so the feature modules stay small
|
|
7
|
+
* and within extension line limits.
|
|
8
|
+
*
|
|
9
|
+
* Guardrails: PREVENT-PI-004 (loopback dashboard response only), PREVENT-011 (no
|
|
10
|
+
* `any`), PREVENT-001 (JSON.parse guarded by an object/shape check).
|
|
11
|
+
*/
|
|
12
|
+
export function sendJson(res, status, body) {
|
|
13
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
14
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
15
|
+
res.end(JSON.stringify(body));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse a JSON request body with a size cap. `cb` receives either a validated
|
|
19
|
+
* plain object or an error reason. PREVENT-001: JSON.parse is guarded by a
|
|
20
|
+
* shape check (rejects null / arrays / non-objects).
|
|
21
|
+
*/
|
|
22
|
+
export function readJsonBody(req, cb) {
|
|
23
|
+
let body = "";
|
|
24
|
+
let tooBig = false;
|
|
25
|
+
req.on("data", (chunk) => {
|
|
26
|
+
if (body.length > 65536) {
|
|
27
|
+
tooBig = true;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
body += chunk.toString();
|
|
31
|
+
});
|
|
32
|
+
req.on("end", () => {
|
|
33
|
+
if (tooBig)
|
|
34
|
+
return cb({ ok: false, error: "body_too_large" });
|
|
35
|
+
try {
|
|
36
|
+
const v = body ? JSON.parse(body) : {};
|
|
37
|
+
if (typeof v !== "object" || v === null || Array.isArray(v)) {
|
|
38
|
+
return cb({ ok: false, error: "invalid_object" });
|
|
39
|
+
}
|
|
40
|
+
cb({ ok: true, value: v });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
cb({ ok: false, error: "invalid_json" });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-vector-cortex-topology.ts — VC3A vector-cortex topology
|
|
3
|
+
* dashboard route.
|
|
4
|
+
*
|
|
5
|
+
* Reader-only GET /api/vector-cortex/topology built ENTIRELY on the CortexReader
|
|
6
|
+
* capability: opens the isolated cortex DB for this repo's state dir and returns
|
|
7
|
+
* the topology summary (enabled, active generation identity, one root digest,
|
|
8
|
+
* derived frontier, record count, ordinal). It is query-only — never
|
|
9
|
+
* append/rebuild/switch. No writer or admin capability is reachable on this path
|
|
10
|
+
* (no writer/admin leakage). Non-fatal: a missing or corrupt cortex DB degrades
|
|
11
|
+
* to `enabled:false`.
|
|
12
|
+
*
|
|
13
|
+
* Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
|
|
14
|
+
* `any`), reader-only aggregate.
|
|
15
|
+
*/
|
|
16
|
+
import { VC3A_ENABLED } from "../../src/config.js";
|
|
17
|
+
import { createCortexStore } from "../../src/vector-cortex/cortex/store.js";
|
|
18
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
19
|
+
/**
|
|
20
|
+
* Reader-only GET /api/vector-cortex/topology (VC3A).
|
|
21
|
+
*/
|
|
22
|
+
export function handleVectorCortexTopology(req, res, ctx) {
|
|
23
|
+
const url = req.url ?? "";
|
|
24
|
+
const path = url.split("?")[0] ?? url;
|
|
25
|
+
if (path !== "/api/vector-cortex/topology")
|
|
26
|
+
return false;
|
|
27
|
+
if (req.method !== "GET") {
|
|
28
|
+
// Reader-only path: no mutation endpoint lives at /topology.
|
|
29
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const enabled = VC3A_ENABLED();
|
|
33
|
+
let active = enabled;
|
|
34
|
+
let summary = { generationId: null, rootDigest: null, sourceHighWater: "0", recordCount: 0, ordinal: null };
|
|
35
|
+
if (enabled) {
|
|
36
|
+
try {
|
|
37
|
+
const store = createCortexStore({ stateDir: ctx.stateDir });
|
|
38
|
+
try {
|
|
39
|
+
const s = store.reader().topologySummary();
|
|
40
|
+
summary = {
|
|
41
|
+
generationId: s.generationId,
|
|
42
|
+
rootDigest: s.rootDigest,
|
|
43
|
+
sourceHighWater: s.sourceHighWater,
|
|
44
|
+
recordCount: s.recordCount,
|
|
45
|
+
ordinal: s.ordinal,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
store.close();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Non-fatal: a missing/corrupt cortex DB degrades to `enabled:false`.
|
|
54
|
+
active = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const body = {
|
|
58
|
+
enabled: active,
|
|
59
|
+
generationId: summary.generationId,
|
|
60
|
+
rootDigest: summary.rootDigest,
|
|
61
|
+
sourceHighWater: summary.sourceHighWater,
|
|
62
|
+
recordCount: summary.recordCount,
|
|
63
|
+
ordinal: summary.ordinal,
|
|
64
|
+
updatedAt: new Date().toISOString(),
|
|
65
|
+
};
|
|
66
|
+
sendJson(res, 200, body);
|
|
67
|
+
return true;
|
|
68
|
+
}
|