The comment sat on the closing brace of factEvidenceLines, so Go attached it
to no declaration and godoc showed it nowhere. Noted in the review of #441.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The Skill tool's description carries the skill listing, but a description is
only read once the model decides to open the tool: on a live run with 36 skills
assigned the agent invoked Skill zero times across 485 trace records, hunting
every class with raw Bash. Put the names where every turn already looks, with
the rule to invoke the matching skill before hunting a class.
Names-only, bounded at 1200 bytes, empty for skill-less agents (prompt stays
byte-identical). The index rides the same seam as FindingGuidance, so the
cached-prefix path keeps its two segments byte-identical to the unsplit prompt.
With agent_traffic_binding disabled (the default) findingWorkflowTools strips
bind_finding_traffic from every agent toolset and removes traffic_refs /
evidence_hint_id from the report_finding and hint schemas, but the tool
descriptions keep promising the binding path: prove_goal says a finding closes
a goal once a traffic_ref is bound, and the report_finding error path says
already-registered findings can be bound later via bind_finding_traffic. An
agent then chases a tool that is not in its toolset.
Observed on a live run (v0.7.0, local OpenAI-compatible model): a worker spent
minutes on it — "the tool bind_finding_traffic must be invoked as a tool", a
bare Bash true, then grepping the transcripts and the strings of the binary.
The task registered findings with poe_level 3, zero bound traffic, and closed
no goal; a run with the switch on bound traffic and closed 4 of 6 goals.
Fix: attach binding-off notes to the same tools the capture-off notes ride on
(report_finding, add_hint / add_task_hint, prove_goal) in the disabled branch,
so the standing guidance stays empty — the contract the PG test asserts — while
the agent is told the tool and the parameters are absent, that findings stay
unverified, and that an operator can enable binding or bind manually.
Test: agent/finding_workflow_test.go asserts the notes exist on the tools and
name the absent tool; red on the planted break, green with the fix. Verified
against the PostgreSQL-dependent server test that CI runs
(TestFindingWorkflowAutoHintToPlannerAndSetting) and go test ./agent/ ./server/.
report_finding rejected whole findings over the optional evidence_hint_id
field in two ways seen in a live DVWA run:
- the key was present but 0, an error, although the field is optional and
models emit 0 for "absent" (21 rejections in one task);
- a fact node id was passed instead of a hint id, an error even when the
caller supplied complete traffic_refs.
Both sink an otherwise provable finding. Now 0 means no hint, and a hint id
that does not resolve to a local hint node degrades to the explicit
traffic_refs. Only a call with no usable hint and no usable refs fails.
Verified end to end: after the fix a worker registered the DVWA UNION SQLi
finding, bound the captured proof exchange itself and quoted the response
body verbatim; the server accepted verification_status=verified (POE L3).
Tests fail on the unfixed tree with the exact production errors.
ActivityContainingEvidence queried one line at a time and returned on the
first match, so an older activity matching line 0 beat a newer one matching
line 1. A single query over unnest() orders by id and keeps the global newest,
and a regression test covers the reversed-order case.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
record_fact trusted a model-written source, so target text labelled
tool_output could prove a goal. The server now matches the fact's evidence
against the intent's recorded activity and pins the activity id. If the same
bytes were captured coming back from the target through the proxy, the fact is
stored as target_response with the traffic id, whatever the model declared,
and prove_goal refuses it (#124 row 1). An untied claim downgrades to
inference/inferred and is refused instead of silently trusted.
The planner overview now carries finding status, and prove_goal refuses
false_positive, duplicate, and ignored findings. A lesson with no company
is visible only to tasks that also have no company. Retraction withdraws
evidence, runs on disposition change, and still runs after a task gains
a second company.
gofmt keeps a one-line function literal only while its body stays short; the asset cleanup in TestAdversarialBenchTrafficRefMissingFromCaptureRefusedPG exceeded that, so gofmt -l flagged the committed file. No behavior change.
AddAgentScope only took isScopeExpansion's answer when it returned no
error; on an error (for example the declared-scope read failing) Expanded
stayed false and the row was recorded as if it were inside the declared
scope, a silent widening.
Choice: mark expanded=true (fail closed) rather than return the error.
By design an agent may widen the task scope without approval as long as
the row is flagged expanded with its source and reason; the flag is the
control, so its fail-closed value is true. The callers do not treat a
classification failure specially: the add_task_scope tool only reports
per-entry errors from AddAgentScope, and returning one here would turn a
failed read of an audit classification into a refusal of a write the
design permits, with the outcome depending on whether the read or the
insert hit the fault. Manual (UI) additions are unchanged; they are not
classified.
Test: adversarial bench case TestAdversarialBenchScopeExpansionErrorMarkedPG
breaks the declared-scope read in a dedicated database (companies renamed,
so ListTaskScope fails while the task_scope insert succeeds); on 5ba19cd the
row is stored with expanded=false, here with expanded=true. The database is
dropped by the test.
prove_goal's finding proof was meant to confirm that each bound traffic_ref
still exists in the live capture, but SetTrafficProofChecker was only called
from tests: Planner.Plan built its ToolSet without it, exchangeExists was
nil, and VerifyFindingProofForNode skipped the check silently.
Decision: wire it (option a). The capture store is reachable when Plan()
runs: server/task_llm.go (agentsForTask) already gives the planner
SetFindingRecorder(s.evidenceStore()), and that evidence store is built on
s.m.traffic, the live capture. So:
- traffic.Traffic.ExchangeExists looks the id up in the capture index
(nil store or lookup failure is an error).
- evidence.Store.TrafficExists delegates to it.
- agent.TrafficCaptureChecker is the interface; Plan() wires the recorder's
TrafficExists into the ToolSet when the recorder implements it, so the
production planner gets the check with no extra server wiring.
- VerifyFindingProofForNode treats a nil checker as unavailable and returns
an error, so prove_goal answers "refused (fail-closed)" instead of
accepting the proof; a lookup error does the same.
The capture store is global, not partitioned per task: the check proves the
exchange is in this server's capture, and the host match against the
finding's assets ties it to the target.
Tests: adversarial bench case TestAdversarialBenchTrafficRefMissingFromCaptureRefusedPG
builds the planner like agentsForTask (NewPlanner + SetFindingRecorder(evidence
store)), with nothing injected into the ToolSet, and checks that a traffic_ref
absent from the capture is refused, that a capture-less evidence store and a
planner without a recorder refuse (fail-closed), and that a captured matching
ref still closes the goal. The three refusal subtests fail on 5ba19cd. Existing
ToolSet-level tests now set an explicit checker, and the existing bench round 2
binds an exchange that is in the capture and runs with the production recorder.
VerifyFindingProofForNode matched bound traffic against the finding's
assets, but when the finding had no asset_ids (or its assets resolved to
no host) hostMatchesFinding returned snapHost != "", so any bound
traffic, e.g. https://unrelated.example.test/, proved the finding and
prove_goal closed the goal.
Fail closed: such a finding returns Proven=false with an explicit reason
("finding has no linked asset ..." / "finding's linked assets have no
host ..."). The finding stays recorded and visible; non-HTTP goals still
close through an observed tool_output fact.
Tests: adversarial bench case TestAdversarialBenchFindingWithoutAssetNotProvenPG
(fails on 5ba19cd with Proven=true, passes here). The two existing tests that
relied on an asset-less proven finding now link a matching HTTP service asset.
The releases v0.4.0 to v0.6.0 seed a record_fact description without the source bullet and their own facts property description. Neither was in the list of known defaults, so the one-time refresh kept both texts on a database seeded by a release and logged the description as an operator edit.
Both released texts are now known defaults, taken byte for byte from agent/tools.go at those tags, and the log line says the description does not match a known default.
record_fact opts out of the harness schema check (norma Spec.RawInput) and
validates its own input. The harness finds the opt-out with a type
assertion on the tool it is handed, and that tool is a wrapper: catalog
tools are metered (meteredTool), and guardPanic wraps every tool last
(guardedTool). Both embed CoreTool, which hides AcceptsRawInput, so the
opt-out was lost and a malformed call was answered by the SDK ("invalid
tool input: facts: expected array") instead of by the handler.
guardedTool and meteredTool now forward AcceptsRawInput, as overriddenTool
already does.
Test: TestFix410AcceptsRawInputSurvivesWrappers covers each wrapper and
record_fact through wireTools, AugmentTools and harness.Query.
The schema the model sees for record_fact declared every fact field twice:
at the top level (single-fact shape) and inside facts[] (batch shape), with
the handler deciding which shape a call is. A model that fills every
declared property sends the single fact inside facts[] and a copy, or a
placeholder such as "", [] or "x", of each field beside it; since PR #282
every such call is refused by name, and the refusal text ("summary is not
allowed at the top level") leads the model to send a dummy value next, so
the same refusal repeats until the intent ends. Observed with a model over
the OpenAI Responses API: 209 of 212 record_fact calls of two tasks were
refused, 156 of them identical in one intent.
The published schema is now {facts:[{...}]} and nothing else (required:
facts, additionalProperties false). The handler keeps the strict contract
of PR #282: unknown or mis-cased fields, invalid or foreign asset ids,
missing summaries, empty batches and any top-level field beside facts
(other than the legacy intent_id) are refused before anything is written,
with an error that names the fields and the one accepted shape. It still
accepts the legacy single fact and the legacy batch with a top-level
intent_id. An item without intent_id is linked to the intent the worker is
running (SetOwnerNode), as report_finding already does.
record_fact opts out of the harness schema check (norma Spec.RawInput) so
the stricter published schema does not reject the legacy shapes before the
handler sees them; the catalog decorator forwards the opt-out.
RepairRecordFactSchema republishes stored and cached schemas as facts-only
and keeps the annotations of facts and its items. A one-time startup
refresh replaces the stored description and the texts that referred to the
top level when they equal the previous defaults; operator edits stay and
are logged. seedFactSourceSchema adds the source enum on the items.
Tests: the handler contract (TestRecordFactSummaryContract,
TestRecordFactStrictFields, TestRecordFactBatchTopLevelConflicts,
TestRecordFactRefusesTopLevelCopiesBesideFacts), the published schema and
its repair (TestRecordFactSchemaIsFactsOnly, TestRecordFactStoredContractRepair,
TestRecordFactInputSchemaUpgrade, TestRecordFactSourceSchemaUpgrade,
TestWireTools), the running-intent default, the one-time refresh
(TestRefreshRecordFactContract) and a synthetic replay of the call shapes
(TestRecordFactShapesReplay).
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
Norma keeps background-task output in os.TempDir()/norma. A test that starts
a Norma session without a private TMPDIR wrote into the host's /tmp/norma.
TestMain of the agent and server packages now creates a directory with
os.MkdirTemp("", "artex-test-tmp-"), sets TMPDIR to it before m.Run and
removes it afterwards on every exit path. The directory is world-writable
and sticky like /tmp: MkdirTemp creates it 0700, which the executor of the
root tests could not traverse. In the server package the setup comes after
RunExecShimIfRequested, which stays the first call; the database suffix,
the test key and the advisory lock run in the same order as before. A test
that sets TMPDIR itself keeps its own.
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.
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.
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.
- 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).
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.
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.
- 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.
Chat joined sessionID into <workDir>/sessions with no allow-list, so
".." or a separator would escape that directory. Production callers
use conv-<id>, but the exported method accepted any string.
Accept only [A-Za-z0-9_-] up to 64 bytes, then confirm the cleaned
path still sits under sessions/.
insert_assets swallowed ListAssetInterceptRules and
TaskInterceptRulesSplit errors and evaluated an empty rule set, which
allowed every asset. A load failure now refuses the whole call. The
tool result is generic; the driver error stays in the process log.
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>
The wake lines interpolated a planner-written intent summary into the trusted sentence, and the overview kept every summary in the plain JSON, so an inherited summary crossed tasks as if this planner had written it (#124, F3). Frame the summary on the wake lines and move the open/running/recent-done summaries into one framed block; the structured intent fields stay plain.
A task already inside the wrap-up reserve only has that reserve left. The worker estimate starts from the defaults because usage rows have no run boundary.