A successful load after a failed search must clear the error even when
the rows, total and counts match the state the failed search left
behind. Without the !dslError check the reducer returns that state and
the error stays visible.
Review of the scope filter:
- netip.ParseAddr accepts any text after % as an IPv6 zone, commas
included, so "fe80::1%eth0,10.0.0.0/8" was kept and the comma join
added 10.0.0.0/8. Zoned addresses are now dropped, and every kept
entry is passed on in canonical form (p.Masked().String(),
a.String()), which never holds a comma or space. IPv4-mapped entries
become the IPv4 range they map.
- The cap was 1,024 entries; a company scope can be larger. It is now
8,192 entries and 120 KiB per list (the proxy gets each list as one
environment string, limited to 128 KiB).
- The runner logs dropped entries with the task ID and their values (up
to 20), so an operator can see why an approved target is refused.
- More names that make a shell or interpreter run extra code are
refused: SHELLOPTS, BASHOPTS, PS4, IFS, PROMPT_COMMAND, GLIBC_TUNABLES,
PYTHONSTARTUP, PYTHONHOME, NODE_OPTIONS, PERL5OPT, PERL5LIB, RUBYOPT,
JAVA_TOOL_OPTIONS, GIT_SSH_COMMAND, GIT_CONFIG_PARAMETERS.
ValidateEnv refused secret-looking names only. An exec request could set
HTTP_PROXY, HTTPS_PROXY, ALL_PROXY or NO_PROXY (any case) and send the
command around the egress proxy, or set PATH, LD_* (LD_PRELOAD,
LD_LIBRARY_PATH, LD_AUDIT, ...), BASH_ENV, ENV, GCONV_PATH or PYTHONPATH
and run code before the command. In the Docker backend the exec Env
overrides the worker container's env, so this applied there.
- ValidateEnv refuses these names with 400. FilterPanelEnv drops them, so
the panel does not send a request the runner refuses.
- ValidateExecRequest checks every scope entry: a domain must be a host
name (optionally "*."), a CIDR entry a valid prefix or address. Both
backends join the entries with commas into the egress proxy
environment, so "1.2.3.4/32,10.0.0.0/8" added an entry nobody
approved. Invalid entries (including any with a comma or a space) are
dropped whole, never split, and the valid ones are kept: the panel
builds scope from free-text fields, and a narrower scope fails closed
at the deny-by-default proxy. The runner logs how many entries it
dropped. More than 1,024 entries in either list is still a 400.
Converts the chat page, chat view and draft chat, the dashboard, the
shared browser page, and the login and setup pages to typed reducers in
_state/. The selected conversation and approval focus stay in the URL.
The chat list poll (2 s) and the dashboard live (5 s) and system (15 s)
polls return the same state when the data is unchanged.
Part of #546.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Converts these pages to typed reducers in _state/, on the shared list
and request slices. The chat bridge status poll returns the same state
when the bridge is unchanged.
Part of #546.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Converts the intercept rules page and judge card, the asset intercept
page, and the notify page and its delivery list to typed reducers in
_state/, on the shared list, request and pagination slices.
InterceptPage's regexErr state is removed: it was only ever set to "",
so its error message could never render.
Part of #546.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Converts the LLM page and profile sheet, the tools page, tool editor and
custom tool dialog, and the create-agent dialog to typed reducers in
_state/, on the shared request slice.
Part of #546.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unchanged-poll comments now say what the code guarantees: the same
state object is returned, so React can bail out of the update. The
assets list comment now says when loaded is reset (first load and a
manual refresh, not tab, page or query changes).
Tests, as requested in review: a poll that changes one nested field of
one row updates that row (assets and credentials), and a successful load
after a failed search clears the error and shows the rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DecomposeGoalsWithProvider built its session without a DynamicBoundary,
and Norma reads 0 as "no cache breakpoint", so every turn of goal
decomposition resent its tools and system prompt uncached on Anthropic
profiles. It now sets 1 for its single static segment, the breakpoint
docs/context-telemetry.md still said deferredSystem returns 0 without
a global deferred-MCP block. It now describes the always-on boundary
and what system_dynamic holds on each lane.
Tests: TestDecomposeGoalsValidStructuredToolCallAccepted checks the
boundary on every request (needs Postgres); it fails with the fix
reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part 1 of 4 of the proxy pool design in #545: storage and a CRUD API.
Nothing activates an entry yet, so the global proxy is unchanged.
- Migration 0028 adds proxy_pool: a unique keyed address hash, at most
one active entry (partial unique index), a CHECK that the active entry
is enabled, and nullable egress_ip, last_check_at and last_check_ok for
the health check.
- Addresses are normalized, sealed at rest (AAD proxy_pool.address) and
covered by the startup key check and key rotation. Uniqueness uses an
HMAC under a sub-key kept on secretBox; RotateSecretKey locks the table
and rehashes in its transaction, and pool writes seal under that lock.
- GET/POST /api/proxy-pool and PATCH/DELETE /api/proxy-pool/{id} never
return an address; a masked address on update keeps the stored one.
- Each worker and proxy pod gets a new name per generation
(artex-w-<hash>-<6 hex>). Exec targets the exact pod of the task state,
so an exec delayed at the API server fails with 404 instead of running
in a replacement pod before that pod passed its network probes.
- setupTask lists the task's pods by label and deletes every pod except
the ones it keeps, with a UID precondition, before it creates new ones.
Same-named pods are no longer deleted without an ownership check.
- Recover adopts only pods whose name matches artex-[wp]-<32 hex>-<6 hex>
and whose name, labels and task annotation agree.
- podAlive returns an error for API failures. Only 404, a UID mismatch, a
deletion timestamp, or a pod that is not running and ready count as
dead. On other errors (a cancelled request too) the exec fails and the
task's pods and policies stay.
- waitPodReady fails fast on CrashLoopBackOff and on exited containers.
- The deny probes print one token per outcome. Only timed out, refused or
unroutable connections count as blocked. Any other result (missing
timeout binary, failed fork, no API env) fails setup at once.
- Probe output, stderr and HTTP client errors go to the runner log only.
The returned errors are generic. A cancelled API request returns a
cancellation error, not "runner unavailable".
- Add fd20:ce::254/128 (GCE IPv6 metadata) to the never-reachable ranges.
- Document that ARTEX_KUBE_CLUSTER_CIDRS must also list the API server
endpoint addresses when they lie outside the cluster ranges (managed
clusters).
- Exec, Kill and Delete reject task IDs with surrounding whitespace.
- go.mod: gopkg.in/yaml.v3 back to indirect (go mod tidy).
- Test: a cancelled exec keeps the task. The scope and probe tests move to
the test PR to stay inside the size limit.
From a second review of the backend:
- Scope CIDRs written as IPv4-mapped IPv6 (::ffff:10.0.0.0/104) are read
as the IPv4 range they map, so the private-range filter and the
never-reachable excepts apply to them. netip treats the two families as
distinct, so such an entry skipped both.
- The never-reachable list adds 0.0.0.0/8 and :: (they reach the proxy's
own host), ::ffff:0:0/96 and link-local through NAT64
(64:ff9b::a9fe:0/112).
- ARTEX_KUBE_CLUSTER_CIDRS and ARTEX_KUBE_PROXY_DENIED_CIDRS refuse /0
(an except equal to its block is rejected by the API server) and
IPv4-mapped prefixes (they would never match).
ARTEX_RUNNER_BACKEND=kubernetes runs each task in a worker pod behind its own
egress-proxy pod, created through the Kubernetes API (kube_client.go) with no
container runtime socket. Per-task NetworkPolicies are applied before the pods
and removed after them; the runner proves they are in effect before the first
command, runs commands through pods/exec under env -i and artex-exec-wrap, and
re-adopts task pods after a restart. Unit tests run against a fake API
server; this commit keeps the tests for the review items, and the other
unit tests and the live cluster test follow in a separate PR.
Changes since the first review (502e42d):
NetworkPolicies and scope:
- Delete and failed setups delete the task's pods and wait until they are
gone before removing the service and, last, the policies. If a pod
cannot be deleted, the policies stay and the task stays tracked. Pods
get a 1s grace, not 0: a zero grace removes the API object before the
kubelet has stopped the containers.
- applyPolicy replaces an existing policy only when it carries the
runner's labels for the same task, and sends its resourceVersion.
- ARTEX_KUBE_PROXY_DENIED_CIDRS adds to DefaultProxyDeniedCIDRs instead
of replacing it. An empty DNSPodLabels map falls back to k8s-app=kube-dns.
- No scope opens the cluster: ARTEX_KUBE_CLUSTER_CIDRS (pod, service and
node CIDRs) plus metadata, loopback, link-local and the API server
address form a never-reachable list. Each scope ipBlock gets them as
except (a block inside one is dropped), the public rule excepts them,
and the proxy refuses them through ARTEX_NEVER_CIDRS (new
EgressPolicy.Never; Docker does not set it). Without
ARTEX_KUBE_CLUSTER_CIDRS, scope CIDRs overlapping private, loopback or
link-local ranges are dropped (logged), so the scope fails closed.
- Isolation does not rely on an outside default-deny policy: every task
pod has its own Ingress+Egress policy, adopted tasks get theirs applied
again, and before the first command the runner checks that the worker
reaches neither the API server nor a public address directly and that
the proxy cannot reach the API server; setup fails otherwise. A scope
change replaces the worker too, so the checks run in a worker no
command has used.
- The proxy pod uses ndots 1, so scope names are not first looked up as
cluster names.
Exec:
- The worker base env comes after the request env in the env(1) argv.
Refusing PATH, proxy and loader variables (LD_*, BASH_ENV, ...) in a
request is a separate change to the shared ValidateEnv, which also
covers the Docker backend.
- Any exec error after the stream started (cancel, broken stream, read
limit) kills the worker's processes, and so does a wrapper timeout
(exit 124 after at least timeout_ms, the Docker rule).
- Exec, Kill and Delete validate the task ID; Exec validates the request.
Concurrency and cleanup:
- Kill takes the task lock; stored tasks are copied, never changed in
place. A Kill caused by an exec acts only on the worker pod UID that
ran it; pod deletes carry a UID precondition.
- An exec queued behind a Delete returns ErrNotFound instead of creating
the task again. Per-task locks are reference counted and removed.
- A failed setup removes what it created, found by label (a foreign
object with the same name stays). Delete returns ErrNotFound only when
no object of the task exists.
- Recover adopts only pods named artex-w-/artex-p-<hash> and services
with a real ClusterIP; adopted tasks are re-checked on first use.
- Scope hash: full SHA-256; task object names use 128 bits.
Config: http:// API servers are refused, the tasks and audit sub paths
must not be ".", equal or nested, and NewKubernetesBackend documents what
the deployment must provide (PID limits, restricted namespace, quotas,
shared volume, shared Kill).
- Test the 401 login fallback when the body is not JSON.
- Flag bare sendBeacon calls and parse .js, .mjs and .cjs as JavaScript.
- Record the change-password 403 in the CHANGELOG.
- change-password returns 403 for a wrong current password and keeps 401
for an invalid or expired session, like authInit's bad setup token.
- apiFetch only treats a 401 from /auth/login as bad credentials; every
other 401 clears the session and returns to /login.
- Tests cover change-password with an expired session and with a wrong
current password, and the direct-network check parses the AST so
comments, strings and test files cannot produce false positives.
- apiFetch treats a 401 from /auth/* as bad credentials, not as an
expired session: the session is kept and the server message is
exposed instead of reloading /login.
- Test the openSSE constructor wiring, the login 401 path, the absence
of Content-Type on the three FormData uploads, and broaden the direct
network check to window/globalThis/self fetch, XMLHttpRequest,
EventSource and sendBeacon in .js, .mjs, .cjs and .jsx files.
- apiFetch forces credentials same-origin and redirect error after the
caller init, so a caller cannot widen either and a future redirect is
refused like in SSEStream.
- clearToken reuses the cookie deletion clearSession uses, including
SameSite=Lax and Secure over HTTPS.
- loadOlderHistory catches the ForbiddenError and shows the server
message instead of leaving an unhandled rejection.
With the category Combobox of the New task sheet open, an overlay click
closed the whole sheet: isRadixOverlayOpenNow did not match the Base UI
popup, whose open state is data-open, not data-state. Add
[data-slot='combobox-content'][data-open] to the selector.
Add web/src/lib/utils.test.mjs, run by test:reducers: a DOM-free test of
preventDismissUnlessOverlayClick with a stub document, covering Select,
popper content, Combobox, menu triggers, the open sheet/dialog trigger
and an expanded Collapsible. The alias loader now adds the JSON import
attribute so tests can import modules that depend on @/i18n.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
requirePerm now applies the recorded permission instead of only checking
that one exists: a perm.Authenticated pattern answers 401 without a valid
session. requireAuth exempts /api/auth/ by prefix, so a wildcard pattern
such as "GET /api/{kind}/items" would otherwise be public for
/api/auth/items.
Handler builds its chain with handlerFor, and TestUntaggedRouteIsForbidden
uses handlerFor, so removing requirePerm from the production chain fails
the test. A wildcard route is tested with a path under /api/auth/.
TestNoRawRouteRegistration allows only root.Handle("/api/", ...) and
root.HandleFunc("/", ...) in server.go; any other root route would skip
requireAuth.
TestHandlerDeniesAuthenticatedRoutesWithoutSession checks every
authenticated route through the real Handler.
Every /api route is now added with s.handle(mux, pattern, perm, h), which
records the permission the route needs. There are two permissions for now:
perm.Public for the routes requireAuth already exempts (/api/auth/*,
/api/health, /api/ready) and perm.Authenticated for all others.
A new check runs after requireAuth and answers 403 when the matched pattern
has no recorded permission, so a route added with a plain HandleFunc call is
denied instead of served. requireAuth itself is unchanged.
Tests check that every route has a permission, that the public routes are
exactly the ones requireAuth exempts, that no file registers a route outside
s.handle, and that an untagged route returns 403.
The review asked for a rebase onto main. A rebase cannot be published to
this fork: ruleset "prevent-force-push-any" (id 13967828) applies
non_fast_forward to ~ALL branches, so every force-push is rejected. The
branch is therefore brought up to date by merge, which is a fast-forward
push and leaves the reviewed commits in place.
The merge result is byte-identical to the rebased result: the staged tree
hashes to 7d33b7fc, the same tree as the rebase I verified locally
(tsc, biome, test:i18n 11/11, test:reducers 59/59, build:static).
Conflict resolution:
- CHANGELOG.md: main's Added section grew (Slack channel, log rotation);
this branch's target-gate entry is kept between them.
- overview-tab.tsx: main refactored TaskInterceptRulesCard onto
useReducer (b9388fb7), so the gate was ported into the new shape rather
than the reverse. The gate keeps its own local state beside the reducer
and the rules read feeds the existing `rulesLoaded` action; the task-id
and request-stamp guards from the review apply to both reads. Nothing
from the refactor is reverted: the diff against main on this file is
additions only, apart from the two lines the guards replace.
http() and twelve calls that used fetch directly (uploads, downloads,
exports, the report, tool-config and the logs history) each built their own
Authorization header. Only http() and the HAR export handled a 401, with two
inline copies of the session clean-up, and openSSE had a third.
All of them now use apiFetch (src/lib/api-fetch.ts):
- 401: clearSession() (src/lib/auth.ts) drops the token and the cookie and
goes to /login, then the call throws, as http() did before.
- 403: throws ForbiddenError, an ApiError with status 403 and the server's
message, ready to show in a toast.
ApiError moves to api-fetch.ts and is still exported from api.ts. The SSE
client keeps its own fetch and now calls clearSession on a 401.
SheetContent and DialogContent each carried a copy of the same
onInteractOutside guard, and losing one copy is how the Sheet guard
disappeared. Move it to preventDismissUnlessOverlayClick in lib/utils.ts
and call it from both. No behavior change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>