refactor(agents): migrate task logs from CSV to directory-based format

Replace shared CSV files (AGENT_TASK_LOG.csv, WEEKLY_AGENT_TASK_LOG.csv)
with per-entry files in docs/agents/task-logs/{daily,weekly}/. Each log
entry is now a separate file named YYYY-MM-DD_HH-MM-SS_<agent>_<status>.md,
eliminating git merge conflicts and race conditions when multiple agents
run concurrently.

Updated files:
- daily-scheduler.md: rewritten for directory-based log format
- weekly-scheduler.md: rewritten for directory-based log format
- META_PROMPTS.md: updated pre-flight scan and claiming instructions
- AGENTS.md: updated scheduler reference from CSV to directory-based

Migrated all existing CSV entries to individual files in the new
directory structure.

https://claude.ai/code/session_01P62EWUXwupgxPhpnRejUuz
This commit is contained in:
Claude committed 2026-02-13 04:41:05 +00:00
1 parent b5e7403df8
commit 17a736b8da
18 files changed
+338 -110

No files matched your search

+1 -1
View File
@@ -274,7 +274,7 @@ To prevent multiple agents from working on the same task simultaneously, every a
gh pr ready
```
**Scheduler agents:** Daily and weekly scheduler agents must follow this protocol in addition to their CSV-based rotation logic. The draft PR check happens _after_ determining the next task but _before_ executing it. See the scheduler prompts for the specific implementation steps.
**Scheduler agents:** Daily and weekly scheduler agents must follow this protocol in addition to their directory-based rotation logic (`docs/agents/task-logs/daily/` and `docs/agents/task-logs/weekly/`). The draft PR check happens _after_ determining the next task but _before_ executing it. See the scheduler prompts for the specific implementation steps.
### Currently In-Flight Work
-10
View File
@@ -1,10 +0,0 @@
date,agent_name,prompt_file,status,branch,summary
2026-02-12,audit-agent,bitvid-audit-agent.md,completed,unstable,"Ran audit scripts, created initial reports"
2026-02-12,ci-health-agent,bitvid-ci-health-agent.md,completed,ai/ci-health-fix-watch-history-flake,"Fixed flaky test in watch-history.test.mjs using waitFor"
2026-02-12,const-refactor-agent,bitvid-const-refactor-agent.md,completed,ai/constants-refactor/daily-run,"Refactored timeouts in UI controllers and webtorrent.js to use canonical constants"
2026-02-13,decompose-agent,bitvid-decompose-agent.md,started,ai/decompose/daily-run,"Task claimed — execution beginning"
2026-02-13,decompose-agent,bitvid-decompose-agent.md,completed,ai/decompose/daily-run,"Extracted ProfileHashtagController from profileModalController.js, reducing file size by ~600 lines"
2026-02-13,deps-security-agent,bitvid-deps-security-agent.md,started,ai/deps-security/daily-run,"Task claimed — execution beginning"
2026-02-13,deps-security-agent,bitvid-deps-security-agent.md,completed,ai/deps-security/daily-run,"Generated npm audit/outdated artifacts and deps report; upgrade attempts blocked by Node >=22 engine requirement in environment"
2026-02-13,docs-agent,bitvid-docs-agent.md,started,ai/docs/daily-run,"Task claimed — execution beginning"
2026-02-13,docs-agent,bitvid-docs-agent.md,completed,ai/docs/daily-run,"Updated README.md with clearer dev setup instructions"
1 date agent_name prompt_file status branch summary
2 2026-02-12 audit-agent bitvid-audit-agent.md completed unstable Ran audit scripts, created initial reports
3 2026-02-12 ci-health-agent bitvid-ci-health-agent.md completed ai/ci-health-fix-watch-history-flake Fixed flaky test in watch-history.test.mjs using waitFor
4 2026-02-12 const-refactor-agent bitvid-const-refactor-agent.md completed ai/constants-refactor/daily-run Refactored timeouts in UI controllers and webtorrent.js to use canonical constants
5 2026-02-13 decompose-agent bitvid-decompose-agent.md started ai/decompose/daily-run Task claimed — execution beginning
6 2026-02-13 decompose-agent bitvid-decompose-agent.md completed ai/decompose/daily-run Extracted ProfileHashtagController from profileModalController.js, reducing file size by ~600 lines
7 2026-02-13 deps-security-agent bitvid-deps-security-agent.md started ai/deps-security/daily-run Task claimed — execution beginning
8 2026-02-13 deps-security-agent bitvid-deps-security-agent.md completed ai/deps-security/daily-run Generated npm audit/outdated artifacts and deps report; upgrade attempts blocked by Node >=22 engine requirement in environment
9 2026-02-13 docs-agent bitvid-docs-agent.md started ai/docs/daily-run Task claimed — execution beginning
10 2026-02-13 docs-agent bitvid-docs-agent.md completed ai/docs/daily-run Updated README.md with clearer dev setup instructions
-4
View File
@@ -1,4 +0,0 @@
date,agent_name,prompt_file,status,branch,summary
2026-02-12,bug-reproducer-agent,bitvid-bug-reproducer-agent.md,completed,unstable,"Created reproducer for hashtag preferences flakiness (tests/hashtag-preferences.test.mjs)"
2026-02-12,changelog-agent,bitvid-changelog-agent.md,completed,unstable,"Drafted changelog and release notes for week of 2026-02-12"
2026-02-13,dead-code-agent,bitvid-dead-code-agent.md,completed,weekly/dead-code-2026-02-13,"No dead code found"
1 date agent_name prompt_file status branch summary
2 2026-02-12 bug-reproducer-agent bitvid-bug-reproducer-agent.md completed unstable Created reproducer for hashtag preferences flakiness (tests/hashtag-preferences.test.mjs)
3 2026-02-12 changelog-agent bitvid-changelog-agent.md completed unstable Drafted changelog and release notes for week of 2026-02-12
4 2026-02-13 dead-code-agent bitvid-dead-code-agent.md completed weekly/dead-code-2026-02-13 No dead code found
+18 -10
View File
@@ -21,10 +21,12 @@ STEP 0 — PRE-FLIGHT SCAN (do this FIRST, before choosing a task):
Record ALL open daily PRs. Every agent name in those titles is OFF LIMITS.
IMPORTANT: this query intentionally filters to titles containing "[daily]". It will NOT list unrelated open PRs.
(Optional visibility check) If you need total open PR context, run a second command without the filter.
b) Read: docs/agents/AGENT_TASK_LOG.csv
Any agent with status "started" (less than 24h old) is also OFF LIMITS.
b) Run: ls docs/agents/task-logs/daily/ | sort
Look for any "_started.md" files that do NOT have a corresponding
"_completed.md" or "_failed.md" file from the same agent at a later
timestamp. Those agents are OFF LIMITS (unless the started file is >24h old).
c) Write down your exclusion list before proceeding.
If the `curl` command fails, you MUST still check the CSV for "started" entries.
If the `curl` command fails, you MUST still check the task log directory.
STEP 1 — Read `AGENTS.md` and `CLAUDE.md` for project rules.
@@ -32,11 +34,13 @@ STEP 2 — Read `docs/agents/prompts/daily-scheduler.md` and follow its
instructions completely, starting from Step 1 (Determine the Next Task).
You already completed Step 0 above — use the exclusion list you built.
- When selecting the next agent, SKIP any agent on your exclusion list.
- Before executing: create a draft PR claim AND log a "started" row in the CSV.
- Before executing: create a draft PR claim AND create a "started" log file
in docs/agents/task-logs/daily/.
- These two actions MUST happen before any task execution begins.
STEP 3 — Once the task is claimed and executed:
- Update your "started" CSV row with the final status (completed/failed).
- Create a new "completed" or "failed" log file in docs/agents/task-logs/daily/.
- Do NOT modify the "started" file — always create a new file.
- Commit and push your changes.
REMEMBER: The #1 failure mode is agents not checking for in-progress work
@@ -60,10 +64,12 @@ STEP 0 — PRE-FLIGHT SCAN (do this FIRST, before choosing a task):
Record ALL open weekly PRs. Every agent name in those titles is OFF LIMITS.
IMPORTANT: this query intentionally filters to titles containing "[weekly]". It will NOT list unrelated open PRs.
(Optional visibility check) If you need total open PR context, run a second command without the filter.
b) Read: docs/agents/WEEKLY_AGENT_TASK_LOG.csv
Any agent with status "started" (less than 24h old) is also OFF LIMITS.
b) Run: ls docs/agents/task-logs/weekly/ | sort
Look for any "_started.md" files that do NOT have a corresponding
"_completed.md" or "_failed.md" file from the same agent at a later
timestamp. Those agents are OFF LIMITS (unless the started file is >24h old).
c) Write down your exclusion list before proceeding.
If the `curl` command fails, you MUST still check the CSV for "started" entries.
If the `curl` command fails, you MUST still check the task log directory.
STEP 1 — Read `AGENTS.md` and `CLAUDE.md` for project rules.
@@ -71,11 +77,13 @@ STEP 2 — Read `docs/agents/prompts/weekly-scheduler.md` and follow its
instructions completely, starting from Step 1 (Determine the Next Task).
You already completed Step 0 above — use the exclusion list you built.
- When selecting the next agent, SKIP any agent on your exclusion list.
- Before executing: create a draft PR claim AND log a "started" row in the CSV.
- Before executing: create a draft PR claim AND create a "started" log file
in docs/agents/task-logs/weekly/.
- These two actions MUST happen before any task execution begins.
STEP 3 — Once the task is claimed and executed:
- Update your "started" CSV row with the final status (completed/failed).
- Create a new "completed" or "failed" log file in docs/agents/task-logs/weekly/.
- Do NOT modify the "started" file — always create a new file.
- Commit and push your changes.
REMEMBER: The #1 failure mode is agents not checking for in-progress work
+111 -42
View File
@@ -17,6 +17,61 @@ Read both `AGENTS.md` and `CLAUDE.md` before executing any task.
---
## Task Log Format
Task logs use a **directory-based format** where each log entry is a separate file. This prevents git merge conflicts when multiple agents run concurrently.
### Directory
```
docs/agents/task-logs/daily/
```
### File Naming Convention
```
YYYY-MM-DD_HH-MM-SS_<agent-name>_<status>.md
```
Examples:
- `2026-02-13_14-30-00_docs-agent_started.md`
- `2026-02-13_15-45-22_docs-agent_completed.md`
### File Content Template
Each log file contains:
```markdown
# Agent Task Log Entry
- **Date:** YYYY-MM-DD
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** started | completed | failed
- **Branch:** <branch-name>
- **Summary:** <one-line summary>
```
### Reading the Log
To find the most recent entry:
```bash
ls docs/agents/task-logs/daily/ | sort | tail -n 1
```
To find all entries for a specific agent:
```bash
ls docs/agents/task-logs/daily/ | grep "<agent-name>"
```
To check for in-progress (`started`) entries without a matching `completed`/`failed`:
```bash
ls docs/agents/task-logs/daily/ | grep "_started.md"
```
Then verify each `started` file has a corresponding `completed` or `failed` file from the same agent at a later timestamp. If not, that agent is still in progress.
---
## Step 0 — Pre-Flight: Scan ALL In-Flight Work (MANDATORY)
> **DO NOT SKIP THIS STEP. This is the single most important step in the entire scheduler. If you skip this, you will cause duplicate work and waste an entire agent run.**
@@ -34,31 +89,31 @@ Record every open PR. These represent **active claims by other agents**. Any age
### 0b. Check the task log for incomplete runs
```bash
cat docs/agents/AGENT_TASK_LOG.csv
ls docs/agents/task-logs/daily/ | sort
```
Look for any rows with status `started` — these represent agents that began work but haven't finished. Treat them the same as open PRs: those agents are OFF LIMITS unless the `started` entry is **older than 24 hours** (stale/abandoned).
Look for any `_started.md` files that do NOT have a corresponding `_completed.md` or `_failed.md` file from the same agent at a later timestamp. These represent agents that began work but haven't finished. Treat them the same as open PRs: those agents are OFF LIMITS unless the `started` entry is **older than 24 hours** (stale/abandoned — check the date in the filename).
### 0c. Build your exclusion list
Combine the results from 0a and 0b into an explicit exclusion list:
- Agents with open/draft PRs → EXCLUDED
- Agents with `started` status less than 24 hours old → EXCLUDED
- Agents with `started` status less than 24 hours old (no matching `completed`/`failed`) → EXCLUDED
Write this exclusion list down before proceeding. You will reference it in Step 1.
**If the `curl` command fails** (e.g., network error, API limit): You MUST still check the CSV for `started` entries. Log a warning in your summary that PR-based claim checking was unavailable.
**If the `curl` command fails** (e.g., network error, API limit): You MUST still check the task log directory for `started` entries. Log a warning in your summary that PR-based claim checking was unavailable.
---
## Step 1 — Determine the Next Task
1. Read the task log at `docs/agents/AGENT_TASK_LOG.csv`.
2. Find the **most recent entry** (last non-header row).
3. Identify the `agent_name` from that entry.
1. List the task log directory: `ls docs/agents/task-logs/daily/ | sort`
2. Find the **most recent entry** (last file alphabetically — filenames sort chronologically).
3. Identify the `agent-name` from the filename (the third segment, between the second `_` and the status).
4. Look up that agent in the alphabetical roster below and select the **next agent** in the list.
5. If the most recent agent is the **last** in the roster, wrap around to the **first**.
6. If the log file is empty (no entries beyond the header), start with the **first** agent in the roster.
6. If the directory is empty, start with the **first** agent in the roster.
7. **CHECK YOUR EXCLUSION LIST FROM STEP 0.** If the selected agent is on the exclusion list, skip to the next agent in the roster. Repeat until you find an agent that is NOT excluded. If you cycle through the entire roster and ALL agents are excluded, log as `failed` with summary `"All roster tasks currently claimed by other agents"` and stop.
### Agent Roster (alphabetical order)
@@ -115,18 +170,32 @@ curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_pag
```
If you see another PR for this agent that was created *before* yours (by a different agent instance), close your PR with `gh pr close <your-pr-number>` (if `gh` works) and go back to Step 1 to select the next agent.
### 2c. Log "started" in the CSV immediately
### 2c. Log "started" in the task log immediately
> **This is critical.** Append a `started` row to the CSV NOW, before executing the task. This ensures the rotation advances even if you crash during execution.
> **This is critical.** Create a `started` log file NOW, before executing the task. This ensures the rotation advances even if you crash during execution.
Create a new file in `docs/agents/task-logs/daily/` with this naming pattern:
Append this row to `docs/agents/AGENT_TASK_LOG.csv`:
```
<date>,<agent-name>,<prompt-file>,started,<branch>,"Task claimed — execution beginning"
YYYY-MM-DD_HH-MM-SS_<agent-name>_started.md
```
Commit and push this CSV update to your branch. This `started` entry serves as a secondary lock: other scheduler instances that cannot reach `gh` will still see it and skip this agent.
Use the current UTC timestamp. The file content should be:
**If `gh` is unavailable:** You MUST still log the `started` entry and push it. The CSV `started` row is your minimum viable claim.
```markdown
# Agent Task Log Entry
- **Date:** <YYYY-MM-DD>
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** started
- **Branch:** <branch-name>
- **Summary:** Task claimed — execution beginning
```
Commit and push this log file to your branch. This `started` entry serves as a secondary lock: other scheduler instances will see it and skip this agent.
**If `gh` is unavailable:** You MUST still create the `started` log file and push it. The log file is your minimum viable claim.
---
@@ -143,47 +212,45 @@ Commit and push this CSV update to your branch. This `started` entry serves as a
## Step 4 — Update the Task Log (Final Status)
After completing the task (or if the task fails), **update** the CSV entry you wrote in Step 2c. Find the `started` row you appended and add a new row with the final status:
After completing the task (or if the task fails), create a **new** log file with the final status. Do NOT modify the `started` file.
Append a new row to `docs/agents/AGENT_TASK_LOG.csv`:
Create a new file in `docs/agents/task-logs/daily/`:
For completed tasks:
```
<date>,<agent-name>,<prompt-file>,completed,<branch>,"<summary of what was done>"
YYYY-MM-DD_HH-MM-SS_<agent-name>_completed.md
```
Or if the task failed:
For failed tasks:
```
<date>,<agent-name>,<prompt-file>,failed,<branch>,"<summary of why it failed>"
YYYY-MM-DD_HH-MM-SS_<agent-name>_failed.md
```
### CSV Format
Use the current UTC timestamp (which will be later than the `started` file). The file content should be:
```
date,agent_name,prompt_file,status,branch,summary
```
```markdown
# Agent Task Log Entry
| Column | Format | Description |
|--------|--------|-------------|
| `date` | `YYYY-MM-DD` | Date the task was executed |
| `agent_name` | string | Agent name from the roster (e.g., `audit-agent`) |
| `prompt_file` | string | Filename executed (e.g., `bitvid-audit-agent.md`) |
| `status` | `started`, `completed`, or `failed` | Current status of the task |
| `branch` | string | Git branch where work was committed |
| `summary` | quoted string | One-line summary of what was done or why it failed |
- **Date:** <YYYY-MM-DD>
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** completed (or failed)
- **Branch:** <branch-name>
- **Summary:** <one-line summary of what was done or why it failed>
```
### Rules for the Log
- **Always append** — never delete or modify existing rows.
- **One `started` + one final row per run** — each scheduler invocation adds exactly two rows (started, then completed/failed).
- **Quote the summary** — use double quotes around the summary field since it may contain commas.
- **Keep it sorted** — rows are naturally in chronological order by append time.
- **Never modify existing files** — always create new files. This eliminates merge conflicts.
- **One `started` + one final file per run** — each scheduler invocation creates exactly two files (started, then completed/failed).
- **Use UTC timestamps** — ensures consistent chronological sorting across time zones.
- **Files sort chronologically** — the filename format ensures `ls | sort` produces a timeline.
---
## Step 5 — Verify and Submit
1. **Verify the log**: Re-read `docs/agents/AGENT_TASK_LOG.csv` and confirm your entries were appended correctly (proper CSV format, no corruption of previous rows).
1. **Verify the log**: List `docs/agents/task-logs/daily/` and confirm your entries were created correctly (proper filename format, valid content).
2. **Run a final check**: Execute `npm run lint` to confirm no lint regressions were introduced.
3. **Commit your changes** with a descriptive message following this pattern:
```
@@ -196,9 +263,9 @@ date,agent_name,prompt_file,status,branch,summary
## Error Handling
- If the agent prompt file is **empty or missing**, skip it, log the run as `failed` with summary `"Prompt file empty or missing"`, and proceed to the **next agent** in the roster.
- If a task **fails mid-execution** (test failures, build errors), log the run as `failed` with a summary describing the failure. Still commit the log update and any partial artifacts.
- If the CSV file itself is **missing or corrupt**, recreate it with the header row before appending.
- If `gh` or `curl` is **unavailable or errors**, fall back to CSV-only claiming (the `started` row). Log a warning in your summary that PR-based claim checking was degraded.
- If a task **fails mid-execution** (test failures, build errors), log the run as `failed` with a summary describing the failure. Still commit the log file and any partial artifacts.
- If the task log directory is **missing**, create it: `mkdir -p docs/agents/task-logs/daily/`.
- If `gh` or `curl` is **unavailable or errors**, fall back to log-file-only claiming (the `started` file). Log a warning in your summary that PR-based claim checking was degraded.
---
@@ -207,9 +274,11 @@ date,agent_name,prompt_file,status,branch,summary
| Layer | Mechanism | Catches |
|-------|-----------|---------|
| **Step 0** | Scan ALL open `[daily]` PRs | Agents claimed by any platform |
| **Step 0** | Check CSV for `started` rows | Agents in progress (even without PR) |
| **Step 0** | Check task log dir for `started` files | Agents in progress (even without PR) |
| **Step 2a** | Create draft PR as lock | Cross-platform visibility |
| **Step 2b** | Race condition re-check | Simultaneous claims |
| **Step 2c** | Log `started` to CSV immediately | Crash recovery — rotation advances |
| **Step 2c** | Create `started` log file immediately | Crash recovery — rotation advances |
All five layers must be executed. No single layer is sufficient on its own.
**Why directories instead of CSV?** Each agent creates its own uniquely-named file, so concurrent agents never touch the same file. This eliminates the git merge conflicts and race conditions that occurred when multiple agents appended to a shared CSV.
+112 -43
View File
@@ -17,6 +17,61 @@ Read both `AGENTS.md` and `CLAUDE.md` before executing any task.
---
## Task Log Format
Task logs use a **directory-based format** where each log entry is a separate file. This prevents git merge conflicts when multiple agents run concurrently.
### Directory
```
docs/agents/task-logs/weekly/
```
### File Naming Convention
```
YYYY-MM-DD_HH-MM-SS_<agent-name>_<status>.md
```
Examples:
- `2026-02-13_14-30-00_changelog-agent_started.md`
- `2026-02-13_15-45-22_changelog-agent_completed.md`
### File Content Template
Each log file contains:
```markdown
# Agent Task Log Entry
- **Date:** YYYY-MM-DD
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** started | completed | failed
- **Branch:** <branch-name>
- **Summary:** <one-line summary>
```
### Reading the Log
To find the most recent entry:
```bash
ls docs/agents/task-logs/weekly/ | sort | tail -n 1
```
To find all entries for a specific agent:
```bash
ls docs/agents/task-logs/weekly/ | grep "<agent-name>"
```
To check for in-progress (`started`) entries without a matching `completed`/`failed`:
```bash
ls docs/agents/task-logs/weekly/ | grep "_started.md"
```
Then verify each `started` file has a corresponding `completed` or `failed` file from the same agent at a later timestamp. If not, that agent is still in progress.
---
## Step 0 — Pre-Flight: Scan ALL In-Flight Work (MANDATORY)
> **DO NOT SKIP THIS STEP. This is the single most important step in the entire scheduler. If you skip this, you will cause duplicate work and waste an entire agent run.**
@@ -34,31 +89,31 @@ Record every open PR. These represent **active claims by other agents**. Any age
### 0b. Check the task log for incomplete runs
```bash
cat docs/agents/WEEKLY_AGENT_TASK_LOG.csv
ls docs/agents/task-logs/weekly/ | sort
```
Look for any rows with status `started` — these represent agents that began work but haven't finished. Treat them the same as open PRs: those agents are OFF LIMITS unless the `started` entry is **older than 24 hours** (stale/abandoned).
Look for any `_started.md` files that do NOT have a corresponding `_completed.md` or `_failed.md` file from the same agent at a later timestamp. These represent agents that began work but haven't finished. Treat them the same as open PRs: those agents are OFF LIMITS unless the `started` entry is **older than 24 hours** (stale/abandoned — check the date in the filename).
### 0c. Build your exclusion list
Combine the results from 0a and 0b into an explicit exclusion list:
- Agents with open/draft PRs → EXCLUDED
- Agents with `started` status less than 24 hours old → EXCLUDED
- Agents with `started` status less than 24 hours old (no matching `completed`/`failed`) → EXCLUDED
Write this exclusion list down before proceeding. You will reference it in Step 1.
**If the `curl` command fails** (e.g., network error, API limit): You MUST still check the CSV for `started` entries. Log a warning in your summary that PR-based claim checking was unavailable.
**If the `curl` command fails** (e.g., network error, API limit): You MUST still check the task log directory for `started` entries. Log a warning in your summary that PR-based claim checking was unavailable.
---
## Step 1 — Determine the Next Task
1. Read the weekly task log at `docs/agents/WEEKLY_AGENT_TASK_LOG.csv`.
2. Find the **most recent entry** (last non-header row).
3. Identify the `agent_name` from that entry.
1. List the task log directory: `ls docs/agents/task-logs/weekly/ | sort`
2. Find the **most recent entry** (last file alphabetically — filenames sort chronologically).
3. Identify the `agent-name` from the filename (the third segment, between the second `_` and the status).
4. Look up that agent in the alphabetical roster below and select the **next agent** in the list.
5. If the most recent agent is the **last** in the roster, wrap around to the **first**.
6. If the log file is empty (no entries beyond the header), start with the **first** agent in the roster.
6. If the directory is empty, start with the **first** agent in the roster.
7. **CHECK YOUR EXCLUSION LIST FROM STEP 0.** If the selected agent is on the exclusion list, skip to the next agent in the roster. Repeat until you find an agent that is NOT excluded. If you cycle through the entire roster and ALL agents are excluded, log as `failed` with summary `"All roster tasks currently claimed by other agents"` and stop.
### Agent Roster (alphabetical order)
@@ -110,18 +165,32 @@ curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_pag
```
If you see another PR for this agent that was created *before* yours (by a different agent instance), close your PR with `gh pr close <your-pr-number>` (if `gh` works) and go back to Step 1 to select the next agent.
### 2c. Log "started" in the CSV immediately
### 2c. Log "started" in the task log immediately
> **This is critical.** Append a `started` row to the CSV NOW, before executing the task. This ensures the rotation advances even if you crash during execution.
> **This is critical.** Create a `started` log file NOW, before executing the task. This ensures the rotation advances even if you crash during execution.
Create a new file in `docs/agents/task-logs/weekly/` with this naming pattern:
Append this row to `docs/agents/WEEKLY_AGENT_TASK_LOG.csv`:
```
<date>,<agent-name>,<prompt-file>,started,<branch>,"Task claimed — execution beginning"
YYYY-MM-DD_HH-MM-SS_<agent-name>_started.md
```
Commit and push this CSV update to your branch. This `started` entry serves as a secondary lock: other scheduler instances that cannot reach `gh` will still see it and skip this agent.
Use the current UTC timestamp. The file content should be:
**If `gh` is unavailable:** You MUST still log the `started` entry and push it. The CSV `started` row is your minimum viable claim.
```markdown
# Agent Task Log Entry
- **Date:** <YYYY-MM-DD>
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** started
- **Branch:** <branch-name>
- **Summary:** Task claimed — execution beginning
```
Commit and push this log file to your branch. This `started` entry serves as a secondary lock: other scheduler instances will see it and skip this agent.
**If `gh` is unavailable:** You MUST still create the `started` log file and push it. The log file is your minimum viable claim.
---
@@ -138,49 +207,47 @@ Commit and push this CSV update to your branch. This `started` entry serves as a
## Step 4 — Update the Task Log (Final Status)
After completing the task (or if the task fails), **update** the CSV entry you wrote in Step 2c. Find the `started` row you appended and add a new row with the final status:
After completing the task (or if the task fails), create a **new** log file with the final status. Do NOT modify the `started` file.
Append a new row to `docs/agents/WEEKLY_AGENT_TASK_LOG.csv`:
Create a new file in `docs/agents/task-logs/weekly/`:
For completed tasks:
```
<date>,<agent-name>,<prompt-file>,completed,<branch>,"<summary of what was done>"
YYYY-MM-DD_HH-MM-SS_<agent-name>_completed.md
```
Or if the task failed:
For failed tasks:
```
<date>,<agent-name>,<prompt-file>,failed,<branch>,"<summary of why it failed>"
YYYY-MM-DD_HH-MM-SS_<agent-name>_failed.md
```
### CSV Format
Use the current UTC timestamp (which will be later than the `started` file). The file content should be:
```
date,agent_name,prompt_file,status,branch,summary
```
```markdown
# Agent Task Log Entry
| Column | Format | Description |
|--------|--------|-------------|
| `date` | `YYYY-MM-DD` | Date the task was executed |
| `agent_name` | string | Agent name from the roster (e.g., `changelog-agent`) |
| `prompt_file` | string | Filename executed (e.g., `bitvid-changelog-agent.md`) |
| `status` | `started`, `completed`, or `failed` | Current status of the task |
| `branch` | string | Git branch where work was committed |
| `summary` | quoted string | One-line summary of what was done or why it failed |
- **Date:** <YYYY-MM-DD>
- **Agent:** <agent-name>
- **Prompt:** <prompt-file>
- **Status:** completed (or failed)
- **Branch:** <branch-name>
- **Summary:** <one-line summary of what was done or why it failed>
```
### Rules for the Log
- **Always append** — never delete or modify existing rows.
- **One `started` + one final row per run** — each scheduler invocation adds exactly two rows (started, then completed/failed).
- **Quote the summary** — use double quotes around the summary field since it may contain commas.
- **Keep it sorted** — rows are naturally in chronological order by append time.
- **Never modify existing files** — always create new files. This eliminates merge conflicts.
- **One `started` + one final file per run** — each scheduler invocation creates exactly two files (started, then completed/failed).
- **Use UTC timestamps** — ensures consistent chronological sorting across time zones.
- **Files sort chronologically** — the filename format ensures `ls | sort` produces a timeline.
**Important:** Weekly agents use their own log file (`WEEKLY_AGENT_TASK_LOG.csv`), separate from the daily log (`AGENT_TASK_LOG.csv`). This keeps weekly and daily rotations independent and avoids one cadence interfering with the other's position tracking.
**Important:** Weekly agents use their own log directory (`docs/agents/task-logs/weekly/`), separate from the daily log (`docs/agents/task-logs/daily/`). This keeps weekly and daily rotations independent and avoids one cadence interfering with the other's position tracking.
---
## Step 5 — Verify and Submit
1. **Verify the log**: Re-read `docs/agents/WEEKLY_AGENT_TASK_LOG.csv` and confirm your entries were appended correctly (proper CSV format, no corruption of previous rows).
1. **Verify the log**: List `docs/agents/task-logs/weekly/` and confirm your entries were created correctly (proper filename format, valid content).
2. **Run a final check**: Execute `npm run lint` to confirm no lint regressions were introduced.
3. **Commit your changes** with a descriptive message following this pattern:
```
@@ -193,9 +260,9 @@ date,agent_name,prompt_file,status,branch,summary
## Error Handling
- If the agent prompt file is **empty or missing**, skip it, log the run as `failed` with summary `"Prompt file empty or missing"`, and proceed to the **next agent** in the roster.
- If a task **fails mid-execution** (test failures, build errors), log the run as `failed` with a summary describing the failure. Still commit the log update and any partial artifacts.
- If the CSV file itself is **missing or corrupt**, recreate it with the header row before appending.
- If `gh` or `curl` is **unavailable or errors**, fall back to CSV-only claiming (the `started` row). Log a warning in your summary that PR-based claim checking was degraded.
- If a task **fails mid-execution** (test failures, build errors), log the run as `failed` with a summary describing the failure. Still commit the log file and any partial artifacts.
- If the task log directory is **missing**, create it: `mkdir -p docs/agents/task-logs/weekly/`.
- If `gh` or `curl` is **unavailable or errors**, fall back to log-file-only claiming (the `started` file). Log a warning in your summary that PR-based claim checking was degraded.
---
@@ -204,9 +271,11 @@ date,agent_name,prompt_file,status,branch,summary
| Layer | Mechanism | Catches |
|-------|-----------|---------|
| **Step 0** | Scan ALL open `[weekly]` PRs | Agents claimed by any platform |
| **Step 0** | Check CSV for `started` rows | Agents in progress (even without PR) |
| **Step 0** | Check task log dir for `started` files | Agents in progress (even without PR) |
| **Step 2a** | Create draft PR as lock | Cross-platform visibility |
| **Step 2b** | Race condition re-check | Simultaneous claims |
| **Step 2c** | Log `started` to CSV immediately | Crash recovery — rotation advances |
| **Step 2c** | Create `started` log file immediately | Crash recovery — rotation advances |
All five layers must be executed. No single layer is sufficient on its own.
**Why directories instead of CSV?** Each agent creates its own uniquely-named file, so concurrent agents never touch the same file. This eliminates the git merge conflicts and race conditions that occurred when multiple agents appended to a shared CSV.
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-12
- **Agent:** audit-agent
- **Prompt:** bitvid-audit-agent.md
- **Status:** completed
- **Branch:** unstable
- **Summary:** Ran audit scripts, created initial reports
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-12
- **Agent:** ci-health-agent
- **Prompt:** bitvid-ci-health-agent.md
- **Status:** completed
- **Branch:** ai/ci-health-fix-watch-history-flake
- **Summary:** Fixed flaky test in watch-history.test.mjs using waitFor
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-12
- **Agent:** const-refactor-agent
- **Prompt:** bitvid-const-refactor-agent.md
- **Status:** completed
- **Branch:** ai/constants-refactor/daily-run
- **Summary:** Refactored timeouts in UI controllers and webtorrent.js to use canonical constants
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** decompose-agent
- **Prompt:** bitvid-decompose-agent.md
- **Status:** started
- **Branch:** ai/decompose/daily-run
- **Summary:** Task claimed — execution beginning
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** decompose-agent
- **Prompt:** bitvid-decompose-agent.md
- **Status:** completed
- **Branch:** ai/decompose/daily-run
- **Summary:** Extracted ProfileHashtagController from profileModalController.js, reducing file size by ~600 lines
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** deps-security-agent
- **Prompt:** bitvid-deps-security-agent.md
- **Status:** started
- **Branch:** ai/deps-security/daily-run
- **Summary:** Task claimed — execution beginning
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** deps-security-agent
- **Prompt:** bitvid-deps-security-agent.md
- **Status:** completed
- **Branch:** ai/deps-security/daily-run
- **Summary:** Generated npm audit/outdated artifacts and deps report; upgrade attempts blocked by Node >=22 engine requirement in environment
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** docs-agent
- **Prompt:** bitvid-docs-agent.md
- **Status:** started
- **Branch:** ai/docs/daily-run
- **Summary:** Task claimed — execution beginning
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** docs-agent
- **Prompt:** bitvid-docs-agent.md
- **Status:** completed
- **Branch:** ai/docs/daily-run
- **Summary:** Updated README.md with clearer dev setup instructions
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-12
- **Agent:** bug-reproducer-agent
- **Prompt:** bitvid-bug-reproducer-agent.md
- **Status:** completed
- **Branch:** unstable
- **Summary:** Created reproducer for hashtag preferences flakiness (tests/hashtag-preferences.test.mjs)
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-12
- **Agent:** changelog-agent
- **Prompt:** bitvid-changelog-agent.md
- **Status:** completed
- **Branch:** unstable
- **Summary:** Drafted changelog and release notes for week of 2026-02-12
@@ -0,0 +1,8 @@
# Agent Task Log Entry
- **Date:** 2026-02-13
- **Agent:** dead-code-agent
- **Prompt:** bitvid-dead-code-agent.md
- **Status:** completed
- **Branch:** weekly/dead-code-2026-02-13
- **Summary:** No dead code found