Skip to content

Isolate DAG orchestration logs from job logs#144

Merged
CoreyRDean merged 1 commit into
mainfrom
fix/dag-log-namespace
May 21, 2026
Merged

Isolate DAG orchestration logs from job logs#144
CoreyRDean merged 1 commit into
mainfrom
fix/dag-log-namespace

Conversation

@CoreyRDean
Copy link
Copy Markdown
Owner

Non-technical summary

This fixes a log-accounting bug where DAG orchestration runs could be mistaken for real job runs when a user had a job whose name ended in -dag. DAG runner logs now live in their own hidden directory, so clauck history, clauck cost, clauck logs --follow, and clauck peek stop guessing from ambiguous filenames and report the right job data.

Why this matters now: issue #121 describes a user-visible correctness problem in spend/history reporting, and the current code was still relying on filename heuristics to paper over the collision.

The system is better afterward because DAG coordination logs are now structurally separated from per-job execution logs instead of being filtered by inference.

Technical summary

  • Added DAG_LOGS_DIR = ~/.clauck/.dag-logs in both lib/clauck and lib/dag-runner.py.
  • Changed DagLogger to write orchestration logs into that dedicated directory with <root>-<ts>-<pid>.log names.
  • Removed the manifest/name-based -dag exclusion logic from cmd_cost and cmd_history; those commands now read only real job logs from JOBS_DIR.
  • Updated DAG log readers in clauck logs --follow, _active_dag_log(), clauck peek, and the doctor diagnostic guidance to use the dedicated DAG log directory.
  • Added regression coverage for the real *-dag job-name case plus dedicated DAG-log-dir behavior in:
    • tests/test_clauck_history_cost.py
    • tests/test_clauck_logs.py
    • tests/test_dag_runner.py

Relevant intent: this preserves inspectability while making the log surface unambiguous, which is a better fit for clauck’s local-runtime contract than trying to infer log type from colliding filenames.

Tests:

  • python3 -m unittest -v tests.test_dag_runner tests.test_clauck_logs tests.test_clauck_history_cost
  • python3 -m unittest discover tests

Breaking changes: none intended. Existing job logs stay where they are. New DAG orchestration logs will be written under ~/.clauck/.dag-logs/ instead of the top-level ~/.clauck/ directory.

Additional notes

Trade-off: this changes the on-disk location for new DAG orchestration logs, but it removes ambiguity across all log-consuming surfaces instead of adding another special-case parser rule.

Deferred follow-up: no migration is included for old DAG logs already written in the root job directory. The fix is intentionally forward-only to keep the increment small and low-risk.

Remaining gap: any historical top-level DAG orchestration logs created before this change remain wherever they were originally written, but new runs stop producing ambiguous filenames.

@CoreyRDean CoreyRDean marked this pull request as ready for review May 21, 2026 13:20
@CoreyRDean CoreyRDean merged commit ca97fae into main May 21, 2026
2 checks passed
@CoreyRDean CoreyRDean deleted the fix/dag-log-namespace branch May 21, 2026 13:20
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0d3f7244b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/clauck
Comment on lines 550 to 553
if not m:
continue
job_name, ts_str = m.group(1), m.group(2)
# Skip DAG orchestration logs only when the -dag suffix is not itself a
# real job name — a job named e.g. "standup-dag" should not be excluded.
if job_name.endswith("-dag") and job_name not in known_jobs:
continue
if name and job_name != name:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve legacy DAG-log exclusion in cost aggregation

This loop now aggregates every top-level *-<ts>-<pid>.log under ~/.clauck, so users who upgrade with pre-change orchestration logs like <root>-dag-...log will have those legacy DAG runs counted as normal jobs (e.g., pipe-dag) in clauck cost. Before this commit those files were explicitly excluded unless -dag was a real job name, so this is a correctness regression for historical spend totals on existing installations.

Useful? React with 👍 / 👎.

Comment thread lib/clauck
pass

# Glob all log files, sorted newest first by mtime
logs = sorted(JOBS_DIR.glob("*-[0-9]*.log"), key=lambda p: p.stat().st_mtime, reverse=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep legacy DAG logs out of history listings

cmd_history now scans all top-level logs in JOBS_DIR without filtering out legacy orchestration files (<root>-dag-<ts>-<pid>.log), so upgraded users can see old DAG coordinator runs reported as regular job invocations. This reintroduces ambiguous/misleading history entries for pre-migration data even though the command previously had explicit exclusion logic for these files.

Useful? React with 👍 / 👎.

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