Skip to content
FunCoding

logs-management

The per-project logs in ./logs: the orchestrator's scan log archive, file service and sweeper, the agent's per-run log routing and levels, the scans' Verbose/Debug detail, and the Logs tab. Detail is raw data that must never reach a scan's stdout; every path is an id walked by descriptor under a root the agent also writes; the database decides who reads a chat's log, never a meta file; the two redaction copies stay identical. Trigger: editing recon_orchestrator/log_archive/; a container removal or _discard in recon_orchestrator/container_manager.py; the routing, policy or level code of agentic/logging_config.py, agentic/log_redaction.py or the log ContextVars of agentic/agent_context.py; recon/helpers/tool_log.py or a tool_log.record call site; scanners/*/detail_log.py or the supply-chain scanner's detail recorder; webapp/src/lib/logs/, webapp/src/app/api/projects/[id]/logs/, webapp/src/app/api/internal/logs/, webapp/src/app/graph/components/LogsView/ or LoggingSection.tsx; a log{Group}* project setting.

Star
3,553
Category
Ops & cloud
License
MIT
Last commit
Nov 30, 2026

skills/logs-management/SKILL.md

View on GitHub

When to Use

  • Changing what a scan, a chat, a Triage run or a CodeFix session saves, where, at which level.
  • Changing how the orchestrator lists, serves, zips, deletes, compresses or expires an entry.
  • Changing who may read or delete a log, or the Logs tab and the Logging settings.

The design, layout and troubleshooting are README.LOGS.md. Also follow orchestrator-container-spawn (a spawn's bind and labels), rbac-authz (every route check), project-settings-cascade (a logging column), redamon-testing (the tests).


Critical Rules

  • NEVER write Verbose or Debug detail to a scan's stdout or stderr. A scan's stdout is the live drawer, which streams at plain recon:read (R); detail (command lines, raw tool output) is raw data (R*). Detail goes only under REDAMON_DETAIL_DIR, through tool_log.record (recon) or the scanners' detail_log.py (gvm_scan and its three byte-identical copies). Never turn on a tool's own verbose flag that prints: AI attack's Debug first used garak's -v, which printed target replies to stdout, and now copies only the bytes this run appended to garak's own log (garak_log_path in main.py). Each kind has a test that stdout is byte-identical at every level (test_tool_log.py, test_scanner_detail_log.py, the tests/test_*_detail_log.py files, test_detail_log.py for AI attack); a new writer or call site adds its own.
  • NEVER remove a scan container except through _discard (container_manager.py). A removed container's Docker log is gone for good; _discard finalizes the entry, then removes with v=True. The stop path once removed recon containers with functools.partial(container.remove, force=True), which lost their last lines and leaked two anonymous volumes per run. test_scan_containers_leave_no_volumes.py reads the module's syntax tree and fails on any other removal form. A deliberate stop calls _mark_stopping(container) before its signal, or the entry reads failed/completed (GVM exits 130, GitHub hunt 0); test_log_archive_stops.py covers each stop path.
  • Ids, never paths. A caller names an entry by project, group and stem, each checked against its pattern, and only service.py turns that into a file: layout.open_dir_nofollow one component at a time, the leaf with O_NOFOLLOW relative to its folder's descriptor (layout.py). Never realpath then open, never os.path.join(root, ...): the agent writes under the same root and the orchestrator runs as root with the Docker socket. The agent opens its files the same way (_open_folder / _open_file in logging_config.py).
  • A route key is route_key(raw), never a sanitised id, and the rule lives in four copies: route_key in logging_config.py and layout.py, routeKey in ids.ts, and the e2e runner's pinned copy in runner.py. Change all four or none; the same hashes are pinned in ids.test.ts and test_log_service.py. A lossy filter once made session.abc and session_abc one folder, so one person wrote into and deleted another's chat log. Never reverse a key: whoever holds the raw id (the database) computes it.
  • Check the exact name before every open, create or delete of a name derived from a route key or a stem (layout.exact_name / open_dir_exact, the agent's _exact_name_at, the runner's _listed). On a case-insensitive disk SESSION_X opens session_x: a case-variant conversation id read, deleted and wrote into another person's chat log until 713bbf4d. Absent exact name: the orchestrator answers 404 and deletes nothing, the agent sends that route's records to its system log.
  • The database decides who reads a log; a meta file never does. Anyone on the host can edit a .meta.json. An agent entry is readable only through readableAgentSessions (joins.ts: readableConversationsWhere plus routeKey(sessionId) equal to the stem), in the list, the read, the download, the zip and the delete alike; a refused entry is the same 404 as a missing one. Never meta.session_id, never requireConversationRead (its author branch asks agent:chat at W+A, so an author below it would see an entry listed and be refused opening it). "By" names only the project's owner or a current collaborator.
  • The two redaction copies stay byte-identical, standard library only: agentic/log_redaction.py and log_archive/redaction.py (test_log_redaction_copies.py). Edit both, and bump REDACTION_VERSION with any pattern change: it is written into every meta's redaction.
  • A scan never relies on its own redaction; the sweeper never redacts a live run's folder; the file service serves detail only when it is redacted and untracked. Scanners carry no copy of the redaction module: what they mask at write time (argv header values and credential flags in tool_log, the GMP password in GVM's detail) is by structure, and everything else is written raw for the orchestrator to redact after the run. A Debug scan whose group was switched off before an orchestrator restart was skipped by adoption, then redacted while it still wrote raw lines, and served as redacted. Now adoption takes back an existing entry whatever the switch, the sweeper asks Docker for the live runs by label before it redacts (_live_runs in retention.py) and redacts nothing when Docker cannot answer, and a tracked entry's detail is never zipped (test_log_detail_guard.py).
  • The logging settings stay mcp: never, deny_reason: not-tuning, share: gate: neither read nor written over MCP, never in a preset, never set by a RoE document (registry.consistency.test.ts, test_registry_share_key.py). Their risk direction comes from the field's shape (loggingDirection in settingsRisk.ts: switch disable, level higher, *RetentionDays shorten); a logging field of another shape has none and fails the gate test.
  • The agent's log policy never comes from get_setting. A handler reads the run's current_log_policy (record_policy()); outside every run it takes the defaults, and a route bound where no policy is takes its project's last loaded one, or is held until there is one. get_setting outside a run's task answers for whichever project loaded last (test_logging_routes.py ..._even_after_another_project_loaded). Triage and CodeFix load their settings before bind_route, or an off run writes its first lines.
  • A group switched off writes nothing: no file, no meta, no events, and a record of no route logged during that run is dropped; a scan group off is never tracked, binds no detail and runs at normal. An off group once kept writing after a Stop (test_log_policy_levels.py test_off_writes_nothing_not_even_a_meta and its neighbours).
  • The webapp's start runs prisma db push --accept-data-loss (the entrypoint in webapp/Dockerfile). Any webapp rebuild pushes whatever schema.prisma holds in the tree, dropping a column that is not there, another session's half-done edit included. Before a rebuild that carries a schema change (a logging column), diff the live database against the tree read-only (Commands) and build only when it is ADD COLUMN.

