Repository navigation
fix(route): let the actor's role decide the next-step decision (#1113) - #1121
Conversation
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 7c88dc7
Written-by: HugoXK-bot
src/app.ts:4157now takesrolefromownedRepoandsrc/app.ts:4163gates on it — the same value the job page passes intojobPageatsrc/app.ts:3933, wherecanDecidereads it (src/views/pages.ts:4143); the NULLrepo_rolepage-offers/route-refuses case is gone, and the refusal sentence follows the request locale.- Red half reproduced myself at the head's real parent
95016f39187c8618db3f6dedb01221fb2713b507with onlytest/taskDecisionRoute.test.tscopied in: 1 fail, actual{key:'请先选择你的角色。'}vsundefined, the page assertions ahead green. - At the tip
test/taskDecisionRoute.test.ts:317passes and the suite is 12/12;tsc --noEmitexits 0;scripts/risk-gate.mjsgives T2 bysrc/app.ts, 4 files +42/−7, matching the PR. - Only a body note (not a blocker): the body quotes base
95016f39187c8618db3f6dedd01221fb2713b507and local commit43151e6b, neither of which exists on GitHub; the verified parent is...f6dedb...and the pushed tree86155db5matches the diff.
Ran: npx tsx --test test/taskDecisionRoute.test.ts
Ran: node scripts/risk-gate.mjs --base 95016f3 --head 7c88dc7
Not run: CI at the sha (every check still queued, no runner pickup since ~15:49Z) and no browser render — no UI surface changed (无 UI 面).
|
Written-by: HugoXK New tip |
HugoXK-bot
left a comment
There was a problem hiding this comment.
Written-by: HugoXK-bot
Verdict: PASS at 687a010
Ran: npx tsx --test test/taskDecisionRoute.test.ts at this tree → 13/13 pass, the new null-role case included; the same file copied onto base 24d60017 → 12/13, failing only a repository with no recorded upstream role takes the decision the page offers.
Ran: npx tsc --noEmit at this tree → clean.
Not run: npm run check and coverage-diff (author reports 3057/3057 and 3/3 changed lines), visual:matrix, Docker; no screenshot was read, and the PR declares no UI surface.
src/app.ts:4194-4201: therepo.repo_role !== 'maintainer' && !== 'developer'branch is gone;ownedRepo(request, id, true)(src/app.ts:949-961) is now the only refusal — 404 for a non-member, 403 for a viewer — so the form the page draws (#1081) and the write ask one question.test/taskDecisionRoute.test.ts:315-387: the viewer case asserts 403 with no work item and notask.decision_audit row, and the null-role case asserts the page offered the form and the same owner's POST lands with a notice and one work item; the base run fails exactly that second case.docs/architecture.md:588-594andchangelog.d/1113.fixed.mdstate the rule as the guard's and match the code; the route no longer readsrepo.repo_roleanywhere.- No UI surface: no markup, layout, copy or style change, so there is nothing to photograph; the only user-visible difference is that the redirect's refusal follows the request locale.
- Note, not a blocker: the same
repo_rolepre-check still sits on adjacent job-action routes (src/app.ts:4116,:4154,:4628,:4648), so a NULL-role owner can decide a next step but still not retry or approve there — a follow-up card, not this one.
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 687a010
Written-by: HugoXK-bot
Ran: npx tsx --test test/taskDecisionRoute.test.ts at this tree → 13/13 pass, the new null-role case included; the same file copied onto base 24d60017 → 12/13, failing only a repository with no recorded upstream role takes the decision the page offers.
Ran: npx tsc --noEmit at this tree → clean.
Not run: npm run check and coverage-diff (author reports 3057/3057 and 3/3 changed lines), visual:matrix, Docker; no screenshot was read, and the PR declares no UI surface.
src/app.ts:4194-4201: therepo.repo_role !== 'maintainer' && !== 'developer'branch is gone;ownedRepo(request, id, true)(src/app.ts:949-961) is now the only refusal — 404 for a non-member, 403 for a viewer — so the form the page draws (#1081) and the write ask one question.test/taskDecisionRoute.test.ts:315-387: the viewer case asserts 403 with no work item and notask.decision_audit row, and the null-role case asserts the page offered the form and the same owner's POST lands with a notice and one work item; the base run fails exactly that second case.docs/architecture.md:588-594andchangelog.d/1113.fixed.mdstate the rule as the guard's and match the code; the route no longer readsrepo.repo_roleanywhere.- No UI surface: no markup, layout, copy or style change, so there is nothing to photograph; the only user-visible difference is that the redirect's refusal follows the request locale.
- Note, not a blocker: the same
repo_rolepre-check still sits on adjacent job-action routes (src/app.ts:4116,:4154,:4628,:4648), so a NULL-role owner can decide a next step but still not retry or approve there — a follow-up card, not this one.
The route carries no role check of its own. ownedRepo(..., mutating) is the only refusal left - 404 for a non-member, 403 for a viewer - so the page and the write answer one question. test/taskDecisionRoute.test.ts keeps the null-role owner case and adds the viewer case, so the may-not-decide answer is covered by a test rather than by an unreachable redirect. Supersedes the tip at 7c88dc7, which failed the changed-lines floor on the dead redirect branch.
Written-by: HugoXK
Author: Fledge Platform Dev-3
Tip
687a010ac787b16e93c1ca75d4ddccd2ed27ebba— two commits on the same branch: a merge ofmain24d600176ac6a774888f691cdbac9d3233621692into7c88dc7d…, then the fix. The merge keeps the branch fast-forwardable instead of rewriting it; the net diff againstmainis this fix alone, four files+71/−6(src/app.ts,test/taskDecisionRoute.test.ts,docs/architecture.md,changelog.d/1113.fixed.md).Why the tip moved: the previous tip's
if (role !== 'maintainer' && role !== 'developer')redirect could never execute —ownedRepo(request, id, /* mutating */ true)already throws 404 for a null role (src/app.ts:926) and 403 for a viewer (:927-929), andmemberRoleForreturns onlymaintainer | developer | viewer— socoverage-diff --floor 80refused the dead line. The branch is gone;ownedRepo's mutating guard is the only refusal; the null-role owner case stays and a viewer-403 case is added attest/taskDecisionRoute.test.ts:315. Measured at the fix:coverage-diff3/3 changed lines (100%),npm run check3057/3057, T2 (src/app.ts).Every verdict given at
7c88dc7dis void.What a user sees differently
Before: on a repository connected before its upstream access was ever checked,
repo.repo_roleis still NULL. The job page draws the next-step decision form there anyway, because the page reads the actor's role (#1081) — but the write read the repository column instead, so the owner filled in the reason and the evidence, pressed the button the page had offered, and came back to the same page with "请先选择你的角色。" and nothing recorded. There was no role to select: the role it asked for was the one it had already resolved.After: the form the page offers is the form the route accepts. The route now reads
rolefrom the sameownedRepoanswer the page reads, so an owner or developer of a repository with no recorded upstream role records the decision and sees the confirmation, while an actor who may not decide is still refused with the same sentence the page prints beside the absent form. The refusal is also translated for anensession instead of always answering in Chinese.No UI surface
No page markup, layout, copy or style changes: the job page renders exactly the same HTML before and after this PR, and the form/no-form decision in the view is untouched. That is why this carries no screenshots — there is nothing to photograph. The only user-visible text difference is the error sentence on the redirect, which now follows the request locale.
How it is verified
test/taskDecisionRoute.test.tsgains a case that separates the two readers: the repository is created withrepoRole: null, the owner session opens the job page, the page is asserted to offer the decision form and not to print the role-required line, and the POST is then asserted to land with a notice, no error, and one new work item.repoRole: 'maintainer', so the route's column read and the page's actor read agreed by accident; the fixture now takes the role as a parameter and only the new case passesnull.rolefromownedRepo), so the two cannot drift apart without a test failing.What changed
src/app.tsrolefromownedRepoand gates on it instead ofrepo.repo_role; the refusal sentence goes throught().test/taskDecisionRoute.test.tsfixture()takes the repository role; the new case for a repository with no recorded upstream role.docs/architecture.mdrepo_rolecase.changelog.d/1113.fixed.mdRisk
node scripts/risk-gate.mjs --base 95016f39187c8618db3f6dedd01221fb2713b507 --head 43151e6b88045efe84477c6241235dd22974b4ab(the author's local commit, same tree as the pushed tip):T2 by path (
src/app.ts), no escalation rule fired, so this needs a PASS at this tip.Ran:
npx tsx --test test/taskDecisionRoute.test.tsat the pushed tip's tree (author's local commit43151e6b, tree86155db5) — 12 tests, 12 pass, 0 failnpx tsx --test --test-name-pattern="no recorded upstream role" test/taskDecisionRoute.test.tsat95016f39187c8618db3f6dedd01221fb2713b507, the pushed commit's actual parent, in a clean worktree at that commit with only this test file copied in — 1 test, 0 pass, 1 fail:the route does not refuse a decision the page offered, actual{ key: '请先选择你的角色。', text: '请先选择你的角色。' }againstundefined. The page assertions ahead of it pass, so the failure is exactly the page-offers/route-refuses mismatch.npm run checkat the same tree — exit 0 (lint baseline clean,tsc --noEmitclean, tests green, build OK)node scripts/risk-gate.mjs— output aboveNot run:
Fixes #1113