Download src/db/batch-memory-continue-record.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.41 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/db/batch-memory-continue-record.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/db/batch-memory-continue-record.js
-
curl -L -o batch-memory-continue-record.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/db/batch-memory-continue-record.js
3.41 kB
| // ์ ์์ continue๊ฐ ์๋ ์์๋ค๊ณ ๋ง๋ค์ง ์๋๋ค. ์๋ ํยท์ ๋ ฅยท๊ด์ธก์ ๋ณ๋ ์น์ธ ์์์ฆ์ ๋ณด์กดํ๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/batch-memory-continue.md v1.0.0 | |
| const{hash,hex}=require('../services/bong-browser-resolution'),{same}=require('./batch-recovery-record'); | |
| const fail=()=>require('./batch-checkpoint-record').fail(); | |
| function resolved(c,key){return Object.values(c.recoveries||{}).find(g=>g.memoryContinuations?.[key])?.memoryContinuations[key]||null;} | |
| function validate(c,g,seen){ | |
| const map=g.memoryContinuations;if(map===undefined)return; | |
| if(!g.loopState||!map||typeof map!=='object'||Array.isArray(map)||!Object.keys(map).length||Object.keys(map).length>4096)fail(); | |
| if(g.originalTask?.id!==c.taskId||g.originalTask.project_id!==c.projectId||hash(require('../services/batch-admission').signature(g.originalTask))!==g.taskHash||require('../utils/batch-definition').fingerprint(g.originalTask)!==c.definitionHash)fail(); | |
| require('./batch-checkpoint-record').json(g.originalTask,16777216); | |
| const steps=require('./batch-checkpoint-record').stepsFor({steps:c.definition.steps}); | |
| for(const[key,r]of Object.entries(map)){ | |
| const e=c.entries[key],source=g.loopState.originalIterations.find(v=>v.iteration_number===e?.iteration),outputs=typeof source?.step_outputs==='string'?JSON.parse(source.step_outputs):source?.step_outputs; | |
| if(!e||e.status!=='failed'||e.attempt!==0||steps[e.stepIndex].on_failure!=='continue'||require('./batch-continued-record').uncertain(e.error)||c.continuations?.[key]||seen.has(key)||!g.entryKeys.includes(key) | |
| ||Object.keys(r).length!==7||Object.keys(r).some(k=>!['entryKey','originalEntryHash','output','outputHash','durationSource','source','consumers'].includes(k))||r.entryKey!==key||r.originalEntryHash!==hash(e)||r.outputHash!==hash(r.output)||r.durationSource!=='original_consumed_output' | |
| ||!r.output||Object.keys(r.output).length!==2||typeof r.output.error!=='string'||r.output.error.slice(0,2000)!==e.error.message||typeof r.output._duration!=='string'||!/^\d+\.\d{2}$/.test(r.output._duration)||!Number.isFinite(Number(r.output._duration)) | |
| ||Object.keys(r.source||{}).length!==3||r.source.kind!=='loop_iteration'||r.source.id!==source?.id||r.source.hash!==hash(source)||!same(outputs?.[e.stepId],r.output)||!Array.isArray(r.consumers)||!r.consumers.length||r.consumers.length>2)fail(); | |
| require('./batch-checkpoint-record').json(r.output);seen.add(key); | |
| for(const v of r.consumers){ | |
| if(v.kind==='entry_inputs'){const next=c.entries[v.key];if(Object.keys(v).length!==5||Object.keys(v).some(k=>!['kind','key','entryHash','inputsHash','configHash'].includes(k))||!next||next.iteration!==e.iteration||next.stepIndex!==e.stepIndex+1||!g.entryKeys.includes(v.key)||v.entryHash!==hash(next)||v.inputsHash!==next.inputsHash||v.configHash!==next.configHash||Date.parse(next.startedAt)<Date.parse(e.completedAt))fail();} | |
| else if(v.kind==='goal_observations'){const event=c.loopEvents?.[v.key];if(Object.keys(v).length!==5||Object.keys(v).some(k=>!['kind','key','eventHash','observationsHash','inputsHash'].includes(k))||event?.phase!=='evaluation_intent'||event.iteration!==e.iteration||!event.entryKeys.includes(key)||v.eventHash!==event.eventHash||!hex(v.observationsHash)||!hex(v.inputsHash)||event.revision>g.checkpointRevision)fail();} | |
| else fail(); | |
| } | |
| } | |
| } | |
| module.exports={resolved,validate}; | |