chore(yun-tianming): drop review cites and change narration, dedupe api request path
Summary
- Comment cleanup across 25
src/files. Removed review-round citations (cubic P1/P2,r2d2 round N,spec 4.1 / FAQ 7.x,console PR #290,insta-platform #385/#357,#138), dated incident notes (seen on prod 2026-09-10,insta-e2e run 31284364163,staging 2026-08-25 … insta-warm-00178a-16,verified … on 2026-09-11), provenance (Ported from firth×3,Design doc §5,Spec 4.4,(user report)), and change narration (used to,previously,no longer,at first,the first version,an earlier round declined,which is exactly how this was missed, the three retellings of the retired Neon path indb.tsand one inmetrics.ts, thepro|enterprisehistory inbilling.ts, thebeta-apiretirement inenv.ts/config.ts, thev0.0.46anecdote inupgrade.ts). Where a story carried a constraint, the constraint survives in one line (e.g. the lock-takeover inode rule incompute.ts, the CA-key shape checks inssh-config.ts, the archive-digest rule indeploy-archive.ts). - Duplicated comment blocks collapsed. The 8-line
--argv-splitting paragraph attached toEXEC_OPTIONSincompute.tsrepeated the one onsplitExecArgsand was removed;index.ts's__ssh-ensure-certnote shrinks to its constraint (the long form stays incompute.ts); the two consecutive "whole blob, not first field" paragraphs inssh-config.tsbecome one; the duplicated "URL never appears in PowerShell source" paragraph inutil.tskeeps only the smart-quote fact the outer doc lacks; a redundant first line aboveEXPLICIT_ADDRESSingithub-source.tsis dropped. - Documentation drift fixed.
feedback.ts'ssubmitdoc said "10s timeout" whileFEEDBACK_TIMEOUT_MS = 15_000; it now names the constant. Indb.tsthe doc comment describingdbVolumeLines("reads the CANONICAL volume* names only …") sat abovefmtBytes; it is moved ontodbVolumeLines, which had no comment. - Dead code.
src/flyctl-build.tsimportedinfofrom./util.jsand never used it (orphaned by commitf94dfe8).src/commands/setup.tsre-exportedwhichOnPathfrom../spawn.js; nothing imports it throughsetup.ts. - Redundant work removed in
src/api.ts.fetch()serialized the request body twice (once for the agent-signature payload, once for the fetch body); it now serializes once and uses the same string for both.request()duplicatedrawRequest()'s>= 400 → ApiErrorline; it now callsrawRequest()and adds only the agent-mode 202 check.
Safety
- Comment edits (all files except the two below): no code tokens changed; every deletion was a citation, date, provenance tag, or narration of a past state; every shrink keeps the "must/must not" sentence.
git diffshows only//and/** */lines outsidesrc/api.ts,src/flyctl-build.ts:7, andsrc/commands/setup.ts:25. - Dead code,
src/flyctl-build.tsunused import:grep -n '\binfo\b' src/flyctl-build.tsreturns only the import line;tsc --noUnusedLocalsreported it as TS6133 and reports nothing else insrc/. - Dead code,
whichOnPathre-export insrc/commands/setup.ts:grep -rn whichOnPath src test scripts *.mdfinds the definition inspawn.ts:29, its one internal call atspawn.ts:73, and the re-export; no importer. The package is a CLI (files: dist/**/*.js,bin: insta), so no external consumer.resolveSpawnableon the same line is live (ensure-skills.ts,test/self-install.test.ts) and is kept. - Redundant work,
src/api.tssingleJSON.stringify: same object, no awaits between the two original calls that could mutate it, so the two strings were identical by construction; agentHeaders still receives''when body is undefined. Exercised bytest/agent.test.ts(signed POST/PUT bodies, evidence:false) andtest/api-signal.test.ts. - Pure refactor inside one module,
request()viarawRequest(): the only reordering is the 202 check now running after the>= 400throw; a status cannot be both 202 and ≥400, so every input takes the same path. Exported names and signatures unchanged. Exercised bytest/agent.test.ts(202 → AgentApprovalRequired, 2xx bodies),test/api-signal.test.ts(401 → ApiError with body, abort propagation),test/user-agent.test.ts. - Documentation drift (
feedback.ts,db.ts): prose corrected to matchFEEDBACK_TIMEOUT_MSatfeedback.ts:48and thevolumeGib/volumeSizereads atdb.ts:187; no new claims.
Verification
Baseline on the untouched tree:
npx tsc --noEmit # exit 0
npx vitest run # 77 files passed, 1467 passed | 120 skipped, exit 0
Final tree:
npx tsc --noEmit # exit 0
npx vitest run # 77 files passed, 1467 passed | 120 skipped, exit 0
Not run here: the 103 test/ssh-orchestration.test.ts cases and the 16 ssh -G cases in test/ssh-config.test.ts skip because this machine has no ssh-keygen/ssh binary (same 120 skips as baseline; the rest are win32-only). The test-windows CI job was not reproducible here. No test flaked between runs. There is no lint script in package.json or CI.
Deferred findings
Defects (reported, not changed):
src/api.ts:111refresh()readsres.body.accessTokenafter a< 400check; an empty 2xx body parses tonull(line 103), the TypeError is caught at 115 and turned intoreturn false, so the user sees the original 401 instead of the fault.src/agent.ts:59-66loadAgentSessionconverts every failure (EACCES, malformed JSON) into the "runinsta setup agent" guidance, which cannot fix a permissions problem.src/commands/project.ts:25-33tryInstallObserveswallows real write failures under a comment that names only "assets missing".src/index.ts:481program.parseAsync(computeArgv)is unawaited; a commander-level rejection (e.g. the preAction hook) becomes an unhandled rejection rather thanfail().src/commands/domain.ts:24,53non-null assertions on optionalpriceCents/checkoutUrlprint$NaN/undefined;recordLinesat:142yields-Infinitywidths on an empty array (exported, untested).src/commands/build.ts:93theWALK_CAPcheck returns from the current directory only; the walk continues into siblings, so the cap does not bound work (only thetruncatedflag is tested).src/commands/metrics.ts:49-61humanByteslabels base-1024 memory/storage valuesKB/MB/GB; it is a third bytes formatter despitestorage.ts:10's "don't grow a third copy" note, and it is untested directly.cliVersionexists three times:src/version.tshonours the bakedINSTA_CLI_VERSION;src/commands/setup.ts:127andsrc/observe/install.ts:18do not, so in the compiled binary (nopackage.json)setup agentinstallsinsta@latestand the observeVERSIONfile says0.0.0.src/commands/storage.ts:23parseObjectLimituses bareNumber()(accepts0x10,1e2) whileservices.ts:38-55anchors on/^\s*(\d+)\s*$/for exactly that reason;test/storage.test.tsnever covers those inputs.src/commands/govern.ts:9interpolateslimitwithoutencodeURIComponentwhilebranchbeside it is encoded.src/commands/compute.ts:741the limits write path printsres.body.service?.name ?? id, dropping theserviceName ??rung every sibling path has;:361lifecycle passesidasfallbackName.src/deploy-archive.ts:180await wait(POLL_MS)runs even whenremaining < POLL_MS, sleeping past the deadline beforeoverdue()fires.src/commands/metrics.ts:105usage()callsrequireProject()even when--proj <id>is explicit, triggering auto-link in an unlinked directory.src/config.ts:327-330persistAutoLinkwalks ancestors viaisHomeLinkTarget, thenwriteProjectwalks again;resolveProjectLinkre-reads theproject.jsonthatfindProjectRootjust read.src/commands/deploy.ts:23,256re-derive the port with bareNumber()bypassing the validation at:167-172.
Refactors not done (coverage or boundary):
qs()is byte-identical insrc/commands/metrics.ts:4andsrc/commands/storage.ts:14; collapsing means one module importing from another (or a new home inutil.ts), left for the owners.- The 409 →
repoConnectedHintre-wrap atsrc/commands/deploy.ts:115and:194is identical, but no test exercises the.catchpath, only the pure hint function. fmtMib/fmtMb(db.ts:47,compute.ts:622),mib/mb(pack.ts:206,build.ts:114), two table renderers (template.ts:36,db-query.ts:42), andtargetService/storageTarget(github.ts:198,storage.ts:47, inlined six more times incompute.ts/db.ts) are near-duplicates with drifted labels or types.- Cyclic imports:
commands/setup.ts↔commands/mcp.ts;setup.ts→project.ts→ensure-skills.ts→setup.ts. src/commands/upgrade.ts:203-212autoEnabled()reads~/.insta/config.jsondirectly instead of throughconfig.ts, ignoring its overrides.src/commands/compute.ts(2026 lines) holds domains, lifecycle, exec, limits/volumes and the whole SSH store, with a second import block mid-file at ~:750.
Comments left alone on purpose: the "Railway-style" comparisons in setup.ts and run.ts read as design intent; the isSafeCAHostPattern docblock at ssh-config.ts:579-596 sits 40 lines from its function and overlaps the allowlist doc, but relocating it was not verified line by line tonight; setup.ts:340-346 has an orphaned paragraph between shouldOfferLogin and makePromptSource.
Test environment: with ssh-keygen absent, 103 of the 116 ssh-orchestration cases and 16 ssh-config cases are silently green; nothing in the run output distinguishes "verified" from "not run".
🤖 Generated with Claude Code
Security findings
- [Yun Tianming] src/config.ts: writeGlobal stores access/refresh tokens at umask default mode
- [Yun Tianming] src/commands/secrets.ts: secrets pull writes .env at umask default mode
- [Yun Tianming] src/commands/setup.ts: --mcp-token passes minted bearer on claude argv
- [Yun Tianming] src/flyctl-build.ts: $HOME interpolated into sh -c installer command
- [Yun Tianming] install.sh: predictable /tmp stderr file (insta-setup-err.$$) follows symlinks
- [Yun Tianming] src/commands/auth.ts: OAuth callback page reflects unescaped error param as HTML
- [Yun Tianming] src/flyctl-build.ts: flyApp from API interpolated unvalidated into fly.toml
- [Yun Tianming] src/util.ts: secrets.set next-action hint prints args.value verbatim
- [Yun Tianming] package-lock.json: vitest 2.1.9 / vite 5.4.21 dev toolchain carries known advisories
Opened by Yun Tianming: nightly sweep 2026-09-17-1000, model claude-fable-5-1, 106 turns, 27 files, 258 changed lines.
Verification: npx tsc --noEmit (exit 0) and npx vitest run (77 files, 1467 passed, 120 skipped) both passed on the final tree, identical to baseline; the 119 ssh-dependent skips could not run here (no ssh-keygen/ssh binary) and the Windows CI job was not reproducible.
🤖 Generated with Claude Code
Summary by cubic
Cleans up comments across 25 src files and removes redundant work in the API client, with no behavior changes. Comments now state current constraints without review citations, dates, provenance tags, or change narration; where a story carried a constraint, the constraint survives in one line.
Refactors
request()now delegates torawRequest()and adds only the agent-mode 202 check.fetch()serializes the body once, reusing the string for both the agent-signature payload and the fetch body.- Removed the unused
infoimport inflyctl-build.tsand the unusedwhichOnPathre-export insetup.ts. - Fixed doc drift in
feedback.ts(outdated 10s timeout) anddb.ts(misplaceddbVolumeLinescomment).