Repository navigation
Access LOWs: list_roles grants in one bounded snapshot, Recreate audit id pinned, audit log hides a role's unchanged name, ChangeList min-w-0 pinned (#67) - #71
Merged
Conversation
…rants in one query (#67) list_roles {grants: true} read the role list, then each role's grants (ListActionsForRole re-reads the role first): two queries per role, and a role deleted in between failed the whole read. ListRoleGrants is acl_roles LEFT JOIN acl_role_actions pinned to tenant_id: one statement, one snapshot, so a role deleted meanwhile is simply absent. Roles by name, grants by entity then action; a role without a grant has an empty, non-nil list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… what it cut (#67) It now reads ListRoleGrants (one query) instead of two reads per role, so a role deleted between the list and its grants is skipped instead of failing with ROLES_READ_FAILED. The output is capped like snapshot_model's: at most 40 roles and 60 grants per role; a cut sets rolesTruncated/rolesTotal or grantsTruncated/grantsTotal and a note pointing at explain_access. The issue's tenant (20 roles x 100 tables x 4 actions) was 545 KB in one result; it is now under 100 KB. Still a read, tenant pinned from the executor, also over MCP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le id (#67) The undo of a role delete (publish revert) writes a create row on __role__; its record_id is the role's id, so the audit log keeps the role's whole life under one id. Nothing pinned it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… names a role row's role (#67) A role update's diff carries the role's name on both sides (#66) so the row names the role; drawn as "name | X | X" it read as a rename on every grants-only save. buildDiffRows now drops a key present on both sides with the same stored value (compared as JSON, not as drawn: two amounts can both read "1,2 tr"), so a save that changed nothing has no diff to open. The role's name moves to the record column of a __role__ row, where the short id stood. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aks inside the row (#67) A token with no space cannot wrap at a space; the text is a flex item whose minimum width is its longest word unless min-w-0 lets it shrink. Nothing pinned the class; jsdom cannot measure, so the width is checked in a real browser too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n both sides (#67) Round 1 of #71's verifier: buildDiffRows dropped every key whose value was the same before and after. The server writes a changed sensitive (PII) field as "[redacted]" on both sides on purpose (audit_redact.go keeps the key: who changed what field, when), so /admin/audit stopped showing that such a field changed: a PII-only update had no diff to open and a mixed update lost the field's row. Only the role writer pads an unchanged key (#66 puts the role's name on both sides so the row names the role). buildDiffRows now drops just that one: `name` on a __role__ row when it did not change. A rename still shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#67) A __role__ row's record cell shows the role's name instead of the short id (#67), and its title carried only the name, so the role id was nowhere on screen to cross-reference. The title is now "<name> · <full record id>", for layout rows too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mments say what they rest on (#67) The caps count rows, not bytes: 40 roles x 60 grants with the longest names the schema allows measure 275 KB, not "about 160 KB"; a subtest now pins that under 300 KB. "*" sorts before every table name only because a table name starts with a letter (in utf8mb4_unicode_ci "_" sorts before "*"); the integration test now orders a "*" grant and an "a_first" table on real MySQL. The deleted-meanwhile comments say the fake stands in for InnoDB's consistent read and that a delete racing the SELECT is not exercised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #67 — the five LOW follow-ups the #66 verifier left.
What changed
list_roles {grants: true}loads grants in one query. Newauth.RoleRepository.ListRoleGrants:acl_roles LEFT JOIN acl_role_actions, pinned totenant_id, parameterized. It replacesListRoles+ oneListActionsForRole(which re-reads the role) per role: 2 queries per role become 1 query in total.ROLES_READ_FAILED: role "ops": auth: role not found.snapshot_modeldoes: at most 40 roles and 60 grants per role. A cut setsrolesTruncated/rolesTotalor, per role,grantsTruncated/grantsTotal, plus anotethat points atexplain_access. The issue's example tenant (20 roles × 100 tables × 4 actions) produced 544,932 bytes before; now under 100 KB. Grants are sorted by table."*"sorts before every table name only because table names start with a letter (inutf8mb4_unicode_ci,_sorts before*), so a role's every-table grants are the last to be cut. The caps count rows, not bytes: at the caps with the longest names the schema allows, the result is 275 KB. It's still read-only over MCP, the tenant still comes from the executor, and no tool or argument was added, so the cassettes are untouched.RoleService.Recreateaudit row: a new test pinsrecord_id= the role's id on the__role__create row that undoing a delete writes.name | X | Xrow that read as a rename.buildDiffRowsnow drops that one key only:nameon a__role__row when its value did not change. A rename still shows, and a role save that changed nothing has no diff to open. Every other row draws every key the server wrote. That includes a sensitive (PII) field, which is written"[redacted]"on both sides on purpose (audit_redact.gokeeps the key: who changed what field, when). The role is still named: a__role__row's record column shows the role's name where its short id was, and the cell's title reads<name> · <full record id>, so the id is still there to cross-reference.min-w-0: a new test pins the class, and a real-browser check (below) measures it at 390 px.propose_accessstill readsListRoles+ListActionsForRole. It is unchanged and out of scope.Proof each test is not vacuous (broke the fix, saw red, restored)
ROLES_READ_FAILED: role "ops": auth: role not found20 roles × 100 tables × 4 actions = 544932 bytes; want at most 100 KB·big role: 400 grants, truncated falseWhere("acl_roles.tenant_id = ?")removedrole "rg_foreign" carries tenant …; want …id→""in itsemitMetaAuditForevent = create __role__/"" in "t1"; want … "rid-gone"a grants-only role update shows the grants, no name row…anda save that changed nothing has no diff to openred[redacted]keys (vitest)a sensitive field redacted on both sides is still drawn as a changeandan update of a sensitive field only still has a diff to openred[redacted]keys (real Chrome, HMR)last_nameexpected title "crm_sales_rep · 4f1c0de0-…" received "crm_sales_rep"maxListedGrantsPerRole60 → 8040 roles × 80 grants with the longest names = 363392 bytes; want at most 300 KBmin-w-0(vitest)a long snake_case token may shrink and break inside the rowredmin-w-0(real Chrome, HMR)liScroll 464 > liClient 287)verify-ui (own API :18467 on a throwaway DB
nexus_wt_access67, ownnext dev --webpack:13467, seed-demo, system Chrome)Seeded through the API: a role whose name and label are one long snake_case token (
crm_customer_support_ticket_escalation_history_entries_reviewer), then a grants-onlyPUTof that role, with its name sent again unchanged.Result:
verify-ui: 20/20 checks passed, at widths 390 and 1440:bao-tri/lich-su: unfolded the newest entry ("Vai · "). The token wraps onto 3 lines inside its row: span right edge 337 ≤ row right edge 349,liScroll 287 = liClient 287, page overflow 0, no page error./admin/auditand the Studio'svan-hanh/nguoi-dung/nhat-ky: the grants-only role update's diff has onlyactions, with nonamerow. The record column reads the role's name. Page overflow 0, no page error.test@example.com):/admin/auditandbao-tri/lich-suboth land on/home, with no diff and no role entry.acceptance-acl.py --expect crm_accounts,crm_contactsas the rep:✅ ĐẠT — người thứ ba đọc được cả 2 entity yêu cầu.nexus_list_roles {grants:true}with a real MCP token: the 3 seeded roles come back whole (36 and 25 grants for the pack roles, uncut, 4.6 KB). After adding 43 roles (one with 400 grants):roles shown 40 | rolesTruncated True rolesTotal 46,bulk_role_00 grants 60 grantsTruncated True grantsTotal 400, plus the note (17 KB).Round 1 (verifier findings on #71)
buildDiffRowshid every key whose value was the same on both sides. That also hid a sensitive field written"[redacted]"on both sides, so/admin/auditstopped showing that a PII field changed. The hiding is now scoped to the one key that a writer pads:nameon a__role__row. Red first: the verifier's two cases (a mixed update and a PII-only update) failed on the round-0 head and pass now.<name> · <id>).field:level, a 100-character role name and a 150-character label), and a subtest keeps it under 300 KB."*"sorts first (table names start with a letter). The integration test orders a"*"grant and ana_firsttable on real MySQL.SELECTis not exercised.list_rolestool description still does not mentionrolesTruncated/grantsTruncated. Changing it would change the tool definitions the cassettes were recorded with, and existing cassettes must not change. The model learns about a cut from thenotein the result.verify-ui, round 1
Same throwaway DB
nexus_wt_access67, own API :18467 (binary built from this head), ownnext dev --webpack:13467, system Chrome, widths 390 and 1440. Seeded through the API: a sensitive fieldso_cccd_v67oncrm_contacts; then, as the rep, a contact, an update of the sensitive value only, and an update of it pluslast_name; then a grants-only role update that changes one grant.Result:
verify-ui: 26/26 checks passed, on/admin/auditand on the Studio'svan-hanh/nguoi-dung/nhat-ky:so_cccd_v67 | [redacted] | [redacted].last_nameandso_cccd_v67.actions. The two role saves that changed nothing have no toggle. All three role rows' record cells are titled<name> · ed692eaf-…./admin/auditto/home, with no diff and no audit row.With the round-0 filter put back (HMR), the same script fails 12 of 26 checks: the PII-only update has no toggle, and the mixed update draws only
last_name.Gates
Ran in
nexus-platform/andnexus-web/on head3846600:gofmt -l .→ empty ·go vet ./...→ clean ·go build ./cmd/server/→ okgo test ./...→ 42 packagesok, exit 0bash scripts/run-integration.sh -timeout 50m -run 'TestListRoleGrants_' ./internal/auth/→run-integration: PASS=1 SKIP=0 go-test-exit=0(round 1; the round-0 run of./internal/auth/ ./internal/ai/ ./internal/mcpserver/ ./internal/services/ ./internal/handlers/→PASS=7869 SKIP=0 go-test-exit=0; round 1 changed no Go code outside tests and comments)python3 scripts/check-orphan-endpoints.py --strict→✅ Không có endpoint mồ côi.python3 scripts/acceptance-acl.py --expect crm_accounts,crm_contacts(rep) →✅ ĐẠT — người thứ ba đọc được cả 2 entity yêu cầu.npx tsc --noEmit→ exit 0 ·npx vitest run(all) →Test Files 585 passed (585),Tests 6276 passed (6276)·npx eslinton the touched files → exit 0 ·npm run build→ exit 0🤖 Generated with Claude Code