@tnunamak/dalan 0.9.8 → 0.9.11
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/CHANGELOG.md +8 -0
- package/bin/dot-acp-agent.mjs +145 -28
- package/bin/dot-worker.mjs +17 -4
- package/docs/design/target-architecture-v2.md +58 -2
- package/docs/design/target-architecture-v3.md +151 -0
- package/docs/local-agent-requester.md +52 -0
- package/docs/pull-workers.md +5 -1
- package/package.json +1 -1
- package/src/acp-bridge.mjs +23 -11
- package/src/as-files.mjs +6 -3
- package/src/cli-help.mjs +4 -2
- package/src/get-summary.mjs +5 -0
- package/src/local-attachment-authority.mjs +174 -0
- package/src/local-attachment-capture.mjs +136 -0
- package/src/local-attachment-cli.mjs +46 -0
- package/src/local-attachment-gateway.mjs +93 -0
- package/src/local-attachment-owner-verify.mjs +152 -0
- package/src/local-attachment-result.mjs +64 -0
- package/src/local-attachment-snapshot.mjs +142 -0
- package/src/mcp-stdio.mjs +189 -7
- package/src/patch-apply.mjs +28 -6
- package/src/publication-authority.mjs +1 -0
- package/src/pull-pacing.mjs +10 -0
- package/src/requester-local-context.mjs +113 -0
- package/src/server.mjs +53 -16
- package/src/store.mjs +199 -15
- package/src/tool-registry.mjs +15 -4
- package/src/work-recovery.mjs +143 -0
- package/src/worker-runs.mjs +25 -0
- package/src/workspace.mjs +17 -10
package/src/workspace.mjs
CHANGED
|
@@ -200,12 +200,13 @@ export function validateIntegrationPatch(dir,patch,assignment) {
|
|
|
200
200
|
}
|
|
201
201
|
return files;
|
|
202
202
|
}
|
|
203
|
-
function newFilePatchHint(file,scope) {
|
|
203
|
+
function newFilePatchHint(file,scope,implementation=false) {
|
|
204
204
|
const creatable = scope?.outputs?.has(file) === true;
|
|
205
|
-
|
|
205
|
+
const status=creatable?'creatable (listed in output_paths)':implementation?'within the writable implementation scope; a valid new-file hunk can create its parent directory':'not creatable (not listed in output_paths)';
|
|
206
|
+
return `${file}: ${status}; for an absent file use these headers: diff --git a/${file} b/${file}, new file mode 100644, --- /dev/null, +++ b/${file}`;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
function normalizeGrantedNewFiles(dir,patch,scope) {
|
|
209
|
+
function normalizeGrantedNewFiles(dir,patch,scope,implementation) {
|
|
209
210
|
return patch.split(/(?=^diff --git )/m).map(section=>{
|
|
210
211
|
const lines=section.split('\n');
|
|
211
212
|
const match=/^diff --git a\/(.+) b\/(.+)$/.exec(lines[0]);
|
|
@@ -224,19 +225,19 @@ function normalizeGrantedNewFiles(dir,patch,scope) {
|
|
|
224
225
|
if(scope?.outputs?.has(file)) throw new Error(`patch rejected: ${file} already exists; use an ordinary edit hunk for an existing file`);
|
|
225
226
|
return section; // an ordinary zero-context insertion into a tracked file
|
|
226
227
|
}
|
|
227
|
-
if(!scope?.outputs?.has(file)) throw new Error(`patch rejected: ${newFilePatchHint(file,scope)}`);
|
|
228
|
+
if(!scope?.outputs?.has(file)) throw new Error(`patch rejected: ${newFilePatchHint(file,scope,implementation)}`);
|
|
228
229
|
return [lines[0],'new file mode 100644','--- /dev/null',`+++ b/${file}`,...lines.slice(first)].join('\n');
|
|
229
230
|
}).join('');
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
function applyPatchToTree(dir,patch,scope=null) {
|
|
233
|
+
function applyPatchToTree(dir,patch,scope=null,implementation=false) {
|
|
233
234
|
if(Buffer.byteLength(patch)>262144) throw new Error('patch too large');
|
|
234
235
|
const files=patchPaths(patch);
|
|
235
236
|
for(const p of files) requireScope(p,scope);
|
|
236
237
|
for(const p of files) safePath(dir,p);
|
|
237
|
-
const normalized=normalizeGrantedNewFiles(dir,patch,scope);
|
|
238
|
+
const normalized=normalizeGrantedNewFiles(dir,patch,scope,implementation);
|
|
238
239
|
const check=spawnSync('git',['-C',dir,'apply','--check','-'],{input:normalized,encoding:'utf8',timeout:10000,env:gitEnv()});
|
|
239
|
-
if(check.status!==0) throw new Error(`patch rejected: ${(check.stderr||'').slice(0,200)} ${files.slice(0,3).map(file=>newFilePatchHint(file,scope)).join('; ')}`);
|
|
240
|
+
if(check.status!==0) throw new Error(`patch rejected: ${(check.stderr||'').slice(0,200)} ${files.slice(0,3).map(file=>newFilePatchHint(file,scope,implementation)).join('; ')}`);
|
|
240
241
|
const applied=spawnSync('git',['-C',dir,'apply','-'],{input:normalized,encoding:'utf8',timeout:10000,env:gitEnv()});
|
|
241
242
|
if(applied.status!==0) throw new Error(`patch apply failed: ${(applied.stderr||'').slice(0,200)}`);
|
|
242
243
|
for(const p of files) {const f=path.join(dir,p);if(fs.existsSync(f))safePath(dir,p,true);}
|
|
@@ -804,7 +805,7 @@ export class Workspace {
|
|
|
804
805
|
// patch with no error. Refuse it here instead. A tracked file under such a name is not new and is not refused (see restoreOutsideWritable).
|
|
805
806
|
const generatedNew=patchPaths(patch).filter(file=>isGenerated(file)&&!existsAtHead(dir,file));
|
|
806
807
|
if(generatedNew.length) throw coded('generated_path',`${generatedNew[0]} is a new file under a build-output directory. Files under node_modules/.venv/target/__pycache__ are treated as build output and are not included in the patch; choose another path. Nothing was applied. This affects only this action on ${requestId}.`);
|
|
807
|
-
const files=this.store.transaction(()=>{const current=this.store.get(requestId);this.store.assertClaim(requestId,claimId,subject,worker);if(current.status!=='claimed'||current.cancelled_at) throw closedWorkspace(current,requestId,claimId);const changed=applyPatchToTree(dir,patch,scopeOf(a.assignment));this.noteIgnoredWritten(requestId,dir,changed);return changed;});return {files,diff_sha256:this.diff(dir,input.base_sha).sha256}; }
|
|
808
|
+
const files=this.store.transaction(()=>{const current=this.store.get(requestId);this.store.assertClaim(requestId,claimId,subject,worker);if(current.status!=='claimed'||current.cancelled_at) throw closedWorkspace(current,requestId,claimId);const changed=applyPatchToTree(dir,patch,scopeOf(a.assignment),a.assignment.execution_scope==='implementation');this.noteIgnoredWritten(requestId,dir,changed);return changed;});return {files,diff_sha256:this.diff(dir,input.base_sha).sha256}; }
|
|
808
809
|
// Paths a patch wrote that git ignores are outside the candidate source (a check can still run them). They are listed, not refused,
|
|
809
810
|
// and kept beside the workspace (never inside it) until the next receipt carries them.
|
|
810
811
|
ignoredWrittenFile(requestId) { return path.join(worktrees,`${requestId}.ignored-written.json`); }
|
|
@@ -1031,7 +1032,10 @@ export class Workspace {
|
|
|
1031
1032
|
const repo=assignment.inputs[0].github_repo;
|
|
1032
1033
|
const declared=dir?availableChecks(repo,dir):this.availableChecksFor(assignment,worker);
|
|
1033
1034
|
if(execution!=='host') return {available_checks:declared,
|
|
1034
|
-
available_check_runnable:Object.fromEntries(declared.map(id=>[id,{runnable:false,reason:'host_execution_unavailable'}]))
|
|
1035
|
+
available_check_runnable:Object.fromEntries(declared.map(id=>[id,{runnable:false,reason:'host_execution_unavailable'}])),
|
|
1036
|
+
host_check_availability:{execution,cause:'job_execution_mode',
|
|
1037
|
+
worker_action:'If you can edit, return the workspace_result patch and say which tests ran.',
|
|
1038
|
+
owner_action:'Verify the sealed patch in an authorized checkout, or submit a new job with host execution.'}};
|
|
1035
1039
|
const namedRequested=assignment.execution_scope==='implementation'&&Array.isArray(assignment.checks)&&assignment.checks.length>0;
|
|
1036
1040
|
const defaultSpec=namedRequested?(dir?detectCheck(repo,dir):this.checkMetadataFor(assignment,worker)?.default):null;
|
|
1037
1041
|
const named=namedRequested&&defaultSpec?assignment.checks.flatMap((_,index)=>{
|
|
@@ -1063,7 +1067,10 @@ export class Workspace {
|
|
|
1063
1067
|
id,{runnable:!refusal,reason:refusal?(noHostCode??refusalCode(refusal)):null},
|
|
1064
1068
|
]));
|
|
1065
1069
|
return {available_checks:available,available_check_runnable,...(available.length?{available_check_details:details,check_guidance:CHECK_GUIDANCE}:{}),
|
|
1066
|
-
host_execution_available:runnable,host_execution_unavailable_reason:reason
|
|
1070
|
+
host_execution_available:runnable,host_execution_unavailable_reason:reason,
|
|
1071
|
+
host_check_availability:{execution,cause:runnable?'ready':noHost&&readinessRefusal&&!baseRefusal?'host_readiness':'check_policy_or_configuration',
|
|
1072
|
+
...(!runnable?{worker_action:'Return the patch and say which checks did not run.',
|
|
1073
|
+
owner_action:'Review the reported host readiness or check authorization before retrying; the job already requests host execution.'}:{})}};
|
|
1067
1074
|
} catch(error) {
|
|
1068
1075
|
if(!String(error?.message??'').includes('check metadata')) throw error;
|
|
1069
1076
|
if(execution==='host'&&assignment.execution_scope!=='implementation') throw error;
|