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
- 分类
- 运维与云
- 许可证
- MIT
- 最近提交
- 2026年11月30日
skills/logs-management/SKILL.md
在 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 underREDAMON_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_pathin main.py). Each kind has a test that stdout is byte-identical at every level (test_tool_log.py, test_scanner_detail_log.py, thetests/test_*_detail_log.pyfiles, 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;_discardfinalizes the entry, then removes withv=True. The stop path once removed recon containers withfunctools.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 readsfailed/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_nofollowone component at a time, the leaf withO_NOFOLLOWrelative to its folder's descriptor (layout.py). Neverrealpaththen open, neveros.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_filein logging_config.py). - A route key is
route_key(raw), never a sanitised id, and the rule lives in four copies:route_keyin logging_config.py and layout.py,routeKeyin ids.ts, and the e2e runner's pinned copy in runner.py. Change all four or none; the same hashes are pinned inids.test.tsandtest_log_service.py. A lossy filter once madesession.abcandsession_abcone 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 diskSESSION_Xopenssession_x: a case-variant conversation id read, deleted and wrote into another person's chat log until713bbf4d. 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 throughreadableAgentSessions(joins.ts:readableConversationsWhereplusrouteKey(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. Nevermeta.session_id, neverrequireConversationRead(its author branch asksagent:chatat 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_VERSIONwith any pattern change: it is written into every meta'sredaction. - 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
redactedand untracked. Scanners carry no copy of the redaction module: what they mask at write time (argv header values and credential flags intool_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 asredacted. Now adoption takes back an existing entry whatever the switch, the sweeper asks Docker for the live runs by label before it redacts (_live_runsin 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 (loggingDirectionin settingsRisk.ts: switchdisable, levelhigher,*RetentionDaysshorten); 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'scurrent_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_settingoutside 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 beforebind_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.pytest_off_writes_nothing_not_even_a_metaand its neighbours). - The webapp's start runs
prisma db push --accept-data-loss(the entrypoint in webapp/Dockerfile). Any webapp rebuild pushes whateverschema.prismaholds 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 isADD 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
相似的 Skill
canary
GAgarrytan/gstack143k近 7 天新增 636 个 star
observability-and-instrumentation
ADaddyosmani/agent-skills122k近 7 天新增 1,627 个 star
paperclip-board
PApaperclipai/paperclip119k近 7 天新增 2,120 个 star
ruview-configure
RUruvnet/RuView106k近 7 天新增 693 个 star