Public: anyone can read this; the crew can change it.
Revert "Main's full check still runs 40+ minutes after #16613 landed" #16635
Check · Review · Land · Live done — Landed and live in production.
revert-16623 → main 0 commits
99 files
changed +215
−335
- docs/features/maintenance-duties.md
- scripts/unused-exports-allow.json
- src/actions/business_plan.ts
- src/actions/dependencies.ts
- src/actions/forge_view.ts
- src/actions/forge_view_ttl.ts
- src/actions/plan.ts
- src/actions/plan_words.ts
- src/actions/search.ts
- src/checks/culprit.ts
- src/checks/red_main.ts
- src/checks/revert_red.ts
- src/contract/openapi/routes/getApiV1Feed.ts
- src/contract/openapi/routes/getApiV1Search.ts
- src/core/page_ceilings.ts
- src/crew/breaker.ts
- src/crew/cap_note.ts
- src/crew/dispatch.ts
- src/crew/guard.ts
- src/feed/feed.ts
- src/feed/last_seen.ts
- src/feed/new_count_cap.ts
- src/feed/newer_label.ts
- src/feed/timeline.ts
- src/fleet/verbs.ts
- src/http/api.ts
- src/http/api/business_plan.ts
- src/http/api/issues.ts
- src/http/feed.ts
- src/http/mcp/tools/atlas.ts
- src/http/mcp/tools/feed.ts
- src/http/mcp/tools/plan.ts
- src/http/mcp/tools/system.ts
- src/http/mcp/tools/wait_for.ts
- src/http/view_stream.ts
- src/maintain/pause.ts
- src/maintain/registry.ts
- src/maintain/runner.ts
- src/maintain/schedule.ts
- src/spawn/clients.ts
- src/spawn/door.ts
- src/spawn/reach.ts
- src/spawn/suite_defaults.ts
- src/tui/screens/atlas.ts
- src/tui/screens/dutybudgets.ts
- src/tui/screens/entries.ts
- src/tui/screens/issue.ts
- src/tui/screens/maintenanceweek.ts
- src/web/pages/maintenance_budgets.ts
- src/web/pages/system.ts
- src/web/pages/thread.ts
- src/web/studio/held_posts.ts
- test/account-purge.test.ts
- test/cloud-watch.test.ts
- test/crew-guard-cap.test.ts
- test/crew-guard.test.ts
- test/displays-list.test.ts
- test/duty-idle.test.ts
- test/duty-roster.test.ts
- test/efficiency-runner.test.ts
- test/feed-new-count.test.ts
- test/helpers/preload.ts
- test/maint-stale-branches.test.ts
- test/maint-untested.test.ts
- test/maintain-backup-age.test.ts
- test/maintain-dead-doc-paths.test.ts
- test/maintain-disk-free.test.ts
- test/maintain-duty-states.test.ts
- test/maintain-edge-kept.test.ts
- test/maintain-failing.test.ts
- test/maintain-flaky-tests.test.ts
- test/maintain-merged-branches.test.ts
- test/maintain-nothing.test.ts
- test/maintain-pause.test.ts
- test/maintain-previews-duty.test.ts
- test/maintain-red-apps.test.ts
- test/maintain-slow-tests.test.ts
- test/maintain-stale-issues.test.ts
- test/maintain-v1-proven.test.ts
- test/maintain-wait-split.test.ts
- test/maintain.test.ts
- test/maintenance-chapter-stall.test.ts
- test/maintenance-last-run.test.ts
- test/maintenance-page.test.ts
- test/maintenance-pause-who.test.ts
- test/maintenance-week-doors.test.ts
- test/memory-watch.test.ts
- test/palette-entries.test.ts
- test/red-main-line.test.ts
- test/revert-red.test.ts
- test/spawn-app-links.test.ts
- test/spawn-in-process-visible.test.ts
- test/spawn-move-cell-sizes.test.ts
- test/spawn-move-cell.test.ts
- test/spawn-sealed-host.test.ts
- test/tui-drift.test.ts
- test/tui-issue-waits.test.ts
- test/tui-maintenance-pause-who.test.ts
- test/verify-after-landing.test.ts
docs/features/maintenance-duties.md +1 −1
| @@ -66,6 +66,6 @@ Tests: `test/duty-idle.test.ts`. | ||
| 66 | 66 | |
| 67 | 67 | ## Adding a duty (#14355) |
| 68 | 68 | |
| 69 | A duty is one file in `src/maintain/duties/` that exports `duty` (a `Duty`, see `src/maintain/duty.ts`). `src/maintain/registry.ts` lists that directory on first use and builds the roster from it, so a pull that adds a duty adds that file and edits no shared list; `scripts/unreached.ts` counts every file there as reached. A file that does not export `duty` stops boot with an error naming it. `duty_idle.ts` is the one exception: it watches the others and is appended last. | |
| 69 | A duty is one file in `src/maintain/duties/` that exports `duty` (a `Duty`, see `src/maintain/duty.ts`). `src/maintain/registry.ts` lists that directory when it loads and builds the roster from it, so a pull that adds a duty adds that file and edits no shared list; `scripts/unreached.ts` counts every file there as reached. A file that does not export `duty` stops boot with an error naming it. `duty_idle.ts` is the one exception: it watches the others and is appended last. | |
| 70 | 70 | |
| 71 | 71 | The roster is in file-name order, and that is the order the runner ticks the duties and `/maintenance` lists them (it used to be a hand-picked order). To place a duty, name its file for where it should sit. Tests: `test/duty-roster.test.ts`. |
scripts/unused-exports-allow.json +2 −1
| @@ -162,17 +162,18 @@ | ||
| 162 | 162 | "src/snapshot/drill_job.ts markerLeft", |
| 163 | 163 | "src/spawn/births.ts provideHoldForTest", |
| 164 | 164 | "src/spawn/births.ts provideMemoryForTest", |
| 165 | "src/spawn/door.ts useWatchProbeByDefault", | |
| 165 | 166 | "src/spawn/child-apps.ts childRuntime", |
| 166 | 167 | "src/spawn/child_db.ts childDbReaders", |
| 167 | 168 | "src/spawn/clients.ts monthsSettled", |
| 168 | 169 | "src/spawn/clients.ts useChildFetch", |
| 169 | 170 | "src/spawn/door.ts usePlacement", |
| 170 | "src/spawn/door.ts useProbe", | |
| 171 | 171 | "src/spawn/host.ts provideCellsForTest", |
| 172 | 172 | "src/spawn/included_credit.ts worstCaseDailyUsd", |
| 173 | 173 | "src/spawn/parent_credential.ts keepParentCredential", |
| 174 | 174 | "src/spawn/pod.ts renderPod", |
| 175 | 175 | "src/spawn/rate.ts resetAnonSpawns", |
| 176 | "src/spawn/reach.ts useReachByDefault", | |
| 176 | 177 | "src/spawn/usage.ts forgetSelfCpu", |
| 177 | 178 | "src/story/records.ts isKnownRecord", |
| 178 | 179 | "src/story/records.ts parseRecords", |
src/actions/business_plan.ts +4 −2
| @@ -24,8 +24,7 @@ import { transact } from "../kernel/db.ts"; | ||
| 24 | 24 | import type { User } from "../core/users.ts"; |
| 25 | 25 | import { err, ok, type Result } from "../kernel/result.ts"; |
| 26 | 26 | import { MAX_DIRECTION_CHARS, MAX_FRESH_CHARS } from "../spawn/plan.ts"; |
| 27 | import { PLAN_MAX } from "./plan_words.ts"; | |
| 28 | import { openPlan, proposePlan, type PlanItem, type Planned, type Proposed } from "./plan.ts"; | |
| 27 | import { openPlan, PLAN_MAX, proposePlan, type PlanItem, type Planned, type Proposed } from "./plan.ts"; | |
| 29 | 28 | |
| 30 | 29 | /** The description, in words: long enough for a business, short enough to read. */ |
| 31 | 30 | export const DESCRIPTION_MAX = 4_000; |
| @@ -239,6 +238,9 @@ export function spawnSeed(plan: BusinessPlan): { direction: string; fresh?: stri | ||
| 239 | 238 | }; |
| 240 | 239 | } |
| 241 | 240 | |
| 241 | /** The largest body either door reads: a description, twelve parts and their edges, with room. */ | |
| 242 | export const ATLAS_BODY_MAX = 64 * 1024; | |
| 243 | ||
| 242 | 244 | /** |
| 243 | 245 | * The issues an earlier confirm of this plan opened here, by number. The |
| 244 | 246 | * stamp line is matched only where `businessItems` puts it, at the very end |
src/actions/dependencies.ts +9
| @@ -18,8 +18,17 @@ import { canRead, canWrite, type Repo } from "../core/repos.ts"; | ||
| 18 | 18 | import type { User } from "../core/users.ts"; |
| 19 | 19 | import { err, ok, type Result } from "../kernel/result.ts"; |
| 20 | 20 | import type { AccessError } from "./access.ts"; |
| 21 | import { SELF_WAIT } from "./plan_words.ts"; | |
| 21 | 22 | import { followLink } from "./pillars.ts"; |
| 22 | 23 | |
| 24 | /** What a refused link says, in the words the API and the MCP share. */ | |
| 25 | export const dependencyWords: Record<string, string> = { | |
| 26 | self: SELF_WAIT, | |
| 27 | cycle: "that would make a loop", | |
| 28 | cross_repo: "dependencies stay inside one repository", | |
| 29 | not_an_issue: "only issues can depend on issues", | |
| 30 | }; | |
| 31 | ||
| 23 | 32 | function requirePlanner( |
| 24 | 33 | app: App, |
| 25 | 34 | actor: User | undefined, |
src/actions/forge_view.ts +1 −2
| @@ -15,9 +15,8 @@ import { appsOf } from "../web/studio/asks.ts"; | ||
| 15 | 15 | import { clientLines, IDLE_LINE } from "./client_line.ts"; |
| 16 | 16 | import { crewNow } from "./crew_now.ts"; |
| 17 | 17 | import { readHealth } from "./health.ts"; |
| 18 | import { VIEW_TTL_MS } from "./forge_view_ttl.ts"; | |
| 19 | ||
| 20 | 18 | |
| 19 | export const VIEW_TTL_MS = 2000; | |
| 21 | 20 | /** Most apps listed; `counts.apps` stays the true number. */ |
| 22 | 21 | export const VIEW_APPS = 200; |
| 23 | 22 |
src/actions/forge_view_ttl.ts deleted −6
src/actions/plan.ts +2 −1
| @@ -33,9 +33,10 @@ import { id as newId } from "../kernel/id.ts"; | ||
| 33 | 33 | import { err, ok, type Result } from "../kernel/result.ts"; |
| 34 | 34 | import { isMirror } from "../origins/write-through.ts"; |
| 35 | 35 | import { lookAlikes } from "./look_alike.ts"; |
| 36 | import { PLAN_MAX, SELF_WAIT } from "./plan_words.ts"; | |
| 36 | import { SELF_WAIT } from "./plan_words.ts"; | |
| 37 | 37 | import { followLink } from "./pillars.ts"; |
| 38 | 38 | |
| 39 | export const PLAN_MAX = 12; | |
| 39 | 40 | /** One sentence, with room. */ |
| 40 | 41 | export const WHY_MAX = 300; |
| 41 | 42 | const KEY = /^[A-Za-z][A-Za-z0-9_.-]{0,39}$/; |
src/actions/plan_words.ts −14
| @@ -10,17 +10,3 @@ export const SELF_WAIT = "an issue cannot wait for itself"; | ||
| 10 | 10 | |
| 11 | 11 | /** A re-plan that can no longer be taken back: the planner has been given it. */ |
| 12 | 12 | export const IN_HAND = "the planner has it in hand already"; |
| 13 | ||
| 14 | /** What a refused link says, in the words the API and the MCP share. */ | |
| 15 | export const dependencyWords: Record<string, string> = { | |
| 16 | self: SELF_WAIT, | |
| 17 | cycle: "that would make a loop", | |
| 18 | cross_repo: "dependencies stay inside one repository", | |
| 19 | not_an_issue: "only issues can depend on issues", | |
| 20 | }; | |
| 21 | ||
| 22 | /** The most issues one plan opens. */ | |
| 23 | export const PLAN_MAX = 12; | |
| 24 | ||
| 25 | /** The largest body either door reads: a description, twelve parts and their edges, with room. */ | |
| 26 | export const ATLAS_BODY_MAX = 64 * 1024; |
src/actions/search.ts +2 −1
| @@ -38,12 +38,13 @@ import { | ||
| 38 | 38 | } from "../core/search.ts"; |
| 39 | 39 | import type { Repo } from "../core/repos.ts"; |
| 40 | 40 | import type { User } from "../core/users.ts"; |
| 41 | import { SEARCH_LIMIT_MAX } from "../core/page_ceilings.ts"; | |
| 42 | 41 | import { searchDocs } from "../view/docs.ts"; |
| 43 | 42 | import { providerForOrigin } from "../origins/credential.ts"; |
| 44 | 43 | |
| 45 | 44 | /** Default page size for each list. */ |
| 46 | 45 | export const SEARCH_LIMIT = 20; |
| 46 | /** Hard ceiling on a caller-chosen limit. */ | |
| 47 | export const SEARCH_LIMIT_MAX = 100; | |
| 47 | 48 | |
| 48 | 49 | /** |
| 49 | 50 | * The refusal an API or MCP caller gets for a `kind` or `limit` the search |
src/checks/culprit.ts +2 −8
| @@ -186,14 +186,8 @@ function unbisected(app: App, repo: Repo, red: Run, why: string): string { | ||
| 186 | 186 | export async function afterVerify(app: App, repo: Repo, run: Run, ask: Ask): Promise<string[]> { |
| 187 | 187 | const red = run.env === VERIFY_ENV ? run : getRun(app.db, bisectOrigin(run.reason) ?? ""); |
| 188 | 188 | if (red === undefined || red.state !== "failed") return []; |
| 189 | const named = red.checkDetail?.files ?? []; | |
| 190 | const passAlone = red.checkDetail?.flakyUnderLoad ?? []; | |
| 191 | const files = named.filter((f) => !passAlone.includes(f)); | |
| 192 | if (named.length === 0) return ["not bisected: the red names no failed test file"]; | |
| 193 | // A file that passed when re-run alone failed for the load it ran under, not for a landing | |
| 194 | // (#16622). | |
| 195 | if (files.length === 0) | |
| 196 | return [`not bisected: ${named.join(", ")} pass alone, so load failed them and no landing did`]; | |
| 189 | const files = red.checkDetail?.files ?? []; | |
| 190 | if (files.length === 0) return ["not bisected: the red names no failed test file"]; | |
| 197 | 191 | if (run === red) { |
| 198 | 192 | const before = finishedBefore(app, repo.id, red.id); |
| 199 | 193 | const known = before?.state === "failed" ? (before.checkDetail?.files ?? []) : []; |
src/checks/red_main.ts +5 −18
| @@ -34,8 +34,6 @@ export interface RedMain { | ||
| 34 | 34 | readonly branch: string; |
| 35 | 35 | /** The check was stopped by its cell's limit or its budget, not by a test: no pull shares it. */ |
| 36 | 36 | readonly limit: boolean; |
| 37 | /** Every failing file passed when re-run alone: load tripped it, no landing broke it (#16622). */ | |
| 38 | readonly flaky: boolean; | |
| 39 | 37 | readonly since: string; |
| 40 | 38 | } |
| 41 | 39 | |
| @@ -88,27 +86,17 @@ const lastMain = (from: string): string => ` | ||
| 88 | 86 | |
| 89 | 87 | /** |
| 90 | 88 | * A summary of a cell stop (`apps/contain.ts`), a budget kill (`kernel/budgets.ts`), a check that |
| 91 | * stalled (`checks/stall.ts`), one the forge's stopping cut off, or one whose step ran past its | |
| 92 | * time ("check took longer than 2400s", `checks/job_step.ts`): the machine's, not a pull's | |
| 93 | * (#16622). | |
| 89 | * stalled (`checks/stall.ts`) or one the forge's stopping cut off: the machine's, not a pull's. | |
| 94 | 90 | */ |
| 95 | const LIMIT = | |
| 96 | /^(?:check failed: )?(?:stopped: |budget:|check stalled:|the forge was stopped under this check|\S+ took longer than \d+s)/; | |
| 91 | const LIMIT = /^(?:check failed: )?(?:stopped: |budget:|check stalled:|the forge was stopped under this check)/; | |
| 97 | 92 | |
| 98 | 93 | function toRed(row: Row): RedMain | undefined { |
| 99 | 94 | if (row.state !== "failed") return undefined; |
| 100 | 95 | let failing: string[] = []; |
| 101 | let flaky = false; | |
| 102 | 96 | try { |
| 103 | const detail = row.check_detail | |
| 104 | ? (JSON.parse(row.check_detail) as { names?: unknown; files?: unknown; flakyUnderLoad?: unknown }) | |
| 105 | : {}; | |
| 106 | const strings = (v: unknown): string[] => | |
| 107 | Array.isArray(v) ? v.filter((n): n is string => typeof n === "string") : []; | |
| 108 | failing = strings(detail.names); | |
| 109 | const files = strings(detail.files); | |
| 110 | const green = strings(detail.flakyUnderLoad); | |
| 111 | flaky = files.length > 0 && files.every((f) => green.includes(f)); | |
| 97 | const detail = row.check_detail ? (JSON.parse(row.check_detail) as { names?: unknown }) : {}; | |
| 98 | if (Array.isArray(detail.names)) | |
| 99 | failing = detail.names.filter((n): n is string => typeof n === "string"); | |
| 112 | 100 | } catch { |
| 113 | 101 | failing = []; |
| 114 | 102 | } |
| @@ -121,7 +109,6 @@ function toRed(row: Row): RedMain | undefined { | ||
| 121 | 109 | summary: row.summary, |
| 122 | 110 | branch: row.branch, |
| 123 | 111 | limit: LIMIT.test(row.summary), |
| 124 | flaky, | |
| 125 | 112 | since: row.finished_at ?? row.created_at, |
| 126 | 113 | }; |
| 127 | 114 | } |
src/checks/revert_red.ts +2 −3
| @@ -5,8 +5,7 @@ | ||
| 5 | 5 | * for the pull it takes back and naming the failing test. It is only ever |
| 6 | 6 | * proposed — a person lands it. A red that spans more than one landing (or a |
| 7 | 7 | * push no pull carried) is the alarm's, not this module's, and a landing |
| 8 | * already reverted, open or shipped or closed, is never proposed twice. A red | |
| 9 | * the machine caused (a limit, a stall, or files that pass alone) proposes none. | |
| 8 | * already reverted, open or shipped or closed, is never proposed twice. | |
| 10 | 9 | */ |
| 11 | 10 | |
| 12 | 11 | import type { App } from "../app.ts"; |
| @@ -89,7 +88,7 @@ export async function proposeRevert(app: App, repoId: string): Promise<Pull | un | ||
| 89 | 88 | working.add(repoId); |
| 90 | 89 | try { |
| 91 | 90 | const red = redMain(app.db, repoId); |
| 92 | if (red === undefined || red.limit || red.flaky || manifestError(red) !== undefined) return undefined; | |
| 91 | if (red === undefined || red.limit || manifestError(red) !== undefined) return undefined; | |
| 93 | 92 | const green = greenBefore(app, repoId, red.branch, red.runId); |
| 94 | 93 | if (green === undefined) return undefined; |
| 95 | 94 | const landed = await soleLanding(app, red, green); |
src/contract/openapi/routes/getApiV1Feed.ts +1 −1
src/contract/openapi/routes/getApiV1Search.ts +1 −1
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | import { type Route, limitTo } from "../shared.ts"; |
| 2 | import { SEARCH_LIMIT_MAX } from "../../../core/page_ceilings.ts"; | |
| 2 | import { SEARCH_LIMIT_MAX } from "../../../actions/search.ts"; | |
| 3 | 3 | |
| 4 | 4 | export const route: Route = { method: "get", path: "/api/v1/search", summary: "Search guides, issues, pulls, repositories and code; `kind` narrows it", auth: false, role: "anonymous", query: { q: "string", kind: "string", limit: limitTo(SEARCH_LIMIT_MAX) }, refusals: { invalid_kind: "kind is not all, repos, issues or code (422)", invalid_limit: "limit is not a whole number from 1 to 100 (422)" }, reply: { repos: "array", issues: "array", code: "array", docs: "array of { title, path, snippet }, at most 5, guides matching; only for kind all", truncated: "object", moreCode: "boolean", codeSkipped: "boolean", note: "string, only when q is blank: what to send" } }; |
src/core/page_ceilings.ts deleted −12
| @@ -1,12 +0,0 @@ | ||
| 1 | /** | |
| 2 | * The hard ceilings on a caller-chosen page size that the contract's route table names | |
| 3 | * (`contract/openapi/routes/`). A leaf: it imports nothing, so a route file reads its ceiling | |
| 4 | * without loading the module that enforces it, and no import cycle runs through the contract | |
| 5 | * (#16622). | |
| 6 | */ | |
| 7 | ||
| 8 | /** Hard ceiling on a caller-chosen search limit. */ | |
| 9 | export const SEARCH_LIMIT_MAX = 100; | |
| 10 | ||
| 11 | /** Hard ceiling on a caller-chosen feed page. */ | |
| 12 | export const FEED_LIMIT_MAX = 50; |
src/crew/breaker.ts +1 −1
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | |
| 8 | 8 | import type { Database } from "bun:sqlite"; |
| 9 | 9 | import type { Repo } from "../core/repos.ts"; |
| 10 | import { CAP_NOTE } from "./cap_note.ts"; | |
| 10 | import { CAP_NOTE } from "./guard.ts"; | |
| 11 | 11 | import { directorsAmong } from "./direct.ts"; |
| 12 | 12 | import { REPEAT_NOTE } from "./repeat_note.ts"; |
| 13 | 13 |
src/crew/cap_note.ts deleted −8
| @@ -1,8 +0,0 @@ | ||
| 1 | /** | |
| 2 | * What a capped issue is parked with. A leaf, so the breaker that lists it among the notes it | |
| 3 | * waits on does not load the guard that writes it (#16622). | |
| 4 | */ | |
| 5 | ||
| 6 | /** The note a capped issue is parked with: the map reads it as `parked`, the asks as a question. */ | |
| 7 | export const CAP_NOTE = | |
| 8 | "Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try."; |
src/crew/dispatch.ts +1 −1
| @@ -97,8 +97,8 @@ import { detectAgent } from "./agent_runner.ts"; | ||
| 97 | 97 | import { followDivergence, settleAll, settleOnPush } from "./converge.ts"; |
| 98 | 98 | import { breakerTripped } from "./breaker.ts"; |
| 99 | 99 | import { REPEAT_NOTE, repeatTripped } from "./repeat.ts"; |
| 100 | import { CAP_NOTE } from "./cap_note.ts"; | |
| 101 | 100 | import { |
| 101 | CAP_NOTE, | |
| 102 | 102 | capNoted, |
| 103 | 103 | capReached, |
| 104 | 104 | HANDOVER_NOTE, |
src/crew/guard.ts +4 −1
| @@ -25,7 +25,6 @@ import { listPulls } from "../core/pulls.ts"; | ||
| 25 | 25 | import type { Repo } from "../core/repos.ts"; |
| 26 | 26 | import { directorsAmong } from "./direct.ts"; |
| 27 | 27 | import { nothingNew, plannerNothingNew } from "./news.ts"; |
| 28 | import { CAP_NOTE } from "./cap_note.ts"; | |
| 29 | 28 | |
| 30 | 29 | /** Runs one issue may start in `CAP_WINDOW_MS` unless the setting says otherwise. */ |
| 31 | 30 | export const ISSUE_RUN_CAP = 6; |
| @@ -41,6 +40,10 @@ export function runCapOf( | ||
| 41 | 40 | : (caps.issueRunCap ?? ISSUE_RUN_CAP); |
| 42 | 41 | } |
| 43 | 42 | |
| 43 | /** The note a capped issue is parked with: the map reads it as `parked`, the asks as a question. */ | |
| 44 | export const CAP_NOTE = | |
| 45 | "Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try."; | |
| 46 | ||
| 44 | 47 | /** What a skipped follow-up records, and what its run says when one was already queued. */ |
| 45 | 48 | export const SKIP_SUMMARY = "skipped: nothing new to act on since the last run"; |
| 46 | 49 |
src/feed/feed.ts +1 −1
| @@ -7,7 +7,6 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import type { Database } from "bun:sqlite"; |
| 10 | import { FEED_LIMIT_MAX } from "../core/page_ceilings.ts"; | |
| 11 | 10 | import { chipsOf, type Chips } from "../core/feed_chips.ts"; |
| 12 | 11 | import { chipHides } from "./chips.ts"; |
| 13 | 12 | import { dismissedItems, mutedRepos } from "../core/interactions.ts"; |
| @@ -26,6 +25,7 @@ import { settledOf } from "./settled.ts"; | ||
| 26 | 25 | import { repliesOf } from "./replies.ts"; |
| 27 | 26 | |
| 28 | 27 | export const FEED_LIMIT_DEFAULT = 20; |
| 28 | export const FEED_LIMIT_MAX = 50; | |
| 29 | 29 | |
| 30 | 30 | const CURSOR = /^(-?\d{1,6}(?:\.\d{1,6})?)\|([a-z]{2,12}:[A-Za-z0-9_.:-]{1,160})$/; |
| 31 | 31 |
src/feed/last_seen.ts +3 −2
| @@ -11,10 +11,11 @@ import { chipsOf } from "../core/feed_chips.ts"; | ||
| 11 | 11 | import { dismissedItems, mutedRepos } from "../core/interactions.ts"; |
| 12 | 12 | import type { User } from "../core/users.ts"; |
| 13 | 13 | import { chipHides } from "./chips.ts"; |
| 14 | import { NEW_COUNT_CAP } from "./new_count_cap.ts"; | |
| 15 | ||
| 16 | 14 | import { viewerCandidates } from "./feed.ts"; |
| 17 | 15 | |
| 16 | /** Counted up to here; more is "99+", so the read never walks a long absence. */ | |
| 17 | export const NEW_COUNT_CAP = 99; | |
| 18 | ||
| 18 | 19 | /** |
| 19 | 20 | * How long a count stands when no event has been written: what no event sees (a grant, a watch). |
| 20 | 21 | */ |
src/feed/new_count_cap.ts deleted −7
src/feed/newer_label.ts +1 −1
src/feed/timeline.ts +1 −2
| @@ -25,8 +25,7 @@ import { dismissedItems, mutedRepos } from "../core/interactions.ts"; | ||
| 25 | 25 | import { getReposByIds } from "../core/repos.ts"; |
| 26 | 26 | import type { User } from "../core/users.ts"; |
| 27 | 27 | import { chipHides } from "./chips.ts"; |
| 28 | import { FEED_LIMIT_MAX } from "../core/page_ceilings.ts"; | |
| 29 | import { decorate, FEED_LIMIT_DEFAULT } from "./feed.ts"; | |
| 28 | import { decorate, FEED_LIMIT_DEFAULT, FEED_LIMIT_MAX } from "./feed.ts"; | |
| 30 | 29 | import { eventCandidates } from "./items.ts"; |
| 31 | 30 | import { showFilter, type Show } from "./mine.ts"; |
| 32 | 31 | import { ago, type FeedItem } from "./rank.ts"; |
src/fleet/verbs.ts +1 −2
| @@ -21,8 +21,7 @@ import { | ||
| 21 | 21 | setIssueLabels, |
| 22 | 22 | setIssueState, |
| 23 | 23 | } from "../actions/issues.ts"; |
| 24 | import { linkIssue, unlinkIssue } from "../actions/dependencies.ts"; | |
| 25 | import { dependencyWords } from "../actions/plan_words.ts"; | |
| 24 | import { linkIssue, unlinkIssue, dependencyWords } from "../actions/dependencies.ts"; | |
| 26 | 25 | import { updateRepoSettings } from "../actions/repos.ts"; |
| 27 | 26 | import { cancelRepoRun, requeueRepoRun } from "../actions/runs.ts"; |
| 28 | 27 | import { isCrew } from "../core/agents.ts"; |
src/http/api.ts +1 −2
| @@ -97,8 +97,7 @@ import { | ||
| 97 | 97 | } from "../actions/contribute.ts"; |
| 98 | 98 | import { watchMilestone } from "../actions/watches.ts"; |
| 99 | 99 | import { THOUGHT_MAX, keepThought } from "../actions/thought.ts"; |
| 100 | import { SEARCH_LIMIT_MAX } from "../core/page_ceilings.ts"; | |
| 101 | import { search, searchRefusal, searchWithin, type SearchPhase } from "../actions/search.ts"; | |
| 100 | import { SEARCH_LIMIT_MAX, search, searchRefusal, searchWithin, type SearchPhase } from "../actions/search.ts"; | |
| 102 | 101 | import { runRepos } from "./run_gate.ts"; |
| 103 | 102 | import { |
| 104 | 103 | commitToBranch, |
src/http/api/business_plan.ts +1 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | import { |
| 8 | ATLAS_BODY_MAX, | |
| 8 | 9 | businessItems, |
| 9 | 10 | checkPillar, |
| 10 | 11 | confirmBusinessPlan, |
| @@ -12,7 +13,6 @@ import { | ||
| 12 | 13 | spawnSeed, |
| 13 | 14 | stampOf, |
| 14 | 15 | } from "../../actions/business_plan.ts"; |
| 15 | import { ATLAS_BODY_MAX } from "../../actions/plan_words.ts"; | |
| 16 | 16 | import { loadRepo } from "../api.ts"; |
| 17 | 17 | import type { Handler } from "../context.ts"; |
| 18 | 18 | import { apiError, boundedBody, json, notFound, requireScope } from "../respond.ts"; |
src/http/api/issues.ts +1 −2
| @@ -15,8 +15,7 @@ import { holds, weakEtag } from "../etag.ts"; | ||
| 15 | 15 | import { ISSUE_TEAMS_SAY, nameTeams } from "../../actions/issue_teams.ts"; |
| 16 | 16 | import { askEstimate, recordEstimate } from "../../actions/estimates.ts"; |
| 17 | 17 | import { estimatesOf } from "../../core/estimates.ts"; |
| 18 | import { confirmIssue, linkIssue, unlinkIssue } from "../../actions/dependencies.ts"; | |
| 19 | import { dependencyWords } from "../../actions/plan_words.ts"; | |
| 18 | import { confirmIssue, dependencyWords, linkIssue, unlinkIssue } from "../../actions/dependencies.ts"; | |
| 20 | 19 | import { |
| 21 | 20 | addCommentThrough, |
| 22 | 21 | closingFrom, |
src/http/feed.ts +1 −1
| @@ -32,8 +32,8 @@ import { feedDigest } from "../web/studio/since.ts"; | ||
| 32 | 32 | import { holds } from "../web/feeds.ts"; |
| 33 | 33 | import { share, RECIPIENTS_MAX } from "../feed/share.ts"; |
| 34 | 34 | import { canRead, getRepo } from "../core/repos.ts"; |
| 35 | import { FEED_LIMIT_MAX } from "../core/page_ceilings.ts"; | |
| 36 | 35 | import { |
| 36 | FEED_LIMIT_MAX, | |
| 37 | 37 | parseCursor, |
| 38 | 38 | readFeed, |
| 39 | 39 | } from "../feed/feed.ts"; |
src/http/mcp/tools/atlas.ts +1 −1
src/http/mcp/tools/feed.ts +1 −2
| @@ -1,5 +1,4 @@ | ||
| 1 | import { FEED_LIMIT_MAX } from "../../../core/page_ceilings.ts"; | |
| 2 | import { FEED_LIMIT_DEFAULT, parseCursor, readFeed } from "../../../feed/feed.ts"; | |
| 1 | import { FEED_LIMIT_DEFAULT, FEED_LIMIT_MAX, parseCursor, readFeed } from "../../../feed/feed.ts"; | |
| 3 | 2 | import { parseBefore, readTimeline } from "../../../feed/timeline.ts"; |
| 4 | 3 | import { CURSOR_NOT_ISSUED } from "../../../actions/feed_words.ts"; |
| 5 | 4 | import { appFilterOf, APP_UNKNOWN_LINE, onlyLine } from "../../../feed/app_filter.ts"; |
src/http/mcp/tools/plan.ts +1 −2
| @@ -1,5 +1,4 @@ | ||
| 1 | import { openPlan, parsePlan, proposePlan } from "../../../actions/plan.ts"; | |
| 2 | import { PLAN_MAX } from "../../../actions/plan_words.ts"; | |
| 1 | import { openPlan, parsePlan, PLAN_MAX, proposePlan } from "../../../actions/plan.ts"; | |
| 3 | 2 | import { good, bad, type Tool, APP_ARG, planRepo, isAnswer } from "../shared.ts"; |
| 4 | 3 | |
| 5 | 4 | export const tool: Tool = { |
src/http/mcp/tools/system.ts +1 −1
| @@ -93,7 +93,7 @@ export const tool: Tool = { | ||
| 93 | 93 | const reader = telemetryReader(ctx.app, user); |
| 94 | 94 | if (!reader) return badBlocked("forbidden", noTelemetryBlocked(ctx.app, user, "Reading this forge's maintenance workers takes the telemetry:read grant.")); |
| 95 | 95 | noteRead(ctx.app, user, reader, "system"); |
| 96 | return good({ workers: weekRows(ctx.app.db, duties().map((d) => d.name)).map((w) => ({ ...w, says: resultWords(w) })) }); | |
| 96 | return good({ workers: weekRows(ctx.app.db, duties.map((d) => d.name)).map((w) => ({ ...w, says: resultWords(w) })) }); | |
| 97 | 97 | } |
| 98 | 98 | if (args["kind"] === "adopted") { |
| 99 | 99 | if (!user.isAdmin) return bad("forbidden", "only an admin of this forge reads its child forges across a restart"); |
src/http/mcp/tools/wait_for.ts +1 −2
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | import { THREAD_SAYS } from "../../../actions/thread_words.ts"; |
| 2 | import { linkIssue } from "../../../actions/dependencies.ts"; | |
| 3 | import { dependencyWords } from "../../../actions/plan_words.ts"; | |
| 2 | import { dependencyWords, linkIssue } from "../../../actions/dependencies.ts"; | |
| 4 | 3 | import { stopWaiting } from "../../../actions/gate.ts"; |
| 5 | 4 | import { good, bad, type Tool, APP_ARG, planRepo, issueArg, isAnswer } from "../shared.ts"; |
| 6 | 5 |
src/http/view_stream.ts +1 −2
| @@ -9,8 +9,7 @@ | ||
| 9 | 9 | * A stream ends with its token (revoked, expired, its person suspended) and |
| 10 | 10 | * is held at most `STREAMS_PER_TOKEN` at a time per credential. |
| 11 | 11 | */ |
| 12 | import { forgeViewText } from "../actions/forge_view.ts"; | |
| 13 | import { VIEW_TTL_MS } from "../actions/forge_view_ttl.ts"; | |
| 12 | import { forgeViewText, VIEW_TTL_MS } from "../actions/forge_view.ts"; | |
| 14 | 13 | import { tokenLive } from "../core/tokens.ts"; |
| 15 | 14 | import { getUserById, isActive } from "../core/users.ts"; |
| 16 | 15 | import { heldOf } from "../perf/held.ts"; |
src/maintain/pause.ts +2 −2
| @@ -116,7 +116,7 @@ function stateWords(name: string, s: Row | null, last: string | undefined, f: { | ||
| 116 | 116 | * after a duty's newest `ok` (and after its last resume), the only ones `failing` can count. |
| 117 | 117 | */ |
| 118 | 118 | export function dutyStates(db: Database, now = Date.now()): DutyState[] { |
| 119 | const names = JSON.stringify(registered().map((d) => d.name)); | |
| 119 | const names = JSON.stringify(registered.map((d) => d.name)); | |
| 120 | 120 | const heads = db |
| 121 | 121 | .query( |
| 122 | 122 | `SELECT d.value AS name, s.paused, s.reason, s.by, s.since, s.from_run, |
| @@ -146,7 +146,7 @@ export function dutyStates(db: Database, now = Date.now()): DutyState[] { | ||
| 146 | 146 | }); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | export const knownDuty = (name: string): boolean => registered().some((d) => d.name === name); | |
| 149 | export const knownDuty = (name: string): boolean => registered.some((d) => d.name === name); | |
| 150 | 150 | |
| 151 | 151 | /** One switch for page, API and MCP: the same words. */ |
| 152 | 152 | export function switchDuty(db: Database, name: unknown, paused: unknown, by: string): { ok: true; says: string } | { ok: false; code: "invalid" | "not_found"; says: string } { |
src/maintain/registry.ts +3 −14
| @@ -33,18 +33,7 @@ export function loadDuties(from: URL = dir): Duty[] { | ||
| 33 | 33 | }); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | /** | |
| 37 | * The duties plus the one that watches them for silence. Built on the first call, not when this | |
| 38 | * module loads: a duty file reaches the app's modules, which reach this registry, so loading the | |
| 39 | * files here while one of them is still mid-load threw whichever way a caller entered the cycle | |
| 40 | * (#16622). Every caller runs after the graph is loaded. | |
| 41 | */ | |
| 42 | export function duties(): readonly Duty[] { | |
| 43 | if (built === undefined) { | |
| 44 | const others = loadDuties(); | |
| 45 | built = [...others, dutyIdle(others)]; | |
| 46 | } | |
| 47 | return built; | |
| 48 | } | |
| 36 | const others: readonly Duty[] = loadDuties(); | |
| 49 | 37 | |
| 50 | let built: readonly Duty[] | undefined; | |
| 38 | /** The duties plus the one that watches them for silence. */ | |
| 39 | export const duties: readonly Duty[] = [...others, dutyIdle(others)]; |
src/maintain/runner.ts +1 −1
| @@ -32,7 +32,7 @@ export interface Maintain { | ||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | export function startMaintain(app: App, options: { duties?: readonly Duty[]; everyMs?: number; timeoutMs?: number; keep?: number } = {}): Maintain { |
| 35 | const list = options.duties ?? registered(); | |
| 35 | const list = options.duties ?? registered; | |
| 36 | 36 | const seen = new Set<string>(); |
| 37 | 37 | for (const d of list) { |
| 38 | 38 | if (!validName(d.name)) throw new Error(`maintenance duty name "${d.name}" is not lowercase words and dashes`); |
src/maintain/schedule.ts +1 −1
| @@ -55,7 +55,7 @@ export function scheduleOf(o: { lastStarted: number | undefined; intervalMs: num | ||
| 55 | 55 | export function dutySchedules(db: Database, states: readonly { name: string; paused: boolean }[], now: number): Map<string, Schedule> { |
| 56 | 56 | const results = lastResultAll(db); |
| 57 | 57 | const paused = new Map(states.map((d) => [d.name, d.paused])); |
| 58 | return new Map(registered().map((d) => [d.name, scheduleOf({ lastStarted: results.get(d.name)?.started, intervalMs: d.intervalMs, paused: paused.get(d.name) === true, now, last: results.get(d.name) })])); | |
| 58 | return new Map(registered.map((d) => [d.name, scheduleOf({ lastStarted: results.get(d.name)?.started, intervalMs: d.intervalMs, paused: paused.get(d.name) === true, now, last: results.get(d.name) })])); | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
src/spawn/clients.ts +7 −1
| @@ -39,7 +39,6 @@ import { billTo, personReading } from "./person_activity.ts"; | ||
| 39 | 39 | import { archiveProposal, type ArchiveProposal } from "./archive_proposal.ts"; |
| 40 | 40 | import { appLinkLines, type AppLinkLine } from "./app_links.ts"; |
| 41 | 41 | import { madeFromOf, type MadeFrom } from "./template_record.ts"; |
| 42 | import { servedWindow } from "./suite_defaults.ts"; | |
| 43 | 42 | import { NO_KEY_HELD, NO_KEY_HOST_LINE } from "../crew/no_key.ts"; |
| 44 | 43 | |
| 45 | 44 | /** What a spawned forge says about itself to anyone: nothing more. */ |
| @@ -576,6 +575,13 @@ export const memoryOf = (rows: readonly Pick<ClientRow, "size">[]): number => | ||
| 576 | 575 | /** `memoryOf` the list last read; undefined before any was. */ |
| 577 | 576 | export const servedMemoryMiB = (app: App): number | undefined => heldMemory.get(app); |
| 578 | 577 | const building = new WeakMap<App, Promise<ClientRow[]>>(); |
| 578 | /** | |
| 579 | * The list a page serves is looked at again in the background when it is older than `ms`. At 0 | |
| 580 | * (the suite's setting) a read waits for a fresh one: a test changes a forge and reads the list at | |
| 581 | * once. | |
| 582 | */ | |
| 583 | export const servedWindow = { ms: 15_000 }; | |
| 584 | ||
| 579 | 585 | /** |
| 580 | 586 | * Read every row now, off the request: what `servedRows` answers from. One at a time; a caller |
| 581 | 587 | * that comes while one is being made takes that one. `probe: false` asks no child anything. |
src/spawn/door.ts +11 −9
| @@ -12,7 +12,6 @@ import { contributeAnswer, wantsToContribute } from "./contribute_words.ts"; | ||
| 12 | 12 | import { nameShapeVerdict } from "./name_verdict.ts"; |
| 13 | 13 | import { linkRequestVisitor } from "../perf/visitor_link.ts"; |
| 14 | 14 | import { templateOfInput } from "../actions/template_timing.ts"; |
| 15 | import { watchProbeDefault } from "./suite_defaults.ts"; | |
| 16 | 15 | import { startWatch, probeOf, type Probe } from "./live.ts"; |
| 17 | 16 | import { firstProof, homeBudgetOf, proves, reachWords, settleChild, type ChildReach } from "./reach.ts"; |
| 18 | 17 | import { |
| @@ -93,6 +92,16 @@ export function probeFor(app: App, url: string, timeoutMs: number): Probe { | ||
| 93 | 92 | return swapped ? swapped(url) : probeOf(url, timeoutMs); |
| 94 | 93 | } |
| 95 | 94 | |
| 95 | let watchProbe: (url: string) => Probe = probeOf; | |
| 96 | /** | |
| 97 | * Tests: how a new child is asked whether it is live, for every forge, unless `useProbe` gave one. | |
| 98 | * The suite's children answer nowhere, so each would keep its place among the births for the whole | |
| 99 | * cap; `test/helpers/preload.ts` has them answer at once. | |
| 100 | */ | |
| 101 | export function useWatchProbeByDefault(probe: ((url: string) => Probe) | undefined): void { | |
| 102 | watchProbe = probe ?? probeOf; | |
| 103 | } | |
| 104 | ||
| 96 | 105 | /** Tests swap how a new child is asked whether it is live. */ |
| 97 | 106 | export function useProbe(app: App, probe: (url: string) => Probe): void { |
| 98 | 107 | probes.set(app, probe); |
| @@ -578,14 +587,7 @@ export async function spawnDoor( | ||
| 578 | 587 | let watching = false; |
| 579 | 588 | try { |
| 580 | 589 | up = bootHostedChild(ctx.app, made.value.name); |
| 581 | const probeFor = probes.get(ctx.app) ?? watchProbeDefault.probe ?? probeOf; | |
| 582 | watching = startWatch(ctx.app, { | |
| 583 | name: made.value.name, | |
| 584 | startedAt, | |
| 585 | ...templateOfInput(raw["template"]), | |
| 586 | probe: probeFor(made.value.url), | |
| 587 | onSettled: place.release, | |
| 588 | }); | |
| 590 | watching = startWatch(ctx.app, { name: made.value.name, startedAt, ...templateOfInput(raw["template"]), probe: (probes.get(ctx.app) ?? watchProbe)(made.value.url), onSettled: place.release }); | |
| 589 | 591 | } finally { |
| 590 | 592 | if (!watching) place.release(); |
| 591 | 593 | } |
src/spawn/reach.ts +8 −2
| @@ -30,7 +30,6 @@ import { uncleanInFirstMinutes } from "../kernel/boots.ts"; | ||
| 30 | 30 | import { lastStop, stoppedMark } from "./stopped.ts"; |
| 31 | 31 | import { readRecord } from "./cell_record.ts"; |
| 32 | 32 | import { during } from "../perf/jobs.ts"; |
| 33 | import { reachDefault } from "./suite_defaults.ts"; | |
| 34 | 33 | |
| 35 | 34 | export const APP_HEADER = "x-forge-app"; |
| 36 | 35 | |
| @@ -103,7 +102,14 @@ export function useReach(app: App, o: Options): void { | ||
| 103 | 102 | options.set(app, o); |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | const optionsOf = (app: App): Options => options.get(app) ?? reachDefault; | |
| 105 | let fallback: Options = {}; | |
| 106 | ||
| 107 | /** What every app without its own `useReach` does; the test preload turns proving off. */ | |
| 108 | export function useReachByDefault(o: Options): void { | |
| 109 | fallback = o; | |
| 110 | } | |
| 111 | ||
| 112 | const optionsOf = (app: App): Options => options.get(app) ?? fallback; | |
| 107 | 113 | /** The most a spawn holds its reply for the new forge to come up and answer. */ |
| 108 | 114 | export const homeBudgetOf = (app: App): number => optionsOf(app).homeWaitMs ?? HOME_WAIT_MS; |
| 109 | 115 | const off = (app: App): boolean => optionsOf(app).fetch === undefined && optionsOf(app).off === true; |
src/spawn/suite_defaults.ts deleted −23
| @@ -1,23 +0,0 @@ | ||
| 1 | /** | |
| 2 | * What the test suite sets for every forge before any test file loads (`test/helpers/preload.ts`). | |
| 3 | * Plain state with no imports of the spawn modules that read it: the preload touches only this | |
| 4 | * file, so a test file that never reaches the spawn door does not pay to load it (#16622). | |
| 5 | */ | |
| 6 | ||
| 7 | import type { Probe } from "./live.ts"; | |
| 8 | ||
| 9 | /** How long a served list of children stays fresh; see `servedWindow` in `clients.ts`. */ | |
| 10 | export const servedWindow = { ms: 15_000 }; | |
| 11 | ||
| 12 | /** What every app without its own `useReach` does; see `useReachByDefault` in `reach.ts`. */ | |
| 13 | export const reachDefault: { | |
| 14 | off?: boolean; | |
| 15 | fetch?: (url: string, init?: RequestInit) => Promise<Response>; | |
| 16 | settleMs?: number; | |
| 17 | homeWaitMs?: number; | |
| 18 | pollMs?: number; | |
| 19 | confirmMs?: number; | |
| 20 | } = {}; | |
| 21 | ||
| 22 | /** How a new child is asked whether it is live, when set; see `door.ts`. */ | |
| 23 | export const watchProbeDefault: { probe?: (url: string) => Probe } = {}; |
src/tui/screens/atlas.ts +1 −1
src/tui/screens/dutybudgets.ts +3 −3
| @@ -19,7 +19,7 @@ const mayAct = (session: Session): boolean => session.user?.isAdmin === true && | ||
| 19 | 19 | /** One duty a line, the chosen one marked; empty for anyone the gate refuses. */ |
| 20 | 20 | export function budgetLines(session: Session, chosen: number): string[] { |
| 21 | 21 | if (!mayAct(session)) return []; |
| 22 | return duties().map((d, i) => { | |
| 22 | return duties.map((d, i) => { | |
| 23 | 23 | const b = budgetOf(session.db, d); |
| 24 | 24 | const u = usedToday(session.db, d.name, new Date()); |
| 25 | 25 | return `${i === chosen ? ">" : " "} ${d.name}: ${u.runs} of ${b.runsPerDay} runs, $${u.dollars.toFixed(2)} of $${b.dollarsPerDay.toFixed(2)} today (${d.budget.reason})`; |
| @@ -29,7 +29,7 @@ export function budgetLines(session: Session, chosen: number): string[] { | ||
| 29 | 29 | /** Move the chosen duty's budget by `delta` (or back to its own with `reset`); what it says, or nothing for anyone the gate refuses. */ |
| 30 | 30 | export function moveBudget(session: Session, chosen: number, kind: BudgetKind, delta: number, reset = false): string { |
| 31 | 31 | if (!mayAct(session)) return ""; |
| 32 | const d = duties()[chosen]; | |
| 32 | const d = duties[chosen]; | |
| 33 | 33 | if (d === undefined) return ""; |
| 34 | 34 | const actor = session.user!.id; |
| 35 | 35 | if (reset) { |
| @@ -58,7 +58,7 @@ export function dutyBudgetScreen(session: Session, ctx: Ctx): Screen { | ||
| 58 | 58 | key(e) { |
| 59 | 59 | if (e.ctrl || e.alt) return true; |
| 60 | 60 | if (e.key === "esc" || e.key === "q") ctx.pop(); |
| 61 | else if (e.key === "j" || e.key === "down") chosen = Math.min(chosen + 1, duties().length - 1); | |
| 61 | else if (e.key === "j" || e.key === "down") chosen = Math.min(chosen + 1, duties.length - 1); | |
| 62 | 62 | else if (e.key === "k" || e.key === "up") chosen = Math.max(chosen - 1, 0); |
| 63 | 63 | else if (e.key === "+") note = moveBudget(session, chosen, "runs", 1); |
| 64 | 64 | else if (e.key === "-") note = moveBudget(session, chosen, "runs", -1); |
src/tui/screens/entries.ts +8 −16
| @@ -47,28 +47,20 @@ export function entryFiles(dir: string = import.meta.dir): [string, string[]][] | ||
| 47 | 47 | }); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | let entries: readonly PaletteEntry[] | undefined; | |
| 51 | ||
| 52 | /** | |
| 53 | * Every entry the files declare, by rank, then file name, then export name. Read on first use, not | |
| 54 | * at load: the screen files import modules that may still be loading when this one is. | |
| 55 | */ | |
| 56 | export function allEntries(): readonly PaletteEntry[] { | |
| 57 | entries ??= entryFiles() | |
| 58 | .flatMap(([f, names]) => { | |
| 59 | const mod = require(join(import.meta.dir, f)) as Record<string, PaletteEntry>; | |
| 60 | return [...names].sort().map((k) => mod[k]!); | |
| 61 | }) | |
| 62 | .sort((a, b) => a.rank - b.rank); | |
| 63 | return entries; | |
| 64 | } | |
| 50 | /** Every entry the files declare, by rank, then file name, then export name. */ | |
| 51 | export const ENTRIES: readonly PaletteEntry[] = entryFiles() | |
| 52 | .flatMap(([f, names]) => { | |
| 53 | const mod = require(join(import.meta.dir, f)) as Record<string, PaletteEntry>; | |
| 54 | return [...names].sort().map((k) => mod[k]!); | |
| 55 | }) | |
| 56 | .sort((a, b) => a.rank - b.rank); | |
| 65 | 57 | |
| 66 | 58 | /** |
| 67 | 59 | * Put each entry the session is offered into `commands`, after the command it names or at the end. |
| 68 | 60 | */ |
| 69 | 61 | export function addEntries(commands: Command[], session: Session, ctx: Ctx): void { |
| 70 | 62 | const placed = new Map<string, number>(); |
| 71 | for (const e of allEntries()) { | |
| 63 | for (const e of ENTRIES) { | |
| 72 | 64 | if (!e.offered(session)) continue; |
| 73 | 65 | const command: Command = { id: e.id, title: e.title, hint: e.hint, run: () => e.run(session, ctx) }; |
| 74 | 66 | const anchor = e.after?.find((id) => commands.some((c) => c.id === id)); |
src/tui/screens/issue.ts +5 −2
| @@ -27,8 +27,11 @@ import { | ||
| 27 | 27 | TAKEN_UP, |
| 28 | 28 | } from "../../actions/issues.ts"; |
| 29 | 29 | import { sealedWords, sealRefusedWords } from "../../actions/seal_issue_words.ts"; |
| 30 | import { linkIssue, unlinkIssue } from "../../actions/dependencies.ts"; | |
| 31 | import { dependencyWords } from "../../actions/plan_words.ts"; | |
| 30 | import { | |
| 31 | dependencyWords, | |
| 32 | linkIssue, | |
| 33 | unlinkIssue, | |
| 34 | } from "../../actions/dependencies.ts"; | |
| 32 | 35 | import { THREAD_SAYS } from "../../actions/thread_words.ts"; |
| 33 | 36 | import { ISSUE_TEAMS_SAY, nameTeams } from "../../actions/issue_teams.ts"; |
| 34 | 37 | import { teamsOfIssue, TEAMS_MAX } from "../../core/issue_teams.ts"; |
src/tui/screens/maintenanceweek.ts +1 −1
| @@ -21,7 +21,7 @@ const mayRead = (session: Session): boolean => telemetryReader(session.app, sess | ||
| 21 | 21 | /** The screen's lines; empty for anyone the gate refuses. */ |
| 22 | 22 | export function weekLines(session: Session, now = new Date()): string[] { |
| 23 | 23 | if (!mayRead(session)) return []; |
| 24 | const rows = weekRows(session.app.db, duties().map((d) => d.name), now); | |
| 24 | const rows = weekRows(session.app.db, duties.map((d) => d.name), now); | |
| 25 | 25 | const width = Math.max(0, ...rows.map((r) => r.name.length)); |
| 26 | 26 | return [ |
| 27 | 27 | weekWords(rows), |
src/web/pages/maintenance_budgets.ts +3 −3
| @@ -16,10 +16,10 @@ import { btn, field as formControl } from "../ui.ts"; | ||
| 16 | 16 | |
| 17 | 17 | /** Every duty's budget row, in `names` order: two reads for all of them, not three a duty. */ |
| 18 | 18 | export function budgetRows(app: App, names: readonly string[], now = new Date()): Html[] { |
| 19 | const budgets = budgetsOf(app.db, duties()); | |
| 19 | const budgets = budgetsOf(app.db, duties); | |
| 20 | 20 | const used = usedTodayAll(app.db, now); |
| 21 | 21 | return names.map((name) => { |
| 22 | const d = duties().find((x) => x.name === name); | |
| 22 | const d = duties.find((x) => x.name === name); | |
| 23 | 23 | const b = budgets.get(name); |
| 24 | 24 | return d === undefined || b === undefined ? html`` : budgetOfRow(d, b, used.get(name) ?? { runs: 0, dollars: 0 }); |
| 25 | 25 | }); |
| @@ -44,7 +44,7 @@ export async function maintenanceBudget(ctx: Ctx): Promise<Response> { | ||
| 44 | 44 | if (user === undefined || !user.isAdmin || user.kind === "agent") return flashTo(ctx, "/maintenance", { tone: "danger", message: "Only a forge admin who is a person sets a budget." }); |
| 45 | 45 | const form = await readForm(ctx, "admin"); |
| 46 | 46 | if (form instanceof Response) return form; |
| 47 | const duty = duties().find((d) => d.name === formField(form, "duty")); | |
| 47 | const duty = duties.find((d) => d.name === formField(form, "duty")); | |
| 48 | 48 | if (duty === undefined) return flashTo(ctx, "/maintenance", { tone: "danger", message: "No such duty." }); |
| 49 | 49 | const picked: [("runs" | "dollars"), number | null][] = []; |
| 50 | 50 | for (const kind of ["runs", "dollars"] as const) { |
src/web/pages/system.ts +1 −1
| @@ -825,7 +825,7 @@ export async function systemPage(ctx: Ctx, patterns: () => readonly string[]): P | ||
| 825 | 825 | ${routeUseSection(timePhase(ctx.request, "routes", () => { |
| 826 | 826 | return leastUsed(routeUsage(ctx.app.db, patterns(), new Date())); |
| 827 | 827 | }))} |
| 828 | ${maintenanceSection(timePhase(ctx.request, "maintenance", () => weekRows(ctx.app.db, duties().map((d) => d.name))), timePhase(ctx.request, "starts", () => startStats(ctx.app.db, new Date(Date.now() - 7 * 86_400_000).toISOString())))} | |
| 828 | ${maintenanceSection(timePhase(ctx.request, "maintenance", () => weekRows(ctx.app.db, duties.map((d) => d.name))), timePhase(ctx.request, "starts", () => startStats(ctx.app.db, new Date(Date.now() - 7 * 86_400_000).toISOString())))} | |
| 829 | 829 | ${footprintSection(lastFootprint() ?? lastProof(ctx.app.config.dataDir)?.footprint ?? null)} |
| 830 | 830 | ${footingSection(standsOn)} |
| 831 | 831 | ${restoreSection(timePhase(ctx.request, "restore", () => restoreLine(lastPass(ctx.app.db), lastDrill(ctx.app.db), Date.now())))} |
src/web/pages/thread.ts +6 −2
| @@ -17,8 +17,12 @@ import { ISSUE_TEAMS_SAY, nameTeams } from "../../actions/issue_teams.ts"; | ||
| 17 | 17 | import { teamsOfIssue, TEAMS_MAX } from "../../core/issue_teams.ts"; |
| 18 | 18 | import { listTeams } from "../../core/teams.ts"; |
| 19 | 19 | import { listCrew } from "../../actions/crew.ts"; |
| 20 | import { confirmIssue, linkIssue, unlinkIssue } from "../../actions/dependencies.ts"; | |
| 21 | import { dependencyWords } from "../../actions/plan_words.ts"; | |
| 20 | import { | |
| 21 | confirmIssue, | |
| 22 | dependencyWords, | |
| 23 | linkIssue, | |
| 24 | unlinkIssue, | |
| 25 | } from "../../actions/dependencies.ts"; | |
| 22 | 26 | import { dependenciesOf } from "../../core/dependencies.ts"; |
| 23 | 27 | import { blockerByTitle, cyclePath, standingOf } from "../../core/dep_standing.ts"; |
| 24 | 28 | import { chain } from "./dep_chain.ts"; |
src/web/studio/held_posts.ts +1 −1
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | * is the same two functions as plain JS for the page. |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | import { NEW_COUNT_CAP } from "../../feed/new_count_cap.ts"; | |
| 7 | import { NEW_COUNT_CAP } from "../../feed/last_seen.ts"; | |
| 8 | 8 | import { newerLabelJs } from "../../feed/newer_label.ts"; |
| 9 | 9 | |
| 10 | 10 | /** The ids in `fresh` not in `shown`, in `fresh`'s order, each once. */ |
test/account-purge.test.ts +1 −1
| @@ -45,7 +45,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true })); | ||
| 45 | 45 | describe("the purge", () => { |
| 46 | 46 | test("is a duty on the roster, hourly", async () => { |
| 47 | 47 | const { duties } = await import("../src/maintain/registry.ts"); |
| 48 | expect(duties().some((d) => d.name === "account-purge")).toBe(true); | |
| 48 | expect(duties.some((d) => d.name === "account-purge")).toBe(true); | |
| 49 | 49 | expect(duty.intervalMs).toBe(3_600_000); |
| 50 | 50 | }); |
| 51 | 51 |
test/cloud-watch.test.ts +1 −1
| @@ -77,7 +77,7 @@ describe("cloud watch", () => { | ||
| 77 | 77 | }); |
| 78 | 78 | |
| 79 | 79 | test("the duty is on the roster", () => { |
| 80 | expect(duties().map((d) => d.name)).toContain("cloud-watch"); | |
| 80 | expect(duties.map((d) => d.name)).toContain("cloud-watch"); | |
| 81 | 81 | }); |
| 82 | 82 | |
| 83 | 83 | test("the forge's own machine and volume are quiet, and the page says when it looked", async () => { |
test/crew-guard-cap.test.ts +1 −1
| @@ -17,8 +17,8 @@ import { getIssueById, type Issue } from "../src/core/issues.ts"; | ||
| 17 | 17 | import { getRepoById, type Repo } from "../src/core/repos.ts"; |
| 18 | 18 | import { claimRun, createRun, finishRun } from "../src/core/runs.ts"; |
| 19 | 19 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 20 | import { CAP_NOTE } from "../src/crew/cap_note.ts"; | |
| 21 | 20 | import { |
| 21 | CAP_NOTE, | |
| 22 | 22 | CAP_WINDOW_MS, |
| 23 | 23 | capNoted, |
| 24 | 24 | capReached, |
test/crew-guard.test.ts +1 −1
| @@ -50,8 +50,8 @@ import { createUser, getUserByName, type User } from "../src/core/users.ts"; | ||
| 50 | 50 | import { driveRepo } from "../src/crew/autonomy.ts"; |
| 51 | 51 | import { breakerParked, breakerTripped } from "../src/crew/breaker.ts"; |
| 52 | 52 | import { queueAgentRun } from "../src/crew/dispatch.ts"; |
| 53 | import { CAP_NOTE } from "../src/crew/cap_note.ts"; | |
| 54 | 53 | import { |
| 54 | CAP_NOTE, | |
| 55 | 55 | guardCounts, |
| 56 | 56 | ISSUE_RUN_CAP, |
| 57 | 57 | SKIP_SUMMARY, |
test/displays-list.test.ts +2 −2
| @@ -21,7 +21,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 21 | 21 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 22 | 22 | import { DISPLAYS_SENTENCE } from "../src/display/known.ts"; |
| 23 | 23 | import { entry as displaysEntry, displaysScreen } from "../src/tui/screens/displays.ts"; |
| 24 | import { allEntries } from "../src/tui/screens/entries.ts"; | |
| 24 | import { ENTRIES } from "../src/tui/screens/entries.ts"; | |
| 25 | 25 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 26 | 26 | import { settleApp } from "./helpers/tui.ts"; |
| 27 | 27 | import { statements } from "./helpers/statements.ts"; |
| @@ -198,7 +198,7 @@ describe("the displays list, page and terminal screen", () => { | ||
| 198 | 198 | expect(mine).toContain("display.json is invalid"); |
| 199 | 199 | expect(mine).toContain("alice/hidden"); |
| 200 | 200 | expect(await screenText(bob)).not.toContain("alice/hidden"); |
| 201 | expect(allEntries()).toContain(displaysEntry); | |
| 201 | expect(ENTRIES).toContain(displaysEntry); | |
| 202 | 202 | }); |
| 203 | 203 | |
| 204 | 204 | test("a stranger is sent to sign in", async () => { |
test/duty-idle.test.ts +1 −1
| @@ -20,7 +20,7 @@ const run = (at: number) => watcher.run({ db: w.app.db, bus: w.app.bus, now: new | ||
| 20 | 20 | const defects = () => w.titles().filter((t) => t === titleOf("quiet-one")); |
| 21 | 21 | |
| 22 | 22 | test("registered, and a duty that never ran or ran recently files nothing", async () => { |
| 23 | expect(duties().map((d) => d.name)).toContain(NAME); | |
| 23 | expect(duties.map((d) => d.name)).toContain(NAME); | |
| 24 | 24 | expect((await run(T0)).actions).toEqual([]); |
| 25 | 25 | ran(T0); |
| 26 | 26 | expect((await run(T0 + 20 * MIN)).actions).toEqual([]); // exactly twice: not over |
test/duty-roster.test.ts +3 −3
| @@ -10,9 +10,9 @@ import { validName } from "../src/maintain/duty.ts"; | ||
| 10 | 10 | test("every duty file is on the roster, once, and the idle watcher is last", () => { |
| 11 | 11 | const files = readdirSync("src/maintain/duties").filter((f) => f.endsWith(".ts") && f !== "duty_idle.ts"); |
| 12 | 12 | expect(dutyFiles()).toEqual(files.sort()); |
| 13 | expect(duties().length).toBe(files.length + 1); | |
| 14 | expect(duties().at(-1)?.name).toBe(NAME); | |
| 15 | const names = duties().map((d) => d.name); | |
| 13 | expect(duties.length).toBe(files.length + 1); | |
| 14 | expect(duties.at(-1)?.name).toBe(NAME); | |
| 15 | const names = duties.map((d) => d.name); | |
| 16 | 16 | expect(new Set(names).size).toBe(names.length); |
| 17 | 17 | for (const n of names) expect(validName(n)).toBe(true); |
| 18 | 18 | }); |
test/efficiency-runner.test.ts +1 −1
| @@ -38,7 +38,7 @@ function falling(now: number): void { | ||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | test("run by the runner with the app, the duty finds the fall; the admin screen lists it", async () => { |
| 41 | expect(duties().map((d) => d.name)).toContain("efficiency-watcher"); | |
| 41 | expect(duties.map((d) => d.name)).toContain("efficiency-watcher"); | |
| 42 | 42 | const now = Date.now(); |
| 43 | 43 | falling(now); |
| 44 | 44 | const m = startMaintain(app, { duties: [duty], everyMs: 1e9 }); |
test/feed-new-count.test.ts +1 −2
| @@ -4,8 +4,7 @@ | ||
| 4 | 4 | */ |
| 5 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 6 | 6 | import { lastVisit } from "../src/core/home_visit.ts"; |
| 7 | import { NEW_COUNT_CAP } from "../src/feed/new_count_cap.ts"; | |
| 8 | import { newLine, newSince } from "../src/feed/last_seen.ts"; | |
| 7 | import { newLine, newSince, NEW_COUNT_CAP } from "../src/feed/last_seen.ts"; | |
| 9 | 8 | import { snappyFixture, type SnappyFixture } from "../bench/snappy.ts"; |
| 10 | 9 | |
| 11 | 10 | let f: SnappyFixture; |
test/helpers/preload.ts +5 −3
| @@ -7,7 +7,8 @@ import "../../src/kernel/bun_guard.ts"; | ||
| 7 | 7 | import { provideCpusForTest } from "../../src/core/capacity.ts"; |
| 8 | 8 | import { provideMirrorOutboundForTest } from "../../src/origins/git-mirror.ts"; |
| 9 | 9 | import { installCheapHash } from "./cheap-hash.ts"; |
| 10 | import { reachDefault, servedWindow, watchProbeDefault } from "../../src/spawn/suite_defaults.ts"; | |
| 10 | import { useReachByDefault } from "../../src/spawn/reach.ts"; | |
| 11 | import { servedWindow } from "../../src/spawn/clients.ts"; | |
| 11 | 12 | import "./roomy-disk.ts"; |
| 12 | 13 | import { provideEmptyImagesForTest } from "../../src/kernel/db.ts"; |
| 13 | 14 | import { emptyImagesIn } from "./empty-images.ts"; |
| @@ -30,7 +31,7 @@ provideEmptyImagesForTest(emptyImagesIn(join(SCRATCH_ROOT, "empty-db"))); | ||
| 30 | 31 | process.env.FORGE_DEV = "1"; |
| 31 | 32 | |
| 32 | 33 | // A suite has no public network to prove a child through (`spawn/reach.ts`); a test of reach injects its own fetch. |
| 33 | reachDefault.off = true; | |
| 34 | useReachByDefault({ off: true }); | |
| 34 | 35 | |
| 35 | 36 | // The /forges list is served from memory in production; a test reads what it just changed (`spawn/clients.ts`). |
| 36 | 37 | servedWindow.ms = 0; |
| @@ -56,4 +57,5 @@ const { provideMemoryForTest } = await import("../../src/spawn/births.ts"); | ||
| 56 | 57 | provideMemoryForTest(() => 64 * 1024 ** 3); |
| 57 | 58 | |
| 58 | 59 | // A new child of the suite answers its first look, so its place among the births is given back. |
| 59 | watchProbeDefault.probe = () => async () => true; | |
| 60 | const { useWatchProbeByDefault } = await import("../../src/spawn/door.ts"); | |
| 61 | useWatchProbeByDefault(() => async () => true); |
test/maint-stale-branches.test.ts +1 −1
| @@ -56,7 +56,7 @@ test("lists stale branches without an open pull, never the default or a pulled o | ||
| 56 | 56 | }); |
| 57 | 57 | |
| 58 | 58 | test("the duty files one finding with a count, is registered, and deletes nothing", async () => { |
| 59 | expect(duties()).toContain(duty); | |
| 59 | expect(duties).toContain(duty); | |
| 60 | 60 | const r = await duty.run({ db: app.db, bus: app.bus, now: NOW, app }); |
| 61 | 61 | expect(r.findings).toHaveLength(1); |
| 62 | 62 | expect(r.findings[0]!.probe?.number).toBe(2); |
test/maint-untested.test.ts +1 −1
test/maintain-backup-age.test.ts +2 −2
| @@ -36,7 +36,7 @@ const run = (hours: number) => duty.run(at(hours)); | ||
| 36 | 36 | const filed = () => w.titles().filter((t) => t === TITLE); |
| 37 | 37 | |
| 38 | 38 | test("the duty is registered", () => { |
| 39 | expect(duties().map((d) => d.name)).toContain("backup-age"); | |
| 39 | expect(duties.map((d) => d.name)).toContain("backup-age"); | |
| 40 | 40 | }); |
| 41 | 41 | |
| 42 | 42 | test("a backup under 36 hours old files nothing", async () => { |
| @@ -80,7 +80,7 @@ test("no backup directory set, or an empty one, is quiet", async () => { | ||
| 80 | 80 | }); |
| 81 | 81 | |
| 82 | 82 | test("the maintenance board lists backup-age as a row", () => { |
| 83 | const rows = weekRows(w.app.db, duties().map((d) => d.name)); | |
| 83 | const rows = weekRows(w.app.db, duties.map((d) => d.name)); | |
| 84 | 84 | expect(rows.map((r) => r.name)).toContain("backup-age"); |
| 85 | 85 | }); |
| 86 | 86 |
test/maintain-dead-doc-paths.test.ts +1 −1
| @@ -40,7 +40,7 @@ test("the duty makes one finding with a probe, and none when nothing is dead", a | ||
| 40 | 40 | }); |
| 41 | 41 | |
| 42 | 42 | test("the duty is registered", () => { |
| 43 | expect(duties()).toContain(duty); | |
| 43 | expect(duties).toContain(duty); | |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | 46 | test("one finding per doc, every dead path listed, and the terminal's run board counts them", async () => { |
test/maintain-disk-free.test.ts +1 −1
| @@ -116,5 +116,5 @@ test("dataSizes sums every top-level directory and the loose files, largest firs | ||
| 116 | 116 | }); |
| 117 | 117 | |
| 118 | 118 | test("the duty is in the registry", () => { |
| 119 | expect(duties().map((d) => d.name)).toContain("disk-free"); | |
| 119 | expect(duties.map((d) => d.name)).toContain("disk-free"); | |
| 120 | 120 | }); |
test/maintain-duty-states.test.ts +3 −3
| @@ -30,8 +30,8 @@ const run = (duty: string, outcome: string) => { | ||
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | test("every duty's state, batched, is the state read one duty at a time", async () => { |
| 33 | expect(duties().length).toBeGreaterThan(7); | |
| 34 | const [byPerson, byRunner, failingOn, erroredOnce, resumed, budgeted, okAfterErrors] = duties().map((d) => d.name); | |
| 33 | expect(duties.length).toBeGreaterThan(7); | |
| 34 | const [byPerson, byRunner, failingOn, erroredOnce, resumed, budgeted, okAfterErrors] = duties.map((d) => d.name); | |
| 35 | 35 | setPaused(app.db, byPerson!, true, "alice", new Date(t)); |
| 36 | 36 | for (const o of ["ok", "failed: one", "failed: two", "failed: three\nmore"]) run(byRunner!, o); |
| 37 | 37 | pauseOnErrors(app.db, byRunner!, new Date(t)); |
| @@ -46,7 +46,7 @@ test("every duty's state, batched, is the state read one duty at a time", async | ||
| 46 | 46 | |
| 47 | 47 | const now = t + 3_600_000; |
| 48 | 48 | const batched = dutyStates(app.db, now); |
| 49 | expect(batched).toEqual(duties().map((d) => dutyState(app.db, d.name, now))); | |
| 49 | expect(batched).toEqual(duties.map((d) => dutyState(app.db, d.name, now))); | |
| 50 | 50 | const said = new Map(batched.map((s) => [s.name, s.detail])); |
| 51 | 51 | expect(said.get(failingOn!)).toStartWith("on; failing since "); |
| 52 | 52 | expect(said.get(budgeted!)).toStartWith("on; failing since "); |
test/maintain-edge-kept.test.ts +1 −1
| @@ -59,7 +59,7 @@ async function run(read: Get, url: string | undefined = "https://forge.example", | ||
| 59 | 59 | const shareable = (edge: Record<string, string>): Get => async () => h({ "cache-control": "public, max-age=0, s-maxage=60", ...edge }); |
| 60 | 60 | |
| 61 | 61 | test("the duty is on the roster, hourly, and reads only the configured URL", async () => { |
| 62 | expect(duties().find((d) => d.name === "edge-kept")?.intervalMs).toBe(3_600_000); | |
| 62 | expect(duties.find((d) => d.name === "edge-kept")?.intervalMs).toBe(3_600_000); | |
| 63 | 63 | const seen: string[] = []; |
| 64 | 64 | const { once } = await run(async (u) => (seen.push(u), h({ "cache-control": "public, s-maxage=60", "cf-cache-status": "HIT" }))); |
| 65 | 65 | const r = await once(); |
test/maintain-failing.test.ts +1 −1
| @@ -25,7 +25,7 @@ let app: App; | ||
| 25 | 25 | let servers: Servers; |
| 26 | 26 | let admin = ""; |
| 27 | 27 | let adminId = ""; |
| 28 | const name = duties()[0]!.name; | |
| 28 | const name = duties[0]!.name; | |
| 29 | 29 | beforeAll(async () => { |
| 30 | 30 | root = mkdtempSync(join(tmpdir(), "forge-failing-")); |
| 31 | 31 | app = createApp({ dataDir: root, port: 0 }); |
test/maintain-flaky-tests.test.ts +1 −1
test/maintain-merged-branches.test.ts +1 −1
| @@ -70,7 +70,7 @@ test("never lists main, even when a pull merged from it", async () => { | ||
| 70 | 70 | }); |
| 71 | 71 | |
| 72 | 72 | test("the duty posts one finding with a number, and is registered", async () => { |
| 73 | expect(duties()).toContain(duty); | |
| 73 | expect(duties).toContain(duty); | |
| 74 | 74 | const r = await duty.run({ db: app.db, bus: app.bus, now: NOW, app }); |
| 75 | 75 | expect(r.findings).toHaveLength(1); |
| 76 | 76 | expect(r.findings[0]!.probe?.number).toBe(1); |
test/maintain-nothing.test.ts +1 −1
| @@ -57,7 +57,7 @@ test("a run with a finding says so and is not 'nothing'", async () => { | ||
| 57 | 57 | |
| 58 | 58 | test("the schedule read from the runs table says 'checked' for a clean row and 'found' for a finding", async () => { |
| 59 | 59 | const { duties } = await import("../src/maintain/registry.ts"); |
| 60 | const { clean, found } = { clean: duties()[0]!, found: duties()[1]! }; | |
| 60 | const { clean, found } = { clean: duties[0]!, found: duties[1]! }; | |
| 61 | 61 | app.db.exec("DELETE FROM maintenance_run"); |
| 62 | 62 | const at = new Date(Date.now() - 3 * H).toISOString(); |
| 63 | 63 | const ins = app.db.query("INSERT INTO maintenance_run (duty, started, finished, findings, outcome) VALUES (?1, ?2, ?2, ?3, 'ok')"); |
test/maintain-pause.test.ts +1 −1
test/maintain-previews-duty.test.ts +1 −1
| @@ -50,7 +50,7 @@ afterAll(async () => { | ||
| 50 | 50 | }); |
| 51 | 51 | |
| 52 | 52 | test("the duty is registered, and with nothing old it finds nothing", async () => { |
| 53 | expect(duties().some((d) => d.name === "preview-dirs")).toBe(true); | |
| 53 | expect(duties.some((d) => d.name === "preview-dirs")).toBe(true); | |
| 54 | 54 | expect(await duty.run(ctx())).toEqual({ findings: [], actions: [] }); |
| 55 | 55 | }); |
| 56 | 56 |
test/maintain-red-apps.test.ts +1 −1
test/maintain-slow-tests.test.ts +1 −1
| @@ -62,7 +62,7 @@ test("a stored log without timings is said, not guessed", async () => { | ||
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | 64 | test("it is registered", () => { |
| 65 | expect(duties().map((d) => d.name)).toContain("slow-tests"); | |
| 65 | expect(duties.map((d) => d.name)).toContain("slow-tests"); | |
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | 68 | test("the slow-tests duty is one of the rows /maintenance lists, on, from the same registry", () => { |
test/maintain-stale-issues.test.ts +1 −1
| @@ -62,5 +62,5 @@ test("at most 20 names, the rest counted; a closed report lets the next night fi | ||
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | 64 | test("the duty is in the registry", () => { |
| 65 | expect(duties().map((d) => d.name)).toContain("stale-issues"); | |
| 65 | expect(duties.map((d) => d.name)).toContain("stale-issues"); | |
| 66 | 66 | }); |
test/maintain-v1-proven.test.ts +1 −1
| @@ -120,7 +120,7 @@ test("no public origin: nothing is called", async () => { | ||
| 120 | 120 | }); |
| 121 | 121 | |
| 122 | 122 | test("the duty is registered, weekly", () => { |
| 123 | expect(duties().find((d) => d.name === "v1-proven")?.intervalMs).toBe(7 * 86_400_000); | |
| 123 | expect(duties.find((d) => d.name === "v1-proven")?.intervalMs).toBe(7 * 86_400_000); | |
| 124 | 124 | }); |
| 125 | 125 | |
| 126 | 126 | test("a passing probe notes it once on its open defect and leaves it open; the defect is found by its body key, not its title", async () => { |
test/maintain-wait-split.test.ts +1 −1
| @@ -118,7 +118,7 @@ test("the run's bound sits under the runner's deadline", () => { | ||
| 118 | 118 | }); |
| 119 | 119 | |
| 120 | 120 | test("the forge runs it", () => { |
| 121 | expect(duties().map((d) => d.name)).toContain("wait-split"); | |
| 121 | expect(duties.map((d) => d.name)).toContain("wait-split"); | |
| 122 | 122 | }); |
| 123 | 123 | |
| 124 | 124 | test("in a cell the duty never asks its own public host: loopback alone, and the line says so (#14664)", async () => { |
test/maintain.test.ts +32 −32
| @@ -102,8 +102,8 @@ test("a duty that throws is recorded as failed and the next still runs", async ( | ||
| 102 | 102 | |
| 103 | 103 | test("the pulls duty is registered and a run with no quiet pull leaves an ok row with no findings", async () => { |
| 104 | 104 | clear(); |
| 105 | expect(duties().map((d) => d.name)).toContain("stale-pulls"); | |
| 106 | const m = startMaintain(app, { duties: duties().filter((d) => d.name === "stale-pulls"), everyMs: 1e9 }); | |
| 105 | expect(duties.map((d) => d.name)).toContain("stale-pulls"); | |
| 106 | const m = startMaintain(app, { duties: duties.filter((d) => d.name === "stale-pulls"), everyMs: 1e9 }); | |
| 107 | 107 | m.stop(); |
| 108 | 108 | await m.tick(new Date("2026-11-11T12:00:00Z")); |
| 109 | 109 | const [row] = latest(app.db, 1); |
| @@ -239,7 +239,7 @@ test("a stored budget replaces the declared one, and a blank takes it back; the | ||
| 239 | 239 | expect(parseBudget("runs", "0")).toBeUndefined(); |
| 240 | 240 | expect(parseBudget("runs", "1e3")).toBeUndefined(); |
| 241 | 241 | expect(parseBudget("dollars", "0.5")).toBe(0.5); |
| 242 | for (const d of duties()) expect(d.budget.reason.length).toBeGreaterThan(10); | |
| 242 | for (const d of duties) expect(d.budget.reason.length).toBeGreaterThan(10); | |
| 243 | 243 | }); |
| 244 | 244 | |
| 245 | 245 | test("POST /maintenance/budget moves a budget for an admin, refuses a bad number, and the page shows the reason", async () => { |
| @@ -249,42 +249,42 @@ test("POST /maintenance/budget moves a budget for an admin, refuses a bad number | ||
| 249 | 249 | const cookie = `forge_session=${createSession(app.db, adminId).token}`; |
| 250 | 250 | const post = (body: Record<string, string>) => |
| 251 | 251 | fetch(`${servers.url}/maintenance/budget`, { method: "POST", redirect: "manual", headers: { cookie, origin: servers.url, "content-type": "application/x-www-form-urlencoded" }, body: new URLSearchParams(body) }); |
| 252 | const name = duties()[0]!.name; | |
| 252 | const name = duties[0]!.name; | |
| 253 | 253 | expect((await post({ duty: name, runs: "7", dollars: "2.5" })).status).toBe(303); |
| 254 | 254 | const { budgetOf } = await import("../src/maintain/budget.ts"); |
| 255 | expect(budgetOf(app.db, duties()[0]!)).toEqual({ runsPerDay: 7, dollarsPerDay: 2.5 }); | |
| 255 | expect(budgetOf(app.db, duties[0]!)).toEqual({ runsPerDay: 7, dollarsPerDay: 2.5 }); | |
| 256 | 256 | await post({ duty: name, runs: "0", dollars: "2.5" }); |
| 257 | expect(budgetOf(app.db, duties()[0]!).runsPerDay).toBe(7); | |
| 257 | expect(budgetOf(app.db, duties[0]!).runsPerDay).toBe(7); | |
| 258 | 258 | await post({ duty: name, runs: "", dollars: "" }); |
| 259 | expect(budgetOf(app.db, duties()[0]!).runsPerDay).toBe(duties()[0]!.budget.runsPerDay); | |
| 259 | expect(budgetOf(app.db, duties[0]!).runsPerDay).toBe(duties[0]!.budget.runsPerDay); | |
| 260 | 260 | const page = await (await fetch(`${servers.url}/maintenance`, { headers: { cookie } })).text(); |
| 261 | expect(page).toContain(duties()[0]!.budget.reason); | |
| 261 | expect(page).toContain(duties[0]!.budget.reason); | |
| 262 | 262 | }); |
| 263 | 263 | |
| 264 | 264 | test("only an admin moves a budget: a non-admin, a guest and a cross-origin post are refused and nothing changes", async () => { |
| 265 | 265 | const { createSession } = await import("../src/core/sessions.ts"); |
| 266 | 266 | const { budgetOf } = await import("../src/maintain/budget.ts"); |
| 267 | 267 | const id = (n: string) => (app.db.query("SELECT id FROM user WHERE username = ?1").get(n) as { id: string }).id; |
| 268 | const own = { ...budgetOf(app.db, duties()[0]!) }; | |
| 268 | const own = { ...budgetOf(app.db, duties[0]!) }; | |
| 269 | 269 | const post = (cookie: string, origin: string) => |
| 270 | 270 | fetch(`${servers.url}/maintenance/budget`, { |
| 271 | 271 | method: "POST", redirect: "manual", |
| 272 | 272 | headers: { ...(cookie ? { cookie } : {}), origin, "content-type": "application/x-www-form-urlencoded" }, |
| 273 | body: new URLSearchParams({ duty: duties()[0]!.name, runs: "3", dollars: "3" }), | |
| 273 | body: new URLSearchParams({ duty: duties[0]!.name, runs: "3", dollars: "3" }), | |
| 274 | 274 | }); |
| 275 | 275 | const bobCookie = `forge_session=${createSession(app.db, id("bob")).token}`; |
| 276 | 276 | const aliceCookie = `forge_session=${createSession(app.db, id("alice")).token}`; |
| 277 | 277 | await post(bobCookie, servers.url); |
| 278 | expect(budgetOf(app.db, duties()[0]!)).toEqual(own); | |
| 278 | expect(budgetOf(app.db, duties[0]!)).toEqual(own); | |
| 279 | 279 | await post("", servers.url); |
| 280 | expect(budgetOf(app.db, duties()[0]!)).toEqual(own); | |
| 280 | expect(budgetOf(app.db, duties[0]!)).toEqual(own); | |
| 281 | 281 | app.db.query("UPDATE user SET is_agent = 1, is_admin = 1 WHERE username = 'bob'").run(); |
| 282 | 282 | await post(bobCookie, servers.url); |
| 283 | expect(budgetOf(app.db, duties()[0]!)).toEqual(own); | |
| 283 | expect(budgetOf(app.db, duties[0]!)).toEqual(own); | |
| 284 | 284 | app.db.query("UPDATE user SET is_agent = 0, is_admin = 0 WHERE username = 'bob'").run(); |
| 285 | 285 | const cross = await post(aliceCookie, "https://evil.example"); |
| 286 | 286 | expect(cross.status).toBeGreaterThanOrEqual(400); |
| 287 | expect(budgetOf(app.db, duties()[0]!)).toEqual(own); | |
| 287 | expect(budgetOf(app.db, duties[0]!)).toEqual(own); | |
| 288 | 288 | }); |
| 289 | 289 | |
| 290 | 290 | test("a stored dollars budget is enforced, and a value equal to the declared one is not stored", async () => { |
| @@ -311,17 +311,17 @@ test("the budget screen moves a budget for an admin who is a person and shows no | ||
| 311 | 311 | const id = (app.db.query("SELECT id FROM user WHERE username = 'alice'").get() as { id: string }).id; |
| 312 | 312 | const as = (user: unknown) => ({ user, db: app.db }) as never; |
| 313 | 313 | const adminS = as({ isAdmin: true, kind: "person", id, username: "alice" }); |
| 314 | const before = budgetOf(app.db, duties()[0]!).runsPerDay; | |
| 315 | expect(budgetLines(adminS, 0).some((l) => l.startsWith("> " + duties()[0]!.name))).toBe(true); | |
| 314 | const before = budgetOf(app.db, duties[0]!).runsPerDay; | |
| 315 | expect(budgetLines(adminS, 0).some((l) => l.startsWith("> " + duties[0]!.name))).toBe(true); | |
| 316 | 316 | moveBudget(adminS, 0, "runs", 1); |
| 317 | expect(budgetOf(app.db, duties()[0]!).runsPerDay).toBe(before + 1); | |
| 317 | expect(budgetOf(app.db, duties[0]!).runsPerDay).toBe(before + 1); | |
| 318 | 318 | moveBudget(adminS, 0, "runs", 0, true); |
| 319 | expect(budgetOf(app.db, duties()[0]!).runsPerDay).toBe(duties()[0]!.budget.runsPerDay); | |
| 319 | expect(budgetOf(app.db, duties[0]!).runsPerDay).toBe(duties[0]!.budget.runsPerDay); | |
| 320 | 320 | for (const who of [as({ isAdmin: false, kind: "person", id }), as({ isAdmin: true, kind: "agent", id }), as(undefined)]) { |
| 321 | 321 | expect(budgetLines(who, 0)).toEqual([]); |
| 322 | 322 | expect(moveBudget(who, 0, "runs", 1)).toBe(""); |
| 323 | 323 | } |
| 324 | expect(budgetOf(app.db, duties()[0]!).runsPerDay).toBe(duties()[0]!.budget.runsPerDay); | |
| 324 | expect(budgetOf(app.db, duties[0]!).runsPerDay).toBe(duties[0]!.budget.runsPerDay); | |
| 325 | 325 | }); |
| 326 | 326 | |
| 327 | 327 | test("the budget screen's keys move the chosen duty's budget, and a refused session's keys do nothing", async () => { |
| @@ -331,7 +331,7 @@ test("the budget screen's keys move the chosen duty's budget, and a refused sess | ||
| 331 | 331 | let popped = 0; |
| 332 | 332 | const ctx = { invalidate: () => {}, pop: () => popped++, theme: {} } as never; |
| 333 | 333 | const press = (screen: { key?: (e: never) => boolean }, key: string) => screen.key!({ key, ctrl: false, alt: false } as never); |
| 334 | const d = duties()[0]!; | |
| 334 | const d = duties[0]!; | |
| 335 | 335 | const own = { ...budgetOf(app.db, d) }; |
| 336 | 336 | const screen = dutyBudgetScreen({ user: { isAdmin: true, kind: "person", id }, db: app.db } as never, ctx); |
| 337 | 337 | press(screen, "+"); |
| @@ -357,21 +357,21 @@ test("every duty's budget and today's use, read in two statements, are what the | ||
| 357 | 357 | const { budgetOf, budgetsOf, setBudget, usedToday, usedTodayAll } = await import("../src/maintain/budget.ts"); |
| 358 | 358 | const now = new Date("2026-11-11T12:00:00Z"); |
| 359 | 359 | const ins = app.db.query("INSERT INTO maintenance_run (duty, started, finished, findings, actions, probes, outcome, dollars) VALUES (?1, ?2, ?2, '[]', '[]', '[]', ?3, ?4)"); |
| 360 | ins.run(duties()[0]!.name, "2026-11-11T01:00:00.000Z", "ok", 0.25); | |
| 361 | ins.run(duties()[0]!.name, "2026-11-11T02:00:00.000Z", "ok", 0.5); | |
| 362 | ins.run(duties()[0]!.name, "2026-11-11T03:00:00.000Z", "budget: runs per day, 2 of 2 used", 0); | |
| 363 | ins.run(duties()[1]!.name, "2026-11-10T23:00:00.000Z", "ok", 1); | |
| 364 | setBudget(app.db, duties()[1]!, "runs", 9, "u"); | |
| 365 | app.db.query("INSERT INTO forge_setting (key, value, updated_by, updated_at) VALUES (?1, 'nonsense', 'u', '')").run(`maintain.${duties()[2]!.name}.dollars`); | |
| 366 | const budgets = budgetsOf(app.db, duties()); | |
| 360 | ins.run(duties[0]!.name, "2026-11-11T01:00:00.000Z", "ok", 0.25); | |
| 361 | ins.run(duties[0]!.name, "2026-11-11T02:00:00.000Z", "ok", 0.5); | |
| 362 | ins.run(duties[0]!.name, "2026-11-11T03:00:00.000Z", "budget: runs per day, 2 of 2 used", 0); | |
| 363 | ins.run(duties[1]!.name, "2026-11-10T23:00:00.000Z", "ok", 1); | |
| 364 | setBudget(app.db, duties[1]!, "runs", 9, "u"); | |
| 365 | app.db.query("INSERT INTO forge_setting (key, value, updated_by, updated_at) VALUES (?1, 'nonsense', 'u', '')").run(`maintain.${duties[2]!.name}.dollars`); | |
| 366 | const budgets = budgetsOf(app.db, duties); | |
| 367 | 367 | const used = usedTodayAll(app.db, now); |
| 368 | for (const d of duties()) { | |
| 368 | for (const d of duties) { | |
| 369 | 369 | expect(budgets.get(d.name)).toEqual(budgetOf(app.db, d)); |
| 370 | 370 | expect(used.get(d.name) ?? { runs: 0, dollars: 0 }).toEqual(usedToday(app.db, d.name, now)); |
| 371 | 371 | } |
| 372 | expect(budgets.get(duties()[1]!.name)!.runsPerDay).toBe(9); | |
| 373 | expect(used.get(duties()[0]!.name)).toEqual({ runs: 2, dollars: 0.75 }); | |
| 374 | setBudget(app.db, duties()[1]!, "runs", null, "u"); | |
| 375 | app.db.query("DELETE FROM forge_setting WHERE key = ?1").run(`maintain.${duties()[2]!.name}.dollars`); | |
| 372 | expect(budgets.get(duties[1]!.name)!.runsPerDay).toBe(9); | |
| 373 | expect(used.get(duties[0]!.name)).toEqual({ runs: 2, dollars: 0.75 }); | |
| 374 | setBudget(app.db, duties[1]!, "runs", null, "u"); | |
| 375 | app.db.query("DELETE FROM forge_setting WHERE key = ?1").run(`maintain.${duties[2]!.name}.dollars`); | |
| 376 | 376 | clear(); |
| 377 | 377 | }); |
test/maintenance-chapter-stall.test.ts +1 −1
test/maintenance-last-run.test.ts +3 −3
| @@ -66,10 +66,10 @@ afterAll(async () => { | ||
| 66 | 66 | * one standing alone. |
| 67 | 67 | */ |
| 68 | 68 | function seed(): { a: string; b: string; c: string; ran: string } { |
| 69 | const [a, b, c] = duties(); | |
| 69 | const [a, b, c] = duties; | |
| 70 | 70 | setSystemTime(new Date(NOW)); |
| 71 | 71 | app.db.run("DELETE FROM maintenance_run"); |
| 72 | for (const d of duties()) setPaused(app.db, d.name, false, "boss"); | |
| 72 | for (const d of duties) setPaused(app.db, d.name, false, "boss"); | |
| 73 | 73 | const ins = app.db.query("INSERT INTO maintenance_run (duty, started, finished, outcome) VALUES (?1, ?2, ?2, 'ok')"); |
| 74 | 74 | ins.run(a!.name, new Date(NOW - a!.intervalMs / 2).toISOString()); |
| 75 | 75 | ins.run(b!.name, new Date(NOW - 4 * b!.intervalMs).toISOString()); |
| @@ -98,7 +98,7 @@ test("the page shows ran/next, late in the attn tone, and says paused once", asy | ||
| 98 | 98 | test("every registered duty has a schedule; a paused one's words are only when it ran", () => { |
| 99 | 99 | seed(); |
| 100 | 100 | const all = dutySchedules(app.db, dutyStates(app.db), Date.now()); |
| 101 | expect([...all.keys()]).toEqual(duties().map((d) => d.name)); | |
| 101 | expect([...all.keys()]).toEqual(duties.map((d) => d.name)); | |
| 102 | 102 | expect(scheduleWords({ ran: "ran 2h ago", next: "next in 4h", late: true })).toBe("ran 2h ago; next in 4h"); |
| 103 | 103 | expect(scheduleWords({ ran: "ran 4d ago", next: "paused", late: false })).toBe("ran 4d ago"); |
| 104 | 104 | }); |
test/maintenance-page.test.ts +1 −1
| @@ -38,7 +38,7 @@ beforeAll(async () => { | ||
| 38 | 38 | // 200 stored rows, a third of them errored, spread over the registered duties. |
| 39 | 39 | const ins = app.db.query("INSERT INTO maintenance_run (duty, started, finished, outcome) VALUES (?1, ?2, ?2, ?3)"); |
| 40 | 40 | app.db.transaction(() => { |
| 41 | for (let i = 0; i < 200; i++) ins.run(duties()[i % duties().length]!.name, new Date(Date.now() - (200 - i) * 60_000).toISOString(), i % 3 === 0 ? "failed: boom" : "ok"); | |
| 41 | for (let i = 0; i < 200; i++) ins.run(duties[i % duties.length]!.name, new Date(Date.now() - (200 - i) * 60_000).toISOString(), i % 3 === 0 ? "failed: boom" : "ok"); | |
| 42 | 42 | })(); |
| 43 | 43 | }); |
| 44 | 44 | afterAll(async () => { |
test/maintenance-pause-who.test.ts +1 −1
| @@ -19,7 +19,7 @@ let root = ""; | ||
| 19 | 19 | let app: App; |
| 20 | 20 | let servers: Servers; |
| 21 | 21 | let admin = ""; |
| 22 | const name = duties()[0]!.name; | |
| 22 | const name = duties[0]!.name; | |
| 23 | 23 | const page = async (): Promise<string> => (await fetch(`${servers.url}/maintenance`, { headers: { authorization: `Bearer ${admin}` } })).text(); |
| 24 | 24 | |
| 25 | 25 | beforeAll(async () => { |
test/maintenance-week-doors.test.ts +4 −4
| @@ -26,7 +26,7 @@ let admin = ""; | ||
| 26 | 26 | let plain = ""; |
| 27 | 27 | let alice: User; |
| 28 | 28 | let bob: User; |
| 29 | const first = duties()[0]!.name; | |
| 29 | const first = duties[0]!.name; | |
| 30 | 30 | |
| 31 | 31 | const identity = (user?: User) => ({ sshUsername: user?.username ?? "git", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user }); |
| 32 | 32 | |
| @@ -66,7 +66,7 @@ test("MCP maintenance answers a row per worker; a non-admin is forbidden; teleme | ||
| 66 | 66 | const out = await call(admin); |
| 67 | 67 | expect(out.result.isError).not.toBe(true); |
| 68 | 68 | const { workers } = JSON.parse(out.result.content[0].text); |
| 69 | expect(workers.map((w: any) => w.name)).toEqual(duties().map((d) => d.name)); | |
| 69 | expect(workers.map((w: any) => w.name)).toEqual(duties.map((d) => d.name)); | |
| 70 | 70 | expect(workers[0]).toMatchObject({ name: first, found: 2, acted: 1, result: "ok", says: "ok in 0 ms" }); |
| 71 | 71 | expect(workers[0].last).not.toBeNull(); |
| 72 | 72 | expect(workers[1]).toMatchObject({ found: 0, acted: 0, last: null }); |
| @@ -85,8 +85,8 @@ test("MCP maintenance answers a row per worker; a non-admin is forbidden; teleme | ||
| 85 | 85 | |
| 86 | 86 | test("the terminal screen says the sentence and lists every worker, for the same gate; others get nothing", () => { |
| 87 | 87 | const lines = weekLines(new Session(app, identity(alice))); |
| 88 | expect(lines[0]).toBe(`1 of ${String(duties().length)} workers found something this week`); | |
| 89 | expect(lines.length).toBe(duties().length + 2); | |
| 88 | expect(lines[0]).toBe(`1 of ${String(duties.length)} workers found something this week`); | |
| 89 | expect(lines.length).toBe(duties.length + 2); | |
| 90 | 90 | expect(lines[2]).toContain("found 2 · acted 1"); |
| 91 | 91 | expect(lines[2]).toContain("ok in 0 ms"); |
| 92 | 92 | expect(lines[3]).toContain("not yet run"); |
test/memory-watch.test.ts −3
| @@ -69,9 +69,6 @@ test("the minute lines name the owner and the figures", () => { | ||
| 69 | 69 | const r = { rss: 5 * 1024 * MIB, heap: 1024 * MIB, commit: 512 * MIB, peakCommit: 700 * MIB, dbCeiling: 1536 * MIB }; |
| 70 | 70 | expect(memoryLine(r, 3_600_000)).toBe("memory main: rss 5120 MiB, heap 1024 MiB, process mimalloc committed 512 MiB (peak 700 MiB), database caches up to 1536 MiB, up 60 min"); |
| 71 | 71 | expect(workerMemoryLine("engine", r)).toBe("memory worker engine: heap 1024 MiB, process rss 5120 MiB"); |
| 72 | // A VM reports no heap until it has collected once; a process that loaded little has not | |
| 73 | // (#16622). | |
| 74 | Bun.gc(true); | |
| 75 | 72 | expect(readNow().heap).toBeGreaterThan(0); |
| 76 | 73 | }); |
| 77 | 74 |
test/palette-entries.test.ts +6 −6
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { expect, test } from "bun:test"; |
| 2 | 2 | import type { Command } from "../src/tui/app/palette.ts"; |
| 3 | import { addEntries, allEntries, entryFiles, type PaletteEntry } from "../src/tui/screens/entries.ts"; | |
| 3 | import { addEntries, ENTRIES, entryFiles, type PaletteEntry } from "../src/tui/screens/entries.ts"; | |
| 4 | 4 | import { mkdtempSync, writeFileSync, rmSync } from "node:fs"; |
| 5 | 5 | import { tmpdir } from "node:os"; |
| 6 | 6 | import { join } from "node:path"; |
| @@ -10,12 +10,12 @@ const stub = (id: string, after?: string[], rank = 0): PaletteEntry => ({ | ||
| 10 | 10 | id, rank, title: id, hint: "", ...(after ? { after } : {}), offered: () => true, run: () => undefined, |
| 11 | 11 | }); |
| 12 | 12 | const place = (commands: Command[], entries: PaletteEntry[]): string[] => { |
| 13 | const saved = [...allEntries()]; | |
| 14 | (allEntries() as PaletteEntry[]).splice(0, allEntries().length, ...entries); | |
| 13 | const saved = [...ENTRIES]; | |
| 14 | (ENTRIES as PaletteEntry[]).splice(0, ENTRIES.length, ...entries); | |
| 15 | 15 | try { |
| 16 | 16 | addEntries(commands, {} as never, {} as never); |
| 17 | 17 | } finally { |
| 18 | (allEntries() as PaletteEntry[]).splice(0, allEntries().length, ...saved); | |
| 18 | (ENTRIES as PaletteEntry[]).splice(0, ENTRIES.length, ...saved); | |
| 19 | 19 | } |
| 20 | 20 | return commands.map((c) => c.id); |
| 21 | 21 | }; |
| @@ -40,7 +40,7 @@ test("an entry the session is not offered is left out", () => { | ||
| 40 | 40 | // The roster is built from the directory, not listed: these are known to be in it, including the |
| 41 | 41 | // entries a file exports under another name than `entry`, in the order the palette has always had. |
| 42 | 42 | test("the palette roster holds the known entries in their pinned order", () => { |
| 43 | const ids = allEntries().map((e) => e.id); | |
| 43 | const ids = ENTRIES.map((e) => e.id); | |
| 44 | 44 | expect(ids.length).toBeGreaterThan(100); |
| 45 | 45 | const known = ["bills", "payments", "sentinel", "boards", "drift", "model-grant", "model-ceiling", "claim-start", "claim-link", "recovery-link", "new-issue-anywhere"]; |
| 46 | 46 | expect(ids.filter((id) => known.includes(id))).toEqual(known.filter((id) => ids.includes(id))); |
| @@ -55,7 +55,7 @@ test("entries sort by rank, then by file name", () => { | ||
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | 57 | test("no two entries share an id", () => { |
| 58 | const ids = allEntries().map((e) => e.id); | |
| 58 | const ids = ENTRIES.map((e) => e.id); | |
| 59 | 59 | expect(new Set(ids).size).toBe(ids.length); |
| 60 | 60 | }); |
| 61 | 61 |
test/red-main-line.test.ts +1 −1
| @@ -4,7 +4,7 @@ import { mainLineFor, redMainLine, redOnMain } from "../src/checks/red_main_line | ||
| 4 | 4 | |
| 5 | 5 | const red = (over: Partial<RedMain> = {}): RedMain => ({ |
| 6 | 6 | repoId: "r", repo: "a/forge", runId: "x", commitOid: "abcdef0123456789", failing: ["sizes hold"], |
| 7 | summary: "check failed: 1 failed", branch: "main", limit: false, flaky: false, since: "2026-11-16T00:00:00Z", ...over, | |
| 7 | summary: "check failed: 1 failed", branch: "main", limit: false, since: "2026-11-16T00:00:00Z", ...over, | |
| 8 | 8 | }); |
| 9 | 9 | const failed = (names: string[]) => ({ state: "failed" as const, checkDetail: { passed: 1, failed: names.length, names } }); |
| 10 | 10 |
test/revert-red.test.ts +2 −18
| @@ -42,12 +42,7 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 42 | 42 | return getPull(app.db, repo.id, opened.value.number)!; |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | const mainCheck = async ( | |
| 46 | state: "ok" | "failed", | |
| 47 | names: string[] = [], | |
| 48 | summary?: string, | |
| 49 | detail: object = {}, | |
| 50 | ): Promise<void> => { | |
| 45 | const mainCheck = async (state: "ok" | "failed", names: string[] = [], summary?: string): Promise<void> => { | |
| 51 | 46 | const oid = await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), "refs/heads/main"); |
| 52 | 47 | const run = createRun(app.db, { repoId: repo.id, kind: "check", env: "main", commitOid: oid ?? "" }); |
| 53 | 48 | app.db |
| @@ -56,7 +51,7 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 56 | 51 | run.id, |
| 57 | 52 | state, |
| 58 | 53 | summary ?? (state === "ok" ? "check passed in 1s" : "check failed: 1 test failed"), |
| 59 | state === "ok" ? "" : JSON.stringify({ names, ...detail }), | |
| 54 | state === "ok" ? "" : JSON.stringify({ names }), | |
| 60 | 55 | new Date().toISOString(), |
| 61 | 56 | ); |
| 62 | 57 | }; |
| @@ -124,7 +119,6 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 124 | 119 | "stopped: out of memory", |
| 125 | 120 | "the forge was stopped under this check 3 times; not trying again", |
| 126 | 121 | "check stalled: started and wrote nothing, offered to no runner, twice; not trying again", |
| 127 | "check took longer than 2400s", | |
| 128 | 122 | ]) { |
| 129 | 123 | await mainCheck("ok"); |
| 130 | 124 | await land(`b${reverts().length}${summary.length}`, `${summary}\n`); |
| @@ -134,16 +128,6 @@ describe("a red main after one landing proposes its revert", () => { | ||
| 134 | 128 | expect(reverts()).toHaveLength(0); |
| 135 | 129 | }); |
| 136 | 130 | |
| 137 | test("a red whose every failing file passes alone opens none (#16622)", async () => { | |
| 138 | await mainCheck("ok"); | |
| 139 | await land("loaded", "load\n"); | |
| 140 | await mainCheck("failed", ["t"], undefined, { files: ["test/a.test.ts"], flakyUnderLoad: ["test/a.test.ts"] }); | |
| 141 | expect(await proposeRevert(app, repo.id)).toBeUndefined(); | |
| 142 | // one file red alone besides: that one is a test's failure, and the landing is proposed | |
| 143 | await mainCheck("failed", ["t"], undefined, { files: ["test/a.test.ts", "test/b.test.ts"], flakyUnderLoad: ["test/a.test.ts"] }); | |
| 144 | expect(await proposeRevert(app, repo.id)).toBeDefined(); | |
| 145 | }); | |
| 146 | ||
| 147 | 131 | test("a green main opens none", async () => { |
| 148 | 132 | await mainCheck("ok"); |
| 149 | 133 | await land("one", "beta\n"); |
test/spawn-app-links.test.ts +1 −2
| @@ -53,8 +53,7 @@ import { bootHostedChild, openChildren } from "../src/spawn/host.ts"; | ||
| 53 | 53 | import { watchLandings } from "../src/spawn/app_follow.ts"; |
| 54 | 54 | import { chmodSync } from "node:fs"; |
| 55 | 55 | import { forgetKey } from "../src/kernel/secret.ts"; |
| 56 | import { dropServed, refreshServed, servedRows } from "../src/spawn/clients.ts"; | |
| 57 | import { servedWindow } from "../src/spawn/suite_defaults.ts"; | |
| 56 | import { dropServed, refreshServed, servedRows, servedWindow } from "../src/spawn/clients.ts"; | |
| 58 | 57 | import { anchorsOf, appLinkSummary, appLinkWords, reasonOf } from "../src/spawn/app_links.ts"; |
| 59 | 58 | import { setFollowTaking } from "../src/core/upstream_follow.ts"; |
| 60 | 59 |
test/spawn-in-process-visible.test.ts +1 −2
| @@ -22,8 +22,7 @@ import { | ||
| 22 | 22 | import { during, jobWatchOf } from "../src/perf/jobs.ts"; |
| 23 | 23 | import { liveOf } from "../src/perf/live.ts"; |
| 24 | 24 | import { stallLine } from "../src/perf/loop.ts"; |
| 25 | import { clientRows } from "../src/spawn/clients.ts"; | |
| 26 | import { servedWindow } from "../src/spawn/suite_defaults.ts"; | |
| 25 | import { clientRows, servedWindow } from "../src/spawn/clients.ts"; | |
| 27 | 26 | import { closeHostedChildren, openChildren, provideCellsForTest } from "../src/spawn/host.ts"; |
| 28 | 27 | import { hostedPlacement } from "../src/spawn/placement.ts"; |
| 29 | 28 | import { |
test/spawn-move-cell-sizes.test.ts +1 −2
| @@ -14,8 +14,7 @@ import { | ||
| 14 | 14 | } from "bun:test"; |
| 15 | 15 | import { writeFileSync } from "node:fs"; |
| 16 | 16 | import { join } from "node:path"; |
| 17 | import { clientRows } from "../src/spawn/clients.ts"; | |
| 18 | import { servedWindow } from "../src/spawn/suite_defaults.ts"; | |
| 17 | import { servedWindow, clientRows } from "../src/spawn/clients.ts"; | |
| 19 | 18 | import { provideCellsForTest, sleepIdleChildren } from "../src/spawn/host.ts"; |
| 20 | 19 | import { moveDisk } from "../src/spawn/move_check.ts"; |
| 21 | 20 | import { |
test/spawn-move-cell.test.ts +1 −2
| @@ -20,8 +20,7 @@ import { | ||
| 20 | 20 | import { Database } from "bun:sqlite"; |
| 21 | 21 | import { readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 22 | 22 | import { join } from "node:path"; |
| 23 | import { clientRows } from "../src/spawn/clients.ts"; | |
| 24 | import { servedWindow } from "../src/spawn/suite_defaults.ts"; | |
| 23 | import { servedWindow, clientRows } from "../src/spawn/clients.ts"; | |
| 25 | 24 | import { provideCellsForTest, sleepIdleChildren } from "../src/spawn/host.ts"; |
| 26 | 25 | import { moveDisk } from "../src/spawn/move_check.ts"; |
| 27 | 26 | import { |
test/spawn-sealed-host.test.ts +1 −2
| @@ -30,8 +30,7 @@ import { | ||
| 30 | 30 | stopCellChildren, |
| 31 | 31 | type CellChild, |
| 32 | 32 | } from "../src/spawn/cell.ts"; |
| 33 | import { clientRows } from "../src/spawn/clients.ts"; | |
| 34 | import { servedWindow } from "../src/spawn/suite_defaults.ts"; | |
| 33 | import { clientRows, servedWindow } from "../src/spawn/clients.ts"; | |
| 35 | 34 | import { |
| 36 | 35 | bootHostedChild, |
| 37 | 36 | closeHostedChildren, |
test/tui-drift.test.ts +2 −2
| @@ -10,7 +10,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 10 | 10 | import { createUser, type User } from "../src/core/users.ts"; |
| 11 | 11 | import type { Repo } from "../src/core/repos.ts"; |
| 12 | 12 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 13 | import { allEntries } from "../src/tui/screens/entries.ts"; | |
| 13 | import { ENTRIES } from "../src/tui/screens/entries.ts"; | |
| 14 | 14 | import { askUpdate, driftRows, driftScreen, entry } from "../src/tui/screens/drift.ts"; |
| 15 | 15 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 16 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| @@ -49,7 +49,7 @@ afterAll(async () => { | ||
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | 51 | test("the entry is in the palette list and offered to a person admin alone", () => { |
| 52 | expect(allEntries()).toContain(entry); | |
| 52 | expect(ENTRIES).toContain(entry); | |
| 53 | 53 | const a = open(alice); |
| 54 | 54 | const b = open(bob); |
| 55 | 55 | expect(entry.offered(a.session)).toBe(true); |
test/tui-issue-waits.test.ts +1 −2
| @@ -8,8 +8,7 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | ||
| 8 | 8 | import { mkdtemp, rm } from "node:fs/promises"; |
| 9 | 9 | import { tmpdir } from "node:os"; |
| 10 | 10 | import { join } from "node:path"; |
| 11 | import { linkIssue } from "../src/actions/dependencies.ts"; | |
| 12 | import { dependencyWords } from "../src/actions/plan_words.ts"; | |
| 11 | import { dependencyWords, linkIssue } from "../src/actions/dependencies.ts"; | |
| 13 | 12 | import { THREAD_SAYS } from "../src/actions/thread_words.ts"; |
| 14 | 13 | import { openIssue } from "../src/actions/issues.ts"; |
| 15 | 14 | import { openPull } from "../src/actions/pulls.ts"; |
test/tui-maintenance-pause-who.test.ts +1 −1
| @@ -29,7 +29,7 @@ afterAll(async () => { | ||
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | 31 | test("a paused duty reads 'paused by <handle> 3 h ago' in the terminal", async () => { |
| 32 | setPaused(app.db, duties()[0]!.name, true, "boss", new Date(Date.now() - 3 * 3_600_000 - 1000)); | |
| 32 | setPaused(app.db, duties[0]!.name, true, "boss", new Date(Date.now() - 3 * 3_600_000 - 1000)); | |
| 33 | 33 | const terminal = headlessTerminal(160, 40); |
| 34 | 34 | const { app: tui, session } = createForgeApp(app, { sshUsername: "boss", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: admin }, { terminal, exitHooks: false }); |
| 35 | 35 | tui.start(); |
test/verify-after-landing.test.ts −17
| @@ -252,23 +252,6 @@ describe("a red verification names its culprit", () => { | ||
| 252 | 252 | expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(1); |
| 253 | 253 | }); |
| 254 | 254 | |
| 255 | test("a red whose every file passes alone is the load's: no bisection, no revert (#16622)", async () => { | |
| 256 | await verification("ok"); | |
| 257 | await land("loaded"); | |
| 258 | const red = await verification("failed"); | |
| 259 | app.db | |
| 260 | .query("UPDATE run SET check_detail = ?2 WHERE id = ?1") | |
| 261 | .run(red.id, JSON.stringify({ passed: 0, failed: 1, names: ["thing > works"], files: [FILE], flakyUnderLoad: [FILE] })); | |
| 262 | const asked: string[] = []; | |
| 263 | const lines = await afterVerify(app, repo, getRun(app.db, red.id)!, async (_r, _e, oid) => { | |
| 264 | asked.push(oid); | |
| 265 | return undefined; | |
| 266 | }); | |
| 267 | expect(lines[0]).toContain("pass alone"); | |
| 268 | expect(asked).toEqual([]); | |
| 269 | expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(0); | |
| 270 | }); | |
| 271 | ||
| 272 | 255 | test("a push no pull carried is named in one issue", async () => { |
| 273 | 256 | await verification("ok"); |
| 274 | 257 | await commitToBranch(app, alice, repo, { branch: "main", message: "direct", files: [{ path: "b.txt", content: "b\n" }] }); |
new above
offline