Skip to content

Commit 8826b30

Browse files
svelderrainruizGitHub Copilot
andauthored
Standing Priority Handoff: tolerate queue-empty idle-repository state (#913) (#914)
* Handle queue-empty handoff state (#913) * Harden idle handoff isolation path (#913) --------- Co-authored-by: GitHub Copilot <copilot@users.noreply.github.com>
1 parent ae0871e commit 8826b30

10 files changed

Lines changed: 371 additions & 70 deletions

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ Use `tools/workflows/update_workflows.py` for mechanical updates (comment-preser
292292
and appends notes to the GitHub Step Summary when available.
293293
- Each invocation also drops a session capsule under `tests/results/_agent/sessions/`
294294
(schema `agent-handoff/session@v1`) capturing branch/head/status snapshots for determinism.
295+
- When the standing-priority queue is intentionally empty, the helper should
296+
emit an idle summary (`issue: none (queue empty)`) and copy the
297+
`standing-priority/no-standing@v1` summary instead of failing on stale
298+
numeric snapshot files from the previously active issue.
295299
- Capture quick regression coverage with `node tools/npm/run-script.mjs priority:handoff-tests`; the script runs
296300
`priority:test`, `hooks:test`, and `semver:check`, then writes `tests/results/_agent/handoff/test-summary.json` so
297301
subsequent agents (or CI summaries) can replay the outcomes.

docs/knowledgebase/GitHub-Intake-Layer.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ When sync writes `tests/results/_agent/issue/no-standing-priority.json` with
6868
complete, the router should expose `issue = null`, and helpers that open new
6969
standing-priority branches/PRs should stop with a clear message instead of
7070
inventing a null issue context. The correct next action is to create or label
71-
the next tracked issue, then rerun bootstrap.
71+
the next tracked issue, then rerun bootstrap. Future-agent handoff helpers
72+
should also honor this mode: `tools/Print-AgentHandoff.ps1` should emit an idle
73+
summary and copy the queue-empty report instead of treating stale numeric
74+
snapshots as a cache mismatch.
7275

7376
## Agent Metadata Contract
7477

docs/schemas/handoff-router-v1.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"const": "agent/priority-router@v1"
1515
},
1616
"issue": {
17-
"type": "integer"
17+
"type": ["integer", "null"]
1818
},
1919
"updatedAt": {
2020
"type": ["string", "null"],
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://labview-community-ci-cd.github.io/compare-vi-cli-action/schemas/standing-priority-no-standing-v1.schema.json",
4+
"title": "Standing Priority Queue Empty Snapshot",
5+
"type": "object",
6+
"required": ["schema", "message", "reason", "openIssueCount"],
7+
"properties": {
8+
"schema": { "type": "string", "const": "standing-priority/no-standing@v1" },
9+
"generatedAt": { "type": ["string", "null"], "format": "date-time" },
10+
"repository": { "type": ["string", "null"] },
11+
"labels": {
12+
"type": "array",
13+
"items": { "type": "string" }
14+
},
15+
"message": { "type": "string", "minLength": 1 },
16+
"reason": { "type": "string", "minLength": 1 },
17+
"openIssueCount": { "type": "integer", "minimum": 0 },
18+
"failOnMissing": { "type": ["boolean", "null"] }
19+
},
20+
"additionalProperties": true
21+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
Describe 'Agent Handoff queue-empty mode' -Tag 'Unit' {
5+
It 'tolerates a queue-empty cache even when a stale numeric snapshot is still present' {
6+
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
7+
$workspaceRoot = Join-Path $TestDrive 'repo'
8+
$toolsDir = Join-Path $workspaceRoot 'tools'
9+
$scriptPath = Join-Path $toolsDir 'Print-AgentHandoff.ps1'
10+
$issueDir = Join-Path $workspaceRoot 'tests' 'results' '_agent' 'issue'
11+
$cachePath = Join-Path $workspaceRoot '.agent_priority_cache.json'
12+
$resultsRoot = Join-Path $TestDrive 'results'
13+
New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null
14+
Copy-Item -LiteralPath (Join-Path $repoRoot 'tools' 'Print-AgentHandoff.ps1') -Destination $scriptPath -Force
15+
16+
try {
17+
New-Item -ItemType Directory -Force -Path $issueDir | Out-Null
18+
New-Item -ItemType Directory -Force -Path $resultsRoot | Out-Null
19+
Set-Content -LiteralPath (Join-Path $workspaceRoot 'AGENT_HANDOFF.txt') -Value @(
20+
'# Agent Handoff'
21+
''
22+
'Synthetic queue-empty handoff workspace for test coverage.'
23+
) -Encoding utf8
24+
25+
Push-Location $workspaceRoot
26+
27+
[pscustomobject][ordered]@{
28+
schema = 'standing-priority/issue@v1'
29+
number = 911
30+
title = 'Standing Priority Intake: handle an empty backlog without breaking bootstrap'
31+
state = 'OPEN'
32+
updatedAt = '2026-03-08T23:35:13Z'
33+
url = 'https://github.com/LabVIEW-Community-CI-CD/compare-vi-cli-action/issues/911'
34+
labels = @('bug', 'standing-priority')
35+
assignees = @()
36+
milestone = 'LabVIEW CI Platform v1 (2026Q2)'
37+
commentCount = 0
38+
bodyDigest = 'body-digest-911'
39+
digest = 'digest-911'
40+
} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $issueDir '911.json') -Encoding utf8
41+
42+
[pscustomobject][ordered]@{
43+
schema = 'standing-priority/no-standing@v1'
44+
generatedAt = '2026-03-08T23:51:50.543Z'
45+
repository = 'LabVIEW-Community-CI-CD/compare-vi-cli-action'
46+
labels = @('standing-priority')
47+
message = 'No open issues remain in LabVIEW-Community-CI-CD/compare-vi-cli-action; the standing-priority queue is empty.'
48+
reason = 'queue-empty'
49+
openIssueCount = 0
50+
failOnMissing = $true
51+
} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $issueDir 'no-standing-priority.json') -Encoding utf8
52+
53+
[pscustomobject][ordered]@{
54+
schema = 'agent/priority-router@v1'
55+
issue = $null
56+
updatedAt = '2026-03-08T23:51:50.541Z'
57+
actions = @()
58+
} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $issueDir 'router.json') -Encoding utf8
59+
60+
[pscustomobject][ordered]@{
61+
number = $null
62+
title = $null
63+
url = $null
64+
cachedAtUtc = '2026-03-08T23:51:50.541Z'
65+
repository = 'LabVIEW-Community-CI-CD/compare-vi-cli-action'
66+
state = 'NONE'
67+
labels = @()
68+
assignees = @()
69+
milestone = $null
70+
commentCount = $null
71+
lastSeenUpdatedAt = $null
72+
issueDigest = $null
73+
bodyDigest = $null
74+
lastFetchSource = 'none'
75+
lastFetchError = 'No open issues remain in LabVIEW-Community-CI-CD/compare-vi-cli-action; the standing-priority queue is empty.'
76+
noStandingReason = 'queue-empty'
77+
noStandingOpenIssueCount = 0
78+
} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $cachePath -Encoding utf8
79+
80+
{ & $scriptPath -ApplyToggles -ResultsRoot $resultsRoot } | Should -Not -Throw
81+
82+
$handoffDir = Join-Path $resultsRoot '_agent' 'handoff'
83+
$issueSummaryPath = Join-Path $handoffDir 'issue-summary.json'
84+
$routerPath = Join-Path $handoffDir 'issue-router.json'
85+
$sessionPath = Get-ChildItem -LiteralPath (Join-Path $resultsRoot '_agent' 'sessions') -Filter '*.json' | Select-Object -First 1
86+
87+
Test-Path -LiteralPath $issueSummaryPath | Should -BeTrue
88+
Test-Path -LiteralPath $routerPath | Should -BeTrue
89+
$sessionPath | Should -Not -BeNullOrEmpty
90+
91+
$issueSummary = Get-Content -LiteralPath $issueSummaryPath -Raw | ConvertFrom-Json -ErrorAction Stop
92+
$issueSummary.schema | Should -Be 'standing-priority/no-standing@v1'
93+
$issueSummary.reason | Should -Be 'queue-empty'
94+
$issueSummary.openIssueCount | Should -Be 0
95+
96+
$router = Get-Content -LiteralPath $routerPath -Raw | ConvertFrom-Json -ErrorAction Stop
97+
$router.issue | Should -Be $null
98+
@($router.actions).Count | Should -Be 0
99+
100+
$session = Get-Content -LiteralPath $sessionPath.FullName -Raw | ConvertFrom-Json -ErrorAction Stop
101+
$session.standingPriority.mode | Should -Be 'queue-empty'
102+
$session.standingPriority.reason | Should -Be 'queue-empty'
103+
$session.standingPriority.openIssueCount | Should -Be 0
104+
} finally {
105+
if ((Get-Location).Path -eq $workspaceRoot) {
106+
Pop-Location
107+
}
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)