Commit Graph
366 Commits
Author SHA1 Message Date
BaaRai f483ecec83 test(server): cover the Norma temp directory rules in a private temp directory
TestCheckNormaTaskDir runs every rule of checkNormaTaskDir on stat facts
alone, without root and without a file system.

On a real directory, with and without root:
- TestPrepareNormaTaskDirAlreadyThere: a directory the executor uid owns, one
  its gid can write in and an other-writable one fail the start, and the error
  names the path, the owner and group, the mode, the executor and the remedy;
  one of another user or of root that the executor cannot write in is used as
  found. Owners, modes, times and contents of the directory and of what it
  holds are hashed before and after: nothing changes in either case.
- TestPrepareNormaTaskDirParent: a parent the executor can write in and that
  is not sticky fails the start; the same parent with the sticky bit passes.
- TestPrepareNormaTaskDirNotADirectory: a symlink, a dangling symlink and a
  regular file fail the start, and nothing is created through the link.
- TestPrepareNormaTaskDirDropDisabled: with the drop disabled nothing is
  checked or created.

As root, TestNormaTaskDirPlantedByExecutorAsRoot lets an executor process
create <temp>/norma with a symlink in it, as it could before a start:
PrepareExecPrivilege fails and leaves the directory as it is.

The root fixture now gives each test its own temp directory, 1777 like /tmp.
PrepareExecPrivilege and Norma's Bash tool reach <temp>/norma, and before
this every root test went to the one of the host. The new tests set TMPDIR to
t.TempDir() for the same reason.
2026-11-20 06:36:48 +01:00
BaaRai 36940cdf0b security(server): decide the Norma temp directory check from the executor identity
The check of <temp>/norma, where Norma writes background-task output from
the server process, now lives in checkNormaTaskDir. It takes the Lstat of
the path, the Stat of its parent and the executor uid and gid, and decides
from the owners and the mode bits. An access check would answer for root,
which the server is.

The start fails when:
- the path is a symlink or not a directory;
- the executor uid owns the directory: under a sticky /tmp the owner can
  still rename it and put another in its place;
- the group or other bits let the executor write in it;
- the parent directory is writable by the executor and not sticky, or the
  executor owns the parent: the sticky bit does not stop the owner of a
  directory from renaming an entry in it.

The error names the path, its owner and group, its mode, the executor uid
and gid, and the remedy: remove the directory or set TMPDIR to a directory
the executor cannot write.

Any other directory already there is used as found, with the same warning as
before when root does not own it or its group can write in it. A missing
directory is still created root:root 0755 and goes through the same check.
A directory that was already there is never chmodded, chowned, renamed or
removed. With the privilege drop disabled nothing is checked or created.
2026-11-20 06:36:48 +01:00
BaaRai 992fcf7030 security(server): refuse to start when the executor can write the Norma temp directory 2026-11-20 06:36:48 +01:00
BaaRai de070c964a test(server): keep the database environment for the tests after the env scrub test
TestSecretEnvCoversCredentialURLs calls ScrubSecretEnv, which unsets every
name in secretEnv for the rest of the test binary, ARTEX_PG_DSN and
ARTEX_SECRET_KEY included. The leak is new on this branch: main has no such
test. Without the fix a merge would silently skip 148 server DB tests in CI:
they skip when ARTEX_PG_DSN is not set, and the run stays green.

The fix is in the test: the loop over secretEnv restores every name with
t.Setenv, so each one gets its value back when the test ends.
2026-11-20 06:36:47 +01:00
BaaRai ebb90199c5 security(agent): name the Norma background output directory
Norma keeps the output of background tasks in os.TempDir()/norma
(<tmp>/norma/<session>/tasks/task_<n>.output), written from the server
process with MkdirAll and an open that follows symlinks. ARTEX does not
choose that path, and the temp directory is world-writable: an executor
process that runs before the first session creates the directory (a stdio
MCP server, a process left from an earlier start) could create it first and
place symlinks in it for the server to write through.

- PrepareExecPrivilege, only when the drop is enabled, now creates
  <TempDir>/norma itself (prepareNormaTaskDir): Mkdir 0755 as root, then
  Lstat. A symlink or a file in its place is refused and the server does
  not start.
