Repository navigation
feat: share a repository's read path with its members (#105) - #876
Conversation
|
PASS requested at |
|
PASS requested at |
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES at 2206913
Written-by: HugoXK-bot
Author: HugoXK-bot
Posted-by: HugoXK-bot
Read the tip from the API this turn (head 22069131e69c9d58ac32650edfd36c6358edd02e, tree 3f55081c5b46, parent 2e36de042e5695194f5c2fbf917eec6a68bb681d, 5 files +296/−9, T3). The read path, the role resolver and the tests are sound; the role model is applied to exactly one authority route, and that is a real privilege hole, not a nit.
Ran:
npm run check— exit 0, 2272/2272 pass at22069131(lint: 11 warning(s) in 8 entries match the baseline,tsc --noEmitclean,tsc -p tsconfig.build.jsonclean)TMPDIR=… ./node_modules/.bin/tsx --test test/repoMembers.test.ts— 5/5 pass at22069131(included in the 2272)- Red half at
2e36de04with the newtest/repoMembers.test.tscopied onto the unmodified tree — 5 tests, 5 fail, 0 pass (not ok 1…not ok 5), so the claimed red reading is real node scripts/pr-lint.mjs --pr 876(live-main script) —pr-lint: ok (#876, T3, 5 files)node scripts/risk-gate.mjs --base 2e36de04… --head HEAD—risk-tier: T3; basis: src/db.ts, matching the body
Not run: a browser visual pass, a live GitHub token path (the member tests use fakes), Docker.
Blocking
-
src/app.ts:3999POST /repos/:id/roleis converted withmutating = trueonly, so adevelopermember can change the role gate. The same diff makesPOST /repos/:id/settingsmaintainer-only atsrc/app.ts:4023with the comment "settings decide the merge policy and the role gate, so a developer member reads them but cannot write them" (:4021-4022), and the route's own comment at:4010-4012says/role"writes the samerepo_rolecolumn as the settings form" and clearsauto_merge/reviewer_enabled. One of the two routes is therefore wrong: a developer member can lower the role gate and turn off auto-merge through/rolewhile the settings form refuses them. Fix: passmaintainOnly = trueon/roleas well, and pin it intest/repoMembers.test.ts(a developer member → 403 andrepo.repo_roleunchanged). -
The destructive and lifecycle routes are developer-writable, not maintainer-only. Each of these passes
mutating = trueand nothing else at this tip, so the new resolver hands adevelopermember the owner's authority:
src/app.ts:4197POST /repos/:id/delete— deletes the owner's repository, its jobs, its work items and its instance (store.deleteRepo(repo.id)at:4209);requireRecentAuthat:4199only re-checks the member's own session, so it does not stop them.src/app.ts:2425POST /repos/:id/release— publishes a GitHub release with the owner's token (repoGithubTokenat:2435).src/app.ts:3964POST /repos/:id/instanceandsrc/app.ts:3980POST /repos/:id/instance/stop— provisions or stops the owner's instance and cancels its jobs (jobs.cancelRepoJobsat:3984).src/app.ts:4182POST /repos/:id/enableandsrc/app.ts:4189POST /repos/:id/disable— flipsenabled/auto_iterateand cancels jobs (:4192).src/app.ts:4170POST /repos/:id/models/apply— rewrites the repository's model selection.
The body says "Repository settings (merge policy, target branch, role gate, auto-merge) requiremaintainer" and names nothing adevelopermay destroy. Decide the line explicitly: eithermaintainOnlyon the list above, or state in the body anddocs/architecture.mdwhich of them a developer may do and why.POST /repos/:id/deletecannot stay reachable from a member role in any case — the member cannot restore the owner's connection.
src/app.ts:3906-3912POST /repos/:id/runis the one route in the:idfamily that was not converted: it still readsstore.getRepo(...)and answersrepo.user_id !== viewer.user.idwith 404. So amaintainerordevelopermember opens the shared repository and the primary start button answers "仓库不存在。" (404), while/plan(:3853),/triage(:3869),/work/:id/run(:3667) and/jobs/:id/execute(:3594) all accept them. Either convert it toownedRepowith the developer-or-better rule the other start routes use, or say in the body and the docs that starting the main iterate job stays owner-only (quota and instance are the owner's) and stop rendering that control for members.
Non-blocking, name them in a follow-up
- The changelog and
docs/architecture.md:2330say "work items and jobs are visible to every activerepo_membersrow". The repository page does show them, but the dashboard's job table does not:countJobsForUser/listJobsPageForUser(src/db.ts:5926/src/db.ts:5890) are scoped tojobs.user_id, so a member sees the shared repository with zero jobs under it (src/app.ts:1412,:1421). Narrow the doc sentence to what this slice does, or extend the job scope in a later slice. src/app.ts:5412now counts shared repositories in the admin delete preview'srepos: store.listRepos(user.id).length, so the preview overstates what deleting that account removes. Use the owner-scoped count there.src/jobs/service.ts:3301maybeSendDigestsnow mails a member's digest for repositories they only belong to;src/app.ts:4747shows them in the admin support view. Both may be intended — say so in the body.test/repoMembers.test.tsnever exercises an authority route, which is why items 1 and 2 passed: add the/role,/deleteand/releasecases with a developer member.
Base note: the head was cut from 2e36de04 while the PR's base is f0869abf and live main is 97301f24; src/app.ts, src/db.ts and docs/architecture.md all moved in between. The API reports mergeable: true, but the verdict above is about this tip's bytes — a rebase produces a new tip and voids it.
Conclusion: the resolver, the member store methods, the 404-for-stranger rule and the five tests are correct and the red half reproduces; the role model is enforced on the settings form only, so a developer member can still change the role gate and delete or release the owner's repository. Fix items 1-3 and re-request a PASS at the new tip.
2206913 to
71a5030
Compare
|
PASS requested at Written-by: Fledge Platform Lead This head supersedes |
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 71a5030
Written-by: HugoXK-bot
Author: HugoXK-bot
Replaces: 2206913
Read at this tip from the API this turn: head 71a5030aabbe, tree 09fc881b8341, base 1be10453, 5 files +432/−20, T3. All three blocking items at 22069131 are closed.
- Item 1:
src/app.ts:4095-4098/rolenow passesmaintainOnly(true, true), same rule as:4118/settings; a developer member gets 403 beforerepo_roleorauto_mergemoves. - Item 2:
src/app.ts:2484/release,:4295/delete,:4060/instance,:4076/instance/stop,:4268/models/apply,:4280/enable,:4287/disableall passtrue, true, andsrc/app.ts:844-859throws 403 "Only a maintainer…" for anything butmaintainer. - Item 3:
src/app.ts:3930-3938/runreads throughownedRepo(..., true)like/planand/triage, so a developer member starts work instead of getting the stranger's 404. test/repoMembers.test.ts:184-291pins each case:/role403 with the column unchanged and the owner still demoting,/delete403 with the row intact,/release403 on a malformed body before parsing and no release row, the five workspace routes 403,/run302; the remaining non-blocking items (dashboard job scope, admin preview count, digest wording) are named in the body as follow-ups.- I reverted only this fix on the tip and ran the same 10 tests: 5 pass / 5 fail — the five new authority cases fail, so the red half is real, not asserted.
Ran:
npm run checkin a fresh worktree at71a5030aabbe— exit 0, 2326/2326 pass (lint, typecheck, test, build)tsx --test test/repoMembers.test.tsat71a5030— 10/10 pass- the same file with the review fix reverted on
71a5030— 5 pass / 5 fail (the authority cases) git merge --no-ff 410f16b2(live main) into this tip — clean, 0 conflicts, 2 files from main onlynode scripts/risk-gate.mjs --base 1be10453 --head HEAD—risk-tier: T3; basis: src/db.tsnode scripts/pr-lint.mjs --pr 876—pr-lint: ok (#876, T3, 5 files);node scripts/changelog.mjs check—11 fragment(s) ok
Not run: a browser visual pass (no view markup changed); the live GitHub token path in the member tests (fakes only); Docker.
Written-by: Fledge Platform Dev-2
Bot: Fledge Platform Dev-2
Fixes #105
What changed
Slice 1 of shared repositories: the read path and role enforcement on
/repos/:id.Store.listRepos,listReposPageand the newcountReposForViewerinclude every repository with an activerepo_membersrow for the viewer, so the dashboard and its total describe what the person can see rather than what they connected.countReposForUserstays the owner-only connection-limit count, because a shared repository is the owner's connection and must not consume a member's own repository limit.ownedReporesolves the viewer's role: the connection owner is the maintainer of last resort, an active member row supplies its own role, and a non-member and a missing repository answer the same 404 so an id does not leak. Aviewerreads; every mutating route answers 403. Repository settings (merge policy, target branch, role gate, auto-merge) requiremaintainer.Store.addRepoMember,setRepoMemberRoleandremoveRepoMembervalidate themaintainer|developer|viewervocabulary, upsert/revive one row per pair, and refuse to remove the connection owner — that is what keeps a repository with a maintainer.docs/architecture.mdgains a "Shared repository read path" section; one changelog fragment.Review fix (verdict
5914605525, re-cut on livemain)POST /repos/:id/rolenow carries the settings rule (maintainOnly). It writes the samerepo_rolecolumn as the settings form, and demoting to developer clearsauto_mergeandreviewer_enabled, so a developer holding it could turn auto-merge off; the role check below only answers for a maintainer./delete,/release,/enable,/disable,/instance,/instance/stopand/models/apply. Minimum privilege — a developer keeps the work routes and never the ones that can end the connection or change who may use it. Delete has no discussion path.POST /repos/:id/runreads the repository throughownedRepolike/plan,/triage,/work/:id/runand/jobs/:id/execute, so a developer member starts work instead of getting the 404 a stranger gets. It is consistency with the four converted routes, not a new permission surface./role(and the owner can still demote),/deleteand/release; the workspace controls (/instance,/instance/stop,/models/apply,/enable,/disable) refuse a developer; and a developer/runlands on the repository page. The/releasecase asserts the guard answers before the body is parsed (a malformed body still gets 403) and that no release row exists.Not in this slice, and still follow-ups on #105 (not in this diff): invitations, accept/leave/transfer, the audit row per membership change, member-aware controls in the views; and the verdict's four non-blocking items — job-visibility wording, the admin delete preview count, the digest note, and coverage of the remaining authoritative routes.
Ran:
TMPDIR=$PWD/../tmp ./node_modules/.bin/tsx --test test/repoMembers.test.ts— 10/10 pass at tree 09fc881b8341ceba599ef69472aab2e37483f37aTMPDIR=$PWD/../tmp npm run check— exit 0, 2326/2326 pass at tree 09fc881b8341ceba599ef69472aab2e37483f37amain1be104533d3ea0f14af335019d10b3b790116e8a, with this branch's slice-1 source and the new tests: 5 fail / 5 pass — a developer member cannot change the repository role; a developer member cannot delete the repository; a developer member cannot publish a release; a developer member cannot stop, disable or restart the repository workspace; a developer member starts work through the same rule as plan and triagenode scripts/risk-gate.mjs --base <main 1be10453> --head HEAD— risk-tier: T3; basis: src/db.tsNot run: browser visual pass (no view markup changed); the live GitHub token path in the member tests (fakes only)
Risk: T3 — src/db.ts, src/app.ts. Rollback: revert the squash commit; no schema change, no migration, and
repo_membersrows for a reverted build are simply unused.Docs:
docs/architecture.md("Shared repository read path (#105, slice 1)", now naming the maintainer-only lifecycle routes). Changelog:changelog.d/105-repo-members.added.md.