import"./DrKWWDpL.js";import{t as e}from"./DYP3EJMY.js";import"./CX8DOZuw2.js";import{w as t}from"./DsanjglN.js";import{t as n}from"./DTkg6Mnx.js";import{_ as r}from"./CvaH7m0y.js";import"./DOPTvi6T.js";import"./CG84LPq-.js";e(),Promise.resolve();async function i(e,n){let i=new Set,a=[],o=await e.$count(r);a.push(`${n}-${o+1}`),a.push(`${n}-v2`),a.push(`${n}-new`);let s=[];for(let c=0;c<a.length;c++){let l=a[c],u=0;for(;u<32;){if(i.has(l)){u++,l=`${l}-x`;continue}if(!await e.select().from(r).where(t(r.slug,l)).get()){s.push(l),i.add(l);break}i.add(l),u++,l=c===2?`${n}-alt-${u}`:`${l}-x`}s.length!==c+1&&s.push(`${n}-${o+c+100}`)}return s.slice(0,3)}async function a(e,t){return i(e,t)}n(`lifecycle:ivtr`),n(`worktree:audit`);function o(e){return e.type===`saga`}async function s(e,t){let n=await e.loadSingleTask(t);if(!n?.parentId)return[];let r=await e.loadSingleTask(n.parentId);return!r||!o(r)?[]:[r]}var c=[`implemented`,`testsPassed`,`qaPassed`,`cleanupDone`,`securityPassed`,`documented`];function l(e,t,n){let r=t.join(`,`);function i(t){return{atoms:[{kind:`note`,note:`saga-auto-close-via-completeTask:${e}:${t}`},{kind:`note`,note:`members:${r}`},{kind:`note`,note:`adr:ADR-073 §1.2 invariants I3+I5`}],capturedAt:n,capturedBy:`system:saga-auto-close`}}let a={};for(let e of c)a[e]=i(e);return{round:1,passed:!0,gates:{implemented:!0,testsPassed:!0,qaPassed:!0,cleanupDone:!0,securityPassed:!0,documented:!0},evidence:a,lastAgent:null,lastUpdated:n,failureLog:[],initializedAt:n}}export{s as n,a as r,l as t};