- A directory that is already there is used as found. It is not chowned:
  it may belong to another user of the host. When root does not own it or
  others can write in it, a warning is logged and nothing else changes.
- SECURITY.md adds this output to the residual list of the Agent Process
  Isolation paragraph, with what the start-up step does and does not cover.

Norma is unchanged.

Tests: TestPrepareNormaTaskDir (created when absent, kept when there,
symlink and file refused, nothing created through the symlink);
root-only TestNormaTaskDirAsRoot (PrepareExecPrivilege leaves
<TMPDIR>/norma root:root 0755 in a sticky world-writable directory, and
an executor process can neither add an entry nor rename it).
2026-11-20 05:35:57 +01:00
BaaRai 4fa45eb449 security(agent): ask_operator staging refuses symlinks and never overwrites
The staged copy of an ask_operator image was written by the server with
os.Create under a name built from the second, in an uploads directory made
with MkdirAll. An agent that can write in uploads/ (a task directory from
before the run-directory layout) could prepare that name as a symlink, and a
symlinked uploads/ was followed.

- uploads/ is created with Mkdir and checked with Lstat: a symlink or a
  file in its place is refused.
- The name is ask-operator-<unixnano>-<8 random hex>.<ext>, created with
  O_CREATE|O_EXCL, mode 0640. A taken name is never opened: another name is
  tried, five at most.
- The source is opened only when it is still the regular file Lstat saw
  (os.SameFile on the Lstat and the Stat of the open file), which refuses a
  file swapped for a symlink between the EvalSymlinks check and the open.
  The run-directory confinement is unchanged.

Not closed: a directory inside the run directory swapped for a symlink
between the check and the open still leads both Lstat and the open to the
same file elsewhere.
2026-11-20 05:35:56 +01:00
BaaRai 7be765bff2 security(agent): restore group sharing for legacy task entries; resolve ask_operator paths from the run dir
The layout commit made tasks/<id> root:root 0755 and shared only the run
directories. Entries that sat directly in a task directory before it
(uploads/, files the main agent wrote there) were left as found and
nothing shared them any more: after an archive restore, which keeps
neither owners nor modes, the executor could not use them. ask_operator
still resolved a relative image_path from tasks/<id>, not from the
directory the agent works in.

- shareTaskDir: after the task directory is set root:root 0755, each
  direct entry that is not a run directory (main, i<N>) is shared with
  the executor group again (shareWithExecGroup: group owner, group
  read/write, traverse and setgid on directories). Run directories are
  handled as before. The task directory stays root-only, so the executor
  works inside an old entry and cannot rename, remove or add one. A
  symlink among the entries is not followed. The pass runs at start-up
  and on archive restore (installTaskArchiveFiles calls
  shareRestoredTaskDir and rolls back on failure), with no operator step.
- ask_operator: image_path is resolved inside the run directory of the
  agent that asks (agent.EnsureRunDir: tasks/<id>/i<N> for a worker,
  tasks/<id>/main without an intent). An absolute path outside it, "..",
  and a symlink leading out are refused as before. The copy is still
  staged in tasks/<id>/uploads. The tool description says so.

Tests: root-only TestShareTaskDirLegacyEntriesAsRoot (owners and modes,
an executor probe, links to a root-only directory and file left alone);
TestRunDirLayoutOnExistingTreeAsRoot now expects the old file shared;
TestTaskArchiveRestoreRunDirOwnershipAsRoot restores an entry of the task
directory; TestStageAskOperatorImage uses the i<N> and main leaves.
SECURITY.md states the sharing of the old entries and the empty main/.
2026-11-20 05:35:56 +01:00
BaaRai 7520c6e588 security(agent): command-output spills go to a root-owned per-task dir
Norma's tool.Capture writes an oversized tool output to a file in
ToolOutputDir, from the server process. ARTEX passed <run dir>/cmd-output:
the executor can write in the run directory and could turn cmd-output into
a symlink, so root wrote the spill where the link pointed.

