Skip to content

Dashboard Activity page: search the audit log by time, service, agent and path (152) - #153

Merged
jerryfane merged 1 commit into
mainfrom
feat/activity-page
Nov 15, 2026
Merged

jerryfane merged 1 commit into
mainfrom
feat/activity-page

Conversation

@jerryfane

Copy link
Copy Markdown
Contributor

Closes 152. Jarvis 488255: to find which agent cancelled macserve job j_ce4ce15b at 16:39:53Z the owner needs sudo to read the audit log on the Studio.

Change

  • GET /activity (owner session, read-only, new nav item): UTC window by the minute (datetime-local; default the last hour; end minute included), optional exact service, exact agent, path-contains.
  • Lists matching proxied calls (time, agent, service, method+path, status, source, note) and dashboard events, newest first by the record's time (records are written at call end but stamped at start), at most 500 (keeps the newest-written past that, says so).
  • The audit log is never rotated, so it is streamed (64 KiB lines; longer lines skipped) and each line's "time" is compared as text before JSON decoding. Non-JSON lines skipped. Missing log → "There is no audit log yet."
  • No new data exposed beyond the owner's dashboard; html/template escapes everything.
  • README paragraph.

Not in this PR: any agent/coordinator access to the audit (permission change, needs the owner).

Evidence

  • TestActivityFindsTheCallerByMinuteAndPath: an audit file with the target cancel, a same-minute call on another job, a later cancel by another role, a dashboard event, a <script> role, a 70 KiB line, a non-JSON line, and an older hour: the query (16:39–16:39, macserve-builds, path j_ce4ce15b) lists only the target and the escaped row, newest first; without filters the dashboard event shows; a bad time is a 400 with the format hint.
  • Full race suite green.

… and path (152)

Owner-only, read-only. A UTC minute window (default the last hour), with
optional service, agent and path-contains filters; newest first, at most
500 rows. The never-rotated log is streamed and a line's time compared as
text before decoding; overlong or non-JSON lines are skipped; everything is
HTML-escaped.
@jerryfane
jerryfane merged commit defcad1 into main Nov 15, 2026
3 checks passed
@jerryfane
jerryfane deleted the feat/activity-page branch November 15, 2026 17:16
@jerryfane

Copy link
Copy Markdown
Contributor Author

Reviewer: adspower-fleet-review
Runtime: omp
Job: local-review-review-router-18e84742ead6b019-1

Decision: changes_requested
Summary: Reviewed exact head e06c5ab. Reproduced incorrect newest-500 selection. Pure-Go checks and Darwin cross-build passed; sandbox-denied C headers prevented CGO/race checks. Frozen evidence contains no prior PR #153 findings.
Severity: P2

Findings

  • Retain newest timestamps rather than last-written records (P2)
    • body: Requests are timestamped at start but logged at completion (internal/server/server.go:272-275). Dropping kept[0] therefore discards newer requests when older requests finish later. Sorting afterward cannot recover discarded records. Retain the 500 newest timestamps instead of the last 500 matches written.
    • evidence: Executed TestReviewActivityNewestAtLimit with 501 matching records: GET /activity returned 200 with 500 rows, omitted the newest request, included the oldest slow request, and displayed 'Showing the newest 500'. Assertion failed.
    • file: internal/dashboard/activity.go
    • line: 120

Tests Run

  • CGO_ENABLED=0 go vet ./... -> passed
  • CGO_ENABLED=0 go build ./... -> passed
  • GOOS=darwin GOARCH=arm64 go build ./... -> passed
  • CGO_ENABLED=0 go test ./internal/dashboard ./internal/admin ./internal/server -count=1 -> all three packages passed
  • CGO_ENABLED=0 go test -overlay /proc/3637747/fd/10 ./internal/dashboard -run ^TestReviewActivity -count=1 -v -> newest-500 regression failed; filtering, minute boundaries, overlong lines, missing/unreadable log, and authentication scenarios passed. Memory-only overlay; no repository edits.
  • go vet ./... -> failed: runtime/cgo denied access to /usr/include/stdc-predef.h
  • go build ./... -> failed: same denied C header
  • go test -race ./internal/dashboard ./internal/admin ./internal/server -count=1 -> runtime/cgo compilation failed on denied C header; enclosing command timed out after 300 seconds
  • go test -overlay /proc/3637747/fd/10 ./internal/dashboard -run ^TestReviewActivity -count=1 -v -> initial CGO-enabled attempt failed on denied C header

Raw runtime output was retained in local Gitmoot state and is not posted here.

jerryfane added a commit that referenced this pull request Nov 15, 2026
…post-merge review P2)

A record is written when its call ends but stamped with its start, so a
slow older call written last displaced a newer one. Keep a min-heap by time.
jerryfane added a commit that referenced this pull request Nov 15, 2026
…eyring/audit (154) (#155)

* Owner can allow an agent to search the audit log: audit_read, GET /_keyring/audit (154)

Owner decision 2026-11-15: per agent, off by default. The agent's page has
Allow audit search / Stop audit access (password; audited as
agent_audit_read; saved as "audit_read": true on the role). An allowed role
calls GET /_keyring/audit with its token (through a relay:
/<role>/_keyring/audit) and the same filters as the Activity page, and gets
JSON. Others get 403. One search at a time (429); each search is audited.
The search moves from the dashboard to server.SearchAudit, shared by both.

* Audit search keeps the newest 500 by time, not the last written (#153 post-merge review P2)

A record is written when its call ends but stamped with its start, so a
slow older call written last displaced a newer one. Keep a min-heap by time.

* Audit search: fractional RFC 3339 windows match exactly (#155 review F1)

Records are stamped to the second, so round both bounds up to whole seconds:
for whole-second t, t >= x and t < y iff t >= ceil(x) and t < ceil(y). The
response reports the rounded window.

* Audit search: keep the caller's window exact; round only when comparing (#155 review f1/f2)

AuditWindow returns the bounds as given, fractions included, and the JSON
answer echoes them with RFC3339Nano, so a returned window can be replayed.
SearchAudit rounds up to whole seconds only for its text comparison.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant