@skyramp/testbot-core 0.13.0-v3.272 → 0.13.0-v3.274

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/dist/VERSION.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.13.0-v3.272","commit":"5aef970fa2dc6d9d1dfda4ef7e4fa06da2d3b3ea"}
1
+ {"version":"0.13.0-v3.274","commit":"8cd483b602f01d717e4d33b02bb0e709d556f24b"}
package/dist/main.js CHANGED
@@ -307,7 +307,7 @@ ${A.message}`),w(127)}),c.on("exit",()=>l("SIGKILL")),c.on("close",(A,E)=>w(A??(
307
307
  `),s=[];n.reduce((i,o)=>(s.push(i),i+o.length+1),0);for(let i of e.matchAll(aQt)){let o=i[1].length,a=e.slice(0,i.index).split(`
308
308
  `).length-1,c=a+1;for(;c<n.length&&(!n[c].trim()||n[c].length-n[c].trimStart().length>o);)c++;let l=n.slice(Math.max(0,a-3),a).join(`
309
309
  `);r.push({title:i[2],start:s[a],end:c<n.length?s[c]:e.length,skipped:/@pytest\.mark\.skip/.test(l)})}return r}for(let n of e.matchAll(oQt)){let s=iQt(e,n.index+n[0].length);s!==void 0&&r.push({title:n[3],start:n.index,end:sQt(e,s),skipped:n[1]==="skip"||n[1]==="fixme"})}return r.filter(n=>!r.some(s=>s!==n&&s.start<=n.start&&n.end<=s.end))}var hC=e=>e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim();function dQt(e,t){let r=hC(t);if(r)return e.find(n=>hC(n.title)===r)??e.find(n=>hC(n.title)&&(r.includes(hC(n.title))||hC(n.title).includes(r)))}var AMe=/@playwright\/test|from\s+playwright|sync_playwright|async_playwright|\bpage\.goto\s*\(|\bcy\.visit\s*\(|\bcypress\b|selenium|webdriver|newSkyrampPlaywrightPage|\bbrowser\.url\s*\(|ApplicationSystemTestCase|\bCapybara\b|\bdriven_by\b|type:\s*:(?:system|feature)\b/i,pQt=[{re:/\.(?:fulfill|abort)\s*\(/,what:"route.fulfill / route.abort"},{re:/\broute_?from_?har\s*\(/i,what:"a HAR replay (routeFromHAR)"},{re:/from\s+['"]msw(?:\/[^'"]*)?['"]|require\(\s*['"]msw|\bsetup(?:Server|Worker)\s*\(/,what:"msw handlers"}];function fQt(e){for(let t of e.matchAll(/\bcy\.intercept\s*\(/g)){let r=0,n=t.index+t[0].length-1,s=n;for(;n<e.length;n++)if(e[n]==="(")r++;else if(e[n]===")"&&--r===0)break;if(/\b(statusCode|fixture|body|forceNetworkError)\s*:|\.(reply|destroy)\s*\(/.test(e.slice(s,n)))return!0}return!1}function hQt(e){let t=pQt.filter(r=>r.re.test(e)).map(r=>r.what);return fQt(e)&&t.push("cy.intercept with a response"),t}var yMe=/(?:\.goto|\bcy\.visit|\bdriver\.get|\bbrowser\.url|\.navigate\(\)\.to)\s*\(\s*(?:f?(['"`])((?:\\.|(?!\1)[^\\])*)\1)?/g,EMe=/(?<![.\w])visit[ \t]*\(?[ \t]*(?:(['"])((?:\\.|(?!\1)[^\\])*)\1)?/g,mQt=/\.(click|dblclick|fill|type|press|pressSequentially|press_sequentially|check|uncheck|selectOption|select_option|setInputFiles|set_input_files|tap|dragTo|drag_to|submit|clear|hover|reload)\s*\(/g,gQt=/(?<![\w$])(?:expect|assert|verify|should)\w*\s*\(|\bexpect\.|\bassert\b/gi,AQt=/\b(?:click_on|click_button|click_link|fill_in|select|check|uncheck|choose|attach_file)\b|\.(?:click|set|select_option)\b/g,yQt=/\b(?:assert\w*|refute\w*|expect)\b/g;function rMe(e,t=!1,r){let n=[...e.matchAll(t?EMe:yMe)].map(i=>({at:i.index,route:i[1]!==void 0?i[2]:void 0})),s=r?.navigators.size?[...e.matchAll(new RegExp(`(?<![\\w$.])(${[...r.navigators].map(i=>i.replace(/[$]/g,"\\$")).join("|")})\\s*\\(`,"g"))].map(i=>({at:i.index,route:void 0})):[];return[...n,...s].sort((i,o)=>i.at-o.at)}var EQt=/(?:from\s+|require\(\s*|import\s+)(['"])(\.{1,2}\/[^'"]+)\1/g,wQt=/require_relative\s+(['"])([^'"]+)\1/g,bQt=/^\s*from\s+(\.+)?([\w.]*)\s+import\b/gm,SQt=/(?:export\s+)?(?:async\s+)?function\s+(\w+)|(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|\w+)\s*=>|^[ \t]*(?:async\s+)?def\s+(\w+)|^[ \t]*(\w+)\s*\([^)]*\)\s*\{/gm;function z6(e,t,r){let n=ms.resolve(ms.dirname(e),t);for(let s of[n,...r.map(i=>n+i),...r.map(i=>ms.join(n,`index${i}`))])try{if(Fa.statSync(s).isFile())return s}catch{}}function CQt(e,t){let r={navigators:new Set,browser:!1,fixtureNavigates:!1},n=/\.rb$/i.test(e),s=/\.py$/i.test(e),i=new Set([ms.resolve(e)]),o=(l,u)=>n?[...u.matchAll(wQt)].map(d=>z6(l,d[2],[".rb"])).filter(d=>!!d):s?[...u.matchAll(bQt)].map(d=>z6(l,(d[1]&&d[1].length>1?"../".repeat(d[1].length-1):"./")+d[2].replace(/\./g,"/"),[".py"])).filter(d=>!!d):[...u.matchAll(EQt)].map(d=>z6(l,d[2],[".ts",".tsx",".js",".mjs",".cjs",".jsx"])).filter(d=>!!d),a=!n&&!s&&/import\s*\{[^}]*\btest\b[^}]*\}\s*from\s*['"]\.{1,2}\//.test(t),c=o(e,t);for(let l=0;l<2&&c.length;l++){let u=[];for(let d of c){if(i.has(d))continue;i.add(d);let p;try{p=gMe(Fa.readFileSync(d,"utf-8"))}catch{continue}AMe.test(p)&&(r.browser=!0);let f=n?EMe:yMe,m=[...p.matchAll(SQt)].map(g=>({name:g[1]??g[2]??g[3]??g[4],at:g.index}));m.forEach((g,w)=>{let A=p.slice(g.at,w+1<m.length?m[w+1].at:p.length);f.lastIndex=0,g.name&&f.test(A)&&r.navigators.add(g.name)}),f.lastIndex=0,a&&/\.extend\s*[<(]/.test(p)&&f.test(p)&&(r.fixtureNavigates=!0),u.push(...o(d,p))}c=u}return r}function nMe(e){let t=e.trim().replace(/^\$\{[^}]*\}/,"").replace(/^https?:\/\/[^/]+/i,"").replace(/^\{[^}]*\}/,"");return t=t.split("?")[0],!t.startsWith("/")&&!t.startsWith("#")&&(t=`/${t}`),t.length>1?t.replace(/\/+$/,""):t}var sMe=/^(:\w+|\[[^\]]+\]|\{[^}]+\}|<[^>]+>|\$\{[^}]*\}|\*)$/;function V6(e,t){let r=nMe(e).split("/"),n=nMe(t).split("/");return r.length===n.length&&r.every((s,i)=>s===n[i]||sMe.test(s)||sMe.test(n[i]))}function vQt(e,t,r,n=!1,s={}){let{ruby:i=!1,helpers:o}=s,a=t.kind!=="in-process";if(a&&!AMe.test(e)&&!o?.browser)return["is not a browser test (no Playwright, Cypress, Capybara or WebDriver page in it, nor in a helper it imports)"];let c=gMe(e),l=i?lQt(c):uQt(c,n),u=r?.trim()?dQt(l,r):l.length===1?l[0]:void 0;if(!u)return[r?.trim()?`has no test titled "${r}"`:`holds ${l.length} tests; say which one walks the journey ("test" in "journeys")`];let d=[];if(u.skipped&&d.push(`its test "${u.title}" is skipped`),!a)return[...d,...iMe(c.slice(u.start,u.end),t,i)];let p="",f=0;for(let A of l)p+=c.slice(f,A.start),f=A.end;p+=c.slice(f);let m=c.slice(u.start,u.end),g=hQt(`${p}
310
- ${m}`);g.length&&d.push(`stubs the app's network (${g.join(", ")}); a journey test runs against the real app, so remove the stub from it`);let w=[...o?.fixtureNavigates?[{at:-1,route:void 0}]:[],...rMe(p,i,o),...rMe(m,i,o).map(A=>({...A,at:A.at+p.length+1}))];if(!w.length)d.push(`never opens a page; start it with a navigation to the entry route ${t.entry}`);else{let A=w.findIndex(E=>E.route===void 0||V6(E.route,t.entry));if(A<0)d.push(`does not open the journey's entry route ${t.entry} (it opens ${w.map(E=>E.route).join(", ")}); start there`);else{let E=t.steps.slice(1).filter(S=>S.route.trim()&&!V6(S.route,t.entry));for(let S of w.slice(A+1)){let x=S.route!==void 0?E.find(I=>V6(S.route,I.route)):void 0;x&&d.push(`jumps by URL to ${S.route} (step ${t.steps.indexOf(x)+1}) instead of getting there through the UI; use page.reload() where the outcome must persist`)}}}if(d.push(...iMe(m,t,i)),!n&&!i&&/@playwright\/test/.test(e)){let A=(m.match(/\btest\.step\s*\(/g)??[]).length;A<t.steps.length&&d.push(`marks ${A} of its ${t.steps.length} steps; wrap each in test.step, named for the step, so a failure names it`)}return d}function iMe(e,t,r){let n=Math.max(-1,...[...e.matchAll(r?AQt:mQt)].map(i=>i.index),...[...e.matchAll(xQt)].map(i=>i.index)),s=[...e.matchAll(r?yQt:gQt)].map(i=>i.index);return s.length?Math.max(...s)<n?[`ends with a user action and no assertion after it; assert the journey's outcome after the last step: ${t.outcome}`]:s.length<t.steps.length?[`has ${s.length} assertion(s) for ${t.steps.length} steps; after each step, assert what the user then sees`]:[]:[`asserts nothing; end it by asserting the journey's outcome: ${t.outcome}`]}var xQt=/\b(?:userEvent|user|fireEvent)\.\w+\s*\(|\.(?:trigger|setValue)\s*\(/g,IQt=/^\s*pass(?:es|ed|ing)\b\s*(?:$|[:;,.(—–-])|\bcould[- ]break\s+(?:check|test|rule|case)s?\b|\b(?:removed|dropped|deleted)\b[^.;]{0,60}\b(?:because|as|since|for)\b[^.;]{0,40}\bpass(?:es|ed|ing)?\b|\bpass(?:es|ed)\b[^.;]{0,40}\b(?:and|so)\b[^.;]{0,20}\b(?:removed|dropped|deleted)\b/i;function AT(e,t,r){return e.map(n=>{let s=t.notWritten?.find(u=>u.case.trim()===n.id)?.reason.trim(),i=t.tests.some(u=>u.covers.includes(n.id));if(s&&!i&&IQt.test(s))return{journey:n,uncovered:s,problems:["its test was removed because it passes; a journey's test stays whether it passes or fails: restore it"]};if(s&&!i)return{journey:n,uncovered:s,problems:[]};let o=t.journeys?.find(u=>u.journey.trim()===n.id),a=o?.file?.trim()||t.tests.find(u=>u.covers.includes(n.id))?.file||n.testFile,c=a?r(a):void 0;if(!c)return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a||"no file"} is not on disk`]};let l;try{l=Fa.readFileSync(c,"utf-8")}catch{return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a} cannot be read`]}}return{journey:n,file:a,test:o?.test,problems:vQt(l,n,o?.test,/\.py$/i.test(c),{ruby:/\.rb$/i.test(c),helpers:CQt(c,l)})}})}function Nc(e,t=[]){let r=[e,...t.map(n=>n.path)].map(n=>ms.resolve(n));return n=>{let s=n.replace(/^\.\//,""),i=s.split("/")[0];return[ms.resolve(e,s),...t.filter(a=>ms.basename(ms.resolve(a.path))===i).map(a=>ms.resolve(a.path,s.slice(i.length+1)))].find(a=>r.some(c=>a.startsWith(c+ms.sep))&&Fa.existsSync(a)&&Fa.statSync(a).isFile())}}function kF(e){return e.filter(t=>t.problems.length).map(t=>`journey ${t.journey.id} (${t.journey.name})${t.file?` in ${t.file}`:""}: ${t.problems.join("; ")}`)}var wMe=(e,t)=>e===t||e.endsWith(`/${t}`)||t.endsWith(`/${e}`);function bMe(e,t,r){if(!r||!t.journeys?.find(s=>s.journey.trim()===e.id)?.brokeAt)return!1;let n=new Set([e.id,...e.steps.flatMap(s=>s.clauses??[])].map(s=>s.trim()));return t.tests.some(s=>wMe(s.file,r)&&s.covers.some(i=>n.has(i.trim()))&&typeof s.result.exit=="number"&&s.result.exit!==0)}function SMe(e,t,r){return(t?AT(e,t,r):e.map(s=>({journey:s,problems:["has no test"]}))).map(({journey:s,file:i,test:o,problems:a,uncovered:c})=>{if(c)return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",status:"Not written",problems:a,uncovered:c};let l=(t?.tests??[]).filter(w=>i&&wMe(w.file,i)),u=l.find(w=>w.covers.includes(s.id))??l[0],d=!!(i&&r(i)),p=u?.result.cases.find(w=>w.case===s.id)?.status,f=!p&&u&&!u.result.cases.length&&u.covers.every(w=>w===s.id)?u.result.exit:null,m=!p&&t!==void 0&&bMe(s,t,i),g=d?p==="pass"||f===0?"Pass":p==="fail"||f!==null&&f!==0||m?"Fail":"Not run":"Not written";return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",...d?{fileName:i}:{},...o?{test:o}:{},status:g,problems:d?a:[]}})}function CMe(e,t){if(!t)return[];let r=[];for(let n of e){let s=t.journeys?.find(p=>p.journey.trim()===n.id),i=s?.brokeAt,o=t.tests.flatMap(p=>p.result.cases.filter(f=>f.case===n.id).map(f=>f.status)),a=o.includes("fail")||!o.length&&bMe(n,t,s?.file?.trim());if(!i||!a)continue;let c=n.steps[i.step-1],l=c?` (${c.route.trim()?`${c.route.trim()} \u2014 `:""}${c.action.trim()})`:"",u=i.notReached??[],d=u.length===1?` Step ${u[0]} was not reached.`:u.length?` Steps ${u.join(", ")} were not reached.`:"";r.push({description:`User journey "${n.name.trim()}" breaks at step ${i.step}${l}: expected ${i.expected.trim()}, got ${i.actual.trim()}.${d}`,severity:"medium",category:"bug",...s?.file?{test:s.file}:{},...c?.clauses?.length?{clauses:[...c.clauses]}:{}})}return r}var RQt=["stale_test","open_question"],oMe=["low","medium","high","critical"],TQt=(e,t)=>oMe.indexOf(t)>oMe.indexOf(e??"")?t:e??t;function vMe(e,t,r=[]){let n=new Map(r.flatMap(a=>[[a.id,a.id],...a.clauses.map(c=>[c.id,a.id])])),s=(a,c)=>a===c||(n.get(a)??a)===(n.get(c)??c),i=[...e],o=[...e];for(let{test:a,clauses:c=[],...l}of t){let u=a?o.flatMap((f,m)=>!RQt.includes(f.category??"")&&KQ(f.description,a)?[m]:[]):[],d=f=>c.some(m=>(o[f].requirementIds??[]).some(g=>s(g,m))),p=u.find(d)??(u.length===1&&!o[u[0]].requirementIds?.length?u[0]:void 0);if(p===void 0){i.push({...l,description:a?`${l.description} (shown by ${a})`:l.description});continue}o[p]={...o[p],description:`${o[p].description} ${l.description}`,severity:TQt(o[p].severity,l.severity)},i[p]=o[p]}return i}function xMe(e,t){if(!e)return;let r=t?.results??[];return{journeys:e.journeys,notWritten:(e.journeysNotWritten??[]).map(n=>({case:n.journey,reason:n.missing})),tests:e.tests.map(n=>{let s=r.filter(c=>n.covers.some(l=>c.behaviorIds.includes(l))),i=s.some(c=>c.status==="Fail"),o=s.some(c=>c.status==="Pass"),a=i?"fail":o?"pass":void 0;return{file:n.file,covers:n.covers,result:{exit:a?i?1:0:null,cases:a?n.covers.map(c=>({case:c,status:a})):[]}}})}}var Ct=y.string().trim().min(1),kQt=e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},BQt=y.preprocess(kQt,y.object({id:Ct.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ct.describe("one testable part of the requirement"),expected:Ct.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:y.string().optional().describe("only when no test can check this clause here: why"),type:y.nativeEnum(Tl).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:y.string().optional().describe('its "METHOD /path", or the page / flow'),steps:y.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:y.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:y.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:y.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:y.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:y.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),TMe=y.object({spec:y.string().optional().describe("file:line of a spec in the repository"),prDescription:y.boolean().optional().describe("or true when a pull request description says otherwise"),reference:y.string().optional().describe("or the key of an item the run was given, as listed"),says:Ct.describe("what it says there, in its own words, copied exactly"),criterion:y.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(e=>[!!e.prDescription,!!e.spec?.trim(),!!e.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),NQt=y.object({id:Ct.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ct,source:y.nativeEnum(ra).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:y.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ct.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:y.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:y.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:y.array(TMe).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:y.array(BQt)}),K6=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(K6||{}),_Qt=y.object({id:Ct.describe('e.g. "F1"'),file:Ct,line:y.number().optional(),claim:Ct.describe("the defect, in one sentence"),severity:y.nativeEnum(wy),evidence:Ct.describe("the code line, or the probe request and response, that shows it"),conflictsWith:y.array(Ct).optional().describe("requirement or clause ids it violates"),keeps:y.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:y.nativeEnum(K6).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:y.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:y.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),PQt=y.object({id:Ct.describe('e.g. "Q1"'),question:Ct.describe("what is unsettled, as a question the PR author can answer"),readings:y.array(Ct).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:y.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:y.array(TMe).optional().describe("when sources of the same rank disagree on it: each of them")}),DQt=y.object({id:Ct.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:y.nativeEnum(Tl).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:Ct.describe('"METHOD /path", or the page / flow'),clause:y.string().optional().describe("the clause id this case checks"),finding:y.string().optional().describe("the finding id this case catches"),steps:Ct.describe("what the test does"),expected:Ct.describe("the expected outcome, from the clause"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),OQt=y.object({test:Ct.describe("existing test file"),action:y.nativeEnum(Dp),reason:Ct,mutates:y.boolean().optional().describe("true when the maintained test changes state"),clauses:y.array(Ct).optional().describe("the clause ids this test checks")}),kMe=y.object({outcome:y.nativeEnum(El).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:y.record(y.string()).optional().describe("service \u2192 base URL of the running app"),health:y.object({url:y.string().optional(),command:y.string().optional(),output:y.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:y.string().optional().describe("command that stops the app"),dependencies:y.record(y.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:y.array(y.string()).optional().describe("what you changed in the recipe"),error:y.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:y.array(y.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:y.object({username:Ct,password:y.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:yW.optional()}),Ki=y.object({schemaVersion:y.literal(1),requirements:y.array(NQt),findings:y.array(_Qt),cases:y.array(DQt).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:y.array(PQt).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:y.array(OQt),journeys:y.array(cMe).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:y.array(y.object({clause:Ct,why:Ct})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:lT.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:kMe.optional().describe("omit when no app was needed or none was started"),summary:Ct.describe("one paragraph: what the change does and where the risk is")});function BF(e){return e?.length?["Left open for the PR's author: assert none of these readings. A test that reaches one checks only what every reading allows.",...e.map(t=>` - ${t.id}${t.about?` (${t.about})`:""}: ${t.question} Readings: ${t.readings.join("; ")}`),""]:[]}var yT=(r=>(r.Backend="backend",r.Ui="ui",r))(yT||{}),X6=e=>{let t=e.skyramp?.draft;return(Array.isArray(t)?t:t?[t]:[]).map(r=>r.trim()).filter(Boolean)},To=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(To||{}),QQt=y.object({file:Ct.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:y.nativeEnum(yT),change:y.nativeEnum(To).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:y.array(y.string()).describe("the plan case ids this file tests"),defect:y.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:y.object({requirement:Ct.describe("the requirement or clause id the change deliberately alters"),line:Ct.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:y.object({exit:y.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:y.array(y.object({case:Ct,status:y.nativeEnum(Ji),defect:y.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:y.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:y.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:y.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:y.string().optional().describe("what failed and why, or why it was not run")}),assertions:y.array(y.object({case:Ct,evidence:Ct})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:y.array(y.object({name:Ct.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:y.array(Ct).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:y.object({draft:y.union([y.string(),y.array(y.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:y.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:y.array(b6).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:Ct.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:eMe.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:lC.optional().describe(`for a file in ${uC}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${Yi}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),MQt=e=>{if(!e||typeof e!="object")return e;let{test:t,...r}=e;return typeof t=="string"&&t.trim()&&r.tests===void 0?{...r,tests:[t]}:e},FQt=y.preprocess(MQt,y.object({description:Ct.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:y.nativeEnum(wy).optional(),sourceFile:y.string().optional().describe("the app file at fault"),sourceLine:y.number().optional(),tests:y.array(Ct).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:y.string().optional().describe("the plan's finding id, when it is one"),requirements:y.array(Ct).optional().describe("the plan's requirement or clause ids it violates")})),Lr=y.object({schemaVersion:y.literal(1),tests:y.array(QQt),notWritten:y.array(y.object({case:Ct,reason:Ct})).describe("every plan case no test covers, and why"),journeys:y.array(RF).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:y.object({command:y.string(),clean:y.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:y.array(y.object({package:Ct,manifest:Ct.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:Ct.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ct.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:y.array(Ct).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:y.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:y.object({message:Ct.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ct.describe("at most 72 characters"),prBody:Ct.describe("what the tests cover and what they found")}),report:y.object({summary:Ct.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:y.array(FQt).describe("every defect the tests found"),nextSteps:y.array(y.string())})});function J6(e,t,r=[]){let{value:n,error:s}=Cn(t,r);return s?{errors:[s]}:ts(e,n)}function Er(e,t,r,n=[]){let s=J6(e,t,n);if(s.value)return s;let i=AC(r);return i===void 0?s:J6(e,i,n)}function BMe(e,t){let r=new Set(e.findings.filter(c=>c.existing?.trim()).map(c=>c.id)),n=e.cases.filter(c=>!c.finding||!r.has(c.finding)),s=new Set(n.map(c=>c.id)),i=e.requirements.flatMap(c=>c.clauses.filter(l=>!l.steps?.trim()||l.skip?!1:s.has(l.id)?(t?.(l.id),!1):!0).map(l=>({id:l.id,type:l.type??"integration",target:l.target?.trim()||c.id,clause:l.id,...l.finding&&!r.has(l.finding)?{finding:l.finding}:{},steps:l.steps.trim(),expected:l.expected,...l.mutates?{mutates:!0}:{}}))),o=[...i,...n],a=nm(o,c=>c.id);return t&&o.filter(c=>!a.includes(c)).forEach(c=>t(c.id)),a.length===e.cases.length&&i.length===0?e:{...e,cases:a}}function NMe(e,t){if(!e.journeys)return e;let r=rm(e.journeys),n=new Set(e.cases.map(i=>i.id)),s=t?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${mC(i)}`,expected:i.outcome.trim()})):[];return{...e,journeys:r,cases:[...e.cases,...s]}}function _Me(e){let t=e.triage;if(t?.decision!=="runtime_required")return e;let r=new Set(t.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...t.plan,...t.outOfScope??[],...t.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=e.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===e.cases.length?e:{...e,cases:s}}function NF(e,t){for(let r of t){if(!r)continue;let{value:n}=J6(e,r);if(n)return n}}function PMe(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||!("app"in t)||kMe.safeParse(t.app).success)return;let{app:r,...n}=t;return JSON.stringify(n)}catch{return}}function AC(e){try{return gC.readFileSync(e,"utf-8")}catch{return}}function nm(e,t){let r=new Set;return e.filter(n=>{let s=t(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function _F(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}var DMe=(e,t)=>{let r=e.requirement.source==="requirement-reference"?e.requirement.reference?.trim():void 0;return e.code?.trim()?e.code.trim():r?Co(r,e.requirement.criterion,t):e.requirement.evidence};function Z6(e,t){return nm(e.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:DMe({...n,requirement:r},t)}))),r=>r.id)}function OMe(e,t,r=new Date){let n=nm(e.requirements,m=>m.id),s=nm(n.flatMap(m=>m.clauses.map(g=>({...g,requirement:m}))),m=>m.id),i=new Set(s.map(m=>m.id)),o=nm(e.findings,m=>m.id),a=new Set(o.map(m=>m.id)),c=nm(e.cases,m=>m.id),l=_F(e.app),u=s.map(m=>({id:m.id,statement:m.clause,surface:c.find(g=>g.clause===m.id)?.target??m.requirement.id,evidence:DMe(m,t.itemNames),satisfies:[m.requirement.id]})),d={schemaVersion:1,repository:t.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:t.changedFiles,nonApplicationOnly:t.nonApplicationOnly,summary:e.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(m=>({id:m.id,statement:m.statement,source:m.source,evidence:m.evidence})),behaviors:u,findings:o.map(m=>({id:m.id,file:m.file,line:m.line,claim:m.claim,severity:m.severity,evidence:m.evidence,status:m.existing?.trim()?"latent":"suspected",conflictsWith:m.conflictsWith})),unexamined:[],summary:e.summary},p=LQt(e.maintenance,ET(t.repository.path,t.related??[])),f={schemaVersion:1,mode:l?"full":"static",maintenance:p.maintenance.map(m=>({test:m.test,...m.repository?{repository:m.repository}:{},action:m.action,evidence:m.reason,...m.mutates?{mutates:!0}:{}})),generate:c.map(m=>({id:m.id,type:m.type,target:m.target,from_behavior:m.clause&&i.has(m.clause)?m.clause:void 0,from_finding:m.finding&&a.has(m.finding)?m.finding:void 0,rationale:s.find(g=>g.id===m.clause)?.clause??o.find(g=>g.id===m.finding)?.claim??UQt(e,m.id)??m.steps,expected_observable:m.expected,verifiable:l,...m.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:e.summary};return{analyze:d,recommend:f,deploy:e.app?$Qt(e.app,t,r):void 0,ambiguous:p.ambiguous}}function ET(e,t){return La(e,t,()=>[])}function LQt(e,t){let r=[],n=nm(e,s=>s.test).map(s=>{let i=t(s.test);return i.ambiguous&&r.push(s.test),xi(i)?{...s,test:i.rel,...i.repository?{repository:i.repository}:{}}:s});return{maintenance:nm(n,kK),ambiguous:r}}function UQt(e,t){let r=e.journeys?.find(n=>n.id===t);return r?`user journey: ${r.name.trim()}`:void 0}function $Qt(e,t,r){return{schemaVersion:1,baseUrls:e.baseUrls,health:e.health?{url:e.health.url,command:e.health.command,output:e.health.output??""}:void 0,teardown:e.teardown?.trim()||t.defaultTeardown||"true",dependencies:e.dependencies,outcome:e.outcome,recipeFixes:e.recipeFixes,bringupError:e.error?{command:"bring-up",output:e.error}:void 0,suspectFiles:e.suspectFiles,seeded:!1,startedAt:r.toISOString(),recipeRecorded:t.recipeRecorded}}var qQt={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function GQt(e){return e.result.exit!==null&&e.result.exit!==0||e.result.cases.some(t=>t.status==="fail")}function Y6(e){let[t,...r]=e.split(`
310
+ ${m}`);g.length&&d.push(`stubs the app's network (${g.join(", ")}); a journey test runs against the real app, so remove the stub from it`);let w=[...o?.fixtureNavigates?[{at:-1,route:void 0}]:[],...rMe(p,i,o),...rMe(m,i,o).map(A=>({...A,at:A.at+p.length+1}))];if(!w.length)d.push(`never opens a page; start it with a navigation to the entry route ${t.entry}`);else{let A=w.findIndex(E=>E.route===void 0||V6(E.route,t.entry));if(A<0)d.push(`does not open the journey's entry route ${t.entry} (it opens ${w.map(E=>E.route).join(", ")}); start there`);else{let E=t.steps.slice(1).filter(S=>S.route.trim()&&!V6(S.route,t.entry));for(let S of w.slice(A+1)){let x=S.route!==void 0?E.find(I=>V6(S.route,I.route)):void 0;x&&d.push(`jumps by URL to ${S.route} (step ${t.steps.indexOf(x)+1}) instead of getting there through the UI; use page.reload() where the outcome must persist`)}}}if(d.push(...iMe(m,t,i)),!n&&!i&&/@playwright\/test/.test(e)){let A=(m.match(/\btest\.step\s*\(/g)??[]).length;A<t.steps.length&&d.push(`marks ${A} of its ${t.steps.length} steps; wrap each in test.step, named for the step, so a failure names it`)}return d}function iMe(e,t,r){let n=Math.max(-1,...[...e.matchAll(r?AQt:mQt)].map(i=>i.index),...[...e.matchAll(xQt)].map(i=>i.index)),s=[...e.matchAll(r?yQt:gQt)].map(i=>i.index);return s.length?Math.max(...s)<n?[`ends with a user action and no assertion after it; assert the journey's outcome after the last step: ${t.outcome}`]:s.length<t.steps.length?[`has ${s.length} assertion(s) for ${t.steps.length} steps; after each step, assert what the user then sees`]:[]:[`asserts nothing; end it by asserting the journey's outcome: ${t.outcome}`]}var xQt=/\b(?:userEvent|user|fireEvent)\.\w+\s*\(|\.(?:trigger|setValue)\s*\(/g,IQt=/^\s*pass(?:es|ed|ing)\b\s*(?:$|[:;,.(—–-])|\bcould[- ]break\s+(?:check|test|rule|case)s?\b|\b(?:removed|dropped|deleted)\b[^.;]{0,60}\b(?:because|as|since|for)\b[^.;]{0,40}\bpass(?:es|ed|ing)?\b|\bpass(?:es|ed)\b[^.;]{0,40}\b(?:and|so)\b[^.;]{0,20}\b(?:removed|dropped|deleted)\b/i;function AT(e,t,r){return e.map(n=>{let s=t.notWritten?.find(u=>u.case.trim()===n.id)?.reason.trim(),i=t.tests.some(u=>u.covers.includes(n.id));if(s&&!i&&IQt.test(s))return{journey:n,uncovered:s,problems:["its test was removed because it passes; a journey's test stays whether it passes or fails: restore it"]};if(s&&!i)return{journey:n,uncovered:s,problems:[]};let o=t.journeys?.find(u=>u.journey.trim()===n.id),a=o?.file?.trim()||t.tests.find(u=>u.covers.includes(n.id))?.file||n.testFile,c=a?r(a):void 0;if(!c)return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a||"no file"} is not on disk`]};let l;try{l=Fa.readFileSync(c,"utf-8")}catch{return{journey:n,file:a,test:o?.test,problems:[`has no test: ${a} cannot be read`]}}return{journey:n,file:a,test:o?.test,problems:vQt(l,n,o?.test,/\.py$/i.test(c),{ruby:/\.rb$/i.test(c),helpers:CQt(c,l)})}})}function Nc(e,t=[]){let r=[e,...t.map(n=>n.path)].map(n=>ms.resolve(n));return n=>{let s=n.replace(/^\.\//,""),i=s.split("/")[0];return[ms.resolve(e,s),...t.filter(a=>ms.basename(ms.resolve(a.path))===i).map(a=>ms.resolve(a.path,s.slice(i.length+1)))].find(a=>r.some(c=>a.startsWith(c+ms.sep))&&Fa.existsSync(a)&&Fa.statSync(a).isFile())}}function kF(e){return e.filter(t=>t.problems.length).map(t=>`journey ${t.journey.id} (${t.journey.name})${t.file?` in ${t.file}`:""}: ${t.problems.join("; ")}`)}var wMe=(e,t)=>e===t||e.endsWith(`/${t}`)||t.endsWith(`/${e}`);function bMe(e,t,r){if(!r||!t.journeys?.find(s=>s.journey.trim()===e.id)?.brokeAt)return!1;let n=new Set([e.id,...e.steps.flatMap(s=>s.clauses??[])].map(s=>s.trim()));return t.tests.some(s=>wMe(s.file,r)&&s.covers.some(i=>n.has(i.trim()))&&typeof s.result.exit=="number"&&s.result.exit!==0)}function SMe(e,t,r){return(t?AT(e,t,r):e.map(s=>({journey:s,problems:["has no test"]}))).map(({journey:s,file:i,test:o,problems:a,uncovered:c})=>{if(c)return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",status:"Not written",problems:a,uncovered:c};let l=(t?.tests??[]).filter(w=>i&&wMe(w.file,i)),u=l.find(w=>w.covers.includes(s.id))??l[0],d=!!(i&&r(i)),p=u?.result.cases.find(w=>w.case===s.id)?.status,f=!p&&u&&!u.result.cases.length&&u.covers.every(w=>w===s.id)?u.result.exit:null,m=!p&&t!==void 0&&bMe(s,t,i),g=d?p==="pass"||f===0?"Pass":p==="fail"||f!==null&&f!==0||m?"Fail":"Not run":"Not written";return{id:s.id,name:s.name,entry:s.entry,steps:s.steps.length,source:s.source??"inferred",...d?{fileName:i}:{},...o?{test:o}:{},status:g,problems:d?a:[]}})}function CMe(e,t){if(!t)return[];let r=[];for(let n of e){let s=t.journeys?.find(p=>p.journey.trim()===n.id),i=s?.brokeAt,o=t.tests.flatMap(p=>p.result.cases.filter(f=>f.case===n.id).map(f=>f.status)),a=o.includes("fail")||!o.length&&bMe(n,t,s?.file?.trim());if(!i||!a)continue;let c=n.steps[i.step-1],l=c?` (${c.route.trim()?`${c.route.trim()} \u2014 `:""}${c.action.trim()})`:"",u=i.notReached??[],d=u.length===1?` Step ${u[0]} was not reached.`:u.length?` Steps ${u.join(", ")} were not reached.`:"";r.push({description:`User journey "${n.name.trim()}" breaks at step ${i.step}${l}: expected ${i.expected.trim()}, got ${i.actual.trim()}.${d}`,severity:"medium",category:"bug",...s?.file?{test:s.file}:{},...c?.clauses?.length?{clauses:[...c.clauses]}:{}})}return r}var RQt=["stale_test","open_question"],oMe=["low","medium","high","critical"],TQt=(e,t)=>oMe.indexOf(t)>oMe.indexOf(e??"")?t:e??t;function vMe(e,t,r=[]){let n=new Map(r.flatMap(a=>[[a.id,a.id],...a.clauses.map(c=>[c.id,a.id])])),s=(a,c)=>a===c||(n.get(a)??a)===(n.get(c)??c),i=[...e],o=[...e];for(let{test:a,clauses:c=[],...l}of t){let u=a?o.flatMap((f,m)=>!RQt.includes(f.category??"")&&KQ(f.description,a)?[m]:[]):[],d=f=>c.some(m=>(o[f].requirementIds??[]).some(g=>s(g,m))),p=u.find(d)??(u.length===1&&!o[u[0]].requirementIds?.length?u[0]:void 0);if(p===void 0){i.push({...l,description:a?`${l.description} (shown by ${a})`:l.description});continue}o[p]={...o[p],description:`${o[p].description} ${l.description}`,severity:TQt(o[p].severity,l.severity)},i[p]=o[p]}return i}function xMe(e,t){if(!e)return;let r=t?.results??[];return{journeys:e.journeys,notWritten:(e.journeysNotWritten??[]).map(n=>({case:n.journey,reason:n.missing})),tests:e.tests.map(n=>{let s=r.filter(c=>n.covers.some(l=>c.behaviorIds.includes(l))),i=s.some(c=>c.status==="Fail"),o=s.some(c=>c.status==="Pass"),a=i?"fail":o?"pass":void 0;return{file:n.file,covers:n.covers,result:{exit:a?i?1:0:null,cases:a?n.covers.map(c=>({case:c,status:a})):[]}}})}}var Ct=y.string().trim().min(1),kQt=e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},BQt=y.preprocess(kQt,y.object({id:Ct.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ct.describe("one testable part of the requirement"),expected:Ct.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:y.string().optional().describe("only when no test can check this clause here: why"),type:y.nativeEnum(Tl).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:y.string().optional().describe('its "METHOD /path", or the page / flow'),steps:y.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:y.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:y.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:y.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:y.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:y.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),TMe=y.object({spec:y.string().optional().describe("file:line of a spec in the repository"),prDescription:y.boolean().optional().describe("or true when a pull request description says otherwise"),reference:y.string().optional().describe("or the key of an item the run was given, as listed"),says:Ct.describe("what it says there, in its own words, copied exactly"),criterion:y.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(e=>[!!e.prDescription,!!e.spec?.trim(),!!e.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),NQt=y.object({id:Ct.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ct,source:y.nativeEnum(ra).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:y.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ct.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:y.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:y.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:y.array(TMe).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:y.array(BQt)}),K6=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(K6||{}),_Qt=y.object({id:Ct.describe('e.g. "F1"'),file:Ct,line:y.number().optional(),claim:Ct.describe("the defect, in one sentence"),severity:y.nativeEnum(wy),evidence:Ct.describe("the code line, or the probe request and response, that shows it"),conflictsWith:y.array(Ct).optional().describe("requirement or clause ids it violates"),keeps:y.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:y.nativeEnum(K6).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:y.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:y.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),PQt=y.object({id:Ct.describe('e.g. "Q1"'),question:Ct.describe("what is unsettled, as a question the PR author can answer"),readings:y.array(Ct).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:y.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:y.array(TMe).optional().describe("when sources of the same rank disagree on it: each of them")}),DQt=y.object({id:Ct.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:y.nativeEnum(Tl).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:Ct.describe('"METHOD /path", or the page / flow'),clause:y.string().optional().describe("the clause id this case checks"),finding:y.string().optional().describe("the finding id this case catches"),steps:Ct.describe("what the test does"),expected:Ct.describe("the expected outcome, from the clause"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),OQt=y.object({test:Ct.describe("existing test file"),action:y.nativeEnum(Dp),reason:Ct,mutates:y.boolean().optional().describe("true when the maintained test changes state"),clauses:y.array(Ct).optional().describe("the clause ids this test checks")}),kMe=y.object({outcome:y.nativeEnum(El).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:y.record(y.string()).optional().describe("service \u2192 base URL of the running app"),health:y.object({url:y.string().optional(),command:y.string().optional(),output:y.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:y.string().optional().describe("command that stops the app"),dependencies:y.record(y.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:y.array(y.string()).optional().describe("what you changed in the recipe"),error:y.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:y.array(y.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:y.object({username:Ct,password:y.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:yW.optional()}),Ki=y.object({schemaVersion:y.literal(1),requirements:y.array(NQt),findings:y.array(_Qt),cases:y.array(DQt).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:y.array(PQt).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:y.array(OQt),journeys:y.array(cMe).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:y.array(y.object({clause:Ct,why:Ct})).optional().describe("a clause a user sees or does that no journey walks, and why: none can reach it through the UI, or it is downstream of this change and not walked here"),triage:lT.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:kMe.optional().describe("omit when no app was needed or none was started"),summary:Ct.describe("one paragraph: what the change does and where the risk is")});function BF(e){return e?.length?["Left open for the PR's author: assert none of these readings. A test that reaches one checks only what every reading allows.",...e.map(t=>` - ${t.id}${t.about?` (${t.about})`:""}: ${t.question} Readings: ${t.readings.join("; ")}`),""]:[]}var yT=(r=>(r.Backend="backend",r.Ui="ui",r))(yT||{}),X6=e=>{let t=e.skyramp?.draft;return(Array.isArray(t)?t:t?[t]:[]).map(r=>r.trim()).filter(Boolean)},To=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(To||{}),QQt=y.object({file:Ct.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:y.nativeEnum(yT),change:y.nativeEnum(To).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:y.array(y.string()).describe("the plan case ids this file tests"),defect:y.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:y.object({requirement:Ct.describe("the requirement or clause id the change deliberately alters"),line:Ct.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:y.object({exit:y.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:y.array(y.object({case:Ct,status:y.nativeEnum(Ji),defect:y.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:y.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:y.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:y.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:y.string().optional().describe("what failed and why, or why it was not run")}),assertions:y.array(y.object({case:Ct,evidence:Ct})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:y.array(y.object({name:Ct.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:y.array(Ct).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:y.object({draft:y.union([y.string(),y.array(y.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:y.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:y.array(b6).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:Ct.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:eMe.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:lC.optional().describe(`for a file in ${uC}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${Yi}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),MQt=e=>{if(!e||typeof e!="object")return e;let{test:t,...r}=e;return typeof t=="string"&&t.trim()&&r.tests===void 0?{...r,tests:[t]}:e},FQt=y.preprocess(MQt,y.object({description:Ct.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:y.nativeEnum(wy).optional(),sourceFile:y.string().optional().describe("the app file at fault"),sourceLine:y.number().optional(),tests:y.array(Ct).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:y.string().optional().describe("the plan's finding id, when it is one"),requirements:y.array(Ct).optional().describe("the plan's requirement or clause ids it violates")})),Lr=y.object({schemaVersion:y.literal(1),tests:y.array(QQt),notWritten:y.array(y.object({case:Ct,reason:Ct})).describe("every plan case no test covers, and why"),journeys:y.array(RF).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:y.object({command:y.string(),clean:y.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:y.array(y.object({package:Ct,manifest:Ct.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:Ct.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ct.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:y.array(Ct).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:y.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:y.object({message:Ct.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ct.describe("at most 72 characters"),prBody:Ct.describe("what the tests cover and what they found")}),report:y.object({summary:Ct.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:y.array(FQt).describe("every defect the tests found"),nextSteps:y.array(y.string())})});function J6(e,t,r=[]){let{value:n,error:s}=Cn(t,r);return s?{errors:[s]}:ts(e,n)}function Er(e,t,r,n=[]){let s=J6(e,t,n);if(s.value)return s;let i=AC(r);return i===void 0?s:J6(e,i,n)}function BMe(e,t){let r=new Set(e.findings.filter(c=>c.existing?.trim()).map(c=>c.id)),n=e.cases.filter(c=>!c.finding||!r.has(c.finding)),s=new Set(n.map(c=>c.id)),i=e.requirements.flatMap(c=>c.clauses.filter(l=>!l.steps?.trim()||l.skip?!1:s.has(l.id)?(t?.(l.id),!1):!0).map(l=>({id:l.id,type:l.type??"integration",target:l.target?.trim()||c.id,clause:l.id,...l.finding&&!r.has(l.finding)?{finding:l.finding}:{},steps:l.steps.trim(),expected:l.expected,...l.mutates?{mutates:!0}:{}}))),o=[...i,...n],a=nm(o,c=>c.id);return t&&o.filter(c=>!a.includes(c)).forEach(c=>t(c.id)),a.length===e.cases.length&&i.length===0?e:{...e,cases:a}}function NMe(e,t){if(!e.journeys)return e;let r=rm(e.journeys),n=new Set(e.cases.map(i=>i.id)),s=t?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${mC(i)}`,expected:i.outcome.trim()})):[];return{...e,journeys:r,cases:[...e.cases,...s]}}function _Me(e){let t=e.triage;if(t?.decision!=="runtime_required")return e;let r=new Set(t.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...t.plan,...t.outOfScope??[],...t.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=e.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===e.cases.length?e:{...e,cases:s}}function NF(e,t){for(let r of t){if(!r)continue;let{value:n}=J6(e,r);if(n)return n}}function PMe(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||!("app"in t)||kMe.safeParse(t.app).success)return;let{app:r,...n}=t;return JSON.stringify(n)}catch{return}}function AC(e){try{return gC.readFileSync(e,"utf-8")}catch{return}}function nm(e,t){let r=new Set;return e.filter(n=>{let s=t(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function _F(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}var DMe=(e,t)=>{let r=e.requirement.source==="requirement-reference"?e.requirement.reference?.trim():void 0;return e.code?.trim()?e.code.trim():r?Co(r,e.requirement.criterion,t):e.requirement.evidence};function Z6(e,t){return nm(e.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:DMe({...n,requirement:r},t)}))),r=>r.id)}function OMe(e,t,r=new Date){let n=nm(e.requirements,m=>m.id),s=nm(n.flatMap(m=>m.clauses.map(g=>({...g,requirement:m}))),m=>m.id),i=new Set(s.map(m=>m.id)),o=nm(e.findings,m=>m.id),a=new Set(o.map(m=>m.id)),c=nm(e.cases,m=>m.id),l=_F(e.app),u=s.map(m=>({id:m.id,statement:m.clause,surface:c.find(g=>g.clause===m.id)?.target??m.requirement.id,evidence:DMe(m,t.itemNames),satisfies:[m.requirement.id]})),d={schemaVersion:1,repository:t.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:t.changedFiles,nonApplicationOnly:t.nonApplicationOnly,summary:e.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(m=>({id:m.id,statement:m.statement,source:m.source,evidence:m.evidence})),behaviors:u,findings:o.map(m=>({id:m.id,file:m.file,line:m.line,claim:m.claim,severity:m.severity,evidence:m.evidence,status:m.existing?.trim()?"latent":"suspected",conflictsWith:m.conflictsWith})),unexamined:[],summary:e.summary},p=LQt(e.maintenance,ET(t.repository.path,t.related??[])),f={schemaVersion:1,mode:l?"full":"static",maintenance:p.maintenance.map(m=>({test:m.test,...m.repository?{repository:m.repository}:{},action:m.action,evidence:m.reason,...m.mutates?{mutates:!0}:{}})),generate:c.map(m=>({id:m.id,type:m.type,target:m.target,from_behavior:m.clause&&i.has(m.clause)?m.clause:void 0,from_finding:m.finding&&a.has(m.finding)?m.finding:void 0,rationale:s.find(g=>g.id===m.clause)?.clause??o.find(g=>g.id===m.finding)?.claim??UQt(e,m.id)??m.steps,expected_observable:m.expected,verifiable:l,...m.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:e.summary};return{analyze:d,recommend:f,deploy:e.app?$Qt(e.app,t,r):void 0,ambiguous:p.ambiguous}}function ET(e,t){return La(e,t,()=>[])}function LQt(e,t){let r=[],n=nm(e,s=>s.test).map(s=>{let i=t(s.test);return i.ambiguous&&r.push(s.test),xi(i)?{...s,test:i.rel,...i.repository?{repository:i.repository}:{}}:s});return{maintenance:nm(n,kK),ambiguous:r}}function UQt(e,t){let r=e.journeys?.find(n=>n.id===t);return r?`user journey: ${r.name.trim()}`:void 0}function $Qt(e,t,r){return{schemaVersion:1,baseUrls:e.baseUrls,health:e.health?{url:e.health.url,command:e.health.command,output:e.health.output??""}:void 0,teardown:e.teardown?.trim()||t.defaultTeardown||"true",dependencies:e.dependencies,outcome:e.outcome,recipeFixes:e.recipeFixes,bringupError:e.error?{command:"bring-up",output:e.error}:void 0,suspectFiles:e.suspectFiles,seeded:!1,startedAt:r.toISOString(),recipeRecorded:t.recipeRecorded}}var qQt={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function GQt(e){return e.result.exit!==null&&e.result.exit!==0||e.result.cases.some(t=>t.status==="fail")}function Y6(e){let[t,...r]=e.split(`
311
311
  `);return[t.length<=by?t:`${t.slice(0,by-1).trimEnd()}\u2026`,...r].join(`
312
312
  `)}function xi(e){return e.rel!==""&&!e.rel.startsWith("..")&&!Rs.isAbsolute(e.rel)}function La(e,t,r=fT){let n=t.map(u=>({name:bS(u),root:Rs.resolve(u.path),slug:u.slug})),s=new Map([...n].reverse().map(u=>[u.name,u])),i=t.length?[{real:fb(Rs.resolve(e))},...n.map(u=>({...u,real:fb(u.root)}))].sort((u,d)=>d.real.length-u.real.length):[],o=new Map,a=u=>o.get(u)??o.set(u,new Set(r(u))).get(u),c=u=>{let d=Rs.resolve(e,u),p=gC.existsSync(d),f=x=>({root:e,rel:_u(e,u),ambiguous:x,exists:p});if(!t.length)return f(!1);let m=!1,g=u.replace(/^\.\//,""),w=g.split("/")[0],A=s.get(w);if(A){let x=g.slice(w.length+1),I=gC.existsSync(Rs.join(A.root,x)),T=!gC.existsSync(Rs.join(e,w))||!p&&I;if(I&&p&&Rs.join(A.root,x)!==d){let P=a(A.root).has(_u(A.root,x)),R=a(e).has(_u(e,u));P&&!R?T=!0:P===R&&(m=!0)}if(T)return{root:A.root,rel:_u(A.root,x),repository:A.slug,dir:A.name,ambiguous:m,exists:I}}let E=Rs.join(fb(Rs.dirname(d)),Rs.basename(d)),S=i.find(x=>xi({rel:Rs.relative(x.real,E)}));return S?"slug"in S?{root:S.root,rel:Rs.relative(S.real,E),repository:S.slug,dir:S.name,ambiguous:m,exists:p}:{...f(m),rel:Rs.relative(S.real,E)}:f(m)},l=new Map;return u=>l.get(u)??l.set(u,c(u)).get(u)}function e5(e,t){let r=[],n=new Set;return{added:e.flatMap(i=>{let o=i;if(!i.repository){let c=t(i.manifest.trim());c.ambiguous&&r.push(i.manifest),c.repository&&c.exists&&xi(c)&&(o={...i,manifest:c.rel,repository:c.repository})}let a=`${Du(o.repository,o.manifest)}\0${o.package.trim()}`;return n.has(a)?[]:(n.add(a),[o])}),ambiguous:r}}var IMe=(e,t=[])=>!e.tests.some(r=>(r.change==="added"||r.change==="updated")&&(r.ci?.collected===!1||t.includes(r.file)));function t5(e,t,r=[],n=[]){let s=n.filter(I=>I.verdict==="disproved").map(I=>I.file),i=[e.ciNotes?.trim(),s.length?`The repo's CI listing does not name ${s.join(", ")}.`:void 0].filter(Boolean).join(" "),o=[],a=[],c=[],l=new Set,u=La(t,r),d=new Map,p=[],f=I=>Du(I.repository,I.file);for(let I of e.tests){let T=u(I.file),{root:P,rel:R,repository:Q,dir:J}=T;if(T.ambiguous&&a.push(I.file),!xi(T)){o.push(I.file);continue}if(I.change!=="deleted"&&!T.exists){o.push(I.file);continue}let z={...I,file:R,shown:J?`${J}/${R}`:R,...Q?{repository:Q}:{}};l.has(f(z))||(l.add(f(z)),d.set(f(z),P),c.push(z),p.push({written:I.file,root:P,file:R,...Q?{repository:Q}:{}}))}let m=c.map(I=>{let T=qQt[I.change];return{...T==="place"?{from:I.shown}:{},file:I.file,...I.repository?{repository:I.repository}:{},action:T,covers:I.covers,...I.defect&&GQt(I)?{finding:!0}:{},reran:{exit:I.result.exit,details:I.result.details,tests:I.result.cases},...I.isolatedRun?{isolatedRun:I.isolatedRun}:{},...T==="delete"?{}:{assertionCount:D6(d.get(f(I)),I.file,XQe)}}}),g=I=>({schemaVersion:1,tests:c.filter(T=>T.kind===I&&T.change==="added").map(T=>({file:T.shown,source:X6(T).length?"skyramp":"llm",language:$h(T.file)??"unknown",covers:T.covers,assertions:T.assertions??[],...T.context?.length?{context:T.context}:{}})),deferredUi:[],summary:e.report.summary}),w=e5(e.dependenciesAdded??[],u);a.push(...w.ambiguous);let A=(e.supportFiles??[]).flatMap(I=>{let T=u(I);return T.ambiguous&&a.push(I),!xi(T)||!T.exists?(o.push(I),[]):[{file:T.rel,...T.repository?{repository:T.repository}:{}}]}),E=e.lint?.command?.trim()??"",S=e.lint?.clean??!0,x={schemaVersion:1,lint:E?[{tool:E.split(/\s+/)[0],command:E,clean:S,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:IMe(e,s),...!IMe(e,s)&&i?{notes:i}:{}},dependencies:{added:w.added},...A.length?{support:A}:{},commit:{message:Y6(e.commit.message)},pr:{title:Y6(e.commit.prTitle).split(`
313
313
  `)[0],body:e.commit.prBody},ready:S,blockers:S?[]:[`the linter (${E||"the repo's linter"}) still reports problems in the test files`],summary:e.report.summary};return{adapt:{schemaVersion:1,items:m,ignored:[],summary:e.report.summary},generate:g("backend"),generateUi:g("ui"),finalize:x,dropped:o,ambiguous:a,placed:p}}function r5(e){let t=[...new Set([...e.tests,...e.maintained??[]].map(o=>o.file))],r=`${t.length} unit test file(s): ${t.join(", ")}`,n=Y6(e.commitMessage?.trim()||"Skyramp Testbot: add unit tests"),s=e.lint?.command?.trim()??"",i=e.lint?.clean??!0;return{schemaVersion:1,lint:s?[{tool:s.split(/\s+/)[0],command:s,clean:i,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:!0},dependencies:{added:[]},commit:{message:n},pr:{title:n.split(`
@@ -315,7 +315,7 @@ ${m}`);g.length&&d.push(`stubs the app's network (${g.join(", ")}); a journey te
315
315
  `).slice(1).join(`
316
316
  `).trim()||r},ready:i,blockers:i?[]:[`the linter (${s||"the repo's linter"}) still reports problems in the test files`],summary:r}}function n5(e,t,r){let n=new Map,s=new Map;for(let a of r.requirements){s.set(a.id,a);for(let c of a.clauses)s.set(c.id,a)}let i=a=>{let c=a?s.get(a):void 0;c&&n.set(c.id,c)},o=a=>a?r.findings.find(c=>c.id===a)?.conflictsWith??[]:[];for(let a of e.requirements??[])i(a);for(let a of o(e.finding))i(a);if(n.size)return n;for(let a of e.tests??[]){let c=t.tests.find(u=>YQ(u.file,a));if(!c)continue;let l=new Set(c.result.cases.filter(u=>u.status==="fail").map(u=>u.case));for(let u of c.covers.filter(d=>!l.size||l.has(d))){let d=r.cases.find(p=>p.id===u);if(!d){i(u);for(let p of o(u))i(p);continue}for(let p of[d.clause,...o(d.finding)])i(p)}}return n}function jQt(e,t,r,n=[],s){let i=n5(e,t,r),o=n.filter(p=>p.body.trim()),a=p=>p.source==="spec"||p.source==="requirement-reference"&&p.reference?.trim()?!0:p.source==="requirement-reference"?!1:RMe(p,o)!==void 0,c=[...i.values()].filter(a).slice(0,2),l=[...new Set(c.filter(p=>p.source==="requirement-reference").map(p=>Co(p.reference,p.criterion,s)))],u=new Map;for(let p of c.filter(f=>f.source==="pr-description")){let f=RMe(p,o);f&&u.set(f,[...u.get(f)??[],WQt(p.evidence)])}let d=c.filter(p=>p.source==="spec").map(p=>p.evidence.trim());return[...l,...[...u].map(([p,f])=>`${p}, which says ${f.join(" and ")}`),...d.length?[`the spec (${d.join("; ")})`]:[]]}function RMe(e,t){let r=yC(e.evidence);if(r===void 0)return;if(!t.length)return VQt(e.evidence);let n=t.find(s=>JQt(r,s.body));return n?CS(n):void 0}var HQt=/(?:^|[\s(\[,;`])((?:[\w.@-]+\/)*[\w.@-]+\.([A-Za-z][A-Za-z0-9]{0,9})(?::\d+(?:-\d+)?)?)(?=[\s),;:#\]`]|\.(?:\s|$)|$)/,zQt=new Set(["md","mdx","markdown","rst","adoc","asciidoc"]);function VQt(e){let t=e.match(QMe),r=t?.index??0,s=(t?`${e.slice(0,r)} ${e.slice(r+t[0].length)}`:e).replace(/\b[a-z][\w+.-]*:\/\/\S+/gi," ").match(HQt);return s&&zQt.has(s[2].toLowerCase())?s[1]:void 0}function WQt(e){let t=yC(e);return t!==void 0?`"${t}"`:e.trim()}function JQt(e,t){let r=Ro(t),n=Ro(e).split(/\.\.\.|\u2026/).map(s=>s.trim()).filter(s=>s.length>=3);return n.length>0&&n.every(s=>r.includes(s))}var QMe=/["\u201c]([^"\u201d]{3,300})["\u201d]|(?:^|[\s:(\[])['\u2018]([^\n]{3,300}?)['\u2019](?=[\s.,;:)\]]|$)/;function yC(e){let t=e.match(QMe);return t?(t[1]??t[2]).trim():void 0}function MMe(e,t,r=[],n){return{schemaVersion:1,businessCaseAnalysis:e.report.summary,issuesFound:e.report.issues.map(s=>({description:XQt(KQt(s.description,s.tests??[]),t?jQt(s,e,t,r,n):[]),severity:s.severity,category:"bug",sourceFile:s.sourceFile,sourceLine:s.sourceLine,...YQt(s,t)})),nextSteps:e.report.nextSteps}}function YQt(e,t){let r=e.finding&&(!t||t.findings.some(s=>s.id===e.finding))?e.finding:void 0,n=e.requirements?.length?e.requirements:r?t?.findings.find(s=>s.id===r)?.conflictsWith:void 0;return{...r?{findingId:r}:{},...n?.length?{requirementIds:[...n]}:{}}}function KQt(e,t){let r=t.filter((n,s)=>!KQ(e,n)&&!t.slice(0,s).some(i=>YQ(i,n)));return r.length?`${e} (shown by ${r.join(", ")})`:e}function XQt(e,t){let r=t.filter(n=>!e.includes(n.replace(/^.*?, which says /,"")));return r.length?`${e}. This contradicts ${r.join(" and ")}.`.replace(/\.\. /,". "):e}function wT(e){let t=new Map;for(let n of e.requirements??[]){t.set(n.id,n);for(let s of n.clauses??[])t.set(s.id,n)}let r=new Map;for(let[n,s]of t)s.source==="could-break"&&r.set(n,s.id);for(let n of e.cases??[]){let s=n.clause?t.get(n.clause):t.get(n.id);!n.finding&&s?.source==="could-break"?r.set(n.id,s.id):r.delete(n.id)}return r}function ZQt(e,t){let r=wT(e),n=new Set((e.journeys??[]).flatMap(a=>[a.id,...a.steps.flatMap(c=>c.clauses??[])].map(c=>c.trim()))),s=new Map,i=new Set;for(let a of n)r.has(a)&&i.add(r.get(a));for(let a of t.tests)if(!(a.change==="deleted"||a.change==="unchanged"))for(let c of a.result.cases){let l=r.get(c.case);!l||n.has(c.case.trim())||(c.status==="pass"?s.set(l,[...s.get(l)??[],{file:a.file,case:c.case}]):i.add(l))}let o=[];for(let[a,c]of s)for(let l of i.has(a)?c:c.slice(1))o.push(`${l.file}: case ${l.case} checks what the change could break (${a}), passes, and another of your tests already covers ${a} \u2014 remove its test and list the case under notWritten with a reason that starts "Passing:" and says what it checked; a passing test of what the change could break stays only when it is the one test of its requirement`);return o}var s5="write-could-break";function FMe(e){return{name:s5,verify(t,r){let n=me(t,"plan.json"),s=e(t,r);if(!n||!s)return{name:this.name,passed:!0};let i=ZQt(n,s);return i.length?{name:this.name,passed:!1,details:i.join("; "),repairable:!0}:{name:this.name,passed:!0}}}}var zMe=require("child_process"),wC=X(require("fs")),Ua=X(require("path"));var UMe=(n=>(n.Requirement="requirement",n.PrDescription="pr_description",n.Code="code",n))(UMe||{}),Ii=y.string().trim().min(1),eMt=y.object({expectation:Ii.max(300).describe("the behavior this assertion pins, in words"),source:y.nativeEnum(UMe),expected:Ii.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),tMt=y.object({file:Ii.describe("path of the NEW test file you wrote, relative to its repository"),repository:Ii.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:Ii.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:lC.optional().describe(`for ${uC}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:y.array(Ii).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:y.array(Ii).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:y.array(eMt).min(1)}),PF=(r=>(r.Updated="updated",r.Deleted="deleted",r))(PF||{}),LMe=300,rMt=y.object({file:Ii.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:Ii.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:y.nativeEnum(PF),staleBecause:y.object({requirement:Ii.describe("the requirement or clause id the change deliberately alters"),line:Ii.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:y.preprocess(e=>typeof e=="string"?e.trim().slice(0,LMe):e,Ii.max(LMe)).describe("what the change deliberately altered that made the test wrong")}),bT=y.object({schemaVersion:y.literal(1),tests:y.array(tMt),maintained:y.array(rMt).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:y.array(y.object({id:Ii,reason:Ii.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:y.array(RF).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:y.array(y.object({journey:Ii,missing:Ii.transform(e=>e.length>300?`${e.slice(0,299)}\u2026`:e)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:y.object({command:y.string(),clean:y.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:Ii.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var $Me=require("child_process"),DF=X(require("path")),EC="maintenance-flags.json",qMe=3;function i5(e){let t=e.trim().match(/^(.+):(\d+)$/);return t?{file:t[1].replace(/^\.\//,""),line:Number(t[2])}:void 0}function nMt(e,t){return e.split(/[^A-Za-z0-9_.-]+/).filter(r=>t.has(r))}function OF(e,t){let r=[];for(let n of e){let s=n.staleBecause;if(!s){r.push(`${n.file} is an existing test you changed: give staleBecause \u2014 the requirement the change deliberately alters, and the changed line of application code (path:line) that alters it \u2014 or, if the change is wrong there, restore the test, leave it failing and report it`);continue}nMt(s.requirement,t.requirementIds).length||r.push(`${n.file}: staleBecause names "${s.requirement}", and no requirement or clause id of the plan is in it`);let i=i5(s.line),o=(i?.file??s.line.trim().replace(/^\.\//,"")).replace(/:\d+$/,""),a=t.changedLines.get(o);(!a||i&&a.size>0&&![...a].some(c=>Math.abs(c-i.line)<=qMe))&&r.push(`${n.file}: ${s.line} is not code this change altered, so the change does not replace what the test asserts`)}return r}function GMe(e,t){let r=new Map;for(let n of e){let s=n.staleBecause?i5(n.staleBecause.line):void 0;if(!s)continue;let i=[...t.defectLines].find(([a])=>{let c=i5(a);return c&&c.file===s.file&&Math.abs(c.line-s.line)<=qMe});if(!i)continue;let o=r.get(i[1])??{at:i[0],files:[]};o.files.includes(n.file)||o.files.push(n.file),r.set(i[1],o)}return[...r].map(([n,{at:s,files:i}])=>{let o=i.length>3?`${i.slice(0,3).join(", ")} and ${i.length-3} more`:i.join(", ");return`${i.length===1?"An existing test was":`${i.length} existing tests were`} updated for a change at ${s}, where the plan also found defect ${n} (${o}): check the updates do not hide it.`})}function jMe(e,t){let r=[],n=o=>o.trim().replace(/^\.\//,""),s=new Map(t.map(o=>[n(o.file),o])),i=new Set(e.map(n));for(let o of t)(o.changed||i.has(n(o.file)))&&!o.ran&&r.push(`${o.file} is an existing test you changed and did not run: re-run it and record its result`);for(let o of i)s.has(o)||r.push(`${o} is an existing test you changed and is not in your result: re-run it and list it with its result`);return r}function sMt(e,t=""){let r=new Map,n,s;for(let i of e.split(`
317
317
  `)){let o=i.match(/^--- a\/(.+)$/);o&&(s=o[1]);let a=i.match(/^\+\+\+ b\/(.+)$/);if(a){n=t+a[1];continue}if(i.startsWith("+++ /dev/null")){s&&!r.has(t+s)&&r.set(t+s,new Set),n=void 0;continue}let c=i.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/);if(!c||!n)continue;let l=Number(c[1]),u=c[2]===void 0?1:Number(c[2]),d=r.get(n)??new Set;for(let p=l;p<l+Math.max(u,1);p++)d.add(p);r.set(n,d)}return r}function QF(e,t){return o5([{path:e.repositoryPath,base:t,related:!1},...(e.relatedRepos??[]).map(r=>({path:r.path,base:r.base??"origin/main",related:!0}))])}function o5(e){let t=new Map;for(let r of e){let n="";try{n=(0,$Me.execFileSync)("git",["-C",r.path,"diff","-U0","--no-color",`${r.base}...HEAD`],{encoding:"utf-8",maxBuffer:64*1024*1024})}catch{continue}let s=r.related?`${DF.basename(DF.resolve(r.path))}/`:"";for(let[i,o]of sMt(n,s))t.set(i,o)}return t}function FF(e){let t=/^(.*?)(?:^|\/)__snapshots__\/([^/]+)\.snap$/.exec(e);return t?`${t[1]?`${t[1]}/`:""}${t[2]}`:e}var ia="generate-unit.json";function iMt(e){let{value:t,error:r}=Cn(e);if(r)return{errors:[r]};let{value:n,errors:s}=ts(bT,t);return s.length?{errors:s}:{output:n,errors:[]}}function xy(e){return iMt(e.stdout)}var VMe=Vi("generate-unit-schema",(e,t)=>xy(t)),oMt=/(^|\/)(__pycache__|\.pytest_cache|node_modules|coverage|\.vitest)(\/|$)|\.pyc$/;function a5(e){let t="";try{t=(0,zMe.execFileSync)("git",["status","--porcelain","--untracked-files=all"],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return{modified:[],added:[]}}let r=[],n=[];for(let s of t.split(`
318
- `)){if(!s.trim())continue;let i=s.slice(3).trim().replace(/^"|"$/g,"");oMt.test(i)||i.startsWith(".skyramp/")||(s.startsWith("??")?n:r).push(i)}return{modified:r,added:n}}var MF=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,aMt=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${MF}["']|\bimport\s+["']${MF}["']|require\(\s*["']${MF}["']\s*\)|\bimport\(\s*["']${MF}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];function LF(e){return aMt.filter(([t])=>t.test(e)).map(([,t])=>t)}var cMt=/@playwright\/test|\bfrom\s+playwright\b|\bimport\s+playwright\b|["']playwright["']|\bselenium\b|\bpuppeteer\b|\bcypress\b|\bwebdriverio\b|\bpage\.goto\s*\(/;function WMe(e){return LF(e).length===0&&!cMt.test(e)}function lMt(e){let t=[],r=/\b(?:test|it|describe)(?:\.\w+)*\(\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1/g;for(let n=r.exec(e);n;n=r.exec(e))t.push(n[2]);return t}function uMt(e){let t=[],r=/(["'`])((?:\\.|(?!\1)[^\\\n])*)\1/g;for(let n=r.exec(e);n;n=r.exec(e))n[2].trim()&&t.push(n[2]);return t}function dMt(e,t,r,n){if(!$u(e)){let i=n.replace(/(?:\[[^\]]*\]|\([^)]*\)|<[^>]*>)+$/,"").split(/::|#/).pop().trim(),a=(/\s/.test(i)?i:i.split(".").pop()).replace(/\/.*$/,"").trim();return a&&t.includes(a)?!0:uMt(t).some(c=>n===c||n.endsWith(` ${c}`))}if(e==="pytest"){let s=n.split("::").pop().replace(/\[.*\]$/,"");return new RegExp(`\\bdef\\s+${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`).test(t)}return/\.each\s*[(`]/.test(t)?!0:r.some(s=>s&&(n===s||n.endsWith(` ${s}`)))}function pMt(e,t,r=[],n=[],s=new Set){let i=[],o=new Set(e.tests.flatMap(p=>p.covers)),a=new Set((e.journeysNotWritten??[]).map(p=>p.journey.trim()));for(let p of n)!o.has(p)&&!a.has(p)&&i.push(`journey "${p}" has no test and is not in journeysNotWritten \u2014 walk it in one in-process test, or say in journeysNotWritten what it needs that is missing`);let c=new Set((e.defectsNotTested??[]).map(p=>p.id));for(let p of r)!o.has(p)&&!c.has(p)&&i.push(`defect "${p}" has no test and is not in defectsNotTested \u2014 give it a test that reaches it and expects the correct behaviour, or say in defectsNotTested why no in-process test can`);for(let p of e.defectsNotTested??[])r.includes(p.id)||i.push(`defectsNotTested names "${p.id}", which is not a defect the plan found (${r.join(", ")||"none"})`);let l=[...t,...r,...n];for(let p of t)!o.has(p)&&!s.has(p)&&i.push(`behavior "${p}" was planned a new unit test and no file covers it \u2014 every planned new unit test is written`);for(let p of e.tests)for(let f of p.covers)l.includes(f)||i.push(`${p.file}: covers "${f}", which is neither a behavior planned a new unit test nor a defect the plan found (${l.join(", ")||"none"})`);let u=new Set(e.tests.flatMap(p=>p.names.map(f=>`${p.file}::${f.replace(/\[.*\]$/,"")}`))),d=Math.max(2,2*l.length);return u.size>d&&i.push(`${u.size} test functions for ${l.length} planned item(s) \u2014 write the fewest tests that obtain the planned missing evidence (at most ${d}), one focused test per planned item`),i}var fMt=/(^|\/)(fixtures?|__fixtures__|testdata|test_data|data|snapshots?|__snapshots__|mocks?|__mocks__)\//i;function HMe(e,t){if(fMt.test(t))return!1;let r=Uu(e,t);return r?zS(r,t):qu(t)}function hMt(e,t){let r=[],n=new Set(e.map(a=>a.file).filter(a=>t.modified.includes(a)&&HMe(t.repo,a))),s=new Set([...t.maintained??[],...n]);for(let a of t.modified)/(^|\/)__snapshots__\/[^/]+\.snap$/.test(a)&&s.has(FF(a))||(s.has(a)?HMe(t.repo,a)||r.push(`${a} is listed in "maintained" but is not a test file \u2014 source and fixtures stay as they are`):r.push(`${a} was changed \u2014 change only existing tests the change made stale, each listed in "maintained"; source and fixtures stay as they are`));let i=new Set(e.map(a=>a.file)),o=new Set(t.addedBefore??[]);for(let a of t.added)!i.has(a)&&!o.has(a)&&r.push(`${a} was added but is not a test in tests[] \u2014 write only new test files, and declare each one`);for(let a of e){let c=Ua.resolve(t.repo,a.file);if(!Gs(t.repo,a.file)){r.push(`${a.file} is outside the repository \u2014 write only new test files, in the repository`);continue}if(!wC.existsSync(c)){r.push(`${a.file} does not exist`);continue}!t.added.includes(a.file)&&!n.has(a.file)&&r.push(`${a.file} is not a new file \u2014 write only new test files`);let l=Wi(t.repo,a.file),u=$u(a.framework)||l!==void 0,d=$u(a.framework)?a.framework:l?.framework??Uu(t.repo,a.file);if(u)$u(a.framework)&&!zS(a.framework,a.file)&&r.push(`${a.file} is not named the way ${a.framework} discovers tests \u2014 follow the repository's test naming`),l?.framework!==a.framework&&r.push(`${a.file} is ${a.framework}, but the repository runs it with ${l?.framework??"no test framework we can run"} \u2014 use the framework the repository already uses`),l?.wrappedBy&&(a.run?r.push(...Fp(t.repo,a.run).map(A=>`${a.file}: its run ${A}`)):r.push(`${a.file}: the repository runs its ${l.framework} tests with \`${l.wrappedBy}\`, not ${l.framework} itself \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`));else{a.run?r.push(...Fp(t.repo,a.run).map(E=>`${a.file}: its run ${E}`)):r.push(`${a.file} is ${a.framework}, which the run has no adapter for \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`);let A=d?t.testAffixes?.get(d):void 0;A?.size&&!A.has($0(a.file))&&r.push(`${a.file} is not named like the repository's existing ${d} tests (${[...A].join(", ")}) \u2014 follow the repository's test naming`)}let p=Ua.dirname(a.file).split(Ua.sep).join("/")||".",f=d&&t.testDirs.get(d)||new Set,m=t.placedDir;m!==void 0?m!=="."&&p!==m&&!p.startsWith(`${m}/`)&&r.push(`${a.file} is not in ${m}, where the Target puts unit tests for this repository`):mMt(t.repo,p,f,a.file)||r.push(`${a.file} is not beside any existing ${u?a.framework:`${a.framework} (${d})`} test (${[...f].join(", ")||"none found"}) \u2014 place each test beside the existing tests`);let g=wC.readFileSync(c,"utf-8"),w=lMt(g);for(let A of a.names)dMt(a.framework,g,w,A)||r.push(`${a.file} declares test "${A}", which is not in the file \u2014 names lists the test functions`);for(let A of LF(g))r.push(`${a.file} uses ${A} \u2014 a unit test runs in one process: no network, no running app; mock with the framework's own tools inside the test`)}return r}function mMt(e,t,r,n){if(r.has(t))return!0;let s=o=>{let a=o.split("/"),c=a.findIndex(l=>gMt.test(l));return c<0?void 0:a.slice(0,c+1).join("/")},i=s(t);if(i&&[...r].some(o=>s(o)===i))return!0;if([...r].some(o=>s(o)===void 0)){let o=Ua.extname(n);try{return wC.readdirSync(Ua.join(e,t)).some(a=>Ua.extname(a)===o&&!qu(a))}catch{return!1}}return!1}var gMt=/^(tests?|spec|specs|__tests__|e2e|testing|integration_tests?)$/i;function AMt(e,t){return JMe(e,t,r=>Ua.dirname(r).split(Ua.sep).join("/")||".")}function yMt(e,t){return JMe(e,t,$0)}function JMe(e,t,r){let n=new Map;for(let s of t){let i=Uu(e,s);!i||!$u(i)&&!qu(s)||(n.has(i)||n.set(i,new Set),n.get(i).add(r(s)))}return n}function sm(e){return me(e,"triage.json")?.decision!=="targeted_unit"?[]:(me(e,"analyze.json")?.findings??[]).filter(r=>r.status!=="refuted"&&r.status!=="latent").map(r=>({id:r.id,claim:r.claim,file:r.file,line:r.line,repository:r.repository,severity:r.severity,...r.conflictsWith?.length?{conflictsWith:r.conflictsWith}:{}}))}function zu(e){return me(e,"triage.json")?.decision!=="targeted_unit"?[]:rm(me(e,"plan.json")?.journeys).filter(t=>t.kind==="in-process")}function ST(e){let t=me(e,"triage.json");return[...new Set((t?.plan??[]).filter(r=>r.mechanism==="new_unit").map(r=>r.behaviorId))]}var YMe={name:"generate-unit-grounded",verify(e,t){let{output:r}=xy(t);if(!r)return{name:this.name,passed:!0};let n=e.prepared,s=zu(e),i=me(e,"plan.json"),o=pMt(r,ST(e),sm(e).map(c=>c.id),s.map(c=>c.id),i?new Set(wT(i).keys()):new Set);s.length&&o.push(...kF(AT(s,{journeys:r.journeys,tests:r.tests,notWritten:(r.journeysNotWritten??[]).map(c=>({case:c.journey,reason:c.missing}))},Nc(e.inputs.repositoryPath,e.inputs.relatedRepos??[]))));for(let c of r.tests){let l=Oh(e.inputs,c.repository);"error"in l&&o.push(`${c.file}: ${l.error}`)}for(let c of Dt(e.inputs).filter(l=>l.writable)){let l=r.tests.filter(g=>dn(e.inputs,g.repository)?.path===c.path),u=(r.maintained??[]).filter(g=>dn(e.inputs,g.repository)?.path===c.path).map(g=>g.file),d=n?.checkouts?.[c.slug],{modified:p,added:f}=a5(c.path),m=cr(e.inputs,c.slug);o.push(...hMt(l,{repo:c.path,testDirs:AMt(c.path,d?.existingTests??[]),testAffixes:yMt(c.path,d?.existingTests??[]),modified:p,added:f,maintained:u,addedBefore:d?.addedBefore,placedDir:cy(e.inputs,c.slug,"unit")}).map(g=>`${m}${g}`))}let a=(r.maintained??[]).filter(c=>c.change==="updated");if(a.length){let c=me(e,"plan.json"),l=me(e,"analyze.json"),u=new Set([...(c?.requirements??[]).flatMap(f=>[f.id,...(f.clauses??[]).map(m=>m.id)]),...(l?.behaviors??[]).map(f=>f.id),...(l?.requirements??[]).map(f=>f.id)]),d=sn(e)?.repository.baseBranch??e.inputs.baseBranch??"origin/main",p=o5([{path:e.inputs.repositoryPath,base:d,related:!1},...(e.inputs.relatedRepos??[]).map(f=>({path:f.path,base:f.base??"origin/main",related:!0}))]);o.push(...OF(a,{requirementIds:u,changedLines:p,defectLines:new Map}))}return o.length?{...ar(this.name,o),repairable:!0}:{name:this.name,passed:!0}}};function KMe(e,t){if(!t.some(n=>n.gates.some(s=>!s.passed&&/secrets|checkout-intact/.test(s.name))))for(let n of[...t].reverse()){if(!n.session)continue;let{output:s,errors:i}=xy(n.session);if(s)return Kr(e,"generate-unit",s,i)}}function XMe(e,t){let{output:r,errors:n}=xy(t);return Kr(e,"generate-unit",r,n)}var UF="native-run.json",Nl=e=>me(e,UF),c5="no selected unit test ran";function $F(e){if(e.results.some(n=>n.status==="Pass"||n.status==="Fail"))return;let t=new Set([...e.results.map(n=>`${n.file}\0${n.selectedName??n.name}`),...e.notRun.map(n=>`${n.file}\0${n.name??""}`)]).size;if(!t)return;let r=e.notRun.length?[...new Set(e.notRun.map(n=>n.reason))]:["every test that reported was skipped"];return`${c5} (${t} selected): ${r.slice(0,3).join("; ").slice(0,600)}`}var CT=e=>e.name==="native-run"&&e.status==="failed"&&!!e.reason?.includes(c5),l5=e=>e.origin==="written"||!!e.written;function ZMe(e,t){let r=e.inputs?.unitPath==="write"&&t.decision==="targeted_unit",n=t.plan.filter(i=>i.mechanism==="existing_unit"||i.mechanism==="new_unit"&&!r),s=r?EMt(e,t.plan.filter(i=>i.mechanism==="new_unit")):[];return n.length===0?s:[...new Set([...s,...wMt(e,n)])]}function EMt(e,t){if(!t.length)return[];let r=me(e,"write.json");if(!r)return["the planned unit tests were not written (write did not finish)"];let n=new Set((Nl(e)?.results??[]).filter(i=>l5(i)&&!i.fromFile&&(i.status==="Pass"||i.status==="Fail")).flatMap(i=>i.behaviorIds)),s=[];for(let i of t){let o=r.tests.filter(c=>c.covers.includes(i.behaviorId)),a=o.some(c=>c.result.cases.some(l=>l.case===i.behaviorId&&(l.status==="pass"||l.status==="fail"))||!c.result.cases.length&&c.result.exit!==null&&c.covers.every(l=>l===i.behaviorId));o.length?!n.has(i.behaviorId)&&!a&&s.push(`${i.behaviorId}: no new unit test for it produced a result`):s.push(`${i.behaviorId}: no new unit test was written${i.covers?` for ${i.covers}`:""}`)}return s}function wMt(e,t){let r=e.state.stages["native-run"],n=Nl(e),s=r?.status==="failed"&&!!r.reason?.includes(c5);if(r?.status!=="passed"&&!s||!n)return[`the planned unit tests did not run${r?.reason?` (${r.reason})`:r?` (${r.status})`:""}`];let i=n.notRun.filter(d=>d.origin!=="written").map(d=>`${d.file}${d.name?`::${d.name}`:""} did not run: ${d.reason}`),o=(d,p)=>new Set(n.results.filter(f=>f.origin===d&&(f.status==="Pass"||f.status==="Fail")===p).flatMap(f=>f.behaviorIds)),a={existing:o("existing",!0),generated:o("generated",!0)},c={existing:o("existing",!1),generated:o("generated",!1)},l=me(e,ia),u=new Set((l?.tests??[]).flatMap(d=>d.covers));for(let d of t)if(d.mechanism==="new_unit"&&!u.has(d.behaviorId))i.push(`${d.behaviorId}: no new unit test was written${d.covers?` for ${d.covers}`:""}`);else{let p=d.mechanism==="new_unit"?"generated":"existing",f=p==="generated"?"new":"existing";a[p].has(d.behaviorId)||i.push(c[p].has(d.behaviorId)?`${d.behaviorId}: every ${f} unit test for it was skipped`:`${d.behaviorId}: no ${f} unit test for it produced a result`)}return[...new Set(i)]}var eFe=X(require("fs")),im=X(require("path"));var u5={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"},tFe=e=>u5[e].toLowerCase(),vT=e=>e.source==="other"&&!e.file,Ts=e=>new Map((e??[]).flatMap(t=>t.file?[[nn(t.key),t.file.name]]:[])),rFe=10*1024*1024,Iy=e=>e?.mediaType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"||e?.mediaType==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",nFe=(e,t)=>im.join(im.dirname(e),`${im.basename(e,im.extname(e))}${t}`),Ry=e=>nFe(e,".extracted.txt");function d5(e){try{return/\S/.test(eFe.readFileSync(Ry(e),"utf-8"))}catch{return!1}}var p5=e=>nFe(e,".quotes.txt");function sFe(e){return Iy(e.file)?Ry(e.path):e.file?.mediaType==="application/pdf"?p5(e.path):e.path}function qF(e){return e.map(t=>t.state!=="read"||!Iy(t.file)||d5(t.path)?t:{...ku(t),file:t.file,state:"not_read",reason:"cannot_open"})}function iFe(e,t){let r=Ts(t),n=[],s=[],i=new Set;for(let o of e.sources??[]){let a=o.reference?t.find(c=>nn(c.key)===nn(o.reference)):void 0;a?.state==="read"&&o.criterion?(n.push(Co(a.key,o.criterion,r)),s.push({...ku(a),criterion:o.criterion,version:a.version}),i.add(vT(a)?0:1)):o.spec?.trim()&&(n.push(o.spec.trim()),i.add(2))}return{labels:n,criteria:s,sameRank:i.size===1}}var oFe=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function aFe(e,t=[]){return(e??[]).map(r=>{let{labels:n,criteria:s,sameRank:i}=iFe(r,t),o=n.length>1?` ${oFe(n)} disagree${i?", and they rank the same":""}.`:"";return{description:`Open question${r.about?` (${r.about})`:""}: ${r.question} Readings: ${r.readings.join("; ")}.${o} No test asserts any of them until you decide.`,severity:"low",category:"open_question",...r.about?{requirementIds:[r.about]}:{},...s.length?{requirements:s}:{}}})}function f5(e,t=[]){return(e??[]).flatMap(r=>{let{labels:n}=iFe(r,t);return n.length<2?[]:[`${r.about??r.id}: ${oFe(n)} disagree (${r.id}), so only what they all allow was tested`]})}function cFe(e,t=[]){if(!e?.length)return;let r=e.map(s=>s.id).join(", "),n=f5(e,t).length?"in the PR description or a spec, or, where sources disagree, in the next run's Run Context or by correcting the source that is wrong":"in the PR description or a spec";return`Decide the open question${e.length>1?"s":""} listed under issues (${r}) and say which reading is meant ${n}; the next run then tests it.`}var Ty=X(require("fs")),Ri=X(require("path"));var bMt=/"(?:@testing-library\/(?:react|vue|svelte|angular|preact|dom|user-event)|jsdom|happy-dom|@vue\/test-utils|enzyme|react-test-renderer)"\s*:/,GF=e=>{try{return Ty.statSync(e).size<1e6?Ty.readFileSync(e,"utf-8"):""}catch{return""}};function h5(e,t){let r=Ri.resolve(e),n=Ri.dirname(Ri.resolve(r,t));if(Ri.relative(r,n).startsWith(".."))return!1;for(;;){if(bMt.test(GF(Ri.join(n,"package.json"))))return!0;if(n===r)return!1;n=Ri.dirname(n)}}var m5=/(^|\/)(e2e|cypress|playwright|selenium)\/|\.(cy|e2e)\.[cm]?[jt]sx?$/i,dFe=/["']@playwright\/test["']|["']cypress["']|\bcy\.(?:visit|request)\(|\b(?:from|import)\s+selenium\b|\bfrom\s+playwright\b|\bwebdriverio\b|\bpuppeteer\b|\bApplicationSystemTestCase\b/,pFe=/\b(?:Static|Channels)?LiveServerTestCase\b|\blive_server\b/,SMt=/["']@skyramp\/skyramp["']|\b(?:from|import)\s+skyramp\b/,CMt=/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0)[:/]|\b(?:BASE_URL|API_URL|APP_URL|SUT_URL|baseURL|base_url)\b/,vMt=/\b(?:requests|httpx|aiohttp|urllib|axios|fetch|got|superagent|HttpClient|RestAssured|Faraday|Net::HTTP)\b/,xMt=/\b(?:jest\.mock|vi\.mock|nock|msw|setupServer|responses|respx|requests_mock|httpretty|fetchMock|fetch-mock|MockAdapter|WebMock|mock\.patch)\b/,IMt=/\b(?:BASE_URL|API_URL|APP_URL|SUT_URL)\b/;function g5(e,t){let r=t.split("::")[0].trim().replace(/\\/g,"/"),n=GF(Ri.resolve(e,r));if(!(pFe.test(n)&&!IMt.test(n))){if(dFe.test(n)||m5.test(r))return"a browser test of the running app";if(SMt.test(n)||CMt.test(n)&&vMt.test(n)&&!xMt.test(n))return"a test that calls the running app"}}function fFe(e,t){let r=t.split("::")[0].trim().replace(/\\/g,"/"),n=GF(Ri.resolve(e,r));return dFe.test(n)||m5.test(r)?"ui":g5(e,r)?"integration":n&&Wi(e,r)?"unit":void 0}var RMt=/\b(?:from|import)\s+(?:selenium|playwright)\b/,lFe={depth:6,files:2e3},hFe=e=>{if(!e.endsWith(".py"))return!1;let t=GF(e);return pFe.test(t)&&RMt.test(t)};function TMt(e){let t=lFe.files,r=(n,s)=>{let i;try{i=Ty.readdirSync(n,{withFileTypes:!0})}catch{return!1}for(let o of i){if(--t<0)return!1;let a=Ri.join(n,o.name);if(o.isFile()&&hFe(a)||o.isDirectory()&&s>0&&!o.name.startsWith(".")&&o.name!=="node_modules"&&r(a,s-1))return!0}return!1};return r(e,lFe.depth)}function uFe(e,t){let r=Ri.resolve(e),n=t.split("::")[0].trim().replace(/\\/g,"/").replace(/\/+$/,""),s=Ri.resolve(r,n);if(!n||Ri.relative(r,s).startsWith(".."))return!1;let i;try{i=Ty.statSync(s).isDirectory()}catch{return!1}return(i?TMt(s):hFe(s))?!0:m5.test(`${n}${i?"/":""}`)?!1:h5(r,i?Ri.join(n,"_"):n)}var kMt=/\b(?:selenium|playwright|webdriver|cypress|browser|live[_ -]?server|headless|jsdom|happy-dom|fireEvent|userEvent|user-event|find_element|clicks|presses|types into|drags|hovers|focuses|scrolls)\b|\.click\(|\bsend_keys\b/i,BMt=/\b(?:test client|self\.client|client\.(?:get|post)|assertContains|assertInHTML|response\.content|request-level|markup|html|css class|class(?:es)?|attributes?|rendered|renders|template)\b/i;function NMt(e){let t=e.filter(r=>!!r?.trim());if(!(!t.length||t.some(r=>kMt.test(r))))return t.every(r=>BMt.test(r))?t[0].trim().slice(0,160):void 0}function _Mt(e){return new Set(e.filter(t=>t.mechanism==="existing_unit"||t.mechanism==="new_unit").map(t=>t.behaviorId))}function mFe(e,t){let r=_Mt(t);return e.action==="verify"&&!!e.clauses?.length&&e.clauses.every(n=>r.has(n))}function gFe(e,t,r){return!e?.maintenance||!t?new Set:new Set(e.maintenance.filter(n=>mFe(n,t.plan)).filter(n=>{let{root:s,rel:i}=r(n.test);return g5(s,i)&&!t.gaps.some(o=>o.missing.includes(i)||o.missing.includes(n.test))}).map(n=>n.test))}var PMt=e=>e.trim().replace(/:\d+(?:-\d+)?$/,"");function DMt(e,t){let r=PMt(e);return r?t.some(n=>n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)||r.endsWith("/")&&(n.startsWith(r)||n.includes(`/${r}`))):!1}function jF(e,t,r){let n=new Set;for(let s of e.requirements)for(let i of s.clauses)s.source!=="could-break"&&(r||!i.code?.trim()||DMt(i.code,t))&&n.add(i.id);return n}var OMt=/\b[A-Z][A-Za-z0-9-]*\d+[a-z]\b/g;function A5(e,t,r){let n=e.behaviorId?.trim()?[e.behaviorId.trim()]:e.missing.match(OMt)??[];return n.length>0&&n.every(s=>t.has(s)&&!r.has(s))}var QMt=new Set(["targeted_unit","existing_evidence_sufficient"]);function AFe(e,t){let r=e.triage?.decision;if(!r||!QMt.has(r))return[];let n=[],s=e.triage,i=c=>!t.own||t.own.has(c),o=new Set(e.requirements.flatMap(c=>c.clauses).filter(c=>c.type==="contract"||c.type==="integration").map(c=>c.id)),a=c=>{let l=c.steps.flatMap(u=>u.clauses??[]);return!!t.own&&l.length>0&&!l.some(u=>i(u)&&!o.has(u))};for(let c of e.journeys??[]){if(t.runtimePossible&&c.kind!=="in-process"&&a(c)){n.push(`journey ${c.id} walks only what the change could break elsewhere or UI code it does not touch, which does not make the decision runtime_required: off the runtime path list its clauses under notInJourney with why (downstream of this change, not walked here) and drop the journey. Where it walks a flow the spec or PR description describes, in which server code alone gives the user an action or an outcome they did not have, keep it and decide runtime_required instead`);continue}if(!t.runtimePossible){c.kind!=="in-process"&&n.push(`journey ${c.id} needs a browser and this run starts no app: when the app cannot be run here, list each such journey's clauses under notInJourney with what is missing, and drop the journey`);continue}if(c.kind!=="in-process"){n.push(`journey ${c.id} is a browser journey, which needs the running app: decide runtime_required when any journey needs a browser, and mark runtime the clauses its steps exercise`);continue}let{root:l,rel:u}=t.locate(c.testFile);if(a(c)&&!h5(l,u)){n.push(`journey ${c.id} is planned in-process for what the change could break elsewhere, and no in-process UI test harness covers ${c.testFile}: that does not make the decision runtime_required \u2014 list its clauses under notInJourney with why and drop the journey`);continue}h5(l,u)||n.push(`journey ${c.id} is planned in-process, and no in-process UI test harness (Testing Library, jsdom, happy-dom, Vue Test Utils, Enzyme) covers ${c.testFile}: a request-level test client does not walk a journey. Decide runtime_required and make it a browser journey \u2014 in-process only where the repo's own in-process UI tests can walk and check all of it`)}if(t.runtimePossible){let c=new Set(e.requirements.flatMap(f=>f.clauses.map(m=>m.id))),l=t.own??c,u=e.maintenance.filter(f=>f.clauses?.length&&!f.clauses.some(m=>l.has(m))).map(f=>f.test),d=new Set(e.requirements.flatMap(f=>f.clauses.filter(m=>m.skip?.trim()).map(m=>m.id))),p=f=>!!(f.behaviorId&&d.has(f.behaviorId))||A5(f,c,l)||u.some(m=>f.missing.includes(m)||f.missing.includes(t.locate(m).rel));for(let f of s.gaps.filter(m=>!p(m))){let m=f.behaviorId?`the gap for ${f.behaviorId}`:`the gap "${f.missing.slice(0,120)}"`;f.needs?f.needs!=="outside"&&n.push(`${m} needs ${f.needs==="browser"?"a browser":"the running app"}, which this run can start: a clause only the running app can check is runtime, not a gap \u2014 decide runtime_required and mark it runtime`):n.push(`${m} does not say what it needs: give it needs browser, running-app or outside`)}}for(let c of e.maintenance){let{root:l,rel:u}=t.locate(c.test),d=g5(l,u);if(!d||t.runtimePossible&&mFe(c,s.plan))continue;let p=()=>s.gaps.some(f=>f.missing.includes(u)||f.missing.includes(c.test));if(t.own&&c.clauses?.length&&!c.clauses.some(f=>i(f))){p()||n.push(`maintenance ${c.test} is ${d} and checks only ${c.clauses.join(", ")}, which the change does not itself alter, so it does not make the decision runtime_required: name such a test under gaps with what is missing (the running app, downstream of this change)`);continue}if(!t.runtimePossible){p()||n.push(`maintenance ${c.test} is ${d} and this run starts no app: when the app cannot be run here, name each such test under gaps with what is missing`);continue}n.push(`maintenance ${c.test} is ${d}, which the unit path cannot run: decide runtime_required when any test under "maintenance" calls the deployed app, and mark runtime the clauses it checks, so it is verified against the app (a live-server test that starts its own server in the test process stays on the unit path)`+(c.action==="verify"?'. If it is only to verify, give its "clauses": one whose every clause an existing_unit or new_unit test here establishes keeps the plan on the unit path':""))}for(let c of e.findings??[]){if(!c.needsApp)continue;let l=c.needsApp==="browser"?"a browser":"the running app's API";if(!t.runtimePossible){if(s.gaps.some(u=>u.behaviorId===c.id||u.missing.includes(c.id)))continue;n.push(`finding ${c.id} needs ${l} to show it and this run starts no app: when the app cannot be run here, name it under gaps with what is missing`);continue}n.push(`finding ${c.id} needs ${l} to show it, which the unit path cannot do: a defect you found that only the running app can show makes the decision runtime_required wherever its code is \u2014 decide runtime_required and give it its case`)}return n.push(...MMt(e,t)),n}function MMt(e,t){let r=[],n=e.triage?.gaps??[],s=i=>n.some(o=>o.behaviorId===i||o.missing.includes(i));for(let i of e.requirements.flatMap(o=>o.clauses)){if(!i.browserOnly||i.skip?.trim())continue;let o=[i.steps,...(e.cases??[]).filter(u=>u.clause===i.id).map(u=>u.steps)],a=NMt(o);if(t.own&&!t.own.has(i.id)){let u=i.browserHarness?.trim(),d=u?t.locate(u):void 0;if(d&&!a&&uFe(d.root,d.rel)||s(i.id))continue;r.push(`clause ${i.id} is browser-only and checks what the change could break elsewhere or UI code it does not touch, which does not make the decision runtime_required: list its clauses under notInJourney and the browser-only ones under gaps, with what is missing (a browser, downstream of this change), unless the repo's in-process browser suite (browserHarness) tests it`);continue}if(a){r.push(`clause ${i.id} is browser-only and its only test checks markup ("${a}"): a browser-only clause needs a browser test; a markup check may be added, not substituted \u2014 drive the behaviour in the repo's in-process browser harness (browserHarness), else decide runtime_required with a browser test of it`);continue}let c=i.browserHarness?.trim();if(c){let{root:u,rel:d}=t.locate(c);if(uFe(u,d))continue}let l=c?`${c} is no in-process browser suite of the repo's (a Django LiveServerTestCase or StaticLiveServerTestCase, or pytest-django live_server, test that drives Selenium or Playwright; or component tests under a DOM test harness)`:"it names no in-process browser harness (browserHarness)";if(!t.runtimePossible){if(n.some(u=>u.behaviorId===i.id||u.missing.includes(i.id)))continue;r.push(`clause ${i.id} is browser-only, ${l}, and this run starts no app: a browser-only clause with no in-process browser harness: name it under gaps with what is missing`);continue}r.push(`clause ${i.id} is browser-only and ${l}: test it in the repo's in-process browser harness and name that suite as browserHarness, else decide runtime_required with a browser test of it, and mark the clause runtime`)}return r}var LMt="triage.json",WF="triage-set-aside.json",UMt=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),$Mt={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function bC(e){return e.some(t=>T6.has(t.mechanism))}function qMt(e){let{value:t,error:r}=Cn(e);if(r)return{errors:[r]};let{value:n,errors:s}=ts(lT,t);return s.length?{errors:s}:{triage:n,errors:[]}}function GMt(e){return qMt(e.stdout)}var Lqr=Vi("triage-schema",(e,t)=>GMt(t)),HF=e=>e.trim().replace(/\s+/g," ");function yFe(e,t){let r=e.find(i=>i.working)??e[0];if(!r)return;let n=i=>ky.existsSync(i)&&ky.statSync(i).isFile(),s=La(r.path,e.filter(i=>i!==r))(t);if(xi(s)&&s.exists&&n(oa.join(s.root,s.rel)))return{abs:oa.join(s.root,s.rel),repository:s.repository??r.slug,rel:s.rel};for(let i of e)if(fu(i.path,t)&&n(oa.resolve(i.path,t)))return{abs:oa.resolve(i.path,t),repository:i.slug,rel:oa.relative(i.path,oa.resolve(i.path,t)).split(oa.sep).join("/")}}function jMt(e,t){let r=[],n=new Set(t.behaviorIds),s=new Map(t.ci.map(g=>[g.id,g])),i=new Map(e.evidence.map(g=>[g.id,g])),o=new Set(e.plan.map(g=>g.mechanism)),a=e.decision==="blocked_preflight",c=new Set;for(let g of e.evidence)(c.has(g.id)||s.has(g.id))&&r.push(`evidence id "${g.id}" is used twice (every id is unique, and ci-<n> ids belong to the CI results)`),c.add(g.id);let l=e.outOfScope??[];for(let g of[...e.plan,...e.gaps,...l])g.behaviorId!==void 0&&!n.has(g.behaviorId)&&r.push(`behaviorId "${g.behaviorId}" is not one of analyze's behaviors (${[...n].join(", ")||"none"})`);if(!a){let g=new Set([...e.plan.map(w=>w.behaviorId),...e.gaps.map(w=>w.behaviorId??""),...l.map(w=>w.behaviorId)]);for(let w of n)g.has(w)||r.push(`behavior "${w}" is neither planned, listed in gaps, nor listed under outOfScope \u2014 every behavior analyze found is accounted for, so the scope never shrinks silently`)}let u=new Set([...e.plan.map(g=>g.behaviorId),...e.gaps.map(g=>g.behaviorId??"")]);for(let g of l){let w=`outOfScope "${g.behaviorId}"`;u.has(g.behaviorId)&&r.push(`${w} is also planned or listed in gaps: a behavior out of scope plans nothing`);let A=I=>{let T=yFe(t.sources,I);if(T)return T;let P=t.changedFiles.find(Q=>Q.path.endsWith(`/${I}`)),R=P&&ay(t.sources,P.repository);return P&&R?yFe([{...R,working:!0}],P.path):void 0},E=[...g.reason.matchAll(/([\w./@+-]+\.[A-Za-z]\w*):(\d+)/g)].flatMap(I=>{let T=A(I[1].replace(/^\.\//,"")),P=Number(I[2]);return T&&P>=1&&P<=ky.readFileSync(T.abs,"utf-8").split(`
318
+ `)){if(!s.trim())continue;let i=s.slice(3).trim().replace(/^"|"$/g,"");oMt.test(i)||i.startsWith(".skyramp/")||(s.startsWith("??")?n:r).push(i)}return{modified:r,added:n}}var MF=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,aMt=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${MF}["']|\bimport\s+["']${MF}["']|require\(\s*["']${MF}["']\s*\)|\bimport\(\s*["']${MF}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];function LF(e){return aMt.filter(([t])=>t.test(e)).map(([,t])=>t)}var cMt=/@playwright\/test|\bfrom\s+playwright\b|\bimport\s+playwright\b|["']playwright["']|\bselenium\b|\bpuppeteer\b|\bcypress\b|\bwebdriverio\b|\bpage\.goto\s*\(/;function WMe(e){return LF(e).length===0&&!cMt.test(e)}function lMt(e){let t=[],r=/\b(?:test|it|describe)(?:\.\w+)*\(\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1/g;for(let n=r.exec(e);n;n=r.exec(e))t.push(n[2]);return t}function uMt(e){let t=[],r=/(["'`])((?:\\.|(?!\1)[^\\\n])*)\1/g;for(let n=r.exec(e);n;n=r.exec(e))n[2].trim()&&t.push(n[2]);return t}function dMt(e,t,r,n){if(!$u(e)){let i=n.replace(/(?:\[[^\]]*\]|\([^)]*\)|<[^>]*>)+$/,"").split(/::|#/).pop().trim(),a=(/\s/.test(i)?i:i.split(".").pop()).replace(/\/.*$/,"").trim();return a&&t.includes(a)?!0:uMt(t).some(c=>n===c||n.endsWith(` ${c}`))}if(e==="pytest"){let s=n.split("::").pop().replace(/\[.*\]$/,"");return new RegExp(`\\bdef\\s+${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`).test(t)}return/\.each\s*[(`]/.test(t)?!0:r.some(s=>s&&(n===s||n.endsWith(` ${s}`)))}function pMt(e,t,r=[],n=[],s=new Set){let i=[],o=new Set(e.tests.flatMap(p=>p.covers)),a=new Set((e.journeysNotWritten??[]).map(p=>p.journey.trim()));for(let p of n)!o.has(p)&&!a.has(p)&&i.push(`journey "${p}" has no test and is not in journeysNotWritten \u2014 walk it in one in-process test, or say in journeysNotWritten what it needs that is missing`);let c=new Set((e.defectsNotTested??[]).map(p=>p.id));for(let p of r)!o.has(p)&&!c.has(p)&&i.push(`defect "${p}" has no test and is not in defectsNotTested \u2014 give it a test that reaches it and expects the correct behaviour, or say in defectsNotTested why no in-process test can`);for(let p of e.defectsNotTested??[])r.includes(p.id)||i.push(`defectsNotTested names "${p.id}", which is not a defect the plan found (${r.join(", ")||"none"})`);let l=[...t,...r,...n];for(let p of t)!o.has(p)&&!s.has(p)&&i.push(`behavior "${p}" was planned a new unit test and no file covers it \u2014 every planned new unit test is written`);for(let p of e.tests)for(let f of p.covers)l.includes(f)||i.push(`${p.file}: covers "${f}", which is neither a behavior planned a new unit test nor a defect the plan found (${l.join(", ")||"none"})`);let u=new Set(e.tests.flatMap(p=>p.names.map(f=>`${p.file}::${f.replace(/\[.*\]$/,"")}`))),d=Math.max(2,2*l.length);return u.size>d&&i.push(`${u.size} test functions for ${l.length} planned item(s) \u2014 write the fewest tests that obtain the planned missing evidence (at most ${d}), one focused test per planned item`),i}var fMt=/(^|\/)(fixtures?|__fixtures__|testdata|test_data|data|snapshots?|__snapshots__|mocks?|__mocks__)\//i;function HMe(e,t){if(fMt.test(t))return!1;let r=Uu(e,t);return r?zS(r,t):qu(t)}function hMt(e,t){let r=[],n=new Set(e.map(a=>a.file).filter(a=>t.modified.includes(a)&&HMe(t.repo,a))),s=new Set([...t.maintained??[],...n]);for(let a of t.modified)/(^|\/)__snapshots__\/[^/]+\.snap$/.test(a)&&s.has(FF(a))||(s.has(a)?HMe(t.repo,a)||r.push(`${a} is listed in "maintained" but is not a test file \u2014 source and fixtures stay as they are`):r.push(`${a} was changed \u2014 change only existing tests the change made stale, each listed in "maintained"; source and fixtures stay as they are`));let i=new Set(e.map(a=>a.file)),o=new Set(t.addedBefore??[]);for(let a of t.added)!i.has(a)&&!o.has(a)&&r.push(`${a} was added but is not a test in tests[] \u2014 write only new test files, and declare each one`);for(let a of e){let c=Ua.resolve(t.repo,a.file);if(!Gs(t.repo,a.file)){r.push(`${a.file} is outside the repository \u2014 write only new test files, in the repository`);continue}if(!wC.existsSync(c)){r.push(`${a.file} does not exist`);continue}!t.added.includes(a.file)&&!n.has(a.file)&&r.push(`${a.file} is not a new file \u2014 write only new test files`);let l=Wi(t.repo,a.file),u=$u(a.framework)||l!==void 0,d=$u(a.framework)?a.framework:l?.framework??Uu(t.repo,a.file);if(u)$u(a.framework)&&!zS(a.framework,a.file)&&r.push(`${a.file} is not named the way ${a.framework} discovers tests \u2014 follow the repository's test naming`),l?.framework!==a.framework&&r.push(`${a.file} is ${a.framework}, but the repository runs it with ${l?.framework??"no test framework we can run"} \u2014 use the framework the repository already uses`),l?.wrappedBy&&(a.run?r.push(...Fp(t.repo,a.run).map(A=>`${a.file}: its run ${A}`)):r.push(`${a.file}: the repository runs its ${l.framework} tests with \`${l.wrappedBy}\`, not ${l.framework} itself \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`));else{a.run?r.push(...Fp(t.repo,a.run).map(E=>`${a.file}: its run ${E}`)):r.push(`${a.file} is ${a.framework}, which the run has no adapter for \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`);let A=d?t.testAffixes?.get(d):void 0;A?.size&&!A.has($0(a.file))&&r.push(`${a.file} is not named like the repository's existing ${d} tests (${[...A].join(", ")}) \u2014 follow the repository's test naming`)}let p=Ua.dirname(a.file).split(Ua.sep).join("/")||".",f=d&&t.testDirs.get(d)||new Set,m=t.placedDir;m!==void 0?m!=="."&&p!==m&&!p.startsWith(`${m}/`)&&r.push(`${a.file} is not in ${m}, where the Target puts unit tests for this repository`):mMt(t.repo,p,f,a.file)||r.push(`${a.file} is not beside any existing ${u?a.framework:`${a.framework} (${d})`} test (${[...f].join(", ")||"none found"}) \u2014 place each test beside the existing tests`);let g=wC.readFileSync(c,"utf-8"),w=lMt(g);for(let A of a.names)dMt(a.framework,g,w,A)||r.push(`${a.file} declares test "${A}", which is not in the file \u2014 names lists the test functions`);for(let A of LF(g))r.push(`${a.file} uses ${A} \u2014 a unit test runs in one process: no network, no running app; mock with the framework's own tools inside the test`)}return r}function mMt(e,t,r,n){if(r.has(t))return!0;let s=o=>{let a=o.split("/"),c=a.findIndex(l=>gMt.test(l));return c<0?void 0:a.slice(0,c+1).join("/")},i=s(t);if(i&&[...r].some(o=>s(o)===i))return!0;if([...r].some(o=>s(o)===void 0)){let o=Ua.extname(n);try{return wC.readdirSync(Ua.join(e,t)).some(a=>Ua.extname(a)===o&&!qu(a))}catch{return!1}}return!1}var gMt=/^(tests?|spec|specs|__tests__|e2e|testing|integration_tests?)$/i;function AMt(e,t){return JMe(e,t,r=>Ua.dirname(r).split(Ua.sep).join("/")||".")}function yMt(e,t){return JMe(e,t,$0)}function JMe(e,t,r){let n=new Map;for(let s of t){let i=Uu(e,s);!i||!$u(i)&&!qu(s)||(n.has(i)||n.set(i,new Set),n.get(i).add(r(s)))}return n}function sm(e){return me(e,"triage.json")?.decision!=="targeted_unit"?[]:(me(e,"analyze.json")?.findings??[]).filter(r=>r.status!=="refuted"&&r.status!=="latent").map(r=>({id:r.id,claim:r.claim,file:r.file,line:r.line,repository:r.repository,severity:r.severity,...r.conflictsWith?.length?{conflictsWith:r.conflictsWith}:{}}))}function zu(e){return me(e,"triage.json")?.decision!=="targeted_unit"?[]:rm(me(e,"plan.json")?.journeys).filter(t=>t.kind==="in-process")}function ST(e){let t=me(e,"triage.json");return[...new Set((t?.plan??[]).filter(r=>r.mechanism==="new_unit").map(r=>r.behaviorId))]}var YMe={name:"generate-unit-grounded",verify(e,t){let{output:r}=xy(t);if(!r)return{name:this.name,passed:!0};let n=e.prepared,s=zu(e),i=me(e,"plan.json"),o=pMt(r,ST(e),sm(e).map(c=>c.id),s.map(c=>c.id),i?new Set(wT(i).keys()):new Set);s.length&&o.push(...kF(AT(s,{journeys:r.journeys,tests:r.tests,notWritten:(r.journeysNotWritten??[]).map(c=>({case:c.journey,reason:c.missing}))},Nc(e.inputs.repositoryPath,e.inputs.relatedRepos??[]))));for(let c of r.tests){let l=Oh(e.inputs,c.repository);"error"in l&&o.push(`${c.file}: ${l.error}`)}for(let c of Dt(e.inputs).filter(l=>l.writable)){let l=r.tests.filter(g=>dn(e.inputs,g.repository)?.path===c.path),u=(r.maintained??[]).filter(g=>dn(e.inputs,g.repository)?.path===c.path).map(g=>g.file),d=n?.checkouts?.[c.slug],{modified:p,added:f}=a5(c.path),m=cr(e.inputs,c.slug);o.push(...hMt(l,{repo:c.path,testDirs:AMt(c.path,d?.existingTests??[]),testAffixes:yMt(c.path,d?.existingTests??[]),modified:p,added:f,maintained:u,addedBefore:d?.addedBefore,placedDir:cy(e.inputs,c.slug,"unit")}).map(g=>`${m}${g}`))}let a=(r.maintained??[]).filter(c=>c.change==="updated");if(a.length){let c=me(e,"plan.json"),l=me(e,"analyze.json"),u=new Set([...(c?.requirements??[]).flatMap(f=>[f.id,...(f.clauses??[]).map(m=>m.id)]),...(l?.behaviors??[]).map(f=>f.id),...(l?.requirements??[]).map(f=>f.id)]),d=sn(e)?.repository.baseBranch??e.inputs.baseBranch??"origin/main",p=o5([{path:e.inputs.repositoryPath,base:d,related:!1},...(e.inputs.relatedRepos??[]).map(f=>({path:f.path,base:f.base??"origin/main",related:!0}))]);o.push(...OF(a,{requirementIds:u,changedLines:p,defectLines:new Map}))}return o.length?{...ar(this.name,o),repairable:!0}:{name:this.name,passed:!0}}};function KMe(e,t){if(!t.some(n=>n.gates.some(s=>!s.passed&&/secrets|checkout-intact/.test(s.name))))for(let n of[...t].reverse()){if(!n.session)continue;let{output:s,errors:i}=xy(n.session);if(s)return Kr(e,"generate-unit",s,i)}}function XMe(e,t){let{output:r,errors:n}=xy(t);return Kr(e,"generate-unit",r,n)}var UF="native-run.json",Nl=e=>me(e,UF),c5="no selected unit test ran";function $F(e){if(e.results.some(n=>n.status==="Pass"||n.status==="Fail"))return;let t=new Set([...e.results.map(n=>`${n.file}\0${n.selectedName??n.name}`),...e.notRun.map(n=>`${n.file}\0${n.name??""}`)]).size;if(!t)return;let r=e.notRun.length?[...new Set(e.notRun.map(n=>n.reason))]:["every test that reported was skipped"];return`${c5} (${t} selected): ${r.slice(0,3).join("; ").slice(0,600)}`}var CT=e=>e.name==="native-run"&&e.status==="failed"&&!!e.reason?.includes(c5),l5=e=>e.origin==="written"||!!e.written;function ZMe(e,t){let r=e.inputs?.unitPath==="write"&&t.decision==="targeted_unit",n=t.plan.filter(i=>i.mechanism==="existing_unit"||i.mechanism==="new_unit"&&!r),s=r?EMt(e,t.plan.filter(i=>i.mechanism==="new_unit")):[];return n.length===0?s:[...new Set([...s,...wMt(e,n)])]}function EMt(e,t){if(!t.length)return[];let r=me(e,"write.json");if(!r)return["the planned unit tests were not written (write did not finish)"];let n=new Set((Nl(e)?.results??[]).filter(i=>l5(i)&&!i.fromFile&&(i.status==="Pass"||i.status==="Fail")).flatMap(i=>i.behaviorIds)),s=[];for(let i of t){let o=r.tests.filter(c=>c.covers.includes(i.behaviorId)),a=o.some(c=>c.result.cases.some(l=>l.case===i.behaviorId&&(l.status==="pass"||l.status==="fail"))||!c.result.cases.length&&c.result.exit!==null&&c.covers.every(l=>l===i.behaviorId));o.length?!n.has(i.behaviorId)&&!a&&s.push(`${i.behaviorId}: no new unit test for it produced a result`):s.push(`${i.behaviorId}: no new unit test was written${i.covers?` for ${i.covers}`:""}`)}return s}function wMt(e,t){let r=e.state.stages["native-run"],n=Nl(e),s=r?.status==="failed"&&!!r.reason?.includes(c5);if(r?.status!=="passed"&&!s||!n)return[`the planned unit tests did not run${r?.reason?` (${r.reason})`:r?` (${r.status})`:""}`];let i=n.notRun.filter(d=>d.origin!=="written").map(d=>`${d.file}${d.name?`::${d.name}`:""} did not run: ${d.reason}`),o=(d,p)=>new Set(n.results.filter(f=>f.origin===d&&(f.status==="Pass"||f.status==="Fail")===p).flatMap(f=>f.behaviorIds)),a={existing:o("existing",!0),generated:o("generated",!0)},c={existing:o("existing",!1),generated:o("generated",!1)},l=me(e,ia),u=new Set((l?.tests??[]).flatMap(d=>d.covers));for(let d of t)if(d.mechanism==="new_unit"&&!u.has(d.behaviorId))i.push(`${d.behaviorId}: no new unit test was written${d.covers?` for ${d.covers}`:""}`);else{let p=d.mechanism==="new_unit"?"generated":"existing",f=p==="generated"?"new":"existing";a[p].has(d.behaviorId)||i.push(c[p].has(d.behaviorId)?`${d.behaviorId}: every ${f} unit test for it was skipped`:`${d.behaviorId}: no ${f} unit test for it produced a result`)}return[...new Set(i)]}var eFe=X(require("fs")),im=X(require("path"));var u5={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"},tFe=e=>u5[e].toLowerCase(),vT=e=>e.source==="other"&&!e.file,Ts=e=>new Map((e??[]).flatMap(t=>t.file?[[nn(t.key),t.file.name]]:[])),rFe=10*1024*1024,Iy=e=>e?.mediaType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"||e?.mediaType==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",nFe=(e,t)=>im.join(im.dirname(e),`${im.basename(e,im.extname(e))}${t}`),Ry=e=>nFe(e,".extracted.txt");function d5(e){try{return/\S/.test(eFe.readFileSync(Ry(e),"utf-8"))}catch{return!1}}var p5=e=>nFe(e,".quotes.txt");function sFe(e){return Iy(e.file)?Ry(e.path):e.file?.mediaType==="application/pdf"?p5(e.path):e.path}function qF(e){return e.map(t=>t.state!=="read"||!Iy(t.file)||d5(t.path)?t:{...ku(t),file:t.file,state:"not_read",reason:"cannot_open"})}function iFe(e,t){let r=Ts(t),n=[],s=[],i=new Set;for(let o of e.sources??[]){let a=o.reference?t.find(c=>nn(c.key)===nn(o.reference)):void 0;a?.state==="read"&&o.criterion?(n.push(Co(a.key,o.criterion,r)),s.push({...ku(a),criterion:o.criterion,version:a.version}),i.add(vT(a)?0:1)):o.spec?.trim()&&(n.push(o.spec.trim()),i.add(2))}return{labels:n,criteria:s,sameRank:i.size===1}}var oFe=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function aFe(e,t=[]){return(e??[]).map(r=>{let{labels:n,criteria:s,sameRank:i}=iFe(r,t),o=n.length>1?` ${oFe(n)} disagree${i?", and they rank the same":""}.`:"";return{description:`Open question${r.about?` (${r.about})`:""}: ${r.question} Readings: ${r.readings.join("; ")}.${o} No test asserts any of them until you decide.`,severity:"low",category:"open_question",...r.about?{requirementIds:[r.about]}:{},...s.length?{requirements:s}:{}}})}function f5(e,t=[]){return(e??[]).flatMap(r=>{let{labels:n}=iFe(r,t);return n.length<2?[]:[`${r.about??r.id}: ${oFe(n)} disagree (${r.id}), so only what they all allow was tested`]})}function cFe(e,t=[]){if(!e?.length)return;let r=e.map(s=>s.id).join(", "),n=f5(e,t).length?"in the PR description or a spec, or, where sources disagree, in the next run's Run Context or by correcting the source that is wrong":"in the PR description or a spec";return`Decide the open question${e.length>1?"s":""} listed under issues (${r}) and say which reading is meant ${n}; the next run then tests it.`}var Ty=X(require("fs")),Ri=X(require("path"));var bMt=/"(?:@testing-library\/(?:react|vue|svelte|angular|preact|dom|user-event)|jsdom|happy-dom|@vue\/test-utils|enzyme|react-test-renderer)"\s*:/,GF=e=>{try{return Ty.statSync(e).size<1e6?Ty.readFileSync(e,"utf-8"):""}catch{return""}};function h5(e,t){let r=Ri.resolve(e),n=Ri.dirname(Ri.resolve(r,t));if(Ri.relative(r,n).startsWith(".."))return!1;for(;;){if(bMt.test(GF(Ri.join(n,"package.json"))))return!0;if(n===r)return!1;n=Ri.dirname(n)}}var m5=/(^|\/)(e2e|cypress|playwright|selenium)\/|\.(cy|e2e)\.[cm]?[jt]sx?$/i,dFe=/["']@playwright\/test["']|["']cypress["']|\bcy\.(?:visit|request)\(|\b(?:from|import)\s+selenium\b|\bfrom\s+playwright\b|\bwebdriverio\b|\bpuppeteer\b|\bApplicationSystemTestCase\b/,pFe=/\b(?:Static|Channels)?LiveServerTestCase\b|\blive_server\b/,SMt=/["']@skyramp\/skyramp["']|\b(?:from|import)\s+skyramp\b/,CMt=/https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0)[:/]|\b(?:BASE_URL|API_URL|APP_URL|SUT_URL|baseURL|base_url)\b/,vMt=/\b(?:requests|httpx|aiohttp|urllib|axios|fetch|got|superagent|HttpClient|RestAssured|Faraday|Net::HTTP)\b/,xMt=/\b(?:jest\.mock|vi\.mock|nock|msw|setupServer|responses|respx|requests_mock|httpretty|fetchMock|fetch-mock|MockAdapter|WebMock|mock\.patch)\b/,IMt=/\b(?:BASE_URL|API_URL|APP_URL|SUT_URL)\b/;function g5(e,t){let r=t.split("::")[0].trim().replace(/\\/g,"/"),n=GF(Ri.resolve(e,r));if(!(pFe.test(n)&&!IMt.test(n))){if(dFe.test(n)||m5.test(r))return"a browser test of the running app";if(SMt.test(n)||CMt.test(n)&&vMt.test(n)&&!xMt.test(n))return"a test that calls the running app"}}function fFe(e,t){let r=t.split("::")[0].trim().replace(/\\/g,"/"),n=GF(Ri.resolve(e,r));return dFe.test(n)||m5.test(r)?"ui":g5(e,r)?"integration":n&&Wi(e,r)?"unit":void 0}var RMt=/\b(?:from|import)\s+(?:selenium|playwright)\b/,lFe={depth:6,files:2e3},hFe=e=>{if(!e.endsWith(".py"))return!1;let t=GF(e);return pFe.test(t)&&RMt.test(t)};function TMt(e){let t=lFe.files,r=(n,s)=>{let i;try{i=Ty.readdirSync(n,{withFileTypes:!0})}catch{return!1}for(let o of i){if(--t<0)return!1;let a=Ri.join(n,o.name);if(o.isFile()&&hFe(a)||o.isDirectory()&&s>0&&!o.name.startsWith(".")&&o.name!=="node_modules"&&r(a,s-1))return!0}return!1};return r(e,lFe.depth)}function uFe(e,t){let r=Ri.resolve(e),n=t.split("::")[0].trim().replace(/\\/g,"/").replace(/\/+$/,""),s=Ri.resolve(r,n);if(!n||Ri.relative(r,s).startsWith(".."))return!1;let i;try{i=Ty.statSync(s).isDirectory()}catch{return!1}return(i?TMt(s):hFe(s))?!0:m5.test(`${n}${i?"/":""}`)?!1:h5(r,i?Ri.join(n,"_"):n)}var kMt=/\b(?:selenium|playwright|webdriver|cypress|browser|live[_ -]?server|headless|jsdom|happy-dom|fireEvent|userEvent|user-event|find_element|clicks|presses|types into|drags|hovers|focuses|scrolls)\b|\.click\(|\bsend_keys\b/i,BMt=/\b(?:test client|self\.client|client\.(?:get|post)|assertContains|assertInHTML|response\.content|request-level|markup|html|css class|class(?:es)?|attributes?|rendered|renders|template)\b/i;function NMt(e){let t=e.filter(r=>!!r?.trim());if(!(!t.length||t.some(r=>kMt.test(r))))return t.every(r=>BMt.test(r))?t[0].trim().slice(0,160):void 0}function _Mt(e){return new Set(e.filter(t=>t.mechanism==="existing_unit"||t.mechanism==="new_unit").map(t=>t.behaviorId))}function mFe(e,t){let r=_Mt(t);return e.action==="verify"&&!!e.clauses?.length&&e.clauses.every(n=>r.has(n))}function gFe(e,t,r){return!e?.maintenance||!t?new Set:new Set(e.maintenance.filter(n=>mFe(n,t.plan)).filter(n=>{let{root:s,rel:i}=r(n.test);return g5(s,i)&&!t.gaps.some(o=>o.missing.includes(i)||o.missing.includes(n.test))}).map(n=>n.test))}var PMt=e=>e.trim().replace(/:\d+(?:-\d+)?$/,"");function DMt(e,t){let r=PMt(e);return r?t.some(n=>n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)||r.endsWith("/")&&(n.startsWith(r)||n.includes(`/${r}`))):!1}function jF(e,t,r){let n=new Set;for(let s of e.requirements)for(let i of s.clauses)s.source!=="could-break"&&(r||!i.code?.trim()||DMt(i.code,t))&&n.add(i.id);return n}var OMt=/\b[A-Z][A-Za-z0-9-]*\d+[a-z]\b/g;function A5(e,t,r){let n=e.behaviorId?.trim()?[e.behaviorId.trim()]:e.missing.match(OMt)??[];return n.length>0&&n.every(s=>t.has(s)&&!r.has(s))}var QMt=new Set(["targeted_unit","existing_evidence_sufficient"]);function AFe(e,t){let r=e.triage?.decision;if(!r||!QMt.has(r))return[];let n=[],s=e.triage,i=c=>!t.own||t.own.has(c),o=new Set(e.requirements.flatMap(c=>c.clauses).filter(c=>c.type==="contract"||c.type==="integration").map(c=>c.id)),a=c=>{let l=c.steps.flatMap(u=>u.clauses??[]);return!!t.own&&l.length>0&&!l.some(u=>i(u)&&!o.has(u))};for(let c of e.journeys??[]){if(t.runtimePossible&&c.kind!=="in-process"&&a(c)){n.push(`journey ${c.id} walks only what the change could break elsewhere or UI code it does not touch, so it does not make the decision runtime_required on that alone. Decide which it is: where it walks a flow the spec or PR description describes, in which server code alone gives the user an action or an outcome they did not have, keep it and decide runtime_required; otherwise list its clauses under notInJourney with why (downstream of this change, not walked here) and drop the journey`);continue}if(!t.runtimePossible){c.kind!=="in-process"&&n.push(`journey ${c.id} needs a browser and this run starts no app: when the app cannot be run here, list each such journey's clauses under notInJourney with what is missing, and drop the journey`);continue}if(c.kind!=="in-process"){n.push(`journey ${c.id} is a browser journey, which needs the running app: decide runtime_required when any journey needs a browser, and mark runtime the clauses its steps exercise`);continue}let{root:l,rel:u}=t.locate(c.testFile);if(a(c)&&!h5(l,u)){n.push(`journey ${c.id} is planned in-process for what the change could break elsewhere, and no in-process UI test harness covers ${c.testFile}: that does not make the decision runtime_required \u2014 list its clauses under notInJourney with why and drop the journey`);continue}h5(l,u)||n.push(`journey ${c.id} is planned in-process, and no in-process UI test harness (a test setup that renders the page inside the test process, such as Testing Library with jsdom) covers ${c.testFile}: a request-level test client does not walk a journey. Decide runtime_required and make it a browser journey \u2014 in-process only where the repo's own in-process UI tests can walk and check all of it`)}if(t.runtimePossible){let c=new Set(e.requirements.flatMap(f=>f.clauses.map(m=>m.id))),l=t.own??c,u=e.maintenance.filter(f=>f.clauses?.length&&!f.clauses.some(m=>l.has(m))).map(f=>f.test),d=new Set(e.requirements.flatMap(f=>f.clauses.filter(m=>m.skip?.trim()).map(m=>m.id))),p=f=>!!(f.behaviorId&&d.has(f.behaviorId))||A5(f,c,l)||u.some(m=>f.missing.includes(m)||f.missing.includes(t.locate(m).rel));for(let f of s.gaps.filter(m=>!p(m))){let m=f.behaviorId?`the gap for ${f.behaviorId}`:`the gap "${f.missing.slice(0,120)}"`;f.needs?f.needs!=="outside"&&n.push(`${m} needs ${f.needs==="browser"?"a browser":"the running app"}, which this run can start: a clause only the running app can check is runtime, not a gap \u2014 decide runtime_required and mark it runtime`):n.push(`${m} does not say what it needs: give it needs browser, running-app or outside`)}}for(let c of e.maintenance){let{root:l,rel:u}=t.locate(c.test),d=g5(l,u);if(!d||t.runtimePossible&&mFe(c,s.plan))continue;let p=()=>s.gaps.some(f=>f.missing.includes(u)||f.missing.includes(c.test));if(t.own&&c.clauses?.length&&!c.clauses.some(f=>i(f))){p()||n.push(`maintenance ${c.test} is ${d} and checks only ${c.clauses.join(", ")}, which the change does not itself alter, so it does not make the decision runtime_required: name such a test under gaps with what is missing (the running app, downstream of this change)`);continue}if(!t.runtimePossible){p()||n.push(`maintenance ${c.test} is ${d} and this run starts no app: when the app cannot be run here, name each such test under gaps with what is missing`);continue}n.push(`maintenance ${c.test} is ${d}, which the unit path cannot run: decide runtime_required when any test under "maintenance" calls the deployed app, and mark runtime the clauses it checks, so it is verified against the app (a live-server test that starts its own server in the test process stays on the unit path)`+(c.action==="verify"?'. If it is only to verify, give its "clauses": one whose every clause an existing_unit or new_unit test here establishes keeps the plan on the unit path':""))}for(let c of e.findings??[]){if(!c.needsApp)continue;let l=c.needsApp==="browser"?"a browser":"the running app's API";if(!t.runtimePossible){if(s.gaps.some(u=>u.behaviorId===c.id||u.missing.includes(c.id)))continue;n.push(`finding ${c.id} needs ${l} to show it and this run starts no app: when the app cannot be run here, name it under gaps with what is missing`);continue}n.push(`finding ${c.id} needs ${l} to show it, which the unit path cannot do: a defect you found that only the running app can show makes the decision runtime_required wherever its code is \u2014 decide runtime_required and give it its case`)}return n.push(...MMt(e,t)),n}function MMt(e,t){let r=[],n=e.triage?.gaps??[],s=i=>n.some(o=>o.behaviorId===i||o.missing.includes(i));for(let i of e.requirements.flatMap(o=>o.clauses)){if(!i.browserOnly||i.skip?.trim())continue;let o=[i.steps,...(e.cases??[]).filter(u=>u.clause===i.id).map(u=>u.steps)],a=NMt(o);if(t.own&&!t.own.has(i.id)){let u=i.browserHarness?.trim(),d=u?t.locate(u):void 0;if(d&&!a&&uFe(d.root,d.rel)||s(i.id))continue;r.push(`clause ${i.id} is browser-only and checks what the change could break elsewhere or UI code it does not touch, which does not make the decision runtime_required: list its clauses under notInJourney and the browser-only ones under gaps, with what is missing (a browser, downstream of this change), unless the repo's in-process browser suite (browserHarness) tests it`);continue}if(a){r.push(`clause ${i.id} is browser-only and its only test checks markup ("${a}"): a browser-only clause needs a browser test; a markup check may be added, not substituted \u2014 drive the behaviour in the repo's in-process browser harness (browserHarness), else decide runtime_required with a browser test of it`);continue}let c=i.browserHarness?.trim();if(c){let{root:u,rel:d}=t.locate(c);if(uFe(u,d))continue}let l=c?`${c} is no in-process browser suite of the repo's (a suite that starts the app in the test process and drives a real browser, such as a Django LiveServerTestCase with Selenium; or component tests under a DOM test harness)`:"it names no in-process browser harness (browserHarness)";if(!t.runtimePossible){if(n.some(u=>u.behaviorId===i.id||u.missing.includes(i.id)))continue;r.push(`clause ${i.id} is browser-only, ${l}, and this run starts no app: a browser-only clause with no in-process browser harness: name it under gaps with what is missing`);continue}r.push(`clause ${i.id} is browser-only and ${l}: test it in the repo's in-process browser harness and name that suite as browserHarness, else decide runtime_required with a browser test of it, and mark the clause runtime`)}return r}var LMt="triage.json",WF="triage-set-aside.json",UMt=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),$Mt={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function bC(e){return e.some(t=>T6.has(t.mechanism))}function qMt(e){let{value:t,error:r}=Cn(e);if(r)return{errors:[r]};let{value:n,errors:s}=ts(lT,t);return s.length?{errors:s}:{triage:n,errors:[]}}function GMt(e){return qMt(e.stdout)}var Lqr=Vi("triage-schema",(e,t)=>GMt(t)),HF=e=>e.trim().replace(/\s+/g," ");function yFe(e,t){let r=e.find(i=>i.working)??e[0];if(!r)return;let n=i=>ky.existsSync(i)&&ky.statSync(i).isFile(),s=La(r.path,e.filter(i=>i!==r))(t);if(xi(s)&&s.exists&&n(oa.join(s.root,s.rel)))return{abs:oa.join(s.root,s.rel),repository:s.repository??r.slug,rel:s.rel};for(let i of e)if(fu(i.path,t)&&n(oa.resolve(i.path,t)))return{abs:oa.resolve(i.path,t),repository:i.slug,rel:oa.relative(i.path,oa.resolve(i.path,t)).split(oa.sep).join("/")}}function jMt(e,t){let r=[],n=new Set(t.behaviorIds),s=new Map(t.ci.map(g=>[g.id,g])),i=new Map(e.evidence.map(g=>[g.id,g])),o=new Set(e.plan.map(g=>g.mechanism)),a=e.decision==="blocked_preflight",c=new Set;for(let g of e.evidence)(c.has(g.id)||s.has(g.id))&&r.push(`evidence id "${g.id}" is used twice (every id is unique, and ci-<n> ids belong to the CI results)`),c.add(g.id);let l=e.outOfScope??[];for(let g of[...e.plan,...e.gaps,...l])g.behaviorId!==void 0&&!n.has(g.behaviorId)&&r.push(`behaviorId "${g.behaviorId}" is not one of analyze's behaviors (${[...n].join(", ")||"none"})`);if(!a){let g=new Set([...e.plan.map(w=>w.behaviorId),...e.gaps.map(w=>w.behaviorId??""),...l.map(w=>w.behaviorId)]);for(let w of n)g.has(w)||r.push(`behavior "${w}" is neither planned, listed in gaps, nor listed under outOfScope \u2014 every behavior analyze found is accounted for, so the scope never shrinks silently`)}let u=new Set([...e.plan.map(g=>g.behaviorId),...e.gaps.map(g=>g.behaviorId??"")]);for(let g of l){let w=`outOfScope "${g.behaviorId}"`;u.has(g.behaviorId)&&r.push(`${w} is also planned or listed in gaps: a behavior out of scope plans nothing`);let A=I=>{let T=yFe(t.sources,I);if(T)return T;let P=t.changedFiles.find(Q=>Q.path.endsWith(`/${I}`)),R=P&&ay(t.sources,P.repository);return P&&R?yFe([{...R,working:!0}],P.path):void 0},E=[...g.reason.matchAll(/([\w./@+-]+\.[A-Za-z]\w*):(\d+)/g)].flatMap(I=>{let T=A(I[1].replace(/^\.\//,"")),P=Number(I[2]);return T&&P>=1&&P<=ky.readFileSync(T.abs,"utf-8").split(`
319
319
  `).length?[{...T,line:P}]:[]}),S=(t.sources.find(I=>I.working)??t.sources[0])?.slug??"",x=I=>Dh(I.repository,S)?!t.changedRanges||NDe(`${I.rel}:${I.line}`,t.changedRanges):ES(t.changedFiles,I.repository,I.rel);E.length===0?r.push(`${w}: cite the unchanged line that decides it (path:line of a file in the repository) in its reason`):(t.changedRanges||E.some(I=>!Dh(I.repository,S)))&&E.every(x)&&r.push(`${w} cites ${E.map(I=>`${sM(t.sources,I.repository)}${I.rel}:${I.line}`).join(", ")}, lines this change modifies \u2014 a behavior the change alters is never out of scope; move it from outOfScope into the plan`)}switch(e.decision){case"existing_evidence_sufficient":{[...o].every(w=>w==="existing_evidence"||w==="unaffected")&&e.gaps.length===0||r.push(`existing_evidence_sufficient means every behavior in scope is established by existing evidence, with no gaps \u2014 this plan also needs ${[...o].filter(w=>w!=="existing_evidence"&&w!=="unaffected").join(", ")||"the evidence named in gaps"}`);break}case"targeted_unit":(![...o].some(g=>yQe.has(g))||bC(e.plan))&&r.push(`targeted_unit plans unit tests and nothing that needs a running app \u2014 this plan has ${[...o].join(", ")||"nothing"}`);break;case"runtime_required":bC(e.plan)||r.push(`runtime_required marks at least one behavior runtime \u2014 this plan has ${[...o].join(", ")||"nothing"}`),o.has("new_unit")&&r.push("runtime_required plans no new unit tests \u2014 this plan has new_unit; mark those behaviors runtime, and keep existing_unit for the existing tests");break;case"blocked_preflight":break}a&&!e.blocked&&r.push('blocked_preflight names the changed file the failure is in, under "blocked"'),!a&&e.blocked&&r.push('"blocked" is only for blocked_preflight'),a&&e.plan.length>0&&r.push("blocked_preflight plans nothing: a change that cannot meet its prerequisites is not validated further");let d=(g,w)=>{let A=ay(t.sources,g);return!!A&&ES(t.changedFiles,A.slug,w)},p=(g,w)=>ky.existsSync(oa.join(g,w));e.blocked&&!d(e.blocked.repository,e.blocked.file)?r.push(`blocked.file "${e.blocked.file}" is not a file this change touches \u2014 a failure elsewhere is not the change's prerequisite`):a&&e.blocked&&VMt(e.blocked.file)&&r.push(`blocked.file "${e.blocked.file}" is test code: test code the change adds or edits that does not load is maintenance, not a block \u2014 plan the tests it stops as update, with its repair as theirs`);for(let g of e.plan){let w=`plan item for "${g.behaviorId}" (${g.mechanism})`;for(let A of g.evidenceIds)!s.has(A)&&!i.has(A)&&r.push(`${w} cites "${A}", which is neither a ci-<n> result nor an evidence id`);if(g.mechanism==="unaffected"){let A=t.behaviorFiles?.get(g.behaviorId),E=/([\w./-]+\.[\w]+):\d+/.exec(g.covers??"")?.[1];if(A&&d(A.repository,A.file)){let S=`${sM(t.sources,A.repository)}${A.file}`;r.push(`${w}: ${S} is changed by this PR, so the change can reach this behavior \u2014 unaffected is never for a behavior in a changed file`)}(!E||!t.sources.some(S=>p(S.path,E)))&&r.push(`${w}: say under "covers" why the change cannot reach it, and cite the code that shows it (path:line of a file in the repository)`)}if(g.mechanism==="existing_evidence"){let A=g.evidenceIds.filter(x=>{let I=s.get(x);if(I)return I.status==="accepted"&&I.kind!=="code_review";let T=i.get(x);return T?.source==="testbot"&&T.outcome==="passed"&&T.kind!=="code_review"}),E=g.evidenceIds.map(x=>s.has(x)?`${x} is ${s.get(x).status}`:`${x} is ${i.get(x)?.outcome??"unknown"}`);A.length===0&&r.push(`${w}: only accepted ci-<n> items and checks you ran that passed can establish a behavior${E.length?` \u2014 ${E.join(", ")}`:" \u2014 it cites nothing"}`),A.length===0&&g.evidenceIds.some(x=>s.get(x)?.kind==="code_review"||i.get(x)?.kind==="code_review")&&r.push(`${w}: AI review is advisory \u2014 it cannot establish a behavior on its own`)}g.mechanism==="existing_unit"&&g.evidenceIds.map(E=>i.get(E)).filter(E=>E?.source==="repository"&&(E.tests?.length??0)>0).length===0&&r.push(`${w}: existing_unit names the repository evidence listing the tests to run`),(g.mechanism==="new_unit"||T6.has(g.mechanism))&&!g.covers?.trim()&&r.push(`${w}: say under "covers" the missing evidence this obtains`)}let f=t.ranCommands.map(HF),m=new Set(e.plan.filter(g=>g.mechanism==="existing_evidence").flatMap(g=>g.evidenceIds));for(let g of e.evidence){if(g.source==="repository"){if(!g.tests?.length){r.push(`evidence "${g.id}" is repository evidence and lists no tests \u2014 list the unit tests that exercise the change, or remove the item, and drop its id from any plan item that cites it. Absence of tests is not evidence: say in the rationale that no tests exist`);continue}let w=e.plan.some(I=>I.mechanism==="existing_unit"&&I.evidenceIds.includes(g.id)),A=e.decision==="existing_evidence_sufficient";!(w||A&&m.has(g.id))&&e.decision!=="blocked_preflight"&&r.push(A?`evidence "${g.id}" identifies existing tests that no existing_evidence item cites \u2014 existing tests you identify are run, and under existing_evidence_sufficient they are cited by the existing_evidence item they support`:`evidence "${g.id}" identifies existing tests that no existing_unit item runs \u2014 existing tests you identify are run: plan existing_unit for the behaviors they exercise, or, if these tests call the running app, move them from evidence to maintenance: they are not evidence`);let S=ay(t.sources,g.repository);S||r.push(`evidence "${g.id}" names ${g.repository}, which is not a repository of this run (${t.sources.map(I=>I.slug).join(", ")}) \u2014 name the owner/repo the tests live in`);let x=t.sources.length>1?'; a test in another checkout: name its "repository"':"";for(let I of g.tests??[]){let T=I.split("::")[0];if(S&&!p(S.path,T))r.push(`evidence "${g.id}" names ${T}, which does not exist in ${S.slug} (tests are repo-relative paths${x})`);else if(S&&w&&!g.run){let P=Wi(S.path,T);P?P.wrappedBy&&r.push(`evidence "${g.id}" runs ${T}, which the repository runs with \`${P.wrappedBy}\`, not ${P.framework} itself \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`):r.push(`evidence "${g.id}" runs ${T}, which pytest, Jest, Vitest and node --test do not run \u2014 give "run": the repository's own command for only these tests, writing JUnit XML to {junit}`)}}S&&w&&g.run&&r.push(...Fp(S.path,g.run).map(I=>`evidence "${g.id}": its run ${I}`))}if(g.source==="testbot"&&m.has(g.id)&&!EFe(g.command,f)){let w=HF(g.command??"");r.push(`evidence "${g.id}" establishes a behavior but is a check this session never ran${w?` ("${w.slice(0,80)}")`:""} \u2014 give the exact command you ran`)}}return r}function EFe(e,t){let r=s=>s.replace(/\\/g,""),n=r(HF(e??""));return!!n&&t.map(r).some(s=>s===n||s.includes(n)||n.includes(s))}function HMt(e,t){let r=t.map(HF);return e.evidence.filter(n=>n.source!=="testbot"||EFe(n.command,r))}function wFe(e,t="triage",r){let n=r??me(e,"analyze.json")?.behaviors;if(!n)return;let s=me(e,eM),i=Dt(e.inputs);return{behaviorIds:n.map(o=>o.id),behaviorFiles:new Map(n.map(o=>[o.id,{repository:o.repository,file:o.evidence.split(":")[0]}])),ci:s?.items??[],changedFiles:xl(sn(e)??{changedFiles:[]},Ko(e.inputs).slug),sources:i,ranCommands:CQe(e.outputsDir,t).flatMap(k6),changedRanges:BDe(e)}}function zMt(e,t,r){return{...t,evidence:HMt(t,r),sutRequired:bC(t.plan),budgetMinutes:e.inputs.budgetMinutes,ciEvidence:me(e,eM)?.items??[]}}function bFe(e,t){let r=new Set(t),n=e.outOfScope?.filter(i=>r.has(i.behaviorId)),s=e.gaps.map(i=>i.behaviorId===void 0||r.has(i.behaviorId)?i:{missing:`${i.behaviorId}: ${i.missing}`});return{...e,gaps:s,...e.outOfScope?{outOfScope:n}:{}}}function y5(e,t,r,n){if(!t)return['save the validation triage decision as "triage" in the plan'];let s=wFe(e,"plan",n);if(!s)return["analyze.json is missing \u2014 nothing to ground the decision against"];let i=bFe(t,s.behaviorIds),o=jMt(i,s);return r&&!bC(i.plan)&&o.push(`the plan brought the app up, though its decision (${i.decision}) needs no running application`),o}var VMt=e=>qu(e)||/(^|\/)conftest\.py$/.test(e),SFe="the plan's validation triage does not hold: ";function WMt(e){let t=e.map(r=>r.replace(SFe,"")).join("; ").split(/ — |; /)[0].trim();return t.length>160?`${t.slice(0,159)}\u2026`:t}function E5(e,t,r,n){if(!t)return["the plan made no validation triage decision"];let s=y5(e,t,r,n);return s.length?[`${SFe}${s.join("; ")}`]:[]}function CFe(e,t){let r=wFe(e,"plan"),n=bFe(t,r?.behaviorIds??[]);return Kr(e,"triage",zMt(e,n,r?.ranCommands??[]),[])}function vFe(e){let t=e.inputs?.pipeline;return t?e.state.stages[t==="two-step"?"plan":"triage"]:e.state.stages.triage??e.state.stages.plan}function w5(e,t=aa(e)){let r=me(e,"plan.json"),n=sn(e);if(!t?.gaps.length||!r?.requirements?.length||!n)return[];let s=xl(n,"").map(a=>a.path),i=jF(r,s,gT(s).length>0),o=new Set(r.requirements.flatMap(a=>a.clauses.map(c=>c.id)));return t.gaps.filter(a=>A5(a,o,i))}function aa(e){if(vFe(e)?.status==="passed")return vl(oa.join(e.outputsDir,LMt))}function $n(e){return e.inputs?.unitPath==="write"&&aa(e)?.decision==="targeted_unit"}function JMt(e){let t=aa(e);if(!t?.sutRequired||$n(e))return!1;let r=new Set(t.plan.filter(n=>n.mechanism==="runtime").map(n=>n.behaviorId));for(let n of me(e,"plan.json")?.cases??[])n.clause&&r.has(n.clause)&&r.add(n.id);return(me(e,"adapt.json")?.items??[]).some(n=>n.reran?.tests?.length?n.reran.tests.some(s=>s.status==="pass"&&r.has(s.case)):n.reran?.exit===0&&(n.covers??[]).some(s=>r.has(s)))}function JF(e){return me(e,"deploy.json")?.outcome==="bringup-failed"&&JMt(e)}function SC(e){return VOe(pF(e.inputs,me(e,`${Is}.json`),aa(e)?.sutRequired))}function xFe(e,t){if(!e.triageBranch&&!(e.name&&YMt.has(e.name)))return;let r=aa(t);if(r){if(r.decision==="existing_evidence_sufficient")return`${xT.runtime}${r.decision}: existing evidence establishes this change, so no test is written or run`;if(t.inputs?.unitPath==="write"&&r.decision==="targeted_unit"){if(e.name==="write")return;if(e.name==="generate-unit")return`${xT.noRuntime}${r.decision}, and write writes its unit tests (unit path write)`}if(e.triageBranch==="runtime"&&!r.sutRequired)return`${xT.runtime}${r.decision}, which needs no running application`;if(e.triageBranch==="no-runtime"&&r.sutRequired)return`${xT.noRuntime}${r.decision}, which needs the running application`}}var YMt=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]),xT={runtime:"not needed \u2014 validation triage decided ",noRuntime:"not on this run's path \u2014 validation triage decided "};function IFe(e){return!!e&&Object.values(xT).some(t=>e.startsWith(t))}function RFe(e,t){if(!e.branchRequires)return[...e.requires];let r=aa(t),n=r&&!r.sutRequired&&!$n(t)?"no-runtime":"runtime";return[...e.requires,...e.branchRequires[n]??[]]}function b5(e){return[...new Set([...e.requires,...e.softRequires??[],...Object.values(e.branchRequires??{}).flat()])]}var KMt=/run budget exhausted/;function S5(e,t){let r=vFe(e);if(!r)return;let n=aa(e);if(!n){let g=vl(oa.join(e.outputsDir,WF))?.problems??[];return{sufficiency:"insufficient",rationale:"Validation triage did not complete, so nothing established what evidence this change needs.",gaps:[`validation triage did not complete (${g.length?`its decision did not hold: ${WMt(g)}`:r.reason??r.status})`],acceptedEvidence:[],actionRequired:[]}}if(n.decision==="blocked_preflight"&&n.blocked)return{sufficiency:"insufficient",rationale:n.rationale,gaps:[`the change does not meet a prerequisite: ${n.blocked.reason} (${n.blocked.file})`],acceptedEvidence:[],actionRequired:[],blockedPreflight:n.blocked};let s=new Set(w5(e,n)),i=n.gaps.filter(g=>!s.has(g)).map(g=>g.behaviorId?`${g.behaviorId}: ${g.missing}`:g.missing),o=new Set;for(let g of n.plan)UMt.has(g.mechanism)||i.push(`${g.behaviorId}: ${$Mt[g.mechanism]} is not available in this run${g.covers?` (${g.covers})`:""}`);n.blocked&&i.push(`the change does not meet a prerequisite: ${n.blocked.reason} (${n.blocked.file})`),i.push(...ZMe(e,n)),i.push(...f5(me(e,"plan.json")?.questions,e.inputs?.requirementItems));let a=iC(e).filter(g=>n.sutRequired||!!e.inputs?.appRunning&&g.status==="unverifiable"),c=n.sutRequired?fF(e.inputs?.sharedEnvironment):[],l=!!e.inputs?.appRunning;i.push(...a.map(g=>YOe(g,l)),...c.map(g=>WOe(g,l))),(a.length||c.length)&&o.add("sut_revision_mismatch");let u=hF(e);i.push(...u.map(KOe));let d=n.sutRequired?VQe(e):[];if(i.push(...d),(u.length||d.length)&&o.add("isolation_unavailable"),n.sutRequired&&!nT(e)&&!JF(e)){let g=e.state.stages.deploy;i.push(`the running application was needed and was not available${g?.reason?` (${g.reason})`:""}`),o.add("deployment_review")}else t.some(g=>g.kind==="tests-not-executed")&&i.push("the planned tests were written but not run");let p=Object.entries(e.state.stages).filter(([,g])=>g&&KMt.test(g.reason??"")).map(([g])=>g);p.length&&i.push(`the execution budget ran out before ${p.join(", ")} finished`);let f=new Set(n.plan.filter(g=>g.mechanism==="existing_evidence").flatMap(g=>g.evidenceIds)),m=n.ciEvidence.filter(g=>g.status==="accepted"&&f.has(g.id)).map(g=>({kind:g.kind,repository:g.repository,revision:g.revision,reference:g.reference,summary:g.summary}));return{sufficiency:i.length?"insufficient":"sufficient",rationale:n.rationale,gaps:i,acceptedEvidence:m,actionRequired:[...o]}}var kFe={async render(){}};function IT(e=t=>console.log(t)){return{async render(t){let r=t.split(`
320
320
  `).filter(n=>!n.startsWith("<!--")).join(`
321
321
  `);e(`
@@ -675,8 +675,8 @@ export default {
675
675
  `)}function vlr(e){let t=e.inputs.sutCredentials?.length?{knowledge:[],credentials:[...e.inputs.sutCredentials]}:void 0;return t?OG(t,()=>{},Hd(e.sutAuthEnv)):[]}var j2="app.revisions";function xlr(e,t){if(e.inputs.appRunning)return[`${e.inputs.appRunning.trim()} Don't start it again: check it answers a real request with real data, and fill "app" with outcome clean (or bringup-failed, with why, if it doesn't answer) and its base URLs.`,t.revisionRead,...GN(e,j2)].filter(Boolean).join(`
676
676
  `);let r=e.inputs.repositoryPath,n=t.recipe;return n.present?[`Bring the app up so the tests can run against it, and leave it running. The repo records how: ${[n.setupScript,n.teardownScript,n.authTokenScript,n.workspaceFile].filter(i=>!!i).map(i=>bs.relative(r,i)).join(", ")}.`,"Run it. If it has drifted, fix it and update those files to what actually worked. If this PR broke start-up, that's","a defect \u2014 say which changed file. Check that the app answers a real request with real data, not just an open port.",...rw,...n.budgetMinutes?[`Start-up can legitimately take up to ${n.budgetMinutes} minutes.`]:[],...n.healthHint?[`A known-good health check: ${JSON.stringify(n.healthHint)}`]:[],...n.stale?[`This PR changes start-up files (${n.staleFiles.join(", ")}), so the recipe may be out of date.`]:[],...GN(e,j2)].join(`
677
677
  `):["Bring the app up so the tests can run against it, and leave it running. The repo has no recorded way to start it","(.skyramp/sut/setup.sh). Find how the repo starts it \u2014 a start or dev script, a Makefile target, a compose file,","its README or docs (a local or offline stack counts) \u2014 run that, save what worked as .skyramp/sut/setup.sh and",".skyramp/sut/teardown.sh, and set app.outcome to clean: there was no recorded way to drift. Set it to bringup-failed","only once a start you ran has failed, with the command and its error.",...rw,...GN(e,j2)].join(`
678
- `)}var WN=e=>!!e.appRunning&&Bl(e),Ilr=new Set(["mutates"]);function Rlr(e){return new Set([...WN(e.inputs)?[]:Ilr,...Ay(e.inputs).length?[]:["revisions"]])}function Tlr(e){return WN(e.inputs)?[" The app runs in a shared environment this policy protects. A case or clause whose test changes state there (an"," API POST, PUT, PATCH or DELETE, in the test or its setup, or a UI flow that submits, creates, edits or deletes) is"," withheld by the runner and reported as a gap: prefer cases that only read, and mark each that still changes state,",' and each such maintenance item, "mutates": true.']:[]}function mnt(e){return[" Under targeted_unit, probe in-process instead, the way the repo's own tests reach this code: one scratch test"," file, run with the repo's runner, that calls what decides each clause (the function or service, a handler through"," the repo's in-process test client, a component rendered as its tests render it), first with the input it normally"," gets, then with the same kinds of input, state and sequence. Put it where the runner finds it, name it so it is"," plainly scratch, keep a copy and its output",` under ${e}*, and delete it from the checkout once it has run. A flag that repeats there is a finding, with the`," call and its result as evidence, and gets its case as step 5 says."]}function klr(e){if(!e.skyrampWalk)return[];let t=bs.join(bs.dirname(e.checkpoint),"journey-walks");return["10. Under runtime_required, walk each browser journey once against the running app with the Skyramp walk helper:",` a Node script that calls \`require(process.env.SKYRAMP_WALK).walk(...)\` (usage at the top of ${e.skyrampWalk.helper}),`,` with ${t} as its outputDir and the script there too, outside the checkout. Walk from the journey's entry`," through every step to the action that finishes it, checking at each step what the user should then see. When a"," step fails, the helper prints the page and an accessibility snapshot: where the selector or route was wrong, fix it"," and walk again; where the page does something other than what the change intends, walk it once more, and if it"," repeats it is a finding, as a flagged probe is. Then write each journey's steps with the selectors and routes that",` worked, and the updated plan to ${e.checkpoint}. The walk fixes how a step is done, never which steps there are: each`," journey keeps its entry, every step and its outcome as 5 planned them, and a step that could not be walked stays"," in, with what stopped it, for the test to reach."]}function Blr(e,t){if(e.inputs.planOnly)return[];if(!e.inputs.appRunning&&t.preflight&&!t.preflight.sutRequired)return[];let r=bs.join(bs.dirname(t.checkpoint),"probe");return WN(e.inputs)?["8. Probe before any test is written. Under runtime_required, probe the running app (skip it if the app isn't"," answering). It is a shared environment this policy protects: send only requests that change nothing (GET and"," HEAD: reads, lists, searches, filters, sorts) and never create, edit, delete, reset or seed anything there. Put",` every probe in one script under ${r}*, each tagged with the clause it checks, and run it, printing a line for`," each probe a check flags (what it read, the status codes, which check failed) and, per clause, how many probes it"," got. Probe each clause through reads, as widely as its code gives reason to: every state its records can be in,"," every field it adds through list, sort, filter and search, and odd query values (zero, negative, huge, empty, case"," variants). Flag any 5xx, and reads that disagree with each other or with derived values (totals, counts).",...mnt(r),"9. Re-run each flagged probe once. Then probe once more where it is worth it: around each flag that repeated (the"," values and states next to it), for each clause a request could check that got no probe, and for each input or field"," the change adds that a kind of probe in 8 reached elsewhere but not there (a huge value sent to one number but not"," another, a field left out of one update but not another, a new field never sorted or filtered by); re-run what"," that flags. Each flag that repeats and involves what the change touched is a defect: add it to",' "findings" with the request and response as its evidence and the rule it breaks, as 3 says, and a case for it.',` Where 2 leaves the right behaviour open, it is a question instead. Then write the updated plan to ${t.checkpoint}`," again."]:["8. Probe before any test is written. Under runtime_required, probe the running app (skip it if the app isn't"," answering). Probe clause by clause: for each, first send what a user would normally send, to see it work and learn"," what the app answers, then the requests that would show it broken \u2014 wrong, missing and odd input, a limit and just"," past it, a user or record state that should be refused, a sequence that could leave it half done \u2014 as many as its"," code gives reason to. Go deepest where the change's own code decides the clause and where a"," failure would lose data, money or access; a cosmetic clause needs little. Put every probe in one script under",` ${r}*, each tagged with the clause it checks, and run it, printing a line for each probe a check flags (what it`," did, the status codes, which check failed) and, per clause, how many probes it got. In what the change touches, defects tend to hide in:"," - every state its records can be in (from the code's status fields and enums) \xD7 every operation the change adds or alters;"," - sequences: write then read back; set, reset, read; edit twice; delete then edit; write then list;"," - payloads: zero, negative, huge, empty, null, missing and extra fields, wrong types, case variants, more items"," than a page holds, one valid and one invalid item together;"," - every field the change adds, through the existing list, sort, filter and search."," Read the record before and after each action. Flag any 5xx; a rejected request that changed anything; a read that"," differs from what was written; a repeated request that changed something more; derived values (totals, counts)"," that disagree with their inputs; an operation that succeeds on a record in a final state (cancelled, shipped, deleted).",...mnt(r),"9. Re-run each flagged probe once. Then probe once more where it is worth it: around each flag that repeated (the"," values and states next to it), for each clause a request could check that got no probe, and for each input or field"," the change adds that a kind of probe in 8 reached elsewhere but not there (a huge value sent to one number but not"," another, a field left out of one update but not another, a new field never sorted or filtered by); re-run what"," that flags. Each flag that repeats and involves what the change touched is a defect: add it to",' "findings" with the request and response as its evidence and the rule it breaks, as 3 says, and a case whose'," steps are that request sequence and whose expected outcome is the correct behaviour.",` Where 2 leaves the right behaviour open, it is a question instead. Then write the updated plan to ${t.checkpoint}`," again.",...klr(t)]}function ole(e){let t=sn(e);return t?gT(xl(t,"").map(r=>r.path)):[]}function nle(e){let t=ole(e);if(!t.length&&!TF(e.inputs.repositoryPath))return[];let r=t.slice(0,8).join(", ")+(t.length>8?", \u2026":"");return[' User journeys: under "journeys", the flows a user walks through the UI, each from where a user normally starts it'," to the outcome they came for, that together pass through everything the change alters that a user sees or does:"," every ui clause is in some journey's steps (or under notInJourney, with why no journey reaches it). Use as many"," journeys as that takes. For each: the entry route; every step in order, with the clauses it exercises and what the user then sees;"," the outcome that shows the journey worked, in the spec's or PR description's own words: everything they say the"," user then sees (the exact message, the order a list is in, each field the page shows of what was saved), not a"," summary of it; under finishes, the user action that completes the task; its source \u2014"," the spec or PR description that describes the flow (quote it),"," else inferred; and the test file it belongs in. Each becomes one test of the whole flow as the PR intends it (its kind):"," in-process only where the repo's own in-process UI tests (component tests under jsdom or the like, for that code) can"," walk and check all of it \u2014 a request-level test client (Django's, Flask's, Rails integration tests) runs no page script"," and does not count \u2014 else a browser test, which needs the running app, so the decision is runtime_required (step 4)."," The changed step is inside the flow, not the whole of it. The journey starts where a user starts the task (the app's"," entry, its login, or the navigation a user would use), not at a link into the changed page unless reaching it by link"," is what the change is about, and gets to the changed step through the page: what an earlier step of the same flow"," creates (the record a change then edits) the journey creates through the app's own form, not through the API. That"," is for the journey only: the other"," cases keep using the records the app already has wherever the change reads or edits existing data, since a record"," made fresh for the test can hide a defect that shows only on older data. The journey goes on past the changed step"," to the action that finishes the user's task (save, submit, pick, open, run), and its last step checks on the page"," what that action produces. The journey ends where the user sees the result,"," which may be past the changed page: the next page built from what was saved, or a record it links to. After a"," change that saves something, a step reloads or reopens it and checks it held. Where the steps only a browser could"," walk pass through what the change leaves as it was (the login and the way to the page, the server keeping what an"," unchanged action saved), and the change does not alter how the page reaches the server (its requests, routes or"," guards), they set the journey up rather than check it: it is in-process where the repo's in-process UI tests can"," check the rest, starting on the page as they do, with the server's answers given the way they give them."," Code that decides what a page shows"," counts though no page changed (a composable, store, hook, style or theme it renders from): what the user then sees"," is in a journey, whatever unit test also checks it."," So is a flow the spec or PR description describes a user walking, though no UI file changed, where server code"," alone gives the user an action or an outcome they did not have (a new command and its reply, being signed out):"," the journey checks it on the page. A new value through a form that already sends and shows it the way it did (a"," parser or validator behind an unchanged field) is not one: the tests of the changed code check it."," A repo with no browser tests is no reason to leave a clause out: its browser journeys go in a test package of their own."," Empty when the change alters nothing a user sees; then say so under notInJourney, per clause, with why. A change"," to UI code that alters what the page holds along a user flow (a DOM attribute, the theme, other client state the"," flow sets) owes a journey that asserts it, even when nothing in the repo reads it yet: that nothing reads it, or"," that the user cannot see it, is no reason to leave it out.",...t.length?[` The change touches UI files: ${r}.`]:[]]}function Nlr(e,t){let{budgetMinutes:r}=e.inputs;return["4. Validation triage, before anything is started: decide what evidence each clause still needs and the cheapest",' reliable way to get it, and save it as "triage" (its behaviorIds are your clause ids). The app is brought up only'," when the decision is runtime_required; existing evidence or native unit tests can often validate a change"," without it. You are not a code reviewer here: no style, naming or architecture commentary.","",...(s=>s.flatMap(i=>i.split(`
679
- `)).map(i=>i?` ${i}`:""))([...Mrt(e,t.triage.change),"",...Frt(e,t.triage),...r?["",`Run budget: ${r} minutes for the whole run, including everything you plan. Name in gaps what it cannot cover.`]:[],"","Scope: validate what this change alters or newly reaches, and what the PR description or a spec states.","- Out of scope is only a clause the change cannot reach: its deciding code is unchanged and no changed path leads to it, or it lives in a checkout the change does not touch. List it under outOfScope with the unchanged line that decides it (path:line), and plan nothing for it. Code the change newly calls or feeds new values to is in scope; a defect found there in the base's own code is recorded as step 3 says. A path is one you can see in the code: a call, an import or a route that reaches the changed code (find its callers); a comment or a name saying code is shared is not one. What something the change adds answers for the inputs it takes is the change's own (step 2). Unchanged code that receives a new value through a path it already had is in scope for what it newly does with it; where it handles the value the way it already handled others, its behaviour has not changed, and it is what the change could break, not what it alters.","","The evidence ladder \u2014 use the cheapest mechanism that establishes each clause in scope:"," existing_evidence an accepted ci-<n> result. A check you ran (typecheck, compile, test collection) establishes only a prerequisite clause \u2014 that the change builds or its config parses \u2014 never a behaviour"," unaffected the change cannot reach this clause: no changed code path leads to it \u2014 cite the code that shows it (path:line); never for a clause decided in a changed file"," existing_unit existing native unit tests that exercise the clause"," new_unit a new in-process test, for evidence nothing provides yet"," runtime only the running application can establish it","A clause only the running app can check is runtime, not a gap, even when every other clause is in-process. It is a gap only when the app cannot be run here; then name what is missing.","Give each gap what it needs: browser (only a real browser shows it), running-app (only the running app or its server shows it: its real requests, sign-in and permissions, what it saves), or outside (something the running app here could not give either: a third-party service it calls, hardware). An app you have not tried to start is no reason for outside.","Give each clause the kind of test the repo already uses for the code it checks \u2014 in-process where the repo tests that code in-process, runtime where it tests it against the running app \u2014 unless that kind cannot check it; then the kind that can. Where it tests that code both ways, as component specs and an end-to-end suite, the in-process kind is the one when it can check the clause.",`Browser-only: for every clause, ask whether its behaviour happens only in a browser \u2014 real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript \u2014 and if so mark it browserOnly. A test that only checks markup (a class or attribute present, the HTML a request returns) proves the precondition, not the behaviour: the header having the sort class does not show that "clicking a column header sorts the list". A browser-only clause is tested in a browser: in the repo's in-process browser harness where it has one \u2014 a Django LiveServerTestCase or StaticLiveServerTestCase, or pytest-django live_server, suite that drives Selenium or Playwright; component tests under jsdom only when the repo's own jsdom tests already drive that kind of interaction \u2014 named as its browserHarness (the suite's path), and the clause stays new_unit, with its triage item's covers saying it is driven in that browser suite; else decide runtime_required with a browser test of it. A markup check may be added, not substituted.`,"","Decisions:","- existing_evidence_sufficient means every clause in scope is established by existing evidence, with no gaps.","- A change that touches no application file (only docs, configuration or CI, in every checkout, and no lockfile) is existing_evidence_sufficient: the diff, and a check you ran that its configuration parses, establish what those files say. Plan no new test for it: a test that pins a file's contents (an action version, an editor setting, a README sentence) checks nothing a user does.","- targeted_unit plans unit tests and nothing that needs a running app.","- runtime_required marks at least one clause runtime, and plans no new unit tests: once the app is needed, this plan's cases are every new test, each still written the way the repo tests that code \u2014 in-process where that can check its clause, in the browser only where it cannot. The existing unit tests you identify still run, as existing_unit.","- The journeys and maintenance of step 5 can need the app too, so plan them before you decide. Decide runtime_required when any journey needs a browser \u2014 real JavaScript or htmx behaviour, navigation across pages or what persists after a reload, where the change alters either, or a server-rendered page the repo tests only at the request level \u2014 and mark runtime the clauses its steps exercise.",'- Decide runtime_required as well when any test under "maintenance" calls the deployed app \u2014 API, contract, integration, end-to-end or UI tests that reach it at its address (BASE_URL or the like), and Skyramp tests \u2014 and checks what the change itself alters, and mark runtime the clauses it checks, so it is verified against the app. So does a gap, for what the change itself alters, that needs a browser or the running app, and a browser-only clause the repo has no in-process browser harness for. A test under "maintenance" only to verify, whose clauses in-process tests run here establish (existing_unit or new_unit, not a CI result), does not: running it again against the app shows nothing they do not.',"- A test that starts its own live server in the test process and drives it in a browser (Django's LiveServerTestCase or StaticLiveServerTestCase, pytest-django's live_server, with Selenium or Playwright) needs no deployed app: under targeted_unit it is maintained and run in-process, with the repo's CI settings and a headless browser.","- When the app cannot be run here, list each such journey's clauses under notInJourney, and each such test under gaps, with what is missing: it is reported not covered, never dropped. So is a browser-only clause with no in-process browser harness: name it under gaps with what is missing.","- A defect you found (step 3) that only the running app can show makes the decision runtime_required wherever its code is, in the change or downstream of it: one in page script or in what the user sees after a click or a save, where the repo has no in-process browser harness for it, or in code the repo tests only against the running app's API. Mark it needsApp (browser or live-api) and give it its case. A defect an in-process test can show is not needsApp. When the app cannot be run here, name it under gaps with what is missing.","- Otherwise only what the change itself alters decides it. A journey or browser-only clause only for what the change could break elsewhere (a could-break requirement), or for UI code the change does not touch when it touches no UI code, does not make the decision runtime_required: off the runtime path list its clauses under notInJourney and the browser-only ones under gaps, with what is missing (a browser, downstream of this change), so it is reported not covered. Nor does a maintained test that calls the deployed app only for such clauses: give each maintained test the clauses it checks, and name such a test under gaps with what is missing (the running app, downstream of this change). A journey through a flow the spec or PR description describes a user walking is not one of these, though no UI file changed, where server code alone gives the user an action or an outcome they did not have (a new command and its reply, being signed out). A new value through a form that already sends and shows it the way it did (a parser or validator behind an unchanged field) stays off the runtime path.","- blocked_preflight: the change cannot meet a basic prerequisite. It names the changed file the failure is in and quotes the error, and plans nothing. A check that fails for an environment reason (a dependency not installed, a missing tool) is not the change failing \u2014 never block on it. Nor is test code the change adds or edits that does not load (a conftest, fixture or helper with an import that does not resolve): it is maintenance, not a block \u2014 plan the tests it stops as update, with its repair as theirs.","","Rules:","- Every clause is planned, listed in gaps, or listed under outOfScope, by its id (R1a). A gap is evidence this run cannot obtain; a test this run will execute (existing_unit, new_unit, runtime) is not one, even when you could not run it while planning.","- Only accepted ci-<n> items, and passing checks you ran for prerequisite clauses, can establish a clause. A stale, untrusted, pending, failing or inconclusive result establishes nothing; a trusted result that failed is a reason to plan evidence, never a pass. AI review is advisory, never evidence.","- Find the existing tests yourself: where the repo keeps tests of the changed code, and their framework.",'- Existing tests that call a running app (API, contract, integration, end-to-end or UI tests) are never evidence: list them in "maintenance" (verify, or update).',"- Repository evidence is only native unit tests, which run without the app. Every repository evidence item lists its tests as repo-relative paths (path::test-name when the file holds more than the relevant ones) \u2014 only the tests that exercise the changed behavior, never the whole suite.",`- ${AQe}`,`- ${dC}`,"- Every repository evidence item is run: cite it from an existing_unit item for the clauses it exercises. Only under existing_evidence_sufficient is nothing run: cite it from the existing_evidence item it supports instead.","- Plan new_unit only for what no existing test asserts, or asserts differently from the requirement (the boundary the change moved); never for what existing tests already prove.","- When the PR description or a spec states the expected behavior, plan evidence for what it states, not for what the code does.","- Evidence items are existing repository tests (source repository) and checks you ran with Bash (source testbot), each with a unique id; the ci-<n> results above are not restated. Run each check as one plain command \u2014 no `&&`, pipes or `echo` \u2014 and copy it into its evidence exactly. Don't start the application, install dependencies or run test suites for triage."])]}function _lr(e){let t=e.prepared,r=e.inputs.repositoryPath,n=t.preflight?.repository.currentBranch??"HEAD",s=t.preflight?.repository.baseBranch??e.inputs.baseBranch??"origin/main",i=UE(e.inputs,e.runDir);return["Plan functional tests for this PR. You won't write the tests: another session will, working from your plan alone,","so whatever it needs has to be in the plan.","",`The repo is at ${r}, checked out on branch \`${n}\`. You can see the change with \`git diff ${s}...HEAD\`.`,...BG(i,s),"Ignore .skyramp/ \u2014 it is Skyramp's own setup, not part of the change.",...ile(e),...ly(e.inputs,i.descriptions),...Wrt(e.inputs),...Yrt(e.inputs),"","1. Read the change: the diff, the description, and any spec, issue or design doc either of them points to.","2. List the requirements: everything the description or a spec states or clearly implies and, where they say"," nothing, what the change is evidently meant to do. Split each into independently testable clauses: each input"," class, boundary, error path, and anything it says must stay as it was. To find them, read the code the change"," wrote for the requirement, and the code it calls for what that answers, and ask where it would act differently \u2014"," for example a value of the wrong type, missing or empty, one at a limit and one just past it, a user who may not"," do it, or a record in a state that should stop it. Each that could change the outcome is a clause; one that can't"," needs none. What the change adds owns every answer it gives to the inputs it takes, including one that comes from"," code it calls (a missing record, an empty result); what that code does for its other callers is what the change"," could break (below), not a clause of the requirement. For each clause, write the expected outcome. Where the",' description or spec states the clause itself, copy its words under "stated". What they state is owed: where the'," code that decides it does not do it, new, unchanged or missing, that is a defect (step 3); where it does, the",' clause needs a test only if the change can alter its outcome, so a stated "stays as it was" in code no changed'," line reaches needs none.",` Each requirement's id is the label the description or spec gives it ("AC-3", "REQ-12"; item 4 of a numbered list`," is R4), else R1, R2\u2026 in order, numbering on after the highest R-label the source uses (R6 after its R5). Where two"," items give the same label, put the item's key in front (PAY-184-AC1, PAY-185-AC1). A clause id is its"," requirement's id plus a letter (AC-3a), and each id is used once. Every case, clause and journey step keeps these"," ids and names a clause or finding the plan has; a finding names the requirement or clause it breaks.",` Where sources disagree, the higher one sets the expected outcome: ${Vrt(e.inputs)}.`," Code that disagrees with what is stated is what's wrong. Two sources of the same rank that disagree leave it",' unsettled, whatever a lower one says: a question, as below, with each of them under its "sources". Where nothing'," is stated, take it from the change's evident intent; code that contradicts that intent, or itself"," elsewhere, is still a defect. Each expected outcome needs a reason the PR's author would accept: the words that"," state it, or an intent the change makes plain. Where more than one outcome would be reasonable and nothing you"," read says which is meant, don't choose one: expect only what every reading allows, such as no error and no data",' lost or stored wrongly (a check that rules one of them out has chosen), and put the rest under "questions", with'," each reading and what points to it. A question is for evidence that is really balanced. Where what you read leans"," one way \u2014 the description's words, what the page shows the user, how the code beside it does the same job \u2014 take"," that reading, expect it, and cite what leans; the reading you set aside is not a question. Data lost or stored"," wrongly, or an action that goes through on a record that should no longer allow it, is a defect whichever reading"," is meant, not a question."," Then list what the change could break that no requirement mentions \u2014 other callers of the functions it changed,"," other paths that read or write the same data, behaviour right next to the change \u2014 and add each as a requirement"," of its own (source could-break, evidence the code it could break), with its clauses. Could-break is only behaviour"," that worked before the change and that the change's own code does not decide: what a new or changed endpoint,"," page or function itself does belongs to the change's requirements (its description or spec, or its evident"," intent), even where nothing states it.",' For each clause, give under "code" the path:line of the code that decides it, when there is one.',"3. Note every defect you find in the change, with the line that shows it. Compare the change with the code beside it"," that does the same job \u2014 other routes answering the same kind of request, other reads of the same data, the other"," layer handling the same value, other code that copies the same record: where they handle a case the change handles"," differently (how a malformed id is answered, who may act, what a read leaves out, whether a value's case matters,"," which fields a copy carries) and the change's way is plainly the wrong one (it fails, loses data, or breaks a rule"," the code keeps everywhere else), the change is wrong unless the description asks for the difference. Where both"," ways are reasonable and nothing says which is meant, it is a question, as in 2, not a defect. A defect breaks a rule"," something you read states or leans to; a rule the app has nowhere (a field you think should be required, two"," values you think should match) is not one. On each page the"," change touches, follow what the user sees when its request fails, when they enter a value it refuses, and right"," after a save, without a reload."," A defect is the change's only where the change's own code does the wrong thing. Before you record one, look at the",` base (git show ${s}:<path>): where the base, left as it was, already does the same with the same kind of input,`,' the change only gives it a new way to be reached. Record such a defect with "existing" (where the base'," does it), and give it no case and no journey step that expects it fixed: it is reported as there before this"," change, not as this change's. A clause about code the change leaves as it was, which the base already does not"," meet, is such a defect, not a clause. But where the wrong outcome comes from something the change adds \u2014 a field,"," a route, a kind of input \u2014 that the base code it relies on was never set up to handle, the defect is the change's."," So is one where the description or spec states what something the change adds does (the status a new route"," answers, the message a new field shows) and it does otherwise: the base doing the same elsewhere does not make it"," existing.",' Give each defect of the change the rule it breaks: under "conflictsWith", the requirements or clauses that state',` it, or, for a rule only the code beside it keeps, under "keeps" that code's path:line (the code beside it, which the change left as it was).`,' Some rules every app keeps and nothing needs to state; a defect that breaks one names it under "rule":',` ${HN()} A defect with no rule at all is a rule you chose, not one the app has: leave it out.`,...Nlr(e,t),"5. Write the test plan for the new tests your triage leaves \u2014 the clauses it marks runtime under runtime_required, or",' new_unit under targeted_unit \u2014 and for the defects. Under existing_evidence_sufficient leave "cases" empty and give'," no clause a test: the evidence comes from triage's plan."," Write the test plan on the clauses themselves: each clause gets the test that checks it, using the input or"," situation the clause is about (type, target, steps \u2014 where a probe already exercised the clause, its requests, so"," the tests send them rather than work them out again;",` its expected outcome is the clause's, and its kind the one the repo already uses for that code, unless that kind cannot check it), or, on the clause, why it can't be tested here. Add to "cases" a second`," test for a clause where one is needed, and one case for every defect of the change you found \u2014 even where a clause's"," test covers the same ground. A defect's case reaches the defect itself (the state, input or sequence that shows it)"," and expects the correct behaviour, so it fails on this branch; where the requirement allows more than one correct"," outcome (reject, or cap), it accepts each of them, so it passes on any fix."," For each clause, ask how the change could get it wrong while its test still passes: another status or message"," than the one it states, a value left behind, the result kept somewhere other than where the user reads it, a path"," the clause covers (an undo, a reset, an input it refuses) that no case takes. Where it could, add to that clause's"," steps and expected outcome what would catch it, within the outcome the clause expects; it is not a new scenario.",' Under every decision, list under "maintenance" the existing tests you can see the change makes wrong or stale,'," and whether to update, delete, regenerate or just re-run (verify) each \u2014 a starting point: the step that writes"," the tests runs the affected tests and finds the rest. A test the change leaves passing, which you would only extend"," with new checks, is not one: those checks are this plan's cases, in the test file they belong in. One that calls the deployed app to check what the change itself alters makes the decision runtime_required (step 4), unless it is only to verify and in-process tests run here establish its clauses; a live-server test, which runs in-process, does not.",...nle(e),`6. Write the plan as JSON (below), "triage" included, to ${t.checkpoint} now, before anything is started.`,`7. ${Clr(e,t)}`,...Blr(e,t),...Tlr(e),"",`Stay inside the checkout and don't commit or push. When you're done, update ${t.checkpoint} with "app" filled in;`,"that file is what's read. End with a one-line final message \u2014 don't repeat the plan in it. The plan's JSON:","",Pu(Ki,0,Rlr(e))].join(`
678
+ `)}var WN=e=>!!e.appRunning&&Bl(e),Ilr=new Set(["mutates"]);function Rlr(e){return new Set([...WN(e.inputs)?[]:Ilr,...Ay(e.inputs).length?[]:["revisions"]])}function Tlr(e){return WN(e.inputs)?[" The app runs in a shared environment this policy protects. A case or clause whose test changes state there (an"," API POST, PUT, PATCH or DELETE, in the test or its setup, or a UI flow that submits, creates, edits or deletes) is"," withheld by the runner and reported as a gap: prefer cases that only read, and mark each that still changes state,",' and each such maintenance item, "mutates": true.']:[]}function mnt(e){return[" Under targeted_unit, probe in-process instead, the way the repo's own tests reach this code: one scratch test"," file, run with the repo's runner, that calls what decides each clause (the function or service, a handler through"," the repo's in-process test client, a component rendered as its tests render it), first with the input it normally"," gets, then with the same kinds of input, state and sequence. Put it where the runner finds it, name it so it is"," plainly scratch, keep a copy and its output",` under ${e}*, and delete it from the checkout once it has run. A flag that repeats there is a finding, with the`," call and its result as evidence, and gets its case as step 5 says."]}function klr(e){if(!e.skyrampWalk)return[];let t=bs.join(bs.dirname(e.checkpoint),"journey-walks");return["10. Under runtime_required, walk each browser journey once against the running app with the Skyramp walk helper:",` a Node script that calls \`require(process.env.SKYRAMP_WALK).walk(...)\` (usage at the top of ${e.skyrampWalk.helper}),`,` with ${t} as its outputDir and the script there too, outside the checkout. Walk from the journey's entry`," through every step to the action that finishes it, checking at each step what the user should then see. When a"," step fails, the helper prints the page and an accessibility snapshot: where the selector or route was wrong, fix it"," and walk again; where the page does something other than what the change intends, walk it once more, and if it"," repeats it is a finding, as a flagged probe is. Then write each journey's steps with the selectors and routes that",` worked, and the updated plan to ${e.checkpoint}. The walk fixes how a step is done, never which steps there are: each`," journey keeps its entry, every step and its outcome as 5 planned them, and a step that could not be walked stays"," in, with what stopped it, for the test to reach."]}function Blr(e,t){if(e.inputs.planOnly)return[];if(!e.inputs.appRunning&&t.preflight&&!t.preflight.sutRequired)return[];let r=bs.join(bs.dirname(t.checkpoint),"probe");return WN(e.inputs)?["8. Probe before any test is written. Under runtime_required, probe the running app (skip it if the app isn't"," answering). It is a shared environment this policy protects: send only requests that change nothing (GET and"," HEAD: reads, lists, searches, filters, sorts) and never create, edit, delete, reset or seed anything there. Put",` every probe in one script under ${r}*, each tagged with the clause it checks, and run it, printing a line for`," each probe a check flags (what it read, the status codes, which check failed) and, per clause, how many probes it"," got. Probe each clause through reads, as widely as its code gives reason to: every state its records can be in,"," every field it adds through list, sort, filter and search, and odd query values (zero, negative, huge, empty, case"," variants). Flag any 5xx, and reads that disagree with each other or with derived values (totals, counts).",...mnt(r),"9. Re-run each flagged probe once. Then probe once more where it is worth it: around each flag that repeated (the"," values and states next to it), for each clause a request could check that got no probe, and for each input or field"," the change adds that a kind of probe in 8 reached elsewhere but not there (a huge value sent to one number but not"," another, a field left out of one update but not another, a new field never sorted or filtered by); re-run what"," that flags. Each flag that repeats and involves what the change touched is a defect: add it to",' "findings" with the request and response as its evidence and the rule it breaks, as 3 says, and a case for it.',` Where 2 leaves the right behaviour open, it is a question instead. Then write the updated plan to ${t.checkpoint}`," again."]:["8. Probe before any test is written. Under runtime_required, probe the running app (skip it if the app isn't"," answering). Probe clause by clause: for each, first send what a user would normally send, to see it work and learn"," what the app answers, then the requests that would show it broken \u2014 wrong, missing and odd input, a limit and just"," past it, a user or record state that should be refused, a sequence that could leave it half done \u2014 as many as its"," code gives reason to. Go deepest where the change's own code decides the clause and where a"," failure would lose data, money or access; a cosmetic clause needs little. Put every probe in one script under",` ${r}*, each tagged with the clause it checks, and run it, printing a line for each probe a check flags (what it`," did, the status codes, which check failed) and, per clause, how many probes it got. In what the change touches, defects tend to hide in:"," - every state its records can be in (from the code's status fields and enums) \xD7 every operation the change adds or alters;"," - sequences: write then read back; set, reset, read; edit twice; delete then edit; write then list;"," - payloads: zero, negative, huge, empty, null, missing and extra fields, wrong types, case variants, more items"," than a page holds, one valid and one invalid item together;"," - every field the change adds, through the existing list, sort, filter and search."," Read the record before and after each action. Flag any 5xx; a rejected request that changed anything; a read that"," differs from what was written; a repeated request that changed something more; derived values (totals, counts)"," that disagree with their inputs; an operation that succeeds on a record in a final state (cancelled, shipped, deleted).",...mnt(r),"9. Re-run each flagged probe once. Then probe once more where it is worth it: around each flag that repeated (the"," values and states next to it), for each clause a request could check that got no probe, and for each input or field"," the change adds that a kind of probe in 8 reached elsewhere but not there (a huge value sent to one number but not"," another, a field left out of one update but not another, a new field never sorted or filtered by); re-run what"," that flags. Each flag that repeats and involves what the change touched is a defect: add it to",' "findings" with the request and response as its evidence and the rule it breaks, as 3 says, and a case whose'," steps are that request sequence and whose expected outcome is the correct behaviour.",` Where 2 leaves the right behaviour open, it is a question instead. Then write the updated plan to ${t.checkpoint}`," again.",...klr(t)]}function ole(e){let t=sn(e);return t?gT(xl(t,"").map(r=>r.path)):[]}function nle(e){let t=ole(e);if(!t.length&&!TF(e.inputs.repositoryPath))return[];let r=t.slice(0,8).join(", ")+(t.length>8?", \u2026":"");return[' User journeys: under "journeys", the flows a user walks through the UI, each from where a user normally starts it'," to the outcome they came for, that together pass through everything the change alters that a user sees or does:"," every ui clause is in some journey's steps (or under notInJourney, with why no journey reaches it). Use as many"," journeys as that takes. For each: the entry route; every step in order, with the clauses it exercises and what the user then sees;"," the outcome that shows the journey worked, in the spec's or PR description's own words: everything they say the"," user then sees (the exact message, the order a list is in, each field the page shows of what was saved), not a"," summary of it; under finishes, the user action that completes the task; its source \u2014"," the spec or PR description that describes the flow (quote it),"," else inferred; and the test file it belongs in. Each becomes one test of the whole flow as the PR intends it (its kind):"," in-process only where the repo's own in-process UI tests (component tests under jsdom or the like, for that code) can"," walk and check all of it \u2014 a request-level test client (for example Django's or Flask's, or Rails integration tests) runs no page script"," and does not count \u2014 else a browser test, which needs the running app, so the decision is runtime_required (step 4)."," The changed step is inside the flow, not the whole of it. The journey starts where a user starts the task (the app's"," entry, its login, or the navigation a user would use), not at a link into the changed page unless reaching it by link"," is what the change is about, and gets to the changed step through the page: what an earlier step of the same flow"," creates (the record a change then edits) the journey creates through the app's own form, not through the API. That"," is for the journey only: the other"," cases keep using the records the app already has wherever the change reads or edits existing data, since a record"," made fresh for the test can hide a defect that shows only on older data. The journey goes on past the changed step"," to the action that finishes the user's task (save, submit, pick, open, run), and its last step checks on the page"," what that action produces. The journey ends where the user sees the result,"," which may be past the changed page: the next page built from what was saved, or a record it links to. After a"," change that saves something, a step reloads or reopens it and checks it held. Where the steps only a browser could"," walk pass through what the change leaves as it was (the login and the way to the page, the server keeping what an"," unchanged action saved), and the change does not alter how the page reaches the server (its requests, routes or"," guards), they set the journey up rather than check it: it is in-process where the repo's in-process UI tests can"," check the rest, starting on the page as they do, with the server's answers given the way they give them."," Code that decides what a page shows"," counts though no page changed (a composable, store, hook, style or theme it renders from): what the user then sees"," is in a journey, whatever unit test also checks it."," So is a flow the spec or PR description describes a user walking, though no UI file changed, where server code"," alone gives the user an action or an outcome they did not have (a new command and its reply, being signed out):"," the journey checks it on the page. A new value through a form that already sends and shows it the way it did (a"," parser or validator behind an unchanged field) is not one: the tests of the changed code check it."," A repo with no browser tests is no reason to leave a clause out: its browser journeys go in a test package of their own."," Empty when the change alters nothing a user sees; then say so under notInJourney, per clause, with why. A change"," to UI code that alters what the page holds along a user flow (a DOM attribute, the theme, other client state the"," flow sets) owes a journey that asserts it, even when nothing in the repo reads it yet: that nothing reads it, or"," that the user cannot see it, is no reason to leave it out.",...t.length?[` The change touches UI files: ${r}.`]:[]]}function Nlr(e,t){let{budgetMinutes:r}=e.inputs;return["4. Validation triage, before anything is started: decide what evidence each clause still needs and the cheapest",' reliable way to get it, and save it as "triage" (its behaviorIds are your clause ids). The app is brought up only'," when the decision is runtime_required; existing evidence or native unit tests can often validate a change"," without it. You are not a code reviewer here: no style, naming or architecture commentary.","",...(s=>s.flatMap(i=>i.split(`
679
+ `)).map(i=>i?` ${i}`:""))([...Mrt(e,t.triage.change),"",...Frt(e,t.triage),...r?["",`Run budget: ${r} minutes for the whole run, including everything you plan. Name in gaps what it cannot cover.`]:[],"","Scope: validate what this change alters or newly reaches, and what the PR description or a spec states.","- Out of scope is only a clause the change cannot reach: its deciding code is unchanged and no changed path leads to it, or it lives in a checkout the change does not touch. List it under outOfScope with the unchanged line that decides it (path:line), and plan nothing for it. Code the change newly calls or feeds new values to is in scope; a defect found there in the base's own code is recorded as step 3 says. A path is one you can see in the code: a call, an import or a route that reaches the changed code (find its callers); a comment or a name saying code is shared is not one. What something the change adds answers for the inputs it takes is the change's own (step 2). Unchanged code that receives a new value through a path it already had is in scope for what it newly does with it; where it handles the value the way it already handled others, its behaviour has not changed, and it is what the change could break, not what it alters.","","The evidence ladder \u2014 use the cheapest mechanism that establishes each clause in scope:"," existing_evidence an accepted ci-<n> result. A check you ran (typecheck, compile, test collection) establishes only a prerequisite clause \u2014 that the change builds or its config parses \u2014 never a behaviour"," unaffected the change cannot reach this clause: no changed code path leads to it \u2014 cite the code that shows it (path:line); never for a clause decided in a changed file"," existing_unit existing native unit tests that exercise the clause"," new_unit a new in-process test, for evidence nothing provides yet"," runtime only the running application can establish it","A clause only the running app can check is runtime, not a gap, even when every other clause is in-process. It is a gap only when the app cannot be run here; then name what is missing.","Give each gap what it needs: browser (only a real browser shows it), running-app (only the running app or its server shows it: its real requests, sign-in and permissions, what it saves), or outside (something the running app here could not give either: a third-party service it calls, hardware). An app you have not tried to start is no reason for outside.","Give each clause the kind of test the repo already uses for the code it checks \u2014 in-process where the repo tests that code in-process, runtime where it tests it against the running app \u2014 unless that kind cannot check it; then the kind that can. Where it tests that code both ways, as component specs and an end-to-end suite, the in-process kind is the one when it can check the clause.",`Browser-only: for every clause, ask whether its behaviour happens only in a browser \u2014 real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript \u2014 and if so mark it browserOnly. A test that only checks markup (a class or attribute present, the HTML a request returns) proves the precondition, not the behaviour: the header having the sort class does not show that "clicking a column header sorts the list". A browser-only clause is tested in a browser: in the repo's in-process browser harness where it has one \u2014 a suite that starts the app in the test process and drives a real browser (for example a Django LiveServerTestCase with Selenium or Playwright); component tests under jsdom only when the repo's own jsdom tests already drive that kind of interaction \u2014 named as its browserHarness (the suite's path), and the clause stays new_unit, with its triage item's covers saying it is driven in that browser suite; else decide runtime_required with a browser test of it. A markup check may be added, not substituted.`,"","Decisions:","- existing_evidence_sufficient means every clause in scope is established by existing evidence, with no gaps.","- A change that touches no application file (only docs, configuration or CI, in every checkout, and no lockfile) is existing_evidence_sufficient: the diff, and a check you ran that its configuration parses, establish what those files say. Plan no new test for it: a test that pins a file's contents (an action version, an editor setting, a README sentence) checks nothing a user does.","- targeted_unit plans unit tests and nothing that needs a running app.","- runtime_required marks at least one clause runtime, and plans no new unit tests: once the app is needed, this plan's cases are every new test, each still written the way the repo tests that code \u2014 in-process where that can check its clause, in the browser only where it cannot. The existing unit tests you identify still run, as existing_unit.","- The journeys and maintenance of step 5 can need the app too, so plan them before you decide. Decide runtime_required when any journey needs a browser \u2014 behaviour that runs in the page (its script, or attributes a page library acts on), navigation across pages or what persists after a reload, where the change alters either, or a server-rendered page the repo tests only at the request level \u2014 and mark runtime the clauses its steps exercise.",'- Decide runtime_required as well when any test under "maintenance" calls the deployed app \u2014 API, contract, integration, end-to-end or UI tests that reach it at its address (BASE_URL or the like), and Skyramp tests \u2014 and checks what the change itself alters, and mark runtime the clauses it checks, so it is verified against the app. So does a gap, for what the change itself alters, that needs a browser or the running app, and a browser-only clause the repo has no in-process browser harness for. A test under "maintenance" only to verify, whose clauses in-process tests run here establish (existing_unit or new_unit, not a CI result), does not: running it again against the app shows nothing they do not.',"- A test that starts its own live server in the test process and drives it in a browser (for example Django's LiveServerTestCase or pytest-django's live_server, with Selenium or Playwright) needs no deployed app: under targeted_unit it is maintained and run in-process, with the repo's CI settings and a headless browser.","- When the app cannot be run here, list each such journey's clauses under notInJourney, and each such test under gaps, with what is missing: it is reported not covered, never dropped. So is a browser-only clause with no in-process browser harness: name it under gaps with what is missing.","- A defect you found (step 3) that only the running app can show makes the decision runtime_required wherever its code is, in the change or downstream of it: one in page script or in what the user sees after a click or a save, where the repo has no in-process browser harness for it, or in code the repo tests only against the running app's API. Mark it needsApp (browser or live-api) and give it its case. A defect an in-process test can show is not needsApp. When the app cannot be run here, name it under gaps with what is missing.","- Otherwise only what the change itself alters decides it. A journey or browser-only clause only for what the change could break elsewhere (a could-break requirement), or for UI code the change does not touch when it touches no UI code, does not make the decision runtime_required: off the runtime path list its clauses under notInJourney and the browser-only ones under gaps, with what is missing (a browser, downstream of this change), so it is reported not covered. Nor does a maintained test that calls the deployed app only for such clauses: give each maintained test the clauses it checks, and name such a test under gaps with what is missing (the running app, downstream of this change). A journey through a flow the spec or PR description describes a user walking is not one of these, though no UI file changed, where server code alone gives the user an action or an outcome they did not have (a new command and its reply, being signed out). A new value through a form that already sends and shows it the way it did (a parser or validator behind an unchanged field) stays off the runtime path.","- blocked_preflight: the change cannot meet a basic prerequisite. It names the changed file the failure is in and quotes the error, and plans nothing. A check that fails for an environment reason (a dependency not installed, a missing tool) is not the change failing \u2014 never block on it. Nor is test code the change adds or edits that does not load (a conftest, fixture or helper with an import that does not resolve): it is maintenance, not a block \u2014 plan the tests it stops as update, with its repair as theirs.","","Rules:","- Every clause is planned, listed in gaps, or listed under outOfScope, by its id (R1a). A gap is evidence this run cannot obtain; a test this run will execute (existing_unit, new_unit, runtime) is not one, even when you could not run it while planning.","- Only accepted ci-<n> items, and passing checks you ran for prerequisite clauses, can establish a clause. A stale, untrusted, pending, failing or inconclusive result establishes nothing; a trusted result that failed is a reason to plan evidence, never a pass. AI review is advisory, never evidence.","- Find the existing tests yourself: where the repo keeps tests of the changed code, and their framework.",'- Existing tests that call a running app (API, contract, integration, end-to-end or UI tests) are never evidence: list them in "maintenance" (verify, or update).',"- Repository evidence is only native unit tests, which run without the app. Every repository evidence item lists its tests as repo-relative paths (path::test-name when the file holds more than the relevant ones) \u2014 only the tests that exercise the changed behavior, never the whole suite.",`- ${AQe}`,`- ${dC}`,"- Every repository evidence item is run: cite it from an existing_unit item for the clauses it exercises. Only under existing_evidence_sufficient is nothing run: cite it from the existing_evidence item it supports instead.","- Plan new_unit only for what no existing test asserts, or asserts differently from the requirement (the boundary the change moved); never for what existing tests already prove.","- When the PR description or a spec states the expected behavior, plan evidence for what it states, not for what the code does.","- Evidence items are existing repository tests (source repository) and checks you ran with Bash (source testbot), each with a unique id; the ci-<n> results above are not restated. Run each check as one plain command \u2014 no `&&`, pipes or `echo` \u2014 and copy it into its evidence exactly. Don't start the application, install dependencies or run test suites for triage."])]}function _lr(e){let t=e.prepared,r=e.inputs.repositoryPath,n=t.preflight?.repository.currentBranch??"HEAD",s=t.preflight?.repository.baseBranch??e.inputs.baseBranch??"origin/main",i=UE(e.inputs,e.runDir);return["Plan functional tests for this PR. You won't write the tests: another session will, working from your plan alone,","so whatever it needs has to be in the plan.","",`The repo is at ${r}, checked out on branch \`${n}\`. You can see the change with \`git diff ${s}...HEAD\`.`,...BG(i,s),"Ignore .skyramp/ \u2014 it is Skyramp's own setup, not part of the change.",...ile(e),...ly(e.inputs,i.descriptions),...Wrt(e.inputs),...Yrt(e.inputs),"","1. Read the change: the diff, the description, and any spec, issue or design doc either of them points to.","2. List the requirements: everything the description or a spec states or clearly implies and, where they say"," nothing, what the change is evidently meant to do. Split each into independently testable clauses: each input"," class, boundary, error path, and anything it says must stay as it was. To find them, read the code the change"," wrote for the requirement, and the code it calls for what that answers, and ask where it would act differently \u2014"," for example a value of the wrong type, missing or empty, one at a limit and one just past it, a user who may not"," do it, or a record in a state that should stop it. Each that could change the outcome is a clause; one that can't"," needs none. What the change adds owns every answer it gives to the inputs it takes, including one that comes from"," code it calls (a missing record, an empty result); what that code does for its other callers is what the change"," could break (below), not a clause of the requirement. For each clause, write the expected outcome. Where the",' description or spec states the clause itself, copy its words under "stated". What they state is owed: where the'," code that decides it does not do it, new, unchanged or missing, that is a defect (step 3); where it does, the",' clause needs a test only if the change can alter its outcome, so a stated "stays as it was" in code no changed'," line reaches needs none.",` Each requirement's id is the label the description or spec gives it ("AC-3", "REQ-12"; item 4 of a numbered list`," is R4), else R1, R2\u2026 in order, numbering on after the highest R-label the source uses (R6 after its R5). Where two"," items give the same label, put the item's key in front (PAY-184-AC1, PAY-185-AC1). A clause id is its"," requirement's id plus a letter (AC-3a), and each id is used once. Every case, clause and journey step keeps these"," ids and names a clause or finding the plan has; a finding names the requirement or clause it breaks.",` Where sources disagree, the higher one sets the expected outcome: ${Vrt(e.inputs)}.`," Code that disagrees with what is stated is what's wrong. Two sources of the same rank that disagree leave it",' unsettled, whatever a lower one says: a question, as below, with each of them under its "sources". Where nothing'," is stated, take it from the change's evident intent; code that contradicts that intent, or itself"," elsewhere, is still a defect. Each expected outcome needs a reason the PR's author would accept: the words that"," state it, or an intent the change makes plain. Where more than one outcome would be reasonable and nothing you"," read says which is meant, don't choose one: expect only what every reading allows, such as no error and no data",' lost or stored wrongly (a check that rules one of them out has chosen), and put the rest under "questions", with'," each reading and what points to it. A question is for evidence that is really balanced. Where what you read leans"," one way \u2014 the description's words, what the page shows the user, how the code beside it does the same job \u2014 take"," that reading, expect it, and cite what leans; the reading you set aside is not a question. Data lost or stored"," wrongly, or an action that goes through on a record that should no longer allow it, is a defect whichever reading"," is meant, not a question."," Then list what the change could break that no requirement mentions \u2014 other callers of the functions it changed,"," other paths that read or write the same data, behaviour right next to the change \u2014 and add each as a requirement"," of its own (source could-break, evidence the code it could break), with its clauses. Could-break is only behaviour"," that worked before the change and that the change's own code does not decide: what a new or changed endpoint,"," page or function itself does belongs to the change's requirements (its description or spec, or its evident"," intent), even where nothing states it.",' For each clause, give under "code" the path:line of the code that decides it, when there is one.',"3. Note every defect you find in the change, with the line that shows it. Compare the change with the code beside it"," that does the same job \u2014 other routes answering the same kind of request, other reads of the same data, the other"," layer handling the same value, other code that copies the same record: where they handle a case the change handles"," differently (how a malformed id is answered, who may act, what a read leaves out, whether a value's case matters,"," which fields a copy carries) and the change's way is plainly the wrong one (it fails, loses data, or breaks a rule"," the code keeps everywhere else), the change is wrong unless the description asks for the difference. Where both"," ways are reasonable and nothing says which is meant, it is a question, as in 2, not a defect. A defect breaks a rule"," something you read states or leans to; a rule the app has nowhere (a field you think should be required, two"," values you think should match) is not one. On each page the"," change touches, follow what the user sees when its request fails, when they enter a value it refuses, and right"," after a save, without a reload."," A defect is the change's only where the change's own code does the wrong thing. Before you record one, look at the",` base (git show ${s}:<path>): where the base, left as it was, already does the same with the same kind of input,`,' the change only gives it a new way to be reached. Record such a defect with "existing" (where the base'," does it), and give it no case and no journey step that expects it fixed: it is reported as there before this"," change, not as this change's. A clause about code the change leaves as it was, which the base already does not"," meet, is such a defect, not a clause. But where the wrong outcome comes from something the change adds \u2014 a field,"," a route, a kind of input \u2014 that the base code it relies on was never set up to handle, the defect is the change's."," So is one where the description or spec states what something the change adds does (the status a new route"," answers, the message a new field shows) and it does otherwise: the base doing the same elsewhere does not make it"," existing.",' Give each defect of the change the rule it breaks: under "conflictsWith", the requirements or clauses that state',` it, or, for a rule only the code beside it keeps, under "keeps" that code's path:line (the code beside it, which the change left as it was).`,' Some rules every app keeps and nothing needs to state; a defect that breaks one names it under "rule":',` ${HN()} A defect with no rule at all is a rule you chose, not one the app has: leave it out.`,...Nlr(e,t),"5. Write the test plan for the new tests your triage leaves \u2014 the clauses it marks runtime under runtime_required, or",' new_unit under targeted_unit \u2014 and for the defects. Under existing_evidence_sufficient leave "cases" empty and give'," no clause a test: the evidence comes from triage's plan."," Write the test plan on the clauses themselves: each clause gets the test that checks it, using the input or"," situation the clause is about (type, target, steps \u2014 where a probe already exercised the clause, its requests, so"," the tests send them rather than work them out again;",` its expected outcome is the clause's, and its kind the one the repo already uses for that code, unless that kind cannot check it), or, on the clause, why it can't be tested here. Add to "cases" a second`," test for a clause where one is needed, and one case for every defect of the change you found \u2014 even where a clause's"," test covers the same ground. A defect's case reaches the defect itself (the state, input or sequence that shows it)"," and expects the correct behaviour, so it fails on this branch; where the requirement allows more than one correct"," outcome (reject, or cap), it accepts each of them, so it passes on any fix."," For each clause, ask how the change could get it wrong while its test still passes: another status or message"," than the one it states, a value left behind, the result kept somewhere other than where the user reads it, a path"," the clause covers (an undo, a reset, an input it refuses) that no case takes. Where it could, add to that clause's"," steps and expected outcome what would catch it, within the outcome the clause expects; it is not a new scenario.",' Under every decision, list under "maintenance" the existing tests you can see the change makes wrong or stale,'," and whether to update, delete, regenerate or just re-run (verify) each \u2014 a starting point: the step that writes"," the tests runs the affected tests and finds the rest. A test the change leaves passing, which you would only extend"," with new checks, is not one: those checks are this plan's cases, in the test file they belong in. One that calls the deployed app to check what the change itself alters makes the decision runtime_required (step 4), unless it is only to verify and in-process tests run here establish its clauses; a live-server test, which runs in-process, does not.",...nle(e),`6. Write the plan as JSON (below), "triage" included, to ${t.checkpoint} now, before anything is started.`,`7. ${Clr(e,t)}`,...Blr(e,t),...Tlr(e),"",`Stay inside the checkout and don't commit or push. When you're done, update ${t.checkpoint} with "app" filled in;`,"that file is what's read. End with a one-line final message \u2014 don't repeat the plan in it. The plan's JSON:","",Pu(Ki,0,Rlr(e))].join(`
680
680
  `)}function Plr(e,t){if(!t)return;let r=Xce(t);if(!r){kn(e).warn("[plan] app.login names a variable the environment does not set: no login for the tests");return}snt(e.runDir,t),e.secretValues=js([...e.secretValues??[],r.password]),e.provideSutLogin?.(JSON.stringify(r))}function Dlr(e){let t=e.app?.login;if(!e.app||!t||q2(t))return e;let{login:r,...n}=e.app;return{...e,app:n}}function _x(e,t,r){let n=bs.join(e.outputsDir,t);return ag.writeFileSync(n,JSON.stringify(Br(r,e.secretValues??[]),null,2)+`
681
681
  `),bs.relative(e.runDir,n)}function Ent(e){let t=ec(e.inputs.repositoryPath);return t.teardownScript?`bash ${bs.relative(e.inputs.repositoryPath,t.teardownScript)}`:void 0}function ale(e){return Mh(e.inputs).map(t=>t.body)}function wnt(e,t){Plr(e,t.app?.login),t=Dlr(t);let r=ont(t);r!==t&&kn(e).warn("[plan] the plan used an id more than once: renamed the later ones so each is kept");let n=ale(e),s=Lce(r,e.inputs.requirementItems,e.inputs.repositoryPath,n);s.length&&kn(e).warn(`[plan] left out ${s.length} requirement(s) that do not hold to their item: ${s.map(g=>g.id).join(", ")}`);let i=s.map(({id:g,why:w})=>({id:g,reference:r.requirements.find(A=>A.id===g)?.reference,why:w})),o=BMe(Uce(r,e.inputs.requirementItems,e.inputs.repositoryPath,n),g=>kn(e).warn(`[plan] case id ${g} is used twice: kept one case and left out the other`)),a=dnt(o,g=>kn(e).warn(`[plan] case ${g} left out: a maintained test checks its clause`)),c=E5(e,a.triage,!!a.app,Z6(a,Ts(e.inputs.requirementItems))),l=c.length===0,u=!l||a.triage?.decision==="runtime_required",d=NMe(l?_Me(a):a,u),p=sn(e),f=OMe(d,{repository:p?.repository??{path:e.inputs.repositoryPath,currentBranch:"HEAD",baseBranch:e.inputs.baseBranch??""},changedFiles:p?.changedFiles.map(g=>g.path)??[],nonApplicationOnly:p?.nonApplicationOnly??!1,defaultTeardown:Ent(e),itemNames:Ts(e.inputs.requirementItems),related:e.inputs.relatedRepos,recipeRecorded:e.prepared?.recipeRecorded});f.ambiguous.length&&kn(e).warn(`[plan] maintained test in both the repo under test and a related checkout, kept the repo under test's: ${f.ambiguous.join(", ")}`);let m={plan:_x(e,"plan.json",d),analyze:_x(e,"analyze.json",f.analyze),recommend:_x(e,"recommend.json",WN(e.inputs)?l6(e.inputs,f.recommend):f.recommend)};return m.notPlanned=_x(e,P2,i),f.deploy&&(m.deploy=_x(e,"deploy.json",f.deploy)),l?Object.assign(m,CFe(e,d.triage)):a.triage&&(m.triageSetAside=_x(e,WF,{problems:c})),m}var Olr={runtime_required:"validation triage: the change needs the running app \u2014 tests against it follow",targeted_unit:"validation triage: unit tests are enough \u2014 no app deployed",existing_evidence_sufficient:"validation triage: existing evidence is enough \u2014 no app deployed, no new tests",blocked_preflight:"validation triage: the change does not meet a prerequisite \u2014 nothing further runs"};function Qlr(e){let t=me(e,"triage.json");if(t)return Olr[t.decision];let r=me(e,"plan.json");return r?E5(e,r.triage,!!r.app)[0]:void 0}async function Mlr(e,t){let r=e.inputs.sharedEnvironment;if(!e.inputs.appRunning||!sC(r))return{};let n=await nC(r,[],t,e.secretValues??[],e.platform,await uF(e,r));return Kr(e,Is,Br(n,e.secretValues??[]),[])}async function Flr(e,t){let r=e.inputs.sharedEnvironment;if(!sC(r)||!vnt(e)||!Glr(e))return{};let n=await nC(r,t,void 0,e.secretValues??[],e.platform,await uF(e,r));return Kr(e,Is,Br(n,e.secretValues??[]),[])}async function Llr(e,t){let r=e.inputs.sharedEnvironment,n=me(e,`${Is}.json`);if(!r||!n||!t.length)return{};let s=await nC({...r,components:Ay(e.inputs),dependencies:[]},t,void 0,e.secretValues??[],e.platform),i=n.components.map(o=>s.components.find(a=>a.name===o.name&&Xh(a.repository,o.repository))??o);return Kr(e,Is,Br({...n,components:i},e.secretValues??[]),[])}var bnt=async(e,t)=>e.inputs.appRunning?Llr(e,t):Flr(e,t),Snt="plan-shared-revisions",Ulr={name:Snt,async verify(e,t){let{value:r}=Er(Ki,t.stdout,io(e),e.secretValues),n=await f6(e,r?.app?.revisions??[]);return n.length?{name:this.name,passed:!1,details:n.join("; "),repairable:!0}:{name:this.name,passed:!0}}},cle="plan-no-secret-leak",$lr=fC(cle,()=>[]),Cnt={name:cle,verify:(e,t,r,n)=>$lr.verify(e,{...t,stdout:""},r,n)};async function qlr(e,t){if(t.some(o=>o.gates.some(a=>a.name===cle&&!a.passed)))return;let r=t.at(-1)?.session;if(!(await Cnt.verify(e,r??{exitCode:1,stdout:"",stderr:"",timedOut:!0,durationMs:0},lle)).passed)return;let s=AC(bs.join(ow(e),sle)),i=NF(Ki,[...t.map(o=>o.session?.stdout).reverse(),s,PMe(s)]);return i?{...wnt(e,i),...await bnt(e,[])}:void 0}function vnt(e){if(e.inputs.appRunning||e.inputs.planOnly)return!1;let t=sn(e);if(t&&!t.sutRequired)return!1;let r=me(e,"plan.json");return!(r?.triage&&!bC(r.triage.plan)&&!r.app)}function Glr(e){let t=me(e,"plan.json")?.app?.outcome;return t==="clean"||t==="recipe-drift"}function gnt(e){if(!vnt(e))return;let t=me(e,"deploy.json")?.teardown??Ent(e);!t||t==="true"||(0,ynt.spawnSync)(t,{shell:!0,cwd:e.inputs.repositoryPath,env:vt(),timeout:12e4,stdio:"ignore"})}var xnt="plan-triage-grounded",jlr={name:xnt,verify(e,t){let{value:r}=Er(Ki,t.stdout,io(e),e.secretValues);if(!r)return{name:this.name,passed:!0};let n=Uce(r,e.inputs.requirementItems,e.inputs.repositoryPath,ale(e)),s=[...y5(e,n.triage,!!n.app,Z6(n,Ts(e.inputs.requirementItems))),...Prt(n.triage,sn(e))];return s.length?{name:this.name,passed:!1,details:s.join("; "),repairable:!0}:{name:this.name,passed:!0}}},Int="plan-journeys",Hlr=[/\b(?:no|without|lacks?|missing)\b[^.;:]{0,30}\b(?:browser|e2e|end-to-end|playwright|cypress|selenium|ui|frontend|front-end)\b[^.;:]{0,30}\b(?:tests?|harness|runner|setup|framework|installed|suite)\b/i,/\bno\s+(?:tests?|harness)\s+(?:for|of)\s+the\s+(?:ui|frontend|front-end|browser|pages?)\b/i],zlr=/\b(?:credentials?|log[- ]?ins?|sso|auth\w*|accounts?|seed(?:ed)?|external|third[- ]party|api[- ]keys?|secrets?|tokens?|observ\w*|visible|shows?|logs?|reach\w*|unreachable|behind|admin\w*|licen[cs]e\w*|hardware|devices?|e-?mail|sms|payment|stripe|host[- ]app|embedd\w*)\b/i,Vlr=e=>Hlr.some(t=>t.test(e))&&!zlr.test(e),Wlr=/\b(?:not|never|isn'?t|aren'?t)\s+(?:visible|seen|shown|user[- ]visible)\b|\binvisible\b|\bno\s+(?:user[- ])?visible\b|\b(?:user|nobody|no one)\s+sees\s+no(?:thing)?\b|\bnothing\s+(?:a|the)\s+user\s+sees\b|\bnothing\b[^.;]{0,40}\b(?:styles?|reads?|renders?|consumes?|uses?)\b|\bno\s+(?:css|style|component|rendering)\b[^.;]{0,40}\b(?:reads?|consumes?|depends?|uses?)\b/i,Jlr=/\b(?:not reachable|unreachable|no (?:route|page|screen|flow|path|link) (?:reaches|renders|opens|leads to)|(?:rendered|used|mounted) only (?:by|in|from)\b[^;]{0,100}\bnothing (?:in the app )?(?:renders|uses|mounts))/i;function Ylr(e){let t=!1,r=[];for(let n of e){let s=n.why??"",i=!Jlr.test(s)&&(Wlr.test(s)||/^\s*same\b/i.test(s)&&t);i&&r.push(n.clause),t=i}return r}var Klr={name:Int,verify(e,t){let{value:r}=Er(Ki,t.stdout,io(e),e.secretValues);if(!r)return{name:this.name,passed:!0};let n=!r.triage||r.triage.decision==="runtime_required",s=r.requirements.flatMap(A=>A.clauses),i=new Set([...r.cases.map(A=>A.id),...s.map(A=>A.id)]),o=Mh(e.inputs),a={takenIds:i,clauses:new Set(s.map(A=>A.id)),uiClauses:nle(e).length?s.filter(A=>A.type==="ui"&&!A.skip?.trim()).map(A=>A.id):[],notInJourney:new Set((r.notInJourney??[]).map(A=>A.clause)),quoted:A=>m6(o,A)},c=sn(e),l=c?xl(c,"").map(A=>A.path):[],u=n?[]:AFe(r,{locate:ET(e.inputs.repositoryPath,e.inputs.relatedRepos??[]),runtimePossible:!!e.inputs.appRunning||c?.sutRequired!==!1,...c?{own:jF(r,l,gT(l).length>0)}:{}}),d=n?r.journeys:(r.journeys??[]).filter(A=>A.kind==="in-process"),p=(r.notInJourney??[]).filter(A=>Vlr(A.why??"")).map(A=>`clause ${A.clause} is under notInJourney because the repo has no browser tests, which is no reason to leave it out: put it in a journey \u2014 in-process where the repo's in-process tests can walk and check it, else a browser test in a test package of its own (decide runtime_required)`),f=nle(e).length?ole(e):[],m=f.length&&!(r.journeys??[]).length&&!(r.notInJourney??[]).length?[`the change touches UI code (${f.slice(0,5).join(", ")}) and the plan has no journey: plan the journey through what a user then sees change, or, if the change alters nothing a user sees, list its clauses under notInJourney with why`]:[],g=f.length&&TF(e.inputs.repositoryPath)?Ylr(r.notInJourney??[]).map(A=>`clause ${A} is under notInJourney because nothing reads it or the user cannot see it, and the change touches UI code: a change to UI code that alters what the page holds along a user flow owes a journey that asserts it, even when nothing reads it yet \u2014 put the clause in that flow's journey, at the step that sets it, and assert it there`):[],w=[...u,...p,...m,...g,...mMe(d,a)];return w.length?{name:this.name,passed:!1,details:w.join("; "),repairable:!0}:{name:this.name,passed:!0}}},Rnt="plan-requirements-grounded",Xlr={name:Rnt,async verify(e,t){let{value:r}=Er(Ki,t.stdout,io(e),e.secretValues);if(!r)return{name:this.name,passed:!0};e.reviewItemFile&&await $rt(r,e.inputs.requirementItems,e.reviewItemFile);let n=Lce(r,e.inputs.requirementItems,e.inputs.repositoryPath,ale(e));return n.length?{name:this.name,passed:!1,repairable:!0,droppable:n.map(({id:s})=>s),details:n.map(({id:s,why:i})=>`${s}: ${i}`).join("; ")}:{name:this.name,passed:!0}}};function Zlr(e,t,r){let n=r.some(u=>u.name===Rnt)?`Repair "requirements" in ${io(e)}: give each requirement-reference requirement its item's key as "reference" and, as evidence, words copied exactly from that item's file. A requirement no item states is not requirement-reference: one a file of the repository states is spec, with that file as its evidence, and one a pull request description states is pr-description, with its words as evidence. One that still does not hold is dropped and reported as not planned.`:void 0,s=r.some(u=>u.name===Int)?`Repair "journeys" in ${io(e)} as named above: each needs an entry route, at least two steps each saying what the user then sees, the outcome, the action that finishes the task (walked to, not stopped short of) and a test file, and every ui clause is in some journey's steps or under notInJourney. Where a journey, maintained test or browser-only clause above needs the running app, decide runtime_required in "triage" and mark runtime the clauses it checks (keep existing_unit for the existing unit tests, and make new_unit clauses runtime).`:void 0,i=r.some(u=>u.name===Zce)?`Repair the ids in ${io(e)} as named above and keep the rest of the plan: each id is used once (where two items give the same label, put the item's key in front: PAY-185-AC1; unlabelled requirements number on after the highest R-label), a clause id is its requirement's id plus a letter, every case, clause and journey step names a clause or finding the plan has, and a finding names the requirement or clause it breaks.`:void 0,o=r.some(u=>u.name===ele)?`Repair "findings" in ${io(e)} as named above and keep the rest of the plan: give each defect the rule it breaks, under "conflictsWith" the requirements or clauses that state it, under "rule" the rule every app keeps that it breaks, or under "keeps" the path:line of the code beside the change, which it left as it was, that keeps it. Remove a defect with none, and the cases that test it.`:void 0,a=r.some(u=>u.name===Snt)?`Repair "${j2}" in ${io(e)}: for each check named above, record what its url returns now, verbatim, or leave the component out.`:void 0,c=r.some(u=>u.name===rle)?`Repair the clauses named above in ${io(e)} and keep the rest of the plan: a clause whose outcome this change cannot alter needs no test, so remove it with the cases and journey steps that name it. Where a line this change wrote leads to its outcome (a new route or call that reaches the code that decides it), name that line under "code" as well. Where the code that decides it does not do what the description or spec states, record that defect as step 3 says.`:void 0,l=eur(e,t,r);return[n,i,o,c,l,s,a].filter(Boolean).join(`
682
682
  `)||void 0}function eur(e,t,r){let n=r.filter(o=>o.name===xnt);if(!n.length)return;let s=Lrt(e,t,n),i=n.some(o=>/brought the app up/.test(o.details??""))?['Only runtime_required starts the app: when a clause needs it, decide runtime_required and mark that clause runtime; when none does, stop what you started and remove "app" from the plan.']:[];return[`Repair "triage" in ${io(e)} and keep the rest of the plan: its behaviorIds are your clause ids.`,...i,...s?[s]:[]].join(`
package/dist/post.js CHANGED
@@ -119,7 +119,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}fun
119
119
  `)[0].length<=yl,{message:`subject line must be <= ${yl} chars`})}),pr:u.object({title:Cs.max(yl,`must be <= ${yl} chars`),body:Cs}),ready:u.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:u.array(u.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:Cs.describe("one paragraph")});var ii=le(require("fs")),Ec=le(require("path")),eD=require("child_process");var fr="{junit}",$p=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))($p||{}),cC=(e=>(e.Minitest="minitest",e))(cC||{}),JN=u.string().trim().min(1),mc=u.object({cwd:JN.describe('repo-relative directory the command starts in ("." for the root)'),argv:u.array(JN).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${fr}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:u.record(u.string(),u.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:u.object({format:u.nativeEnum($p).describe(`junit (JUnit XML to ${fr}), trx (to ${fr}), or go-test-json (go test -json on the command's output)`),reporter:u.nativeEnum(cC).optional().describe("a reporter Testbot loads for a runner that writes no report: minitest")}).optional().describe("the report the command writes; junit when omitted")});var yc="a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test), or one the repository's test script runs through another command (ng test, nx test)",Tne=`pytest, Jest, Vitest and node --test tests run as the run already knows them, unless the repository's test script runs them through another command (ng test, nx test), which may be the only one that compiles them. A test in any other framework, or one run that way, also gives "run": the repository's own command for only those tests, from the directory the repository runs it in, as separate arguments without a shell. Its "report" says what the runner writes: junit (JUnit XML to ${fr} in the reporter's argument or env setting), trx (a TRX file to ${fr}, which every dotnet test writes with its built-in logger), or go-test-json (go test -json, read from the command's output). A Maven or Gradle command names no ${fr}: its build writes JUnit XML to its own report directory, which the run reads. Use a reporter the repository already has, or one of those; a reporter or converter the command fetches is the version the repository pins, or else its latest release (an older one may not build with the repository's toolchain). For minitest, which writes none, give report.reporter "minitest" and the run fills ${fr} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${fr} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${fr} in argv and env with its report path, executes the command, and reads that report.`;var Lo=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(Lo||{}),si=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(si||{}),uC=(n=>(n.Repository="repository",n.Testbot="testbot",n))(uC||{}),lC=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(lC||{}),on=u.string().trim().min(1),K9=u.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var Z9=u.object({id:K9,source:u.nativeEnum(uC),kind:u.nativeEnum(Js),outcome:u.nativeEnum(lC),summary:on.max(400).describe("one line: what it shows"),tests:u.array(on).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:on.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:on.optional().describe("source testbot: the exact command you ran, as you ran it"),run:mc.optional().describe(`source repository, for tests in ${yc}: how the run executes only these tests, all of them in one command, with the repository's own runner writing JUnit XML to {junit}. Name each test (path::test-name): a test is credited to a file only by its name or by a report that names the file`)}),X9=u.object({behaviorId:on.describe("an id from analyze's behaviors"),mechanism:u.nativeEnum(si),evidenceIds:u.array(on).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:u.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),dC=(r=>(r.Browser="browser",r.RunningApp="running-app",r.Outside="outside",r))(dC||{}),eK=u.object({behaviorId:u.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:on.max(600).describe("the evidence that is required and cannot be obtained in this run"),needs:u.nativeEnum(dC).optional().describe("what that evidence needs: browser (only a real browser shows it), running-app (only the running app or its server shows it: its real requests, sign-in and permissions, what it saves), or outside (something the running app here could not give either: a third-party service it calls, hardware)")}),tK=u.object({file:on.describe("the changed file the failure is in"),repository:on.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:on.max(300).describe("what prerequisite the change fails"),evidence:on.max(400).describe("the error line, quoted")}),nK=u.object({behaviorId:on.describe("an id from analyze's behaviors"),reason:on.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),El=u.object({schemaVersion:u.literal(1),decision:u.nativeEnum(Lo),evidence:u.array(Z9).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:u.array(X9).describe("how each changed behavior's evidence is obtained"),gaps:u.array(eK),outOfScope:u.array(nK).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:tK.optional().describe("only for blocked_preflight"),rationale:on.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function Vp(t){let e=Ke(t,"recommend.json");if(!e||!Array.isArray(e.generate)||!Array.isArray(e.maintenance))return;let n=e;return{...n,maintenance:n.maintenance.map(({repository:r,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...r?.trim()?{repository:r.trim()}:{}}))}}var Oo=le(require("fs"));function WN(t){let e=[];for(let n of oK(t)){let r=n;r?.type==="tool_use"&&typeof r.name=="string"&&e.push(r.name)}return e}function zN(t){return WN(t).some(e=>/^mcp__skyramp__skyramp_(contract|integration)_test_generation$/.test(e))}function KN(t){return WN(t).some(e=>e==="mcp__skyramp__skyramp_ui_test_generation")}function iK(t){if(!Oo.existsSync(t))return{};for(let e of Oo.readFileSync(t,"utf-8").split(`
120
120
  `)){let n=e.trim();if(n)try{let r=JSON.parse(n);if(r.type==="system"&&r.subtype==="init"&&Array.isArray(r.mcp_servers))return Object.fromEntries(r.mcp_servers.filter(s=>typeof s.name=="string").map(s=>[s.name,typeof s.status=="string"?s.status:"unknown"]))}catch{}}return{}}function ZN(t){let e=iK(t).skyramp;return e===void 0||e==="connected"}function oK(t){if(!Oo.existsSync(t))return[];let e=[];for(let n of Oo.readFileSync(t,"utf-8").split(`
121
121
  `)){let r=n.trim();if(!r)continue;let s;try{s=JSON.parse(r)}catch{continue}let i=s.message?.content;Array.isArray(i)&&e.push(...i)}return e}function cK(t){return wn(aC,t).errors}function uK(t,e=[]){let{value:n,error:r}=ft(t,e);if(r)return{errors:[r]};let s=cK(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}function Gp(t,e=[]){return uK(t.stdout,e)}function lK(t){return t.generate.filter(e=>e.type!=="ui").map(e=>e.id)}function tD(t){return t.generate.filter(e=>e.type==="ui").map(e=>e.id)}var jp={backend:{stage:"generate",cases:lK,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:t=>`recommend case "${t}" is not covered by any generated test`,unknownCovered:t=>`test covers unknown recommend id "${t}"`,unasserted:t=>`case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:zN,codegenHint:"These tests were hand-written. Skyramp codegen (skyramp_contract_test_generation / skyramp_integration_test_generation) was available but not used \u2014 it computes valid sample data and response correlations. Prefer scaffolding with it and then refining, especially for the failures above."},ui:{stage:"generate-ui",cases:tD,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:t=>`UI case "${t}" is not covered by any generated UI test`,unknownCovered:t=>`test covers "${t}" which is not a recommend UI case`,unasserted:t=>`UI case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:KN,codegenHint:"This UI test was hand-authored. Skyramp UI codegen (skyramp_ui_test_generation) was available but not used. Prefer scaffolding with it and then refining, especially for the failures above."}},Are=_n("generate-schema",(t,e)=>Gp(e,t.secretValues));function dK(t){let e=jp[t];return{name:`${e.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=Gp(r,n.secretValues);if(!s)return St(this.name,i);let o=Vp(n);if(!o)return St(this.name,[e.noRecommendCoverage]);let c=new Set(s.tests.flatMap(f=>f.covers)),l=[],d=e.cases(o);for(let f of d)c.has(f)||l.push(e.uncovered(f));let A=new Set(t==="ui"?d:o.generate.map(f=>f.id));for(let f of c)A.has(f)||l.push(e.unknownCovered(f));if(t==="backend"){let f=new Set(s.deferredUi),h=new Set(tD(o));for(let y of h)!f.has(y)&&!c.has(y)&&l.push(`UI case "${y}" is neither covered nor deferred to the UI stage`);for(let y of f)h.has(y)||l.push(`deferredUi lists "${y}" which is not a UI case`)}return l.length===0?{name:this.name,passed:!0}:St(this.name,l)}}}function AK(t){let e=jp[t];return{name:`${e.stage}-intent`,verify(n,r){let{generate:s,errors:i}=Gp(r,n.secretValues);if(!s)return St(this.name,i);let o=Vp(n);if(!o)return St(this.name,[e.noRecommendIntent]);let{asserted:c,errors:l,badFiles:d}=EK(s,n.inputs.repositoryPath),A=l.length;for(let h of e.cases(o))c.has(h)||l.push(e.unasserted(h));if(l.length===0)return{name:this.name,passed:!0};let f=St(this.name,l);return A>0&&A===l.length&&d.size>0?{...f,droppable:[...d]}:f}}}function pK(t){let e=jp[t];return n=>{if(!n.inputs.skyrampMcp?.command||t==="backend"&&!XE(n))return;let r=Ec.join(n.outputsDir,`${e.stage}-stream.ndjson`);if(!(!ii.existsSync(r)||e.usedCodegen(r)))return ZN(r)?e.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}var pre=dK("backend"),fre=AK("backend"),hre=pK("backend");var XN=t=>t.replace(/\s+/g,"");var AC={python:[/\bassert\s*[({\w"'`]/g,/\bpytest\.raises\s*\(/g,/\bself\.assert\w*\s*\(/g],typescript:[/\bexpect\s*\(/g,/\.should\b/g,/\bassert\s*[.(]/g],go:[/\bt\.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)\s*\(/g,/\b(assert|require)\.\w+\s*\(/g],java:[/\bassert\w*\s*\(/g,/\bassertThat\s*\(/g],ruby:[/\bexpect\s*[({]/g,/\bassert\w*\b/g,/\.should\b/g]};for(let[t,e]of[["javascript","typescript"],["kotlin","java"]])AC[t]=AC[e];function fK(t,e){if(t.includes(Wu(e))||XN(t).includes(XN(e)))return!0;let n=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!/^(\/\/|#|\*|\/\*)/.test(r));return n.length>0&&n.every(r=>t.includes(Wu(r)))?!0:yK(t,e)}var hK=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,gK=12,mK=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function yK(t,e){let n=e.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=hK.exec(s);if(!i)continue;let o=s.slice(i.index),c=mK.exec(o);if(c&&(o=o.slice(0,c.index)),o=Wu(o).replace(/[,\s]+$/,""),o.length<gK||!t.includes(o))return!1;r++}return r>0}function EK(t,e){let n=new Set,r=[],s=new Set;for(let i of t.tests){let o=Ec.resolve(e,i.file);if(!ii.existsSync(o))continue;let c=Wu(ii.readFileSync(o,"utf-8"));for(let l of i.assertions??[]){if(!fK(c,l.evidence)){r.push(`assertion evidence for "${l.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(l.case)?n.add(l.case):(r.push(`assertion cites case "${l.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}var CK=/\.(spec|test)\.[cm]?[jt]sx?$/i;function nD(t){let e;try{e=(0,eD.execFileSync)("git",[...ei,"status","--porcelain","--untracked-files=all"],{env:Ut(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=s=>/_scaffold/i.test(s)||hp.test(s),r=[];for(let s of e.split(`
122
- `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function IK(t){let e=jp[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=nD(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>CK.test(o)===n);return i.length===0?{name:this.name,passed:!0}:St(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var gre=IK("backend");var Cl=le(require("fs")),$o=le(require("path"));var xre=10*6e4;function iD(t){return wn(tC,t).errors}function RK(t,e=[]){let{value:n,error:r}=ft(t,e);if(r)return{errors:[r]};let s=iD(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var kK="adapt-scratch",sD=`${kK}/adapt-result.json`;function oD(t,e){let n=$o.join(t.outputsDir,sD),r;try{r=Cl.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(o=>r.includes(o)))return{errors:[`${sD} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=RK(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?ho(n):void 0;return i!==void 0&&iD(i).length===0?{adapt:i,errors:[]}:s}var Kre=_n("adapt-schema",oD);var aD=require("child_process");function cD(t){let e;try{e=(0,aD.execFileSync)("git",[...ei,"status","--porcelain","-z","--untracked-files=all"],{env:Ut(),cwd:t,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let n=e.split("\0"),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.length<4)continue;let o=i.slice(0,2);r.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return r}var ose=2*1024*1024;var Hp=u.string().trim().min(1),xK=u.object({cwd:Hp.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:u.array(Hp).min(1).describe("the command as separate arguments, run without a shell"),env:u.record(u.string(),u.string()).optional().describe("plain settings the listing needs beyond the CI step's own; never a credential or PATH")}),TK=u.object({file:Hp.describe("a file of the test's checkout, relative to its root"),line:Hp.describe("a line of that file, quoted exactly from where its command starts to its end")}),uD=u.object({collected:u.boolean().describe("whether the repo's CI runs this test as it is"),steps:u.array(TK).optional().describe("when collected: the line in a CI file that starts the tests, then each line it runs on the way to the test runner"),runner:u.string().optional().describe("when collected: the test runner the last of those lines starts, by the name that line and the list command both use"),list:xK.optional().describe("when collected: a command that lists the tests that runner collects without running them; Testbot runs it, and its output must name this file"),why:u.string().optional().describe("when not collected: why the repo's CI will not run it")});var _K=u.object({route:u.string().describe('the page this step happens on, e.g. "/products/:id"'),action:u.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:u.array(u.string()).optional().describe("the plan clause ids this step exercises"),check:u.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),Il=(n=>(n.InProcess="in-process",n.Browser="browser",n))(Il||{}),lD=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(lD||{}),dD=u.object({id:u.string().describe('e.g. "J1"'),name:u.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:u.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:u.array(_K).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:u.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:u.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:u.nativeEnum(Il).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:u.nativeEnum(lD).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:u.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:u.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),qp=u.object({journey:u.string().describe("the plan's journey id"),file:u.string().describe("the browser test file that walks it"),brokeAt:u.object({step:u.number().int().describe("the 1-based step whose check failed first"),expected:u.string(),actual:u.string().describe("what the app did instead, from the runner's output"),notReached:u.array(u.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:u.string().describe("the title of the one test in that file that walks it end to end")});var mse=["stale_test","open_question"],yse=["low","medium","high","critical"];var me=u.string().trim().min(1),OK=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},$K=u.preprocess(OK,u.object({id:me.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:me.describe("one testable part of the requirement"),expected:me.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(ti).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:u.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),AD=u.object({spec:u.string().optional().describe("file:line of a spec in the repository"),prDescription:u.boolean().optional().describe("or true when a pull request description says otherwise"),reference:u.string().optional().describe("or the key of an item the run was given, as listed"),says:me.describe("what it says there, in its own words, copied exactly"),criterion:u.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(t=>[!!t.prDescription,!!t.spec?.trim(),!!t.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),VK=u.object({id:me.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:me,source:u.nativeEnum(ys).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:me.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(AD).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:u.array($K)}),pD=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(pD||{}),GK=u.object({id:me.describe('e.g. "F1"'),file:me,line:u.number().optional(),claim:me.describe("the defect, in one sentence"),severity:u.nativeEnum(Uo),evidence:me.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(me).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(pD).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),jK=u.object({id:me.describe('e.g. "Q1"'),question:me.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(me).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:u.array(AD).optional().describe("when sources of the same rank disagree on it: each of them")}),HK=u.object({id:me.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(ti).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:me.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:me.describe("what the test does"),expected:me.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),qK=u.object({test:me.describe("existing test file"),action:u.nativeEnum(ni),reason:me,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(me).optional().describe("the clause ids this test checks")}),YK=u.object({outcome:u.nativeEnum(hs).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:me,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:SE.optional()}),Jse=u.object({schemaVersion:u.literal(1),requirements:u.array(VK),findings:u.array(GK),cases:u.array(HK).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(jK).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(qK),journeys:u.array(dD).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:me,why:me})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:El.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:YK.optional().describe("omit when no app was needed or none was started"),summary:me.describe("one paragraph: what the change does and where the risk is")});var fD=(n=>(n.Backend="backend",n.Ui="ui",n))(fD||{});var Yp=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Yp||{}),JK=u.object({file:me.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(fD),change:u.nativeEnum(Yp).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:me.describe("the requirement or clause id the change deliberately alters"),line:me.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:me,status:u.nativeEnum(jn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:me,evidence:me})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:me.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(me).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(oC).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:me.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:uD.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:mc.optional().describe(`for a file in ${yc}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${fr}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),WK=t=>{if(!t||typeof t!="object")return t;let{test:e,...n}=t;return typeof e=="string"&&e.trim()&&n.tests===void 0?{...n,tests:[e]}:t},zK=u.preprocess(WK,u.object({description:me.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(Uo).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),tests:u.array(me).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(me).optional().describe("the plan's requirement or clause ids it violates")})),Wse=u.object({schemaVersion:u.literal(1),tests:u.array(JK),notWritten:u.array(u.object({case:me,reason:me})).describe("every plan case no test covers, and why"),journeys:u.array(qp).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:me,manifest:me.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:me.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:me.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(me).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:u.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:u.object({message:me.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:me.describe("at most 72 characters"),prBody:me.describe("what the tests cover and what they found")}),report:u.object({summary:me.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(zK).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var zse={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var gD=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(gD||{}),kt=u.string().trim().min(1),KK=u.object({expectation:kt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(gD),expected:kt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),ZK=u.object({file:kt.describe("path of the NEW test file you wrote, relative to its repository"),repository:kt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:kt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:mc.optional().describe(`for ${yc}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(kt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(kt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(KK).min(1)}),Jp=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Jp||{}),hD=300,XK=u.object({file:kt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:kt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Jp),staleBecause:u.object({requirement:kt.describe("the requirement or clause id the change deliberately alters"),line:kt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,hD):t,kt.max(hD)).describe("what the change deliberately altered that made the test wrong")}),hC=u.object({schemaVersion:u.literal(1),tests:u.array(ZK),maintained:u.array(XK).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:kt,reason:kt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(qp).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:kt,missing:kt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:kt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var zp="generate-unit.json";function n3(t){let{value:e,error:n}=ft(t);if(n)return{errors:[n]};let{value:r,errors:s}=wn(hC,e);return s.length?{errors:s}:{output:r,errors:[]}}function r3(t){return n3(t.stdout)}var _ie=_n("generate-unit-schema",(t,e)=>r3(e));var Wp=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,Mie=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Wp}["']|\bimport\s+["']${Wp}["']|require\(\s*["']${Wp}["']\s*\)|\bimport\(\s*["']${Wp}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var oi=le(require("path"));var qie={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var gC=t=>new Map((t??[]).flatMap(e=>e.file?[[qu(e.key),e.file.name]]:[])),i3=10*1024*1024,o3=t=>t?.mediaType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"||t?.mediaType==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",CD=(t,e)=>oi.join(oi.dirname(t),`${oi.basename(t,oi.extname(t))}${e}`),a3=t=>CD(t,".extracted.txt");var c3=t=>CD(t,".quotes.txt");function ID(t){return o3(t.file)?a3(t.path):t.file?.mediaType==="application/pdf"?c3(t.path):t.path}var roe=new Set(["targeted_unit","existing_evidence_sufficient"]);var p3="triage.json";var qoe=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),Yoe={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function f3(t){let{value:e,error:n}=ft(t);if(n)return{errors:[n]};let{value:r,errors:s}=wn(El,e);return s.length?{errors:s}:{triage:r,errors:[]}}function h3(t){return f3(t.stdout)}var Joe=_n("triage-schema",(t,e)=>h3(e));function g3(t){let e=t.inputs?.pipeline;return e?t.state.stages[e==="two-step"?"plan":"triage"]:t.state.stages.triage??t.state.stages.plan}function mC(t){if(g3(t)?.status==="passed")return ho(wl.join(t.outputsDir,p3))}function yC(t){return LN(KE(t.inputs,Ke(t,`${gl}.json`),mC(t)?.sutRequired))}var Woe=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Gt();Gt();function bD(t,e){return e?`<!-- skyramp-testbot-run: ${e} -->
122
+ `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function IK(t){let e=jp[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=nD(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>CK.test(o)===n);return i.length===0?{name:this.name,passed:!0}:St(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var gre=IK("backend");var Cl=le(require("fs")),$o=le(require("path"));var xre=10*6e4;function iD(t){return wn(tC,t).errors}function RK(t,e=[]){let{value:n,error:r}=ft(t,e);if(r)return{errors:[r]};let s=iD(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var kK="adapt-scratch",sD=`${kK}/adapt-result.json`;function oD(t,e){let n=$o.join(t.outputsDir,sD),r;try{r=Cl.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(o=>r.includes(o)))return{errors:[`${sD} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=RK(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?ho(n):void 0;return i!==void 0&&iD(i).length===0?{adapt:i,errors:[]}:s}var Kre=_n("adapt-schema",oD);var aD=require("child_process");function cD(t){let e;try{e=(0,aD.execFileSync)("git",[...ei,"status","--porcelain","-z","--untracked-files=all"],{env:Ut(),cwd:t,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let n=e.split("\0"),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.length<4)continue;let o=i.slice(0,2);r.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return r}var ose=2*1024*1024;var Hp=u.string().trim().min(1),xK=u.object({cwd:Hp.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:u.array(Hp).min(1).describe("the command as separate arguments, run without a shell"),env:u.record(u.string(),u.string()).optional().describe("plain settings the listing needs beyond the CI step's own; never a credential or PATH")}),TK=u.object({file:Hp.describe("a file of the test's checkout, relative to its root"),line:Hp.describe("a line of that file, quoted exactly from where its command starts to its end")}),uD=u.object({collected:u.boolean().describe("whether the repo's CI runs this test as it is"),steps:u.array(TK).optional().describe("when collected: the line in a CI file that starts the tests, then each line it runs on the way to the test runner"),runner:u.string().optional().describe("when collected: the test runner the last of those lines starts, by the name that line and the list command both use"),list:xK.optional().describe("when collected: a command that lists the tests that runner collects without running them; Testbot runs it, and its output must name this file"),why:u.string().optional().describe("when not collected: why the repo's CI will not run it")});var _K=u.object({route:u.string().describe('the page this step happens on, e.g. "/products/:id"'),action:u.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:u.array(u.string()).optional().describe("the plan clause ids this step exercises"),check:u.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),Il=(n=>(n.InProcess="in-process",n.Browser="browser",n))(Il||{}),lD=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(lD||{}),dD=u.object({id:u.string().describe('e.g. "J1"'),name:u.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:u.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:u.array(_K).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:u.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:u.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:u.nativeEnum(Il).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:u.nativeEnum(lD).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:u.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:u.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),qp=u.object({journey:u.string().describe("the plan's journey id"),file:u.string().describe("the browser test file that walks it"),brokeAt:u.object({step:u.number().int().describe("the 1-based step whose check failed first"),expected:u.string(),actual:u.string().describe("what the app did instead, from the runner's output"),notReached:u.array(u.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:u.string().describe("the title of the one test in that file that walks it end to end")});var mse=["stale_test","open_question"],yse=["low","medium","high","critical"];var me=u.string().trim().min(1),OK=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},$K=u.preprocess(OK,u.object({id:me.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:me.describe("one testable part of the requirement"),expected:me.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(ti).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:u.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),AD=u.object({spec:u.string().optional().describe("file:line of a spec in the repository"),prDescription:u.boolean().optional().describe("or true when a pull request description says otherwise"),reference:u.string().optional().describe("or the key of an item the run was given, as listed"),says:me.describe("what it says there, in its own words, copied exactly"),criterion:u.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(t=>[!!t.prDescription,!!t.spec?.trim(),!!t.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),VK=u.object({id:me.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:me,source:u.nativeEnum(ys).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:me.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(AD).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:u.array($K)}),pD=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(pD||{}),GK=u.object({id:me.describe('e.g. "F1"'),file:me,line:u.number().optional(),claim:me.describe("the defect, in one sentence"),severity:u.nativeEnum(Uo),evidence:me.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(me).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(pD).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),jK=u.object({id:me.describe('e.g. "Q1"'),question:me.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(me).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:u.array(AD).optional().describe("when sources of the same rank disagree on it: each of them")}),HK=u.object({id:me.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(ti).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:me.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:me.describe("what the test does"),expected:me.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),qK=u.object({test:me.describe("existing test file"),action:u.nativeEnum(ni),reason:me,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(me).optional().describe("the clause ids this test checks")}),YK=u.object({outcome:u.nativeEnum(hs).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:me,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:SE.optional()}),Jse=u.object({schemaVersion:u.literal(1),requirements:u.array(VK),findings:u.array(GK),cases:u.array(HK).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(jK).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(qK),journeys:u.array(dD).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:me,why:me})).optional().describe("a clause a user sees or does that no journey walks, and why: none can reach it through the UI, or it is downstream of this change and not walked here"),triage:El.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:YK.optional().describe("omit when no app was needed or none was started"),summary:me.describe("one paragraph: what the change does and where the risk is")});var fD=(n=>(n.Backend="backend",n.Ui="ui",n))(fD||{});var Yp=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Yp||{}),JK=u.object({file:me.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(fD),change:u.nativeEnum(Yp).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:me.describe("the requirement or clause id the change deliberately alters"),line:me.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:me,status:u.nativeEnum(jn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:me,evidence:me})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:me.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(me).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(oC).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:me.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:uD.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:mc.optional().describe(`for a file in ${yc}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${fr}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),WK=t=>{if(!t||typeof t!="object")return t;let{test:e,...n}=t;return typeof e=="string"&&e.trim()&&n.tests===void 0?{...n,tests:[e]}:t},zK=u.preprocess(WK,u.object({description:me.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(Uo).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),tests:u.array(me).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(me).optional().describe("the plan's requirement or clause ids it violates")})),Wse=u.object({schemaVersion:u.literal(1),tests:u.array(JK),notWritten:u.array(u.object({case:me,reason:me})).describe("every plan case no test covers, and why"),journeys:u.array(qp).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:me,manifest:me.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:me.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:me.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(me).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:u.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:u.object({message:me.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:me.describe("at most 72 characters"),prBody:me.describe("what the tests cover and what they found")}),report:u.object({summary:me.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(zK).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var zse={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var gD=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(gD||{}),kt=u.string().trim().min(1),KK=u.object({expectation:kt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(gD),expected:kt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),ZK=u.object({file:kt.describe("path of the NEW test file you wrote, relative to its repository"),repository:kt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:kt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:mc.optional().describe(`for ${yc}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(kt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(kt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(KK).min(1)}),Jp=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Jp||{}),hD=300,XK=u.object({file:kt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:kt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Jp),staleBecause:u.object({requirement:kt.describe("the requirement or clause id the change deliberately alters"),line:kt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,hD):t,kt.max(hD)).describe("what the change deliberately altered that made the test wrong")}),hC=u.object({schemaVersion:u.literal(1),tests:u.array(ZK),maintained:u.array(XK).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:kt,reason:kt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(qp).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:kt,missing:kt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:kt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var zp="generate-unit.json";function n3(t){let{value:e,error:n}=ft(t);if(n)return{errors:[n]};let{value:r,errors:s}=wn(hC,e);return s.length?{errors:s}:{output:r,errors:[]}}function r3(t){return n3(t.stdout)}var _ie=_n("generate-unit-schema",(t,e)=>r3(e));var Wp=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,Mie=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Wp}["']|\bimport\s+["']${Wp}["']|require\(\s*["']${Wp}["']\s*\)|\bimport\(\s*["']${Wp}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var oi=le(require("path"));var qie={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var gC=t=>new Map((t??[]).flatMap(e=>e.file?[[qu(e.key),e.file.name]]:[])),i3=10*1024*1024,o3=t=>t?.mediaType==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"||t?.mediaType==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",CD=(t,e)=>oi.join(oi.dirname(t),`${oi.basename(t,oi.extname(t))}${e}`),a3=t=>CD(t,".extracted.txt");var c3=t=>CD(t,".quotes.txt");function ID(t){return o3(t.file)?a3(t.path):t.file?.mediaType==="application/pdf"?c3(t.path):t.path}var roe=new Set(["targeted_unit","existing_evidence_sufficient"]);var p3="triage.json";var qoe=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),Yoe={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function f3(t){let{value:e,error:n}=ft(t);if(n)return{errors:[n]};let{value:r,errors:s}=wn(El,e);return s.length?{errors:s}:{triage:r,errors:[]}}function h3(t){return f3(t.stdout)}var Joe=_n("triage-schema",(t,e)=>h3(e));function g3(t){let e=t.inputs?.pipeline;return e?t.state.stages[e==="two-step"?"plan":"triage"]:t.state.stages.triage??t.state.stages.plan}function mC(t){if(g3(t)?.status==="passed")return ho(wl.join(t.outputsDir,p3))}function yC(t){return LN(KE(t.inputs,Ke(t,`${gl}.json`),mC(t)?.sutRequired))}var Woe=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Gt();Gt();function bD(t,e){return e?`<!-- skyramp-testbot-run: ${e} -->
123
123
  ${t}`:t}var QD=600,Zp=300;function BD(t){return typeof t=="string"?t.trim():t instanceof Buffer?t.toString("utf-8").trim():""}function m3(t){let e=t,n=(typeof e?.message=="string"?e.message:String(t)).trim(),r=[BD(e?.stderr),BD(e?.stdout)].filter(Boolean);return r.length?[n.split(`
124
124
  `)[0],...r].join(`
125
125
  `):n}function SD(t,e,n,r=0){let s=t.join(e);if(s.length<=n)return s;let[i="",...o]=t;if(!o.length)return`${i.slice(0,n-1)}\u2026`;let c=i.length<=r?i:i.slice(0,Math.floor(n/3)),l=n-c.length-e.length-1;return`${c}${e}\u2026${o.join(e).slice(-l)}`}function vD(t,e){return SD(t.trim().split(`
@@ -90,7 +90,7 @@ ${u}`,this.dataLineCount++;return}if(Fu(t,s,B1)){R1(t,i)&&(this.setEventFieldSiz
90
90
  `)[0].length<=Ic,{message:`subject line must be <= ${Ic} chars`})}),pr:c.object({title:gr.max(Ic,`must be <= ${Ic} chars`),body:gr}),ready:c.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:c.array(c.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:gr.describe("one paragraph")});var zr=Ce(require("fs")),Ro=Ce(require("path")),Av=require("child_process");var In="{junit}",Rl=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(Rl||{}),Xf=(t=>(t.Minitest="minitest",t))(Xf||{}),rv=c.string().trim().min(1),wo=c.object({cwd:rv.describe('repo-relative directory the command starts in ("." for the root)'),argv:c.array(rv).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${In}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:c.record(c.string(),c.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:c.object({format:c.nativeEnum(Rl).describe(`junit (JUnit XML to ${In}), trx (to ${In}), or go-test-json (go test -json on the command's output)`),reporter:c.nativeEnum(Xf).optional().describe("a reporter Testbot loads for a runner that writes no report: minitest")}).optional().describe("the report the command writes; junit when omitted")});var bo="a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test), or one the repository's test script runs through another command (ng test, nx test)",O5=`pytest, Jest, Vitest and node --test tests run as the run already knows them, unless the repository's test script runs them through another command (ng test, nx test), which may be the only one that compiles them. A test in any other framework, or one run that way, also gives "run": the repository's own command for only those tests, from the directory the repository runs it in, as separate arguments without a shell. Its "report" says what the runner writes: junit (JUnit XML to ${In} in the reporter's argument or env setting), trx (a TRX file to ${In}, which every dotnet test writes with its built-in logger), or go-test-json (go test -json, read from the command's output). A Maven or Gradle command names no ${In}: its build writes JUnit XML to its own report directory, which the run reads. Use a reporter the repository already has, or one of those; a reporter or converter the command fetches is the version the repository pins, or else its latest release (an older one may not build with the repository's toolchain). For minitest, which writes none, give report.reporter "minitest" and the run fills ${In} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${In} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${In} in argv and env with its report path, executes the command, and reads that report.`;var ei=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(ei||{}),Wr=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(Wr||{}),em=(n=>(n.Repository="repository",n.Testbot="testbot",n))(em||{}),tm=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(tm||{}),vt=c.string().trim().min(1),Tq=c.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var Dq=c.object({id:Tq,source:c.nativeEnum(em),kind:c.nativeEnum(Vr),outcome:c.nativeEnum(tm),summary:vt.max(400).describe("one line: what it shows"),tests:c.array(vt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:vt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:vt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:wo.optional().describe(`source repository, for tests in ${bo}: how the run executes only these tests, all of them in one command, with the repository's own runner writing JUnit XML to {junit}. Name each test (path::test-name): a test is credited to a file only by its name or by a report that names the file`)}),Nq=c.object({behaviorId:vt.describe("an id from analyze's behaviors"),mechanism:c.nativeEnum(Wr),evidenceIds:c.array(vt).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:c.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),nm=(r=>(r.Browser="browser",r.RunningApp="running-app",r.Outside="outside",r))(nm||{}),Fq=c.object({behaviorId:c.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:vt.max(600).describe("the evidence that is required and cannot be obtained in this run"),needs:c.nativeEnum(nm).optional().describe("what that evidence needs: browser (only a real browser shows it), running-app (only the running app or its server shows it: its real requests, sign-in and permissions, what it saves), or outside (something the running app here could not give either: a third-party service it calls, hardware)")}),Mq=c.object({file:vt.describe("the changed file the failure is in"),repository:vt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:vt.max(300).describe("what prerequisite the change fails"),evidence:vt.max(400).describe("the error line, quoted")}),Uq=c.object({behaviorId:vt.describe("an id from analyze's behaviors"),reason:vt.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),Bc=c.object({schemaVersion:c.literal(1),decision:c.nativeEnum(ei),evidence:c.array(Dq).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:c.array(Nq).describe("how each changed behavior's evidence is obtained"),gaps:c.array(Fq),outOfScope:c.array(Uq).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:Mq.optional().describe("only for blocked_preflight"),rationale:vt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function Sl(e){let t=Oe(e,"recommend.json");if(!t||!Array.isArray(t.generate)||!Array.isArray(t.maintenance))return;let n=t;return{...n,maintenance:n.maintenance.map(({repository:r,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...r?.trim()?{repository:r.trim()}:{}}))}}o(Sl,"readRecommend");var ti=Ce(require("fs"));function sv(e){let t=[];for(let n of $q(e)){let r=n;r?.type==="tool_use"&&typeof r.name=="string"&&t.push(r.name)}return t}o(sv,"toolUsesFromTrace");function iv(e){return sv(e).some(t=>/^mcp__skyramp__skyramp_(contract|integration)_test_generation$/.test(t))}o(iv,"usedSkyrampCodegen");function ov(e){return sv(e).some(t=>t==="mcp__skyramp__skyramp_ui_test_generation")}o(ov,"usedSkyrampUiCodegen");function Pq(e){if(!ti.existsSync(e))return{};for(let t of ti.readFileSync(e,"utf-8").split(`
91
91
  `)){let n=t.trim();if(n)try{let r=JSON.parse(n);if(r.type==="system"&&r.subtype==="init"&&Array.isArray(r.mcp_servers))return Object.fromEntries(r.mcp_servers.filter(s=>typeof s.name=="string").map(s=>[s.name,typeof s.status=="string"?s.status:"unknown"]))}catch{}}return{}}o(Pq,"mcpServerStatuses");function av(e){let t=Pq(e).skyramp;return t===void 0||t==="connected"}o(av,"skyrampConnected");function $q(e){if(!ti.existsSync(e))return[];let t=[];for(let n of ti.readFileSync(e,"utf-8").split(`
92
92
  `)){let r=n.trim();if(!r)continue;let s;try{s=JSON.parse(r)}catch{continue}let i=s.message?.content;Array.isArray(i)&&t.push(...i)}return t}o($q,"contentBlocks");function Gq(e){return Ht(Zf,e).errors}o(Gq,"validateGenerateOutput");function Vq(e,t=[]){let{value:n,error:r}=at(e,t);if(r)return{errors:[r]};let s=Gq(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}o(Vq,"parseGenerateText");function kl(e,t=[]){return Vq(e.stdout,t)}o(kl,"parseGenerateFromSession");function Hq(e){return e.generate.filter(t=>t.type!=="ui").map(t=>t.id)}o(Hq,"backendCases");function uv(e){return e.generate.filter(t=>t.type==="ui").map(t=>t.id)}o(uv,"uiCases");var vl={backend:{stage:"generate",cases:Hq,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:o(e=>`recommend case "${e}" is not covered by any generated test`,"uncovered"),unknownCovered:o(e=>`test covers unknown recommend id "${e}"`,"unknownCovered"),unasserted:o(e=>`case "${e}" has no verified assertion enforcing its expected_observable`,"unasserted"),usedCodegen:iv,codegenHint:"These tests were hand-written. Skyramp codegen (skyramp_contract_test_generation / skyramp_integration_test_generation) was available but not used \u2014 it computes valid sample data and response correlations. Prefer scaffolding with it and then refining, especially for the failures above."},ui:{stage:"generate-ui",cases:uv,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:o(e=>`UI case "${e}" is not covered by any generated UI test`,"uncovered"),unknownCovered:o(e=>`test covers "${e}" which is not a recommend UI case`,"unknownCovered"),unasserted:o(e=>`UI case "${e}" has no verified assertion enforcing its expected_observable`,"unasserted"),usedCodegen:ov,codegenHint:"This UI test was hand-authored. Skyramp UI codegen (skyramp_ui_test_generation) was available but not used. Prefer scaffolding with it and then refining, especially for the failures above."}},bX=sn("generate-schema",(e,t)=>kl(t,e.secretValues));function qq(e){let t=vl[e];return{name:`${t.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=kl(r,n.secretValues);if(!s)return dt(this.name,i);let a=Sl(n);if(!a)return dt(this.name,[t.noRecommendCoverage]);let A=new Set(s.tests.flatMap(g=>g.covers)),u=[],d=t.cases(a);for(let g of d)A.has(g)||u.push(t.uncovered(g));let p=new Set(e==="ui"?d:a.generate.map(g=>g.id));for(let g of A)p.has(g)||u.push(t.unknownCovered(g));if(e==="backend"){let g=new Set(s.deferredUi),f=new Set(uv(a));for(let m of f)!g.has(m)&&!A.has(m)&&u.push(`UI case "${m}" is neither covered nor deferred to the UI stage`);for(let m of g)f.has(m)||u.push(`deferredUi lists "${m}" which is not a UI case`)}return u.length===0?{name:this.name,passed:!0}:dt(this.name,u)}}}o(qq,"generateCoverageGateFor");function Jq(e){let t=vl[e];return{name:`${t.stage}-intent`,verify(n,r){let{generate:s,errors:i}=kl(r,n.secretValues);if(!s)return dt(this.name,i);let a=Sl(n);if(!a)return dt(this.name,[t.noRecommendIntent]);let{asserted:A,errors:u,badFiles:d}=Xq(s,n.inputs.repositoryPath),p=u.length;for(let f of t.cases(a))A.has(f)||u.push(t.unasserted(f));if(u.length===0)return{name:this.name,passed:!0};let g=dt(this.name,u);return p>0&&p===u.length&&d.size>0?{...g,droppable:[...d]}:g}}}o(Jq,"generateIntentGateFor");function Yq(e){let t=vl[e];return n=>{if(!n.inputs.skyrampMcp?.command||e==="backend"&&!Hf(n))return;let r=Ro.join(n.outputsDir,`${t.stage}-stream.ndjson`);if(!(!zr.existsSync(r)||t.usedCodegen(r)))return av(r)?t.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}o(Yq,"codegenRetryHintFor");var RX=qq("backend"),SX=Jq("backend"),kX=Yq("backend");var cv=o(e=>e.replace(/\s+/g,""),"squeeze");var rm={python:[/\bassert\s*[({\w"'`]/g,/\bpytest\.raises\s*\(/g,/\bself\.assert\w*\s*\(/g],typescript:[/\bexpect\s*\(/g,/\.should\b/g,/\bassert\s*[.(]/g],go:[/\bt\.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)\s*\(/g,/\b(assert|require)\.\w+\s*\(/g],java:[/\bassert\w*\s*\(/g,/\bassertThat\s*\(/g],ruby:[/\bexpect\s*[({]/g,/\bassert\w*\b/g,/\.should\b/g]};for(let[e,t]of[["javascript","typescript"],["kotlin","java"]])rm[e]=rm[t];function jq(e,t){if(e.includes(uc(t))||cv(e).includes(cv(t)))return!0;let n=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!/^(\/\/|#|\*|\/\*)/.test(r));return n.length>0&&n.every(r=>e.includes(uc(r)))?!0:Zq(e,t)}o(jq,"evidenceFound");var Wq=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,zq=12,Kq=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function Zq(e,t){let n=t.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=Wq.exec(s);if(!i)continue;let a=s.slice(i.index),A=Kq.exec(a);if(A&&(a=a.slice(0,A.index)),a=uc(a).replace(/[,\s]+$/,""),a.length<zq||!e.includes(a))return!1;r++}return r>0}o(Zq,"annotatedAssertionFound");function Xq(e,t){let n=new Set,r=[],s=new Set;for(let i of e.tests){let a=Ro.resolve(t,i.file);if(!zr.existsSync(a))continue;let A=uc(zr.readFileSync(a,"utf-8"));for(let u of i.assertions??[]){if(!jq(A,u.evidence)){r.push(`assertion evidence for "${u.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(u.case)?n.add(u.case):(r.push(`assertion cites case "${u.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}o(Xq,"verifiedAssertions");var eJ=/\.(spec|test)\.[cm]?[jt]sx?$/i;function lv(e){let t;try{t=(0,Av.execFileSync)("git",[...Yr,"status","--porcelain","--untracked-files=all"],{env:Vt(),cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=o(s=>/_scaffold/i.test(s)||El.test(s),"isTestLitter"),r=[];for(let s of t.split(`
93
- `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),a=i.indexOf(" -> ");if(a!==-1&&(i=i.slice(a+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let A=i.replace(/^\.\//,"");A.startsWith(".skyramp/")||!n(A)||r.push(A)}return r}o(lv,"testLitter");function tJ(e){let t=vl[e],n=e==="ui";return{name:`${t.stage}-no-litter`,verify(r){let s=lv(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>eJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:dt(this.name,[`${t.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}o(tJ,"noLitterGateFor");var vX=tJ("backend");var Qc=Ce(require("fs")),ni=Ce(require("path"));var HX=10*6e4;function gv(e){return Ht(Jf,e).errors}o(gv,"validateAdaptOutput");function cJ(e,t=[]){let{value:n,error:r}=at(e,t);if(r)return{errors:[r]};let s=gv(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(cJ,"parseAdaptText");var AJ="adapt-scratch",pv=`${AJ}/adapt-result.json`;function hv(e,t){let n=ni.join(e.outputsDir,pv),r;try{r=Qc.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(e.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${pv} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=cJ(t.stdout,e.secretValues);if(s.adapt)return s;let i=r!==void 0?js(n):void 0;return i!==void 0&&gv(i).length===0?{adapt:i,errors:[]}:s}o(hv,"parseAdaptFromSession");var d6=sn("adapt-schema",hv);var fv=require("child_process");function mv(e){let t;try{t=(0,fv.execFileSync)("git",[...Yr,"status","--porcelain","-z","--untracked-files=all"],{env:Vt(),cwd:e,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let n=t.split("\0"),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.length<4)continue;let a=i.slice(0,2);r.push({code:a,path:i.slice(3)}),(a[0]==="R"||a[0]==="C")&&s++}return r}o(mv,"statusEntries");var B6=2*1024*1024;var xl=c.string().trim().min(1),uJ=c.object({cwd:xl.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:c.array(xl).min(1).describe("the command as separate arguments, run without a shell"),env:c.record(c.string(),c.string()).optional().describe("plain settings the listing needs beyond the CI step's own; never a credential or PATH")}),lJ=c.object({file:xl.describe("a file of the test's checkout, relative to its root"),line:xl.describe("a line of that file, quoted exactly from where its command starts to its end")}),Ev=c.object({collected:c.boolean().describe("whether the repo's CI runs this test as it is"),steps:c.array(lJ).optional().describe("when collected: the line in a CI file that starts the tests, then each line it runs on the way to the test runner"),runner:c.string().optional().describe("when collected: the test runner the last of those lines starts, by the name that line and the list command both use"),list:uJ.optional().describe("when collected: a command that lists the tests that runner collects without running them; Testbot runs it, and its output must name this file"),why:c.string().optional().describe("when not collected: why the repo's CI will not run it")});var hJ=c.object({route:c.string().describe('the page this step happens on, e.g. "/products/:id"'),action:c.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:c.array(c.string()).optional().describe("the plan clause ids this step exercises"),check:c.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),wc=(n=>(n.InProcess="in-process",n.Browser="browser",n))(wc||{}),yv=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(yv||{}),Cv=c.object({id:c.string().describe('e.g. "J1"'),name:c.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:c.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:c.array(hJ).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:c.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:c.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:c.nativeEnum(wc).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:c.nativeEnum(yv).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:c.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:c.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),Tl=c.object({journey:c.string().describe("the plan's journey id"),file:c.string().describe("the browser test file that walks it"),brokeAt:c.object({step:c.number().int().describe("the 1-based step whose check failed first"),expected:c.string(),actual:c.string().describe("what the app did instead, from the runner's output"),notReached:c.array(c.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:c.string().describe("the title of the one test in that file that walks it end to end")});var F6=["stale_test","open_question"],M6=["low","medium","high","critical"];var ae=c.string().trim().min(1),CJ=o(e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},"skippedNeedsNoExpected"),IJ=c.preprocess(CJ,c.object({id:ae.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:ae.describe("one testable part of the requirement"),expected:ae.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:c.string().optional().describe("only when no test can check this clause here: why"),type:c.nativeEnum(qr).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:c.string().optional().describe('its "METHOD /path", or the page / flow'),steps:c.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:c.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:c.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:c.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:c.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:c.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:c.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),Iv=c.object({spec:c.string().optional().describe("file:line of a spec in the repository"),prDescription:c.boolean().optional().describe("or true when a pull request description says otherwise"),reference:c.string().optional().describe("or the key of an item the run was given, as listed"),says:ae.describe("what it says there, in its own words, copied exactly"),criterion:c.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(e=>[!!e.prDescription,!!e.spec?.trim(),!!e.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),BJ=c.object({id:ae.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:ae,source:c.nativeEnum(dr).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:c.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:ae.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:c.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:c.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:c.array(Iv).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:c.array(IJ)}),Bv=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(Bv||{}),QJ=c.object({id:ae.describe('e.g. "F1"'),file:ae,line:c.number().optional(),claim:ae.describe("the defect, in one sentence"),severity:c.nativeEnum(Zs),evidence:ae.describe("the code line, or the probe request and response, that shows it"),conflictsWith:c.array(ae).optional().describe("requirement or clause ids it violates"),keeps:c.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:c.nativeEnum(Bv).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:c.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:c.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),wJ=c.object({id:ae.describe('e.g. "Q1"'),question:ae.describe("what is unsettled, as a question the PR author can answer"),readings:c.array(ae).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:c.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:c.array(Iv).optional().describe("when sources of the same rank disagree on it: each of them")}),bJ=c.object({id:ae.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:c.nativeEnum(qr).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:ae.describe('"METHOD /path", or the page / flow'),clause:c.string().optional().describe("the clause id this case checks"),finding:c.string().optional().describe("the finding id this case catches"),steps:ae.describe("what the test does"),expected:ae.describe("the expected outcome, from the clause"),mutates:c.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),RJ=c.object({test:ae.describe("existing test file"),action:c.nativeEnum(Jr),reason:ae,mutates:c.boolean().optional().describe("true when the maintained test changes state"),clauses:c.array(ae).optional().describe("the clause ids this test checks")}),SJ=c.object({outcome:c.nativeEnum(ar).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:c.record(c.string()).optional().describe("service \u2192 base URL of the running app"),health:c.object({url:c.string().optional(),command:c.string().optional(),output:c.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:c.string().optional().describe("command that stops the app"),dependencies:c.record(c.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:c.array(c.string()).optional().describe("what you changed in the recipe"),error:c.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:c.array(c.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:c.object({username:ae,password:c.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:Oh.optional()}),d7=c.object({schemaVersion:c.literal(1),requirements:c.array(BJ),findings:c.array(QJ),cases:c.array(bJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:c.array(wJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:c.array(RJ),journeys:c.array(Cv).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:c.array(c.object({clause:ae,why:ae})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Bc.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:SJ.optional().describe("omit when no app was needed or none was started"),summary:ae.describe("one paragraph: what the change does and where the risk is")});var Qv=(n=>(n.Backend="backend",n.Ui="ui",n))(Qv||{});var Dl=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Dl||{}),kJ=c.object({file:ae.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:c.nativeEnum(Qv),change:c.nativeEnum(Dl).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:c.array(c.string()).describe("the plan case ids this file tests"),defect:c.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:c.object({requirement:ae.describe("the requirement or clause id the change deliberately alters"),line:ae.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:c.object({exit:c.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:c.array(c.object({case:ae,status:c.nativeEnum(an),defect:c.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:c.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:c.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:c.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:c.string().optional().describe("what failed and why, or why it was not run")}),assertions:c.array(c.object({case:ae,evidence:ae})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:c.array(c.object({name:ae.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:c.array(ae).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:c.object({draft:c.union([c.string(),c.array(c.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:c.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:c.array(Kf).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:ae.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:Ev.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:wo.optional().describe(`for a file in ${bo}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${In}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),vJ=o(e=>{if(!e||typeof e!="object")return e;let{test:t,...n}=e;return typeof t=="string"&&t.trim()&&n.tests===void 0?{...n,tests:[t]}:e},"oneTestIsTests"),xJ=c.preprocess(vJ,c.object({description:ae.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:c.nativeEnum(Zs).optional(),sourceFile:c.string().optional().describe("the app file at fault"),sourceLine:c.number().optional(),tests:c.array(ae).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:c.string().optional().describe("the plan's finding id, when it is one"),requirements:c.array(ae).optional().describe("the plan's requirement or clause ids it violates")})),p7=c.object({schemaVersion:c.literal(1),tests:c.array(kJ),notWritten:c.array(c.object({case:ae,reason:ae})).describe("every plan case no test covers, and why"),journeys:c.array(Tl).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:c.object({command:c.string(),clean:c.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:c.array(c.object({package:ae,manifest:ae.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:ae.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:ae.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:c.array(ae).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:c.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:c.object({message:ae.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:ae.describe("at most 72 characters"),prBody:ae.describe("what the tests cover and what they found")}),report:c.object({summary:ae.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:c.array(xJ).describe("every defect the tests found"),nextSteps:c.array(c.string())})});var g7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var bv=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(bv||{}),ct=c.string().trim().min(1),TJ=c.object({expectation:ct.max(300).describe("the behavior this assertion pins, in words"),source:c.nativeEnum(bv),expected:ct.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),DJ=c.object({file:ct.describe("path of the NEW test file you wrote, relative to its repository"),repository:ct.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:ct.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:wo.optional().describe(`for ${bo}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:c.array(ct).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:c.array(ct).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:c.array(TJ).min(1)}),Nl=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Nl||{}),wv=300,NJ=c.object({file:ct.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:ct.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:c.nativeEnum(Nl),staleBecause:c.object({requirement:ct.describe("the requirement or clause id the change deliberately alters"),line:ct.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:c.preprocess(e=>typeof e=="string"?e.trim().slice(0,wv):e,ct.max(wv)).describe("what the change deliberately altered that made the test wrong")}),om=c.object({schemaVersion:c.literal(1),tests:c.array(DJ),maintained:c.array(NJ).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:c.array(c.object({id:ct,reason:ct.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:c.array(Tl).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:c.array(c.object({journey:ct,missing:ct.transform(e=>e.length>300?`${e.slice(0,299)}\u2026`:e)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:c.object({command:c.string(),clean:c.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:ct.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var Ml="generate-unit.json";function UJ(e){let{value:t,error:n}=at(e);if(n)return{errors:[n]};let{value:r,errors:s}=Ht(om,t);return s.length?{errors:s}:{output:r,errors:[]}}o(UJ,"parseGenerateUnitText");function LJ(e){return UJ(e.stdout)}o(LJ,"parseGenerateUnitFromSession");var nee=sn("generate-unit-schema",(e,t)=>LJ(t));var Fl=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,ree=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Fl}["']|\bimport\s+["']${Fl}["']|require\(\s*["']${Fl}["']\s*\)|\bimport\(\s*["']${Fl}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var wee=new Set(["targeted_unit","existing_evidence_sufficient"]);var HJ="triage.json";var gte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),hte={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function qJ(e){let{value:t,error:n}=at(e);if(n)return{errors:[n]};let{value:r,errors:s}=Ht(Bc,t);return s.length?{errors:s}:{triage:r,errors:[]}}o(qJ,"parseTriageText");function JJ(e){return qJ(e.stdout)}o(JJ,"parseTriageFromSession");var fte=sn("triage-schema",(e,t)=>JJ(t));function YJ(e){let t=e.inputs?.pipeline;return t?e.state.stages[t==="two-step"?"plan":"triage"]:e.state.stages.triage??e.state.stages.plan}o(YJ,"triageDecider");function am(e){if(YJ(e)?.status==="passed")return js(bc.join(e.outputsDir,HJ))}o(am,"readTriage");function cm(e){return YS(Af(e.inputs,Oe(e,`${hc}.json`),am(e)?.sutRequired))}o(cm,"revisionBlockReason");var mte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var es=Ce(require("fs")),Xr=Ce(require("path")),ix=require("child_process");var Am=require("child_process"),So=Ce(require("fs")),kv=Ce(require("os")),_l=Ce(require("path"));var jJ={onPath:o(e=>(0,Am.spawnSync)("sh",["-c",`command -v ${e}`],{stdio:"ignore"}).status===0,"onPath"),run:o((e,t)=>(0,Am.spawnSync)(e[0],e.slice(1),{cwd:t,stdio:"ignore",timeout:6e4}).status??1,"run")},Ll={cleanup:o(()=>{},"cleanup")},WJ=new Set(["pnpm","yarn"]);function vv(e,t=kv.tmpdir(),n=jJ){if(process.platform==="win32")return Ll;try{let r=Lf(e);if(!WJ.has(r)||n.onPath(r)||!n.onPath("corepack"))return Ll;So.mkdirSync(t,{recursive:!0});let s=So.mkdtempSync(_l.join(t,"testbot-pm-")),i=o(()=>So.rmSync(s,{recursive:!0,force:!0}),"cleanup");return n.run(["corepack","enable","--install-directory",s,r],e)!==0?(i(),Ll):{dir:s,cleanup:i}}catch{return Ll}}o(vv,"packageManagerShims");function xv(e,t=process.env){return e.dir?{...t,PATH:[e.dir,t.PATH].filter(Boolean).join(_l.delimiter)}:t}o(xv,"withShims");var Ol=require("crypto");var Tte=[...sf,"AWS_REGION","AWS_DEFAULT_REGION","AWS_ENDPOINT_URL","AWS_ENDPOINT_URL_BEDROCK_RUNTIME","AWS_ENDPOINT_URL_STS","AWS_SHARED_CREDENTIALS_FILE","AWS_CONFIG_FILE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BASE_URL","ANTHROPIC_BEDROCK_BASE_URL"].filter((e,t,n)=>n.indexOf(e)===t);var Ote=process.env.RUNNER_TOOL_CACHE||"/opt/hostedtoolcache";var Xte={jest:"jest",vitest:"vitest"};var qne=5*6e4;function KJ(e){return Ht(zf,e).errors}o(KJ,"validateAnalysisOutput");function Nv(e,t=[]){let{value:n,error:r}=at(e,t);if(r)return{errors:[r]};let s=KJ(n);return s.length>0?{errors:s}:{analysis:n,errors:[]}}o(Nv,"parseAnalysisText");function ZJ(e,t=[]){return Nv(e.stdout,t)}o(ZJ,"parseAnalysisFromSession");var pre=sn("analysis-schema",(e,t)=>ZJ(t,e.secretValues));var ise=Vu.rows.notRun(!0);var Rc="kept, not ",Sc="(declined the planned ";function um(e){if(!e)return[];let t=[],n=0,r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="("?n++:i===")"?n=Math.max(0,n-1):n===0&&i===";"&&e[s+1]===" "&&e[s-1]===")"&&(t.push(e.slice(r,s)),r=s+2)}return t.push(e.slice(r)),t.map(s=>{let i=s.trim();if(!i.endsWith(")"))return{expectation:i};let a=0;for(let A=i.length-1;A>=0;A--)if(i[A]===")")a++;else if(i[A]==="("&&--a===0){let u=i.slice(0,A).trim(),d=i.slice(A+1,-1).trim();return u&&d?{expectation:u,expected:d}:{expectation:i}}return{expectation:i}})}o(um,"assertionParts");var Fv=new Set(["update","regenerate","delete"]);var ose={update:"updated",regenerate:"regenerated",delete:"deleted",verify:"verified",none:"touched"};var Mv=c.string().trim().min(1),lm=c.object({schemaVersion:c.literal(1).optional(),businessCaseAnalysis:Mv.describe("1-2 sentences: what this change means for a user, and whether the evidence shows it working"),issuesFound:c.array(c.object({description:Mv,severity:c.string().optional().describe("critical | high | medium | low"),category:c.string().optional().describe("bug | lint | type | config"),sourceFile:c.string().optional(),sourceLine:c.number().optional(),findingId:c.string().optional(),requirementIds:c.array(c.string()).optional()})).describe("every real problem this run exposed \u2014 cause, file:line, severity"),nextSteps:c.array(c.string()).describe("concrete follow-ups the author can act on; required non-empty when a disclosure is BLOCKING")});function tY(e){return Ht(lm,e).errors}o(tY,"validateProseOutput");function nY(e,t=[]){let{value:n,error:r}=at(e.stdout,t);if(r)return{errors:[r]};let s=tY(n);return s.length>0?{errors:s}:{prose:n,errors:[]}}o(nY,"parseProseFromSession");var Cse=sn("report-schema",(e,t)=>nY(t,e.secretValues));var rY="<!-- skyramp-testbot -->",Uv=Fv,sY=new Set(["lint","type","config"]),Lv={critical:0,high:1,medium:2,low:3},Vv=new Set(["Pass","Fail"]);var pm=o(e=>vs(ee().statusLabels,e),"statusLabel"),dm=o(e=>vs(ee().testTypeCellLabels,e),"testTypeLabel");function we(e){return(e??"").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>").trim()}o(we,"escCell");function _v(e,t){return!e||!Vv.has(e)?"\u2014":t?`${pm(e)} (${we(Hv(t))})`:pm(e)}o(_v,"maintStatus");function Hv(e){let t=o(r=>{let s=r.indexOf(": ");return s<0?r:vs(ee().staged.maintenanceActions,r.slice(0,s))+r.slice(s)},"action");if(e.startsWith(Rc))return ee().staged.keptNot+t(e.slice(Rc.length));let n=e.indexOf(Sc);return n<0?e:e.slice(0,n)+ee().staged.declinedPlanned+t(e.slice(n+Sc.length))}o(Hv,"declineNote");function Pv(e){return e.category!==void 0&&sY.has(e.category.toLowerCase())}o(Pv,"isTooling");function $v(e,t){return(Lv[(e.severity??"").toLowerCase()]??4)-(Lv[(t.severity??"").toLowerCase()]??4)}o($v,"bySeverity");function Ov(e){return`- ${e.severity?`**[${vs(ee().severityLabels,e.severity.toLowerCase()).toUpperCase()}]** `:""}${e.description.trim()}`}o(Ov,"issueLine");function iY(e){let t=e.resultId?.split("#").slice(1).join("#");if(e.testType!=="unit"||!t)return;let n=t;try{n=decodeURIComponent(t)}catch{}let r=/^(.*?)(\[.*\])$/.exec(n);return r?{fn:r[1],kase:r[2]}:{fn:n}}o(iY,"unitTestOf");var qv=o((e,t)=>e!==void 0&&t!==void 0&&e.replace(/^\.\//,"")===t.replace(/^\.\//,""),"samePath");function Jv(e,t){return(e.testVideos??[]).find(n=>n.url&&t(n))?.url}o(Jv,"videoLink");function gm(e,t){return Jv(e,n=>qv(n.fileName,t.fileName)&&(!n.repository||!t.repository||n.repository.toLowerCase()===t.repository.toLowerCase()))}o(gm,"resultVideoLink");function hm(e,t){return Jv(e,n=>qv(n.writtenAs??n.fileName,t))}o(hm,"journeyVideoLink");function oY(e,t,n){return n?gm(e,{fileName:t,repository:n}):hm(e,t)}o(oY,"requirementVideoLink");function aY(e){let t=[],n=new Map;for(let a of e.newTestsCreated)a.testType==="unit"&&n.set(a.fileName,[...n.get(a.fileName)??[],a.testId.split("::").slice(1).join("::")]);let r=new Map,s=o((a,A)=>(n.get(a??"")??[]).find(u=>u!==A&&zk(A,u)),"parentOf"),i=new Map;for(let a of e.testResults){let A=iY(a),u=A&&!A.kase?s(a.fileName,A.fn):void 0;if(A&&u&&(A={fn:u,kase:`"${A.fn}"`}),A?.kase&&r.set(a,A.kase),!A){t.push({testId:a.testId,testType:a.testType,endpoint:a.endpoint,status:a.status,details:a.details??"",...a.fileName?{fileName:a.fileName}:{},...a.repository?{repository:a.repository}:{}});continue}let d=`${a.fileName??""}#${A.fn}`,p=i.get(d);p||(p={row:{testId:a.testId,testType:a.testType,endpoint:a.endpoint,status:a.status,details:"",test:A.fn,...a.fileName?{fileName:a.fileName}:{},...a.repository?{repository:a.repository}:{}},cases:[]},i.set(d,p),t.push(p.row)),p.cases.push(a)}for(let{row:a,cases:A}of i.values()){let u=A.filter(f=>f.status==="Fail"),d=A.filter(f=>f.status==="Pass").length,p=A.filter(f=>f.status==="Skipped").length;a.cases=A.length,a.status=u.length?"Fail":p?"Skipped":"Pass";let g=u[0];a.details=A.length===1?A[0].details??"":ee().staged.casesPassed(d,A.length,p)+(g?`; ${r.get(g)??""} ${g.details??""}`.replace(/; +/,"; ").trimEnd():"")}return t}o(aY,"resultRows");function cY(e){return um(e).map(t=>t.expected===void 0?t.expectation:`${t.expectation}: ${Kr(t.expected)}`)}o(cY,"unitAssertions");function Kr(e){let t=Math.max(0,...(e.match(/`+/g)??[]).map(s=>s.length)),n="`".repeat(t+1),r=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${r}${e}${r}${n}`}o(Kr,"codeSpan");function Gv(e){return e.newTestsCreated.some(t=>t.testType!=="unit")&&e.testResults.every(t=>t.status==="Skipped")}o(Gv,"nothingExecuted");function Yv(e,t={}){let{audience:n,collapsed:r=!1,existingEvidence:s=[],requestedBy:i,sourcePullRequest:a}=t,A=n!=="testbot-pr",u=n!=="comment",d=n!=="testbot-pr",p=[rY];if(a&&p.push(ee().staged.testsSourcePullRequest(Kr(a)),""),i){let Q=i.name.replace(/\s+/g," ").trim().replace(/[<>[\]()*_`\\|#]/g,"\\$&").replace(/@/g,"@\u200D");p.push(i.kind==="person"?ee().staged.requestedByPerson(Q):ee().staged.requestedByPolicy(Q),"")}e.notTranslated&&p.push(vs(ee().staged.notTranslated,e.notTranslated),"");let g=o(Q=>{r?p.push("<details>",`<summary>${Q}</summary>`,""):p.push(`### ${Q}`)},"sectionStart"),f=o(()=>{r&&p.push("","</details>"),p.push("")},"sectionEnd");if(A){for(let Q of e.businessCaseAnalysis.trim().split(/\r?\n/))p.push(`> ${Q}`);p.push("")}if(Gv(e)&&p.push(ee().staged.noLiveApp(e.newTestsCreated.length),""),u&&e.newTestsCreated.length){let Q=new Map;for(let H of e.newTestsCreated){if(H.testType!=="unit")continue;let W=(H.testId.split("::").slice(1).join("::")||H.testId).replace(/\[.*\]$/,""),P=Q.get(H.fileName)??{functions:new Set,endpoints:[],descriptions:new Map};H.endpoint&&!P.endpoints.includes(H.endpoint)&&P.endpoints.push(H.endpoint);let ge=H.description?.trim()??"",Me=P.descriptions.get(W)??[];Me.includes(ge)||Me.push(ge),P.functions.add(W),P.descriptions.set(W,Me),Q.set(H.fileName,P)}let S=e.newTestsCreated.filter(H=>H.testType!=="unit"),F=S.length+[...Q.values()].reduce((H,W)=>H+W.functions.size,0);g(ee().testRecommendationsImplementedHeader(F));for(let[H,{functions:W,endpoints:P,descriptions:ge}]of Q){let Me=W.size;p.push(ee().staged.unitTestsInFile(`\`${H}\``,Me,P.map(Se=>`\`${Se}\``).join(", ")),"");let be=new Map;for(let[Se,Ie]of ge){let _e=Ie.join("\0"),$=be.get(_e)??{fns:[],descriptions:Ie};$.fns.push(Se),be.set(_e,$)}let De=0;for(let{fns:Se,descriptions:Ie}of be.values()){p.push(`${++De}. ${Se.map($=>`\`${$}\``).join(", ")}`);let _e=[...new Set(Ie.flatMap($=>cY($)))];for(let $ of _e)p.push(` - ${$}`)}p.push("")}for(let H of S){let W=H.testId?`\`${H.testId}\``:dm(H.testType),P=H.fileName?` (\`${H.fileName}\`)`:"",ge=H.endpoint?`
93
+ `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),a=i.indexOf(" -> ");if(a!==-1&&(i=i.slice(a+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let A=i.replace(/^\.\//,"");A.startsWith(".skyramp/")||!n(A)||r.push(A)}return r}o(lv,"testLitter");function tJ(e){let t=vl[e],n=e==="ui";return{name:`${t.stage}-no-litter`,verify(r){let s=lv(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>eJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:dt(this.name,[`${t.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}o(tJ,"noLitterGateFor");var vX=tJ("backend");var Qc=Ce(require("fs")),ni=Ce(require("path"));var HX=10*6e4;function gv(e){return Ht(Jf,e).errors}o(gv,"validateAdaptOutput");function cJ(e,t=[]){let{value:n,error:r}=at(e,t);if(r)return{errors:[r]};let s=gv(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(cJ,"parseAdaptText");var AJ="adapt-scratch",pv=`${AJ}/adapt-result.json`;function hv(e,t){let n=ni.join(e.outputsDir,pv),r;try{r=Qc.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(e.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${pv} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=cJ(t.stdout,e.secretValues);if(s.adapt)return s;let i=r!==void 0?js(n):void 0;return i!==void 0&&gv(i).length===0?{adapt:i,errors:[]}:s}o(hv,"parseAdaptFromSession");var d6=sn("adapt-schema",hv);var fv=require("child_process");function mv(e){let t;try{t=(0,fv.execFileSync)("git",[...Yr,"status","--porcelain","-z","--untracked-files=all"],{env:Vt(),cwd:e,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let n=t.split("\0"),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.length<4)continue;let a=i.slice(0,2);r.push({code:a,path:i.slice(3)}),(a[0]==="R"||a[0]==="C")&&s++}return r}o(mv,"statusEntries");var B6=2*1024*1024;var xl=c.string().trim().min(1),uJ=c.object({cwd:xl.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:c.array(xl).min(1).describe("the command as separate arguments, run without a shell"),env:c.record(c.string(),c.string()).optional().describe("plain settings the listing needs beyond the CI step's own; never a credential or PATH")}),lJ=c.object({file:xl.describe("a file of the test's checkout, relative to its root"),line:xl.describe("a line of that file, quoted exactly from where its command starts to its end")}),Ev=c.object({collected:c.boolean().describe("whether the repo's CI runs this test as it is"),steps:c.array(lJ).optional().describe("when collected: the line in a CI file that starts the tests, then each line it runs on the way to the test runner"),runner:c.string().optional().describe("when collected: the test runner the last of those lines starts, by the name that line and the list command both use"),list:uJ.optional().describe("when collected: a command that lists the tests that runner collects without running them; Testbot runs it, and its output must name this file"),why:c.string().optional().describe("when not collected: why the repo's CI will not run it")});var hJ=c.object({route:c.string().describe('the page this step happens on, e.g. "/products/:id"'),action:c.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:c.array(c.string()).optional().describe("the plan clause ids this step exercises"),check:c.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),wc=(n=>(n.InProcess="in-process",n.Browser="browser",n))(wc||{}),yv=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(yv||{}),Cv=c.object({id:c.string().describe('e.g. "J1"'),name:c.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:c.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:c.array(hJ).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:c.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:c.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:c.nativeEnum(wc).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:c.nativeEnum(yv).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:c.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:c.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),Tl=c.object({journey:c.string().describe("the plan's journey id"),file:c.string().describe("the browser test file that walks it"),brokeAt:c.object({step:c.number().int().describe("the 1-based step whose check failed first"),expected:c.string(),actual:c.string().describe("what the app did instead, from the runner's output"),notReached:c.array(c.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:c.string().describe("the title of the one test in that file that walks it end to end")});var F6=["stale_test","open_question"],M6=["low","medium","high","critical"];var ae=c.string().trim().min(1),CJ=o(e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},"skippedNeedsNoExpected"),IJ=c.preprocess(CJ,c.object({id:ae.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:ae.describe("one testable part of the requirement"),expected:ae.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:c.string().optional().describe("only when no test can check this clause here: why"),type:c.nativeEnum(qr).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:c.string().optional().describe('its "METHOD /path", or the page / flow'),steps:c.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:c.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:c.string().optional().describe("path:line of the code that decides this clause, when there is one"),stated:c.string().optional().describe("the description's or spec's own words that state this clause, copied exactly, when they do"),mutates:c.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:c.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:c.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),Iv=c.object({spec:c.string().optional().describe("file:line of a spec in the repository"),prDescription:c.boolean().optional().describe("or true when a pull request description says otherwise"),reference:c.string().optional().describe("or the key of an item the run was given, as listed"),says:ae.describe("what it says there, in its own words, copied exactly"),criterion:c.number().int().positive().optional().describe("an item's only: leave it out; Testbot numbers it")}).refine(e=>[!!e.prDescription,!!e.spec?.trim(),!!e.reference?.trim()].filter(Boolean).length===1,{message:`names no source, or more than one: give "spec" its file:line or "reference" an item's key, or set "prDescription", one of them; list each source as its own entry`}),BJ=c.object({id:ae.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:ae,source:c.nativeEnum(dr).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:c.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:ae.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:c.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:c.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:c.array(Iv).optional().describe("requirement-reference only: each lower-ranked source that says otherwise, a spec in the repository, a PR description or another item; this requirement wins, so test what it says"),clauses:c.array(IJ)}),Bv=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(Bv||{}),QJ=c.object({id:ae.describe('e.g. "F1"'),file:ae,line:c.number().optional(),claim:ae.describe("the defect, in one sentence"),severity:c.nativeEnum(Zs),evidence:ae.describe("the code line, or the probe request and response, that shows it"),conflictsWith:c.array(ae).optional().describe("requirement or clause ids it violates"),keeps:c.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:c.nativeEnum(Bv).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:c.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:c.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),wJ=c.object({id:ae.describe('e.g. "Q1"'),question:ae.describe("what is unsettled, as a question the PR author can answer"),readings:c.array(ae).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:c.string().optional().describe("the requirement or clause id it is about, when there is one"),sources:c.array(Iv).optional().describe("when sources of the same rank disagree on it: each of them")}),bJ=c.object({id:ae.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:c.nativeEnum(qr).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:ae.describe('"METHOD /path", or the page / flow'),clause:c.string().optional().describe("the clause id this case checks"),finding:c.string().optional().describe("the finding id this case catches"),steps:ae.describe("what the test does"),expected:ae.describe("the expected outcome, from the clause"),mutates:c.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),RJ=c.object({test:ae.describe("existing test file"),action:c.nativeEnum(Jr),reason:ae,mutates:c.boolean().optional().describe("true when the maintained test changes state"),clauses:c.array(ae).optional().describe("the clause ids this test checks")}),SJ=c.object({outcome:c.nativeEnum(ar).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:c.record(c.string()).optional().describe("service \u2192 base URL of the running app"),health:c.object({url:c.string().optional(),command:c.string().optional(),output:c.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:c.string().optional().describe("command that stops the app"),dependencies:c.record(c.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:c.array(c.string()).optional().describe("what you changed in the recipe"),error:c.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:c.array(c.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:c.object({username:ae,password:c.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:Oh.optional()}),d7=c.object({schemaVersion:c.literal(1),requirements:c.array(BJ),findings:c.array(QJ),cases:c.array(bJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:c.array(wJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:c.array(RJ),journeys:c.array(Cv).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:c.array(c.object({clause:ae,why:ae})).optional().describe("a clause a user sees or does that no journey walks, and why: none can reach it through the UI, or it is downstream of this change and not walked here"),triage:Bc.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:SJ.optional().describe("omit when no app was needed or none was started"),summary:ae.describe("one paragraph: what the change does and where the risk is")});var Qv=(n=>(n.Backend="backend",n.Ui="ui",n))(Qv||{});var Dl=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Dl||{}),kJ=c.object({file:ae.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:c.nativeEnum(Qv),change:c.nativeEnum(Dl).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:c.array(c.string()).describe("the plan case ids this file tests"),defect:c.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:c.object({requirement:ae.describe("the requirement or clause id the change deliberately alters"),line:ae.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:c.object({exit:c.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:c.array(c.object({case:ae,status:c.nativeEnum(an),defect:c.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:c.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:c.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:c.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:c.string().optional().describe("what failed and why, or why it was not run")}),assertions:c.array(c.object({case:ae,evidence:ae})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:c.array(c.object({name:ae.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:c.array(ae).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:c.object({draft:c.union([c.string(),c.array(c.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:c.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:c.array(Kf).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:ae.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),ci:Ev.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:wo.optional().describe(`for a file in ${bo}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${In}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),vJ=o(e=>{if(!e||typeof e!="object")return e;let{test:t,...n}=e;return typeof t=="string"&&t.trim()&&n.tests===void 0?{...n,tests:[t]}:e},"oneTestIsTests"),xJ=c.preprocess(vJ,c.object({description:ae.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:c.nativeEnum(Zs).optional(),sourceFile:c.string().optional().describe("the app file at fault"),sourceLine:c.number().optional(),tests:c.array(ae).optional().describe("every test file that fails because of it: a defect several tests show is one issue"),finding:c.string().optional().describe("the plan's finding id, when it is one"),requirements:c.array(ae).optional().describe("the plan's requirement or clause ids it violates")})),p7=c.object({schemaVersion:c.literal(1),tests:c.array(kJ),notWritten:c.array(c.object({case:ae,reason:ae})).describe("every plan case no test covers, and why"),journeys:c.array(Tl).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:c.object({command:c.string(),clean:c.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:c.array(c.object({package:ae,manifest:ae.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:ae.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:ae.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:c.array(ae).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciNotes:c.string().optional().describe("for each test whose ci says the repo's CI will not run it: the test, and the exact change the author must make for CI to run it"),commit:c.object({message:ae.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:ae.describe("at most 72 characters"),prBody:ae.describe("what the tests cover and what they found")}),report:c.object({summary:ae.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:c.array(xJ).describe("every defect the tests found"),nextSteps:c.array(c.string())})});var g7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var bv=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(bv||{}),ct=c.string().trim().min(1),TJ=c.object({expectation:ct.max(300).describe("the behavior this assertion pins, in words"),source:c.nativeEnum(bv),expected:ct.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),DJ=c.object({file:ct.describe("path of the NEW test file you wrote, relative to its repository"),repository:ct.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:ct.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:wo.optional().describe(`for ${bo}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:c.array(ct).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:c.array(ct).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:c.array(TJ).min(1)}),Nl=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Nl||{}),wv=300,NJ=c.object({file:ct.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:ct.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:c.nativeEnum(Nl),staleBecause:c.object({requirement:ct.describe("the requirement or clause id the change deliberately alters"),line:ct.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:c.preprocess(e=>typeof e=="string"?e.trim().slice(0,wv):e,ct.max(wv)).describe("what the change deliberately altered that made the test wrong")}),om=c.object({schemaVersion:c.literal(1),tests:c.array(DJ),maintained:c.array(NJ).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:c.array(c.object({id:ct,reason:ct.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:c.array(Tl).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:c.array(c.object({journey:ct,missing:ct.transform(e=>e.length>300?`${e.slice(0,299)}\u2026`:e)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:c.object({command:c.string(),clean:c.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:ct.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var Ml="generate-unit.json";function UJ(e){let{value:t,error:n}=at(e);if(n)return{errors:[n]};let{value:r,errors:s}=Ht(om,t);return s.length?{errors:s}:{output:r,errors:[]}}o(UJ,"parseGenerateUnitText");function LJ(e){return UJ(e.stdout)}o(LJ,"parseGenerateUnitFromSession");var nee=sn("generate-unit-schema",(e,t)=>LJ(t));var Fl=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,ree=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Fl}["']|\bimport\s+["']${Fl}["']|require\(\s*["']${Fl}["']\s*\)|\bimport\(\s*["']${Fl}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var wee=new Set(["targeted_unit","existing_evidence_sufficient"]);var HJ="triage.json";var gte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),hte={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function qJ(e){let{value:t,error:n}=at(e);if(n)return{errors:[n]};let{value:r,errors:s}=Ht(Bc,t);return s.length?{errors:s}:{triage:r,errors:[]}}o(qJ,"parseTriageText");function JJ(e){return qJ(e.stdout)}o(JJ,"parseTriageFromSession");var fte=sn("triage-schema",(e,t)=>JJ(t));function YJ(e){let t=e.inputs?.pipeline;return t?e.state.stages[t==="two-step"?"plan":"triage"]:e.state.stages.triage??e.state.stages.plan}o(YJ,"triageDecider");function am(e){if(YJ(e)?.status==="passed")return js(bc.join(e.outputsDir,HJ))}o(am,"readTriage");function cm(e){return YS(Af(e.inputs,Oe(e,`${hc}.json`),am(e)?.sutRequired))}o(cm,"revisionBlockReason");var mte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var es=Ce(require("fs")),Xr=Ce(require("path")),ix=require("child_process");var Am=require("child_process"),So=Ce(require("fs")),kv=Ce(require("os")),_l=Ce(require("path"));var jJ={onPath:o(e=>(0,Am.spawnSync)("sh",["-c",`command -v ${e}`],{stdio:"ignore"}).status===0,"onPath"),run:o((e,t)=>(0,Am.spawnSync)(e[0],e.slice(1),{cwd:t,stdio:"ignore",timeout:6e4}).status??1,"run")},Ll={cleanup:o(()=>{},"cleanup")},WJ=new Set(["pnpm","yarn"]);function vv(e,t=kv.tmpdir(),n=jJ){if(process.platform==="win32")return Ll;try{let r=Lf(e);if(!WJ.has(r)||n.onPath(r)||!n.onPath("corepack"))return Ll;So.mkdirSync(t,{recursive:!0});let s=So.mkdtempSync(_l.join(t,"testbot-pm-")),i=o(()=>So.rmSync(s,{recursive:!0,force:!0}),"cleanup");return n.run(["corepack","enable","--install-directory",s,r],e)!==0?(i(),Ll):{dir:s,cleanup:i}}catch{return Ll}}o(vv,"packageManagerShims");function xv(e,t=process.env){return e.dir?{...t,PATH:[e.dir,t.PATH].filter(Boolean).join(_l.delimiter)}:t}o(xv,"withShims");var Ol=require("crypto");var Tte=[...sf,"AWS_REGION","AWS_DEFAULT_REGION","AWS_ENDPOINT_URL","AWS_ENDPOINT_URL_BEDROCK_RUNTIME","AWS_ENDPOINT_URL_STS","AWS_SHARED_CREDENTIALS_FILE","AWS_CONFIG_FILE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BASE_URL","ANTHROPIC_BEDROCK_BASE_URL"].filter((e,t,n)=>n.indexOf(e)===t);var Ote=process.env.RUNNER_TOOL_CACHE||"/opt/hostedtoolcache";var Xte={jest:"jest",vitest:"vitest"};var qne=5*6e4;function KJ(e){return Ht(zf,e).errors}o(KJ,"validateAnalysisOutput");function Nv(e,t=[]){let{value:n,error:r}=at(e,t);if(r)return{errors:[r]};let s=KJ(n);return s.length>0?{errors:s}:{analysis:n,errors:[]}}o(Nv,"parseAnalysisText");function ZJ(e,t=[]){return Nv(e.stdout,t)}o(ZJ,"parseAnalysisFromSession");var pre=sn("analysis-schema",(e,t)=>ZJ(t,e.secretValues));var ise=Vu.rows.notRun(!0);var Rc="kept, not ",Sc="(declined the planned ";function um(e){if(!e)return[];let t=[],n=0,r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="("?n++:i===")"?n=Math.max(0,n-1):n===0&&i===";"&&e[s+1]===" "&&e[s-1]===")"&&(t.push(e.slice(r,s)),r=s+2)}return t.push(e.slice(r)),t.map(s=>{let i=s.trim();if(!i.endsWith(")"))return{expectation:i};let a=0;for(let A=i.length-1;A>=0;A--)if(i[A]===")")a++;else if(i[A]==="("&&--a===0){let u=i.slice(0,A).trim(),d=i.slice(A+1,-1).trim();return u&&d?{expectation:u,expected:d}:{expectation:i}}return{expectation:i}})}o(um,"assertionParts");var Fv=new Set(["update","regenerate","delete"]);var ose={update:"updated",regenerate:"regenerated",delete:"deleted",verify:"verified",none:"touched"};var Mv=c.string().trim().min(1),lm=c.object({schemaVersion:c.literal(1).optional(),businessCaseAnalysis:Mv.describe("1-2 sentences: what this change means for a user, and whether the evidence shows it working"),issuesFound:c.array(c.object({description:Mv,severity:c.string().optional().describe("critical | high | medium | low"),category:c.string().optional().describe("bug | lint | type | config"),sourceFile:c.string().optional(),sourceLine:c.number().optional(),findingId:c.string().optional(),requirementIds:c.array(c.string()).optional()})).describe("every real problem this run exposed \u2014 cause, file:line, severity"),nextSteps:c.array(c.string()).describe("concrete follow-ups the author can act on; required non-empty when a disclosure is BLOCKING")});function tY(e){return Ht(lm,e).errors}o(tY,"validateProseOutput");function nY(e,t=[]){let{value:n,error:r}=at(e.stdout,t);if(r)return{errors:[r]};let s=tY(n);return s.length>0?{errors:s}:{prose:n,errors:[]}}o(nY,"parseProseFromSession");var Cse=sn("report-schema",(e,t)=>nY(t,e.secretValues));var rY="<!-- skyramp-testbot -->",Uv=Fv,sY=new Set(["lint","type","config"]),Lv={critical:0,high:1,medium:2,low:3},Vv=new Set(["Pass","Fail"]);var pm=o(e=>vs(ee().statusLabels,e),"statusLabel"),dm=o(e=>vs(ee().testTypeCellLabels,e),"testTypeLabel");function we(e){return(e??"").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>").trim()}o(we,"escCell");function _v(e,t){return!e||!Vv.has(e)?"\u2014":t?`${pm(e)} (${we(Hv(t))})`:pm(e)}o(_v,"maintStatus");function Hv(e){let t=o(r=>{let s=r.indexOf(": ");return s<0?r:vs(ee().staged.maintenanceActions,r.slice(0,s))+r.slice(s)},"action");if(e.startsWith(Rc))return ee().staged.keptNot+t(e.slice(Rc.length));let n=e.indexOf(Sc);return n<0?e:e.slice(0,n)+ee().staged.declinedPlanned+t(e.slice(n+Sc.length))}o(Hv,"declineNote");function Pv(e){return e.category!==void 0&&sY.has(e.category.toLowerCase())}o(Pv,"isTooling");function $v(e,t){return(Lv[(e.severity??"").toLowerCase()]??4)-(Lv[(t.severity??"").toLowerCase()]??4)}o($v,"bySeverity");function Ov(e){return`- ${e.severity?`**[${vs(ee().severityLabels,e.severity.toLowerCase()).toUpperCase()}]** `:""}${e.description.trim()}`}o(Ov,"issueLine");function iY(e){let t=e.resultId?.split("#").slice(1).join("#");if(e.testType!=="unit"||!t)return;let n=t;try{n=decodeURIComponent(t)}catch{}let r=/^(.*?)(\[.*\])$/.exec(n);return r?{fn:r[1],kase:r[2]}:{fn:n}}o(iY,"unitTestOf");var qv=o((e,t)=>e!==void 0&&t!==void 0&&e.replace(/^\.\//,"")===t.replace(/^\.\//,""),"samePath");function Jv(e,t){return(e.testVideos??[]).find(n=>n.url&&t(n))?.url}o(Jv,"videoLink");function gm(e,t){return Jv(e,n=>qv(n.fileName,t.fileName)&&(!n.repository||!t.repository||n.repository.toLowerCase()===t.repository.toLowerCase()))}o(gm,"resultVideoLink");function hm(e,t){return Jv(e,n=>qv(n.writtenAs??n.fileName,t))}o(hm,"journeyVideoLink");function oY(e,t,n){return n?gm(e,{fileName:t,repository:n}):hm(e,t)}o(oY,"requirementVideoLink");function aY(e){let t=[],n=new Map;for(let a of e.newTestsCreated)a.testType==="unit"&&n.set(a.fileName,[...n.get(a.fileName)??[],a.testId.split("::").slice(1).join("::")]);let r=new Map,s=o((a,A)=>(n.get(a??"")??[]).find(u=>u!==A&&zk(A,u)),"parentOf"),i=new Map;for(let a of e.testResults){let A=iY(a),u=A&&!A.kase?s(a.fileName,A.fn):void 0;if(A&&u&&(A={fn:u,kase:`"${A.fn}"`}),A?.kase&&r.set(a,A.kase),!A){t.push({testId:a.testId,testType:a.testType,endpoint:a.endpoint,status:a.status,details:a.details??"",...a.fileName?{fileName:a.fileName}:{},...a.repository?{repository:a.repository}:{}});continue}let d=`${a.fileName??""}#${A.fn}`,p=i.get(d);p||(p={row:{testId:a.testId,testType:a.testType,endpoint:a.endpoint,status:a.status,details:"",test:A.fn,...a.fileName?{fileName:a.fileName}:{},...a.repository?{repository:a.repository}:{}},cases:[]},i.set(d,p),t.push(p.row)),p.cases.push(a)}for(let{row:a,cases:A}of i.values()){let u=A.filter(f=>f.status==="Fail"),d=A.filter(f=>f.status==="Pass").length,p=A.filter(f=>f.status==="Skipped").length;a.cases=A.length,a.status=u.length?"Fail":p?"Skipped":"Pass";let g=u[0];a.details=A.length===1?A[0].details??"":ee().staged.casesPassed(d,A.length,p)+(g?`; ${r.get(g)??""} ${g.details??""}`.replace(/; +/,"; ").trimEnd():"")}return t}o(aY,"resultRows");function cY(e){return um(e).map(t=>t.expected===void 0?t.expectation:`${t.expectation}: ${Kr(t.expected)}`)}o(cY,"unitAssertions");function Kr(e){let t=Math.max(0,...(e.match(/`+/g)??[]).map(s=>s.length)),n="`".repeat(t+1),r=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${r}${e}${r}${n}`}o(Kr,"codeSpan");function Gv(e){return e.newTestsCreated.some(t=>t.testType!=="unit")&&e.testResults.every(t=>t.status==="Skipped")}o(Gv,"nothingExecuted");function Yv(e,t={}){let{audience:n,collapsed:r=!1,existingEvidence:s=[],requestedBy:i,sourcePullRequest:a}=t,A=n!=="testbot-pr",u=n!=="comment",d=n!=="testbot-pr",p=[rY];if(a&&p.push(ee().staged.testsSourcePullRequest(Kr(a)),""),i){let Q=i.name.replace(/\s+/g," ").trim().replace(/[<>[\]()*_`\\|#]/g,"\\$&").replace(/@/g,"@\u200D");p.push(i.kind==="person"?ee().staged.requestedByPerson(Q):ee().staged.requestedByPolicy(Q),"")}e.notTranslated&&p.push(vs(ee().staged.notTranslated,e.notTranslated),"");let g=o(Q=>{r?p.push("<details>",`<summary>${Q}</summary>`,""):p.push(`### ${Q}`)},"sectionStart"),f=o(()=>{r&&p.push("","</details>"),p.push("")},"sectionEnd");if(A){for(let Q of e.businessCaseAnalysis.trim().split(/\r?\n/))p.push(`> ${Q}`);p.push("")}if(Gv(e)&&p.push(ee().staged.noLiveApp(e.newTestsCreated.length),""),u&&e.newTestsCreated.length){let Q=new Map;for(let H of e.newTestsCreated){if(H.testType!=="unit")continue;let W=(H.testId.split("::").slice(1).join("::")||H.testId).replace(/\[.*\]$/,""),P=Q.get(H.fileName)??{functions:new Set,endpoints:[],descriptions:new Map};H.endpoint&&!P.endpoints.includes(H.endpoint)&&P.endpoints.push(H.endpoint);let ge=H.description?.trim()??"",Me=P.descriptions.get(W)??[];Me.includes(ge)||Me.push(ge),P.functions.add(W),P.descriptions.set(W,Me),Q.set(H.fileName,P)}let S=e.newTestsCreated.filter(H=>H.testType!=="unit"),F=S.length+[...Q.values()].reduce((H,W)=>H+W.functions.size,0);g(ee().testRecommendationsImplementedHeader(F));for(let[H,{functions:W,endpoints:P,descriptions:ge}]of Q){let Me=W.size;p.push(ee().staged.unitTestsInFile(`\`${H}\``,Me,P.map(Se=>`\`${Se}\``).join(", ")),"");let be=new Map;for(let[Se,Ie]of ge){let _e=Ie.join("\0"),$=be.get(_e)??{fns:[],descriptions:Ie};$.fns.push(Se),be.set(_e,$)}let De=0;for(let{fns:Se,descriptions:Ie}of be.values()){p.push(`${++De}. ${Se.map($=>`\`${$}\``).join(", ")}`);let _e=[...new Set(Ie.flatMap($=>cY($)))];for(let $ of _e)p.push(` - ${$}`)}p.push("")}for(let H of S){let W=H.testId?`\`${H.testId}\``:dm(H.testType),P=H.fileName?` (\`${H.fileName}\`)`:"",ge=H.endpoint?`
94
94
  \`${H.endpoint}\``:"",Me=H.description?`
95
95
  ${H.description.trim()}`:"";p.push(`- ${W}${P}${ge}${Me}`)}f()}let m=(e.testMaintenance??[]).filter(Q=>Uv.has(Q.action));if(u&&m.length){g(ee().staged.testMaintenanceHeader),p.push(ee().maintenanceTableHeader),p.push("|-----------|----------|------|--------|--------|-------|");for(let Q of m)p.push(`| ${we(dm(Q.testType))} | ${we(Q.endpoint)} | \`${we(Q.fileName)}\` | ${we(Q.description)} | ${_v(Q.beforeStatus,Q.beforeDetails)} | ${_v(Q.afterStatus,Q.afterDetails)} |`);f()}let E=o(Q=>Q.startsWith(Rc)||Q.includes(Sc),"hasDeclineNote"),I=(e.testMaintenance??[]).filter(Q=>E(Q.afterDetails)&&(!Uv.has(Q.action)||!Vv.has(Q.afterStatus??"")));if(u&&I.length){g(ee().staged.declinedMaintenanceHeader);for(let Q of I)p.push(`- \`${we(Q.fileName)}\`: ${we(Hv(Q.afterDetails))}`);f()}if(u&&s.length){g(ee().staged.existingEvidenceHeader);let Q=new Map;for(let S of s){let F=`${S.check}\0${S.url??""}\0${S.revision??""}`;Q.set(F,[...Q.get(F)??[],S])}for(let[,[S,...F]]of Q){let H=S.url?`[${Kr(S.check)}](${S.url})`:Kr(S.check);p.push(ee().staged.trustedCheckPassed(H,S.revision?Kr(S.revision.slice(0,7)):""),"");for(let W of[S,...F])p.push(`- ${Kr(W.behavior)}`);p.push("")}f()}if(u&&e.testResults.length){g(ee().staged.testResultsHeader);let Q=aY(e),S=Q.some(P=>P.test),F=Q.some(P=>gm(e,P)),H=S?ee().staged.unitResultsTableHeader:ee().staged.resultsTableHeader;p.push(F?`${H} ${ee().columnVideo} |`:H),p.push(`${S?"|---------|-----------|----------|------|-------|--------|---------|":"|---------|-----------|----------|--------|---------|"}${F?"-------|":""}`);for(let P of Q){let ge=P.details.replace(/(\S+\.(?:py|ts|js|spec\.\w+))/gi,"`$1`"),Me=P.testId?`\`${we(P.testId)}\``:"\u2014",be=S?` ${P.test?`\`${we(P.test)}\``:""} | ${P.cases??""} |`:"",De=gm(e,P),Se=F?` ${De?ee().videoDownloadLink(De):"\u2014"} |`:"";p.push(`| ${Me} | ${we(dm(P.testType))} | ${we(P.endpoint)} |${be} ${we(pm(P.status))} | ${we(ge)} |${Se}`)}let W=(e.testVideos??[]).find(P=>P.artifactsUrl)?.artifactsUrl;!F&&W&&p.push("",ee().videosArtifactFallback(W)),f()}if(e.requirements?.length){let Q=e.requirements.flatMap(P=>P.clauses),S=o(P=>P.status==="Pass"||P.status==="Passed, test not kept","passes"),F=Q.filter(S).length;g(ee().staged.requirementsHeader(F,Q.length));let H=o(P=>vs(ee().staged.clauseStatuses,P.status),"status"),W=o(P=>(P.status==="Not tested"||P.status==="Passed, test not kept")&&P.notTested?`${H(P)}: ${P.notTested}`:P.findings.length?`${H(P)} \u2014 ${P.findings.join(", ")}`:H(P),"result");if(u){p.push(ee().staged.requirementsTableHeader),p.push("|-------------|--------|-------|--------|");for(let P of e.requirements)P.clauses.forEach((ge,Me)=>{let be=Me===0?`**${we(P.label)}**${P.statement?` ${we(P.statement)}`:""}`:"",De=`\`${we(ge.id)}\`${ge.text?` ${we(ge.text)}`:""}`,Se=new Map;for(let $ of ge.tests){let ve=$.fileName??$.testId,ye=Se.get(ve)??{fns:new Set};for(let Jt of $.functions)ye.fns.add(Jt);ye.video??=$.fileName?oY(e,$.fileName,$.repository):void 0,Se.set(ve,ye)}let Ie=Se.size?[...Se].map(([$,{fns:ve,video:ye}])=>`\`${we($)}\`${ve.size?` \u2014 ${[...ve].map(Jt=>`\`${we(Jt)}\``).join(", ")}`:""}${ye?` ${ee().videoDownloadLink(ye)}`:""}`).join("<br>"):"\u2014",_e=P.source==="could-break"&&ge.status==="Pass"?ee().staged.regressionGuard:"";p.push(`| ${be} | ${De} | ${Ie} | ${we(W(ge)+_e)} |`)})}else{p.push(ee().staged.requirementsSummaryTableHeader),p.push("|-------------|-----------------|-------------|");for(let P of e.requirements){let ge=P.clauses.filter(S).length,Me=P.clauses.filter(be=>!S(be)).map(be=>`\`${we(be.id)}\` ${we(W(be))}`);p.push(`| **${we(P.label)}**${P.statement?` ${we(P.statement)}`:""} | ${ge}/${P.clauses.length} | ${Me.join("<br>")||"\u2014"} |`)}}f()}if(u&&e.changes?.length&&!e.requirements?.length){let Q=e.executionCoverage,S=Q?ee().staged.coverageCaption(Q.generated,Q.modified,Q.verified,Q.executed):"";g(`${ee().staged.behaviourCoverageHeader}${S}`),p.push(ee().staged.coverageTableHeader),p.push("|-----------|--------|-----------|----------------|");for(let F of e.changes){let H=F.testedBy.length?F.testedBy.map(P=>`\`${we(P)}\``).join(", "):F.writtenBy.length?ee().staged.writtenNotRun:"\u2014",W=F.maintainedBy.length?F.maintainedBy.map(P=>`\`${we(P)}\``).join(", "):"\u2014";p.push(`| ${we(F.text)} | \`${we(F.source)}\` | ${H} | ${W} |`)}f()}if(e.userJourneys?.length){let Q=e.userJourneys.filter(F=>F.status==="Pass"&&!F.problems.length).length;g(`\u{1F9ED} User Journeys Covered (${Q}/${e.userJourneys.length} walked end to end)`);let S=e.userJourneys.some(F=>hm(e,F.fileName));p.push(`| Journey | Test | Status | Notes |${S?` ${ee().columnVideo} |`:""}`),p.push(`|---------|------|--------|-------|${S?"-------|":""}`);for(let F of e.userJourneys){let H=F.fileName?`\`${we(F.fileName)}\`${F.test?` \u2014 ${we(F.test)}`:""}`:"\u2014",W=F.source&&F.source!=="inferred"?`; described in the ${F.source==="spec"?"spec":"PR description"}`:"; inferred from the app",P=(F.uncovered?`not covered: ${F.uncovered}`:F.problems.length?`does not walk it end to end: ${F.problems.join("; ")}`:`from ${F.entry}, ${F.steps} steps`)+W,ge=S?hm(e,F.fileName):void 0;p.push(`| ${we(F.name)} | ${H} | ${we(F.status)} | ${we(P)} |${S?` ${ge?ee().videoDownloadLink(ge):"\u2014"} |`:""}`)}f()}if(d){let Q=e.issuesFound.filter(F=>!Pv(F)).sort($v),S=e.issuesFound.filter(Pv).sort($v);if(Q.length){g(ee().staged.issuesFoundHeader);for(let F of Q)p.push(Ov(F));f()}if(S.length){p.push(`### ${ee().configErrorsHeader}`);for(let F of S)p.push(Ov(F));p.push("")}}let v=e.testPackages??[],C=e.dependencyChanges??[];if(v.length){p.push(ee().staged.testPackagesHeader,"");for(let Q of v)p.push(`- ${ee().staged.testPackageLine(Q.directory,Q.entrypoint)}`);C.length||p.push(`- ${ee().staged.appManifestsUntouched}`),p.push("")}if(C.length){p.push(ee().staged.dependencyChangesHeader,"");for(let Q of C)p.push(`- ${ee().staged.dependencyChangeLine(Q.package,Q.repository?`${Q.repository}: ${Q.manifest}`:Q.manifest,(Q.reason??"").replace(/\s+/g," ").trim())}`);p.push("")}let T=(e.caveats??[]).filter(Q=>Q.kind!=="tests-not-executed"||!Gv(e));if(T.length){p.push(ee().staged.caveatsHeader,"");for(let Q of T)p.push(`- ${Q.text}`);p.push("")}if(d&&e.nextSteps.length){p.push(ee().nextStepsHeader,"");for(let Q of e.nextSteps)p.push(`- ${Q.trim()}`);p.push("")}return p.join(`
96
96
  `).replace(/\n{3,}/g,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/testbot-core",
3
- "version": "0.13.0-v3.272",
3
+ "version": "0.13.0-v3.274",
4
4
  "description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
5
5
  "main": "dist/main.js",
6
6
  "//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. dist/VERSION.json exists only in a release-engine.yml build.",