- With the privilege drop on, ToolOutputDir is <data>/spill/tasks/<id> for
  the worker, the main agent and the planner of a task, and
  <data>/spill/sessions/<id> for a chat. The server creates it when the
  run starts (agent.SetSpillDirMaker, same style as SetRunDirMaker):
  root:<exec gid> 0750 below root:root 0755 parents, each level through a
  descriptor opened with O_NOFOLLOW. A directory that cannot be created
  leaves the run without a spill directory (output is truncated), never
  with the run directory. Without the drop the path stays
  <run dir>/cmd-output.
- Norma v0.4.11 writes the spill file 0600 (directory 0700), so the
  executor could not read it. The runs wrap their hooks (agent.SpillHooks):
  after a tool call whose result carries the spill marker, the server makes
  the files of the directory root:<exec gid> 0640. The agent reads a spill
  with Bash; the file tools do not reach outside the run directory.
- The spill directory follows the task: stageTaskFiles moves it to the
  delete staging with tasks/<id>, stageTaskArchiveFiles packs it as
  files/spill/tasks/<id>, and installTaskArchiveFiles restores it and puts
  its ownership back. Deleting a conversation removes
  spill/sessions/conv-<id>.

Tests: TestToolOutputDir (agent); TestDeleteTaskFilesRemovesSpillDir,
TestRemoveConversationSpill and the archive round trip (server); root-only
TestSpillDirAsRoot, and the spill directory in
TestTaskArchiveRestoreRunDirOwnershipAsRoot. SECURITY.md drops the spill
from the residual list.
2026-11-20 05:35:55 +01:00
BaaRai e73cdeda93 security(agent): share only run-dir leaves; main agent gets its own leaf
The task and chat workspace trees were shared whole with the executor
group, and the main agent and the planner worked in tasks/<id>, the parent
of every worker directory: the executor could rename, remove or replace a
run directory, its own included, and plant entries beside them.

- Layout: no agent working directory is an ancestor of another. The main
  agent and the planner work in tasks/<id>/main, a worker in
  tasks/<id>/i<N>, a chat in sessions/<id>. With the privilege drop on,
  tasks/, sessions/ and tasks/<id> are root:root 0755 and only the leaves
  are root:<exec gid> 2775.
- PrepareExecPrivilege no longer shares tasks/ and sessions/. It sets the
  parents, shares the leaves found on disk with what they hold, and
  registers the run-directory maker (agent.SetRunDirMaker). ensureRunDir
  and the chat session directory go through it: each level is created
  with Mkdir and set through a descriptor opened with O_NOFOLLOW, parents
  before the leaf, so a link planted where a run directory goes is
  refused. Without the drop both stay a plain MkdirAll.
- Uploads for the main agent land in tasks/<id>/main/uploads, and the
  attachment paths given to it use the same directory; session uploads
  create sessions/<id> by the same rule.
- Task archives still pack and delete the whole task directory, so the
  package holds files/tasks/<id>/main and i<N>. The package keeps neither
  owners nor directory modes: the restore puts the layout back
  (installTaskArchiveFiles takes the privilege).
- Existing data is not migrated. Files a task wrote directly in
  tasks/<id>/ stay there with their owner and mode; the main agent starts
  in an empty tasks/<id>/main and its file tools no longer reach them.

Tests: TestRunDirLayout and TestIsRunDirName (agent); root-only
TestRunDirLayoutAsRoot, TestRunDirSiblingsProtectedAsRoot,
TestRunDirLayoutOnExistingTreeAsRoot and
TestTaskArchiveRestoreRunDirOwnershipAsRoot (server). The archive tests
use the main/ and i<N> leaves. SECURITY.md states the invariant, names the
race that remains and drops ensureRunDir from the residual list.
2026-11-20 05:35:55 +01:00
BaaRai c1c1fe9141 security(agent): confine ingest_bbot; write tool scripts outside the run dir
Two root file operations took a path the agent controls.

- ingest_bbot opened the path it was given with os.Open in the server
  process, which is root in the image: any root-readable file could be
  named, and the result counts told its line structure. The tool now opens
  the file through the file tools' confinement (openWorkRoot on the run's
  working directory under the data directory, then os.Root): an absolute
  path elsewhere, "..", a symlink, a hard-linked file and a run directory
  reached by a symlink are refused. It fails closed without a data
  directory or a working directory. The worker passes its data directory
  to the ToolSet (SetWorkBase); the tool reads the ToolContext for the
  working directory, like ingest_scan_output.
- execPython wrote the script of a custom tool as root to
  <run dir>/.tools and then chowned it. The executor can write the run
  directory, so it could turn .tools into a symlink and have root create
  and chown a file elsewhere. With the privilege drop on, the script now
  goes to <data>/exec-scripts, created by PrepareExecPrivilege as
  root:<exec gid> 0750, outside tasks/ and sessions/: the executor reads
  the 0640 script and cannot create, rename or replace an entry. An
  enabled drop without that directory is an error, not a fallback to the
  run directory. Without the drop nothing changes. PrepareExecPrivilege
  takes the privilege by pointer to record ExecPrivilege.ScriptDir.

Tests: TestOpenBbotOutputConfined and TestIngestBbotToolConfined (no
Postgres), TestExecPythonNeedsScriptDirWhenDropping, and the root-only
TestExecPythonScriptDirAsRoot (.tools planted as a symlink to a root-only
directory). TestIngestBbotScopeSplit now places its file in a run
directory. SECURITY.md: the two paths leave the residual list; the
command-output spill stays.
2026-11-20 05:35:54 +01:00
BaaRai ebcfe532e0 security(agent): refuse run dirs reached by symlink; scrub S3 archive keys
- openWorkRoot: refuse the run directory when its resolved path differs from
  the path under the data directory, so a relative symlink that stays inside
  the data directory (run -> traffic/_ca) no longer reaches root-only files.
- Test: TestConfinedFileToolsRunDirRelativeSymlinkInside targets <base>/traffic/_ca.
- secretEnv: add ARTEX_ARCHIVE_S3_ACCESS_KEY_ID, ARTEX_ARCHIVE_S3_SECRET_ACCESS_KEY,
  ARTEX_ARCHIVE_S3_SESSION_TOKEN; the sealed-env test covers them.
- SECURITY.md: document the run-dir race and the residual root writes through
  agent-influenced paths (cmd-output spill, .tools, bbot ingest).
2026-11-20 05:35:54 +01:00
BaaRai eb5d3d73c1 security(agent): confine the file tools and close the executor review
The SDK file tools Read, Write, Edit, MultiEdit, LS, Glob and Grep run in
the server process, which is root in the image, and took any absolute or
relative path: Read returned /app/keys/jwt.key or the config file, and
Write could plant a skill or rewrite the config past the approval gate.

- agent/filetools.go: defaultTools replaces the seven tools for every
  agent kind (chat, main agent, planner, worker). Same names, prompts and
  schemas; every path goes through an os.Root on the run's working
  directory, opened component by component below the data directory, so
  absolute paths elsewhere, "..", symlinks leading out, a run directory
  swapped for a symlink and files with extra hard links are refused. Grep
  no longer starts ripgrep. The LLM connection test passes an empty tool
  list instead of nil (nil meant the unconfined defaults).
- traffic: chmod the go-mitmproxy CA private key to 0600 after the proxy
  creates or loads it; the CA certificate stays readable.
- server: the executor gets HOME and XDG_CACHE_HOME in <data>/exec-home,
  owned by it, on the bash shim, the MCP drop shim and the custom-tool
  credential path.
- server: ARTEX_LLM_PROXY and ARTEX_LLM_BASE_URL can carry user:pass@;
  they are scrubbed and sealed with the other startup secrets.
- docker: no-new-privileges for the artex service, setuid/setgid bits
  stripped in the image, PLAYWRIGHT_BROWSERS_PATH kept at root's cache.
- db: the persistence approval seed inserts each rule only when no rule
  of that name exists, so a re-run does not duplicate rules.
- Root-gated tests run the bash shim, a custom tool and an MCP stdio
  command as the executor and check the uid, a 0600 root file, the
  server's /proc environ and a cache write.
2026-11-20 05:35:54 +01:00
BaaRai 04a7ab3c39 security(server): keep server secrets from agent processes
GHSA-prm8-vw2v-wjwh: the agent command executor ran as root in the server's
container and PID namespace, so it could read /app/keys and recover the
server secrets from /proc/<pid>/environ.

