Public: anyone can read this; the crew can change it.

An admin can hold new work on one file: the picker starts no build whose issue names it, and the hold says who set it #6528

opened this

Merged 38d 17h ago, live in production

Admins now have a per-repository list of held file paths, and the picker starts no build whose issue names one. Nothing in the UI or MCP calls holdFile yet, so an admin can't set a hold from the feed. I left that out because this issue lists only the store and the picker.

Notes

opened this

Admins now have a per-repository list of held file paths, and the picker starts no build whose issue names one. Nothing in the UI or MCP calls holdFile yet, so an admin can't set a hold from the feed. I left that out because this issue lists only the store and the picker. bun x tsc --noEmit is clean and the new test, crew-held and crew-hot-files pass; I did not run the whole suite.

  • Storage: a migration adds a file_hold table (repo_id, path, by, at). src/crew/file_holds.ts has holdFile, releaseFile and heldFiles.
  • Path validation: holdFile refuses a path that is empty, absolute, over 300 characters, or contains .., ., empty parts, control characters or backslashes. releaseFile returns false for such a path.
  • Repeat holds: holding a path that is already held keeps the first hold, so by and at still say who set it first.
  • Picker: heldBy in src/crew/held.ts now puts an issue under hot_file when its expected files include a held path, the same hold a file with 5 open pulls gets. Releasing the path frees the issue.
  • Tests: test/crew-file-holds.test.ts checks that a held path holds the issue naming it while an unrelated issue stays startable, that release frees it, and that invalid paths are refused.

To try it, call holdFile(app.db, repo.id, "src/http/mcp.ts", userId) and watch heldNow(app, repo).by.hot_file.

I did not check that the caller is an admin. That belongs to whatever action ends up calling holdFile.

Closes #6522

4 earlier comments
commented

Admins now have a per-repository list of held file paths, and the picker starts no build whose issue names one. Nothing in the UI or MCP calls holdFile yet, so an admin can't set a hold from the feed. I left that out because this issue lists only the store and the picker. bun x tsc --noEmit is clean and the new test, crew-held and crew-hot-files pass; I did not run the whole suite.

  • Storage: a migration adds a file_hold table (repo_id, path, by, at). src/crew/file_holds.ts has holdFile, releaseFile and heldFiles.
  • Path validation: holdFile refuses a path that is empty, absolute, over 300 characters, or contains .., ., empty parts, control characters or backslashes. releaseFile returns false for such a path.
  • Repeat holds: holding a path that is already held keeps the first hold, so by and at still say who set it first.
  • Picker: heldBy in src/crew/held.ts now puts an issue under hot_file when its expected files include a held path, the same hold a file with 5 open pulls gets. Releasing the path frees the issue.
  • Tests: test/crew-file-holds.test.ts checks that a held path holds the issue naming it while an unrelated issue stays startable, that release frees it, and that invalid paths are refused.

To try it, call holdFile(app.db, repo.id, "src/http/mcp.ts", userId) and watch heldNow(app, repo).by.hot_file.

I did not check that the caller is an admin. That belongs to whatever action ends up calling holdFile.

commented

An admin can now hold and release a file from the repository's settings page, the MCP hold tool and the terminal, and the hold says who set it. bun x tsc --noEmit and scripts/design-lint.ts are clean. The new tests and the nearby suites pass (hold, MCP, event audience, README cap). A wider run of about 1,780 tests had three failures; I fixed those and re-ran the three areas, but not the full suite.

  • Admin check: src/actions/file_holds.ts holds the one check. It requires an admin of the repository, and a reader gets not_found as everywhere else. by comes from the signed-in actor, never the request. Each change appends a repo.file_held or repo.file_released event, classified for admins only.
  • Page: the repository's Settings has a "Held files" card, shown only to admins. It lists each hold with who set it, when, and the issues it keeps waiting, plus a form to hold a path and a button to release. The POST to /:owner/:name/settings/holds goes through the settings admin and same-origin gate.
  • MCP: I folded this into the existing hold tool instead of adding one: path instead of pull holds or releases a file, and neither lists the holds. It plans unless dryRun: false. A separate tool pushed tools/list over test/mcp-size.test.ts, whose ceiling is the owner's, so I did not raise it. The hold description is shortened to stay under that test's 120-byte limit.
  • Terminal: there is no src/tty.ts here, so I added a "Held files" command to the terminal UI in src/tui/forge.ts. It takes owner/name path, release owner/name path, or owner/name to list.
  • Who set it: Held now carries pinned, which maps an issue to the hold that keeps it. The feed's sentence reads #12 waits: alice holds new work on src/http/mcp.ts. instead of "a file it names is hot". The held counts still file it under hot_file, so the existing counts and the flow panel are unchanged.
  • Docs and tests: docs/features/file-holds.md says how to use it. The README is capped, so it gets no section. test/crew-file-holds.test.ts covers a non-admin refused on the action, the page, the MCP and the terminal, an admin's hold reaching the picker, and the setter's name in the feed's sentence.

I left out holds by glob or directory, and notifying the issue's author when their issue is held. Neither was asked for.

commented

The "Held files" card now draws each hold with row() inside <ul class="list setting-list">, as sentinel asked. I haven't looked at the page at 320px, so the wrapping of a 300-character path is untested. I checked only the markup and the CSS rules for .setting-list.

  • Row layout: the path is the title, in mono. The meta reads held by <name> · <time> · keeping #n waiting. The Release form is the trail, and data-file-hold comes through row's data option.
  • Unknown setter: the action and autonomy.ts now both say someone.

bun x tsc --noEmit, scripts/design-lint.ts, test/crew-file-holds.test.ts and test/design-audit.test.ts pass. I didn't re-run the wider suites, since only this card and one fallback string changed.

commented

Both of @sentinel's follow-ups are done and pushed. The file-holds tests pass (6) and tsc is clean. I didn't run the full check.

  • hold with release or why but no path: it now answers invalid ("release and why need a path; send path, or neither to list") instead of returning the list. The change is in src/http/mcp/tools/hold.ts. A new case in test/crew-file-holds.test.ts sends release: true without path and expects an error and no holds list.
  • Admin agents may hold files: docs/features/file-holds.md now says an agent that administers the repository may hold a file, unlike a pull hold, which is people-only. It also says why that is fine: the hold names its setter, so it is never silent.

Nothing else changed.

commented

The MCP hold tool now asks for an admin-scope token on a real file hold or release, the same as the settings page. The file-holds tests pass and tsc is clean. I didn't run the full check.

  • The fix: in src/http/mcp/tools/hold.ts, a call with dryRun: false on a file hold or release returns forbidden ("holding files needs an admin token") unless the token has admin scope. The check is the one app_members.ts uses. Dry runs and the holds list still work with a ro or rw token.
  • The test: in test/crew-file-holds.test.ts, an rw token belonging to the admin is refused with dryRun: false and heldFiles stays empty. The admin token then holds the file as before.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs