Repository navigation
feat: make the policy file the one source of what Triage may do - #688
TheGreatAxios merged 30 commits into
Conversation
|
Triage: Unsure Asking a maintainer about:
Not yet confirmed, a maintainer will check:
Waiting on:
Notes:
|
|
Second review of this PR, now at e8f6d48. It covers the seven commits since 4e9d86b. I ran these locally on e8f6d48:
When I posted this, CI's Earlier findings
New findingsNone. Two things to note, neither blocking:
Ready to merge once CI's |
e8f6d48 to
b3fc2c2
Compare
|
Review of the rebase at b3fc2c2. I compared the pull request's diff against main before the rebase (e8f6d48 against its merge base) and after it (b3fc2c2 against main), and read every hunk that differs. The policy read now carries main's The held actions list from #693 now has "Do it" and "Always, in this repository" in place of Approve. Do it needs the Do grant. Always needs grant create, a kind the policy file names, and never a kind its verdict always holds. Always goes through the Do write even when the action is the bar's own entry. The old menu, its The "not posted" wording moved to where #693 put it, in pane-report.ts, and its test was updated with it. The user manual reads as one voice. The reading pane and Taking action sections describe the same buttons and access rules. Checks: lint passes, hub and web typecheck clean, 246 web unit tests and 257 DOM tests pass. Against local Postgres, policy-read, policy-file, triage-automation, tenant-config and server tests all pass. server.postgres.test.ts needs a longer hook timeout locally, because its migrations take more than 5s here, and it passes in CI. CI on this head is green, chain included (16 pass). "a listener whose sidecar disconnected…" and "a repository with no policy file gets no manager…" both pass. The second scenario runs after the first, so a local timeout in the first also fails the second. Findings:
|
|
Fixed in 0062988: the line now reads "Do it or hide the held action", in the pane, its test and the manual. |
The renewal loop mints a second installation token with contents read for the workspace's repositories, stores it as github-read beside github under the same lock, and code review binds only it. A token GitHub widened is refused, and the portal's GitHub App row says why code review cannot run. CL-11606
… the portal CL-11606
…sitory Grants are written under an advisory lock on their holder, since stock's grant table has no unique index to insert against. One connect helper, used by GitHub connect, manifest completion and Bitbucket Data Center connect, creates the pr-triage role and gives admins use on the host's credentials and triage-do:* on every connect. Reading automatic kinds no longer creates the role. Switching a repository off or removing it deletes the role's triage-do grants on it in the same transaction as the config write, on both hosts. Invites into the Deployer role are refused like the Triage role. Refs CL-11606
…icy automation The workspace's corbitsTriage.automation is policy (the default when absent) or ask, set through the tenant patch, which needs tenant manage. Under policy, every successful policy read of an enabled repository, on both hosts, runs grantWanted: under the pr-triage role's advisory lock it inserts the missing allows for the kinds the policy and its decide rules use, posting always included, and deletes the role's allows for every other kind, so the same policy read again touches no row. The read carries the kinds as granted, and shares the tenant row's lock so a repository switched off meanwhile is not granted again. A refused, corrupt or missing read changes nothing. Switching a GitHub repository on wakes the reconcile pass; switching to policy takes effect on the next pass. Under ask the hub grants only posting, on enable, switching to it writes and removes nothing, and a policy pull request lists the kinds that will wait for a person. Settings has the switch for those who may manage the workspace. CL-11606
The stored policy read, the stored-wins-while-they-differ rule, the archive-on-match step, the corrupt status, the policy pin on repository records and the artifact routes are gone. The upgrades route answers start or ok. A repository with no file runs no triage and deploys no manager. Edited text opens a pull request over the file it was edited from, or is pushed to the default branch as one commit where the host's branch rules let the hub push; a preview route reads edited text as triage would. Every policy artifact still standing is archived once at boot.
…t or a push The editor loads the file's text, checks it as triage would, cautions before a save that lets Triage approve or merge risky changes on its own, and saves through the export route or, where the branch allows it, the push route. Autosave, drafts, merge and the stored-policy panels are gone; the triage switch writes the workspace settings itself.
…waiting policy pull requests
…ved as a pull request or a push
The portal rebuilt the kinds from the pack and the decide kinds with its own copy of policyKinds. The hub now answers them as `wanted`, computed with the contracts' policyKinds the grant writer already uses, and the portal reads them.
…s for a person Close on Unsure and merge on anything but Pass wait for a person whatever the role holds, so the policy read no longer lists them as wanted, the portal no longer shows them as missing, and policy automation no longer grants them. CL-11606
… to ask Under ask every action but the verdict waits for a person, as Settings says, so switching from policy leaves each enabled repository with posting only. CL-11606
…l make Under policy automation merging edited text grants what it uses, so a newly added approve or merge is cautioned before it is saved, not after it runs. CL-11606
…ead as one Say which workflow binds which credential (only the manager binds github, code review binds github-read, Bitbucket Data Center keeps one token), when the grant writer runs, what it grants and takes back and the locks it shares, and correct the user docs that still said every action but posting waits for a person. CL-11606
…before A grant left on a repository switched off before grants were taken back with it no longer returns when the repository is enabled again. CL-11606
…d from A client that left the sha out skipped the check that the file had not changed meanwhile, and could overwrite it unseen. CL-11606
Two reads of one policy file could commit their grants in either order, so an older read could put back what a newer one took away until the next read. CL-11606
… restorable CL-11606
POST /api/integrations/triage-automation/:tenantId takes { repo, source, kind }.
It needs stock grant:* create through the hub's authorize, an enabled, connected
repository record of that source and a kind the host has. It resolves the
pr-triage role itself, builds the Do resource and writes the allow with
allowRole under the tenant row's share lock, so a repository switched off
meanwhile takes the grant with the others; it never grants a person. It
answers with what Triage now does on its own there.
A held item in the inbox offers Do it, once as the person, and Always, in this
repository, which approves it and then calls the route; Always shows only with
grant:* create and never for a kind that is always held for the verdict. The
repository page's Allow card, addGrant and the portal's stock grant-create
wrapper are gone. Settings lists what Triage does on its own in each enabled
repository, with Remove per kind under ask automation; under policy the line
says the policy file sets these. The merge caution moves to its own component,
shared by the policy editor and Settings.
CL-11606
The github-read token named every recorded repository of the primary installation, so one renamed or transferred made GitHub refuse the whole mint and stopped code review for the workspace. The scope is now the recorded repositories GitHub's live installation listing still has; past GitHub's 500-repository limit it asks for contents read across the installation; with none left the token is marked expired and blanked. A scoped token whose response names a repository not asked for, or covers every repository, is refused like one with extra permissions. CL-11606
…new ones under policy The first boot writes ask into every namespace written before the setting existed, keeping grants allowed by hand. A namespace's first write stamps policy. Switching to ask takes back policy grants in the tenant update, with the injected clock.
…the policy file The push route also needs stock create on grant:* or manage on the workspace, and logs the principal that pushed. The editor shows Push only to them.
…rdict always holds The route takes the held action's verdict and refuses a kind alwaysHeld on it or missing from the policy file's wanted kinds. The inbox offers Always only for a wanted kind.
…eaders PolicySource and the policy read no longer carry repo; the comment header still reads it from comments written before the policy file was the only policy. Stale stored-policy wording goes.
The fake GitHub's read-token write refusal is removed: the chain runs no code review, whose agents need a model the stub does not serve.
0062988 to
b6063ef
Compare
The repository's
.corbits-triage.ymlon its default branch is now the only policy, and what Triage does on its own follows it.One policy source. The stored policy read, the "stored wins while they differ" rule, the policy pin on repository records, the
corruptstatus and the tenant artifact routes are gone. A repository with no file runs no triage and deploys no manager. Every stored policy still standing is archived once at boot, not migrated. The portal edits the file in place and saves it as a pull request, or as one commit pushed to the default branch where the host's branch rules let the hub push (GET/POST …/policy/push). Before saving, a preview route reads the edited text as triage would,extendsresolved, and the editor cautions when it lets Triage approve or merge things it shouldn't. Edited text must carry theshait was edited from, and only one policy pull request is open at a time. The outcomes baseline now starts from Triage's first verdict, since the stored-policy dates are gone.Automation modes and the grant writer. The workspace's
corbitsTriage.automationispolicyorask, switched in Settings by owners and admins. A new workspace starts underpolicy.policy, every successful policy read of an enabled repository, on both hosts, makes thepr-triagerole hold exactly the kinds the policy uses plus posting, and takes back the rest. A step that always waits for a person (Close on Unsure, Merge on anything but Pass) is not granted, since the grant would allow nothing.ask, only posting is granted. Switching toasktakes back everything but posting.wanted, the kinds the policy has Triage do on its own, computed on the hub;policyKindsandpostingKindslive in@corbits/triage-contracts.Consent in the inbox. A held action offers Do it (approve once) and Always, in this repository, which grants that kind on that repository through
POST /api/integrations/triage-automation/:tenantId(needsgrant:*create; never grants a person). Settings lists what Triage does on its own per repository, with Remove underask. The repository panel's Allow card is removed.Read-only token for code review. Code review, which runs a model over untrusted code, now binds a
github-readinstallation token minted withcontents: readonly, for the workspace's repositories that GitHub still lists. Above GitHub's 500-repository limit the token reads the whole installation, still read-only. A token GitHub issues with more permissions or repositories than asked is refused. It renews and is revoked with thegithubtoken. A refused read token is retried early without failing the write token, and when no repositories are left it is blanked and marked expired. Bitbucket Data Center has no token the hub can narrow, so code review there keeps the workspace's one token.Upgrade behaviour. Existing workspaces are set to
askonce at the first boot, keeping the actions allowed by hand, until an owner or admin switches them topolicy; docs/SELF_HOST.md and the User Manual say so.Docs. ARCHITECTURE, IMPLEMENTATION, PRODUCT, SELF_HOST, BITBUCKET_DATACENTER, README, the triage-contracts README, the User Manual and AGENTS.md are updated in one pass. The User Manual screenshots were not retaken; images 06 and 39 may show the old screens. No workflow's judging or review changed, so no eval result applies.
Verified.
bun run check: no errors.bun run lint: warnings only, in files this PR doesn't touch.bun run test: 1546 pass, 0 fail, Postgres tests included.bun run test:chain: 15 pass, 0 fail. New chain scenarios cover a repository with no file, the policy grant writer, and Always, in this repository.Review fixes.
automationexisted is set toaskonce, grants kept (keepExistingWorkspacesAsking). A workspace's first settings write stampspolicy. Switching toasknow takes grants back in the tenant update route, with the injected clock.createongrant:*ormanageon the workspace, and logs the principal. The editor shows Push only to those people.always_held) or that the policy file does not name (kind_not_wanted). The inbox shows Always only for a kind in the policy read'swanted.PolicySourceand the policy read no longer carryrepo; only the comment header keeps it, to read comments written before the policy file was the only policy. Stale stored-policy wording is gone.bun run lintwarnings only, none new; hub tests 463 pass with Postgres; apps/web and triage-contracts 484 pass, DOM tests 11 pass; workflow and tool packages 415 pass;bun run test:chain16 pass, 0 fail, the new disable case included.Waiting on you.
doResourceis also the person Do check (doRefused, used by the GitHub action, held Do and Bitbucket code review send routes), the portal's Do and Settings checks,automaticKindsand its three callers (which would need the host), hand-made person grants that would need migrating, the OpenAPI descriptions and the docs. Options: (a) a follow-up issue that adds the host to every Do resource, person grants included; (b) keep the shared resource and rely on the case-insensitive name-clash refusal on Bitbucket enable, which now stops new clashes. Recommendation: (b) here, (a) as its own issue.policy, since nothing marks when a workspace was created relative to this release. Options: keep that, or add a marker to tell them apart. Recommendation: keep it; they have no repositories, so nothing changes on upgrade.Closes CL-11606