feat(api): count a repo's env vars, and pin WorkerDTO's two declarations #115
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lz/agent-nexus!115
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/env-var-count"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fourth of four addressing
sidebar-issues. Stacked on #114 — merge that first.Split out of the restyle deliberately:
sidebar-issuesasks for a chip showing "num. of env vars", but delivering it needs a DTO field, a new query, a signature change threaded through two call sites and a parity test. That is backend work, and it was three quarters of the restyle's line count while having nothing to do with styling. #114 is net −13 without it.The field
env_var_countonWorkerDTO, feeding anN envchip alongside the mount count the sidebar already showed.repo_env_varsis keyed onrepo_full_name, so this is one grouped query for the whole list rather than one per workspace, and it selects counts only —encrypted_valueis never read, so it needs no master key and works while the vault is locked. Two workspaces on one repo therefore report the same number, which is what the field means.Two things worth review attention
workerRowToDTO's new parameter is required, not defaulted to 0. A default lets a future call site compile while reporting "no env vars" for a repo that has them — the same silent-wrong-value trap themounts_jsonrestatement inspawnWorkeralready carries a comment about, andspawnWorkeris exactly where it would have bitten: a new workspace inherits its repo's env immediately.WorkerDTOis declared on both sides of the wire, likeMountSpec— and unlikeMountSpecit had no parity guard. Only one drift direction is caught by the compiler:workerRowToDTOconstructs the server type, so a field the server lacks fails the build; a field the client declares and the server never sets fails nothing and arrivesundefinedthrough a non-optional type. I hit exactly that while writing this.worker-dto-parity.test.tsasserts mutual assignability, so either direction is now a compile error. Mirrorsmount-parity.test.ts, which AGENTS.md names as what makes that duplication safe.Negative-controlled: planting a client-only field made the assertion fail and name the property. A guard that cannot fail is worse than none.
Verification
env_var_countconfirmed reachingGET /api/workersagainst a seeded instance (4 env vars on one repo, 0 on the others) and rendering as a4 envchip.Gates: typecheck 4898 files / 0 errors, lint clean, 121 files / 1201 tests.