Repository navigation
feat(admin): Mode B lane readiness card and pilot nav preset - #628
Open
privatejoel wants to merge 1 commit into
Open
privatejoel wants to merge 1 commit into
privatejoel wants to merge 1 commit into
Conversation
Plan C-8 (R-M5). Add GET /api/admin/lane_readiness. It is admin only and writes nothing. It returns one check for each item, with ok, warn or missing and a one-line reason: - The flags so_processing_mode, terms_check_mode and order_handoff_enabled. - Migrations 221, 250, 251 and 253, each probed by one table and column. - The last run of cron/tick and cron/daily, from the probeCron reader of /api/health. - The mail provider, the handoff recipients (counts only), CLAMAV_URL and the orders.payment_terms column (OPS-3). - Use of seven lane steps in the last 7 days, from audit_events. A probe reads missing only for 42703, PGRST204, 42P01 or PGRST205. Any other error reads warn. Every query on a tenant table filters tenant_id. Add a card on Admin > Sales & quotes. It shows the checks and the pilot nav preset (C-D9 defaults). The card shows what the preset hides and shows. It applies the preset only when an admin clicks, through the existing nav_settings write. The sidebar and the phone tabs now read the same visibleNav() result, so the phone tabs follow the preset. The preset follows the C-D5 and C-D9 defaults. DISC-1 has not run yet. No migration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
Plan C-8 (R-M5 in
docs/SO_EXECUTION_COHESION.md). This PR adds a readiness card for the Mode B lane and a pilot nav preset.The endpoint.
GET /api/admin/lane_readinessis admin only. It writes nothing. It returns a list of checks. Each check has a status (ok,warnormissing) and a one-line reason.so_processing_mode(B is ok, A is warn),terms_check_mode(on or shadow is ok, off is warn),order_handoff_enabled(off is warn, because C-D13 turns it on later).tenant_settings.so_processing_mode), 250 (order_term_checks), 251 (orders.handoff_status), 253 (admin_notifications.recipient_user_id).cron/tickandcron/dailyfromcron_health. The endpoint uses theprobeCronreader of/api/health. No row is missing. A stale run or a failed run is warn.emailProvider()andemailConfigured()that/api/healthreports.resolveInternalRecipientson the saved To and CC lists. The check returns counts only, not addresses.CLAMAV_URLset or not (OPS-2).orders.payment_terms(OPS-3): the probe says if the column exists on this database.audit_eventsfor each of seven actions (create_order,order_reconcile_quotes,order_terms_checked,order_term_decided,approve_order,so_pdf_downloaded,order_sales_order_attached). Zero is warn.A probe reads
missingonly for 42703, PGRST204, 42P01 or PGRST205. Any other error readswarnwith the error. It never readsok. Every query on a tenant table filterstenant_id.cron_healthhas no tenant.The card. Admin > Sales & quotes > Mode B lane readiness shows the checks in groups. Below them, the pilot nav preset shows what it hides and shows for each role. Nothing changes until an admin clicks "Apply pilot preset". The click sends the map through the existing
PATCH /api/admin/nav_settings. The admin can change any role back in Admin > Navigation.The preset (C-D9 defaults).
intake). "Orders (Register)" is Sales Orders (so), which holds the Register view.The phone tabs follow the preset.
app.tsxnow gives the sidebar andMobileShellthe samevisibleNav()result, andMobileShellalready hides a tab that is not in its nav.The preset follows the C-D5 and C-D9 defaults. DISC-1 (discovery with the pilot team) has not run yet. Change the preset after DISC-1 if the team works differently.
Small refactors:
hasRoleAccessmoved fromNavVisibilityAdmin.tsxtolib/nav-settings.ts, and the nav filter inapp.tsxbecamevisibleNav(). Both keep their behaviour.health.jsexportsprobeCron.Deliberate shortcuts (each marked in the code):
shortcut: 253 is probed before its PR (C-17) merges, so it reads missing until then.shortcut: fixed to the C-D5 and C-D9 defaults, change it after DISC-1 with the pilot team.Deploy notes
SERVER_ACTIONS. The endpoint uses the coarseadminpermission.payment_terms) from it.Tests
New tests:
src/v3-app/api-lane-readiness.test.js(29 tests, through the real router and the realauth.js): a ready lane is all ok; usage counts only this tenant and only the last 7 days; the endpoint writes nothing and filters every tenant-table query by the caller's tenant; sales_manager, sales_engineer, operator and viewer get 403 before any read; no tenant gets 400; PATCH gets 405; each probe reads missing for its missing-schema code (eight cases); an unrelated probe error reads warn; flags off read warn; cron missing, stale, failed and unreadable; no mail provider; no To list, no To that resolves, some entries that resolve to nobody, no addresses in the response, no members of another tenant; noCLAMAV_URL; an unused step.src/v3-app/lib/nav-visibility.pilot-preset.test.ts(8 tests): what each pilot role sees after the preset, admin gets every item back, other roles keep their entries, the preview before anything applies, idempotence, and the server'snormalizeMapaccepts the map unchanged.src/v3-app/components/mobile-shell.pilot-tabs.test.tsx(4 tests): the phone tabs and the More drawer follow the preset.src/v3-app/components/LaneReadinessCard.test.tsx(3 tests): the checks render; the preview shows and nothing saves before the click; the click saves the preset map and updates the live nav.Mutation check. Each rule was broken, a test failed, and the rule was restored. All 23 mutations were killed:
readtenant_idfiltertenant_idfilterpayment_termsprobe is skippedvisibleNavignores the settingGates:
npm run check: pass.npm run lint: 0 errors. No warnings in the changed files.npm run build: pass. Build outputs deleted.npm run verify: pass. It rewrotedocs/RBAC_AUDIT.mdanddocs/WRITE_PATH_AUDIT.mdwith drift that is not from this change. This PR keeps only the new row forsrc/api/admin/lane_readiness.jsindocs/RBAC_AUDIT.md.npm run eval:golden: pass.NODE_OPTIONS=--no-experimental-webstorage npx vitest run --maxWorkers=2: 630 files, 7411 tests, all pass.Not covered
cron/tickandcron/daily.nav_settingsaccepts. Design and support roles do not change.🤖 Generated with Claude Code