@skyramp/testbot-core 0.13.0-v3.213 → 0.13.0-v3.214

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/post.js CHANGED
@@ -117,7 +117,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}fun
117
117
  `)){let n=e.trim();if(n)try{let r=JSON.parse(n);if(r.type==="system"&&r.subtype==="init"&&Array.isArray(r.mcp_servers))return Object.fromEntries(r.mcp_servers.filter(s=>typeof s.name=="string").map(s=>[s.name,typeof s.status=="string"?s.status:"unknown"]))}catch{}}return{}}function f0(t){let e=Pj(t).skyramp;return e===void 0||e==="connected"}function Oj(t){if(!po.existsSync(t))return[];let e=[];for(let n of po.readFileSync(t,"utf-8").split(`
118
118
  `)){let r=n.trim();if(!r)continue;let s;try{s=JSON.parse(r)}catch{continue}let i=s.message?.content;Array.isArray(i)&&e.push(...i)}return e}var $j=u.object({route:u.string().describe('the page this step happens on, e.g. "/products/:id"'),action:u.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:u.array(u.string()).optional().describe("the plan clause ids this step exercises"),check:u.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),Ru=(n=>(n.InProcess="in-process",n.Browser="browser",n))(Ru||{}),g0=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(g0||{}),m0=u.object({id:u.string().describe('e.g. "J1"'),name:u.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:u.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:u.array($j).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:u.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:u.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:u.nativeEnum(Ru).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:u.nativeEnum(g0).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:u.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:u.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),_d=u.object({journey:u.string().describe("the plan's journey id"),file:u.string().describe("the browser test file that walks it"),brokeAt:u.object({step:u.number().int().describe("the 1-based step whose check failed first"),expected:u.string(),actual:u.string().describe("what the app did instead, from the runner's output"),notReached:u.array(u.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:u.string().describe("the title of the one test in that file that walks it end to end")});var Sy=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Sy||{}),xu=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(xu||{}),Ud=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(Ud||{}),E0=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(E0||{}),C0=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(C0||{}),Va=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(Va||{}),Fe=u.string().trim().min(1),Ga=Fe.describe("file:line"),y0=t=>Fe.refine(e=>e.length<=400,e=>({message:`is ${e.length} characters, over the 400 cap \u2014 ${t}`})),Tu=Fe.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'),by=u.object({method:Fe,path:Fe,service:u.string().optional(),evidence:Ga,repository:Tu}),Vj=u.object({id:Fe.describe("short-slug, e.g. R9"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:u.nativeEnum(Va).describe("spec outranks pr-description when both state it"),evidence:Fe.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),Gj=u.object({id:Fe.describe("short-slug"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:Fe.describe("METHOD /path, or a component/page name"),evidence:Fe.describe("file:line from the diff that introduces it"),repository:Tu,satisfies:u.array(Fe).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)")}),Hj=u.object({id:Fe.describe("short-slug"),file:Fe,line:u.number().optional(),claim:y0("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:u.nativeEnum(xu),evidence:y0("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:u.nativeEnum(Ud),repository:Tu,conflictsWith:u.array(Fe).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),Yj=u.object({name:Fe,language:u.string().optional(),framework:u.string().optional(),evidence:Ga,repository:Tu}),qj=u.object({dir:Fe,framework:u.string().optional(),kind:u.nativeEnum(E0),evidence:Ga,repository:Tu}),jj=u.object({from:Fe,to:Fe,onDelete:u.nativeEnum(C0),evidence:Ga}),Jj=u.object({entity:Fe,field:Fe,values:u.array(u.string()),evidence:Ga}),Wj=u.object({entities:u.array(u.object({name:Fe,evidence:Ga})),references:u.array(jj).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:u.array(Jj)}),rX=u.object({schemaVersion:u.literal(1),repository:u.object({path:Fe.describe("absolute repo path"),currentBranch:Fe,baseBranch:Fe}),project:u.object({type:u.nativeEnum(Sy),primaryLanguage:Fe,languages:u.array(u.string()),frameworks:u.array(u.string())}),services:u.array(Yj),infrastructure:u.object({containerized:u.boolean(),hasDockerCompose:u.boolean(),composeFiles:u.array(u.string()),hasCiCd:u.boolean()}),diff:u.object({changedFiles:u.array(u.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:u.boolean(),summary:Fe.describe("\u2264400 chars")}),endpoints:u.object({new:u.array(by),modified:u.array(by),removed:u.array(by)}),existingTests:u.object({locations:u.array(qj)}),entityMap:Wj,requirements:u.array(Vj).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:u.array(Gj),findings:u.array(Hj),unexamined:u.array(u.string()).describe("files or areas outside this change you did not open"),summary:Fe.describe("one paragraph on what this change does and its test-relevant risk")});var Ld=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(Ld||{}),rs=u.string().trim().min(1),zj=u.object({case:rs.describe("recommend id this assertion enforces"),evidence:rs.describe("the exact assertion line from the file that checks that case's observable")}),ky=u.object({kind:u.nativeEnum(Id).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:rs.describe("the dependency, endpoint or data it affects"),mechanism:u.nativeEnum(Bd).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:rs.describe("what it sets up"),worker:rs.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:rs.optional().describe("seed: a command, without a shell, that removes the data when the test does not")}),Kj=u.object({file:rs.describe("staged path under .skyramp/staged/"),source:u.nativeEnum(Ld),language:rs,covers:u.array(u.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:u.array(zj).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:u.array(ky).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")}),vy=u.object({schemaVersion:u.literal(1),tests:u.array(Kj),deferredUi:u.array(u.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:rs.describe("one paragraph")});var ss=u.string().trim().min(1),Du=72,Zj=u.object({repository:ss.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:u.string(),command:u.string().describe("the exact command you ran, scoped to the changed files"),clean:u.boolean(),fixed:u.array(u.string()).optional().describe("files you fixed"),uncovered:u.array(u.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.")}),dX=u.object({schemaVersion:u.literal(1),lint:u.array(Zj).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:u.object({ok:u.boolean(),notes:u.string().optional()}),ciReadiness:u.object({covered:u.boolean().describe("will the repo's CI run these tests?"),notes:u.string().optional()}),dependencies:u.object({added:u.array(u.object({package:u.string(),manifest:u.string(),repository:ss.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:ss.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:u.array(u.object({file:ss,repository:ss.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:u.object({message:ss.refine(t=>t.split(`
