@skyramp/testbot-core 0.13.0-v3.284 → 0.13.0-v3.285
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 +1 -1
- package/dist/main.js +370 -370
- package/dist/post.js +2 -2
- package/dist/runner-client.cjs +2 -2
- package/package.json +1 -1
package/dist/runner-client.cjs
CHANGED
|
@@ -86,11 +86,11 @@ ${u}`,this.dataLineCount++;return}if($u(t,s,D1)){U1(t,i)&&(this.setEventFieldSiz
|
|
|
86
86
|
`+h.slice(R+1):j+=h.slice(N),j.slice(1)}o(jc,"foldLine");function Ir(h){let B="",w=0;for(let D=0;D<h.length;w>=65536?D+=2:D++){w=Sn(h,D);let N=Ce[w];!N&&yr(w)?(B+=h[D],w>=65536&&(B+=h[D+1])):B+=N||He(w)}return B}o(Ir,"escapeString");function ed(h,B,w){let D="",N=h.tag;for(let L=0,R=w.length;L<R;L+=1){let O=w[L];h.replacer&&(O=h.replacer.call(w,String(L),O)),(y(h,B,O,!1,!1)||typeof O>"u"&&y(h,B,null,!1,!1))&&(D!==""&&(D+=","+(h.condenseFlow?"":" ")),D+=h.dump)}h.tag=N,h.dump="["+D+"]"}o(ed,"writeFlowSequence");function $o(h,B,w,D){let N="",L=h.tag;for(let R=0,O=w.length;R<O;R+=1){let j=w[R];h.replacer&&(j=h.replacer.call(w,String(R),j)),(y(h,B+1,j,!0,!0,!1,!0)||typeof j>"u"&&y(h,B+1,null,!0,!0,!1,!0))&&((!D||N!=="")&&(N+=Qt(h,B)),h.dump&&A===h.dump.charCodeAt(0)?N+="-":N+="- ",N+=h.dump)}h.tag=L,h.dump=N||"[]"}o($o,"writeBlockSequence");function td(h,B,w){let D="",N=h.tag,L=Object.keys(w);for(let R=0,O=L.length;R<O;R+=1){let j="";D!==""&&(j+=", "),h.condenseFlow&&(j+='"');let te=L[R],se=w[te];h.replacer&&(se=h.replacer.call(w,te,se)),y(h,B,te,!1,!1)&&(h.dump.length>1024&&(j+="? "),j+=h.dump+(h.condenseFlow?'"':"")+":"+(h.condenseFlow?"":" "),y(h,B,se,!1,!1)&&(j+=h.dump,D+=j))}h.tag=N,h.dump="{"+D+"}"}o(td,"writeFlowMapping");function nd(h,B,w,D){let N="",L=h.tag,R=Object.keys(w);if(h.sortKeys===!0)R.sort();else if(typeof h.sortKeys=="function")R.sort(h.sortKeys);else if(h.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let O=0,j=R.length;O<j;O+=1){let te="";(!D||N!=="")&&(te+=Qt(h,B));let se=R[O],Ae=w[se];if(h.replacer&&(Ae=h.replacer.call(w,se,Ae)),!y(h,B+1,se,!0,!0,!0))continue;let ge=h.tag!==null&&h.tag!=="?"||h.dump&&h.dump.length>1024;ge&&(h.dump&&A===h.dump.charCodeAt(0)?te+="?":te+="? "),te+=h.dump,ge&&(te+=Qt(h,B)),y(h,B+1,Ae,!0,ge)&&(h.dump&&A===h.dump.charCodeAt(0)?te+=":":te+=": ",te+=h.dump,N+=te)}h.tag=L,h.dump=N||"{}"}o(nd,"writeBlockMapping");function l(h,B,w){let D=w?h.explicitTypes:h.implicitTypes;for(let N=0,L=D.length;N<L;N+=1){let R=D[N];if((R.instanceOf||R.predicate)&&(!R.instanceOf||typeof B=="object"&&B instanceof R.instanceOf)&&(!R.predicate||R.predicate(B))){if(w?R.multi&&R.representName?h.tag=R.representName(B):h.tag=R.tag:h.tag="?",R.represent){let O=h.styleMap[R.tag]||R.defaultStyle,j;if(r.call(R.represent)==="[object Function]")j=R.represent(B,O);else if(s.call(R.represent,O))j=R.represent[O](B,O);else throw new t("!<"+R.tag+'> tag resolver accepts not "'+O+'" style');h.dump=j}return!0}}return!1}o(l,"detectType");function y(h,B,w,D,N,L,R){h.tag=null,h.dump=w,l(h,w,!1)||l(h,w,!0);let O=r.call(h.dump),j=D;D&&(D=h.flowLevel<0||h.flowLevel>B);let te=O==="[object Object]"||O==="[object Array]",se,Ae;if(te&&(se=h.duplicates.indexOf(w),Ae=se!==-1),(h.tag!==null&&h.tag!=="?"||Ae||h.indent!==2&&B>0)&&(N=!1),Ae&&h.usedDuplicates[se])h.dump="*ref_"+se;else{if(te&&Ae&&!h.usedDuplicates[se]&&(h.usedDuplicates[se]=!0),O==="[object Object]")D&&Object.keys(h.dump).length!==0?(nd(h,B,h.dump,N),Ae&&(h.dump="&ref_"+se+h.dump)):(td(h,B,h.dump),Ae&&(h.dump="&ref_"+se+" "+h.dump));else if(O==="[object Array]")D&&h.dump.length!==0?(h.noArrayIndent&&!R&&B>0?$o(h,B-1,h.dump,N):$o(h,B,h.dump,N),Ae&&(h.dump="&ref_"+se+h.dump)):(ed(h,B,h.dump),Ae&&(h.dump="&ref_"+se+" "+h.dump));else if(O==="[object String]")h.tag!=="?"&&Vc(h,h.dump,B,L,j);else{if(O==="[object Undefined]")return!1;if(h.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+O)}if(h.tag!==null&&h.tag!=="?"){let ge=encodeURI(h.tag[0]==="!"?h.tag.slice(1):h.tag).replace(/!/g,"%21");h.tag[0]==="!"?ge="!"+ge:ge.slice(0,18)==="tag:yaml.org,2002:"?ge="!!"+ge.slice(18):ge="!<"+ge+">",h.dump=ge+" "+h.dump}}return!0}o(y,"writeNode");function S(h,B){let w=[],D=[];v(h,w,D);let N=D.length;for(let L=0;L<N;L+=1)B.duplicates.push(w[D[L]]);B.usedDuplicates=new Array(N)}o(S,"getDuplicateReferences");function v(h,B,w){if(h!==null&&typeof h=="object"){let D=B.indexOf(h);if(D!==-1)w.indexOf(D)===-1&&w.push(D);else if(B.push(h),Array.isArray(h))for(let N=0,L=h.length;N<L;N+=1)v(h[N],B,w);else{let N=Object.keys(h);for(let L=0,R=N.length;L<R;L+=1)v(h[N[L]],B,w)}}}o(v,"inspectNode");function b(h,B){B=B||{};let w=new Te(B);w.noRefs||S(h,w);let D=h;return w.replacer&&(D=w.replacer.call({"":D},"",D)),y(w,0,D,!0,!0)?w.dump+`
|
|
87
87
|
`:""}return o(b,"dump2"),Of.dump=b,Of}o(tq,"requireDumper");var vk;function nq(){if(vk)return ft;vk=1;let e=eq(),t=tq();function n(r,s){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}return o(n,"renamed"),ft.Type=Bt(),ft.Schema=xk(),ft.FAILSAFE_SCHEMA=Fk(),ft.JSON_SCHEMA=Pk(),ft.CORE_SCHEMA=$k(),ft.DEFAULT_SCHEMA=Gf(),ft.load=e.load,ft.loadAll=e.loadAll,ft.dump=t.dump,ft.YAMLException=Ic(),ft.types={binary:Vk(),float:_k(),map:Nk(),null:Mk(),pairs:qk(),set:jk(),timestamp:Ok(),bool:Uk(),int:Lk(),merge:Gk(),omap:Hk(),seq:Dk(),str:Tk()},ft.safeLoad=n("safeLoad","load"),ft.safeLoadAll=n("safeLoadAll","loadAll"),ft.safeDump=n("safeDump","dump"),ft}o(nq,"requireJsYaml");var rq=nq(),sq=Z2(rq),{Type:e4,Schema:t4,FAILSAFE_SCHEMA:n4,JSON_SCHEMA:r4,CORE_SCHEMA:s4,DEFAULT_SCHEMA:i4,load:ei,loadAll:iq,dump:o4,YAMLException:a4,types:c4,safeLoad:A4,safeLoadAll:u4,safeDump:l4}=sq;var Sl=fe(require("fs")),ti=fe(require("path"));var wo=fe(require("path"));var h4=wo.join(".skyramp","workspace.yml");var oq={py:"python",go:"go",java:"java",kt:"kotlin",rb:"ruby",cs:"csharp",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",kts:"kotlin",rs:"rust",php:"php",scala:"scala",swift:"swift",ex:"elixir",exs:"elixir",dart:"dart",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",hh:"cpp",groovy:"groovy"};var f4=new Set(Object.values(oq));var R4=5*6e4;function Hf(e){try{let r=JSON.parse(Sl.readFileSync(ti.join(e,"package.json"),"utf-8")).packageManager,s=typeof r=="string"?r.match(/^(pnpm|yarn|bun|npm)\b/):null;if(s)return s[1]}catch{}let t=[["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["bun.lockb","bun"],["bun.lock","bun"],["package-lock.json","npm"]],n=ti.resolve(e);for(let r=0;r<6;r++){for(let[i,a]of t)if(Sl.existsSync(ti.join(n,i)))return a;let s=ti.dirname(n);if(s===n)break;n=s}return"npm"}o(Hf,"packageManagerOf");var Jk=["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],aq={"package.json":Jk,"pyproject.toml":["poetry.lock","uv.lock","pdm.lock"],Pipfile:["Pipfile.lock"]};function jf(e,t){let n=Ue.basename(t),r=aq[n];if(!r)return[];let s=Ue.resolve(e),i=Ue.dirname(Ue.resolve(s,t)),a=Ue.relative(s,i);if(a===".."||a.startsWith(`..${Ue.sep}`)||Ue.isAbsolute(a))return[];let A=o((d,p)=>p.map(g=>Ue.join(Ue.relative(s,d),g)).filter(g=>yf(s,g)),"trackedIn"),u=A(i,r);if(u.length)return u;for(let d=i;d!==s;){d=Ue.dirname(d);let p=cq(d,Ue.relative(d,i).split(Ue.sep).join("/"),n);if(p)return A(d,p)}return[]}o(jf,"trackedLockfiles");function Yk(e,t){return t.filter(n=>sk(e,n)&&kl(Ue.join(e,n)))}o(Yk,"updatedLockfiles");function cq(e,t,n){if(n==="package.json"){let r=pq(Ue.join(e,"pnpm-workspace.yaml"));if(qf(r?.packages,t))return["pnpm-lock.yaml"];let i=uq(Ue.join(e,"package.json"))?.workspaces,a=Array.isArray(i)?i:i?.packages;return qf(a,t)?Jk.filter(A=>A!=="pnpm-lock.yaml"):void 0}if(n==="pyproject.toml"){let r=Aq(Ue.join(e,"pyproject.toml"));if(r&&qf([...r.members,...r.exclude.map(s=>`!${s}`)],t))return["uv.lock"]}}o(cq,"workspaceLockfiles");function qf(e,t){if(!Array.isArray(e))return!1;let n=o(a=>a.trim().replace(/^\.\//,"").replace(/\/+$/,""),"norm"),r=e.filter(a=>typeof a=="string"),s=r.filter(a=>!a.startsWith("!")).map(n),i=r.filter(a=>a.startsWith("!")).map(a=>n(a.slice(1)));return s.some(a=>Ue.matchesGlob(t,a))&&!i.some(a=>Ue.matchesGlob(t,a))}o(qf,"lists");function Aq(e){let t;try{t=Qc.readFileSync(e,"utf-8")}catch{return}let n=t.split(`
|
|
88
88
|
`),r=n.findIndex(A=>A.trim()==="[tool.uv.workspace]");if(r<0)return;let s=n.findIndex((A,u)=>u>r&&A.trim().startsWith("[")),i=n.slice(r+1,s<0?void 0:s).join(`
|
|
89
|
-
`),a=o(A=>{let u=i.match(new RegExp(`^\\s*${A}\\s*=\\s*\\[([^\\]]*)\\]`,"m"));return u?[...u[1].matchAll(/["']([^"']+)["']/g)].map(d=>d[1]):[]},"array");return{members:a("members"),exclude:a("exclude")}}o(Aq,"uvWorkspace");function uq(e){return lq(Wk(e))}o(uq,"readJson");function lq(e){try{return JSON.parse(e)}catch{return}}o(lq,"parseJson");function dq(e){try{return ei(e)}catch{return}}o(dq,"parseYaml");function pq(e){return dq(Wk(e))}o(pq,"readYaml");function Wk(e){try{return Qc.readFileSync(e,"utf-8")}catch{return""}}o(Wk,"readText");function kl(e){try{return Qc.lstatSync(e).isFile()}catch{return!1}}o(kl,"isFile");var Jf="test-package.json";var gq=["node_modules",".venv","test-results","playwright-report","blob-report","__pycache__",".pytest_cache"],zk=o(e=>e.split(hr.sep).join("/"),"posix");function Yf(e,t){let n=zk(e);return t.some(r=>n===r||n.startsWith(`${r}/`))}o(Yf,"insidePackage");function Kk(e){return zk(e).split("/").some(t=>gq.includes(t))}o(Kk,"producedByPackage");var hq=o(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRegex"),Xk=/%[psdifjo#]|\$[A-Za-z_][\w.]*/g;var fq=/ (?:>|›) /;function mq(e){return e.split(Xk).map(t=>t.split(fq).map(hq).join("(?: > | \u203A | )")).join(".+?")}o(mq,"testNamePattern");function ev(e,t){return new RegExp(Xk.source).test(t)?new RegExp(`^(?:.* )?${mq(t)}$`).test(e):!1}o(ev,"isEachCaseOf");function Wf(e){return zf(e)&&hf(e).length===0&&mf(e.inputs?.sharedEnvironment).length===0}o(Wf,"sutIsHealthy");function zf(e){let t=Rq(e);if(!t&&e.state.stages.deploy?.status!=="passed")return!1;let n=Pe(e,"deploy.json");return n?bq(n):!t}o(zf,"sutCameUp");function bq(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}o(bq,"deployCameUp");function Rq(e){let t=e.state.stages.plan,n=e.state.stages.deploy;return!(e.inputs?.pipeline?e.inputs.pipeline==="two-step":!n)||t?.status!=="passed"?!1:!n||n.updatedAt<=t.updatedAt}o(Rq,"broughtUpByPlan");var ni=(a=>(a.Place="place",a.Update="update",a.Regenerate="regenerate",a.Delete="delete",a.Verify="verify",a.None="none",a))(ni||{}),un=(r=>(r.Pass="pass",r.Fail="fail",r.Skip="skip",r))(un||{}),An=c.string().trim().min(1),nv=c.object({case:An.describe("a covers id \u2014 the recommend case this test realizes"),status:c.nativeEnum(un)}),rv=c.object({exit:c.number({invalid_type_error:"must be a number or null"}).nullable().describe("process exit of the re-run; null when no SUT was available"),details:c.string().optional().describe("what failed, or why a file was not run \u2014 required on any non-zero exit"),tests:c.array(nv).optional().describe("ONE ENTRY PER CASE the file covers; must agree with exit (0 \u2192 no fail; non-zero \u2192 at least one)")}),sv=c.object({from:c.string().optional().describe("staged path \u2014 required for placements"),file:An.describe("final path relative to its repository, inside that checkout, with a source-file extension"),repository:An.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),action:c.nativeEnum(ni),covers:c.array(c.string()).optional().describe("recommend ids a placed test covers"),repro:c.boolean().optional().describe("this test is MEANT to fail \u2014 it reproduces a reported bug"),finding:c.boolean().optional().describe("a non-repro test that failed on a REAL product bug"),placementBroken:c.boolean().optional().describe('placement/harness problem one repair could not fix \u2014 every reran.tests entry is then "skip"'),keptReason:An.optional().describe("why a planned delete/regenerate was declined and the file kept"),isolatedRun:An.optional().describe('only for a test marked "runs alone": the command, from its checkout root and without a shell, that runs only this file and writes its JUnit XML into $SKYRAMP_RESULTS_DIR (named by its path: no shell expands it) \u2014 the harness runs it, so leave reran.exit null'),reran:rv,assertionCount:c.number().int().nonnegative().optional().describe("[derived] assertions reachable from the file, counted at write time")}).refine(e=>e.action!=="place"||typeof e.from=="string"&&e.from.trim().length>0,{message:'is a place but has no "from" staged path',path:[]}),iv=(n=>(n.Junit="junit",n.Converter="converter",n))(iv||{}),Sq=An.optional().describe("the items[].file this test is in \u2014 needed only when two of this suite's files cover the same case id"),kq=c.object({results:An.describe("the JUnit XML file this run wrote, a plain file name inside $SKYRAMP_RESULTS_DIR (e.g. backend.xml)"),source:c.nativeEnum(iv),run:An.describe("the command you ran that wrote it, exactly as you ran it (with any converter)"),files:c.array(An).min(1).describe("the items[].file paths this run covered"),cases:c.array(c.object({test:An.describe("the test's name as the runner reports it, qualified by its class or file (e.g. tests/test_a.py::test_x) when the bare name repeats"),case:An.describe("the covers id it realizes"),file:Sq})).describe("map each reported test name to the case it covers")}),vq=c.object({suites:c.array(kq).min(1)}),Kf=c.object({schemaVersion:c.literal(1),items:c.array(sv),runnerResults:vq.optional().describe("the JUnit XML your test runs wrote into $SKYRAMP_RESULTS_DIR, so the harness reads each test's result from the runner \u2014 omit only when no SUT is available"),ignored:c.array(c.string()).describe("existing tests assessed and deliberately left untouched"),summary:An.describe("one paragraph")});var Tl=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Tl||{}),ri=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(ri||{}),si=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(si||{}),Xf=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(Xf||{}),em=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(em||{}),qn=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(qn||{}),ke=c.string().trim().min(1),Ro=ke.describe("file:line"),ov=o(e=>ke.refine(t=>t.length<=400,t=>({message:`is ${t.length} characters, over the 400 cap \u2014 ${e}`})),"cap400"),wc=ke.optional().describe('multi-repo only: the OTHER checkout this lives in \u2014 its "owner/repo" slug, or the directory name if the run discovered it; omit for the working checkout'),Zf=c.object({method:ke,path:ke,service:c.string().optional(),evidence:Ro,repository:wc}),xq=c.object({id:ke.describe("short-slug, e.g. R9"),statement:ke.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:c.nativeEnum(qn).describe("spec outranks pr-description when both state it"),evidence:ke.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),Tq=c.object({id:ke.describe("short-slug"),statement:ke.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:ke.describe("METHOD /path, or a component/page name"),evidence:ke.describe("file:line from the diff that introduces it"),repository:wc,satisfies:c.array(ke).optional().describe("requirement ids (from `requirements`) this behaviour correctly implements \u2014 a requirement met only in part is ALSO named by the finding that shows the rest (conflictsWith)")}),Dq=c.object({id:ke.describe("short-slug"),file:ke,line:c.number().optional(),claim:ov("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:c.nativeEnum(ri),evidence:ov("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:c.nativeEnum(si),repository:wc,conflictsWith:c.array(ke).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),Nq=c.object({name:ke,language:c.string().optional(),framework:c.string().optional(),evidence:Ro,repository:wc}),Fq=c.object({dir:ke,framework:c.string().optional(),kind:c.nativeEnum(Xf),evidence:Ro,repository:wc}),Mq=c.object({from:ke,to:ke,onDelete:c.nativeEnum(em),evidence:Ro}),Uq=c.object({entity:ke,field:ke,values:c.array(c.string()),evidence:Ro}),Lq=c.object({entities:c.array(c.object({name:ke,evidence:Ro})),references:c.array(Mq).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:c.array(Uq)}),tm=c.object({schemaVersion:c.literal(1),repository:c.object({path:ke.describe("absolute repo path"),currentBranch:ke,baseBranch:ke}),project:c.object({type:c.nativeEnum(Tl),primaryLanguage:ke,languages:c.array(c.string()),frameworks:c.array(c.string())}),services:c.array(Nq),infrastructure:c.object({containerized:c.boolean(),hasDockerCompose:c.boolean(),composeFiles:c.array(c.string()),hasCiCd:c.boolean()}),diff:c.object({changedFiles:c.array(c.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:c.boolean(),summary:ke.describe("\u2264400 chars")}),endpoints:c.object({new:c.array(Zf),modified:c.array(Zf),removed:c.array(Zf)}),existingTests:c.object({locations:c.array(Fq)}),entityMap:Lq,requirements:c.array(xq).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:c.array(Tq),findings:c.array(Dq),unexamined:c.array(c.string()).describe("files or areas outside this change you did not open"),summary:ke.describe("one paragraph on what this change does and its test-relevant risk")});var Dl=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(Dl||{}),mr=c.string().trim().min(1),_q=c.object({case:mr.describe("recommend id this assertion enforces"),evidence:mr.describe("the exact assertion line from the file that checks that case's observable")}),nm=c.object({kind:c.nativeEnum(Al).describe("seed: data the test creates in the app; runtime_mock: a mock on a Skyramp worker, which other tests reach too; env_override: an env value the app runs with. A stub inside the test's own process, such as a browser page's route, is none of these"),target:mr.describe("the dependency, endpoint or data it affects"),mechanism:c.nativeEnum(ul).describe("test_code: the test applies and undoes it; skyramp_mocker: a mock the test applies on a Skyramp worker; recipe_override: the mocker cannot reach the dependency (its URL is fixed in the build)"),detail:mr.describe("what it sets up"),worker:mr.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:mr.optional().describe("seed: a command that removes the data when the test does not, run as written and without a shell: give real values, not a placeholder such as <id>, single-quote an argument that holds shell syntax, or put the logic in a script in the repository and run that")}),Pq=c.object({file:mr.describe("staged path under .skyramp/staged/"),source:c.nativeEnum(Dl),language:mr,covers:c.array(c.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:c.array(_q).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:c.array(nm).optional().describe("what the test sets up against the running app, in order: data it seeds, Skyramp mocks it applies, env overrides; omit when none")}),rm=c.object({schemaVersion:c.literal(1),tests:c.array(Pq),deferredUi:c.array(c.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:mr.describe("one paragraph")});var Er=c.string().trim().min(1),bc=72,$q=c.object({repository:Er.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:c.string(),command:c.string().describe("the exact command you ran, scoped to the changed files"),clean:c.boolean(),fixed:c.array(c.string()).optional().describe("files you fixed"),uncovered:c.array(c.string()).describe("changed/new files this linter's own config does not match (wrong extension, wrong directory) \u2014 so `clean` never examined them, even though CI may still execute them. Empty array, not omitted, when every changed/new file IS covered.")}),W5=c.object({schemaVersion:c.literal(1),lint:c.array($q).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:c.object({ok:c.boolean(),notes:c.string().optional()}),ciReadiness:c.object({covered:c.boolean().describe("will the repo's CI run these tests?"),notes:c.string().optional()}),dependencies:c.object({added:c.array(c.object({package:c.string(),manifest:c.string(),repository:Er.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:Er.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")})).describe("every package added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own")}),support:c.array(c.object({file:Er,repository:Er.optional().describe("owner/repo of the file's checkout; omit for the working checkout")})).optional().describe("the files the tests need besides themselves (helper modules, page objects, fixtures, snapshots), delivered with them"),commit:c.object({message:Er.refine(e=>e.split(`
|
|
89
|
+
`),a=o(A=>{let u=i.match(new RegExp(`^\\s*${A}\\s*=\\s*\\[([^\\]]*)\\]`,"m"));return u?[...u[1].matchAll(/["']([^"']+)["']/g)].map(d=>d[1]):[]},"array");return{members:a("members"),exclude:a("exclude")}}o(Aq,"uvWorkspace");function uq(e){return lq(Wk(e))}o(uq,"readJson");function lq(e){try{return JSON.parse(e)}catch{return}}o(lq,"parseJson");function dq(e){try{return ei(e)}catch{return}}o(dq,"parseYaml");function pq(e){return dq(Wk(e))}o(pq,"readYaml");function Wk(e){try{return Qc.readFileSync(e,"utf-8")}catch{return""}}o(Wk,"readText");function kl(e){try{return Qc.lstatSync(e).isFile()}catch{return!1}}o(kl,"isFile");var Jf="test-package.json";var gq=["node_modules",".venv","test-results","playwright-report","blob-report","__pycache__",".pytest_cache"],zk=o(e=>e.split(hr.sep).join("/"),"posix");function Yf(e,t){let n=zk(e);return t.some(r=>n===r||n.startsWith(`${r}/`))}o(Yf,"insidePackage");function Kk(e){return zk(e).split("/").some(t=>gq.includes(t))}o(Kk,"producedByPackage");var hq=o(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRegex"),Xk=/%[psdifjo#]|\$[A-Za-z_][\w.]*/g;var fq=/ (?:>|›) /;function mq(e){return e.split(Xk).map(t=>t.split(fq).map(hq).join("(?: > | \u203A | )")).join(".+?")}o(mq,"testNamePattern");function ev(e,t){return new RegExp(Xk.source).test(t)?new RegExp(`^(?:.* )?${mq(t)}$`).test(e):!1}o(ev,"isEachCaseOf");function Wf(e){return zf(e)&&hf(e).length===0&&mf(e.inputs?.sharedEnvironment).length===0}o(Wf,"sutIsHealthy");function zf(e){let t=Rq(e);if(!t&&e.state.stages.deploy?.status!=="passed")return!1;let n=Pe(e,"deploy.json");return n?bq(n):!t}o(zf,"sutCameUp");function bq(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}o(bq,"deployCameUp");function Rq(e){let t=e.state.stages.plan,n=e.state.stages.deploy;return!(e.inputs?.pipeline?e.inputs.pipeline==="two-step":!n)||t?.status!=="passed"?!1:!n||n.updatedAt<=t.updatedAt}o(Rq,"broughtUpByPlan");var ni=(a=>(a.Place="place",a.Update="update",a.Regenerate="regenerate",a.Delete="delete",a.Verify="verify",a.None="none",a))(ni||{}),un=(r=>(r.Pass="pass",r.Fail="fail",r.Skip="skip",r))(un||{}),An=c.string().trim().min(1),nv=c.object({case:An.describe("a covers id \u2014 the recommend case this test realizes"),status:c.nativeEnum(un),fromJourney:c.boolean().optional()}),rv=c.object({exit:c.number({invalid_type_error:"must be a number or null"}).nullable().describe("process exit of the re-run; null when no SUT was available"),details:c.string().optional().describe("what failed, or why a file was not run \u2014 required on any non-zero exit"),tests:c.array(nv).optional().describe("ONE ENTRY PER CASE the file covers; must agree with exit (0 \u2192 no fail; non-zero \u2192 at least one)")}),sv=c.object({from:c.string().optional().describe("staged path \u2014 required for placements"),file:An.describe("final path relative to its repository, inside that checkout, with a source-file extension"),repository:An.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),action:c.nativeEnum(ni),covers:c.array(c.string()).optional().describe("recommend ids a placed test covers"),repro:c.boolean().optional().describe("this test is MEANT to fail \u2014 it reproduces a reported bug"),finding:c.boolean().optional().describe("a non-repro test that failed on a REAL product bug"),placementBroken:c.boolean().optional().describe('placement/harness problem one repair could not fix \u2014 every reran.tests entry is then "skip"'),keptReason:An.optional().describe("why a planned delete/regenerate was declined and the file kept"),isolatedRun:An.optional().describe('only for a test marked "runs alone": the command, from its checkout root and without a shell, that runs only this file and writes its JUnit XML into $SKYRAMP_RESULTS_DIR (named by its path: no shell expands it) \u2014 the harness runs it, so leave reran.exit null'),reran:rv,assertionCount:c.number().int().nonnegative().optional().describe("[derived] assertions reachable from the file, counted at write time")}).refine(e=>e.action!=="place"||typeof e.from=="string"&&e.from.trim().length>0,{message:'is a place but has no "from" staged path',path:[]}),iv=(n=>(n.Junit="junit",n.Converter="converter",n))(iv||{}),Sq=An.optional().describe("the items[].file this test is in \u2014 needed only when two of this suite's files cover the same case id"),kq=c.object({results:An.describe("the JUnit XML file this run wrote, a plain file name inside $SKYRAMP_RESULTS_DIR (e.g. backend.xml)"),source:c.nativeEnum(iv),run:An.describe("the command you ran that wrote it, exactly as you ran it (with any converter)"),files:c.array(An).min(1).describe("the items[].file paths this run covered"),cases:c.array(c.object({test:An.describe("the test's name as the runner reports it, qualified by its class or file (e.g. tests/test_a.py::test_x) when the bare name repeats"),case:An.describe("the covers id it realizes"),file:Sq})).describe("map each reported test name to the case it covers")}),vq=c.object({suites:c.array(kq).min(1)}),Kf=c.object({schemaVersion:c.literal(1),items:c.array(sv),runnerResults:vq.optional().describe("the JUnit XML your test runs wrote into $SKYRAMP_RESULTS_DIR, so the harness reads each test's result from the runner \u2014 omit only when no SUT is available"),ignored:c.array(c.string()).describe("existing tests assessed and deliberately left untouched"),summary:An.describe("one paragraph")});var Tl=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Tl||{}),ri=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(ri||{}),si=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(si||{}),Xf=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(Xf||{}),em=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(em||{}),qn=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(qn||{}),ke=c.string().trim().min(1),Ro=ke.describe("file:line"),ov=o(e=>ke.refine(t=>t.length<=400,t=>({message:`is ${t.length} characters, over the 400 cap \u2014 ${e}`})),"cap400"),wc=ke.optional().describe('multi-repo only: the OTHER checkout this lives in \u2014 its "owner/repo" slug, or the directory name if the run discovered it; omit for the working checkout'),Zf=c.object({method:ke,path:ke,service:c.string().optional(),evidence:Ro,repository:wc}),xq=c.object({id:ke.describe("short-slug, e.g. R9"),statement:ke.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:c.nativeEnum(qn).describe("spec outranks pr-description when both state it"),evidence:ke.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),Tq=c.object({id:ke.describe("short-slug"),statement:ke.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:ke.describe("METHOD /path, or a component/page name"),evidence:ke.describe("file:line from the diff that introduces it"),repository:wc,satisfies:c.array(ke).optional().describe("requirement ids (from `requirements`) this behaviour correctly implements \u2014 a requirement met only in part is ALSO named by the finding that shows the rest (conflictsWith)")}),Dq=c.object({id:ke.describe("short-slug"),file:ke,line:c.number().optional(),claim:ov("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:c.nativeEnum(ri),evidence:ov("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:c.nativeEnum(si),repository:wc,conflictsWith:c.array(ke).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),Nq=c.object({name:ke,language:c.string().optional(),framework:c.string().optional(),evidence:Ro,repository:wc}),Fq=c.object({dir:ke,framework:c.string().optional(),kind:c.nativeEnum(Xf),evidence:Ro,repository:wc}),Mq=c.object({from:ke,to:ke,onDelete:c.nativeEnum(em),evidence:Ro}),Uq=c.object({entity:ke,field:ke,values:c.array(c.string()),evidence:Ro}),Lq=c.object({entities:c.array(c.object({name:ke,evidence:Ro})),references:c.array(Mq).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:c.array(Uq)}),tm=c.object({schemaVersion:c.literal(1),repository:c.object({path:ke.describe("absolute repo path"),currentBranch:ke,baseBranch:ke}),project:c.object({type:c.nativeEnum(Tl),primaryLanguage:ke,languages:c.array(c.string()),frameworks:c.array(c.string())}),services:c.array(Nq),infrastructure:c.object({containerized:c.boolean(),hasDockerCompose:c.boolean(),composeFiles:c.array(c.string()),hasCiCd:c.boolean()}),diff:c.object({changedFiles:c.array(c.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:c.boolean(),summary:ke.describe("\u2264400 chars")}),endpoints:c.object({new:c.array(Zf),modified:c.array(Zf),removed:c.array(Zf)}),existingTests:c.object({locations:c.array(Fq)}),entityMap:Lq,requirements:c.array(xq).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:c.array(Tq),findings:c.array(Dq),unexamined:c.array(c.string()).describe("files or areas outside this change you did not open"),summary:ke.describe("one paragraph on what this change does and its test-relevant risk")});var Dl=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(Dl||{}),mr=c.string().trim().min(1),_q=c.object({case:mr.describe("recommend id this assertion enforces"),evidence:mr.describe("the exact assertion line from the file that checks that case's observable")}),nm=c.object({kind:c.nativeEnum(Al).describe("seed: data the test creates in the app; runtime_mock: a mock on a Skyramp worker, which other tests reach too; env_override: an env value the app runs with. A stub inside the test's own process, such as a browser page's route, is none of these"),target:mr.describe("the dependency, endpoint or data it affects"),mechanism:c.nativeEnum(ul).describe("test_code: the test applies and undoes it; skyramp_mocker: a mock the test applies on a Skyramp worker; recipe_override: the mocker cannot reach the dependency (its URL is fixed in the build)"),detail:mr.describe("what it sets up"),worker:mr.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:mr.optional().describe("seed: a command that removes the data when the test does not, run as written and without a shell: give real values, not a placeholder such as <id>, single-quote an argument that holds shell syntax, or put the logic in a script in the repository and run that")}),Pq=c.object({file:mr.describe("staged path under .skyramp/staged/"),source:c.nativeEnum(Dl),language:mr,covers:c.array(c.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:c.array(_q).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:c.array(nm).optional().describe("what the test sets up against the running app, in order: data it seeds, Skyramp mocks it applies, env overrides; omit when none")}),rm=c.object({schemaVersion:c.literal(1),tests:c.array(Pq),deferredUi:c.array(c.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:mr.describe("one paragraph")});var Er=c.string().trim().min(1),bc=72,$q=c.object({repository:Er.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:c.string(),command:c.string().describe("the exact command you ran, scoped to the changed files"),clean:c.boolean(),fixed:c.array(c.string()).optional().describe("files you fixed"),uncovered:c.array(c.string()).describe("changed/new files this linter's own config does not match (wrong extension, wrong directory) \u2014 so `clean` never examined them, even though CI may still execute them. Empty array, not omitted, when every changed/new file IS covered.")}),W5=c.object({schemaVersion:c.literal(1),lint:c.array($q).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:c.object({ok:c.boolean(),notes:c.string().optional()}),ciReadiness:c.object({covered:c.boolean().describe("will the repo's CI run these tests?"),notes:c.string().optional()}),dependencies:c.object({added:c.array(c.object({package:c.string(),manifest:c.string(),repository:Er.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:Er.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")})).describe("every package added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own")}),support:c.array(c.object({file:Er,repository:Er.optional().describe("owner/repo of the file's checkout; omit for the working checkout")})).optional().describe("the files the tests need besides themselves (helper modules, page objects, fixtures, snapshots), delivered with them"),commit:c.object({message:Er.refine(e=>e.split(`
|
|
90
90
|
`)[0].length<=bc,{message:`subject line must be <= ${bc} chars`})}),pr:c.object({title:Er.max(bc,`must be <= ${bc} chars`),body:Er}),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:Er.describe("one paragraph")});var es=fe(require("fs")),vo=fe(require("path")),pv=require("child_process");var ln="{junit}",Nl=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(Nl||{}),sm=(t=>(t.Minitest="minitest",t))(sm||{}),av=c.string().trim().min(1),So=c.object({cwd:av.describe('repo-relative directory the command starts in ("." for the root)'),argv:c.array(av).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${ln}, 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(Nl).describe(`junit (JUnit XML to ${ln}), trx (to ${ln}), or go-test-json (go test -json on the command's output)`),reporter:c.nativeEnum(sm).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 ko="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)",X5=`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 ${ln} in the reporter's argument or env setting), trx (a TRX file to ${ln}, 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 ${ln}: 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 ${ln} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${ln} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${ln} in argv and env with its report path, executes the command, and reads that report.`;var ii=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(ii||{}),Xr=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(Xr||{}),im=(n=>(n.Repository="repository",n.Testbot="testbot",n))(im||{}),om=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(om||{}),Dt=c.string().trim().min(1),Oq=c.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var Gq=c.object({id:Oq,source:c.nativeEnum(im),kind:c.nativeEnum(Jr),outcome:c.nativeEnum(om),summary:Dt.max(400).describe("one line: what it shows"),tests:c.array(Dt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:Dt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:Dt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:So.optional().describe(`source repository, for tests in ${ko}: 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`)}),Vq=c.object({behaviorId:Dt.describe("an id from analyze's behaviors"),mechanism:c.nativeEnum(Xr),evidenceIds:c.array(Dt).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')}),am=(r=>(r.Browser="browser",r.RunningApp="running-app",r.Outside="outside",r))(am||{}),Hq=c.object({behaviorId:c.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:Dt.max(600).describe("the evidence that is required and cannot be obtained in this run"),needs:c.nativeEnum(am).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)")}),qq=c.object({file:Dt.describe("the changed file the failure is in"),repository:Dt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:Dt.max(300).describe("what prerequisite the change fails"),evidence:Dt.max(400).describe("the error line, quoted")}),jq=c.object({behaviorId:Dt.describe("an id from analyze's behaviors"),reason:Dt.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)")}),Rc=c.object({schemaVersion:c.literal(1),decision:c.nativeEnum(ii),evidence:c.array(Gq).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:c.array(Vq).describe("how each changed behavior's evidence is obtained"),gaps:c.array(Hq),outOfScope:c.array(jq).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:qq.optional().describe("only for blocked_preflight"),rationale:Dt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function Fl(e){let t=Pe(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(Fl,"readRecommend");var oi=fe(require("fs"));function cv(e){let t=[];for(let n of zq(e)){let r=n;r?.type==="tool_use"&&typeof r.name=="string"&&t.push(r.name)}return t}o(cv,"toolUsesFromTrace");function Av(e){return cv(e).some(t=>/^mcp__skyramp__skyramp_(contract|integration)_test_generation$/.test(t))}o(Av,"usedSkyrampCodegen");function uv(e){return cv(e).some(t=>t==="mcp__skyramp__skyramp_ui_test_generation")}o(uv,"usedSkyrampUiCodegen");function Wq(e){if(!oi.existsSync(e))return{};for(let t of oi.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(Wq,"mcpServerStatuses");function lv(e){let t=Wq(e).skyramp;return t===void 0||t==="connected"}o(lv,"skyrampConnected");function zq(e){if(!oi.existsSync(e))return[];let t=[];for(let n of oi.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(zq,"contentBlocks");function Zq(e){return Yt(rm,e).errors}o(Zq,"validateGenerateOutput");function Xq(e,t=[]){let{value:n,error:r}=ct(e,t);if(r)return{errors:[r]};let s=Zq(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}o(Xq,"parseGenerateText");function Ml(e,t=[]){return Xq(e.stdout,t)}o(Ml,"parseGenerateFromSession");function ej(e){return e.generate.filter(t=>t.type!=="ui").map(t=>t.id)}o(ej,"backendCases");function gv(e){return e.generate.filter(t=>t.type==="ui").map(t=>t.id)}o(gv,"uiCases");var Ul={backend:{stage:"generate",cases:ej,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:Av,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:gv,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:uv,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."}},LX=cn("generate-schema",(e,t)=>Ml(t,e.secretValues));function tj(e){let t=Ul[e];return{name:`${t.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=Ml(r,n.secretValues);if(!s)return ht(this.name,i);let a=Fl(n);if(!a)return ht(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(gv(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}:ht(this.name,u)}}}o(tj,"generateCoverageGateFor");function nj(e){let t=Ul[e];return{name:`${t.stage}-intent`,verify(n,r){let{generate:s,errors:i}=Ml(r,n.secretValues);if(!s)return ht(this.name,i);let a=Fl(n);if(!a)return ht(this.name,[t.noRecommendIntent]);let{asserted:A,errors:u,badFiles:d}=Aj(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=ht(this.name,u);return p>0&&p===u.length&&d.size>0?{...g,droppable:[...d]}:g}}}o(nj,"generateIntentGateFor");function rj(e){let t=Ul[e];return n=>{if(!n.inputs.skyrampMcp?.command||e==="backend"&&!Wf(n))return;let r=vo.join(n.outputsDir,`${t.stage}-stream.ndjson`);if(!(!es.existsSync(r)||t.usedCodegen(r)))return lv(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(rj,"codegenRetryHintFor");var _X=tj("backend"),PX=nj("backend"),$X=rj("backend");var dv=o(e=>e.replace(/\s+/g,""),"squeeze");var cm={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"]])cm[e]=cm[t];function sj(e,t){if(e.includes(gc(t))||dv(e).includes(dv(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(gc(r)))?!0:cj(e,t)}o(sj,"evidenceFound");var ij=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,oj=12,aj=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function cj(e,t){let n=t.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=ij.exec(s);if(!i)continue;let a=s.slice(i.index),A=aj.exec(a);if(A&&(a=a.slice(0,A.index)),a=gc(a).replace(/[,\s]+$/,""),a.length<oj||!e.includes(a))return!1;r++}return r>0}o(cj,"annotatedAssertionFound");function Aj(e,t){let n=new Set,r=[],s=new Set;for(let i of e.tests){let a=vo.resolve(t,i.file);if(!es.existsSync(a))continue;let A=gc(es.readFileSync(a,"utf-8"));for(let u of i.assertions??[]){if(!sj(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(Aj,"verifiedAssertions");var uj=/\.(spec|test)\.[cm]?[jt]sx?$/i;function hv(e){let t;try{t=(0,pv.execFileSync)("git",[...Kr,"status","--porcelain","--untracked-files=all"],{env:Jt(),cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=o(s=>/_scaffold/i.test(s)||wl.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(hv,"testLitter");function lj(e){let t=Ul[e],n=e==="ui";return{name:`${t.stage}-no-litter`,verify(r){let s=hv(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>uj.test(a)===n);return i.length===0?{name:this.name,passed:!0}:ht(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(lj,"noLitterGateFor");var OX=lj("backend");var Sc=fe(require("fs")),ai=fe(require("path"));var n6=10*6e4;function Ev(e){return Yt(Kf,e).errors}o(Ev,"validateAdaptOutput");function Ej(e,t=[]){let{value:n,error:r}=ct(e,t);if(r)return{errors:[r]};let s=Ev(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(Ej,"parseAdaptText");var yj="adapt-scratch",mv=`${yj}/adapt-result.json`;function yv(e,t){let n=ai.join(e.outputsDir,mv),r;try{r=Sc.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(e.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${mv} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Ej(t.stdout,e.secretValues);if(s.adapt)return s;let i=r!==void 0?Zs(n):void 0;return i!==void 0&&Ev(i).length===0?{adapt:i,errors:[]}:s}o(yv,"parseAdaptFromSession");var w6=cn("adapt-schema",yv);var Cv=require("child_process");function Iv(e){return Cj(e)??[]}o(Iv,"statusEntries");function Cj(e){let t;try{t=(0,Cv.execFileSync)("git",[...Kr,"status","--porcelain","-z","--untracked-files=all"],{env:Jt(),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(Cj,"readStatusEntries");var F6=2*1024*1024;var _l=c.string().trim().min(1),Ij=c.object({cwd:_l.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:c.array(_l).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")}),Bj=c.object({file:_l.describe("a file of the test's checkout, relative to its root"),line:_l.describe("a line of that file, quoted exactly from where its command starts to its end")}),Bv=c.object({collected:c.boolean().describe("whether the repo's CI runs this test as it is"),steps:c.array(Bj).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:Ij.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 Rj=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")}),kc=(n=>(n.InProcess="in-process",n.Browser="browser",n))(kc||{}),Qv=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(Qv||{}),wv=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(Rj).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(kc).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(Qv).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")}),Pl=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 j6=["stale_test","open_question"],J6=["low","medium","high","critical"];var re=c.string().trim().min(1),Tj=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"),Dj=c.preprocess(Tj,c.object({id:re.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:re.describe("one testable part of the requirement"),expected:re.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(zr).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; in another repo of the change, that repo's directory name then its path"),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)")})),bv=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:re.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`}),Nj=c.object({id:re.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:re,source:c.nativeEnum(qn).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:re.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(bv).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(Dj)}),Rv=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(Rv||{}),Fj=c.object({id:re.describe('e.g. "F1"'),file:re,line:c.number().optional(),claim:re.describe("the defect, in one sentence"),severity:c.nativeEnum(ri),evidence:re.describe("the code line, or the probe request and response, that shows it"),conflictsWith:c.array(re).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(Rv).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)")}),Mj=c.object({id:re.describe('e.g. "Q1"'),question:re.describe("what is unsettled, as a question the PR author can answer"),readings:c.array(re).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(bv).optional().describe("when sources of the same rank disagree on it: each of them")}),Uj=c.object({id:re.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:c.nativeEnum(zr).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:re.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:re.describe("what the test does"),expected:re.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")}),Lj=c.object({test:re.describe("existing test file"),action:c.nativeEnum(gr),reason:re,mutates:c.boolean().optional().describe("true when the maintained test changes state"),clauses:c.array(re).optional().describe("the clause ids this test checks")}),_j=c.object({outcome:c.nativeEnum(lr).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:re,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:Yh.optional()}),w7=c.object({schemaVersion:c.literal(1),requirements:c.array(Nj),findings:c.array(Fj),cases:c.array(Uj).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:c.array(Mj).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:c.array(Lj),journeys:c.array(wv).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:re,why:re})).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"),unplannedComponents:c.array(c.object({components:c.array(re).min(1).describe("changed components, as the change lists them"),why:re})).optional().describe("changed components no clause reaches, and why their change needs no test; several may share one reason"),triage:Rc.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:_j.optional().describe("omit when no app was needed or none was started"),summary:re.describe("one paragraph: what the change does and where the risk is")});var Sv=(n=>(n.Backend="backend",n.Ui="ui",n))(Sv||{});var vc=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(vc||{}),Pj=c.object({file:re.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:c.nativeEnum(Sv),change:c.nativeEnum(vc).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:re.describe("the requirement or clause id the change deliberately alters"),line:re.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:re,status:c.nativeEnum(un),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:re,evidence:re})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:c.array(c.object({name:re.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(re).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(nm).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:re.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:Bv.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:So.optional().describe(`for a file in ${ko}, 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 ${ln}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),$j=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"),Oj=c.preprocess($j,c.object({description:re.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:c.nativeEnum(ri).optional(),sourceFile:c.string().optional().describe("the app file at fault"),sourceLine:c.number().optional(),tests:c.array(re).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(re).optional().describe("the plan's requirement or clause ids it violates")})),b7=c.object({schemaVersion:c.literal(1),tests:c.array(Pj),notWritten:c.array(c.object({case:re,reason:re})).describe("every plan case no test covers, and why"),journeys:c.array(Pl).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:re,manifest:re.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:re.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:re.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(re).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:re.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:re.describe("at most 72 characters"),prBody:re.describe("what the tests cover and what they found")}),report:c.object({summary:re.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:c.array(Oj).describe("every defect the tests found"),nextSteps:c.array(c.string())})});var R7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var vv=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(vv||{}),At=c.string().trim().min(1),Gj=c.object({expectation:At.max(300).describe("the behavior this assertion pins, in words"),source:c.nativeEnum(vv),expected:At.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),Vj=c.object({file:At.describe("path of the NEW test file you wrote, relative to its repository"),repository:At.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:At.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:So.optional().describe(`for ${ko}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:c.array(At).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(At).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:c.array(Gj).min(1)}),$l=(n=>(n.Updated="updated",n.Deleted="deleted",n))($l||{}),kv=300,Hj=c.object({file:At.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:At.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:c.nativeEnum($l),staleBecause:c.object({requirement:At.describe("the requirement or clause id the change deliberately alters"),line:At.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,kv):e,At.max(kv)).describe("what the change deliberately altered that made the test wrong")}),um=c.object({schemaVersion:c.literal(1),tests:c.array(Vj),maintained:c.array(Hj).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:c.array(c.object({id:At,reason:At.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(Pl).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:c.array(c.object({journey:At,missing:At.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:At.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var Gl="generate-unit.json";function Jj(e){let{value:t,error:n}=ct(e);if(n)return{errors:[n]};let{value:r,errors:s}=Yt(um,t);return s.length?{errors:s}:{output:r,errors:[]}}o(Jj,"parseGenerateUnitText");function Yj(e){return Jj(e.stdout)}o(Yj,"parseGenerateUnitFromSession");var gee=cn("generate-unit-schema",(e,t)=>Yj(t));var Ol=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,hee=[[/\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+["']${Ol}["']|\bimport\s+["']${Ol}["']|require\(\s*["']${Ol}["']\s*\)|\bimport\(\s*["']${Ol}["']\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 Uee=new Set(["targeted_unit","existing_evidence_sufficient"]);var Xj="triage.json";var Rte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),Ste={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 eJ(e){let{value:t,error:n}=ct(e);if(n)return{errors:[n]};let{value:r,errors:s}=Yt(Rc,t);return s.length?{errors:s}:{triage:r,errors:[]}}o(eJ,"parseTriageText");function tJ(e){return eJ(e.stdout)}o(tJ,"parseTriageFromSession");var kte=cn("triage-schema",(e,t)=>tJ(t));function nJ(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(nJ,"triageDecider");function lm(e){if(nJ(e)?.status==="passed")return Zs(xc.join(e.outputsDir,Xj))}o(lm,"readTriage");function dm(e){return KS(ff(e.inputs,Pe(e,`${yc}.json`),lm(e)?.sutRequired))}o(dm,"revisionBlockReason");var vte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var ss=fe(require("fs")),rs=fe(require("path")),hx=require("child_process");var pm=require("child_process"),xo=fe(require("fs")),Fv=fe(require("os")),ql=fe(require("path"));var rJ={onPath:o(e=>(0,pm.spawnSync)("sh",["-c",`command -v ${e}`],{stdio:"ignore"}).status===0,"onPath"),run:o((e,t)=>(0,pm.spawnSync)(e[0],e.slice(1),{cwd:t,stdio:"ignore",timeout:6e4}).status??1,"run")},Hl={cleanup:o(()=>{},"cleanup")},sJ=new Set(["pnpm","yarn"]);function Mv(e,t=Fv.tmpdir(),n=rJ){if(process.platform==="win32")return Hl;try{let r=Hf(e);if(!sJ.has(r)||n.onPath(r)||!n.onPath("corepack"))return Hl;xo.mkdirSync(t,{recursive:!0});let s=xo.mkdtempSync(ql.join(t,"testbot-pm-")),i=o(()=>xo.rmSync(s,{recursive:!0,force:!0}),"cleanup");return n.run(["corepack","enable","--install-directory",s,r],e)!==0?(i(),Hl):{dir:s,cleanup:i}}catch{return Hl}}o(Mv,"packageManagerShims");function Uv(e,t=process.env){return e.dir?{...t,PATH:[e.dir,t.PATH].filter(Boolean).join(ql.delimiter)}:t}o(Uv,"withShims");var Wl=require("crypto");var Vte=[...df,"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 Xte=process.env.RUNNER_TOOL_CACHE||"/opt/hostedtoolcache";var lne={jest:"jest",vitest:"vitest"};var nre=5*6e4;function oJ(e){return Yt(tm,e).errors}o(oJ,"validateAnalysisOutput");function $v(e,t=[]){let{value:n,error:r}=ct(e,t);if(r)return{errors:[r]};let s=oJ(n);return s.length>0?{errors:s}:{analysis:n,errors:[]}}o($v,"parseAnalysisText");function aJ(e,t=[]){return $v(e.stdout,t)}o(aJ,"parseAnalysisFromSession");var Ore=cn("analysis-schema",(e,t)=>aJ(t,e.secretValues));var $se=Wu.rows.notRun(!0);var Tc="kept, not ",Dc="(declined the planned ";function gm(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(gm,"assertionParts");var Ov=new Set(["update","regenerate","delete"]);var Ose={update:"updated",regenerate:"regenerated",delete:"deleted",verify:"verified",none:"touched"};var Gv=c.string().trim().min(1),hm=c.object({schemaVersion:c.literal(1).optional(),businessCaseAnalysis:Gv.describe("1-2 sentences: what this change means for a user, and whether the evidence shows it working"),issuesFound:c.array(c.object({description:Gv,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 uJ(e){return Yt(hm,e).errors}o(uJ,"validateProseOutput");function lJ(e,t=[]){let{value:n,error:r}=ct(e.stdout,t);if(r)return{errors:[r]};let s=uJ(n);return s.length>0?{errors:s}:{prose:n,errors:[]}}o(lJ,"parseProseFromSession");var tie=cn("report-schema",(e,t)=>lJ(t,e.secretValues));var dJ="<!-- skyramp-testbot -->",Vv=Ov,pJ=new Set(["lint","type","config"]),Hv={critical:0,high:1,medium:2,low:3},zv=new Set(["Pass","Fail"]);var mm=o(e=>Ns(ee().statusLabels,e),"statusLabel"),fm=o(e=>Ns(ee().testTypeCellLabels,e),"testTypeLabel");function Qe(e){return(e??"").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>").trim()}o(Qe,"escCell");function qv(e,t){return!e||!zv.has(e)?"\u2014":t?`${mm(e)} (${Qe(Kv(t))})`:mm(e)}o(qv,"maintStatus");function Kv(e){let t=o(r=>{let s=r.indexOf(": ");return s<0?r:Ns(ee().staged.maintenanceActions,r.slice(0,s))+r.slice(s)},"action");if(e.startsWith(Tc))return ee().staged.keptNot+t(e.slice(Tc.length));let n=e.indexOf(Dc);return n<0?e:e.slice(0,n)+ee().staged.declinedPlanned+t(e.slice(n+Dc.length))}o(Kv,"declineNote");function jv(e){return e.category!==void 0&&pJ.has(e.category.toLowerCase())}o(jv,"isTooling");function Jv(e,t){return(Hv[(e.severity??"").toLowerCase()]??4)-(Hv[(t.severity??"").toLowerCase()]??4)}o(Jv,"bySeverity");function Yv(e){return`- ${e.severity?`**[${Ns(ee().severityLabels,e.severity.toLowerCase()).toUpperCase()}]** `:""}${e.description.trim()}`}o(Yv,"issueLine");function gJ(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(gJ,"unitTestOf");var Zv=o((e,t)=>e!==void 0&&t!==void 0&&e.replace(/^\.\//,"")===t.replace(/^\.\//,""),"samePath");function Xv(e,t){return(e.testVideos??[]).find(n=>n.url&&t(n))?.url}o(Xv,"videoLink");function Em(e,t){return Xv(e,n=>Zv(n.fileName,t.fileName)&&(!n.repository||!t.repository||n.repository.toLowerCase()===t.repository.toLowerCase()))}o(Em,"resultVideoLink");function ym(e,t){return Xv(e,n=>Zv(n.writtenAs??n.fileName,t))}o(ym,"journeyVideoLink");function hJ(e,t,n){return n?Em(e,{fileName:t,repository:n}):ym(e,t)}o(hJ,"requirementVideoLink");function fJ(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&&ev(A,u)),"parentOf"),i=new Map;for(let a of e.testResults){let A=gJ(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(fJ,"resultRows");function mJ(e){return gm(e).map(t=>t.expected===void 0?t.expectation:`${t.expectation}: ${ts(t.expected)}`)}o(mJ,"unitAssertions");function ts(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(ts,"codeSpan");function Wv(e){return e.newTestsCreated.some(t=>t.testType!=="unit")&&e.testResults.every(t=>t.status==="Skipped")}o(Wv,"nothingExecuted");function ex(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=[dJ];if(a&&p.push(ee().staged.testsSourcePullRequest(ts(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(Ns(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(Wv(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 Y=(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 le=H.description?.trim()??"",Fe=P.descriptions.get(Y)??[];Fe.includes(le)||Fe.push(le),P.functions.add(Y),P.descriptions.set(Y,Fe),Q.set(H.fileName,P)}let x=e.newTestsCreated.filter(H=>H.testType!=="unit"),F=x.length+[...Q.values()].reduce((H,Y)=>H+Y.functions.size,0);g(ee().testRecommendationsImplementedHeader(F));for(let[H,{functions:Y,endpoints:P,descriptions:le}]of Q){let Fe=Y.size;p.push(ee().staged.unitTestsInFile(`\`${H}\``,Fe,P.map(xe=>`\`${xe}\``).join(", ")),"");let Re=new Map;for(let[xe,Ce]of le){let Ye=Ce.join("\0"),$=Re.get(Ye)??{fns:[],descriptions:Ce};$.fns.push(xe),Re.set(Ye,$)}let ve=0;for(let{fns:xe,descriptions:Ce}of Re.values()){p.push(`${++ve}. ${xe.map($=>`\`${$}\``).join(", ")}`);let Ye=[...new Set(Ce.flatMap($=>mJ($)))];for(let $ of Ye)p.push(` - ${$}`)}p.push("")}for(let H of x){let Y=H.testId?`\`${H.testId}\``:fm(H.testType),P=H.fileName?` (\`${H.fileName}\`)`:"",le=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(hv,"testLitter");function lj(e){let t=Ul[e],n=e==="ui";return{name:`${t.stage}-no-litter`,verify(r){let s=hv(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>uj.test(a)===n);return i.length===0?{name:this.name,passed:!0}:ht(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(lj,"noLitterGateFor");var OX=lj("backend");var Sc=fe(require("fs")),ai=fe(require("path"));var n6=10*6e4;function Ev(e){return Yt(Kf,e).errors}o(Ev,"validateAdaptOutput");function Ej(e,t=[]){let{value:n,error:r}=ct(e,t);if(r)return{errors:[r]};let s=Ev(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(Ej,"parseAdaptText");var yj="adapt-scratch",mv=`${yj}/adapt-result.json`;function yv(e,t){let n=ai.join(e.outputsDir,mv),r;try{r=Sc.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(e.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${mv} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Ej(t.stdout,e.secretValues);if(s.adapt)return s;let i=r!==void 0?Zs(n):void 0;return i!==void 0&&Ev(i).length===0?{adapt:i,errors:[]}:s}o(yv,"parseAdaptFromSession");var w6=cn("adapt-schema",yv);var Cv=require("child_process");function Iv(e){return Cj(e)??[]}o(Iv,"statusEntries");function Cj(e){let t;try{t=(0,Cv.execFileSync)("git",[...Kr,"status","--porcelain","-z","--untracked-files=all"],{env:Jt(),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(Cj,"readStatusEntries");var F6=2*1024*1024;var _l=c.string().trim().min(1),Ij=c.object({cwd:_l.describe(`directory the command starts in, relative to the test's checkout ("." for its root)`),argv:c.array(_l).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")}),Bj=c.object({file:_l.describe("a file of the test's checkout, relative to its root"),line:_l.describe("a line of that file, quoted exactly from where its command starts to its end")}),Bv=c.object({collected:c.boolean().describe("whether the repo's CI runs this test as it is"),steps:c.array(Bj).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:Ij.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 Rj=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")}),kc=(n=>(n.InProcess="in-process",n.Browser="browser",n))(kc||{}),Qv=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(Qv||{}),wv=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(Rj).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(kc).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(Qv).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")}),Pl=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 j6=["stale_test","open_question"],J6=["low","medium","high","critical"];var re=c.string().trim().min(1),Tj=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"),Dj=c.preprocess(Tj,c.object({id:re.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:re.describe("one testable part of the requirement"),expected:re.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(zr).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; in another repo of the change, that repo's directory name then its path"),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)")})),bv=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:re.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`}),Nj=c.object({id:re.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:re,source:c.nativeEnum(qn).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:re.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(bv).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(Dj)}),Rv=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(Rv||{}),Fj=c.object({id:re.describe('e.g. "F1"'),file:re,line:c.number().optional(),claim:re.describe("the defect, in one sentence"),severity:c.nativeEnum(ri),evidence:re.describe("the code line, or the probe request and response, that shows it"),conflictsWith:c.array(re).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(Rv).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)")}),Mj=c.object({id:re.describe('e.g. "Q1"'),question:re.describe("what is unsettled, as a question the PR author can answer"),readings:c.array(re).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(bv).optional().describe("when sources of the same rank disagree on it: each of them")}),Uj=c.object({id:re.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:c.nativeEnum(zr).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:re.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:re.describe("what the test does"),expected:re.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")}),Lj=c.object({test:re.describe("existing test file"),action:c.nativeEnum(gr),reason:re,mutates:c.boolean().optional().describe("true when the maintained test changes state"),clauses:c.array(re).optional().describe("the clause ids this test checks")}),_j=c.object({outcome:c.nativeEnum(lr).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:re,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:Yh.optional()}),w7=c.object({schemaVersion:c.literal(1),requirements:c.array(Nj),findings:c.array(Fj),cases:c.array(Uj).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:c.array(Mj).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:c.array(Lj),journeys:c.array(wv).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:re,why:re})).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"),unplannedComponents:c.array(c.object({components:c.array(re).min(1).describe("changed components, as the change lists them"),why:re})).optional().describe("changed components no clause reaches, and why their change needs no test; several may share one reason"),triage:Rc.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:_j.optional().describe("omit when no app was needed or none was started"),summary:re.describe("one paragraph: what the change does and where the risk is")});var Sv=(n=>(n.Backend="backend",n.Ui="ui",n))(Sv||{});var vc=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(vc||{}),Pj=c.object({file:re.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:c.nativeEnum(Sv),change:c.nativeEnum(vc).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, each with its own result under result.cases"),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:re.describe("the requirement or clause id the change deliberately alters"),line:re.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:re,status:c.nativeEnum(un),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:re,evidence:re})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:c.array(c.object({name:re.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(re).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(nm).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:re.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:Bv.optional().describe("for a file you added or updated: whether the repo's CI will run it, and how you know"),run:So.optional().describe(`for a file in ${ko}, 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 ${ln}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),$j=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"),Oj=c.preprocess($j,c.object({description:re.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:c.nativeEnum(ri).optional(),sourceFile:c.string().optional().describe("the app file at fault"),sourceLine:c.number().optional(),tests:c.array(re).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(re).optional().describe("the plan's requirement or clause ids it violates")})),b7=c.object({schemaVersion:c.literal(1),tests:c.array(Pj),notWritten:c.array(c.object({case:re,reason:re})).describe("every plan case no test covers, and why"),journeys:c.array(Pl).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:re,manifest:re.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:re.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:re.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(re).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:re.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:re.describe("at most 72 characters"),prBody:re.describe("what the tests cover and what they found")}),report:c.object({summary:re.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:c.array(Oj).describe("every defect the tests found"),nextSteps:c.array(c.string())})});var R7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var vv=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(vv||{}),At=c.string().trim().min(1),Gj=c.object({expectation:At.max(300).describe("the behavior this assertion pins, in words"),source:c.nativeEnum(vv),expected:At.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),Vj=c.object({file:At.describe("path of the NEW test file you wrote, relative to its repository"),repository:At.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:At.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:So.optional().describe(`for ${ko}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:c.array(At).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(At).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:c.array(Gj).min(1)}),$l=(n=>(n.Updated="updated",n.Deleted="deleted",n))($l||{}),kv=300,Hj=c.object({file:At.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:At.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:c.nativeEnum($l),staleBecause:c.object({requirement:At.describe("the requirement or clause id the change deliberately alters"),line:At.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,kv):e,At.max(kv)).describe("what the change deliberately altered that made the test wrong")}),um=c.object({schemaVersion:c.literal(1),tests:c.array(Vj),maintained:c.array(Hj).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:c.array(c.object({id:At,reason:At.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(Pl).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:c.array(c.object({journey:At,missing:At.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:At.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var Gl="generate-unit.json";function Jj(e){let{value:t,error:n}=ct(e);if(n)return{errors:[n]};let{value:r,errors:s}=Yt(um,t);return s.length?{errors:s}:{output:r,errors:[]}}o(Jj,"parseGenerateUnitText");function Yj(e){return Jj(e.stdout)}o(Yj,"parseGenerateUnitFromSession");var gee=cn("generate-unit-schema",(e,t)=>Yj(t));var Ol=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,hee=[[/\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+["']${Ol}["']|\bimport\s+["']${Ol}["']|require\(\s*["']${Ol}["']\s*\)|\bimport\(\s*["']${Ol}["']\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 Uee=new Set(["targeted_unit","existing_evidence_sufficient"]);var Xj="triage.json";var Rte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),Ste={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 eJ(e){let{value:t,error:n}=ct(e);if(n)return{errors:[n]};let{value:r,errors:s}=Yt(Rc,t);return s.length?{errors:s}:{triage:r,errors:[]}}o(eJ,"parseTriageText");function tJ(e){return eJ(e.stdout)}o(tJ,"parseTriageFromSession");var kte=cn("triage-schema",(e,t)=>tJ(t));function nJ(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(nJ,"triageDecider");function lm(e){if(nJ(e)?.status==="passed")return Zs(xc.join(e.outputsDir,Xj))}o(lm,"readTriage");function dm(e){return KS(ff(e.inputs,Pe(e,`${yc}.json`),lm(e)?.sutRequired))}o(dm,"revisionBlockReason");var vte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var ss=fe(require("fs")),rs=fe(require("path")),hx=require("child_process");var pm=require("child_process"),xo=fe(require("fs")),Fv=fe(require("os")),ql=fe(require("path"));var rJ={onPath:o(e=>(0,pm.spawnSync)("sh",["-c",`command -v ${e}`],{stdio:"ignore"}).status===0,"onPath"),run:o((e,t)=>(0,pm.spawnSync)(e[0],e.slice(1),{cwd:t,stdio:"ignore",timeout:6e4}).status??1,"run")},Hl={cleanup:o(()=>{},"cleanup")},sJ=new Set(["pnpm","yarn"]);function Mv(e,t=Fv.tmpdir(),n=rJ){if(process.platform==="win32")return Hl;try{let r=Hf(e);if(!sJ.has(r)||n.onPath(r)||!n.onPath("corepack"))return Hl;xo.mkdirSync(t,{recursive:!0});let s=xo.mkdtempSync(ql.join(t,"testbot-pm-")),i=o(()=>xo.rmSync(s,{recursive:!0,force:!0}),"cleanup");return n.run(["corepack","enable","--install-directory",s,r],e)!==0?(i(),Hl):{dir:s,cleanup:i}}catch{return Hl}}o(Mv,"packageManagerShims");function Uv(e,t=process.env){return e.dir?{...t,PATH:[e.dir,t.PATH].filter(Boolean).join(ql.delimiter)}:t}o(Uv,"withShims");var Wl=require("crypto");var Vte=[...df,"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 Xte=process.env.RUNNER_TOOL_CACHE||"/opt/hostedtoolcache";var lne={jest:"jest",vitest:"vitest"};var nre=5*6e4;function oJ(e){return Yt(tm,e).errors}o(oJ,"validateAnalysisOutput");function $v(e,t=[]){let{value:n,error:r}=ct(e,t);if(r)return{errors:[r]};let s=oJ(n);return s.length>0?{errors:s}:{analysis:n,errors:[]}}o($v,"parseAnalysisText");function aJ(e,t=[]){return $v(e.stdout,t)}o(aJ,"parseAnalysisFromSession");var Ore=cn("analysis-schema",(e,t)=>aJ(t,e.secretValues));var $se=Wu.rows.notRun(!0);var Tc="kept, not ",Dc="(declined the planned ";function gm(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(gm,"assertionParts");var Ov=new Set(["update","regenerate","delete"]);var Ose={update:"updated",regenerate:"regenerated",delete:"deleted",verify:"verified",none:"touched"};var Gv=c.string().trim().min(1),hm=c.object({schemaVersion:c.literal(1).optional(),businessCaseAnalysis:Gv.describe("1-2 sentences: what this change means for a user, and whether the evidence shows it working"),issuesFound:c.array(c.object({description:Gv,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 uJ(e){return Yt(hm,e).errors}o(uJ,"validateProseOutput");function lJ(e,t=[]){let{value:n,error:r}=ct(e.stdout,t);if(r)return{errors:[r]};let s=uJ(n);return s.length>0?{errors:s}:{prose:n,errors:[]}}o(lJ,"parseProseFromSession");var tie=cn("report-schema",(e,t)=>lJ(t,e.secretValues));var dJ="<!-- skyramp-testbot -->",Vv=Ov,pJ=new Set(["lint","type","config"]),Hv={critical:0,high:1,medium:2,low:3},zv=new Set(["Pass","Fail"]);var mm=o(e=>Ns(ee().statusLabels,e),"statusLabel"),fm=o(e=>Ns(ee().testTypeCellLabels,e),"testTypeLabel");function Qe(e){return(e??"").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>").trim()}o(Qe,"escCell");function qv(e,t){return!e||!zv.has(e)?"\u2014":t?`${mm(e)} (${Qe(Kv(t))})`:mm(e)}o(qv,"maintStatus");function Kv(e){let t=o(r=>{let s=r.indexOf(": ");return s<0?r:Ns(ee().staged.maintenanceActions,r.slice(0,s))+r.slice(s)},"action");if(e.startsWith(Tc))return ee().staged.keptNot+t(e.slice(Tc.length));let n=e.indexOf(Dc);return n<0?e:e.slice(0,n)+ee().staged.declinedPlanned+t(e.slice(n+Dc.length))}o(Kv,"declineNote");function jv(e){return e.category!==void 0&&pJ.has(e.category.toLowerCase())}o(jv,"isTooling");function Jv(e,t){return(Hv[(e.severity??"").toLowerCase()]??4)-(Hv[(t.severity??"").toLowerCase()]??4)}o(Jv,"bySeverity");function Yv(e){return`- ${e.severity?`**[${Ns(ee().severityLabels,e.severity.toLowerCase()).toUpperCase()}]** `:""}${e.description.trim()}`}o(Yv,"issueLine");function gJ(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(gJ,"unitTestOf");var Zv=o((e,t)=>e!==void 0&&t!==void 0&&e.replace(/^\.\//,"")===t.replace(/^\.\//,""),"samePath");function Xv(e,t){return(e.testVideos??[]).find(n=>n.url&&t(n))?.url}o(Xv,"videoLink");function Em(e,t){return Xv(e,n=>Zv(n.fileName,t.fileName)&&(!n.repository||!t.repository||n.repository.toLowerCase()===t.repository.toLowerCase()))}o(Em,"resultVideoLink");function ym(e,t){return Xv(e,n=>Zv(n.writtenAs??n.fileName,t))}o(ym,"journeyVideoLink");function hJ(e,t,n){return n?Em(e,{fileName:t,repository:n}):ym(e,t)}o(hJ,"requirementVideoLink");function fJ(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&&ev(A,u)),"parentOf"),i=new Map;for(let a of e.testResults){let A=gJ(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(fJ,"resultRows");function mJ(e){return gm(e).map(t=>t.expected===void 0?t.expectation:`${t.expectation}: ${ts(t.expected)}`)}o(mJ,"unitAssertions");function ts(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(ts,"codeSpan");function Wv(e){return e.newTestsCreated.some(t=>t.testType!=="unit")&&e.testResults.every(t=>t.status==="Skipped")}o(Wv,"nothingExecuted");function ex(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=[dJ];if(a&&p.push(ee().staged.testsSourcePullRequest(ts(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(Ns(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(Wv(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 Y=(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 le=H.description?.trim()??"",Fe=P.descriptions.get(Y)??[];Fe.includes(le)||Fe.push(le),P.functions.add(Y),P.descriptions.set(Y,Fe),Q.set(H.fileName,P)}let x=e.newTestsCreated.filter(H=>H.testType!=="unit"),F=x.length+[...Q.values()].reduce((H,Y)=>H+Y.functions.size,0);g(ee().testRecommendationsImplementedHeader(F));for(let[H,{functions:Y,endpoints:P,descriptions:le}]of Q){let Fe=Y.size;p.push(ee().staged.unitTestsInFile(`\`${H}\``,Fe,P.map(xe=>`\`${xe}\``).join(", ")),"");let Re=new Map;for(let[xe,Ce]of le){let Ye=Ce.join("\0"),$=Re.get(Ye)??{fns:[],descriptions:Ce};$.fns.push(xe),Re.set(Ye,$)}let ve=0;for(let{fns:xe,descriptions:Ce}of Re.values()){p.push(`${++ve}. ${xe.map($=>`\`${$}\``).join(", ")}`);let Ye=[...new Set(Ce.flatMap($=>mJ($)))];for(let $ of Ye)p.push(` - ${$}`)}p.push("")}for(let H of x){let Y=H.testId?`\`${H.testId}\``:fm(H.testType),P=H.fileName?` (\`${H.fileName}\`)`:"",le=H.endpoint?`
|
|
94
94
|
\`${H.endpoint}\``:"",Fe=H.description?`
|
|
95
95
|
${H.description.trim()}`:"";p.push(`- ${Y}${P}${le}${Fe}`)}f()}let m=(e.testMaintenance??[]).filter(Q=>Vv.has(Q.action));if(u&&m.length){g(ee().staged.testMaintenanceHeader),p.push(ee().maintenanceTableHeader),p.push("|-----------|----------|------|--------|--------|-------|");for(let Q of m)p.push(`| ${Qe(fm(Q.testType))} | ${Qe(Q.endpoint)} | \`${Qe(Q.fileName)}\` | ${Qe(Q.description)} | ${qv(Q.beforeStatus,Q.beforeDetails)} | ${qv(Q.afterStatus,Q.afterDetails)} |`);f()}let E=o(Q=>Q.startsWith(Tc)||Q.includes(Dc),"hasDeclineNote"),I=(e.testMaintenance??[]).filter(Q=>E(Q.afterDetails)&&(!Vv.has(Q.action)||!zv.has(Q.afterStatus??"")));if(u&&I.length){g(ee().staged.declinedMaintenanceHeader);for(let Q of I)p.push(`- \`${Qe(Q.fileName)}\`: ${Qe(Kv(Q.afterDetails))}`);f()}if(u&&s.length){g(ee().staged.existingEvidenceHeader);let Q=new Map;for(let x of s){let F=`${x.check}\0${x.url??""}\0${x.revision??""}`;Q.set(F,[...Q.get(F)??[],x])}for(let[,[x,...F]]of Q){let H=x.url?`[${ts(x.check)}](${x.url})`:ts(x.check);p.push(ee().staged.trustedCheckPassed(H,x.revision?ts(x.revision.slice(0,7)):""),"");for(let Y of[x,...F])p.push(`- ${ts(Y.behavior)}`);p.push("")}f()}if(u&&e.testResults.length){g(ee().staged.testResultsHeader);let Q=fJ(e),x=Q.some(P=>P.test),F=Q.some(P=>Em(e,P)),H=x?ee().staged.unitResultsTableHeader:ee().staged.resultsTableHeader;p.push(F?`${H} ${ee().columnVideo} |`:H),p.push(`${x?"|---------|-----------|----------|------|-------|--------|---------|":"|---------|-----------|----------|--------|---------|"}${F?"-------|":""}`);for(let P of Q){let le=P.details.replace(/(\S+\.(?:py|ts|js|spec\.\w+))/gi,"`$1`"),Fe=P.testId?`\`${Qe(P.testId)}\``:"\u2014",Re=x?` ${P.test?`\`${Qe(P.test)}\``:""} | ${P.cases??""} |`:"",ve=Em(e,P),xe=F?` ${ve?ee().videoDownloadLink(ve):"\u2014"} |`:"";p.push(`| ${Fe} | ${Qe(fm(P.testType))} | ${Qe(P.endpoint)} |${Re} ${Qe(mm(P.status))} | ${Qe(le)} |${xe}`)}let Y=(e.testVideos??[]).find(P=>P.artifactsUrl)?.artifactsUrl;!F&&Y&&p.push("",ee().videosArtifactFallback(Y)),f()}if(e.requirements?.length){let Q=e.requirements.flatMap(P=>P.clauses),x=o(P=>P.status==="Pass"||P.status==="Passed, test not kept","passes"),F=Q.filter(x).length;g(ee().staged.requirementsHeader(F,Q.length));let H=o(P=>Ns(ee().staged.clauseStatuses,P.status),"status"),Y=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((le,Fe)=>{let Re=Fe===0?`**${Qe(P.label)}**${P.statement?` ${Qe(P.statement)}`:""}`:"",ve=`\`${Qe(le.id)}\`${le.text?` ${Qe(le.text)}`:""}`,xe=new Map;for(let $ of le.tests){let lt=$.fileName??$.testId,He=xe.get(lt)??{fns:new Set};for(let Rn of $.functions)He.fns.add(Rn);He.video??=$.fileName?hJ(e,$.fileName,$.repository):void 0,xe.set(lt,He)}let Ce=xe.size?[...xe].map(([$,{fns:lt,video:He}])=>`\`${Qe($)}\`${lt.size?` \u2014 ${[...lt].map(Rn=>`\`${Qe(Rn)}\``).join(", ")}`:""}${He?` ${ee().videoDownloadLink(He)}`:""}`).join("<br>"):"\u2014",Ye=P.source==="could-break"&&le.status==="Pass"?ee().staged.regressionGuard:"";p.push(`| ${Re} | ${ve} | ${Ce} | ${Qe(Y(le)+Ye)} |`)})}else{p.push(ee().staged.requirementsSummaryTableHeader),p.push("|-------------|-----------------|-------------|");for(let P of e.requirements){let le=P.clauses.filter(x).length,Fe=P.clauses.filter(Re=>!x(Re)).map(Re=>`\`${Qe(Re.id)}\` ${Qe(Y(Re))}`);p.push(`| **${Qe(P.label)}**${P.statement?` ${Qe(P.statement)}`:""} | ${le}/${P.clauses.length} | ${Fe.join("<br>")||"\u2014"} |`)}}f()}if(u&&e.changes?.length&&!e.requirements?.length){let Q=e.executionCoverage,x=Q?ee().staged.coverageCaption(Q.generated,Q.modified,Q.verified,Q.executed):"";g(`${ee().staged.behaviourCoverageHeader}${x}`),p.push(ee().staged.coverageTableHeader),p.push("|-----------|--------|-----------|----------------|");for(let F of e.changes){let H=F.testedBy.length?F.testedBy.map(P=>`\`${Qe(P)}\``).join(", "):F.writtenBy.length?ee().staged.writtenNotRun:"\u2014",Y=F.maintainedBy.length?F.maintainedBy.map(P=>`\`${Qe(P)}\``).join(", "):"\u2014";p.push(`| ${Qe(F.text)} | \`${Qe(F.source)}\` | ${H} | ${Y} |`)}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 x=e.userJourneys.some(F=>ym(e,F.fileName));p.push(`| Journey | Test | Status | Notes |${x?` ${ee().columnVideo} |`:""}`),p.push(`|---------|------|--------|-------|${x?"-------|":""}`);for(let F of e.userJourneys){let H=F.fileName?`\`${Qe(F.fileName)}\`${F.test?` \u2014 ${Qe(F.test)}`:""}`:"\u2014",Y=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`)+Y,le=x?ym(e,F.fileName):void 0;p.push(`| ${Qe(F.name)} | ${H} | ${Qe(F.status)} | ${Qe(P)} |${x?` ${le?ee().videoDownloadLink(le):"\u2014"} |`:""}`)}f()}if(d){let Q=e.issuesFound.filter(F=>!jv(F)).sort(Jv),x=e.issuesFound.filter(jv).sort(Jv);if(Q.length){g(ee().staged.issuesFoundHeader);for(let F of Q)p.push(Yv(F));f()}if(x.length){p.push(`### ${ee().configErrorsHeader}`);for(let F of x)p.push(Yv(F));p.push("")}}let k=e.testPackages??[],C=e.dependencyChanges??[];if(k.length){p.push(ee().staged.testPackagesHeader,"");for(let Q of k)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"||!Wv(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.
|
|
3
|
+
"version": "0.13.0-v3.285",
|
|
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.",
|