Skip to content

Latest commit

 

History

History
598 lines (504 loc) · 46.9 KB

README.LOGS.md

File metadata and controls

598 lines (504 loc) · 46.9 KB

Logs

Every project keeps its own logs in one host folder, ./logs beside the checkout: the output of each scan container (full recon, partial recon, GVM, GitHub hunt, TruffleHog, supply chain, AI attack surface), each agent chat, each Triage run and each CodeFix session. The recon orchestrator saves the scans and serves every file; the agent writes its own part; the webapp decides who may read or delete what and shows it in the Logs tab of /graph.

This page is the developer's reference: the layout, the writers, the levels, redaction, retention, the file service, authorization and troubleshooting. The tab as a person sees it is the wiki page Logs. The rules a change in this area must keep are the logs-management skill (SKILL.md).

Contents

  1. The folder
  2. Who writes what
  3. Levels per group
  4. Redaction
  5. Retention, compression and the quota
  6. The file service (orchestrator)
  7. Webapp routes and authorization
  8. Settings
  9. Configuration
  10. Upgrading from 7.x
  11. Trust model
  12. Troubleshooting
  13. Code and tests

1. The folder

./logs is mounted at /redamon-logs in the recon orchestrator and in the agent, read-write in both. The webapp never mounts it. It is gitignored and dockerignored.

logs/
  projects/<projectId>/
    recon/          <ts>_<runId>.log  (.log.gz once compressed)  <stem>.meta.json  <stem>.detail/
    partial_recon/  <ts>_<tool>_<runId>.{log,meta.json,detail/}
    gvm/            <ts>_<logId>.{log,meta.json,detail/}
    github_hunt/    <ts>_<logId>.{log,meta.json,detail/}
    trufflehog/     <ts>_<source>_<logId>.{log,meta.json,detail/}
    supply_chain/   <ts>_<logId>.{log,meta.json,detail/}
    ai_attack/      <ts>_<tool>_<runId>.{log,meta.json,detail/}   (the meta lists garak's reports)
    agent/<key>/    session.log  session.log.1 … session.log.N  events.jsonl  meta.json
    triage/         <ts>_<key>.log  (rotated <stem>.log.1 …)  <stem>.meta.json
    codefix/        <ts>_<key>.log  (rotated <stem>.log.1 …)  <stem>.meta.json
  system/agent/     agent.log* and agent.events.jsonl* (records of no run)
  unassigned/agent/<name>/   chat folders whose conversation is gone

The ten groups are fixed: recon, partial_recon, gvm, github_hunt, trufflehog, supply_chain, ai_attack (the seven scan groups), agent, triage, codefix.

Names.

  • <ts> is UTC, %Y%m%dT%H%M%SZ, so names sort by time.
  • runId is the run's own id (full recon's recon_run_id, partial recon's and AI attack's run id). GVM, GitHub hunt, TruffleHog and supply chain have none, so the spawn makes a logId, a uuid4 hex. TruffleHog's own run id is its source, repeated across runs, so it is part of the name but never names the run alone.
  • Every filename part is filtered to [A-Za-z0-9_-] first; a project id must match ^[A-Za-z0-9_-]{1,64}$ and the orchestrator's own project-id rule, a stem ^[A-Za-z0-9_-]{1,160}$.
  • A public log id is <group>/<stem>: recon/20261126T190112Z_<runId>, agent/<key>.

Route keys. A chat session id, a Triage logId and a CodeFix session id become a folder or stem part through one rule, applied by the agent, the orchestrator and the webapp alike:

def route_key(raw: str) -> str:
    if re.fullmatch(r"[A-Za-z0-9_-]{1,120}", raw) and not raw.startswith("h--"):
        return raw
    return "h--" + hashlib.sha256(raw.encode("utf-8")).hexdigest()[:40]