119
119
  `)[0].length<=Du,{message:`subject line must be <= ${Du} chars`})}),pr:u.object({title:ss.max(Du,`must be <= ${Du} chars`),body:ss}),ready:u.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:u.array(u.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:ss.describe("one paragraph")});var qs=Re(require("fs")),qa=Re(require("path")),S0=require("child_process");var is="{junit}",B0=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(B0||{}),Q0=(e=>(e.Minitest="minitest",e))(Q0||{}),I0=u.string().trim().min(1),Ha=u.object({cwd:I0.describe('repo-relative directory the command starts in ("." for the root)'),argv:u.array(I0).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report one argument holds ${is}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:u.record(u.string(),u.string()).optional().describe("plain settings the tests read beyond the repository's CI test job (RAILS_ENV=test, DB_CONNECTION=sqlite); never a credential, PATH, or a tool's install path"),report:u.object({format:u.nativeEnum(B0).describe(`junit (JUnit XML to ${is}), trx (to ${is}), or go-test-json (go test -json on the command's output)`),reporter:u.nativeEnum(Q0).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 Ya="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)",gX=`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 the argument ${is}), trx (a TRX file to ${is}, 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 ${is}: 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 ${is} itself. A setting the tests read goes in "env" (RAILS_ENV=test): the run sets it, so never wrap the command in a shell to set one. The run executes the command and reads that report.`;var ho=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(ho||{}),Ys=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(Ys||{}),xy=(n=>(n.Repository="repository",n.Testbot="testbot",n))(xy||{}),Ty=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(Ty||{}),Kt=u.string().trim().min(1),Xj=u.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var eJ=u.object({id:Xj,source:u.nativeEnum(xy),kind:u.nativeEnum(_s),outcome:u.nativeEnum(Ty),summary:Kt.max(400).describe("one line: what it shows"),tests:u.array(Kt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:Kt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:Kt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:Ha.optional().describe(`source repository, for tests in ${Ya}: 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`)}),tJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),mechanism:u.nativeEnum(Ys),evidenceIds:u.array(Kt).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:u.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),nJ=u.object({behaviorId:u.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:Kt.max(600).describe("the evidence that is required and cannot be obtained in this run")}),rJ=u.object({file:Kt.describe("the changed file the failure is in"),repository:Kt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:Kt.max(300).describe("what prerequisite the change fails"),evidence:Kt.max(400).describe("the error line, quoted")}),sJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),reason:Kt.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)")}),Nu=u.object({schemaVersion:u.literal(1),decision:u.nativeEnum(ho),evidence:u.array(eJ).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:u.array(tJ).describe("how each changed behavior's evidence is obtained"),gaps:u.array(nJ),outOfScope:u.array(sJ).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:rJ.optional().describe("only for blocked_preflight"),rationale:Kt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function Od(t){let e=bn(t,"recommend.json");if(!e||!Array.isArray(e.generate)||!Array.isArray(e.maintenance))return;let n=e;return{...n,maintenance:n.maintenance.map(({repository:r,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...r?.trim()?{repository:r.trim()}:{}}))}}function cJ(t){return es(vy,t).errors}function uJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=cJ(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}function $d(t,e=[]){return uJ(t.stdout,e)}function AJ(t){return t.generate.filter(e=>e.type!=="ui").map(e=>e.id)}function k0(t){return t.generate.filter(e=>e.type==="ui").map(e=>e.id)}var Vd={backend:{stage:"generate",cases:AJ,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:t=>`recommend case "${t}" is not covered by any generated test`,unknownCovered:t=>`test covers unknown recommend id "${t}"`,unasserted:t=>`case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:p0,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:k0,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:t=>`UI case "${t}" is not covered by any generated UI test`,unknownCovered:t=>`test covers "${t}" which is not a recommend UI case`,unasserted:t=>`UI case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:h0,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."}},zX=Us("generate-schema",(t,e)=>$d(e,t.secretValues));function lJ(t){let e=Vd[t];return{name:`${e.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=$d(r,n.secretValues);if(!s)return Mt(this.name,i);let a=Od(n);if(!a)return Mt(this.name,[e.noRecommendCoverage]);let c=new Set(s.tests.flatMap(h=>h.covers)),A=[],l=e.cases(a);for(let h of l)c.has(h)||A.push(e.uncovered(h));let p=new Set(t==="ui"?l:a.generate.map(h=>h.id));for(let h of c)p.has(h)||A.push(e.unknownCovered(h));if(t==="backend"){let h=new Set(s.deferredUi),g=new Set(k0(a));for(let C of g)!h.has(C)&&!c.has(C)&&A.push(`UI case "${C}" is neither covered nor deferred to the UI stage`);for(let C of h)g.has(C)||A.push(`deferredUi lists "${C}" which is not a UI case`)}return A.length===0?{name:this.name,passed:!0}:Mt(this.name,A)}}}function dJ(t){let e=Vd[t];return{name:`${e.stage}-intent`,verify(n,r){let{generate:s,errors:i}=$d(r,n.secretValues);if(!s)return Mt(this.name,i);let a=Od(n);if(!a)return Mt(this.name,[e.noRecommendIntent]);let{asserted:c,errors:A,badFiles:l}=EJ(s,n.inputs.repositoryPath),p=A.length;for(let g of e.cases(a))c.has(g)||A.push(e.unasserted(g));if(A.length===0)return{name:this.name,passed:!0};let h=Mt(this.name,A);return p>0&&p===A.length&&l.size>0?{...h,droppable:[...l]}:h}}}function pJ(t){let e=Vd[t];return n=>{if(!n.inputs.skyrampMcp?.command||t==="backend"&&!By(n))return;let r=qa.join(n.outputsDir,`${e.stage}-stream.ndjson`);if(!(!qs.existsSync(r)||e.usedCodegen(r)))return f0(r)?e.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}var KX=lJ("backend"),ZX=dJ("backend"),XX=pJ("backend");var b0=t=>t.replace(/\s+/g,"");var Dy={python:[/\bassert\s*[({\w"'`]/g,/\bpytest\.raises\s*\(/g,/\bself\.assert\w*\s*\(/g],typescript:[/\bexpect\s*\(/g,/\.should\b/g,/\bassert\s*[.(]/g],go:[/\bt\.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)\s*\(/g,/\b(assert|require)\.\w+\s*\(/g],java:[/\bassert\w*\s*\(/g,/\bassertThat\s*\(/g],ruby:[/\bexpect\s*[({]/g,/\bassert\w*\b/g,/\.should\b/g]};for(let[t,e]of[["javascript","typescript"],["kotlin","java"]])Dy[t]=Dy[e];function hJ(t,e){if(t.includes(Iu(e))||b0(t).includes(b0(e)))return!0;let n=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!/^(\/\/|#|\*|\/\*)/.test(r));return n.length>0&&n.every(r=>t.includes(Iu(r)))?!0:yJ(t,e)}var fJ=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,gJ=12,mJ=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function yJ(t,e){let n=e.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=fJ.exec(s);if(!i)continue;let a=s.slice(i.index),c=mJ.exec(a);if(c&&(a=a.slice(0,c.index)),a=Iu(a).replace(/[,\s]+$/,""),a.length<gJ||!t.includes(a))return!1;r++}return r>0}function EJ(t,e){let n=new Set,r=[],s=new Set;for(let i of t.tests){let a=qa.resolve(e,i.file);if(!qs.existsSync(a))continue;let c=Iu(qs.readFileSync(a,"utf-8"));for(let A of i.assertions??[]){if(!hJ(c,A.evidence)){r.push(`assertion evidence for "${A.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(A.case)?n.add(A.case):(r.push(`assertion cites case "${A.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}var CJ=/\.(spec|test)\.[cm]?[jt]sx?$/i;function v0(t){let e;try{e=(0,S0.execFileSync)("git",[...Dd,"status","--porcelain","--untracked-files=all"],{env:zn(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=s=>/_scaffold/i.test(s)||Sd.test(s),r=[];for(let s of e.split(`
120
- `)){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 c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function IJ(t){let e=Vd[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=v0(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>CJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:Mt(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var e6=IJ("backend");var Fu=Re(require("fs")),fo=Re(require("path"));function T0(t){return es(Qy,t).errors}function wJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=T0(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var bJ="adapt-scratch",R0=`${bJ}/adapt-result.json`;function D0(t,e){let n=fo.join(t.outputsDir,R0),r;try{r=Fu.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${R0} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=wJ(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?va(n):void 0;return i!==void 0&&T0(i).length===0?{adapt:i,errors:[]}:s}var Q6=Us("adapt-schema",D0);var D6=2*1024*1024;var le=u.string().trim().min(1),kJ=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},vJ=u.preprocess(kJ,u.object({id:le.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:le.describe("one testable part of the requirement"),expected:le.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(Gs).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),RJ=u.object({id:le.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:le,source:u.nativeEnum(Va).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:le.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(u.object({spec:le.describe("file:line of the spec in the repository"),says:le.describe("what the spec says there, in its own words")})).optional().describe("requirement-reference only: each spec in the repository that says otherwise; the item wins, so test what it says"),clauses:u.array(vJ)}),N0=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(N0||{}),xJ=u.object({id:le.describe('e.g. "F1"'),file:le,line:u.number().optional(),claim:le.describe("the defect, in one sentence"),severity:u.nativeEnum(xu),evidence:le.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(le).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(N0).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),TJ=u.object({id:le.describe('e.g. "Q1"'),question:le.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(le).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one")}),DJ=u.object({id:le.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(Gs).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:le.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:le.describe("what the test does"),expected:le.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),NJ=u.object({test:le.describe("existing test file"),action:u.nativeEnum(uo),reason:le,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(le).optional().describe("the clause ids this test checks")}),FJ=u.object({outcome:u.nativeEnum(ts).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:le,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:py.optional()}),u7=u.object({schemaVersion:u.literal(1),requirements:u.array(RJ),findings:u.array(xJ),cases:u.array(DJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(TJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(NJ),journeys:u.array(m0).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:le,why:le})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Nu.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:FJ.optional().describe("omit when no app was needed or none was started"),summary:le.describe("one paragraph: what the change does and where the risk is")});var F0=(n=>(n.Backend="backend",n.Ui="ui",n))(F0||{});var Ny=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Ny||{}),MJ=u.object({file:le.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(F0),change:u.nativeEnum(Ny).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:le.describe("the requirement or clause id the change deliberately alters"),line:le.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:le,status:u.nativeEnum(Kn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:le,evidence:le})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:le.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(le).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(ky).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:le.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),run:Ha.optional().describe(`for a file in ${Ya}, 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 ${is}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),_J=u.object({description:le.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(xu).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),test:u.string().optional().describe("the test file that shows it"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(le).optional().describe("the plan's requirement or clause ids it violates")}),A7=u.object({schemaVersion:u.literal(1),tests:u.array(MJ),notWritten:u.array(u.object({case:le,reason:le})).describe("every plan case no test covers, and why"),journeys:u.array(_d).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:le,manifest:le.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:le.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:le.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(le).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"),ciRunsTests:u.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:u.object({message:le.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:le.describe("at most 72 characters"),prBody:le.describe("what the tests cover and what they found")}),report:u.object({summary:le.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(_J).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var l7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var _0=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(_0||{}),yt=u.string().trim().min(1),UJ=u.object({expectation:yt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(_0),expected:yt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),LJ=u.object({file:yt.describe("path of the NEW test file you wrote, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:yt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:Ha.optional().describe(`for ${Ya}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(yt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(yt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(UJ).min(1)}),Fy=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Fy||{}),M0=300,PJ=u.object({file:yt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Fy),staleBecause:u.object({requirement:yt.describe("the requirement or clause id the change deliberately alters"),line:yt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,M0):t,yt.max(M0)).describe("what the change deliberately altered that made the test wrong")}),My=u.object({schemaVersion:u.literal(1),tests:u.array(LJ),maintained:u.array(PJ).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:yt,reason:yt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(_d).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:yt,missing:yt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:yt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var D7=5*6e4;function VJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=es(My,e);return s.length?{errors:s}:{output:r,errors:[]}}function GJ(t){return VJ(t.stdout)}var _ee=Us("generate-unit-schema",(t,e)=>GJ(e));var Gd=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,Uee=[[/\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+["']${Gd}["']|\bimport\s+["']${Gd}["']|require\(\s*["']${Gd}["']\s*\)|\bimport\(\s*["']${Gd}["']\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 L0=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,P0=String.raw`\b(?:not|isn't|aren't|never|no)\s+(?:be\s+)?(?:covered|tested|exercised|verified|checked|walked|executed|run)\b|\buncovered\b|\bunverified\b`,Zee=[new RegExp(`${L0}[^.;\\n]{0,100}(?:${P0})`,"i"),new RegExp(`(?:${P0})[^.;\\n]{0,100}${L0}`,"i")];var Xee=new Set(["targeted_unit","existing_evidence_sufficient"]);var Ote=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),$te={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 JJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=es(Nu,e);return s.length?{errors:s}:{triage:r,errors:[]}}function WJ(t){return JJ(t.stdout)}var Vte=Us("triage-schema",(t,e)=>WJ(e));var Gte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Dt();Dt();var KJ="Skyramp-Pull-Request",ZJ="Skyramp-Delivery-Base",XJ="Skyramp-Tested-Revision";var cne=["%H","%P","%an","%ae","%ce",`%(trailers:key=${KJ},valueonly,separator=%x2C)`,"%s",`%(trailers:key=${ZJ},valueonly,separator=%x2C)`,`%(trailers:key=${XJ},valueonly,separator=%x2C)`];var O0=Re(require("path"));var bt=u.string().trim().min(1),_y=(n=>(n.TestbotManaged="testbot_managed",n.CustomerDeployed="customer_deployed",n))(_y||{}),Hd=[".skyramp/sut/setup.sh",".skyramp/sut/teardown.sh"],Uy=u.object({schemaVersion:u.literal(1),type:u.nativeEnum(_y).optional(),status:u.enum(["ready","blocked"]),environment:Oa.optional(),components:u.array(u.object({name:bt,repository:bt.describe(`owner/repo, or "${zt}" for a customer-deployed component no repository builds`),healthy:u.boolean(),url:u.string().min(1).nullable(),...hy,credentials:u.array(u.string().regex(La)).max(50).optional(),deployed:bt.nullable().optional().describe("customer_deployed only: the revision the component runs, as setup read it (WF-SETUP-22's Deployed now), or null when it could not tell")}).strict()),suites:u.array(u.object({framework:bt,file:bt,result:u.enum(["pass","fail","error"])}).strict()),inputsUsed:u.array(bt),inputsUsedHow:u.array(u.object({input:bt,how:bt}).strict()).optional(),inputsNotUsed:u.array(u.object({input:bt,reason:bt}).strict()),blockers:u.array(u.object({component:bt,problem:bt,evidence:bt,fix:bt}).strict()),replay:u.object({outcome:bt,durationSeconds:u.number().nonnegative().nullable()}).strict().nullable(),files:u.array(u.object({path:bt,content:u.string()}).strict())}).strict().superRefine((t,e)=>{t.inputsUsedHow?.forEach((s,i)=>{t.inputsUsed.includes(s.input)||e.addIssue({code:u.ZodIssueCode.custom,path:["inputsUsedHow",i,"input"],message:"not one of inputsUsed"})}),t.components.forEach((s,i)=>{s.credentials&&new Set(s.credentials).size!==s.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"credentials"],message:"names a credential twice"})});let n=t.type==="customer_deployed";n!==(t.environment!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment"],message:"an environment exactly when the plan's type is customer_deployed"}),t.environment&&new Set(t.environment.credentials).size!==t.environment.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment","credentials"],message:"names a credential twice"});let r=new Set(t.components.map(s=>s.name));if(t.environment?.revisionSources.forEach((s,i)=>{s.components.forEach((a,c)=>{r.has(a)||e.addIssue({code:u.ZodIssueCode.custom,path:["environment","revisionSources",i,"components",c],message:"not one of components"})})}),t.components.forEach((s,i)=>{s.deployed!==void 0!==n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"deployed"],message:"what a component runs exactly when the plan is customer_deployed"}),s.repository===zt&&!n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"repository"],message:`only a customer_deployed component is ${zt}`})}),n&&(t.components.forEach((s,i)=>{t.components.findIndex(a=>a.name===s.name)!==i&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"name"],message:"names a component twice"})}),t.replay!==null&&e.addIssue({code:u.ZodIssueCode.custom,path:["replay"],message:"a customer_deployed plan is never replayed"}),t.files.forEach((s,i)=>{Hd.includes(s.path)&&e.addIssue({code:u.ZodIssueCode.custom,path:["files",i,"path"],message:"a customer_deployed plan has no script that starts or stops the system"})})),n&&t.status==="ready"){let s=new Set(t.environment?.revisionSources.flatMap(i=>i.components));t.components.forEach((i,a)=>{i.repository!==zt&&!s.has(i.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",a,"name"],message:"a ready customer_deployed plan reads what every component a repository builds runs"})})}});var Lne=["clean","recipe-drift"];function Mu(t){let e=O0.posix.normalize(t);return e===t&&(e===".skyramp/workspace.yml"||e.startsWith(".skyramp/sut/")&&e.length>13)}var qd=(n=>(n.GitHub="github",n.AzureDevOps="azure-devops",n))(qd||{}),Oy=(i=>(i.Trigger="TRIGGER",i.Baseline="BASELINE",i.AuthoritativeRelatedChange="AUTHORITATIVE_RELATED_CHANGE",i.ConfiguredSharedDependency="CONFIGURED_SHARED_DEPENDENCY",i.ManualOverride="MANUAL_OVERRIDE",i))(Oy||{}),Uu=(a=>(a.PullRequest="pull_request",a.ReadyForReview="ready_for_review",a.Schedule="schedule",a.Manual="manual",a.SutSetup="sut_setup",a.RevisionRead="revision_read",a))(Uu||{}),nW=["sut_setup"],rW=["sut_setup","schedule","revision_read"];var jd=(e=>(e.PullRequest="pull_request",e))(jd||{}),Lu=(s=>(s.ModelProvider="model_provider",s.SutAccess="sut_access",s.Skyramp="skyramp",s.Other="other",s))(Lu||{});var Jd=(i=>(i.ReportUploaded="report_uploaded",i.NoReport="no_report",i.Cancelled="cancelled",i.RecipeUploaded="recipe_uploaded",i.RevisionsUploaded="revisions_uploaded",i))(Jd||{}),Z0=(n=>(n.Running="running",n.Ended="ended",n))(Z0||{}),Wd=(p=>(p.TimedOut="timed_out",p.AgentFailed="agent_failed",p.SetupFailed="setup_failed",p.CredentialMissing="credential_missing",p.RunnerLost="runner_lost",p.CheckoutFailed="checkout_failed",p.EnvironmentUnverified="environment_unverified",p.ModelProviderDenied="model_provider_denied",p.ModelProviderUnavailable="model_provider_unavailable",p.RunnerProviderNotReady="runner_provider_not_ready",p))(Wd||{}),$y=(r=>(r.Onboard="onboard",r.Deploy="deploy",r.Recheck="recheck",r))($y||{}),Vy=(n=>(n.Started="started",n.Finished="finished",n))(Vy||{}),Gy=(r=>(r.Passed="passed",r.Failed="failed",r.Skipped="skipped",r))(Gy||{});var Hy=(r=>(r.ChooseCredential="choose_credential",r.FreeText="free_text",r.ChooseSource="choose_source",r))(Hy||{});var zd=(r=>(r.Discover="discover",r.Start="start",r.Check="check",r))(zd||{}),Kd=(s=>(s.ValidationPlan="validation_plan",s.TestEnvironment="test_environment",s.TestConditions="test_conditions",s.Tests="tests",s))(Kd||{}),Pu=(s=>(s.Found="found",s.Starting="starting",s.Up="up",s.OutOfScope="out_of_scope",s))(Pu||{}),Zn=u.string().regex(/^[1-9][0-9]{0,18}$/),as=u.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Ja=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,_t=u.string().regex(Ja),Ut=u.string().regex(/^[0-9a-f]{64}$/),Yd=u.object({id:_t,revision:Zn}).strict(),Zd={provider:u.literal("github"),providerAccountId:Zn,providerRepositoryId:Zn},Xd={provider:u.literal("azure-devops"),providerAccountId:_t,providerRepositoryId:_t},Xn=u.discriminatedUnion("provider",[u.object(Zd).strict(),u.object(Xd).strict()]),Yy=u.discriminatedUnion("provider",[u.object(Zd).passthrough(),u.object(Xd).passthrough()]),go=t=>`${t.provider}:${t.providerRepositoryId}`,$0={namespace:u.string().min(1),name:u.string().min(1)},X0=u.discriminatedUnion("provider",[u.object({...Zd,...$0}).strict(),u.object({...Xd,...$0}).strict()]),V0=u.object({ref:u.string().min(1),revision:as}).strict(),sW=u.object({repository:X0,revision:as,ref:u.string().nullable(),reason:u.nativeEnum(Oy),change:u.object({kind:u.nativeEnum(jd),number:Zn,base:V0.optional()}).strict().nullable(),compareWith:V0.optional()}).strict();function iW(t){if(t.trigger.kind==="revision_read"!=!t.baseline)return t.baseline?"a revision_read run names no baseline":"names its baseline";if(!t.baseline)return null;let{confirmedRunId:e,initialBaselineId:n,sources:r}=t.baseline;if(e!==null&&n!==void 0)return"a run compares with one baseline";let s=t.trigger.kind==="schedule"&&e!==null||n!==void 0;if(!r)return s?"names every source of the snapshot, once":null;if(e===null&&n===void 0)return"a run with no Confirmed Baseline names no baseline sources";let i=new Set(t.sources.map(A=>go(A.repository))),a=new Set(r.map(A=>go(A.repository)));return a.size===r.length&&a.size===i.size&&[...a].every(A=>i.has(A))?null:"names every source of the snapshot, once"}var eT=/^[A-Z][A-Z0-9_]+-[1-9][0-9]*$/,tT=/^[1-9][0-9]{0,18}$/,G0=new RegExp(`${eT.source}|${tT.source}`),H0=/^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+$/,oW=u.union([u.object({source:u.literal("jira"),site:u.string().regex(H0),key:u.string().regex(eT),updated:u.string().datetime(),contentHash:Ut}).strict(),u.object({source:u.literal("confluence"),site:u.string().regex(H0),key:u.string().regex(tT),version:u.number().int().positive(),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),contentHash:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict()]),Y0=u.union([u.literal("jira"),u.literal("confluence")]),aW=u.object({schemaVersion:u.literal(1),items:u.array(u.union([u.object({source:Y0,site:u.string(),key:u.string().regex(G0),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:Y0,site:u.string(),key:u.string().regex(G0),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("read"),version:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict()])),instructions:u.array(u.string()).optional()}).strict(),cW=u.object({schemaVersion:u.literal(1),runId:_t,skyrampOrgId:_t,target:Yd,policy:Yd.nullable(),trigger:u.object({kind:u.nativeEnum(Uu),requestedAt:u.string().datetime()}).strict(),configuration:u.object({captureId:_t,revision:Zn.nullable(),hash:Ut}).strict(),baseline:u.object({confirmedRunId:_t.nullable(),initialBaselineId:_t.optional(),sources:u.array(u.object({repository:Xn,revision:as}).strict()).optional()}).strict().optional(),sources:u.array(sW).min(1),execution:u.object({provider:u.nativeEnum(qd),repository:X0,workflowPath:u.string(),ref:u.string()}).strict(),credentials:u.array(u.object({name:u.string(),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict()),requirements:u.array(oW).min(1).optional(),instructions:u.object({contentHash:Ut}).strict().optional(),deployedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).min(1).optional()}).strict().superRefine((t,e)=>{let n=new Set;(t.requirements??[]).forEach((A,l)=>{let p="fileName"in A?"file":"pasted";A.source==="other"&&A.key!==`${p}-${A.contentHash.slice(0,16)}`&&e.addIssue({code:u.ZodIssueCode.custom,message:"is not the key of its content hash",path:["requirements",l,"key"]});let h=oy({source:A.source,key:A.key});n.has(h)&&e.addIssue({code:u.ZodIssueCode.custom,message:"names an item that the run already names",path:["requirements",l,"key"]}),n.add(h)});let r=t.trigger.kind,s=nW.includes(r);s!==(t.policy===null)&&e.addIssue({code:u.ZodIssueCode.custom,path:["policy"],message:s?`a ${r} run has no policy`:"names the policy revision"});let i=iW(t);i&&e.addIssue({code:u.ZodIssueCode.custom,path:t.baseline?["baseline","sources"]:["baseline"],message:i}),rW.includes(r)&&t.sources.forEach((A,l)=>{A.reason!=="BASELINE"&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"reason"],message:`a ${r} run selects only BASELINE sources`})}),t.deployedRevisions&&r!=="manual"&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions"],message:"only a manual run pins deployed revisions"});let a=new Set(t.sources.map(A=>go(A.repository))),c=new Set;(t.deployedRevisions??[]).forEach((A,l)=>{let p=go(A.repository);a.has(p)?c.has(p)&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"repository appears twice"}):e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"names a repository outside the snapshot"}),c.add(p)}),t.sources.forEach((A,l)=>{A.compareWith&&(A.reason!=="MANUAL_OVERRIDE"||A.change)&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"compareWith"],message:"only a MANUAL_OVERRIDE source without a change names a revision to compare with"})})});var nT=(n=>(n.Person="person",n.Policy="policy",n))(nT||{}),uW=u.object({kind:u.nativeEnum(nT),name:u.string().min(1).max(256)}).strict(),Yne=u.object({schemaVersion:u.literal(1),attempt:u.object({id:_t,number:u.number().int().positive(),deadlineAt:u.string().datetime()}).strict(),manifest:cW,manifestHash:Ut,entitlements:u.array(u.string()).optional(),runToken:u.string().min(1).optional(),requestedBy:uW.nullable().optional(),writeAllowed:u.boolean().optional(),claudeCodeVersion:u.string().regex(/^[0-9]+\.[0-9]+\.[0-9]+$/,"an exact version, such as 2.1.290").nullable().optional(),deployedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).optional(),statedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).optional()}).strict(),q0={providerRunAttempt:u.number().int().positive(),workflowRef:u.string().min(1)},AW=u.string().regex(/^[^/]+\/[^/]+\/[1-9][0-9]{0,15}\/[1-9][0-9]{0,15}$/),qne=u.object({schemaVersion:u.literal(1),runId:_t,execution:u.discriminatedUnion("provider",[u.object({...q0,provider:u.literal("github"),repository:u.object(Zd).strict(),providerRunId:Zn}).strict(),u.object({...q0,provider:u.literal("azure-devops"),repository:u.object(Xd).strict(),providerRunId:AW}).strict()]),requester:u.literal(!0).optional(),writeCheck:u.literal(!0).optional(),claudeCodePin:u.literal(!0).optional(),deployedPins:u.literal(!0).optional(),statedPins:u.literal(!0).optional()}).strict(),j0=u.object({repository:Xn,number:Zn}).strict(),lW=u.discriminatedUnion("status",[u.object({status:u.literal("none")}).strict(),u.object({status:u.literal("delivered"),pullRequests:u.array(j0).min(1)}).strict(),u.object({status:u.literal("partial"),pullRequests:u.array(j0).min(1),failures:u.array(u.object({repository:Xn,message:u.string()}).strict()).min(1)}).strict(),u.object({status:u.literal("failed"),message:u.string()}).strict()]),dW=u.object({blockedPreflight:u.object({file:u.string().min(1),repository:u.string().min(1).optional(),reason:u.string().min(1).max(300),evidence:u.string().min(1).max(400)}).strict().optional(),sufficiency:u.nativeEnum(Sa),rationale:u.string().min(1),gaps:u.array(u.string().min(1)),acceptedEvidence:u.array(u.object({kind:u.nativeEnum(_s),repository:u.string().min(1),revision:as,reference:u.string().min(1),summary:u.string().min(1)}).strict()),actionRequired:u.array(u.nativeEnum(ka))}).strict().superRefine((t,e)=>{t.sufficiency==="insufficient"!=t.gaps.length>0&&e.addIssue({code:u.ZodIssueCode.custom,path:["gaps"],message:"only insufficient evidence names gaps, and it names at least one"}),new Set(t.actionRequired).size!==t.actionRequired.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["actionRequired"],message:"a reason appears twice"})}),Ly=500,pW=2048,hW=1e3,fW=/[\\/:*?"<>|;#$*{},+=[\]%\p{Cc}\p{Cf}]/u,J0=t=>t.length>0&&t.length<=64&&t===t.trim()&&!fW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith("."),gW=t=>{if(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/.test(t))return!0;let[e,n,r,...s]=t.split("/");return t.length<=201&&s.length===0&&r!==void 0&&/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/.test(e)&&J0(n)&&J0(r)},mW=u.object({testResults:u.array(u.object({resultId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/),repository:u.string().refine(gW,"Invalid"),testType:u.string(),endpoint:u.string(),status:u.enum(["Pass","Fail","Skipped"]),details:u.string(),fileName:u.string().optional(),testId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/).optional(),failureCause:u.object({kind:u.nativeEnum(cy),family:u.nativeEnum(uy).optional()}).strict().optional(),origin:u.nativeEnum(ay).optional()}).strict()),validation:dW,changes:u.array(u.object({id:u.string().min(1).max(512),text:u.string().max(16384),source:u.string().max(pW),testedBy:u.array(u.string().min(1).max(1024)).max(Ly),writtenBy:u.array(u.string().min(1).max(1024)).max(Ly),maintainedBy:u.array(u.string().min(1).max(1024)).max(Ly)}).strict()).max(hW).optional(),traceVersion:u.literal(1)}).passthrough().superRefine((t,e)=>{let n=new Set;t.testResults.forEach((r,s)=>{let i=r.failureCause;i&&r.status==="Pass"&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"a passing result has no failure cause"}),i&&i.kind==="environment"!=(i.family!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"an environment cause names its family, and no other cause does"});let a=["testResults",s,"resultId"],c=r.resultId.slice(`${r.repository}:${r.testType}:`.length);(!r.resultId.startsWith(`${r.repository}:${r.testType}:`)||c===""||c.startsWith("/")||c.startsWith("#"))&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"is not repository:testType:path for this result"}),n.has(r.resultId)&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"stable identity repeated"}),n.add(r.resultId)})});var rT=50,W0=u.string().regex(/^(?!.*\.\.)(?!\/)(?!.*\/$)[A-Za-z0-9._/-]{1,255}$/),sT=u.discriminatedUnion("kind",[u.object({kind:u.literal("branch_pushed"),repository:Xn,branch:W0,commit:as}).strict(),u.object({kind:u.enum(["pull_request_opened","pull_request_edited"]),repository:Xn,number:Zn,branch:W0}).strict()]),yW=u.object({schemaVersion:u.literal(1),run:u.object({runId:_t,attemptNumber:u.number().int().positive(),manifestHash:Ut}).strict(),target:Yd,policy:Yd,provenance:u.object({sources:u.array(u.object({repository:Xn,revision:as}).strict()),firstQualification:u.literal(!0).optional()}).strict(),delivery:u.object({generatedTests:lW}).strict(),producer:u.object({testbot:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/),mcp:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/)}).strict(),report:mW,githubWrites:u.array(sT).max(rT).optional()}).strict(),jne=yW.pick({schemaVersion:!0,run:!0,target:!0,provenance:!0,producer:!0}).extend({recipe:Uy}).strict().superRefine(({recipe:t},e)=>{let n=(i,a)=>e.addIssue({code:u.ZodIssueCode.custom,path:["recipe",...i],message:a});t.status==="blocked"&&t.blockers.length===0&&n(["blockers"],"a blocked recipe names at least one blocker");let r=new Set,s=0;t.files.forEach((i,a)=>{Mu(i.path)||n(["files",a,"path"],"is not .skyramp/workspace.yml or a file under .skyramp/sut/"),r.has(i.path)&&n(["files",a,"path"],"file repeated"),r.add(i.path),fy.test(i.content)&&n(["files",a,"content"],"is not text");let c=Buffer.byteLength(i.content,"utf8");s+=c,c>ku&&n(["files",a,"content"],`larger than ${ku} bytes`)}),s>vu&&n(["files"],`recipe text over ${vu} bytes in total`)}),Jne=u.object({components:u.array(u.object({name:u.string().min(1),repository:u.string().regex(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/),observedRevision:u.string().regex(/^[0-9a-f]{7,64}$/).nullable(),source:u.nativeEnum(Cd),evidence:u.string()}).strict().refine(t=>t.source!=="agent"||t.observedRevision===null,{path:["observedRevision"],message:"a component only an agent session can read names no revision"}))}).strict();var EW=u.object({schemaVersion:u.literal(1),stage:u.nativeEnum($y),event:u.nativeEnum(Vy),status:u.nativeEnum(Gy).optional()}).strict().refine(t=>t.status===void 0||t.event==="finished",{path:["status"],message:"only a finished stage has a status"}),Wa=100,qy=5e3,_u=2e3,Py=100,jy=/^[A-Za-z0-9_-]{1,64}$/,iT=20,oT=200,aT=100,cT=100,CW=200,z0="[^/\\s](?:(?:[^/\\s]| )*[^/\\s])?",IW=new RegExp(`^(?:[^/\\s]+/[^/\\s]+|[^/\\s]+/${z0}/${z0})$`),uT=500,AT=50,Ou=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/,xn=t=>u.string().max(t).refine(e=>e.trim().length>0&&!Ou.test(e),"blank, or not text"),os={sequence:u.number().int().min(1).max(qy),at:u.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?Z$/)},lT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),phase:u.nativeEnum(zd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("component"),name:xn(Py),repository:xn(CW).refine(t=>IW.test(t)||t===zt,"not owner/name"),file:xn(uT).nullable(),status:u.nativeEnum(Pu),version:xn(cT).optional()}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("question"),id:u.string().regex(jy),type:u.nativeEnum(Hy),text:xn(_u),component:xn(Py).nullable(),choices:u.array(xn(oT)).max(iT),placeholder:xn(aT).optional()}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict(),u.object({...os,kind:u.literal("credentials"),names:u.array(u.string().regex(La)).min(1).max(AT)}).strict()]).superRefine((t,e)=>{t.kind==="credentials"&&new Set(t.names).size!==t.names.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["names"],message:"a name twice"}),t.kind==="question"&&(t.type==="free_text"!=(t.choices.length===0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"choices exactly when the question is not free_text"}),new Set(t.choices).size!==t.choices.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"a choice twice"}))}),BW=u.object({schemaVersion:u.literal(1),events:u.array(lT).max(Wa)}).strict(),dT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),stage:u.nativeEnum(Kd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict()]),QW=u.object({schemaVersion:u.literal(1),events:u.array(dT).max(Wa)}).strict(),K0={id:u.string().uuid(),text:u.string(),by:u.string().nullable(),at:u.string(),replied:u.literal(!0).optional()},pT=u.discriminatedUnion("kind",[u.object({...K0,kind:u.literal("instruction"),question:u.null()}),u.object({...K0,kind:u.literal("answer"),question:u.string().regex(jy)})]),hT=u.string().regex(/^[A-Za-z0-9+/]{43}=$/),wW=u.object({id:u.string().uuid(),revision:u.string(),by:u.string().nullable(),at:u.string(),target:u.string(),own:u.object({source:u.enum(["policy","test_environment"]),text:u.string()}).nullable()}),bW=u.object({schemaVersion:u.literal(1),leftOut:u.array(u.string()),messages:u.array(pT).optional(),stop:u.object({key:hT}).optional(),notes:wW.optional()}),SW=u.object({schemaVersion:u.literal(1),messages:u.array(pT).optional()});var fT=500*1024*1024,gT=u.object({id:Zn,name:u.string().regex(/^[A-Za-z0-9._-]{1,200}$/),providerRunId:Zn,expiresAt:u.string().datetime()}).strict(),kW=u.object({schemaVersion:u.literal(1),artifact:gT,sessionId:_t,contentHash:Ut,bytes:u.number().int().min(1).max(fT)}).strict(),vW=u.object({schemaVersion:u.literal(1),checkpoint:u.object({artifact:gT,repository:u.object({namespace:u.string().min(1),name:u.string().min(1)}).strict(),sessionId:_t,contentHash:Ut,key:hT}).strict().nullable()}).strict(),RW=200,ja=100,Jy=(r=>(r.Resume="resume",r.Retry="retry",r.Update="update",r))(Jy||{}),xW=u.object({kind:u.nativeEnum(Jy),setup:u.object({runId:_t,endedAt:u.string().nullable(),outcome:u.string().nullable()}).strict(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1),status:u.nativeEnum(Pu)}).strict()).max(ja),credentials:u.array(u.string().min(1)).max(ja),answers:u.array(u.object({question:u.string(),answer:u.string().nullable()}).strict()).max(ja),instructions:u.array(u.object({text:u.string(),reply:u.string().nullable()}).strict()).max(ja),log:u.array(u.object({phase:u.nativeEnum(zd),text:u.string()}).strict()).max(RW),recipe:u.object({files:u.array(u.object({path:u.string().min(1),content:u.string()}).strict()).max(ja),blockers:u.array(u.object({component:u.string(),problem:u.string(),evidence:u.string(),fix:u.string()}).strict()).max(ja)}).strict().optional()}).strict(),TW=u.object({schemaVersion:u.literal(1),context:xW.nullable()}).strict(),DW=u.object({schemaVersion:u.literal(1),configuration:u.object({captureId:_t,revision:Zn.nullable(),hash:Ut}).strict(),capture:u.object({schemaVersion:u.literal(1),settings:u.object({target:u.object({environment:u.unknown()}).passthrough(),timeoutMinutes:u.number().int().positive(),answerWaitMinutes:u.number().int().positive().optional(),testEnvironment:u.object({name:u.string().min(1),address:u.string().min(1).optional(),readyWhen:u.string().min(1).optional()}).passthrough().optional()}).passthrough(),provenance:u.object({}).passthrough(),hash:Ut}).strict()}).strict(),NW=Oa.extend({version:u.number().int().positive(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1)}).strict()),contentHash:Ut.optional(),files:u.array(u.object({path:u.string().refine(t=>Mu(t)&&!Hd.includes(t),"not a file of a customer_deployed plan"),content:u.string()}).strict()).optional()}).strict(),FW=u.object({schemaVersion:u.literal(1),testEnvironment:NW.nullable().optional(),runtimePlan:u.object({version:u.number().int().positive(),contentHash:Ut,files:u.array(u.object({path:u.string().refine(Mu,"not a recipe file path"),content:u.string()}).strict()).min(1),recipe:u.record(u.unknown()).optional()}).strict().nullable()}).strict().refine(t=>!(t.runtimePlan&&t.testEnvironment),{message:"a run pins a recipe or a customer's Test Environment, never both",path:["testEnvironment"]}),MW=u.object({schemaVersion:u.literal(1),state:u.nativeEnum(Z0),ending:u.nativeEnum(Jd).nullable(),cause:u.nativeEnum(Wd).nullable(),deadlineAt:u.string().datetime()}).strict();function mT(t){return t.reportUploaded?{schemaVersion:1,reason:"report_uploaded",cause:null}:t.recipeUploaded?{schemaVersion:1,reason:"recipe_uploaded",cause:null}:t.revisionsUploaded?{schemaVersion:1,reason:"revisions_uploaded",cause:null}:t.cancelled?{schemaVersion:1,reason:"cancelled",cause:null}:{schemaVersion:1,reason:"no_report",cause:_W(t)}}function _W(t){return t.runnerProviderNotReady?"runner_provider_not_ready":t.credentialMissing?"credential_missing":t.checkoutFailed?"checkout_failed":t.environmentUnverified?"environment_unverified":t.setupFailed?"setup_failed":t.timedOut?"timed_out":t.modelProviderDenied?"model_provider_denied":t.modelProviderUnavailable?"model_provider_unavailable":"agent_failed"}var Zne={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var LW=10*1024*1024;var yT=Re(require("fs")),$u="SKYRAMP_AZURE_SUPERVISED",Wy=3;function ep(t){return t.replace(/##(?=(?:vso)?\[)/gi,"#\u200B#")}function zy(t,e=process.env){e[$u]==="1"?yT.writeSync(Wy,`${JSON.stringify(t)}
120
+ `)){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 c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function IJ(t){let e=Vd[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=v0(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>CJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:Mt(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var e6=IJ("backend");var Fu=Re(require("fs")),fo=Re(require("path"));function T0(t){return es(Qy,t).errors}function wJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=T0(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var bJ="adapt-scratch",R0=`${bJ}/adapt-result.json`;function D0(t,e){let n=fo.join(t.outputsDir,R0),r;try{r=Fu.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${R0} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=wJ(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?va(n):void 0;return i!==void 0&&T0(i).length===0?{adapt:i,errors:[]}:s}var Q6=Us("adapt-schema",D0);var D6=2*1024*1024;var le=u.string().trim().min(1),kJ=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},vJ=u.preprocess(kJ,u.object({id:le.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:le.describe("one testable part of the requirement"),expected:le.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(Gs).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),RJ=u.object({id:le.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:le,source:u.nativeEnum(Va).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:le.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(u.object({spec:u.string().optional().describe("file:line of the spec in the repository; leave it out for a PR description"),prDescription:u.boolean().optional().describe("true when a pull request description says otherwise"),says:le.describe("what the spec or the PR description says there, in its own words, copied exactly")}).refine(t=>!!(t.prDescription||t.spec?.trim()),{message:'names no source: give "spec" its file:line, or set "prDescription"'})).optional().describe("requirement-reference only: each spec in the repository, and each PR description, that says otherwise; the item wins, so test what it says"),clauses:u.array(vJ)}),N0=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(N0||{}),xJ=u.object({id:le.describe('e.g. "F1"'),file:le,line:u.number().optional(),claim:le.describe("the defect, in one sentence"),severity:u.nativeEnum(xu),evidence:le.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(le).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(N0).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),TJ=u.object({id:le.describe('e.g. "Q1"'),question:le.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(le).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one")}),DJ=u.object({id:le.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(Gs).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:le.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:le.describe("what the test does"),expected:le.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),NJ=u.object({test:le.describe("existing test file"),action:u.nativeEnum(uo),reason:le,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(le).optional().describe("the clause ids this test checks")}),FJ=u.object({outcome:u.nativeEnum(ts).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:le,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:py.optional()}),u7=u.object({schemaVersion:u.literal(1),requirements:u.array(RJ),findings:u.array(xJ),cases:u.array(DJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(TJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(NJ),journeys:u.array(m0).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:le,why:le})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Nu.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:FJ.optional().describe("omit when no app was needed or none was started"),summary:le.describe("one paragraph: what the change does and where the risk is")});var F0=(n=>(n.Backend="backend",n.Ui="ui",n))(F0||{});var Ny=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Ny||{}),MJ=u.object({file:le.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(F0),change:u.nativeEnum(Ny).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:le.describe("the requirement or clause id the change deliberately alters"),line:le.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:le,status:u.nativeEnum(Kn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:le,evidence:le})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:le.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(le).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(ky).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:le.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),run:Ha.optional().describe(`for a file in ${Ya}, 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 ${is}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),_J=u.object({description:le.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(xu).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),test:u.string().optional().describe("the test file that shows it"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(le).optional().describe("the plan's requirement or clause ids it violates")}),A7=u.object({schemaVersion:u.literal(1),tests:u.array(MJ),notWritten:u.array(u.object({case:le,reason:le})).describe("every plan case no test covers, and why"),journeys:u.array(_d).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:le,manifest:le.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:le.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:le.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(le).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"),ciRunsTests:u.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:u.object({message:le.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:le.describe("at most 72 characters"),prBody:le.describe("what the tests cover and what they found")}),report:u.object({summary:le.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(_J).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var l7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var _0=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(_0||{}),yt=u.string().trim().min(1),UJ=u.object({expectation:yt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(_0),expected:yt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),LJ=u.object({file:yt.describe("path of the NEW test file you wrote, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:yt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:Ha.optional().describe(`for ${Ya}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(yt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(yt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(UJ).min(1)}),Fy=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Fy||{}),M0=300,PJ=u.object({file:yt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Fy),staleBecause:u.object({requirement:yt.describe("the requirement or clause id the change deliberately alters"),line:yt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,M0):t,yt.max(M0)).describe("what the change deliberately altered that made the test wrong")}),My=u.object({schemaVersion:u.literal(1),tests:u.array(LJ),maintained:u.array(PJ).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:yt,reason:yt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(_d).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:yt,missing:yt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:yt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var D7=5*6e4;function VJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=es(My,e);return s.length?{errors:s}:{output:r,errors:[]}}function GJ(t){return VJ(t.stdout)}var _ee=Us("generate-unit-schema",(t,e)=>GJ(e));var Gd=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,Uee=[[/\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+["']${Gd}["']|\bimport\s+["']${Gd}["']|require\(\s*["']${Gd}["']\s*\)|\bimport\(\s*["']${Gd}["']\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 L0=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,P0=String.raw`\b(?:not|isn't|aren't|never|no)\s+(?:be\s+)?(?:covered|tested|exercised|verified|checked|walked|executed|run)\b|\buncovered\b|\bunverified\b`,Zee=[new RegExp(`${L0}[^.;\\n]{0,100}(?:${P0})`,"i"),new RegExp(`(?:${P0})[^.;\\n]{0,100}${L0}`,"i")];var Xee=new Set(["targeted_unit","existing_evidence_sufficient"]);var Ote=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),$te={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 JJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=es(Nu,e);return s.length?{errors:s}:{triage:r,errors:[]}}function WJ(t){return JJ(t.stdout)}var Vte=Us("triage-schema",(t,e)=>WJ(e));var Gte=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Dt();Dt();var KJ="Skyramp-Pull-Request",ZJ="Skyramp-Delivery-Base",XJ="Skyramp-Tested-Revision";var cne=["%H","%P","%an","%ae","%ce",`%(trailers:key=${KJ},valueonly,separator=%x2C)`,"%s",`%(trailers:key=${ZJ},valueonly,separator=%x2C)`,`%(trailers:key=${XJ},valueonly,separator=%x2C)`];var O0=Re(require("path"));var bt=u.string().trim().min(1),_y=(n=>(n.TestbotManaged="testbot_managed",n.CustomerDeployed="customer_deployed",n))(_y||{}),Hd=[".skyramp/sut/setup.sh",".skyramp/sut/teardown.sh"],Uy=u.object({schemaVersion:u.literal(1),type:u.nativeEnum(_y).optional(),status:u.enum(["ready","blocked"]),environment:Oa.optional(),components:u.array(u.object({name:bt,repository:bt.describe(`owner/repo, or "${zt}" for a customer-deployed component no repository builds`),healthy:u.boolean(),url:u.string().min(1).nullable(),...hy,credentials:u.array(u.string().regex(La)).max(50).optional(),deployed:bt.nullable().optional().describe("customer_deployed only: the revision the component runs, as setup read it (WF-SETUP-22's Deployed now), or null when it could not tell")}).strict()),suites:u.array(u.object({framework:bt,file:bt,result:u.enum(["pass","fail","error"])}).strict()),inputsUsed:u.array(bt),inputsUsedHow:u.array(u.object({input:bt,how:bt}).strict()).optional(),inputsNotUsed:u.array(u.object({input:bt,reason:bt}).strict()),blockers:u.array(u.object({component:bt,problem:bt,evidence:bt,fix:bt}).strict()),replay:u.object({outcome:bt,durationSeconds:u.number().nonnegative().nullable()}).strict().nullable(),files:u.array(u.object({path:bt,content:u.string()}).strict())}).strict().superRefine((t,e)=>{t.inputsUsedHow?.forEach((s,i)=>{t.inputsUsed.includes(s.input)||e.addIssue({code:u.ZodIssueCode.custom,path:["inputsUsedHow",i,"input"],message:"not one of inputsUsed"})}),t.components.forEach((s,i)=>{s.credentials&&new Set(s.credentials).size!==s.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"credentials"],message:"names a credential twice"})});let n=t.type==="customer_deployed";n!==(t.environment!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment"],message:"an environment exactly when the plan's type is customer_deployed"}),t.environment&&new Set(t.environment.credentials).size!==t.environment.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment","credentials"],message:"names a credential twice"});let r=new Set(t.components.map(s=>s.name));if(t.environment?.revisionSources.forEach((s,i)=>{s.components.forEach((a,c)=>{r.has(a)||e.addIssue({code:u.ZodIssueCode.custom,path:["environment","revisionSources",i,"components",c],message:"not one of components"})})}),t.components.forEach((s,i)=>{s.deployed!==void 0!==n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"deployed"],message:"what a component runs exactly when the plan is customer_deployed"}),s.repository===zt&&!n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"repository"],message:`only a customer_deployed component is ${zt}`})}),n&&(t.components.forEach((s,i)=>{t.components.findIndex(a=>a.name===s.name)!==i&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"name"],message:"names a component twice"})}),t.replay!==null&&e.addIssue({code:u.ZodIssueCode.custom,path:["replay"],message:"a customer_deployed plan is never replayed"}),t.files.forEach((s,i)=>{Hd.includes(s.path)&&e.addIssue({code:u.ZodIssueCode.custom,path:["files",i,"path"],message:"a customer_deployed plan has no script that starts or stops the system"})})),n&&t.status==="ready"){let s=new Set(t.environment?.revisionSources.flatMap(i=>i.components));t.components.forEach((i,a)=>{i.repository!==zt&&!s.has(i.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",a,"name"],message:"a ready customer_deployed plan reads what every component a repository builds runs"})})}});var Lne=["clean","recipe-drift"];function Mu(t){let e=O0.posix.normalize(t);return e===t&&(e===".skyramp/workspace.yml"||e.startsWith(".skyramp/sut/")&&e.length>13)}var qd=(n=>(n.GitHub="github",n.AzureDevOps="azure-devops",n))(qd||{}),Oy=(i=>(i.Trigger="TRIGGER",i.Baseline="BASELINE",i.AuthoritativeRelatedChange="AUTHORITATIVE_RELATED_CHANGE",i.ConfiguredSharedDependency="CONFIGURED_SHARED_DEPENDENCY",i.ManualOverride="MANUAL_OVERRIDE",i))(Oy||{}),Uu=(a=>(a.PullRequest="pull_request",a.ReadyForReview="ready_for_review",a.Schedule="schedule",a.Manual="manual",a.SutSetup="sut_setup",a.RevisionRead="revision_read",a))(Uu||{}),nW=["sut_setup"],rW=["sut_setup","schedule","revision_read"];var jd=(e=>(e.PullRequest="pull_request",e))(jd||{}),Lu=(s=>(s.ModelProvider="model_provider",s.SutAccess="sut_access",s.Skyramp="skyramp",s.Other="other",s))(Lu||{});var Jd=(i=>(i.ReportUploaded="report_uploaded",i.NoReport="no_report",i.Cancelled="cancelled",i.RecipeUploaded="recipe_uploaded",i.RevisionsUploaded="revisions_uploaded",i))(Jd||{}),Z0=(n=>(n.Running="running",n.Ended="ended",n))(Z0||{}),Wd=(p=>(p.TimedOut="timed_out",p.AgentFailed="agent_failed",p.SetupFailed="setup_failed",p.CredentialMissing="credential_missing",p.RunnerLost="runner_lost",p.CheckoutFailed="checkout_failed",p.EnvironmentUnverified="environment_unverified",p.ModelProviderDenied="model_provider_denied",p.ModelProviderUnavailable="model_provider_unavailable",p.RunnerProviderNotReady="runner_provider_not_ready",p))(Wd||{}),$y=(r=>(r.Onboard="onboard",r.Deploy="deploy",r.Recheck="recheck",r))($y||{}),Vy=(n=>(n.Started="started",n.Finished="finished",n))(Vy||{}),Gy=(r=>(r.Passed="passed",r.Failed="failed",r.Skipped="skipped",r))(Gy||{});var Hy=(r=>(r.ChooseCredential="choose_credential",r.FreeText="free_text",r.ChooseSource="choose_source",r))(Hy||{});var zd=(r=>(r.Discover="discover",r.Start="start",r.Check="check",r))(zd||{}),Kd=(s=>(s.ValidationPlan="validation_plan",s.TestEnvironment="test_environment",s.TestConditions="test_conditions",s.Tests="tests",s))(Kd||{}),Pu=(s=>(s.Found="found",s.Starting="starting",s.Up="up",s.OutOfScope="out_of_scope",s))(Pu||{}),Zn=u.string().regex(/^[1-9][0-9]{0,18}$/),as=u.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Ja=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,_t=u.string().regex(Ja),Ut=u.string().regex(/^[0-9a-f]{64}$/),Yd=u.object({id:_t,revision:Zn}).strict(),Zd={provider:u.literal("github"),providerAccountId:Zn,providerRepositoryId:Zn},Xd={provider:u.literal("azure-devops"),providerAccountId:_t,providerRepositoryId:_t},Xn=u.discriminatedUnion("provider",[u.object(Zd).strict(),u.object(Xd).strict()]),Yy=u.discriminatedUnion("provider",[u.object(Zd).passthrough(),u.object(Xd).passthrough()]),go=t=>`${t.provider}:${t.providerRepositoryId}`,$0={namespace:u.string().min(1),name:u.string().min(1)},X0=u.discriminatedUnion("provider",[u.object({...Zd,...$0}).strict(),u.object({...Xd,...$0}).strict()]),V0=u.object({ref:u.string().min(1),revision:as}).strict(),sW=u.object({repository:X0,revision:as,ref:u.string().nullable(),reason:u.nativeEnum(Oy),change:u.object({kind:u.nativeEnum(jd),number:Zn,base:V0.optional()}).strict().nullable(),compareWith:V0.optional()}).strict();function iW(t){if(t.trigger.kind==="revision_read"!=!t.baseline)return t.baseline?"a revision_read run names no baseline":"names its baseline";if(!t.baseline)return null;let{confirmedRunId:e,initialBaselineId:n,sources:r}=t.baseline;if(e!==null&&n!==void 0)return"a run compares with one baseline";let s=t.trigger.kind==="schedule"&&e!==null||n!==void 0;if(!r)return s?"names every source of the snapshot, once":null;if(e===null&&n===void 0)return"a run with no Confirmed Baseline names no baseline sources";let i=new Set(t.sources.map(A=>go(A.repository))),a=new Set(r.map(A=>go(A.repository)));return a.size===r.length&&a.size===i.size&&[...a].every(A=>i.has(A))?null:"names every source of the snapshot, once"}var eT=/^[A-Z][A-Z0-9_]+-[1-9][0-9]*$/,tT=/^[1-9][0-9]{0,18}$/,G0=new RegExp(`${eT.source}|${tT.source}`),H0=/^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+$/,oW=u.union([u.object({source:u.literal("jira"),site:u.string().regex(H0),key:u.string().regex(eT),updated:u.string().datetime(),contentHash:Ut}).strict(),u.object({source:u.literal("confluence"),site:u.string().regex(H0),key:u.string().regex(tT),version:u.number().int().positive(),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),contentHash:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict()]),Y0=u.union([u.literal("jira"),u.literal("confluence")]),aW=u.object({schemaVersion:u.literal(1),items:u.array(u.union([u.object({source:Y0,site:u.string(),key:u.string().regex(G0),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:Y0,site:u.string(),key:u.string().regex(G0),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("read"),version:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict()])),instructions:u.array(u.string()).optional()}).strict(),cW=u.object({schemaVersion:u.literal(1),runId:_t,skyrampOrgId:_t,target:Yd,policy:Yd.nullable(),trigger:u.object({kind:u.nativeEnum(Uu),requestedAt:u.string().datetime()}).strict(),configuration:u.object({captureId:_t,revision:Zn.nullable(),hash:Ut}).strict(),baseline:u.object({confirmedRunId:_t.nullable(),initialBaselineId:_t.optional(),sources:u.array(u.object({repository:Xn,revision:as}).strict()).optional()}).strict().optional(),sources:u.array(sW).min(1),execution:u.object({provider:u.nativeEnum(qd),repository:X0,workflowPath:u.string(),ref:u.string()}).strict(),credentials:u.array(u.object({name:u.string(),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict()),requirements:u.array(oW).min(1).optional(),instructions:u.object({contentHash:Ut}).strict().optional(),deployedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).min(1).optional()}).strict().superRefine((t,e)=>{let n=new Set;(t.requirements??[]).forEach((A,l)=>{let p="fileName"in A?"file":"pasted";A.source==="other"&&A.key!==`${p}-${A.contentHash.slice(0,16)}`&&e.addIssue({code:u.ZodIssueCode.custom,message:"is not the key of its content hash",path:["requirements",l,"key"]});let h=oy({source:A.source,key:A.key});n.has(h)&&e.addIssue({code:u.ZodIssueCode.custom,message:"names an item that the run already names",path:["requirements",l,"key"]}),n.add(h)});let r=t.trigger.kind,s=nW.includes(r);s!==(t.policy===null)&&e.addIssue({code:u.ZodIssueCode.custom,path:["policy"],message:s?`a ${r} run has no policy`:"names the policy revision"});let i=iW(t);i&&e.addIssue({code:u.ZodIssueCode.custom,path:t.baseline?["baseline","sources"]:["baseline"],message:i}),rW.includes(r)&&t.sources.forEach((A,l)=>{A.reason!=="BASELINE"&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"reason"],message:`a ${r} run selects only BASELINE sources`})}),t.deployedRevisions&&r!=="manual"&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions"],message:"only a manual run pins deployed revisions"});let a=new Set(t.sources.map(A=>go(A.repository))),c=new Set;(t.deployedRevisions??[]).forEach((A,l)=>{let p=go(A.repository);a.has(p)?c.has(p)&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"repository appears twice"}):e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"names a repository outside the snapshot"}),c.add(p)}),t.sources.forEach((A,l)=>{A.compareWith&&(A.reason!=="MANUAL_OVERRIDE"||A.change)&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"compareWith"],message:"only a MANUAL_OVERRIDE source without a change names a revision to compare with"})})});var nT=(n=>(n.Person="person",n.Policy="policy",n))(nT||{}),uW=u.object({kind:u.nativeEnum(nT),name:u.string().min(1).max(256)}).strict(),Yne=u.object({schemaVersion:u.literal(1),attempt:u.object({id:_t,number:u.number().int().positive(),deadlineAt:u.string().datetime()}).strict(),manifest:cW,manifestHash:Ut,entitlements:u.array(u.string()).optional(),runToken:u.string().min(1).optional(),requestedBy:uW.nullable().optional(),writeAllowed:u.boolean().optional(),claudeCodeVersion:u.string().regex(/^[0-9]+\.[0-9]+\.[0-9]+$/,"an exact version, such as 2.1.290").nullable().optional(),deployedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).optional(),statedRevisions:u.array(u.object({repository:Xn,revision:as}).strict()).optional()}).strict(),q0={providerRunAttempt:u.number().int().positive(),workflowRef:u.string().min(1)},AW=u.string().regex(/^[^/]+\/[^/]+\/[1-9][0-9]{0,15}\/[1-9][0-9]{0,15}$/),qne=u.object({schemaVersion:u.literal(1),runId:_t,execution:u.discriminatedUnion("provider",[u.object({...q0,provider:u.literal("github"),repository:u.object(Zd).strict(),providerRunId:Zn}).strict(),u.object({...q0,provider:u.literal("azure-devops"),repository:u.object(Xd).strict(),providerRunId:AW}).strict()]),requester:u.literal(!0).optional(),writeCheck:u.literal(!0).optional(),claudeCodePin:u.literal(!0).optional(),deployedPins:u.literal(!0).optional(),statedPins:u.literal(!0).optional()}).strict(),j0=u.object({repository:Xn,number:Zn}).strict(),lW=u.discriminatedUnion("status",[u.object({status:u.literal("none")}).strict(),u.object({status:u.literal("delivered"),pullRequests:u.array(j0).min(1)}).strict(),u.object({status:u.literal("partial"),pullRequests:u.array(j0).min(1),failures:u.array(u.object({repository:Xn,message:u.string()}).strict()).min(1)}).strict(),u.object({status:u.literal("failed"),message:u.string()}).strict()]),dW=u.object({blockedPreflight:u.object({file:u.string().min(1),repository:u.string().min(1).optional(),reason:u.string().min(1).max(300),evidence:u.string().min(1).max(400)}).strict().optional(),sufficiency:u.nativeEnum(Sa),rationale:u.string().min(1),gaps:u.array(u.string().min(1)),acceptedEvidence:u.array(u.object({kind:u.nativeEnum(_s),repository:u.string().min(1),revision:as,reference:u.string().min(1),summary:u.string().min(1)}).strict()),actionRequired:u.array(u.nativeEnum(ka))}).strict().superRefine((t,e)=>{t.sufficiency==="insufficient"!=t.gaps.length>0&&e.addIssue({code:u.ZodIssueCode.custom,path:["gaps"],message:"only insufficient evidence names gaps, and it names at least one"}),new Set(t.actionRequired).size!==t.actionRequired.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["actionRequired"],message:"a reason appears twice"})}),Ly=500,pW=2048,hW=1e3,fW=/[\\/:*?"<>|;#$*{},+=[\]%\p{Cc}\p{Cf}]/u,J0=t=>t.length>0&&t.length<=64&&t===t.trim()&&!fW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith("."),gW=t=>{if(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/.test(t))return!0;let[e,n,r,...s]=t.split("/");return t.length<=201&&s.length===0&&r!==void 0&&/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/.test(e)&&J0(n)&&J0(r)},mW=u.object({testResults:u.array(u.object({resultId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/),repository:u.string().refine(gW,"Invalid"),testType:u.string(),endpoint:u.string(),status:u.enum(["Pass","Fail","Skipped"]),details:u.string(),fileName:u.string().optional(),testId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/).optional(),failureCause:u.object({kind:u.nativeEnum(cy),family:u.nativeEnum(uy).optional()}).strict().optional(),origin:u.nativeEnum(ay).optional()}).strict()),validation:dW,changes:u.array(u.object({id:u.string().min(1).max(512),text:u.string().max(16384),source:u.string().max(pW),testedBy:u.array(u.string().min(1).max(1024)).max(Ly),writtenBy:u.array(u.string().min(1).max(1024)).max(Ly),maintainedBy:u.array(u.string().min(1).max(1024)).max(Ly)}).strict()).max(hW).optional(),traceVersion:u.literal(1)}).passthrough().superRefine((t,e)=>{let n=new Set;t.testResults.forEach((r,s)=>{let i=r.failureCause;i&&r.status==="Pass"&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"a passing result has no failure cause"}),i&&i.kind==="environment"!=(i.family!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"an environment cause names its family, and no other cause does"});let a=["testResults",s,"resultId"],c=r.resultId.slice(`${r.repository}:${r.testType}:`.length);(!r.resultId.startsWith(`${r.repository}:${r.testType}:`)||c===""||c.startsWith("/")||c.startsWith("#"))&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"is not repository:testType:path for this result"}),n.has(r.resultId)&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"stable identity repeated"}),n.add(r.resultId)})});var rT=50,W0=u.string().regex(/^(?!.*\.\.)(?!\/)(?!.*\/$)[A-Za-z0-9._/-]{1,255}$/),sT=u.discriminatedUnion("kind",[u.object({kind:u.literal("branch_pushed"),repository:Xn,branch:W0,commit:as}).strict(),u.object({kind:u.enum(["pull_request_opened","pull_request_edited"]),repository:Xn,number:Zn,branch:W0}).strict()]),yW=u.object({schemaVersion:u.literal(1),run:u.object({runId:_t,attemptNumber:u.number().int().positive(),manifestHash:Ut}).strict(),target:Yd,policy:Yd,provenance:u.object({sources:u.array(u.object({repository:Xn,revision:as}).strict()),firstQualification:u.literal(!0).optional()}).strict(),delivery:u.object({generatedTests:lW}).strict(),producer:u.object({testbot:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/),mcp:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/)}).strict(),report:mW,githubWrites:u.array(sT).max(rT).optional()}).strict(),jne=yW.pick({schemaVersion:!0,run:!0,target:!0,provenance:!0,producer:!0}).extend({recipe:Uy}).strict().superRefine(({recipe:t},e)=>{let n=(i,a)=>e.addIssue({code:u.ZodIssueCode.custom,path:["recipe",...i],message:a});t.status==="blocked"&&t.blockers.length===0&&n(["blockers"],"a blocked recipe names at least one blocker");let r=new Set,s=0;t.files.forEach((i,a)=>{Mu(i.path)||n(["files",a,"path"],"is not .skyramp/workspace.yml or a file under .skyramp/sut/"),r.has(i.path)&&n(["files",a,"path"],"file repeated"),r.add(i.path),fy.test(i.content)&&n(["files",a,"content"],"is not text");let c=Buffer.byteLength(i.content,"utf8");s+=c,c>ku&&n(["files",a,"content"],`larger than ${ku} bytes`)}),s>vu&&n(["files"],`recipe text over ${vu} bytes in total`)}),Jne=u.object({components:u.array(u.object({name:u.string().min(1),repository:u.string().regex(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/),observedRevision:u.string().regex(/^[0-9a-f]{7,64}$/).nullable(),source:u.nativeEnum(Cd),evidence:u.string()}).strict().refine(t=>t.source!=="agent"||t.observedRevision===null,{path:["observedRevision"],message:"a component only an agent session can read names no revision"}))}).strict();var EW=u.object({schemaVersion:u.literal(1),stage:u.nativeEnum($y),event:u.nativeEnum(Vy),status:u.nativeEnum(Gy).optional()}).strict().refine(t=>t.status===void 0||t.event==="finished",{path:["status"],message:"only a finished stage has a status"}),Wa=100,qy=5e3,_u=2e3,Py=100,jy=/^[A-Za-z0-9_-]{1,64}$/,iT=20,oT=200,aT=100,cT=100,CW=200,z0="[^/\\s](?:(?:[^/\\s]| )*[^/\\s])?",IW=new RegExp(`^(?:[^/\\s]+/[^/\\s]+|[^/\\s]+/${z0}/${z0})$`),uT=500,AT=50,Ou=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/,xn=t=>u.string().max(t).refine(e=>e.trim().length>0&&!Ou.test(e),"blank, or not text"),os={sequence:u.number().int().min(1).max(qy),at:u.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?Z$/)},lT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),phase:u.nativeEnum(zd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("component"),name:xn(Py),repository:xn(CW).refine(t=>IW.test(t)||t===zt,"not owner/name"),file:xn(uT).nullable(),status:u.nativeEnum(Pu),version:xn(cT).optional()}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("question"),id:u.string().regex(jy),type:u.nativeEnum(Hy),text:xn(_u),component:xn(Py).nullable(),choices:u.array(xn(oT)).max(iT),placeholder:xn(aT).optional()}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict(),u.object({...os,kind:u.literal("credentials"),names:u.array(u.string().regex(La)).min(1).max(AT)}).strict()]).superRefine((t,e)=>{t.kind==="credentials"&&new Set(t.names).size!==t.names.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["names"],message:"a name twice"}),t.kind==="question"&&(t.type==="free_text"!=(t.choices.length===0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"choices exactly when the question is not free_text"}),new Set(t.choices).size!==t.choices.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"a choice twice"}))}),BW=u.object({schemaVersion:u.literal(1),events:u.array(lT).max(Wa)}).strict(),dT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),stage:u.nativeEnum(Kd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict()]),QW=u.object({schemaVersion:u.literal(1),events:u.array(dT).max(Wa)}).strict(),K0={id:u.string().uuid(),text:u.string(),by:u.string().nullable(),at:u.string(),replied:u.literal(!0).optional()},pT=u.discriminatedUnion("kind",[u.object({...K0,kind:u.literal("instruction"),question:u.null()}),u.object({...K0,kind:u.literal("answer"),question:u.string().regex(jy)})]),hT=u.string().regex(/^[A-Za-z0-9+/]{43}=$/),wW=u.object({id:u.string().uuid(),revision:u.string(),by:u.string().nullable(),at:u.string(),target:u.string(),own:u.object({source:u.enum(["policy","test_environment"]),text:u.string()}).nullable()}),bW=u.object({schemaVersion:u.literal(1),leftOut:u.array(u.string()),messages:u.array(pT).optional(),stop:u.object({key:hT}).optional(),notes:wW.optional()}),SW=u.object({schemaVersion:u.literal(1),messages:u.array(pT).optional()});var fT=500*1024*1024,gT=u.object({id:Zn,name:u.string().regex(/^[A-Za-z0-9._-]{1,200}$/),providerRunId:Zn,expiresAt:u.string().datetime()}).strict(),kW=u.object({schemaVersion:u.literal(1),artifact:gT,sessionId:_t,contentHash:Ut,bytes:u.number().int().min(1).max(fT)}).strict(),vW=u.object({schemaVersion:u.literal(1),checkpoint:u.object({artifact:gT,repository:u.object({namespace:u.string().min(1),name:u.string().min(1)}).strict(),sessionId:_t,contentHash:Ut,key:hT}).strict().nullable()}).strict(),RW=200,ja=100,Jy=(r=>(r.Resume="resume",r.Retry="retry",r.Update="update",r))(Jy||{}),xW=u.object({kind:u.nativeEnum(Jy),setup:u.object({runId:_t,endedAt:u.string().nullable(),outcome:u.string().nullable()}).strict(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1),status:u.nativeEnum(Pu)}).strict()).max(ja),credentials:u.array(u.string().min(1)).max(ja),answers:u.array(u.object({question:u.string(),answer:u.string().nullable()}).strict()).max(ja),instructions:u.array(u.object({text:u.string(),reply:u.string().nullable()}).strict()).max(ja),log:u.array(u.object({phase:u.nativeEnum(zd),text:u.string()}).strict()).max(RW),recipe:u.object({files:u.array(u.object({path:u.string().min(1),content:u.string()}).strict()).max(ja),blockers:u.array(u.object({component:u.string(),problem:u.string(),evidence:u.string(),fix:u.string()}).strict()).max(ja)}).strict().optional()}).strict(),TW=u.object({schemaVersion:u.literal(1),context:xW.nullable()}).strict(),DW=u.object({schemaVersion:u.literal(1),configuration:u.object({captureId:_t,revision:Zn.nullable(),hash:Ut}).strict(),capture:u.object({schemaVersion:u.literal(1),settings:u.object({target:u.object({environment:u.unknown()}).passthrough(),timeoutMinutes:u.number().int().positive(),answerWaitMinutes:u.number().int().positive().optional(),testEnvironment:u.object({name:u.string().min(1),address:u.string().min(1).optional(),readyWhen:u.string().min(1).optional()}).passthrough().optional()}).passthrough(),provenance:u.object({}).passthrough(),hash:Ut}).strict()}).strict(),NW=Oa.extend({version:u.number().int().positive(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1)}).strict()),contentHash:Ut.optional(),files:u.array(u.object({path:u.string().refine(t=>Mu(t)&&!Hd.includes(t),"not a file of a customer_deployed plan"),content:u.string()}).strict()).optional()}).strict(),FW=u.object({schemaVersion:u.literal(1),testEnvironment:NW.nullable().optional(),runtimePlan:u.object({version:u.number().int().positive(),contentHash:Ut,files:u.array(u.object({path:u.string().refine(Mu,"not a recipe file path"),content:u.string()}).strict()).min(1),recipe:u.record(u.unknown()).optional()}).strict().nullable()}).strict().refine(t=>!(t.runtimePlan&&t.testEnvironment),{message:"a run pins a recipe or a customer's Test Environment, never both",path:["testEnvironment"]}),MW=u.object({schemaVersion:u.literal(1),state:u.nativeEnum(Z0),ending:u.nativeEnum(Jd).nullable(),cause:u.nativeEnum(Wd).nullable(),deadlineAt:u.string().datetime()}).strict();function mT(t){return t.reportUploaded?{schemaVersion:1,reason:"report_uploaded",cause:null}:t.recipeUploaded?{schemaVersion:1,reason:"recipe_uploaded",cause:null}:t.revisionsUploaded?{schemaVersion:1,reason:"revisions_uploaded",cause:null}:t.cancelled?{schemaVersion:1,reason:"cancelled",cause:null}:{schemaVersion:1,reason:"no_report",cause:_W(t)}}function _W(t){return t.runnerProviderNotReady?"runner_provider_not_ready":t.credentialMissing?"credential_missing":t.checkoutFailed?"checkout_failed":t.environmentUnverified?"environment_unverified":t.setupFailed?"setup_failed":t.timedOut?"timed_out":t.modelProviderDenied?"model_provider_denied":t.modelProviderUnavailable?"model_provider_unavailable":"agent_failed"}var Zne={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var LW=10*1024*1024;var yT=Re(require("fs")),$u="SKYRAMP_AZURE_SUPERVISED",Wy=3;function ep(t){return t.replace(/##(?=(?:vso)?\[)/gi,"#\u200B#")}function zy(t,e=process.env){e[$u]==="1"?yT.writeSync(Wy,`${JSON.stringify(t)}
121
121
  `):process.stdout.write(t.command!==void 0?`${t.command}
122
122
  `:t.text??"")}function Ky(t){zy({command:t})}function ET(t){return t.replace(/%/g,"%AZP25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function PW(t){return ET(t).replace(/;/g,"%3B").replace(/]/g,"%5D")}function tp(t,e,n){let r=Object.entries(e).map(([s,i])=>`${s}=${PW(i)}`).join(";");return`##vso[${t}${r?` ${r}`:""}]${ET(n)}`}function CT(t){if(!t)return[];let e=t.split(/\r?\n/).filter(n=>n.trim()&&n!==t);return[t,...e].map(n=>tp("task.setsecret",{},n))}function IT(t,e=Ky){for(let n of CT(t))e(n)}function OW(t){return t.replace(/%0D/g,"\r").replace(/%0A/g,`
123
123
  `).replace(/%25/g,"%")}function BT(t){let e=/^::([a-z-]+)(?: [^:]*)?::(.*)$/s.exec(t.replace(/\r?\n$/,""));if(!e)return;let[,n,r]=e,s=OW(r),i=ep(s);switch(n){case"add-mask":return CT(s);case"warning":case"error":return[tp("task.logissue",{type:n},i)];case"notice":return[i];case"debug":return i.split(`