diff --git a/docs/agents/prompts/META_PROMPTS.md b/docs/agents/prompts/META_PROMPTS.md index ed656341..420fd3d8 100644 --- a/docs/agents/prompts/META_PROMPTS.md +++ b/docs/agents/prompts/META_PROMPTS.md @@ -14,7 +14,7 @@ before choosing a task — is to run these two commands. Not later. NOW. COMMAND 1 — Check for open daily agent PRs: - curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' + curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/daily/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' Normalize each PR to an agent name using this deterministic rule: 1) Preferred: parse `head.ref` as `agents/daily//...` @@ -60,6 +60,12 @@ Now proceed with the scheduler: in docs/agents/task-logs/daily/. Both MUST exist before task execution begins. 4. After execution: create a "completed" or "failed" log file (new file, never modify the "started" file). Commit and push. + +Race check rule (must be applied after pushing your claim branch): +- Re-run the sortable PR metadata command and compare only PRs with matching derived `agent`. +- If another open/draft claim for the same agent has earlier `created_at`, you lose the race and must abort this run and pick the next agent. +- If timestamps are equal or ambiguous, lower PR `number` wins. +- Print one line before proceeding: `RACE CHECK: won` or `RACE CHECK: lost (agent already claimed by PR #)`. ``` ## Weekly Scheduler Meta Prompt @@ -72,7 +78,7 @@ before choosing a task — is to run these two commands. Not later. NOW. COMMAND 1 — Check for open weekly agent PRs: - curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' + curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/weekly/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' Normalize each PR to an agent name using this deterministic rule: 1) Preferred: parse `head.ref` as `agents/weekly//...` @@ -118,4 +124,10 @@ Now proceed with the scheduler: in docs/agents/task-logs/weekly/. Both MUST exist before task execution begins. 4. After execution: create a "completed" or "failed" log file (new file, never modify the "started" file). Commit and push. + +Race check rule (must be applied after pushing your claim branch): +- Re-run the sortable PR metadata command and compare only PRs with matching derived `agent`. +- If another open/draft claim for the same agent has earlier `created_at`, you lose the race and must abort this run and pick the next agent. +- If timestamps are equal or ambiguous, lower PR `number` wins. +- Print one line before proceeding: `RACE CHECK: won` or `RACE CHECK: lost (agent already claimed by PR #)`. ``` diff --git a/docs/agents/prompts/daily-scheduler.md b/docs/agents/prompts/daily-scheduler.md index efb7d1d6..e7fb7efa 100644 --- a/docs/agents/prompts/daily-scheduler.md +++ b/docs/agents/prompts/daily-scheduler.md @@ -76,7 +76,7 @@ If you arrived here from the meta prompt and already ran these commands and past Run this command: ```bash -curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' +curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/daily/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' ``` **Paste the complete raw output.** If the command returns nothing or errors, write: `OUTPUT: (empty — no results)` @@ -180,9 +180,18 @@ You must create a visible claim before doing any work. This claim is a **distrib After pushing, re-check for competing claims: ```bash -curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' +curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/daily/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' ``` -If you see another PR for this agent that was created *before* yours, abandon your branch and go back to Step 1 to select the next agent. +Decision logic (must be explicit): +1. Compare only open/draft PRs whose derived `agent` matches the agent you just claimed. +2. If another matching PR has an earlier `created_at`, abort this run and pick the next agent. +3. If `created_at` values are equal or ambiguous, use the lower `number` as the tie-breaker (lower number wins). + +Before proceeding, print exactly one race verdict line: +- `RACE CHECK: won` +- `RACE CHECK: lost (agent already claimed by PR #)` + +If the verdict is lost, abandon your branch and go back to Step 1 to select the next agent. ### 2c. Log "started" in the task log immediately diff --git a/docs/agents/prompts/weekly-scheduler.md b/docs/agents/prompts/weekly-scheduler.md index 04aae5d1..bee0dfd5 100644 --- a/docs/agents/prompts/weekly-scheduler.md +++ b/docs/agents/prompts/weekly-scheduler.md @@ -76,7 +76,7 @@ If you arrived here from the meta prompt and already ran these commands and past Run this command: ```bash -curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' +curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/weekly/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' ``` **Paste the complete raw output.** If the command returns nothing or errors, write: `OUTPUT: (empty — no results)` @@ -175,9 +175,18 @@ You must create a visible claim before doing any work. This claim is a **distrib After pushing, re-check for competing claims: ```bash -curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, title, draft, created_at, head: {ref: .head.ref}, labels: [.labels[].name]}]}' +curl -s "https://api.github.com/repos/PR0M3TH3AN/bitvid/pulls?state=open&per_page=100" | jq '{count: length, prs: [.[] | {number, created_at, draft, head: {ref: .head.ref}, agent: ((.head.ref | capture("^agents/weekly/(?[^/]+)/")?.agent) // (.title | capture("(?[A-Za-z0-9-]+-agent)")?.agent // null))}] | sort_by(.created_at, .number)}' ``` -If you see another PR for this agent that was created *before* yours, abandon your branch and go back to Step 1 to select the next agent. +Decision logic (must be explicit): +1. Compare only open/draft PRs whose derived `agent` matches the agent you just claimed. +2. If another matching PR has an earlier `created_at`, abort this run and pick the next agent. +3. If `created_at` values are equal or ambiguous, use the lower `number` as the tie-breaker (lower number wins). + +Before proceeding, print exactly one race verdict line: +- `RACE CHECK: won` +- `RACE CHECK: lost (agent already claimed by PR #)` + +If the verdict is lost, abandon your branch and go back to Step 1 to select the next agent. ### 2c. Log "started" in the task log immediately