It is injective: two distinct ids never share a key. (A lossy filter used to turn session.abc and session_abc into one folder, so one person could write into, or delete, another person's chat log.) A key is never reversed: whoever holds the raw id (the database) computes the key.

Exact names. route_key keeps mixed-case ids, and on a case-insensitive disk (Docker Desktop on macOS) SESSION_X and session_x are one folder. So every open, create or delete of a name derived from a route key first checks that the exact name is in its folder's listing. When only a case variant is there, the entry counts as absent: the orchestrator answers 404 and deletes nothing, and the agent sends that route's records to system/agent/ (one warning per route). On a case-sensitive disk the check never fails for a name that exists.

Ownership. Every writer gives what it creates to the owner of ./logs itself (os.stat(<root>).st_uid / st_gid): folders 0755, files 0644. That owner is the host user on Linux and container root (the host user) under rootless Docker, so the files can be opened and deleted from a file manager without sudo. A refused chown is logged once and never raises.

Meta files are display data only. Anyone with access to the host can edit them, so nothing decides access from them (see section 7). Each is written to a temp file in the same folder and renamed over, and a missing or corrupt one reads as unknown, never as an error for the whole list.

Meta Fields
Scan <stem>.meta.json schema (1), id, project_id, group, kind, run_id, log_id, container, actor_user_id, level, status (running, completed, failed, stopped, interrupted, unavailable), exit_code, oom_killed, started_at, finished_at, bytes, lines, truncated, compressed, redaction, detail (none, raw, redacted, oversize), artifacts (AI attack only), error (when unavailable)
Triage / CodeFix <stem>.meta.json schema, id, project_id, group, kind, log_id or codefix_session_id, triage_run_id (once authorize answers) or remediation_id, level, status (running, then completed or failed), started_at, finished_at, redaction
Agent meta.json schema, id (agent/<key>), project_id, group, session_id (the raw id), started_at, streams, migrated, moved_at when the sweeper moved it, and migrated_at in a meta an earlier build's migration wrote (the sweeper still honours it)

For GVM, GitHub hunt and supply chain the scan meta's run_id is null and log_id set; for TruffleHog run_id is the source and log_id set; for recon, partial recon and AI attack run_id is set and log_id null.


2. Who writes what

2.1 Scans: the LogArchiver

log_archive/archiver.py, started in the orchestrator's lifespan, before the reaper's first tick and the first request.

  • Naming and tracking. Each of the seven spawns in container_manager.py names its entry first (_log_plan → LogArchiver.plan, which also makes the detail folder at Verbose or Debug), then hands the container to _archive → LogArchiver.track. A group switched off in the project's policy is never tracked: no file, no meta, and the scan runs at normal with nothing bound.

  • Labels and log driver. Every scan container carries the run labels (redamon.project_id, redamon.run_id, redamon.run_kind) and an explicit json-file driver (50 MB × 4), so the archiver can always read it and find it again after a restart.

  • The poll. One asyncio task reads every tracked container every 2 s, on its own single-thread executor (never the docker-op or log-stream pools, so capture and status calls cannot starve each other). Reads stream (logs(stream=True, follow=False, timestamps=True, since=<whole seconds>)); docker-py takes since in whole seconds, so each read asks for the last second again and a cursor of (newest stamp, how many lines carried it) drops what was already written.

  • Each line is ANSI-stripped (the live drawer's pattern), redacted, and appended with its Docker timestamp in front (log_archive/writer.py). The file stops at LOGS_MAX_FILE_MB (256) with [log truncated at N MB] and truncated: true. The meta is rewritten when the entry opens, every 30 s and at the end.

  • The end. An entry is finalized when the poll sees its container exit, in finalize_sync (which _discard runs before every container removal, on the caller's thread), or as interrupted when the container vanished (removed outside the orchestrator, docker rm -f): at most one tick is lost. A stop from the UI marks the container as stopping before its signal (_mark_stopping), so the entry reads stopped whatever the exit code (recon exits 143, GVM 130, GitHub hunt may exit 0, the grace's SIGKILL is 137). Otherwise exit 0 is completed and anything else failed. Exit code and OOM flag go in the meta.

  • Every removal goes through _discard. A removed container's log is gone for good, so _discard(container, force=...) finalizes the entry and then removes the container with its anonymous volumes (v=True). The stop path (_end_run_container) uses it too. test_scan_containers_leave_no_volumes.py reads container_manager.py and fails on any other removal.

  • Restarts. At startup adopt() lists the labelled scan containers that are not broker-owned and whose name starts with their kind's prefix (live or exited).

    • An existing entry whose meta still says running (or has no meta) is resumed, whether or not its container is live and whatever the group's switch says now: the cursor is placed from the stamps of the log file's last lines (a line a crash cut short is truncated away first), and an exited container is then finalized by its exit code at the next poll. An entry that already ended is left alone.
    • A new entry, read from the start of the container's Docker log, is made only for a live container whose group is on: a finished container with no entry may be one whose log a person deleted while it waited for removal.
    • A running meta with no container left after that becomes interrupted.

    A graceful stop of the orchestrator (docker compose restart or stop) ends the scans it runs: ContainerManager.cleanup stops each one through its stop path, which marks it as stopping first, so their entries read stopped. Adoption is for an orchestrator that crashed or was killed. On shutdown flush_all() gives whatever is still tracked one last read and leaves it running for the next start.

  • Failures never reach a scan. A missing, read-only or full disk, or a link planted on the way, turns the entry unavailable (with the errno in the meta when it still can), and the archiver warns at most once a minute.

  • One archiver per process. The orchestrator runs one uvicorn worker; with WEB_CONCURRENCY above 1 the archive stays off and says so. Without the /redamon-logs mount it also stays off and every scan runs as before.

  • AI attack artifacts. At the end, the meta lists garak's .report.jsonl / .hitlog.jsonl under scanners/ai_attack_surface_scan/output/<run>/; the file service serves them in the entry's bundle, read in place, never copied.

Not archived per project: the capture proxy and its ingest worker, the OSV and sca-intel refresh sidecars, the agent's GuardDog leg and every person's Kali sandbox. Each serves every project at once. The CodeFix build sandbox's commands reach the CodeFix log (Verbose).

2.2 Scan detail at Verbose and Debug

At Verbose or Debug, and only when the orchestrator knows the host path of its /redamon-logs mount (auto-detected, or LOGS_PATH), plan() makes the entry's empty <stem>.detail/ and the spawn binds it at /app/run-logs (rw) with REDAMON_LOG_LEVEL, REDAMON_DETAIL_DIR, LOGS_DETAIL_MAX_FILE_MB and LOGS_DETAIL_MAX_RUN_MB. Without the host path, or when the folder cannot be made, the scan runs at normal with nothing bound: Docker would otherwise create a missing bind source itself, empty and root-owned. A folder name already there was made by someone else and is never bound. TruffleHog runs as uid 10001 with every capability dropped, so its detail folder is given to that uid (opened to everyone if the disk refuses the chown) and given back to the root's owner by the sweeper.

Writer What it writes
Full and partial recon: recon/helpers/tool_log.py record(...), called by run_tool_container, run_with_heartbeat, the direct subprocess tool runs and the supply-chain analyzer recorder Verbose: one line per tool run in tools.jsonl (seq, tool, argv, rc, timed_out, duration_s, stdout_bytes, stderr_tail of 4 KB). Debug: also <seq>_<tool>.out with the full stdout and stderr, and a copy of each output file the tool wrote
Supply chain: the scanner's own recorder in scanners/supply_chain_scan/main.py, passed to run_analyzer_job Verbose: each analyzer job's mode, argv, exit code, duration and artifact size. Debug: the job's artifact. Jobs run only with deep analysis, which is off by default
GVM, GitHub hunt, TruffleHog, AI attack: detail_log.py, the same file in each scanner folder (gvm_scan, github_secret_hunt, trufflehog_scan, ai_attack_surface_scan) scanner.log: the scanner's records at DEBUG, and at Debug each tool's extras (section 3)
  • Caps. Each file stops at LOGS_DETAIL_MAX_FILE_MB (32) and the folder at LOGS_DETAIL_MAX_RUN_MB (512), each with a marker line; the scan goes on.
  • Argv masking at write time. A pattern cannot know the name of a header an auth profile injects, so tool_log masks by structure: every -H / --header / -header / --headers value keeps its name and loses its value (-H "X-Api-Key: [REDACTED]"), the argument after a credential flag (-key, --api-key, -token, --token, --registry-token, --service-account, -auth) is [REDACTED], and so is a password in a URL. A few tools' own forms are covered too (arjun's and hakrawler's joined headers, graphql-cop's JSON headers).
  • Never on stdout. A scan's stdout is the live drawer, which streams at plain recon:read (R), while detail is raw data (R*). Every writer above writes only under REDAMON_DETAIL_DIR, and each kind has a test that its stdout is byte-identical at every level. Where a tool's own verbose flag would print more, it is not used: AI attack's Debug copies the bytes this run appended to garak's own log instead of garak's -v, and a secret scanner's raw stdout is recorded at Debug by size only.
  • Raw until redacted. A scan writes detail raw; no scanner carries a copy of the redaction module. The orchestrator redacts the folder once the run has ended (section 5), and the file service serves a detail folder only when its meta says detail: redacted and the archiver no longer tracks it.

2.3 The agent: chats, Triage and CodeFix

agentic/logging_config.py, with two ContextVars in agent_context.py:

  • current_log_route = (project_id, stream, key), stream agent, triage or codefix, set where each run starts (create_config for a chat turn; the start of a Triage run with a new logId; the start of a CodeFix run with its session id). Records with no route (AI Navigator, Tradecraft ingestion jobs, the Neo4j read pool's threads, websocket housekeeping) go to system/agent/agent.log.
  • current_log_policy = LogPolicy(enabled, level, max_bytes, backups), set with the run's own settings: a chat's from load_project_settings (LOG_AGENT_ENABLED, LOG_AGENT_LEVEL, and LOG_MAX_MB / LOG_BACKUP_COUNT for the file size, read every turn), a Triage or CodeFix run's from its own load_cypherfix_settings (logTriage* / logCodefix*, read once per run; their file size stays the default, 10 MB and 5 copies). A handler never reads get_setting, whose answer outside a run's task is whichever project loaded last.

How a record is written:

  • The level. normal keeps INFO and up, verbose DEBUG too, and debug what verbose keeps plus each writer's extras (section 3). The default is Normal, so a chat's file keeps INFO only; before this feature it kept DEBUG.
  • A group switched off writes nothing: no session file, no events.jsonl, no meta, and a record of no route logged during that run is dropped too.
  • The events stream (events.jsonl) follows the chat's switch only and ignores the level: its records are small and machine-read. Triage and CodeFix events stay in system/agent/agent.events.jsonl.
  • Records held until the project's first policy. A record can be logged where no run's policy is (a node re-asserting its route in another task, a late record); it then takes its project's last loaded policy. Before the first load since the agent started there is none, and the defaults could write into a project whose logs are off, so the record is held (at most 500 records or 1 MB in all, past which they are written under the defaults) and written or dropped when a run of that project sets its policy.
  • The console at Debug. A debug run's record is cut to 4 KB on the console, and each route prints at most 64 KB a minute there; the session file has the whole record.
  • Rotation and reopening. Each route's handler takes its size and copies from the run's policy (so agentLogMaxMb / agentLogBackupCount apply per chat), and reopens a file deleted under it instead of writing to the unlinked inode.
  • Stop. /agent-session/stop calls close_route, which closes the route's files and keeps a 10-minute tombstone: a late record of a stopped session goes to system/agent/ instead of making again the folder a conversation delete removes next. A new turn lifts the tombstone.
  • Descriptors only. The agent opens every folder and file by descriptor with O_NOFOLLOW; a link or another non-file on a route's path sends that route's records to system/agent/ (one warning). A Triage or CodeFix entry deleted after it was first written is never made again by the same run.
  • No writable root, no log file. When /redamon-logs is missing or not a writable folder (a compose file without the ./logs mount, a read-only one, SELinux refusing it), the agent writes no log file anywhere: its records reach only the console (docker logs redamon-agent), and at start it logs one ERROR line, The logs root /redamon-logs is missing or not writable, naming the fix (mount ./logs there, make it writable, restart with ./redamon.sh up, which creates the folder). No other folder takes the files in its place.

/app/logs in the agent is ./agentic/mcp-data and holds no logs: the MCP presets keep their data there (the Memory server's mcp_memory.json, the Filesystem server's sandbox/ and its SQLite file). The container path stays /app/logs because every server saved from those presets keeps those paths in its arguments.

LOG_PER_SESSION and LOG_EVENT_STREAM (code defaults in project_settings.py, read once at startup) stay as process-wide kill switches: with LOG_PER_SESSION off every record goes to system/agent/agent.log.


3. Levels per group

Each group has its own switch, level and retention (section 8). A level reaches a scan at spawn and an agent run when it starts, so a change applies to the next run.

Group Normal Verbose adds Debug adds
Full recon What the live drawer shows, with Docker timestamps tools.jsonl: each tool run's argv (header values masked), exit code, duration, output size, stderr tail <seq>_<tool>.out and copies of each tool's output files, capped
Partial recon The same, for one tool and run same same
GVM The scanner container: the gvmd connection, target and task creation, progress, the report fetch scanner.log: the scanner's DEBUG lines (the scanner prints most of its output, so this holds little) python-gvm's DEBUG lines (the GMP exchange), its password masked at write time
GitHub hunt Orgs and repositories enumerated, rate-limit waits, secrets per repository (type only) The scanner's DEBUG lines Each request's URL, status and rate-limit headers; each match's redacted sample
TruffleHog One log per source: progress, verified and unverified counts TruffleHog's own log at --log-level=2, through the scanner's redaction --log-level=5; never its findings file, which holds the secrets
Supply chain The OSV, GuardDog and retire steps per repository, and what was never analysed Each analyzer job's mode, argv, exit code, duration, artifact size Each analyzer job's artifact
AI attack surface The scanner's INFO log; garak's report and hit log listed as artifacts The scanner's DEBUG lines The bytes this run appended to garak's own log
Agent chat session.log at INFO: guardrail verdict, the full system prompt (first iteration), chain context, todo list, Q&A history, each decision, tool calls with a 4,000-character output head, approvals, errors; events.jsonl DEBUG: the classification prompt and node internals The full prompt every iteration and each raw model reply (LOG_LLM_VERBOSE), and a tool's output up to 1,000,000 characters (LOG_TOOL_OUTPUT_MAX_CHARS) on the single-tool path; overridden in that run's settings only
Triage The run's INFO log: groups scored, reviews, cache hits, the publish The run's DEBUG lines Each review's prompt and reply
CodeFix The session's INFO log: the clone, the plan, file edits, sandbox commands and results, the pull request Every tool's full input and output, sandbox output included Each model call's prompt and reply

4. Redaction

One module, two byte-identical copies: agentic/log_redaction.py (the agent's RedactingFilter on every handler) and recon_orchestrator/log_archive/redaction.py (each archived scan line, and each detail file after the run). tests/test_log_redaction_copies.py fails when they differ or when the shared file imports anything outside the standard library.

  • What it removes: token shapes (GitHub, OpenAI sk-, Slack xox*, AWS AKIA…, Bearer and Basic credentials), authorization / api-key / token key-value pairs, user:pass@ in URLs, Cookie / Set-Cookie / Authorization / Proxy-Authorization header values (keeping the header's name), a quoted -H 'Authorization: …' argument, and GMP <password> and <login>.
  • REDACTION_VERSION goes in every meta (redaction). Bump it when the patterns change.
  • Detail files are redacted line by line (a temp file, then a rename, walked by descriptor); a JSON-lines file value by value, a .json file up to 4 MB as one document. A link, FIFO or other non-regular file in the folder is deleted, never followed.
  • The limits. A pattern knows only known shapes. Debug detail is raw tool output and model prompts: a secret a tool found in a target's response is redacted only when it has a known shape. The settings form says so beside Debug ("raw tool output and model prompts; redaction catches known secret shapes only"). That is why raising a level needs Manage on a shared project and reading needs Raw data & files.

5. Retention, compression and the quota

log_archive/retention.py: one loop, every hour (the first sweep 5 minutes after the orchestrator starts), each sweep on the sweeper's own single-thread executor. Gzipping a 256 MB log on the archiver's executor would stall the capture of every running scan.

  1. Detail redaction. Every finished entry whose meta says detail: raw is redacted, then marked redacted. This step also runs every 60 s between sweeps while anything waits for it. It never touches the folder of a run Docker still lists as live (its labels), and in a round where Docker cannot be asked it redacts nothing. A folder over LOGS_DETAIL_MAX_RUN_MB plus 8 MB, or with more than 50,000 entries, is marked oversize and left as it is, never served; one nested deeper than 16 folders is deleted. A stray detail folder (no log, no meta, untracked, older than an hour: its spawn failed) is deleted.
  2. Policies. GET /api/internal/logs/policies for every project folder. When the webapp does not answer, the rest of the sweep is skipped: the sweeper never deletes on missing information.
  3. Retention, then compression, per project and group, under the project's lock:
    • an entry older than its group's retention days (when above 0) is deleted, with its detail;
    • a finished scan log over 1 MB, 10 minutes after it finished, is gzipped to .log.gz (compressed: true). Only the seven scan groups are ever compressed; agent, Triage and CodeFix files are left as written, since the agent may still hold them open.
    • The clocks: a scan entry ages from its meta's finished_at (its files' newest mtime without one); an agent folder and a Triage or CodeFix entry from their files' newest mtime, but never earlier than a migrated_at in their meta (which only an earlier build's migration wrote).
    • An entry the archiver tracks is never compressed or deleted, whatever its meta says.
  4. Gone projects. A project folder whose project no longer exists (the webapp's POST /api/internal/logs/lookup), untouched for 24 hours and with nothing of it tracked, is removed: a teardown whose log step failed, or a late agent record after one.
  5. Orphan chats. An agent folder older than 7 days whose session has no conversation left moves to unassigned/agent/ (with moved_at). unassigned/ is emptied 30 days after the move. When the lookup does not answer, steps 4 and 5 wait for the next sweep.
  6. Quota. Over LOGS_QUOTA_GB (20; 0 turns it off), finished entries are deleted until usage is under 90% of it, each step taking the oldest entry of the project using the most space, so one project's Debug runs never evict another project's logs. unassigned/ counts as one more project; system/ is never evicted; an agent, Triage or CodeFix entry counts as finished after 10 minutes without a write. One warning line per batch.

The quota is soft and checked hourly; between sweeps the per-file and per-run caps bound growth, and scan admission refuses a start when free disk drops under JOB_QUEUE_MIN_FREE_DISK. A retention of 0 keeps a group's logs until the quota needs the room.


6. The file service (orchestrator)

Only log_archive/service.py turns a log id into a file. A caller names an entry by project, group and stem, each checked against its pattern; the path is then opened one component at a time from the root without following a link (layout.open_dir_nofollow), each leaf with O_NOFOLLOW relative to its folder's descriptor, and every name derived from a stem or route key checked exactly. Every walk, read, decompression, zip and delete runs in the threadpool, never on the event loop. Every route sits behind the X-Orchestrator-Key middleware; only the webapp holds that key.

Method and path Answer
GET /logs/projects/{pid} {project_id, available, usage_bytes, entries: [{id, group, stem, bytes, in_use, compressed, detail, meta}]}; available says whether the archive runs
GET /logs/projects/{pid}/{group}/{stem}/content text/plain: tail=N (N ≤ 5,000) the last lines, else the byte range offset / limit (≤ 2 MB, tail too) of the decompressed text, with X-Log-Next-Offset; a running entry up to its last complete line; an agent entry serves session.log
GET /logs/projects/{pid}/{group}/{stem}/download?bundle=0|1 Attachment: 0 the stored .log / .log.gz (agent: session.log); 1 a zip of the entry's files, its redacted detail (or a .detail.txt note saying why it is left out) and its AI attack artifacts
POST /logs/projects/{pid}/zip {ids} (≤ 500) One streamed zip, each member cut at the size its file had when the member started; an id that does not exist fails the whole request before any byte
DELETE /logs/projects/{pid}/entries {ids} (≤ 500) {deleted, refused: [{id, reason}]}, reasons log_in_use (a tracked scan), not_found, invalid_id, io_error; 200 for any valid body
DELETE /logs/projects/{pid}/agent/{session} {success, removed}. {session} is the raw Conversation.sessionId, mapped by route_key, never used as a path; an empty one is 400
DELETE /logs/projects/{pid} Untracks the project's containers, removes projects/<pid>/; {success, removed, bytes}
GET /logs/usage {total_bytes, quota_bytes, projects: {pid: bytes}}
DELETE /project/{id}/files (existing) Also takes {"ai_attack_run_ids": [...]} and deletes each valid uuid's AI attack output folder

Errors: 400 invalid_id (a pattern failed) or invalid_request (a bad body or query), 404 not_found, 503 logs_unavailable (no root, or the disk refused a delete). Deleting an entry or a chat folder takes the entry's lock, which the poll, the finalize and the sweeper take too, so none of them is half way through an entry another removes. The whole-project delete takes no entry lock: it marks the project as being deleted (a gzip in it lets go at its next chunk), takes the project's lock (which the sweeper's per-project steps hold too), untracks the project's containers, then removes the tree, with one more pass when a late writer added a file meanwhile.


7. Webapp routes and authorization

Two permissions (101 in all), in permissions.ts:

Permission Level Built-in sets
logs:read Raw data & files (R*) Default member, Red-team operator, Recon operator, Read-only analyst, Automation (it reads, as for workspace:read)
logs:delete Manage (M) Default member, Red-team operator, Recon operator; never Automation (the LOG_DELETE group of builtinSets.ts) nor Read-only analyst

A custom set gains neither until someone adds it. Neither has an MCP scope, and no MCP or AI Navigator tool reads logs.

Route Guard Does
GET /api/projects/[id]/logs logs:read The orchestrator's list, agent entries filtered (below), joined for display
GET /api/projects/[id]/logs/[group]/[stem] logs:read The text (?tail=, ?offset=&limit=), text/plain with nosniff
GET /api/projects/[id]/logs/[group]/[stem]/download logs:read The file or the bundle (?bundle=1), an attachment with nosniff
POST /api/projects/[id]/logs/zip logs:read, same origin One zip; any id the caller cannot list answers 404 for the whole request. A POST only to carry the ids (READ_LEVEL_WRITES in levelLessHelpers.test.ts)
DELETE /api/projects/[id]/logs logs:delete, same origin Only ids the caller can list; a chat whose agent runs is refused log_in_use (409 when every id is). The audit row project.logs.delete (before: {ids, groups, bytes}) is written first, in auditedTransaction; a row that failed means nothing is deleted
POST /api/internal/logs/lookup Internal key (the scanner key is refused) {sessions: {sid: pid}, projects: {pid: exists}} for the sweeper (gone projects, orphan chats)
GET /api/internal/logs/policies Internal key The 30 logging columns per project, exists: false for one that is gone

The streaming routes wait at most 30 s for the orchestrator's headers, then stream as long as the browser keeps the request (maxDuration 900 s); a browser that leaves closes the orchestrator's generator. Client code is lib/logs/.

The database decides; the meta is display only. Every scan, Triage and CodeFix entry of the project is readable by anyone the route's logs:read let in. An agent entry is a chat's log, and one predicate decides it in the list, the read, the download, the zip and the delete: a conversation of readableConversationsWhere(access, projectId, viewer) whose routeKey(sessionId) is the entry's stem (readableAgentSessions in joins.ts). The folder's meta names a session id too; it is never read for a decision. requireConversationRead is not used: its author branch asks agent:chat (W+A), so an author below it would see an entry listed and then be refused opening it. An agent entry the predicate refuses is the same 404 as one that does not exist.

So who reads whose chat logs is who reads whose conversations:

  • with write sharing not in force, each person reads only their own chats' logs;
  • with it in force, others' chats need Raw data & files and one of: the author shared the chat; the owner's Co-owners can read every session of this project is on and the reader holds Manage (the owner and co-owners); Root's break-glass (every chat, read-only, never a delete);
  • an overseer never reads a log (oversight has no R*), and a read share without Raw data sees no tab and gets 403 from every route.

The display joins. A Triage entry shows its TriageRun (by the meta's triage_run_id, within this project: its status and times), a CodeFix entry its Remediation's title. "By" is a scan entry's meta actor_user_id, a Triage entry's TriageRun.actorUserId, and a chat's author; a CodeFix entry has none. For a scan or a Triage run a name is shown only when that person is the project's owner or a collaborator on it now, so a meta edited on the host cannot reveal another account's name.

Elsewhere.

  • The tab shows only with useCan('logs:read') and R* on the open project (cosmetic: the routes decide). /graph?view=logs&log=<group>/<stem> opens a saved log.
  • Deleting a conversation deletes its chat log folder (best effort, a log_cleanup warning when it fails); project teardown removes the project's logs (delete_logs, after delete_files, which now also gets the project's AI attack run ids); deleting an account tears its projects down the same way.
  • Ownership transfer moves nothing (files are keyed by project id; access follows the database); project export leaves logs out and import brings none.

8. Settings

Thirty Project columns, three per group (log{G}Enabled default true, log{G}Level default normal of normal | verbose | debug, log{G}RetentionDays default 30, 0-3650, 0 keeping them forever), plus the agent's agentLogMaxMb and agentLogBackupCount, all in the project form's Logging tab, which the Logs tab's Settings button also opens.

Service Reads
Orchestrator log_archive/policy.py fetches the policies route on each spawn and each sweep, cached 60 s. A failed fetch gives the defaults (on, Normal: never Debug) to a spawn, with one warning a minute and a minute's pause before it asks again; the sweeper skips a sweep it cannot read.
Agent chat LOG_AGENT_ENABLED / LOG_AGENT_LEVEL in AGENT_SETTING_COLUMNS, every turn
Triage / CodeFix Their own load_cypherfix_settings, once per run, with the Prisma defaults as fallback

The registry (registry.yaml, tool logging, group: logging) closes all 30 to MCP (mcp: never, deny_reason: not-tuning): they are neither read nor written over MCP. They never travel with a preset, and a RoE document never sets them. They are share: gate, judged by direction on a shared project (settingsRisk.ts): turning a group off, raising its level, or shortening its retention (shorten: a smaller number, or any number where it was 0) needs Manage; the opposite of each needs Write; the owner passes everything. See README.SETTINGS_REGISTRY.md.


9. Configuration

Each variable is optional, set in .env, and reaches the orchestrator through its compose environment: block (it has no env_file); an empty or invalid value keeps the default, and so does 0 for the three caps.

Variable Default Meaning
LOGS_QUOTA_GB 20 Instance quota for ./logs; 0 turns it off
LOGS_MAX_FILE_MB 256 Cap on one saved scan log
LOGS_DETAIL_MAX_FILE_MB 32 Cap on one detail file; handed to each Verbose/Debug scan
LOGS_DETAIL_MAX_RUN_MB 512 Cap on one run's detail folder; a folder over it plus 8 MB is never served

Mounts in docker-compose.yml: the orchestrator has ./logs:/redamon-logs and ./scanners/ai_attack_surface_scan/output:/app/ai_attack_surface_scan/output (writable, so a project's delete removes its AI attack output); the agent has ./logs:/redamon-logs (REDAMON_LOGS_DIR) beside ./agentic/mcp-data:/app/logs, the MCP presets' data, not logs. LOGS_PATH names the host path of the logs folder when the orchestrator cannot detect it from its own mounts; without it Verbose and Debug scans run at Normal. Compose does not forward it: set it in the recon-orchestrator's environment: block of docker-compose.yml (a value in .env alone never reaches the orchestrator) and recreate the orchestrator.

./redamon.sh install, update, up and up-dev create logs/projects, logs/system, logs/unassigned and agentic/mcp-data as the invoking user before any docker compose up (ensure_logs_dir). ./redamon.sh purge deletes ./logs (with a sudo fallback for root-owned files) and keeps agentic/mcp-data; clean and down keep both.

Docker's own copy of a compose service's output is bounded too (an x-logging anchor: json-file, 10 MB × 3); that is docker compose logs, not this folder.


10. Upgrading from 7.x

Nothing is migrated. 7.x wrote the agent's logs flat in agentic/logs/ (agent.<sid>.log*, agent.<sid>.events.jsonl*, agent.log*); those files stay where they are, unread, and the Logs tab never shows them. The CodeFix and Triage logs of 7.x lived in the agent container's own layer and went with it.

The MCP presets' data in that folder moves once. Before any docker compose up, ./redamon.sh (_ensure_mcp_data_dir, called by ensure_logs_dir) moves agentic/logs/mcp_memory.json and agentic/logs/sandbox/ into agentic/mcp-data/ when that name is not there yet, never over one that is, and says what it moved. Docker made agentic/logs as root when it first mounted it, so when the invoking user's mv is refused the same rename runs as root in a throwaway alpine container (_mcp_data_move_as_root); the files keep their owner, and the move counts only once they are in place. If that fails too, it warns with the sudo mv to run. When agentic/logs still holds anything else, it prints a notice that those are old logs RedAmon no longer reads and the folder can be deleted. It never deletes anything itself.

Scan logs from before the feature cannot be recovered: those containers were removed. A GVM, GitHub hunt, TruffleHog, supply-chain or AI attack scan that ran across the upgrade has no saved log (it carried no run labels); full and partial recon scans are adopted.


11. Trust model

  • The orchestrator runs as root with the Docker socket, and the agent writes under the same root. So the orchestrator never resolves a path under it by name: every read, write, gzip and delete walks by descriptor without following a link, and a link the agent plants is refused (404, unavailable, or deleted by the sweeper), never followed by those operations.
  • Docker binds are the exception. Docker resolves a symlink in a bind source. The detail folder is made fresh by the orchestrator (a name already there is never bound) and its host path handed to Docker at the spawn; between the two, the agent, which mounts ./logs read-write, could replace <stem>.detail with a link, and Docker would bind the link's target into the scan container read-write. This is accepted, not closed: the agent already holds the master keys and every tenant's data, so a compromised agent has easier ways in. The same holds for the agent reading every project's scan logs through its mount.
  • Raw detail sits on the host until the sweeper redacts it. The host user already holds .env and every key; nothing serves it raw.
  • Meta files are display data. Access comes from database rows only, and "by" names only project members.
  • Scan containers never get the orchestrator key; under ./logs they write only their own detail folder.

12. Troubleshooting

Symptom Cause Fix
./logs is owned by root and new files cannot be deleted without sudo The stack was started with plain docker compose up before ./logs existed: Docker creates a missing bind source as root ./redamon.sh up creates it first. The orchestrator also repairs a root-owned ./logs at start, giving it and everything under it to the owner of its /app/recon mount (the checkout); it skips the repair under rootless Docker, where root is you. By hand: sudo chown -R "$(id -u):$(id -g)" logs
The orchestrator or agent logs, once, could not give … to the logs folder's owner / Could not give the agent's log files to the owner of … The disk refused the chown: Docker Desktop's file sharing, rootless Docker Nothing to fix. Docker Desktop shows the files as yours anyway; under rootless Docker container root is you
On Fedora / RHEL / CentOS nothing is saved in ./logs, and the Logs tab reports logs_unavailable SELinux in enforcing mode refuses an unlabelled bind mount Add :z to the two ./logs:/redamon-logs:rw mounts in docker-compose.yml (orchestrator and agent), as for every other bind on such a host; the detail folders made inside it take the folder's label
A chat's log is missing from the list and its records are in system/agent/agent.log; the agent warned that the log opens a folder or file listed under another spelling A case-insensitive disk (Docker Desktop on macOS) and two session ids that differ only in case Expected: each person's log stays theirs. The diverted records are in the system log
No chat, Triage or CodeFix log appears under ./logs, and docker logs redamon-agent shows the ERROR The logs root /redamon-logs is missing or not writable The agent was started without the ./logs:/redamon-logs:rw mount, or the container cannot write it (a :ro mount, SELinux: the row above); it then writes no log file anywhere, console only Keep the agent's mount as docker-compose.yml ships it, then ./redamon.sh up, which creates ./logs and recreates the agent
Every logs route answers 503 logs_unavailable, and the orchestrator logged /redamon-logs is not mounted The orchestrator was started from a compose file without the ./logs mount Recreate it from the shipped docker-compose.yml (./redamon.sh up)
The tab lists the saved logs but says The log archive is not available on this server The orchestrator runs more than one worker (WEB_CONCURRENCY above 1), so the archive stays off: nothing new is saved Run one worker; docker compose logs recon-orchestrator | grep '\[logs\]' says why it is off
A scan set to Verbose or Debug has no detail, and its meta says level: normal The orchestrator does not know the logs folder's host path (it warns at most once a minute: the host path of /redamon-logs is unknown) Add LOGS_PATH: <host path of ./logs> to the recon-orchestrator's environment: block in docker-compose.yml (the orchestrator has no env_file, so a value in .env alone never reaches it), then recreate it (docker compose up -d --force-recreate recon-orchestrator)
The bundle holds a .detail.txt note instead of the detail The run is still going, the sweeper has not redacted the folder yet (up to a minute after the run, or the first sweep 5 minutes after an orchestrator start), or the folder is oversize Download again after the next sweep; for oversize, raise LOGS_DETAIL_MAX_RUN_MB (the next hourly sweep redacts it) or delete the entry
An entry reads unavailable The writer could not write (full or read-only disk, a link in the path); the meta's error names the errno Free the disk or fix the folder; the scan itself was not affected
A Triage or CodeFix entry stays running The agent stopped mid-run, so nothing wrote the end Harmless; the sweeper ages it by its files' mtime
Logs vanish sooner than their retention The instance quota (LOGS_QUOTA_GB) deleted the oldest entries of the largest project Raise the quota, lower levels, or shorten other groups' retention
docker compose logs <service> shows something the tab does not Those are the services' own console logs (Docker's copy, 10 MB × 3 per service); the tab shows the per-project logs in ./logs Use docker compose logs for the services, the Logs tab for scans and chats

13. Code and tests

Area Code Tests
Layout, descriptor walk, route key, exact names layout.py recon_orchestrator/tests/test_log_archive_layout.py
Archiver, writer, policy archiver.py, writer.py, policy.py test_log_archiver.py, test_log_archive_writer.py, test_log_policy.py, test_log_archive_spawns.py, test_log_archive_stops.py, test_log_archive_removal.py, test_scan_containers_leave_no_volumes.py
File service, sweeper service.py, retention.py, webapp.py test_log_service.py, test_log_retention.py, test_log_detail_guard.py
Agent routing and levels logging_config.py, agent_context.py agentic/tests/test_logging_routes.py, test_logging_per_session.py, test_log_policy_levels.py, test_triage_codefix_log_routes.py, test_session_stop_closes_log_route.py
Redaction log_redaction.py and its copy tests/test_log_redaction_copies.py, agentic/tests/test_log_redaction_patterns.py
Scan detail tool_log.py, the four detail_log.py recon/tests/test_tool_log.py, test_tool_log_call_sites.py, tests/test_scanner_detail_log.py and each scanner's test_*_detail_log.py
Webapp lib/logs/, the routes under app/api/projects/[id]/logs/ and app/api/internal/logs/, app/graph/components/LogsView/, LoggingSection.tsx Next to the source; the flags-off block in sharingWrite.flags.off.test.ts
Control plane ensure_logs_dir, _ensure_mcp_data_dir, _mcp_data_move_as_root, _purge_logs in redamon.sh tests/logs_layout_test.sh