Skip to content

Commit 22dee25

Browse files
committed
docs(ask): map requirements and security verification (MAG-4934)
1 parent d440f63 commit 22dee25

3 files changed

Lines changed: 152 additions & 1 deletion

File tree

‎docs/ASK-YOUR-DATA-IMPLEMENTATION.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,18 @@ budget and execution. MAG-4751 self-hosted distribution remains a separate produ
7171
- Answers have bounded summary/sections and server-authored source/time evidence.
7272
Tool errors, no data, partial coverage and truncation remain distinguishable.
7373
Render plain text; no model-authored HTML, URLs or executable content.
74+
- PromQL/LogQL accept bounded literal range selectors; advanced subqueries,
75+
duration arithmetic, offset and @ modifiers are denied before MCP dispatch.
76+
Source-side cardinality, memory, sample and execution limits remain necessary.
7477
- Personal history is private to its person/customer. Internal prompt access uses
7578
explicit trusted Magma staff identity, never the customer's admin role or email
7679
domain alone. No public/internal endpoint accepts a customer override.
7780
- Chats and prompt content expire after 90 days or a shorter customer policy.
7881
Retention is a leased, observable scheduled job. Minimal accounting without
7982
prompt/answer content can survive for reconciliation; deletion must not reset
80-
monthly spend. Runtime secrets and credential-shaped text are never logged.
83+
monthly spend. Runtime secrets and supported credential formats are redacted
84+
before storage/model use; collector-side redaction remains necessary for other
85+
secret formats and customer-specific sensitive data.
8186

8287
## API contract
8388

@@ -103,6 +108,10 @@ bounded; direct IDs always require ownership checks.
103108

104109
## Acceptance ledger
105110

111+
The [17 November requirement-by-requirement and security review](validation/MAG-4934/REQUIREMENTS-SECURITY-REVIEW.md)
112+
maps all ticket clauses to code, tests and PRs, records reproduced fixes, and
113+
separates implemented behavior from the remaining deployed acceptance gates.
114+
106115
An item is checked only with corresponding observed evidence. Each slice records
107116
dated commands/results and remaining limits; opening or merging its PR does not
108117
establish acceptance.

‎docs/validation/MAG-4934/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# MAG-4934 runtime preparation evidence
22

