@skyramp/testbot-core 0.13.0-v3.216 → 0.13.0-v3.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VERSION.json +1 -1
- package/dist/main.js +263 -263
- package/dist/post.js +2 -2
- package/dist/runner-client.cjs +1 -1
- package/package.json +1 -1
package/dist/runner-client.cjs
CHANGED
|
@@ -78,7 +78,7 @@ ${l}`,this.dataLineCount++;return}if(Ru(e,s,sY)){AY(e,i)&&(this.setEventFieldSiz
|
|
|
78
78
|
`)){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{}}o(Z0,"mcpServerStatuses");function sE(t){let e=Z0(t).skyramp;return e===void 0||e==="connected"}o(sE,"skyrampConnected");function K0(t){if(!Xr.existsSync(t))return[];let e=[];for(let n of Xr.readFileSync(t,"utf-8").split(`
|
|
79
79
|
`)){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}o(K0,"contentBlocks");var iE=[".skyramp/sut",".skyramp/workspace.yml"];var xq=["--",":/",...iE.map(t=>`:(exclude)${t}`)];var X0=A.object({route:A.string().describe('the page this step happens on, e.g. "/products/:id"'),action:A.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:A.array(A.string()).optional().describe("the plan clause ids this step exercises"),check:A.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),xo=(n=>(n.InProcess="in-process",n.Browser="browser",n))(xo||{}),oE=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(oE||{}),aE=A.object({id:A.string().describe('e.g. "J1"'),name:A.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:A.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:A.array(X0).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:A.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:A.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:A.nativeEnum(xo).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:A.nativeEnum(oE).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:A.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:A.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),wA=A.object({journey:A.string().describe("the plan's journey id"),file:A.string().describe("the browser test file that walks it"),brokeAt:A.object({step:A.number().int().describe("the 1-based step whose check failed first"),expected:A.string(),actual:A.string().describe("what the app did instead, from the runner's output"),notReached:A.array(A.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:A.string().describe("the title of the one test in that file that walks it end to end")});var Hl=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Hl||{}),Do=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(Do||{}),bA=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(bA||{}),cE=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(cE||{}),uE=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(uE||{}),ei=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(ei||{}),Ie=A.string().trim().min(1),ti=Ie.describe("file:line"),AE=o(t=>Ie.refine(e=>e.length<=400,e=>({message:`is ${e.length} characters, over the 400 cap \u2014 ${t}`})),"cap400"),To=Ie.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'),Vl=A.object({method:Ie,path:Ie,service:A.string().optional(),evidence:ti,repository:To}),ex=A.object({id:Ie.describe("short-slug, e.g. R9"),statement:Ie.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:A.nativeEnum(ei).describe("spec outranks pr-description when both state it"),evidence:Ie.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),tx=A.object({id:Ie.describe("short-slug"),statement:Ie.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:Ie.describe("METHOD /path, or a component/page name"),evidence:Ie.describe("file:line from the diff that introduces it"),repository:To,satisfies:A.array(Ie).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)")}),nx=A.object({id:Ie.describe("short-slug"),file:Ie,line:A.number().optional(),claim:AE("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:A.nativeEnum(Do),evidence:AE("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:A.nativeEnum(bA),repository:To,conflictsWith:A.array(Ie).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),rx=A.object({name:Ie,language:A.string().optional(),framework:A.string().optional(),evidence:ti,repository:To}),sx=A.object({dir:Ie,framework:A.string().optional(),kind:A.nativeEnum(cE),evidence:ti,repository:To}),ix=A.object({from:Ie,to:Ie,onDelete:A.nativeEnum(uE),evidence:ti}),ox=A.object({entity:Ie,field:Ie,values:A.array(A.string()),evidence:ti}),ax=A.object({entities:A.array(A.object({name:Ie,evidence:ti})),references:A.array(ix).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:A.array(ox)}),$q=A.object({schemaVersion:A.literal(1),repository:A.object({path:Ie.describe("absolute repo path"),currentBranch:Ie,baseBranch:Ie}),project:A.object({type:A.nativeEnum(Hl),primaryLanguage:Ie,languages:A.array(A.string()),frameworks:A.array(A.string())}),services:A.array(rx),infrastructure:A.object({containerized:A.boolean(),hasDockerCompose:A.boolean(),composeFiles:A.array(A.string()),hasCiCd:A.boolean()}),diff:A.object({changedFiles:A.array(A.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:A.boolean(),summary:Ie.describe("\u2264400 chars")}),endpoints:A.object({new:A.array(Vl),modified:A.array(Vl),removed:A.array(Vl)}),existingTests:A.object({locations:A.array(sx)}),entityMap:ax,requirements:A.array(ex).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:A.array(tx),findings:A.array(nx),unexamined:A.array(A.string()).describe("files or areas outside this change you did not open"),summary:Ie.describe("one paragraph on what this change does and its test-relevant risk")});var RA=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(RA||{}),Ln=A.string().trim().min(1),Ax=A.object({case:Ln.describe("recommend id this assertion enforces"),evidence:Ln.describe("the exact assertion line from the file that checks that case's observable")}),Jl=A.object({kind:A.nativeEnum(cA).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:Ln.describe("the dependency, endpoint or data it affects"),mechanism:A.nativeEnum(uA).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:Ln.describe("what it sets up"),worker:Ln.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:Ln.optional().describe("seed: a command, without a shell, that removes the data when the test does not")}),cx=A.object({file:Ln.describe("staged path under .skyramp/staged/"),source:A.nativeEnum(RA),language:Ln,covers:A.array(A.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:A.array(Ax).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:A.array(Jl).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")}),ql=A.object({schemaVersion:A.literal(1),tests:A.array(cx),deferredUi:A.array(A.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:Ln.describe("one paragraph")});var _n=A.string().trim().min(1),No=72,ux=A.object({repository:_n.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:A.string(),command:A.string().describe("the exact command you ran, scoped to the changed files"),clean:A.boolean(),fixed:A.array(A.string()).optional().describe("files you fixed"),uncovered:A.array(A.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.")}),ej=A.object({schemaVersion:A.literal(1),lint:A.array(ux).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:A.object({ok:A.boolean(),notes:A.string().optional()}),ciReadiness:A.object({covered:A.boolean().describe("will the repo's CI run these tests?"),notes:A.string().optional()}),dependencies:A.object({added:A.array(A.object({package:A.string(),manifest:A.string(),repository:_n.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:_n.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:A.array(A.object({file:_n,repository:_n.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:A.object({message:_n.refine(t=>t.split(`
|
|
80
80
|
`)[0].length<=No,{message:`subject line must be <= ${No} chars`})}),pr:A.object({title:_n.max(No,`must be <= ${No} chars`),body:_n}),ready:A.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:A.array(A.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:_n.describe("one paragraph")});var hr=Ve(require("fs")),si=Ve(require("path")),fE=require("child_process");var zt="{junit}",dE=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(dE||{}),hE=(e=>(e.Minitest="minitest",e))(hE||{}),lE=A.string().trim().min(1),ni=A.object({cwd:lE.describe('repo-relative directory the command starts in ("." for the root)'),argv:A.array(lE).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${zt}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:A.record(A.string(),A.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:A.object({format:A.nativeEnum(dE).describe(`junit (JUnit XML to ${zt}), trx (to ${zt}), or go-test-json (go test -json on the command's output)`),reporter:A.nativeEnum(hE).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 ri="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)",sj=`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 ${zt} in the reporter's argument or env setting), trx (a TRX file to ${zt}, 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 ${zt}: 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 ${zt} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${zt} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${zt} in argv and env with its report path, executes the command, and reads that report.`;var es=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(es||{}),dr=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(dr||{}),Wl=(n=>(n.Repository="repository",n.Testbot="testbot",n))(Wl||{}),zl=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(zl||{}),dt=A.string().trim().min(1),lx=A.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var dx=A.object({id:lx,source:A.nativeEnum(Wl),kind:A.nativeEnum(or),outcome:A.nativeEnum(zl),summary:dt.max(400).describe("one line: what it shows"),tests:A.array(dt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:dt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:dt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:ni.optional().describe(`source repository, for tests in ${ri}: 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`)}),hx=A.object({behaviorId:dt.describe("an id from analyze's behaviors"),mechanism:A.nativeEnum(dr),evidenceIds:A.array(dt).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:A.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')}),gx=A.object({behaviorId:A.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:dt.max(600).describe("the evidence that is required and cannot be obtained in this run")}),px=A.object({file:dt.describe("the changed file the failure is in"),repository:dt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:dt.max(300).describe("what prerequisite the change fails"),evidence:dt.max(400).describe("the error line, quoted")}),fx=A.object({behaviorId:dt.describe("an id from analyze's behaviors"),reason:dt.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),Fo=A.object({schemaVersion:A.literal(1),decision:A.nativeEnum(es),evidence:A.array(dx).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:A.array(hx).describe("how each changed behavior's evidence is obtained"),gaps:A.array(gx),outOfScope:A.array(fx).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:px.optional().describe("only for blocked_preflight"),rationale:dt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function SA(t){let e=jt(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()}:{}}))}}o(SA,"readRecommend");function Ix(t){return Mn(ql,t).errors}o(Ix,"validateGenerateOutput");function yx(t,e=[]){let{value:n,error:r}=_t(t,e);if(r)return{errors:[r]};let s=Ix(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}o(yx,"parseGenerateText");function vA(t,e=[]){return yx(t.stdout,e)}o(vA,"parseGenerateFromSession");function Qx(t){return t.generate.filter(e=>e.type!=="ui").map(e=>e.id)}o(Qx,"backendCases");function mE(t){return t.generate.filter(e=>e.type==="ui").map(e=>e.id)}o(mE,"uiCases");var xA={backend:{stage:"generate",cases:Qx,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:o(t=>`recommend case "${t}" is not covered by any generated test`,"uncovered"),unknownCovered:o(t=>`test covers unknown recommend id "${t}"`,"unknownCovered"),unasserted:o(t=>`case "${t}" has no verified assertion enforcing its expected_observable`,"unasserted"),usedCodegen:nE,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:mE,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:o(t=>`UI case "${t}" is not covered by any generated UI test`,"uncovered"),unknownCovered:o(t=>`test covers "${t}" which is not a recommend UI case`,"unknownCovered"),unasserted:o(t=>`UI case "${t}" has no verified assertion enforcing its expected_observable`,"unasserted"),usedCodegen:rE,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."}},Oj=cr("generate-schema",(t,e)=>vA(e,t.secretValues));function Bx(t){let e=xA[t];return{name:`${e.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=vA(r,n.secretValues);if(!s)return lt(this.name,i);let a=SA(n);if(!a)return lt(this.name,[e.noRecommendCoverage]);let c=new Set(s.tests.flatMap(g=>g.covers)),l=[],d=e.cases(a);for(let g of d)c.has(g)||l.push(e.uncovered(g));let h=new Set(t==="ui"?d:a.generate.map(g=>g.id));for(let g of c)h.has(g)||l.push(e.unknownCovered(g));if(t==="backend"){let g=new Set(s.deferredUi),f=new Set(mE(a));for(let m of f)!g.has(m)&&!c.has(m)&&l.push(`UI case "${m}" is neither covered nor deferred to the UI stage`);for(let m of g)f.has(m)||l.push(`deferredUi lists "${m}" which is not a UI case`)}return l.length===0?{name:this.name,passed:!0}:lt(this.name,l)}}}o(Bx,"generateCoverageGateFor");function wx(t){let e=xA[t];return{name:`${e.stage}-intent`,verify(n,r){let{generate:s,errors:i}=vA(r,n.secretValues);if(!s)return lt(this.name,i);let a=SA(n);if(!a)return lt(this.name,[e.noRecommendIntent]);let{asserted:c,errors:l,badFiles:d}=Dx(s,n.inputs.repositoryPath),h=l.length;for(let f of e.cases(a))c.has(f)||l.push(e.unasserted(f));if(l.length===0)return{name:this.name,passed:!0};let g=lt(this.name,l);return h>0&&h===l.length&&d.size>0?{...g,droppable:[...d]}:g}}}o(wx,"generateIntentGateFor");function bx(t){let e=xA[t];return n=>{if(!n.inputs.skyrampMcp?.command||t==="backend"&&!Gl(n))return;let r=si.join(n.outputsDir,`${e.stage}-stream.ndjson`);if(!(!hr.existsSync(r)||e.usedCodegen(r)))return sE(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."}}o(bx,"codegenRetryHintFor");var Gj=Bx("backend"),$j=wx("backend"),Yj=bx("backend");var pE=o(t=>t.replace(/\s+/g,""),"squeeze");var Zl={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"]])Zl[t]=Zl[e];function Rx(t,e){if(t.includes(wo(e))||pE(t).includes(pE(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(wo(r)))?!0:xx(t,e)}o(Rx,"evidenceFound");var kx=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,Sx=12,vx=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function xx(t,e){let n=e.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=kx.exec(s);if(!i)continue;let a=s.slice(i.index),c=vx.exec(a);if(c&&(a=a.slice(0,c.index)),a=wo(a).replace(/[,\s]+$/,""),a.length<Sx||!t.includes(a))return!1;r++}return r>0}o(xx,"annotatedAssertionFound");function Dx(t,e){let n=new Set,r=[],s=new Set;for(let i of t.tests){let a=si.resolve(e,i.file);if(!hr.existsSync(a))continue;let c=wo(hr.readFileSync(a,"utf-8"));for(let l of i.assertions??[]){if(!Rx(c,l.evidence)){r.push(`assertion evidence for "${l.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(l.case)?n.add(l.case):(r.push(`assertion cites case "${l.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}o(Dx,"verifiedAssertions");var Tx=/\.(spec|test)\.[cm]?[jt]sx?$/i;function EE(t){let e;try{e=(0,fE.execFileSync)("git",[...yA,"status","--porcelain","--untracked-files=all"],{env:Un(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=o(s=>/_scaffold/i.test(s)||CA.test(s),"isTestLitter"),r=[];for(let s of e.split(`
|
|
81
|
-
`)){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}o(EE,"testLitter");function Nx(t){let e=xA[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=EE(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>Tx.test(a)===n);return i.length===0?{name:this.name,passed:!0}:lt(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(", ")}`])}}}o(Nx,"noLitterGateFor");var Vj=Nx("backend");var Uo=Ve(require("fs")),ts=Ve(require("path"));function yE(t){return Mn($l,t).errors}o(yE,"validateAdaptOutput");function Mx(t,e=[]){let{value:n,error:r}=_t(t,e);if(r)return{errors:[r]};let s=yE(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(Mx,"parseAdaptText");var Lx="adapt-scratch",CE=`${Lx}/adapt-result.json`;function QE(t,e){let n=ts.join(t.outputsDir,CE),r;try{r=Uo.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${CE} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Mx(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?js(n):void 0;return i!==void 0&&yE(i).length===0?{adapt:i,errors:[]}:s}o(QE,"parseAdaptFromSession");var gW=cr("adapt-schema",QE);var wW=2*1024*1024;var ne=A.string().trim().min(1),Px=o(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},"skippedNeedsNoExpected"),Ox=A.preprocess(Px,A.object({id:ne.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:ne.describe("one testable part of the requirement"),expected:ne.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:A.string().optional().describe("only when no test can check this clause here: why"),type:A.nativeEnum(ur).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:A.string().optional().describe('its "METHOD /path", or the page / flow'),steps:A.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:A.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:A.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:A.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:A.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:A.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)")})),Gx=A.object({id:ne.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:ne,source:A.nativeEnum(ei).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:A.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:ne.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:A.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:A.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:A.array(A.object({spec:A.string().optional().describe("file:line of the spec in the repository; leave it out for a PR description"),prDescription:A.boolean().optional().describe("true when a pull request description says otherwise"),says:ne.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:A.array(Ox)}),BE=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(BE||{}),$x=A.object({id:ne.describe('e.g. "F1"'),file:ne,line:A.number().optional(),claim:ne.describe("the defect, in one sentence"),severity:A.nativeEnum(Do),evidence:ne.describe("the code line, or the probe request and response, that shows it"),conflictsWith:A.array(ne).optional().describe("requirement or clause ids it violates"),keeps:A.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:A.nativeEnum(BE).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:A.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:A.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)")}),Yx=A.object({id:ne.describe('e.g. "Q1"'),question:ne.describe("what is unsettled, as a question the PR author can answer"),readings:A.array(ne).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:A.string().optional().describe("the requirement or clause id it is about, when there is one")}),Vx=A.object({id:ne.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:A.nativeEnum(ur).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:ne.describe('"METHOD /path", or the page / flow'),clause:A.string().optional().describe("the clause id this case checks"),finding:A.string().optional().describe("the finding id this case catches"),steps:ne.describe("what the test does"),expected:ne.describe("the expected outcome, from the clause"),mutates:A.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")}),Hx=A.object({test:ne.describe("existing test file"),action:A.nativeEnum(Kr),reason:ne,mutates:A.boolean().optional().describe("true when the maintained test changes state"),clauses:A.array(ne).optional().describe("the clause ids this test checks")}),Jx=A.object({outcome:A.nativeEnum(Ar).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:A.record(A.string()).optional().describe("service \u2192 base URL of the running app"),health:A.object({url:A.string().optional(),command:A.string().optional(),output:A.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:A.string().optional().describe("command that stops the app"),dependencies:A.record(A.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:A.array(A.string()).optional().describe("what you changed in the recipe"),error:A.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:A.array(A.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:A.object({username:ne,password:A.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:Ku.optional()}),nz=A.object({schemaVersion:A.literal(1),requirements:A.array(Gx),findings:A.array($x),cases:A.array(Vx).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:A.array(Yx).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:A.array(Hx),journeys:A.array(aE).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:A.array(A.object({clause:ne,why:ne})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Fo.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:Jx.optional().describe("omit when no app was needed or none was started"),summary:ne.describe("one paragraph: what the change does and where the risk is")});var wE=(n=>(n.Backend="backend",n.Ui="ui",n))(wE||{});var Kl=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Kl||{}),qx=A.object({file:ne.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:A.nativeEnum(wE),change:A.nativeEnum(Kl).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:A.array(A.string()).describe("the plan case ids this file tests"),defect:A.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:A.object({requirement:ne.describe("the requirement or clause id the change deliberately alters"),line:ne.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:A.object({exit:A.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:A.array(A.object({case:ne,status:A.nativeEnum(Wt),defect:A.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:A.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:A.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:A.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:A.string().optional().describe("what failed and why, or why it was not run")}),assertions:A.array(A.object({case:ne,evidence:ne})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:A.array(A.object({name:ne.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:A.array(ne).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:A.object({draft:A.union([A.string(),A.array(A.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:A.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:A.array(Jl).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:ne.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:ni.optional().describe(`for a file in ${ri}, 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 ${zt}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),jx=A.object({description:ne.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:A.nativeEnum(Do).optional(),sourceFile:A.string().optional().describe("the app file at fault"),sourceLine:A.number().optional(),test:A.string().optional().describe("the test file that shows it"),finding:A.string().optional().describe("the plan's finding id, when it is one"),requirements:A.array(ne).optional().describe("the plan's requirement or clause ids it violates")}),rz=A.object({schemaVersion:A.literal(1),tests:A.array(qx),notWritten:A.array(A.object({case:ne,reason:ne})).describe("every plan case no test covers, and why"),journeys:A.array(wA).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:A.object({command:A.string(),clean:A.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:A.array(A.object({package:ne,manifest:ne.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:ne.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:ne.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:A.array(ne).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:A.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:A.object({message:ne.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:ne.describe("at most 72 characters"),prBody:ne.describe("what the tests cover and what they found")}),report:A.object({summary:ne.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:A.array(jx).describe("every defect the tests found"),nextSteps:A.array(A.string())})});var sz={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var RE=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(RE||{}),Je=A.string().trim().min(1),Wx=A.object({expectation:Je.max(300).describe("the behavior this assertion pins, in words"),source:A.nativeEnum(RE),expected:Je.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),zx=A.object({file:Je.describe("path of the NEW test file you wrote, relative to its repository"),repository:Je.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:Je.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:ni.optional().describe(`for ${ri}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:A.array(Je).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:A.array(Je).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:A.array(Wx).min(1)}),Xl=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Xl||{}),bE=300,Zx=A.object({file:Je.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:Je.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:A.nativeEnum(Xl),staleBecause:A.object({requirement:Je.describe("the requirement or clause id the change deliberately alters"),line:Je.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:A.preprocess(t=>typeof t=="string"?t.trim().slice(0,bE):t,Je.max(bE)).describe("what the change deliberately altered that made the test wrong")}),ed=A.object({schemaVersion:A.literal(1),tests:A.array(zx),maintained:A.array(Zx).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:A.array(A.object({id:Je,reason:Je.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:A.array(wA).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:A.array(A.object({journey:Je,missing:Je.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:A.object({command:A.string(),clean:A.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:Je.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var vz=5*6e4;function eD(t){let{value:e,error:n}=_t(t);if(n)return{errors:[n]};let{value:r,errors:s}=Mn(ed,e);return s.length?{errors:s}:{output:r,errors:[]}}o(eD,"parseGenerateUnitText");function tD(t){return eD(t.stdout)}o(tD,"parseGenerateUnitFromSession");var _9=cr("generate-unit-schema",(t,e)=>tD(e));var DA=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,P9=[[/\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+["']${DA}["']|\bimport\s+["']${DA}["']|require\(\s*["']${DA}["']\s*\)|\bimport\(\s*["']${DA}["']\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 SE=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,vE=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`,nZ=[new RegExp(`${SE}[^.;\\n]{0,100}(?:${vE})`,"i"),new RegExp(`(?:${vE})[^.;\\n]{0,100}${SE}`,"i")];var rZ=new Set(["targeted_unit","existing_evidence_sufficient"]);var JZ=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),qZ={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 iD(t){let{value:e,error:n}=_t(t);if(n)return{errors:[n]};let{value:r,errors:s}=Mn(Fo,e);return s.length?{errors:s}:{triage:r,errors:[]}}o(iD,"parseTriageText");function oD(t){return iD(t.stdout)}o(oD,"parseTriageFromSession");var jZ=cr("triage-schema",(t,e)=>oD(e));var WZ=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var xE=Ve(require("fs"));var aD="SKYRAMP_AZURE_SUPERVISED",AD=3;function cD(t,e=process.env){e[aD]==="1"?xE.writeSync(AD,`${JSON.stringify(t)}
|
|
81
|
+
`)){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}o(EE,"testLitter");function Nx(t){let e=xA[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=EE(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>Tx.test(a)===n);return i.length===0?{name:this.name,passed:!0}:lt(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(", ")}`])}}}o(Nx,"noLitterGateFor");var Vj=Nx("backend");var Uo=Ve(require("fs")),ts=Ve(require("path"));function yE(t){return Mn($l,t).errors}o(yE,"validateAdaptOutput");function Mx(t,e=[]){let{value:n,error:r}=_t(t,e);if(r)return{errors:[r]};let s=yE(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}o(Mx,"parseAdaptText");var Lx="adapt-scratch",CE=`${Lx}/adapt-result.json`;function QE(t,e){let n=ts.join(t.outputsDir,CE),r;try{r=Uo.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${CE} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Mx(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?js(n):void 0;return i!==void 0&&yE(i).length===0?{adapt:i,errors:[]}:s}o(QE,"parseAdaptFromSession");var gW=cr("adapt-schema",QE);var wW=2*1024*1024;var ne=A.string().trim().min(1),Px=o(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},"skippedNeedsNoExpected"),Ox=A.preprocess(Px,A.object({id:ne.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:ne.describe("one testable part of the requirement"),expected:ne.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:A.string().optional().describe("only when no test can check this clause here: why"),type:A.nativeEnum(ur).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:A.string().optional().describe('its "METHOD /path", or the page / flow'),steps:A.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:A.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:A.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:A.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:A.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:A.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)")})),Gx=A.object({id:ne.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:ne,source:A.nativeEnum(ei).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:A.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:ne.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:A.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:A.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:A.array(A.object({spec:A.string().optional().describe("file:line of the spec in the repository; leave it out for a PR description"),prDescription:A.boolean().optional().describe("true when a pull request description says otherwise"),says:ne.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:A.array(Ox)}),BE=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(BE||{}),$x=A.object({id:ne.describe('e.g. "F1"'),file:ne,line:A.number().optional(),claim:ne.describe("the defect, in one sentence"),severity:A.nativeEnum(Do),evidence:ne.describe("the code line, or the probe request and response, that shows it"),conflictsWith:A.array(ne).optional().describe("requirement or clause ids it violates"),keeps:A.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:A.nativeEnum(BE).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:A.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:A.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)")}),Yx=A.object({id:ne.describe('e.g. "Q1"'),question:ne.describe("what is unsettled, as a question the PR author can answer"),readings:A.array(ne).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:A.string().optional().describe("the requirement or clause id it is about, when there is one")}),Vx=A.object({id:ne.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:A.nativeEnum(ur).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:ne.describe('"METHOD /path", or the page / flow'),clause:A.string().optional().describe("the clause id this case checks"),finding:A.string().optional().describe("the finding id this case catches"),steps:ne.describe("what the test does"),expected:ne.describe("the expected outcome, from the clause"),mutates:A.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")}),Hx=A.object({test:ne.describe("existing test file"),action:A.nativeEnum(Kr),reason:ne,mutates:A.boolean().optional().describe("true when the maintained test changes state"),clauses:A.array(ne).optional().describe("the clause ids this test checks")}),Jx=A.object({outcome:A.nativeEnum(Ar).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:A.record(A.string()).optional().describe("service \u2192 base URL of the running app"),health:A.object({url:A.string().optional(),command:A.string().optional(),output:A.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:A.string().optional().describe("command that stops the app"),dependencies:A.record(A.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:A.array(A.string()).optional().describe("what you changed in the recipe"),error:A.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:A.array(A.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:A.object({username:ne,password:A.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:Ku.optional()}),nz=A.object({schemaVersion:A.literal(1),requirements:A.array(Gx),findings:A.array($x),cases:A.array(Vx).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:A.array(Yx).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:A.array(Hx),journeys:A.array(aE).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:A.array(A.object({clause:ne,why:ne})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Fo.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:Jx.optional().describe("omit when no app was needed or none was started"),summary:ne.describe("one paragraph: what the change does and where the risk is")});var wE=(n=>(n.Backend="backend",n.Ui="ui",n))(wE||{});var Kl=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Kl||{}),qx=A.object({file:ne.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:A.nativeEnum(wE),change:A.nativeEnum(Kl).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:A.array(A.string()).describe("the plan case ids this file tests"),defect:A.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:A.object({requirement:ne.describe("the requirement or clause id the change deliberately alters"),line:ne.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:A.object({exit:A.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:A.array(A.object({case:ne,status:A.nativeEnum(Wt),defect:A.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:A.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:A.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:A.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:A.string().optional().describe("what failed and why, or why it was not run")}),assertions:A.array(A.object({case:ne,evidence:ne})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:A.array(A.object({name:ne.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:A.array(ne).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:A.object({draft:A.union([A.string(),A.array(A.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:A.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:A.array(Jl).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:ne.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:ni.optional().describe(`for a file in ${ri}, 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 ${zt}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),jx=A.object({description:ne.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:A.nativeEnum(Do).optional(),sourceFile:A.string().optional().describe("the app file at fault"),sourceLine:A.number().optional(),test:A.string().optional().describe("the test file that shows it"),finding:A.string().optional().describe("the plan's finding id, when it is one"),requirements:A.array(ne).optional().describe("the plan's requirement or clause ids it violates")}),rz=A.object({schemaVersion:A.literal(1),tests:A.array(qx),notWritten:A.array(A.object({case:ne,reason:ne})).describe("every plan case no test covers, and why"),journeys:A.array(wA).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:A.object({command:A.string(),clean:A.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:A.array(A.object({package:ne,manifest:ne.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:ne.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:ne.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:A.array(ne).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:A.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),ciNotes:A.string().optional().describe("when ciRunsTests is false: which of your tests the repo's CI will not collect, why, and the exact change the author must make for CI to run them"),commit:A.object({message:ne.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:ne.describe("at most 72 characters"),prBody:ne.describe("what the tests cover and what they found")}),report:A.object({summary:ne.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:A.array(jx).describe("every defect the tests found"),nextSteps:A.array(A.string())})});var sz={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var RE=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(RE||{}),Je=A.string().trim().min(1),Wx=A.object({expectation:Je.max(300).describe("the behavior this assertion pins, in words"),source:A.nativeEnum(RE),expected:Je.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),zx=A.object({file:Je.describe("path of the NEW test file you wrote, relative to its repository"),repository:Je.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:Je.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:ni.optional().describe(`for ${ri}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:A.array(Je).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:A.array(Je).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:A.array(Wx).min(1)}),Xl=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Xl||{}),bE=300,Zx=A.object({file:Je.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:Je.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:A.nativeEnum(Xl),staleBecause:A.object({requirement:Je.describe("the requirement or clause id the change deliberately alters"),line:Je.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:A.preprocess(t=>typeof t=="string"?t.trim().slice(0,bE):t,Je.max(bE)).describe("what the change deliberately altered that made the test wrong")}),ed=A.object({schemaVersion:A.literal(1),tests:A.array(zx),maintained:A.array(Zx).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:A.array(A.object({id:Je,reason:Je.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:A.array(wA).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:A.array(A.object({journey:Je,missing:Je.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:A.object({command:A.string(),clean:A.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:Je.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var vz=5*6e4;function eD(t){let{value:e,error:n}=_t(t);if(n)return{errors:[n]};let{value:r,errors:s}=Mn(ed,e);return s.length?{errors:s}:{output:r,errors:[]}}o(eD,"parseGenerateUnitText");function tD(t){return eD(t.stdout)}o(tD,"parseGenerateUnitFromSession");var _9=cr("generate-unit-schema",(t,e)=>tD(e));var DA=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,P9=[[/\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+["']${DA}["']|\bimport\s+["']${DA}["']|require\(\s*["']${DA}["']\s*\)|\bimport\(\s*["']${DA}["']\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 SE=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,vE=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`,nZ=[new RegExp(`${SE}[^.;\\n]{0,100}(?:${vE})`,"i"),new RegExp(`(?:${vE})[^.;\\n]{0,100}${SE}`,"i")];var rZ=new Set(["targeted_unit","existing_evidence_sufficient"]);var JZ=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),qZ={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 iD(t){let{value:e,error:n}=_t(t);if(n)return{errors:[n]};let{value:r,errors:s}=Mn(Fo,e);return s.length?{errors:s}:{triage:r,errors:[]}}o(iD,"parseTriageText");function oD(t){return iD(t.stdout)}o(oD,"parseTriageFromSession");var jZ=cr("triage-schema",(t,e)=>oD(e));var WZ=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);var xE=Ve(require("fs"));var aD="SKYRAMP_AZURE_SUPERVISED",AD=3;function cD(t,e=process.env){e[aD]==="1"?xE.writeSync(AD,`${JSON.stringify(t)}
|
|
82
82
|
`):process.stdout.write(t.command!==void 0?`${t.command}
|
|
83
83
|
`:t.text??"")}o(cD,"writeFrame");function uD(t){cD({command:t})}o(uD,"writeAzureCommand");function DE(t){return t.replace(/%/g,"%AZP25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}o(DE,"escapeData");function lD(t){return DE(t).replace(/;/g,"%3B").replace(/]/g,"%5D")}o(lD,"escapeProperty");function dD(t,e,n){let r=Object.entries(e).map(([s,i])=>`${s}=${lD(i)}`).join(";");return`##vso[${t}${r?` ${r}`:""}]${DE(n)}`}o(dD,"vsoCommand");function hD(t){if(!t)return[];let e=t.split(/\r?\n/).filter(n=>n.trim()&&n!==t);return[t,...e].map(n=>dD("task.setsecret",{},n))}o(hD,"setSecretLines");function TE(t,e=uD){for(let n of hD(t))e(n)}o(TE,"azureSetSecret");function Lo(t){return t.replace(/\/+$/,"")}o(Lo,"withoutTrailingSlash");function td(t){let e=new URL(t),n=e.pathname.split("/").filter(Boolean);if(n.length)return decodeURIComponent(n[n.length-1]);if(e.hostname.endsWith(".visualstudio.com"))return e.hostname.split(".")[0];throw new Error(`SYSTEM_COLLECTIONURI "${t}" names no organization`)}o(td,"azureOrganization");var gD=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/,pD=/[\\/:*?"<>|;#${},+=[\]%\p{Cc}\p{Cf}]/u;function NE(t){return t.length>0&&t.length<=64&&t===t.trim()&&!pD.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith(".")}o(NE,"isName");function TA(t){return nd(`${t.namespace}/${t.name}`)}o(TA,"azureRepositoryOfSource");function nd(t){let e=t.indexOf("/"),n=t.lastIndexOf("/"),r=t.slice(0,e),s=t.slice(e+1,n),i=t.slice(n+1);if(e<0||e===n||!gD.test(r)||!NE(s)||!NE(i))throw new Error(`"${t}" is not an Azure DevOps organization/project/repository`);return{organization:r,project:s,name:i}}o(nd,"azureRepositoryOf");function FE(t,e){let n=td(t);if(n.toLowerCase()!==e.organization.toLowerCase())throw new Error(`${e.organization}/${e.project}/${e.name} is not in ${n}, the Azure DevOps organization this job runs in`)}o(FE,"inOrganization");function UE(t,e){return FE(t,e),`${Lo(t)}/${encodeURIComponent(e.project)}/_git/${encodeURIComponent(e.name)}`}o(UE,"azureCloneUrl");function rd(t,e){return FE(t,e),`${Lo(t)}/${encodeURIComponent(e.project)}/_apis/git/repositories/${encodeURIComponent(e.name)}`}o(rd,"azureRepositoryApi");var fD="7.1",Mo=class extends Error{constructor(n,r){super(n);this.status=r}status;static{o(this,"AzureRestError")}};async function sd(t){let e=t.accept??"application/json",n=new URL(t.url);n.searchParams.has("api-version")||n.searchParams.set("api-version",fD);let r=await(t.fetch??fetch)(n.toString(),{method:t.method??"GET",headers:{Authorization:`Bearer ${t.token}`,Accept:e,...t.body!==void 0?{"Content-Type":"application/json"}:{}},...t.body!==void 0?{body:JSON.stringify(t.body)}:{},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!r.ok){let s=(await r.json().catch(()=>({}))).message;throw new Mo(`Azure DevOps answered ${r.status}${typeof s=="string"?`: ${s}`:""}`,r.status)}return e!=="application/json"?Buffer.from(await r.arrayBuffer()):r.status===204?{}:await r.json()}o(sd,"azureRest");function mD(t){return`AUTHORIZATION: bearer ${t}`}o(mD,"azureGitAuthorization");function ME(t,e){return{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${Lo(t)}/.extraheader`,GIT_CONFIG_VALUE_0:mD(e)}}o(ME,"azureGitAuthEnv");var ED="7.1-preview.1",CD=".azure-pipelines/skyramp-testbot-v3.yml";function id(t){return t.GITHUB_ACTIONS!=="true"&&/^true$/i.test(t.TF_BUILD??"")}o(id,"isAzurePipelines");function PE(t,e={}){let n=o(g=>{let f=t[g];if(!f)throw new Error(`${g} is not set; the V3 runner handshake needs it`);return f},"read"),r=Lo(t.SYSTEM_COLLECTIONURI??""),s=o(()=>td(n("SYSTEM_COLLECTIONURI")),"organization"),i=t.SYSTEM_TEAMPROJECT,a=t.BUILD_REPOSITORY_NAME,c=t.BUILD_REPOSITORY_ID?.toLowerCase(),l=t.SYSTEM_ACCESSTOKEN,d=e.mask??(g=>TE(g)),h=o(g=>async()=>{if(!g)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_OIDCREQUESTURI to $(System.OidcRequestUri).");if(!l)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_ACCESSTOKEN to $(System.AccessToken).");let f=new URL(g);if(f.protocol!=="https:")throw new Error("SYSTEM_OIDCREQUESTURI is not an https URL");f.searchParams.set("api-version",ED);let m=await(e.fetch??fetch)(f.toString(),{method:"POST",headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/json",Accept:"application/json"},body:"{}",redirect:"error",signal:AbortSignal.timeout(3e4)});if(!m.ok)throw new Error(`Azure DevOps refused the OIDC token request: ${m.status}`);let C=(await m.json().catch(()=>({}))).oidcToken;if(typeof C!="string"||!C)throw new Error("Azure DevOps's OIDC token response carried no token");return d(C),C},"mint");return{runnerPlatform:id(t)?"azure":void 0,workspace:t.BUILD_SOURCESDIRECTORY||void 0,serverUrl:r,apiUrl:r,repository:c&&i&&a&&r?{id:c,slug:`${s()}/${i}/${a}`}:void 0,runId:t.BUILD_BUILDID||void 0,runAttempt:t.SYSTEM_STAGEATTEMPT||void 0,job:t.SYSTEM_JOBNAME||void 0,execution(){let g=n("SYSTEM_STAGEATTEMPT");if(!/^[1-9][0-9]*$/.test(g))throw new Error(`SYSTEM_STAGEATTEMPT is "${g}", not a positive whole number`);let f=n("SYSTEM_COLLECTIONID").toLowerCase();if(!qs.test(f))throw new Error(`SYSTEM_COLLECTIONID is "${f}", not a GUID`);let m=n("BUILD_REPOSITORY_ID").toLowerCase();if(!qs.test(m))throw new Error(`BUILD_REPOSITORY_ID is "${m}", not a GUID`);let C=[s(),n("SYSTEM_TEAMPROJECT"),n("SYSTEM_DEFINITIONID"),n("BUILD_BUILDID")].map(encodeURIComponent).join("/");return{provider:"azure-devops",repository:{provider:"azure-devops",providerAccountId:f,providerRepositoryId:m},providerRunId:C,providerRunAttempt:Number(g),workflowRef:`${CD}@${n("BUILD_SOURCEBRANCH")}`}},takeIdToken(){let g=t.SYSTEM_OIDCREQUESTURI;delete t.SYSTEM_OIDCREQUESTURI;let f=h(g);return()=>f()},takeSourceToken(){return delete t.SYSTEM_ACCESSTOKEN,l||void 0},webIdentity(){if(!t.SYSTEM_OIDCREQUESTURI?.trim()||!l)return;let g=h(t.SYSTEM_OIDCREQUESTURI);return{token:o(()=>g(),"token"),runId:t.BUILD_BUILDID}},v3RunsOnly:!0,assumesBedrockRole:!0,namesSourceToMcp:!0,checkSourceName(g){TA(g)},cloneUrl(g){return UE(r,TA(g))},gitAuthEnv(g){return ME(r,g)},async pullRequest(g,f,m){let C=await sd({token:await m.token(),url:`${rd(r,TA(g))}/pullrequests/${f}`,fetch:m.fetch}),y=C.status==="completed";return{...typeof C.title=="string"?{title:C.title}:{},...typeof C.description=="string"?{body:C.description}:{},...typeof C.status=="string"?{merged:y}:{},...y&&typeof C.lastMergeCommit?.commitId=="string"?{mergeCommit:C.lastMergeCommit.commitId}:{},...y&&typeof C.lastMergeSourceCommit?.commitId=="string"?{mergedHead:C.lastMergeSourceCommit.commitId}:{}}},async commit(g,f,m){let C;try{C=rd(r,nd(g))}catch{return{lookup:"unknown"}}try{let y=await sd({token:await m.token(),url:`${C}/commits/${encodeURIComponent(f)}`,fetch:m.fetch});return typeof y.commitId=="string"?{sha:y.commitId}:{lookup:"missing"}}catch(y){return{lookup:y instanceof Mo&&(y.status===404||y.status===400)?"missing":"unknown"}}}}}o(PE,"azureRunnerHost");var GE=Ve(require("os"),1);function _o(t){return t==null?"":typeof t=="string"||t instanceof String?t:JSON.stringify(t)}o(_o,"toCommandValue");function ad(t,e,n){let r=new od(t,e,n);process.stdout.write(r.toString()+GE.EOL)}o(ad,"issueCommand");var OE="::",od=class{static{o(this,"Command")}constructor(e,n,r){e||(e="missing.command"),this.command=e,this.properties=n,this.message=r}toString(){let e=OE+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let n=!0;for(let r in this.properties)if(this.properties.hasOwnProperty(r)){let s=this.properties[r];s&&(n?n=!1:e+=",",e+=`${r}=${yD(s)}`)}}return e+=`${OE}${ID(this.message)}`,e}};function ID(t){return _o(t).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}o(ID,"escapeData");function yD(t){return _o(t).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}o(yD,"escapeProperty");var Ya=Ve(require("http"),1),Pp=Ve(require("https"),1);function Ad(t){let e=t.protocol==="https:";if(QD(t))return;let n=e?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(n)try{return new NA(n)}catch{if(!n.startsWith("http://")&&!n.startsWith("https://"))return new NA(`http://${n}`)}else return}o(Ad,"getProxyUrl");function QD(t){if(!t.hostname)return!1;let e=t.hostname;if(BD(e))return!0;let n=process.env.no_proxy||process.env.NO_PROXY||"";if(!n)return!1;let r;t.port?r=Number(t.port):t.protocol==="http:"?r=80:t.protocol==="https:"&&(r=443);let s=[t.hostname.toUpperCase()];typeof r=="number"&&s.push(`${s[0]}:${r}`);for(let i of n.split(",").map(a=>a.trim().toUpperCase()).filter(a=>a))if(i==="*"||s.some(a=>a===i||a.endsWith(`.${i}`)||i.startsWith(".")&&a.endsWith(`${i}`)))return!0;return!1}o(QD,"checkBypass");function BD(t){let e=t.toLowerCase();return e==="localhost"||e.startsWith("127.")||e.startsWith("[::1]")||e.startsWith("[0:0:0:0:0:0:0:1]")}o(BD,"isLoopbackAddress");var NA=class extends URL{static{o(this,"DecodedURL")}constructor(e,n){super(e,n),this._decodedUsername=decodeURIComponent(super.username),this._decodedPassword=decodeURIComponent(super.password)}get username(){return this._decodedUsername}get password(){return this._decodedPassword}};var Tr=Ve(qE(),1),Ck=Ve(Ek(),1);var Le=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},Ht;(function(t){t[t.OK=200]="OK",t[t.MultipleChoices=300]="MultipleChoices",t[t.MovedPermanently=301]="MovedPermanently",t[t.ResourceMoved=302]="ResourceMoved",t[t.SeeOther=303]="SeeOther",t[t.NotModified=304]="NotModified",t[t.UseProxy=305]="UseProxy",t[t.SwitchProxy=306]="SwitchProxy",t[t.TemporaryRedirect=307]="TemporaryRedirect",t[t.PermanentRedirect=308]="PermanentRedirect",t[t.BadRequest=400]="BadRequest",t[t.Unauthorized=401]="Unauthorized",t[t.PaymentRequired=402]="PaymentRequired",t[t.Forbidden=403]="Forbidden",t[t.NotFound=404]="NotFound",t[t.MethodNotAllowed=405]="MethodNotAllowed",t[t.NotAcceptable=406]="NotAcceptable",t[t.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",t[t.RequestTimeout=408]="RequestTimeout",t[t.Conflict=409]="Conflict",t[t.Gone=410]="Gone",t[t.TooManyRequests=429]="TooManyRequests",t[t.InternalServerError=500]="InternalServerError",t[t.NotImplemented=501]="NotImplemented",t[t.BadGateway=502]="BadGateway",t[t.ServiceUnavailable=503]="ServiceUnavailable",t[t.GatewayTimeout=504]="GatewayTimeout"})(Ht||(Ht={}));var at;(function(t){t.Accept="accept",t.ContentType="content-type"})(at||(at={}));var Zn;(function(t){t.ApplicationJson="application/json"})(Zn||(Zn={}));var KY=[Ht.MovedPermanently,Ht.ResourceMoved,Ht.SeeOther,Ht.TemporaryRedirect,Ht.PermanentRedirect],XY=[Ht.BadGateway,Ht.ServiceUnavailable,Ht.GatewayTimeout],e2=["OPTIONS","GET","DELETE","HEAD"],t2=10,n2=5,Lp=class t extends Error{static{o(this,"HttpClientError")}constructor(e,n){super(e),this.name="HttpClientError",this.statusCode=n,Object.setPrototypeOf(this,t.prototype)}},_p=class{static{o(this,"HttpClientResponse")}constructor(e){this.message=e}readBody(){return Le(this,void 0,void 0,function*(){return new Promise(e=>Le(this,void 0,void 0,function*(){let n=Buffer.alloc(0);this.message.on("data",r=>{n=Buffer.concat([n,r])}),this.message.on("end",()=>{e(n.toString())})}))})}readBodyBuffer(){return Le(this,void 0,void 0,function*(){return new Promise(e=>Le(this,void 0,void 0,function*(){let n=[];this.message.on("data",r=>{n.push(r)}),this.message.on("end",()=>{e(Buffer.concat(n))})}))})}};var xu=class{static{o(this,"HttpClient")}constructor(e,n,r){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=n||[],this.requestOptions=r,r&&(r.ignoreSslError!=null&&(this._ignoreSslError=r.ignoreSslError),this._socketTimeout=r.socketTimeout,r.allowRedirects!=null&&(this._allowRedirects=r.allowRedirects),r.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=r.allowRedirectDowngrade),r.maxRedirects!=null&&(this._maxRedirects=Math.max(r.maxRedirects,0)),r.keepAlive!=null&&(this._keepAlive=r.keepAlive),r.allowRetries!=null&&(this._allowRetries=r.allowRetries),r.maxRetries!=null&&(this._maxRetries=r.maxRetries))}options(e,n){return Le(this,void 0,void 0,function*(){return this.request("OPTIONS",e,null,n||{})})}get(e,n){return Le(this,void 0,void 0,function*(){return this.request("GET",e,null,n||{})})}del(e,n){return Le(this,void 0,void 0,function*(){return this.request("DELETE",e,null,n||{})})}post(e,n,r){return Le(this,void 0,void 0,function*(){return this.request("POST",e,n,r||{})})}patch(e,n,r){return Le(this,void 0,void 0,function*(){return this.request("PATCH",e,n,r||{})})}put(e,n,r){return Le(this,void 0,void 0,function*(){return this.request("PUT",e,n,r||{})})}head(e,n){return Le(this,void 0,void 0,function*(){return this.request("HEAD",e,null,n||{})})}sendStream(e,n,r,s){return Le(this,void 0,void 0,function*(){return this.request(e,n,r,s)})}getJson(e){return Le(this,arguments,void 0,function*(n,r={}){r[at.Accept]=this._getExistingOrDefaultHeader(r,at.Accept,Zn.ApplicationJson);let s=yield this.get(n,r);return this._processResponse(s,this.requestOptions)})}postJson(e,n){return Le(this,arguments,void 0,function*(r,s,i={}){let a=JSON.stringify(s,null,2);i[at.Accept]=this._getExistingOrDefaultHeader(i,at.Accept,Zn.ApplicationJson),i[at.ContentType]=this._getExistingOrDefaultContentTypeHeader(i,Zn.ApplicationJson);let c=yield this.post(r,a,i);return this._processResponse(c,this.requestOptions)})}putJson(e,n){return Le(this,arguments,void 0,function*(r,s,i={}){let a=JSON.stringify(s,null,2);i[at.Accept]=this._getExistingOrDefaultHeader(i,at.Accept,Zn.ApplicationJson),i[at.ContentType]=this._getExistingOrDefaultContentTypeHeader(i,Zn.ApplicationJson);let c=yield this.put(r,a,i);return this._processResponse(c,this.requestOptions)})}patchJson(e,n){return Le(this,arguments,void 0,function*(r,s,i={}){let a=JSON.stringify(s,null,2);i[at.Accept]=this._getExistingOrDefaultHeader(i,at.Accept,Zn.ApplicationJson),i[at.ContentType]=this._getExistingOrDefaultContentTypeHeader(i,Zn.ApplicationJson);let c=yield this.patch(r,a,i);return this._processResponse(c,this.requestOptions)})}request(e,n,r,s){return Le(this,void 0,void 0,function*(){if(this._disposed)throw new Error("Client has already been disposed.");let i=new URL(n),a=this._prepareRequest(e,i,s),c=this._allowRetries&&e2.includes(e)?this._maxRetries+1:1,l=0,d;do{if(d=yield this.requestRaw(a,r),d&&d.message&&d.message.statusCode===Ht.Unauthorized){let g;for(let f of this.handlers)if(f.canHandleAuthentication(d)){g=f;break}return g?g.handleAuthentication(this,a,r):d}let h=this._maxRedirects;for(;d.message.statusCode&&KY.includes(d.message.statusCode)&&this._allowRedirects&&h>0;){let g=d.message.headers.location;if(!g)break;let f=new URL(g);if(i.protocol==="https:"&&i.protocol!==f.protocol&&!this._allowRedirectDowngrade)throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");if(yield d.readBody(),f.hostname!==i.hostname)for(let m in s)m.toLowerCase()==="authorization"&&delete s[m];a=this._prepareRequest(e,f,s),d=yield this.requestRaw(a,r),h--}if(!d.message.statusCode||!XY.includes(d.message.statusCode))return d;l+=1,l<c&&(yield d.readBody(),yield this._performExponentialBackoff(l))}while(l<c);return d})}dispose(){this._agent&&this._agent.destroy(),this._disposed=!0}requestRaw(e,n){return Le(this,void 0,void 0,function*(){return new Promise((r,s)=>{function i(a,c){a?s(a):c?r(c):s(new Error("Unknown error"))}o(i,"callbackForResult"),this.requestRawWithCallback(e,n,i)})})}requestRawWithCallback(e,n,r){typeof n=="string"&&(e.options.headers||(e.options.headers={}),e.options.headers["Content-Length"]=Buffer.byteLength(n,"utf8"));let s=!1;function i(l,d){s||(s=!0,r(l,d))}o(i,"handleResult");let a=e.httpModule.request(e.options,l=>{let d=new _p(l);i(void 0,d)}),c;a.on("socket",l=>{c=l}),a.setTimeout(this._socketTimeout||3*6e4,()=>{c&&c.end(),i(new Error(`Request timeout: ${e.options.path}`))}),a.on("error",function(l){i(l)}),n&&typeof n=="string"&&a.write(n,"utf8"),n&&typeof n!="string"?(n.on("close",function(){a.end()}),n.pipe(a)):a.end()}getAgent(e){let n=new URL(e);return this._getAgent(n)}getAgentDispatcher(e){let n=new URL(e),r=Ad(n);if(r&&r.hostname)return this._getProxyAgentDispatcher(n,r)}_prepareRequest(e,n,r){let s={};s.parsedUrl=n;let i=s.parsedUrl.protocol==="https:";s.httpModule=i?Pp:Ya;let a=i?443:80;if(s.options={},s.options.host=s.parsedUrl.hostname,s.options.port=s.parsedUrl.port?parseInt(s.parsedUrl.port):a,s.options.path=(s.parsedUrl.pathname||"")+(s.parsedUrl.search||""),s.options.method=e,s.options.headers=this._mergeHeaders(r),this.userAgent!=null&&(s.options.headers["user-agent"]=this.userAgent),s.options.agent=this._getAgent(s.parsedUrl),this.handlers)for(let c of this.handlers)c.prepareRequest(s.options);return s}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},$a(this.requestOptions.headers),$a(e||{})):$a(e||{})}_getExistingOrDefaultHeader(e,n,r){let s;if(this.requestOptions&&this.requestOptions.headers){let a=$a(this.requestOptions.headers)[n];a&&(s=typeof a=="number"?a.toString():a)}let i=e[n];return i!==void 0?typeof i=="number"?i.toString():i:s!==void 0?s:r}_getExistingOrDefaultContentTypeHeader(e,n){let r;if(this.requestOptions&&this.requestOptions.headers){let i=$a(this.requestOptions.headers)[at.ContentType];i&&(typeof i=="number"?r=String(i):Array.isArray(i)?r=i.join(", "):r=i)}let s=e[at.ContentType];return s!==void 0?typeof s=="number"?String(s):Array.isArray(s)?s.join(", "):s:r!==void 0?r:n}_getAgent(e){let n,r=Ad(e),s=r&&r.hostname;if(this._keepAlive&&s&&(n=this._proxyAgent),s||(n=this._agent),n)return n;let i=e.protocol==="https:",a=100;if(this.requestOptions&&(a=this.requestOptions.maxSockets||Ya.globalAgent.maxSockets),r&&r.hostname){let c={maxSockets:a,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(r.username||r.password)&&{proxyAuth:`${r.username}:${r.password}`}),{host:r.hostname,port:r.port})},l,d=r.protocol==="https:";i?l=d?Tr.httpsOverHttps:Tr.httpsOverHttp:l=d?Tr.httpOverHttps:Tr.httpOverHttp,n=l(c),this._proxyAgent=n}if(!n){let c={keepAlive:this._keepAlive,maxSockets:a};n=i?new Pp.Agent(c):new Ya.Agent(c),this._agent=n}return i&&this._ignoreSslError&&(n.options=Object.assign(n.options||{},{rejectUnauthorized:!1})),n}_getProxyAgentDispatcher(e,n){let r;if(this._keepAlive&&(r=this._proxyAgentDispatcher),r)return r;let s=e.protocol==="https:";return r=new Ck.ProxyAgent(Object.assign({uri:n.href,pipelining:this._keepAlive?1:0},(n.username||n.password)&&{token:`Basic ${Buffer.from(`${n.username}:${n.password}`).toString("base64")}`})),this._proxyAgentDispatcher=r,s&&this._ignoreSslError&&(r.options=Object.assign(r.options.requestTls||{},{rejectUnauthorized:!1})),r}_getUserAgentWithOrchestrationId(e){let n=e||"actions/http-client",r=process.env.ACTIONS_ORCHESTRATION_ID;if(r){let s=r.replace(/[^a-z0-9_.-]/gi,"_");return`${n} actions_orchestration_id/${s}`}return n}_performExponentialBackoff(e){return Le(this,void 0,void 0,function*(){e=Math.min(t2,e);let n=n2*Math.pow(2,e);return new Promise(r=>setTimeout(()=>r(),n))})}_processResponse(e,n){return Le(this,void 0,void 0,function*(){return new Promise((r,s)=>Le(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===Ht.NotFound&&r(a);function c(h,g){if(typeof g=="string"){let f=new Date(g);if(!isNaN(f.valueOf()))return f}return g}o(c,"dateTimeDeserializer");let l,d;try{d=yield e.readBody(),d&&d.length>0&&(n&&n.deserializeDates?l=JSON.parse(d,c):l=JSON.parse(d),a.result=l),a.headers=e.message.headers}catch{}if(i>299){let h;l&&l.message?h=l.message:d&&d.length>0?h=d:h=`Failed request: (${i})`;let g=new Lp(h,i);g.result=a.result,s(g)}else r(a)}))})}},$a=o(t=>Object.keys(t).reduce((e,n)=>(e[n.toLowerCase()]=t[n],e),{}),"lowercaseKeys");var r2=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})};var Du=class{static{o(this,"BearerCredentialHandler")}constructor(e){this.token=e}prepareRequest(e){if(!e.headers)throw Error("The request has no headers");e.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return r2(this,void 0,void 0,function*(){throw new Error("not implemented")})}};var Ik=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},Tu=class t{static{o(this,"OidcClient")}static createHttpClient(e=!0,n=10){let r={allowRetries:e,maxRetries:n};return new xu("actions/oidc-client",[new Du(t.getRequestToken())],r)}static getRequestToken(){let e=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!e)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable");return e}static getIDTokenUrl(){let e=process.env.ACTIONS_ID_TOKEN_REQUEST_URL;if(!e)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable");return e}static getCall(e){return Ik(this,void 0,void 0,function*(){var n;let i=(n=(yield t.createHttpClient().getJson(e).catch(a=>{throw new Error(`Failed to get ID Token.
|
|
84
84
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyramp/testbot-core",
|
|
3
|
-
"version": "0.13.0-v3.
|
|
3
|
+
"version": "0.13.0-v3.217",
|
|
4
4
|
"description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. dist/VERSION.json exists only in a release-engine.yml build.",
|