Patterns

A recon tool run recorded for the detail folder (it prints nothing and never raises):

from recon.helpers import tool_log

tool_log.record("katana", cmd,
                rc=None if timed_out else process.returncode,
                duration_s=elapsed, stdout=katana_out,
                stderr=stderr_output, timed_out=timed_out)

A logs route that reads one entry, agent entries through the one predicate:

const auth = await requirePermission(request, 'logs:read', { projectId })
if (auth instanceof NextResponse) return auth
const id = logId(group, stem)
if (!id) return invalidLogId()
if (id.group === 'agent' && !(await readableAgentSession(logReader(auth, projectId), id.stem))) return logNotFound()

Commands

# the per-file Docker gate, by section (never host pytest)
./redamon.sh test unit
./agentic/run_tests.sh tests/test_logging_routes.py tests/test_log_policy_levels.py
cd webapp && npx vitest run --no-file-parallelism src/lib/logs src/app/api/projects/\[id\]/logs \
  src/app/graph/components/LogsView src/lib/authz/sharingWrite.flags.off.test.ts

# before a webapp rebuild that changes schema.prisma: what the start's push would do, read-only
docker compose exec -T webapp sh -c 'cat > /tmp/schema.next.prisma' < webapp/prisma/schema.prisma
docker compose exec -T webapp sh -c \
  'npx prisma migrate diff --from-url "$DATABASE_URL" --to-schema-datamodel /tmp/schema.next.prisma --script'

Resources

  • README.LOGS.md - layout, writers, levels, sweeper, routes, trust model, troubleshooting
  • Logs - the tab as users see it
  • Related skills: orchestrator-container-spawn, rbac-authz, project-settings-cascade, redamon-testing

Similar Skills

Featured

internal-comms

Write internal communications following company formats, including status reports, leadership updates, and newsletters.

ANanthropics/skills203k2,822 new stars in the last 7 days

canary

GAgarrytan/gstack143k524 new stars in the last 7 days

observability-and-instrumentation

ADaddyosmani/agent-skills122k1,421 new stars in the last 7 days

Featured

shipping-and-launch

A pre-launch checklist covering monitoring, staged rollouts and rollback plans.

ADaddyosmani/agent-skills122k1,421 new stars in the last 7 days

paperclip-board

PApaperclipai/paperclip119k1,727 new stars in the last 7 days

ruview-configure

RUruvnet/RuView106k596 new stars in the last 7 days