deadbyte-mcp 0.13.0 → 0.14.0
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/.gitattributes +7 -0
- package/AGENTS.md +25 -0
- package/CONTEXT.md +3 -3
- package/MANIFEST.SHA256 +66 -40
- package/R42-PARENT.json +19 -0
- package/README.txt +2 -2
- package/bin/appcontainer-stage.obj +0 -0
- package/bin/bootstrap-advapi32.obj +0 -0
- package/bin/bootstrap-exitcode.obj +0 -0
- package/bin/bootstrap-kernel32.obj +0 -0
- package/bin/child-control-probe.obj +0 -0
- package/bin/child-control-stage.obj +0 -0
- package/bin/contained-reverse-worker.obj +0 -0
- package/bin/contained-transform-worker.obj +0 -0
- package/bin/containment-probe.obj +0 -0
- package/bin/deadbyte-contain.obj +0 -0
- package/bin/deadbyte-exec.obj +0 -0
- package/bin/deadbyte-process-host.obj +0 -0
- package/bin/deadbyte-tunnel-host.obj +0 -0
- package/controller/README.TXT +1 -1
- package/controller/deadbyte-controller.ps1 +1 -1
- package/controller/deadbyte-desktop-policy.json +5 -5
- package/controller/deadbyte-process-policy.json +4 -4
- package/docs/ARCHITECTURE.md +1 -1
- package/harness/r42-agent-evals.json +48 -0
- package/harness/task-contract.schema.json +33 -0
- package/package.json +9 -7
- package/proof/CONTAINMENT-BUILD.txt +6 -6
- package/scripts/agent-eval-r42.mjs +46 -0
- package/scripts/deferred-slot-operation-r42.mjs +126 -0
- package/scripts/final-closure-r42.mjs +116 -0
- package/scripts/final-closure-verify-r42.mjs +223 -0
- package/scripts/gate-windows-r42.ps1 +54 -0
- package/scripts/release-parity-r42.mjs +235 -0
- package/scripts/release-parity-tests-r42.ps1 +6 -0
- package/scripts/verify-r42-parent.mjs +101 -0
- package/scripts/windows-gate-evidence-r42.mjs +64 -0
- package/src/agent-eval-r42.mjs +73 -0
- package/src/agent-eval-runner-r42.mjs +138 -0
- package/src/agent-governance-r42.mjs +142 -0
- package/src/autonomous-context-engine.mjs +2 -0
- package/src/autonomous-loop-state.mjs +10 -0
- package/src/autonomous-mcp-tools.mjs +21 -6
- package/src/autonomous-output-contracts.mjs +18 -2
- package/src/autonomous-planner-contracts.mjs +3 -0
- package/src/autonomous-planner.mjs +46 -6
- package/src/autonomous-policy.mjs +10 -2
- package/src/autonomous-runtime.mjs +116 -16
- package/src/autonomous-supervisor.mjs +1 -1
- package/src/evidence-publisher-r42.mjs +76 -0
- package/src/mcp-server.mjs +1 -1
- package/src/provider-circuit.mjs +4 -4
- package/src/version.mjs +1 -1
- package/test/agent-eval-r42.test.mjs +39 -0
- package/test/agent-eval-runner-r42.test.mjs +61 -0
- package/test/agent-governance-r42.test.mjs +77 -0
- package/test/autonomous-r34-e2e.test.mjs +2 -1
- package/test/cli-entrypoint.test.mjs +1 -1
- package/test/core.test.mjs +1 -1
- package/test/evidence-publisher-r42.test.mjs +53 -0
- package/test/human-clarification-r42.test.mjs +53 -0
- package/test/provider-responses-r42.test.mjs +90 -0
- package/test/r33-closeout-regression.test.mjs +27 -12
- package/test/r33-finalization.test.mjs +3 -3
- package/test/r42-finalization.test.mjs +38 -0
- package/test/release-version.test.mjs +13 -13
- package/test/task-contract-r42.test.mjs +41 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://deadbyte.local/schemas/task-contract-v1.json",
|
|
4
|
+
"title": "DEADBYTE Task Contract v1",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema",
|
|
9
|
+
"scope",
|
|
10
|
+
"non_goals",
|
|
11
|
+
"constraints",
|
|
12
|
+
"evidence_requirements",
|
|
13
|
+
"risk_level",
|
|
14
|
+
"clarification_policy",
|
|
15
|
+
"project_default",
|
|
16
|
+
"risk_minimum",
|
|
17
|
+
"explicit_override",
|
|
18
|
+
"effective_rigor"
|
|
19
|
+
],
|
|
20
|
+
"properties": {
|
|
21
|
+
"schema": { "const": "deadbyte.task-contract.v1" },
|
|
22
|
+
"scope": { "type": "array", "maxItems": 32, "items": { "type": "string", "minLength": 1, "maxLength": 512 } },
|
|
23
|
+
"non_goals": { "type": "array", "maxItems": 24, "items": { "type": "string", "minLength": 1, "maxLength": 512 } },
|
|
24
|
+
"constraints": { "type": "array", "maxItems": 32, "items": { "type": "string", "minLength": 1, "maxLength": 512 } },
|
|
25
|
+
"evidence_requirements": { "type": "array", "maxItems": 32, "items": { "type": "string", "minLength": 1, "maxLength": 512 } },
|
|
26
|
+
"risk_level": { "enum": ["low", "medium", "high"] },
|
|
27
|
+
"clarification_policy": { "enum": ["ask_when_blocked", "fail_closed"] },
|
|
28
|
+
"project_default": { "enum": ["lightweight", "structured", "agentic"] },
|
|
29
|
+
"risk_minimum": { "enum": ["lightweight", "structured", "agentic"] },
|
|
30
|
+
"explicit_override": { "type": ["string", "null"], "enum": ["lightweight", "structured", "agentic", null] },
|
|
31
|
+
"effective_rigor": { "enum": ["lightweight", "structured", "agentic"] }
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deadbyte-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Authenticated MCP
|
|
6
|
+
"description": "Authenticated MCP agentic runtime with identity-bound task contracts, typed human clarification, bounded model providers, signed audit chains, immutable release slots, and separately revocable machine authority.",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22"
|
|
9
9
|
},
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
"manifest:verify": "node scripts/release-manifest.mjs verify",
|
|
14
14
|
"r41:parent:verify": "node scripts/verify-r41-parent.mjs",
|
|
15
15
|
"r41:memory:verify": "node scripts/verify-memory-r41.mjs",
|
|
16
|
+
"r42:parent:verify": "node scripts/verify-r42-parent.mjs",
|
|
17
|
+
"r42:eval": "node scripts/agent-eval-r42.mjs",
|
|
16
18
|
"self-update:runtime": "node scripts/runtime-self-update.mjs",
|
|
17
|
-
"self-update:deferred": "node scripts/deferred-slot-operation-
|
|
18
|
-
"release:parity": "node scripts/release-parity-
|
|
19
|
-
"release:final:write": "node scripts/final-closure-
|
|
20
|
-
"release:final:verify": "node scripts/final-closure-verify-
|
|
19
|
+
"self-update:deferred": "node scripts/deferred-slot-operation-r42.mjs",
|
|
20
|
+
"release:parity": "node scripts/release-parity-r42.mjs",
|
|
21
|
+
"release:final:write": "node scripts/final-closure-r42.mjs",
|
|
22
|
+
"release:final:verify": "node scripts/final-closure-verify-r42.mjs",
|
|
21
23
|
"proof": "node src/proof-cli.mjs workspaces/demo input.txt",
|
|
22
24
|
"verify": "node src/verifier-cli.mjs workspaces/demo evidence/latest.json",
|
|
23
25
|
"trust:init": "node src/trust-init.mjs",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"contained:run": "node src/contained-cli.mjs workspaces/demo input.txt",
|
|
41
43
|
"contained:smoke": "node src/contained-smoke.mjs",
|
|
42
44
|
"mcp:contained:smoke": "node src/mcp-contained-smoke-client.mjs",
|
|
43
|
-
"gate:windows": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-windows-
|
|
45
|
+
"gate:windows": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-windows-r42.ps1",
|
|
44
46
|
"authority:smoke": "node src/authority-smoke.mjs",
|
|
45
47
|
"mcp:remote:smoke": "node src/remote-mcp-smoke-client.mjs",
|
|
46
48
|
"mcp:host:smoke": "node src/mcp-host-smoke-client.mjs",
|
|
@@ -39,7 +39,7 @@ deadbyte-process-host.cpp
|
|
|
39
39
|
exit_code=0
|
|
40
40
|
==== probe-dependencies ====
|
|
41
41
|
|
|
42
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
42
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\containment-probe.exe
|
|
43
43
|
|
|
44
44
|
File Type: EXECUTABLE IMAGE
|
|
45
45
|
|
|
@@ -59,7 +59,7 @@ File Type: EXECUTABLE IMAGE
|
|
|
59
59
|
exit_code=0
|
|
60
60
|
==== contained-launcher-dependencies ====
|
|
61
61
|
|
|
62
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
62
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\deadbyte-exec.exe
|
|
63
63
|
|
|
64
64
|
File Type: EXECUTABLE IMAGE
|
|
65
65
|
|
|
@@ -83,7 +83,7 @@ File Type: EXECUTABLE IMAGE
|
|
|
83
83
|
exit_code=0
|
|
84
84
|
==== contained-worker-dependencies ====
|
|
85
85
|
|
|
86
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
86
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\contained-transform-worker.exe
|
|
87
87
|
|
|
88
88
|
File Type: EXECUTABLE IMAGE
|
|
89
89
|
|
|
@@ -104,7 +104,7 @@ File Type: EXECUTABLE IMAGE
|
|
|
104
104
|
exit_code=0
|
|
105
105
|
==== contained-reverse-worker-dependencies ====
|
|
106
106
|
|
|
107
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
107
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\contained-reverse-worker.exe
|
|
108
108
|
|
|
109
109
|
File Type: EXECUTABLE IMAGE
|
|
110
110
|
|
|
@@ -125,7 +125,7 @@ File Type: EXECUTABLE IMAGE
|
|
|
125
125
|
exit_code=0
|
|
126
126
|
==== named-tunnel-host-dependencies ====
|
|
127
127
|
|
|
128
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
128
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\deadbyte-tunnel-host.exe
|
|
129
129
|
|
|
130
130
|
File Type: EXECUTABLE IMAGE
|
|
131
131
|
|
|
@@ -144,7 +144,7 @@ File Type: EXECUTABLE IMAGE
|
|
|
144
144
|
exit_code=0
|
|
145
145
|
==== process-host-dependencies ====
|
|
146
146
|
|
|
147
|
-
Dump of file D:\Projects\deadbyte-mcp-
|
|
147
|
+
Dump of file D:\Projects\deadbyte-mcp\development\deadbyte-mcp-r42-agentic-dev\bin\deadbyte-process-host.exe
|
|
148
148
|
|
|
149
149
|
File Type: EXECUTABLE IMAGE
|
|
150
150
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { access, readFile } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { canonicalJson } from '../src/canonical-json.mjs';
|
|
7
|
+
import { requestProviderDecision } from '../src/autonomous-planner.mjs';
|
|
8
|
+
import { runAgentEvalSuiteR42, readAndVerifyR42EvalEvidence } from '../src/agent-eval-runner-r42.mjs';
|
|
9
|
+
|
|
10
|
+
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const root=path.resolve(here,'..');
|
|
12
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
13
|
+
const suiteFile=path.join(root,'harness','r42-agent-evals.json');
|
|
14
|
+
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
15
|
+
const suite=JSON.parse(await readFile(suiteFile,'utf8'));
|
|
16
|
+
const suiteSha=sha(Buffer.from(canonicalJson(suite),'utf8'));
|
|
17
|
+
const manifestBytes=await readFile(path.join(root,'MANIFEST.SHA256'));
|
|
18
|
+
const manifestSha=sha(manifestBytes);
|
|
19
|
+
const evidenceRoot=path.join(stateRoot,'evidence','release','r42-agent-evals');
|
|
20
|
+
const evidenceId=`r42-${manifestSha.slice(0,16)}-${suiteSha.slice(0,16)}`;
|
|
21
|
+
const existing=path.join(evidenceRoot,'agent_eval',`${evidenceId}.json`);
|
|
22
|
+
|
|
23
|
+
try{
|
|
24
|
+
await access(existing);
|
|
25
|
+
const verified=await readAndVerifyR42EvalEvidence(existing,{subjectManifestSha256:manifestSha,suiteSha256:suiteSha});
|
|
26
|
+
console.log(JSON.stringify({status:'passed',source:'existing',path:existing,evidence_sha256:verified.evidence_sha256,
|
|
27
|
+
manifest_sha256:manifestSha,suite_sha256:suiteSha,case_count:verified.payload.case_count}));
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}catch(error){
|
|
30
|
+
if(error?.code!=='ENOENT')throw error;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const apiKeyEnv=process.env.DEADBYTE_R42_EVAL_API_KEY_ENV||'OPENAI_API_KEY';
|
|
34
|
+
if(typeof process.env[apiKeyEnv]!=='string'||process.env[apiKeyEnv].length<1){
|
|
35
|
+
throw new Error(`R42 model-backed eval requires credential env '${apiKeyEnv}'`);
|
|
36
|
+
}
|
|
37
|
+
const planner={backend:'openai_responses',endpoint:process.env.DEADBYTE_R42_EVAL_ENDPOINT||'https://api.openai.com/v1/responses',
|
|
38
|
+
model:process.env.DEADBYTE_R42_EVAL_MODEL||'gpt-5',api_key_env:apiKeyEnv,max_tokens:4096,
|
|
39
|
+
reasoning_effort:process.env.DEADBYTE_R42_EVAL_REASONING||'high',store:false,timeout_ms:120000,max_response_bytes:1048576};
|
|
40
|
+
const requestModel=async({prompt})=>{
|
|
41
|
+
const response=await requestProviderDecision({planner},prompt);
|
|
42
|
+
return {...response,raw_response_sha256:sha(Buffer.from(response.raw_text,'utf8'))};
|
|
43
|
+
};
|
|
44
|
+
const run=await runAgentEvalSuiteR42({suite,subjectManifestSha256:manifestSha,requestModel,evidenceRoot});
|
|
45
|
+
console.log(JSON.stringify({status:'passed',source:'live',path:run.publication.path,evidence_sha256:run.publication.evidence_sha256,
|
|
46
|
+
manifest_sha256:manifestSha,suite_sha256:suiteSha,case_count:run.payload.case_count}));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createHash, createPublicKey, randomBytes } from 'node:crypto';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { mkdir, readFile, realpath, writeFile } from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { parseActivePointer } from '../src/release-slot.mjs';
|
|
8
|
+
import { loadPowerShellDataFile, runSlotUpdateCli, verifySlotUpdateEnvelope } from '../src/runtime-update.mjs';
|
|
9
|
+
|
|
10
|
+
const HEX64=/^[0-9a-f]{64}$/;
|
|
11
|
+
const RECEIPT_ID=/^r27-[A-Za-z0-9-]+$/;
|
|
12
|
+
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const packageRoot=path.resolve(here,'..');
|
|
14
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
15
|
+
const evidenceRoot=path.join(stateRoot,'evidence','deferred-slot-operations');
|
|
16
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
17
|
+
const atomicJson=async(file,value)=>{
|
|
18
|
+
await mkdir(path.dirname(file),{recursive:true});
|
|
19
|
+
const temp=`${file}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
|
|
20
|
+
await writeFile(temp,`${JSON.stringify(value,null,2)}\n`,{flag:'wx'});
|
|
21
|
+
await import('node:fs/promises').then(fs=>fs.rename(temp,file));
|
|
22
|
+
};
|
|
23
|
+
function activationArgs(manifestSha){
|
|
24
|
+
if(!HEX64.test(manifestSha??'')) throw new Error('activate requires one lowercase manifest SHA-256');
|
|
25
|
+
return ['--stage',packageRoot,'--development-root',packageRoot,'--expected-version','0.14.0',
|
|
26
|
+
'--expected-manifest',manifestSha,'--process-policy',path.join(packageRoot,'controller','deadbyte-process-policy.json'),
|
|
27
|
+
'--process-policy-sha256',null,'--desktop-policy',path.join(packageRoot,'controller','deadbyte-desktop-policy.json'),
|
|
28
|
+
'--desktop-policy-sha256',null,'--semantic-lsp-config',path.join(packageRoot,'controller','deadbyte-semantic-lsp-config.json'),
|
|
29
|
+
'--semantic-lsp-config-sha256',null,'--enable-machine-fs','--enable-observation','--enable-desktop','--enable-autonomous-supervisor'];
|
|
30
|
+
}
|
|
31
|
+
async function bridgeBootstrapArgs(explicitBridgeRoot=null,explicitBridgeSha256=null){
|
|
32
|
+
const hasRoot=typeof explicitBridgeRoot==='string'&&explicitBridgeRoot.length>0;
|
|
33
|
+
const hasSha=typeof explicitBridgeSha256==='string'&&explicitBridgeSha256.length>0;
|
|
34
|
+
if(hasRoot!==hasSha) throw new Error('bridge override requires exact root + SHA pair');
|
|
35
|
+
let bridgeRootRaw,expectedSha256=null;
|
|
36
|
+
if(hasRoot){
|
|
37
|
+
if(!path.isAbsolute(explicitBridgeRoot)||!HEX64.test(explicitBridgeSha256)) throw new Error('bridge override requires exact root + SHA pair');
|
|
38
|
+
bridgeRootRaw=explicitBridgeRoot;expectedSha256=explicitBridgeSha256;
|
|
39
|
+
}else{
|
|
40
|
+
const pointer=parseActivePointer(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
|
|
41
|
+
const config=await loadPowerShellDataFile(pointer.config_path);
|
|
42
|
+
bridgeRootRaw=config?.Bridge?.WorkingDirectory;
|
|
43
|
+
if(typeof bridgeRootRaw!=='string'||!path.isAbsolute(bridgeRootRaw)) throw new Error('active controller Bridge.WorkingDirectory must be absolute');
|
|
44
|
+
}
|
|
45
|
+
const bridgeRoot=await realpath(path.resolve(bridgeRootRaw));
|
|
46
|
+
const packageFile=path.join(bridgeRoot,'package.json');
|
|
47
|
+
const bridgeScript=path.join(bridgeRoot,'src','bridge.mjs');
|
|
48
|
+
const pkg=JSON.parse(await readFile(packageFile,'utf8'));
|
|
49
|
+
if(pkg?.name!=='deadbyte-chatgpt-bridge') throw new Error('active Bridge package identity mismatch');
|
|
50
|
+
const scriptSha256=sha256(await readFile(bridgeScript));
|
|
51
|
+
if(expectedSha256&&scriptSha256!==expectedSha256) throw new Error('bridge override SHA-256 mismatch');
|
|
52
|
+
return ['--bridge-root',bridgeRoot,'--bridge-script-sha256',scriptSha256];
|
|
53
|
+
}
|
|
54
|
+
async function rollbackArgs(receiptPath){
|
|
55
|
+
const resolved=await realpath(path.resolve(receiptPath));
|
|
56
|
+
const allowed=path.join(stateRoot,'evidence','updates')+path.sep;
|
|
57
|
+
if(!resolved.startsWith(allowed)||path.basename(resolved).toLowerCase()!=='receipt.json'||!RECEIPT_ID.test(path.basename(path.dirname(resolved)))) {
|
|
58
|
+
throw new Error('rollback receipt must be one signed activation receipt under the update evidence store');
|
|
59
|
+
}
|
|
60
|
+
const envelope=JSON.parse(await readFile(resolved,'utf8'));
|
|
61
|
+
const publicKey=createPublicKey(await readFile(path.join(stateRoot,'trust','ed25519-public.pem')));
|
|
62
|
+
if(!verifySlotUpdateEnvelope(envelope,publicKey)||envelope.body?.rollback_performed!==false) throw new Error('rollback activation receipt verification failed');
|
|
63
|
+
const pointer=parseActivePointer(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
|
|
64
|
+
if(pointer.release_id!==envelope.body?.active_pointer?.release_id||pointer.generation_root!==envelope.body?.active_pointer?.generation_root) {
|
|
65
|
+
throw new Error('rollback receipt does not identify the active release generation');
|
|
66
|
+
}
|
|
67
|
+
return ['--rollback-receipt',resolved];
|
|
68
|
+
}
|
|
69
|
+
async function normalizedArgs(mode,value,{explicitBridgeRoot=null,explicitBridgeSha256=null}={}){
|
|
70
|
+
if(mode==='activate'){
|
|
71
|
+
const args=activationArgs(value);
|
|
72
|
+
args[args.indexOf('--process-policy-sha256')+1]=sha256(await readFile(path.join(packageRoot,'controller','deadbyte-process-policy.json')));
|
|
73
|
+
args[args.indexOf('--desktop-policy-sha256')+1]=sha256(await readFile(path.join(packageRoot,'controller','deadbyte-desktop-policy.json')));
|
|
74
|
+
args[args.indexOf('--semantic-lsp-config-sha256')+1]=sha256(await readFile(path.join(packageRoot,'controller','deadbyte-semantic-lsp-config.json')));
|
|
75
|
+
args.push(...await bridgeBootstrapArgs(explicitBridgeRoot,explicitBridgeSha256));
|
|
76
|
+
return args;
|
|
77
|
+
}
|
|
78
|
+
if(mode==='rollback'){
|
|
79
|
+
if(explicitBridgeRoot||explicitBridgeSha256) throw new Error('rollback does not accept bridge override');
|
|
80
|
+
return rollbackArgs(value);
|
|
81
|
+
}
|
|
82
|
+
throw new Error("operation must be exactly 'activate' or 'rollback'");
|
|
83
|
+
}
|
|
84
|
+
const rawArgs=process.argv.slice(2);
|
|
85
|
+
const mode=rawArgs[0],value=rawArgs[1];
|
|
86
|
+
if(!value||!['activate','rollback'].includes(mode)) throw new Error('usage: deferred-slot-operation-r42.mjs <activate manifest_sha256|rollback activation_receipt> [--bridge-root ABS --bridge-script-sha256 HEX64]');
|
|
87
|
+
let cursor=2,explicitBridgeRoot=null,explicitBridgeSha256=null;
|
|
88
|
+
if(rawArgs[cursor]==='--bridge-root'){
|
|
89
|
+
explicitBridgeRoot=rawArgs[cursor+1]??null;
|
|
90
|
+
if(rawArgs[cursor+2]!=='--bridge-script-sha256') throw new Error('bridge override requires exact root + SHA pair');
|
|
91
|
+
explicitBridgeSha256=rawArgs[cursor+3]??null;cursor+=4;
|
|
92
|
+
}
|
|
93
|
+
let workerFlag=null,operationIdArg=null;
|
|
94
|
+
if(rawArgs[cursor]==='--worker'){workerFlag='--worker';operationIdArg=rawArgs[cursor+1]??null;cursor+=2;}
|
|
95
|
+
if(cursor!==rawArgs.length) throw new Error('deferred slot operation arguments invalid');
|
|
96
|
+
if((explicitBridgeRoot===null)!==(explicitBridgeSha256===null)) throw new Error('bridge override requires exact root + SHA pair');
|
|
97
|
+
if(mode==='rollback'&&(explicitBridgeRoot||explicitBridgeSha256)) throw new Error('rollback does not accept bridge override');
|
|
98
|
+
if(workerFlag==='--worker'){
|
|
99
|
+
if(!/^[0-9a-f]{32}$/.test(operationIdArg??'')) throw new Error('deferred worker operation id invalid');
|
|
100
|
+
const statePath=path.join(evidenceRoot,`${operationIdArg}.json`);
|
|
101
|
+
await new Promise(resolve=>setTimeout(resolve,4000));
|
|
102
|
+
await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationIdArg,mode,state:'running',started_at_utc:new Date().toISOString(),bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
|
|
103
|
+
try{
|
|
104
|
+
const args=await normalizedArgs(mode,value,{explicitBridgeRoot,explicitBridgeSha256});
|
|
105
|
+
const result=await runSlotUpdateCli(args,{stateRoot});
|
|
106
|
+
await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationIdArg,mode,state:'completed',
|
|
107
|
+
completed_at_utc:new Date().toISOString(),receipt_path:result.receipt_path,receipt_sha256:result.receipt_sha256,
|
|
108
|
+
active_release:result.pointer.release_id,generation_root:result.pointer.generation_root,bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
|
|
109
|
+
}catch(error){
|
|
110
|
+
await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationIdArg,mode,state:'failed',
|
|
111
|
+
completed_at_utc:new Date().toISOString(),error:String(error?.message??error),bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
|
|
112
|
+
process.exitCode=1;
|
|
113
|
+
}
|
|
114
|
+
}else{
|
|
115
|
+
const operationId=randomBytes(16).toString('hex');
|
|
116
|
+
const statePath=path.join(evidenceRoot,`${operationId}.json`);
|
|
117
|
+
await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationId,mode,state:'scheduled',scheduled_at_utc:new Date().toISOString(),bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
|
|
118
|
+
const workerArgs=[fileURLToPath(import.meta.url),mode,value];
|
|
119
|
+
if(explicitBridgeRoot) workerArgs.push('--bridge-root',explicitBridgeRoot,'--bridge-script-sha256',explicitBridgeSha256);
|
|
120
|
+
workerArgs.push('--worker',operationId);
|
|
121
|
+
const child=spawn(process.execPath,workerArgs,{
|
|
122
|
+
cwd:packageRoot,detached:true,stdio:'ignore',windowsHide:true,env:{...process.env,DEADBYTE_STATE_ROOT:stateRoot}
|
|
123
|
+
});
|
|
124
|
+
child.unref();
|
|
125
|
+
console.log(JSON.stringify({status:'scheduled',operation_id:operationId,mode,state_path:statePath,execution_provider:'deadbyte_mcp',rdc_operation_count:0,bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256}));
|
|
126
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createHash, createPrivateKey, createPublicKey, sign as cryptoSign } from 'node:crypto';
|
|
2
|
+
import { lstat, mkdir, open, readFile, rename, rm } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { probeR40FullSurface } from '../src/r40-full-surface-probe.mjs';
|
|
7
|
+
import { probeR40CompactDisarmed } from '../src/r40-compact-disarmed-probe.mjs';
|
|
8
|
+
import {
|
|
9
|
+
validateParityEvidence,
|
|
10
|
+
R42_PREDECESSOR_RELEASE_ID,
|
|
11
|
+
R42_PREDECESSOR_MANIFEST
|
|
12
|
+
} from './release-parity-r42.mjs';
|
|
13
|
+
|
|
14
|
+
const DOMAIN=Buffer.from('DEADBYTE-R42-FINAL-CLOSURE-V1\0','utf8');
|
|
15
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
16
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
17
|
+
const canonical=value=>Array.isArray(value)?value.map(canonical):value&&typeof value==='object'
|
|
18
|
+
?Object.fromEntries(Object.keys(value).sort().map(key=>[key,canonical(value[key])])):value;
|
|
19
|
+
const canonicalJson=value=>JSON.stringify(canonical(value));
|
|
20
|
+
function insist(ok,msg){if(!ok) throw new Error(msg);}
|
|
21
|
+
function samePath(a,b){return path.resolve(String(a)).toLowerCase()===path.resolve(String(b)).toLowerCase();}
|
|
22
|
+
async function fileEvidence(file){const abs=path.resolve(file),bytes=await readFile(abs);return {path:abs,sha256:sha256(bytes)};}
|
|
23
|
+
async function publicUrl(){
|
|
24
|
+
const value=(await readFile(path.join(stateRoot,'bridge','mcp-url.txt'),'utf8')).trim();
|
|
25
|
+
const url=new URL(value);insist(url.protocol==='https:','final closure requires HTTPS public endpoint');return value;
|
|
26
|
+
}
|
|
27
|
+
async function grantAbsence(){
|
|
28
|
+
const out={};
|
|
29
|
+
for(const name of ['process-grant.json','coding-grant.json','autonomous-grant.json','desktop-grant.json','host-grant.json']){
|
|
30
|
+
let absent=false;try{await lstat(path.join(stateRoot,'runtime',name));}catch(error){if(error?.code==='ENOENT') absent=true;else throw error;}
|
|
31
|
+
insist(absent,`authority grant still present: ${name}`);out[name]=true;
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
async function atomicCreate(file,bytes){
|
|
36
|
+
await mkdir(path.dirname(file),{recursive:true});
|
|
37
|
+
const temp=`${file}.tmp-${process.pid}-${Math.random().toString(16).slice(2)}`;
|
|
38
|
+
const handle=await open(temp,'wx');
|
|
39
|
+
try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}
|
|
40
|
+
try{await rename(temp,file);}catch(error){await rm(temp,{force:true}).catch(()=>{});throw error;}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function writeFinalClosure({parityPath,activationPath,windowsGatePath}){
|
|
44
|
+
const pointer=JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
|
|
45
|
+
insist(pointer.version==='0.14.0','final closure requires V0.14.0 active release');
|
|
46
|
+
insist(pointer.release_id===`v${pointer.version}-${pointer.manifest_sha256.slice(0,16)}`,'final closure release id/content address mismatch');
|
|
47
|
+
|
|
48
|
+
const parity=JSON.parse(await readFile(path.resolve(parityPath),'utf8'));
|
|
49
|
+
insist(parity.schema==='deadbyte.r42-parity.v1','R40 parity schema mismatch at final closure');
|
|
50
|
+
validateParityEvidence(parity);
|
|
51
|
+
insist(parity.candidate?.release_id===pointer.release_id&&parity.candidate?.manifest_sha256===pointer.manifest_sha256,'parity candidate/current release mismatch');
|
|
52
|
+
insist(parity.successor?.release_id===pointer.release_id&&parity.successor?.manifest_sha256===pointer.manifest_sha256,'parity successor/current release mismatch');
|
|
53
|
+
insist(parity.predecessor?.release_id===R42_PREDECESSOR_RELEASE_ID&&parity.predecessor?.manifest_sha256===R42_PREDECESSOR_MANIFEST,'parity predecessor identity mismatch');
|
|
54
|
+
insist(parity.rollback?.receipt_path&&parity.restore?.receipt_path,'parity rollback/restore receipt paths missing');
|
|
55
|
+
insist(parity.immutable_slot?.protected===true,'parity immutable-slot proof missing');
|
|
56
|
+
insist(samePath(parity.immutable_slot.release_root,pointer.release_root),'parity immutable release root mismatch');
|
|
57
|
+
insist(!samePath(parity.immutable_slot.development_root,pointer.release_root),'development_root must differ from immutable release_root');
|
|
58
|
+
|
|
59
|
+
const windowsGate=JSON.parse(await readFile(path.resolve(windowsGatePath),'utf8'));
|
|
60
|
+
insist(windowsGate.schema==='deadbyte.r42-windows-gate.v1'&&windowsGate.status==='passed'&&windowsGate.exit_code===0,'R40 Windows gate evidence invalid');
|
|
61
|
+
insist(windowsGate.version==='0.14.0'&&windowsGate.manifest_sha256===pointer.manifest_sha256,'R40 Windows gate/current release mismatch');
|
|
62
|
+
insist(windowsGate.marker==='DEADBYTE V0.14.0 / R42 WINDOWS BATCH GATE: PASS','R40 Windows gate marker mismatch');
|
|
63
|
+
|
|
64
|
+
const localFull=await probeR40FullSurface({packageRoot:pointer.release_root,generationRoot:pointer.generation_root,stateRoot});
|
|
65
|
+
insist(localFull.status==='passed'&&localFull.tool_count===80&&localFull.strict_output_schemas===true,'final local full 80-tool proof failed');
|
|
66
|
+
const compact=await probeR40CompactDisarmed(await publicUrl());
|
|
67
|
+
insist(compact.status==='passed'&&compact.tool_count===42&&compact.capability_closure===true,'final public compact capability closure failed');
|
|
68
|
+
insist(compact.coding_armed===false&&compact.autonomous_armed===false&&compact.desktop_armed===false,'final public compact authority is not DISARMED');
|
|
69
|
+
insist(compact.desktop_observation_receipt_verified===true&&compact.desktop_grounding_receipt_verified===true,'final public Desktop read-only proof missing');
|
|
70
|
+
insist(compact.release_id===pointer.release_id&&compact.release_manifest_sha256===pointer.manifest_sha256,'final public compact release binding mismatch');
|
|
71
|
+
insist(compact.machine_status?.release_id===pointer.release_id&&compact.machine_status?.release_manifest_sha256===pointer.manifest_sha256,'final machine status/current release mismatch');
|
|
72
|
+
insist(compact.machine_ping?.nonce===compact.nonce,'final machine ping nonce mismatch');
|
|
73
|
+
|
|
74
|
+
const evidence={
|
|
75
|
+
parity:await fileEvidence(parityPath),activation:await fileEvidence(activationPath),
|
|
76
|
+
rollback:await fileEvidence(parity.rollback.receipt_path),restore:await fileEvidence(parity.restore.receipt_path),
|
|
77
|
+
windows_gate:await fileEvidence(windowsGatePath),model_eval:await fileEvidence(parity.model_eval.path)
|
|
78
|
+
};
|
|
79
|
+
const body={
|
|
80
|
+
schema:'deadbyte.r42-final-closure.v1',version:'0.14.0',release_label:'R42 AGENTIC GOVERNANCE BASELINE',
|
|
81
|
+
completed_at_utc:new Date().toISOString(),active_pointer:pointer,
|
|
82
|
+
predecessor:{release_id:R42_PREDECESSOR_RELEASE_ID,version:'0.13.0',manifest_sha256:R42_PREDECESSOR_MANIFEST},
|
|
83
|
+
immutable_slot:{protected:true,release_root:path.resolve(pointer.release_root),development_root:path.resolve(parity.immutable_slot.development_root)},
|
|
84
|
+
surfaces:{
|
|
85
|
+
local_full:{status:localFull.status,profile:localFull.profile,tool_count:localFull.tool_count,catalog_sha256:localFull.catalog_sha256,strict_output_schemas:localFull.strict_output_schemas,protocol_revision:localFull.protocol_revision},
|
|
86
|
+
public_compact:{status:compact.status,profile:compact.profile,tool_count:compact.tool_count,catalog_sha256:compact.catalog_sha256,strict_output_schemas:compact.strict_output_schemas,ledger_sha256:compact.ledger_sha256,capability_count:compact.capability_count,production_non_host_capabilities:compact.production_non_host_capabilities,capability_closure:compact.capability_closure,coding_armed:compact.coding_armed,autonomous_armed:compact.autonomous_armed,desktop_armed:compact.desktop_armed,desktop_observation_receipt_verified:compact.desktop_observation_receipt_verified,desktop_grounding_receipt_verified:compact.desktop_grounding_receipt_verified,protocol_revision:compact.protocol_revision},
|
|
87
|
+
deterministic_memory:parity.deterministic_memory,
|
|
88
|
+
model_eval:parity.model_eval
|
|
89
|
+
},
|
|
90
|
+
evidence,
|
|
91
|
+
machine:{status:compact.machine_status,ping:compact.machine_ping,nonce:compact.nonce},
|
|
92
|
+
authority:{all_disarmed:true,grants_absent:await grantAbsence()}
|
|
93
|
+
};
|
|
94
|
+
const privateKey=createPrivateKey(await readFile(path.join(stateRoot,'trust','ed25519-private.pem')));
|
|
95
|
+
const publicKey=createPublicKey(privateKey);
|
|
96
|
+
insist(privateKey.asymmetricKeyType==='ed25519'&&publicKey.asymmetricKeyType==='ed25519','closure signing key must be Ed25519');
|
|
97
|
+
const keyId=sha256(Buffer.from(publicKey.export({type:'spki',format:'der'})));
|
|
98
|
+
const bodyBytes=Buffer.from(canonicalJson(body),'utf8');
|
|
99
|
+
const signature=cryptoSign(null,Buffer.concat([DOMAIN,bodyBytes]),privateKey);
|
|
100
|
+
const envelope={body,body_sha256:sha256(bodyBytes),attestation:{algorithm:'ed25519',domain:'DEADBYTE-R42-FINAL-CLOSURE-V1',key_id:keyId,signature_base64:signature.toString('base64')}};
|
|
101
|
+
envelope.closure_sha256=sha256(Buffer.from(canonicalJson(envelope),'utf8'));
|
|
102
|
+
const dir=path.join(stateRoot,'evidence','release');
|
|
103
|
+
const file=path.join(dir,`r42-final-${pointer.manifest_sha256.slice(0,16)}.json`);
|
|
104
|
+
const bytes=Buffer.from(`${JSON.stringify(envelope,null,2)}\n`,'utf8');
|
|
105
|
+
await atomicCreate(file,bytes);
|
|
106
|
+
return {status:'written',path:file,sha256:sha256(bytes),closure_sha256:envelope.closure_sha256,release_id:pointer.release_id};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
|
|
110
|
+
if(invoked){
|
|
111
|
+
const [parityPath,activationPath,windowsGatePath]=process.argv.slice(2);
|
|
112
|
+
if(!parityPath||!activationPath||!windowsGatePath) throw new Error('usage: node scripts/final-closure-r42.mjs <parity.json> <activation-receipt.json> <windows-gate.json>');
|
|
113
|
+
writeFinalClosure({parityPath,activationPath,windowsGatePath})
|
|
114
|
+
.then(result=>console.log(JSON.stringify(result,null,2)))
|
|
115
|
+
.catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|
|
116
|
+
}
|