3+
The [17 November requirements and security review](REQUIREMENTS-SECURITY-REVIEW.md)
4+
maps all current ticket requirements to PRs and checks, records three reproduced
5+
fixes and the remaining deployed acceptance gates.
6+
37
The [native provider and internal runtime follow-up](LIVE.md) supersedes the
48
expired-SSO/provider-access status below. The original slice's local checks
59
remain recorded here; live follow-up evidence does not imply a deployed pilot.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Managed Ask requirements and security review
2+
3+
17 November 2026. This review reads the current descriptions and linked work in
4+
MAG-4750, MAG-4929–4934, MAG-5359 and MAG-5370. MAG-4642 and MAG-4751 are also
5+
checked for scope. An implemented requirement below means code plus the named
6+
verification, not a deployed customer capability or a guarantee against every
7+
possible attack. The [live receipts](LIVE.md) remain dated provider evidence.
8+
9+
## Requirement coverage
10+
11+
All dashboard slices feed the single [release PR #405](https://github.com/Magma-Devs/smart-router-dashboard/pull/405).
12+
The following rows map every product/build/Done-when clause, including clauses
13+
shared by several tickets, to the owning review slice and executable evidence.
14+
15+
| Requirement | Owning PR / implementation | Verification and limit |
16+
| --- | --- | --- |
17+
| Managed customer opt-in; all signed-in roles; API and UI gate; on-prem/disabled/anonymous cannot spend | #389, #396; `config.ts`, `routes/ask.ts`, `AskProvider.tsx` | `ask-adapters`, `ask-routes`, disabled browser spec; `read_only` HTTP/browser flow. Deployed gate rehearsal remains open. |
18+
| Browser never holds Bedrock/MCP secrets; runtime server bearer, fixed model/region and destinations | #389, #400, #401; `bedrock.ts`, `mcp.ts`, Compose; chart #189/fleet #1494 | Adapter endpoint/header/redirect checks, Compose checks, dated scoped provider receipts. Permanent deployed secrets/pins remain open. |
19+
| Customer mapping verified with whoami; reject staff/multi-customer/foreign source/catalog/result; recheck before reads | #389/#401; `mcp.ts` | `ask-adapters` identity and result-envelope tests; dated live whoami/catalog/read. Filters grant no access. |
20+
| Discover supported service tools and verify read-only execute_operation operations | #389/#393; local `readPolicy` in `mcp.ts` | Catalog intersection plus GET/readOnly/kind/schema checks; unknown operations, write annotations and credential arguments rejected before operation dispatch. Convenience tools cannot expand the local catalog. |
21+
| Carry chain/time and both router axes from dashboard; preserve conversation context | #389/#396; shared `askPageContextSchema`, `AskProvider.tsx` | Shared strict-contract regression and router-scoped browser regression. Router values remain filter tokens, never endpoints or tenant identity. |
22+
| Metrics, request logs, provider incidents and protocol changes; unavailable evidence stated | #393/#401; `orchestrator.ts`, `status.chain_events` policy | Metrics/log/status fixtures, partial/empty/error evidence, real metrics/log reads. Latest live catalog lacks status capability; deployed status data is **not** proved. |
23+
| Top-bar entry and shortcut, no new menu item | #396; `AskEntry.tsx`, gateway shell | Ask component and Chromium flows. |
24+
| Panel keeps dashboard usable; minimize to pill while work continues | #396; `AskSurface.tsx`, provider-owned state | Browser minimize/dashboard interaction/reopen; separate dated real-provider panel receipt. |
25+
| One run/person across tabs and replicas; locked composer, Processing, Stop without step progress | #390/#393/#396; store unique constraint, worker, composer | Independent HTTP/PostgreSQL concurrency and lease tests; cross-tab browser cancellation. |
26+
| Shared panel/full IDs; /ask, authorized deep links, Expand/back, same chat and originating page | #396; `AskProvider.tsx`, full view | Browser panel/full/back/reload/deep-link and ownership tests. Navigation destination is a local allowlist. |
27+
| Last view remembered on server across browsers | #390/#396; preferences | Fresh API instance persistence and browser context with cookies but no local storage. |
28+
| Private PostgreSQL history, grouped dates, pagination and search | #390/#396; `store.ts`, history UI | Person/customer ownership, scoped cursors, message paging/reading position, history search and browser grouping tests. Search text uses POST body. |
29+
| Copy, completion date/time, one-line summary and numbered sections with optional points/stat | #389/#396; shared contract, answer view | Contract bounds and UI tests; Chromium copy/date/plain-text rendering. |
30+
| API validates answer before storage/display; stable unavailable/invalid/truncated/cancel/interrupted/budget errors | #389/#393/#394/#396 | `ask-adapters`, `ask-orchestrator`, `ask-worker`, real PostgreSQL and browser error/retry/reload checks. Failed runs have no assistant success message. |
31+
| Plain initial prompts and observed-question tuning; no sample-answer fallback | #393/#401 | Locally authored system prompt, mandatory successful read, validated presentation; real-provider receipts separate from synthetic fixtures. |
32+
| Durable queue, atomic idempotency, leases/fencing, crashes/restarts, revoked sessions and cancellation | #390/#393; `store.ts`, `worker.ts` | Real HTTP/PostgreSQL independent connections, concurrent retry, stale completion, recovery, revocation and different-customer cancellation. |
33+
| Untrusted prompts/history/logs/catalog; immutable tool/customer/credential boundary | #389/#393; strict schemas and catalog intersection | Forced malicious model requests after planted log instructions are denied; usage still recorded. These tests establish server enforcement, not universal model instruction-following. |
34+
| Bound tool steps, query range/results, context/tokens/time; preserve source/observation/query windows | #389/#393/#394 | Adapter streaming/deadline tests, query-text guard, context/output limits, worker cancellation and server-authored evidence. Source-side cardinality/resource limits still require deployed verification. |
35+
| Default $10/customer/UTC month, configurable, all people and Ask/Investigate share pool | #394; `budget.ts`, `pricing.ts` | Twelve competing people/replicas on real PostgreSQL; per-customer isolation and shared feature pool. Investigate entry UI is separate MAG-4642. |
36+
| Reserve before every paid step, current versioned model/region prices, free count, include cache/reasoning billing | #389/#394/#401 | Counter/pricing tests and model dispatch ordering; real native usage receipts. Unsupported/missing usage retains a hold. |
37+
| Retry/cancel/failure/crash/month rollover cannot erase incurred usage or double settle | #394 | Budget tests and real PostgreSQL late duplicate receipt, dispatch fence, reservation-after-retention and UTC boundary checks. No automatic paid replay. |
38+
| Clear budget-limit error, no amount in customer UI | #394/#396 | Admission rollback, stable error contract and composer/UI tests; amounts only in staff health/export. |
39+
| Retained person/customer/question/time/tools/latency/tokens/cost/answer/error | #390/#394; schema and `ask-internal.ts` | Real record persistence, per-step accounting and authenticated staff export tests. |
40+
| Internal authorized Magma staff read/export; customer admin denied; no customer override or credential logging | #394/#401; `staff.ts`, internal routes, redaction | Staff identity/grant/foreign-customer/role tests; dated real OAuth export/revocation/admin-denial receipts; credential regression tests. |
41+
| Content expires at ≤90 days or shorter policy, physically deleted by scheduled job; observable failure/retry | #394/#400/#401; `retention.ts`, runtime | Retention cutoff, retry/health and flag-off scheduling tests; dated actual PostgreSQL runtime sweep. Accounting remains without content. |
42+
| Fresh linked PRs; original #200/#300 reference only; one stable dashboard release | #389–401 and #405 | No prototype prerequisite; slices do not change VERSION; aggregate proposes only 0.69.7 → 0.70.0. Final number must follow then-current main. |
43+
| Generic customer onboarding through infra, exact-customer credentials/config, backend Secret references and isolated flags | chart #189; fleet #1494/MAG-5359 | Schema/render/Secret checks; two-customer fixture, guard mutations, selected-tenant-only edits, encrypted credential workflow. GK8 is a first tenant, not hardcoded authorization. |
44+
| Released artifact prerequisites, exact-image checkpoint, enable/disable retaining identity/accounting/cleanup; safe rollback | #400/#401; chart #189; fleet #1494 | Local delivery/checkpoint fixtures and runbook. Actual released pins, permanent credentials and GK8 rollout/rehearsal remain **open**. |
45+
| Reliable required editor-cleanup gate supporting fleet delivery | infra #1504/MAG-5370, included in #1494 | Real child-process regression, guard mutations, full editor suite and hosted CI. Original historical failing PID state is unobserved. |
46+
| Live provider smoke and full browser/API/MCP/Bedrock/PostgreSQL flow, separately from mocks | #401; `LIVE.md`, provider/browser/runtime JSON | Dated native full/panel receipts exist. No new live provider test is claimed by this offline review. Exact released/deployed GK8 image remains open. |
47+
| GK8 configured cap, observability, operational staff/retention, disabled other customers/on-prem, disable/rollback | MAG-4934, #400/#401, chart/fleet | Local and dated isolated runtime proofs exist; **deployed customer acceptance remains open**. |
48+
| Pilot date and later 60-day outcome handoff | MAG-4934 → MAG-4642 | No pilot date recorded. Preserve baseline 49 support cases and 95% target; future outcome is not implementation acceptance. |
49+
50+
MAG-4642's error-row Investigate action (GUID/chain/time/error) is an **unimplemented
51+
dependent follow-up**, not covered by these UI PRs. MAG-4751's paid self-hosted MCP
52+
distribution is a separate unscheduled product, not a managed-chat prerequisite.
53+
MAG-3702 is historical provisioning and cannot prove current access.
54+
55+
## Reproduced findings and fixes
56+
57+
1. **Credential disclosure through common field/header/URL formats.** The original
58+
redactor leaves `client_secret`, cookie and AWS-secret field variants, Basic/
59+
Digest headers, WebSocket/database URL paths and exact runtime secrets used as
60+
object keys. The new regression initially fails 29 of 38 cases. The fix expands
61+
normalized credential keys, whole header values, quoted assignments, private
62+
key blocks and connection URL scrubbing, and sanitizes object keys. Tests also
63+
check actual HTTP/PostgreSQL/history and the outgoing Bedrock request body.
64+
This does not classify arbitrary PII, encrypted/encoded secrets or all possible
65+
application-specific secret names; collectors must continue upstream redaction.
66+
2. **Selected-router submission fails.** UI `router` is rejected by the strict
67+
shared context, and config `routerId` is omitted. The contract regression fails
68+
before adding the optional collector axis. The fix captures both axes, with
69+
strict token validation and browser panel/full/reload/follow-up verification.
70+
3. **Query text bypasses the outer time-window bound.** Five adapter regressions
71+
initially admit long selectors, offsets, absolute time relocation, subqueries
72+
and duration arithmetic. A small fail-closed dialect guard now admits literal
73+
range selectors with a total ≤24h and rejects those advanced constructs before
74+
`execute_operation`. Quotes and comments are treated as data. The model is told
75+
this supported dialect. This is intentionally not a general query parser or a
76+
cardinality/CPU bound; the source must enforce sample/memory/time quotas.
77+
78+
## Security verification scope
79+
80+
The suites cover foreign IDs/cursors/customer overrides, role escalation and
81+
revoked sessions; unsafe catalog claims and injected tool arguments; fixed
82+
destinations, redirects, deadlines and streamed response limits; persistent and
83+
reflected text/HTML handling; credential redaction before persistence/model use;
84+
cross-replica run/financial races, uncertain usage and retention/accounting safety.
85+
Final local verification on the combined candidate:
86+
87+
- **4,201 workspace tests pass**, plus **25 real HTTP/PostgreSQL tests** and
88+
**five Chromium flows** against the actual API/database with explicit synthetic
89+
provider boundaries. Typecheck and API/web production builds pass. Lint has
90+
zero errors and 14 existing warnings.
91+
- **Six security guard mutations are killed by behavioral assertions**: normalized
92+
credential fields, complete header values, connection URL schemes, object-key
93+
redaction, query dispatch policy and the strict router context contract. Source
94+
is restored after every mutation; transform/compile failures do not count.
95+
- Chart: **nine** real Helm render/schema tests pass. Fleet: **35** configuration,
96+
real owned-key crypto, Make and landing fixtures pass; **17** guard mutations
97+
are killed. They do not access a customer credential or deploy anything.
98+
- Browser fixture isolation is corrected: each flow receives a fresh synthetic
99+
ingress address; the router flow uses its own read-only person so its persisted
100+
last-view preference cannot change the next person's starting state. Production
101+
rate limits, login, customer authorization and budget enforcement remain active.
102+
103+
- Production JS dependency audit: 285 total dependencies, zero known advisories
104+
at review time (`pnpm audit --prod --json`). This is not an OS/image scan.
105+
- Redacted Gitleaks scan of each feature Git range: chart and fleet have no
106+
findings; dashboard reports four copies of the same deterministic synthetic
107+
TOTP encryption fixture in test files. Each is reviewed as fixture data, not a
108+
runtime credential. Findings are not suppressed with a broad path allowlist.
109+
- GitHub CodeQL alert inventory contains no open managed Ask finding. One open
110+
historical Python logging alert belongs to `backend/app/api/routes/auth.py`,
111+
outside this TypeScript feature. New commit checks must pass before merge.
112+
- No third-party hosted security scan, penetration test of a deployed customer,
113+
container/OS vulnerability scan, cloud-wide IAM audit or restored-backup test
114+
is represented by these checks.
115+
116+
## Operational failure modes that remain acceptance gates
117+
118+
- **Mixed replicas / flag propagation:** a rollout is complete only after every
119+
old replica is replaced and denials are observed. Provider revocation has its
120+
own propagation time; a boolean is not an instantaneous kill switch.
121+
- **Budget configuration drift:** stale replicas may never raise a persisted
122+
pool. Raising the configured cap during a month does not raise an existing
123+
pool automatically; future months use the configured cap. Lowering requires
124+
disabled dispatch, consistent rollout and persisted-pool verification. An
125+
existing pool increase needs a separately reviewed reconciliation procedure.
126+
- **Unknown provider outcome:** keep uncertain holds; settle from authoritative
127+
receipts. Retention, restart and rollback cannot release money speculatively.
128+
- **Private data beyond primary tables:** deployed backup expiry, restore sweeps,
129+
effective database logging and provider invocation logging need runtime checks.
130+
The dated control-plane observations do not establish effective SQL defaults
131+
or deletion from every retained backup.
132+
- **Source cost and capability:** request byte/result/deadline/dialect bounds do
133+
not replace upstream resource quotas. Verify actual per-customer query limits
134+
and status-source availability before promising those capabilities.
135+
- **Release identity and health:** deploy the reviewed image digests/chart,
136+
verify current prices/counter/credential on every replica, then repeat both
137+
live views, staff read/export/cleanup and enabled→disabled→rollback checks.
138+
Record pilot start only after that evidence exists.

0 commit comments

Comments
 (0)