Deliverable 1, executor identity. Agent processes (Bash, the interactive
shell, custom tools, stdio MCP servers) run as the uid/gid set by
-exec-uid and -exec-gid (default 10001). Custom tools use
SysProcAttr.Credential. Norma starts Bash and the shell itself, so a PATH
shim (the server binary named bash) drops the identity before exec; MCP
stdio commands run through the same binary in drop mode. The task and chat
workspace trees are shared with the executor group (setgid, group rw,
umask 002). The key files and the config file become root-only, and
/app/keys is 0700 in the image. An explicit -exec-uid that cannot be applied
stops the start; the default logs once that same-uid isolation is
unavailable when the server is not root.

Deliverable 2, sealed environment. On Linux, SealProcessEnv re-executes the
server once with the secret variables removed from its environment block,
passing the values through an inherited pipe. The new image restores them
into the Go environment, so readers see the same configuration. Off Linux it
logs that the environment is not sealed.

Deliverable 3, approval gate. Custom tools, MCP servers and skill files
(create_/update_ of custom tool and MCP, create_skill, update_skill_file)
meet built-in ask rules seeded once (intercept_persistence_rules_v1). A user
allow rule cannot skip them; a user deny still wins. The rules are data the
agent cannot edit.

Tests: resolution and refusal of root identities, drop command wrapping,
sealed-environment encoding, and an end-to-end handoff test on Linux that
checks the kernel environment block and a child process hold no secret
names and that the values survive (empty and multi-line included). Approval
matching is tested in intercept.
2026-11-20 05:35:53 +01:00
BaaRai bd95c2669f Merge pull request #375 from Alexandre200-lab/main
Refactor PostgreSQL test skipping logic and improve documentation
2026-11-20 03:33:50 +01:00
BaaRai 705ac80128 Merge pull request #380 from Amineharrabi/feat/stream-messages-direction-filter
feat(traffic): filter stream messages by direction
2026-11-20 03:06:08 +01:00
BaaRai b27ac66009 security(server): block SSRF in POST /api/llm/models (GHSA-7w8h) 2026-11-20 02:35:39 +01:00
BaaRai 4677c1b6f6 Merge pull request #387 from BaaRai/security/workspace-platform-deny
fix(server): keep the capture CA and index out of the workspace file API
2026-11-20 01:37:49 +01:00
BaaRai 43f1c893c4 Merge pull request #385 from BaaRai/security/denylist-git-cmake
fix(intercept): deny always-allow for git, cmake, ctest and cpack
2026-11-20 01:34:21 +01:00
BaaRai 73ab430c6a fix(server): keep the capture CA and index out of the workspace file API
The workspace file manager roots every path at the data directory, so the
capture proxy CA private key under traffic/_ca and the SQLite exchange index
under traffic/_index were listable, downloadable, overwritable and deletable
through /api/workspace/*. Refuse those two subtrees after resolving the path,
so a symlink alias or a Windows spelling a trailing dot cannot reach them.
2026-11-20 01:23:50 +01:00
BaaRai 02a67bf9c5 fix(intercept): deny always-allow for git, cmake, ctest and cpack
The argv allow denylist is the only gate that stops an always-allow rule
from naming a program whose flags can run arbitrary commands. git (aliases,
hooks, -c), cmake (-P), ctest and cpack run commands from user-controlled
files, so an allow prefix for them is never safe. Also key the arity table
by the normalised program name so a path-qualified binary derives the same
prefix length as the bare name.
2026-11-20 01:23:45 +01:00
BaaRai b3c9708bf3 fix(server): attach rotated LLM profile pin after execContextFor (#376) 2026-11-20 01:01:08 +01:00
unknownandClaude Opus 5.5 d22e9e0e58 feat(traffic): filter stream messages by direction
GET /api/traffic/stream and the traffic_messages tool take an optional
direction (c2s or s2c) to list one side of a WebSocket or SSE
conversation. total and offset apply to the filtered list, seq stays the
position in the whole stream, and the meta limit marker is kept in a
filtered page so dropped messages are never hidden. Any other value is
rejected (400 / tool error).

Part of #379 (traffic inspection: filter by direction).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:37:23 +01:00
Alexandrelab-200 cb0915319c fix(test): use pgdb alias for skip helper in aliased imports 2026-11-19 14:43:29 -03:00
Alexandrelab-200 f85eb86103 Merge remote-tracking branch 'refs/remotes/origin/main' 2026-11-19 14:25:18 -03:00
Alexandrelab-200 db0aae3657 Refactor PostgreSQL test skipping logic
- Introduced uniform skipping functions in the db package: SkipPGUnavailable and SkipNoPG.
- Updated all relevant test files to utilize these new functions for better consistency and readability.
- Added new db/testpg.go file to house the skipping logic.
- Created architecture and operations documentation to provide a comprehensive overview of the ARTEX system.
- Added a verification script to streamline local testing and ensure code quality.
2026-11-19 14:23:29 -03:00
BaaRai b1ccac4c9a fix(server): confine workspace and skill file paths against symlink escapes (#367) 2026-11-19 16:10:02 +01:00
BaaRai 9f892e4e95 fix(intercept): make target pins name-only behind any proxy
The gate treated a call as direct whenever only the recording proxy or a
custom tool's own proxy was in the path, so it stored IP pins the proxy
did not enforce. ProxyAddr now covers the recording and global proxies,
a per-tool check covers a custom http tool's own proxy, and the gate
marks the pin name-only for any of them.

Closes #368.
2026-11-19 15:47:36 +01:00
BaaRai c2ddd1c6ba Merge pull request #363 from chetanvhsk-wq/chetanvhsk-wq-postgres-readiness-probe
feat(server): add PostgreSQL-backed readiness probe
2026-11-19 14:28:40 +01:00
BaaRai a88bc26144 Merge pull request #349 from anqorithm/abdallah/console-browser-protections
feat(server): add browser protections for the operator console
2026-11-19 14:28:25 +01:00
Coff0xc bf6feefbdf fix(server): cap conversation message page size
GET /api/conversations/{id}/messages passed limit through to the
database with no upper bound, so a huge query could load the whole
transcript. Clamp history pages to 200 and keep the since tail at 1000.
2026-11-19 14:24:11 +01:00
chetan-venugopalaandCopilot App 2aa89ab786 feat(server): add PostgreSQL readiness probe
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-19 17:26:47 +05:30
Coff0xc 3546ea0fff fix(mcp): rewrite npx -y and playwright-mcp rows missing --browser
The stock seed was npx @playwright/mcp, but the UI mock and common
invocations use npx -y, which the first pass left untouched. Also add
--browser chromium to a leftover playwright-mcp --headless row, resolve
the MCP's playwright-core CLI via require.resolve, and cover proxy-arg
stripping so capture sync does not depend on args[0].
2026-11-18 22:42:38 +01:00
Coff0xc f2666dbae2 fix(mcp): launch the browser MCP from playwright-mcp, not npx
npx @playwright/mcp queries the npm registry on every start even with
the package installed globally, so the image's pin did not decide what
ran and offline starts failed. Seed playwright-mcp --headless --browser
chromium, rewrite leftover stock npx rows once, and install the Chromium
build the MCP's own playwright-core expects.

Fixes #329
2026-11-18 22:42:25 +01:00
Coff0xc 389825a683 fix(server): rate-limit change-password guesses
POST /api/auth/change-password checked the current password with bcrypt
and had no limiter. A stolen session could guess without backoff.

Reuse the login limiter, keyed by client IP and by the session token,
so rotating the source address with the same token still blocks.
A successful change clears both buckets.
2026-11-18 22:41:00 +01:00
anqorithm 23f95611c1 feat(server): add browser protections for the operator console 2026-11-18 22:13:26 +01:00
Coff0xc 203103360e fix(server): confine ask_operator image_path to the task directory
image_path was opened as a raw filesystem path, so any readable
png/jpg/jpeg/webp/gif on the host could be copied into the operator
transcript. The path is now resolved from the task working directory
and refused when it contains .. or EvalSymlinks outside that tree.
2026-11-18 17:22:42 +01:00
Coff0xc 230a99c2b9 fix(mcp): keep MCP env a writable map when JSON is null
json.Unmarshal of JSON null into a map yields nil. syncBrowserMCPProxy
then assigned NODE_EXTRA_CA_CERTS under traffic capture and panicked,
including during NewManager on every restart once that row was stored.
2026-11-18 11:43:40 +00:00
BaaRai 366e14066f Merge pull request #322 from Dev-next-gen/fix/finding-filename-utf8
fix(report): keep finding zip names on a rune boundary
2026-11-18 12:12:23 +01:00
Mike ReadandClaude Opus 5.5 03e216d032 fix: report provider refusals, do not rerun them as idle turns
A turn the provider's safety system declines (Anthropic stop_reason
"refusal", OpenAI-compatible finish_reason "content_filter") has no text
and no tool calls. Norma passes the stop reason through and the harness
ends any tool-less turn with ReasonCompleted, so the run summary said the
model "ended this turn normally", and steerHooks.Stop took the empty turn
for an idle one and resent the conversation up to the empty-response retry
count.

The LLM recorder is the one layer that sees the stop reason. It now hands
each completed call's stop reason to an optional context sink
(llmrec.WithStopSink). captureRunSession installs a per-run tracker
(agent.WithStopTracker) on that sink. With it:

- steerHooks.Stop does not inject the idle-turn rerun after a refusal;
- terminalText reports "provider refusal (stop_reason ...)" and says the
  intent was not completed, instead of the completed wording.

Other terminal states and ordinary empty turns are unchanged.

Fixes #327

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 00:41:18 -06:00
Leo Camus 88aefa0fc3 fix(report): keep finding zip names on a rune boundary
FindingFilename cut the name at 120 bytes, which can split a multi-byte
character. archive/zip only sets the UTF-8 flag on valid names, so the
entry was written without it and unzip tools decoded the whole name as
CP437, garbling every non-ASCII character in it.
2026-11-18 02:37:26 +00:00
Chubboy Ren c833130c28 fix: enforce exact record_fact fields and validate asset anchors 2026-11-18 01:51:41 +00:00
Chubboy Ren c0c568b31f Merge remote-tracking branch 'upstream/main' into codex/fix-record-fact-input-contract 2026-11-18 01:34:26 +00:00
BaaRai 6568a8eb44 fix(llm): record breaker health on every task LLM path
The /system/llm/ badge read llm_profile_health, which only the failover
Pool wrote. A task pinned to an explicit chain, a bound agent with
failover off, and the global provider all call the provider directly, so
a dead backend stayed "Healthy".

One policy now lives in llmpool.Registry.RecordCall, used by the Pool and
by the task runtimes: a success clears the state, a failover-eligible
failure trips it, context cancellation and deterministic 400s do not, and
a stream that already delivered output is left alone. The selection
carries the profile whose breaker the call updates, and a provider
already wrapped in the Pool reports nothing to avoid double counting.

The LLM recording page also explains an empty list while the llm_record
toggle is off, after the settings call resolves.

Originally reported in #257.
2026-11-18 01:31:18 +01:00
Coff0xc 6a0b79d34f feat(findings): add report_state separate from triage 2026-11-18 00:07:50 +01:00
protonmatter 95bd9c24f0 Merge commit 'eddf03ce61f0a506fede039ea8936709b84ade8e' into protonmatter/session-epoch
# Conflicts:
#	CHANGELOG.md
2026-11-17 16:56:29 -05:00
protonmatter 134562c3d9 Drop the unused database import and align the password constants. 2026-11-17 22:54:16 +01:00
protonmatter 7cac9c240b Retry the password version on login when startup could not read it. 2026-11-17 22:54:16 +01:00
protonmatter ebc54b8751 Bind sessions to a password version so revocation cannot tie inside one second.
The hash and version commit together, a failed read rejects tokens, and the reset script tells the operator to restart.
2026-11-17 22:54:16 +01:00
protonmatter 26a7bbec37 Reject sessions issued before a password change.
A failed password read no longer mints a setup token, and filling the login limiter no longer drops an active lockout.
2026-11-17 22:54:16 +01:00
BaaRai eddf03ce61 Merge pull request #304 from Protonmatter/protonmatter/llmpool-health-queue
Coalesce circuit-breaker health writes
2026-11-17 22:52:27 +01:00