feat(lifecycle): persist remote batch state durably - #50
Conversation
📝 WalkthroughWalkthrough원격 배치의 관찰 순서와 상태를 PostgreSQL에 영속화했습니다. Changes원격 배치 수명주기 영속화
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant DurableBatchAPIClient
participant PostgreSQLSequence
participant ProviderAPI
participant persist_remote_batch_state
participant llm_remote_batch_jobs
DurableBatchAPIClient->>PostgreSQLSequence: 관찰 순서 예약
PostgreSQLSequence-->>DurableBatchAPIClient: observation_order 반환
DurableBatchAPIClient->>ProviderAPI: 배치 생성·조회·취소 요청
ProviderAPI-->>DurableBatchAPIClient: provider 응답
DurableBatchAPIClient->>persist_remote_batch_state: 검증된 응답과 observation_order 전달
persist_remote_batch_state->>llm_remote_batch_jobs: 정규화된 snapshot upsert
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
…batch-lifecycle # Conflicts: # CHANGELOG.md
|
@coderabbitai review Exact-head review requested for |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.coverage:
- Line 1: Remove the tracked .coverage artifact from the repository and add
.coverage to .gitignore so coverage.py’s generated SQLite data remains local and
is not committed again.
In `@pg_llm_batch/durable_client.py`:
- Around line 117-120: Update the ValidationError construction in the
validated_batch_id versus recovery_batch_id mismatch branch to pass the
explanation using the message= keyword, preserving the exception type and
existing redaction behavior while leaving field/value/reason diagnostics
meaningful.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0fcc8737-6b12-43d1-aa17-8f2a8c138cf3
📒 Files selected for processing (13)
.coverageCHANGELOG.mddocs/remote-batch-lifecycle.mddocs/superpowers/evidence/2026-08-04-remote-field-contract-red.mddocs/superpowers/evidence/2026-08-05-remote-batch-error-redaction-green.mddocs/superpowers/evidence/2026-08-05-remote-batch-error-redaction-red.mddocs/superpowers/evidence/2026-08-05-remote-batch-identity-reconciliation-red.mdpg_llm_batch/db.pypg_llm_batch/durable_client.pytests/test_remote_batch_error_redaction.pytests/test_remote_batch_identity_contract.pytests/test_remote_batch_metadata_contract.pytests/test_remote_batch_state_contracts.py
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/superpowers/evidence/2026-08-04-remote-field-contract-red.md
- tests/test_remote_batch_state_contracts.py
- docs/remote-batch-lifecycle.md
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.coverage:
- Line 1: Remove the tracked .coverage artifact from the repository and add
.coverage to .gitignore so coverage.py’s generated SQLite data remains local and
is not committed again.
In `@pg_llm_batch/durable_client.py`:
- Around line 117-120: Update the ValidationError construction in the
validated_batch_id versus recovery_batch_id mismatch branch to pass the
explanation using the message= keyword, preserving the exception type and
existing redaction behavior while leaving field/value/reason diagnostics
meaningful.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0fcc8737-6b12-43d1-aa17-8f2a8c138cf3
📒 Files selected for processing (13)
.coverageCHANGELOG.mddocs/remote-batch-lifecycle.mddocs/superpowers/evidence/2026-08-04-remote-field-contract-red.mddocs/superpowers/evidence/2026-08-05-remote-batch-error-redaction-green.mddocs/superpowers/evidence/2026-08-05-remote-batch-error-redaction-red.mddocs/superpowers/evidence/2026-08-05-remote-batch-identity-reconciliation-red.mdpg_llm_batch/db.pypg_llm_batch/durable_client.pytests/test_remote_batch_error_redaction.pytests/test_remote_batch_identity_contract.pytests/test_remote_batch_metadata_contract.pytests/test_remote_batch_state_contracts.py
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/superpowers/evidence/2026-08-04-remote-field-contract-red.md
- tests/test_remote_batch_state_contracts.py
- docs/remote-batch-lifecycle.md
🛑 Comments failed to post (1)
.coverage (1)
1-1: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
.coverage파일을 리포지토리에서 제거하십시오.
.coverage는 coverage.py가 생성하는 SQLite 데이터 파일입니다. 이 파일은 빌드 아티팩트이며 소스가 아닙니다. 커밋하면 다음 문제가 발생합니다.
- 매 실행마다 바이너리 내용이 바뀌어 diff 노이즈와 병합 충돌이 생깁니다.
- 파일 내부에
/home/runner/work/pg-llm-batch/pg-llm-batch/...형태의 CI 러너 절대 경로가 저장됩니다.- 로컬 실행 결과가 커밋된 파일을 덮어씁니다.
이 파일을 삭제하고
.gitignore에 등록하십시오.🧹 제안 조치
git rm --cached .coverage
.gitignore에 추가:+.coverage +.coverage.* +coverage.xml +htmlcov/🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.coverage at line 1, Remove the tracked .coverage artifact from the repository and add .coverage to .gitignore so coverage.py’s generated SQLite data remains local and is not committed again.
|
@opencode-agent @cwl-noema-review exact-head review requested for |
|
@coderabbitai review Review exact head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
base='162e6f544e90545fbd7ffb4000a81a625a88a51a'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Exact commit identity =='
git cat-file -e "${base}^{commit}"
git cat-file -e "${head}^{commit}"
git show -s --format='base=%H%nbase_subject=%s' "$base"
git show -s --format='head=%H%nhead_parents=%P%nhead_subject=%s' "$head"
echo '== Exact-range changed files =='
git diff --name-status --find-renames "$base" "$head"
echo '== Source and test structure =='
for file in \
pg_llm_batch/durable_client.py \
pg_llm_batch/db.py \
pg_llm_batch/schema.sql \
docker/postgres/init/02_schema.sql \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_schema_integrity.py \
pyproject.toml \
CHANGELOG.md
do
if git cat-file -e "${head}:${file}" 2>/dev/null; then
echo "-- ${file}"
git show "${head}:${file}" > "/tmp/$(basename "${file}")"
case "$file" in
*.py) ast-grep outline "/tmp/$(basename "${file}")" --items all --view compact || true ;;
*) sed -n '1,260p' "/tmp/$(basename "${file}") ;;
esac
fi
done
echo '== Lifecycle, order, terminal, counters, identity, and redaction paths =='
for file in pg_llm_batch/durable_client.py pg_llm_batch/db.py; do
echo "-- ${file}"
git show "${head}:${file}" | rg -n -i -C 12 \
'observation|order|terminal|status|greatest|counter|completed|failed|cancelled|validate_remote|identity|batch_id|recovery|GatewayError|from None|metadata|MAX_PROVIDER|persist|recorder' || true
done
echo '== Relevant regression tests =='
for file in \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_schema_integrity.py
do
if git cat-file -e "${head}:${file}" 2>/dev/null; then
echo "-- ${file}"
git show "${head}:${file}" | rg -n -C 5 \
'def test_|observation|terminal|counter|identity|redact|recovery|metadata|mirror|standalone|coverage|docstring' || true
fi
done
echo '== Canonical schema and image-schema equality =='
git show "${head}:pg_llm_batch/schema.sql" > /tmp/canonical-schema.sql
git show "${head}:docker/postgres/init/02_schema.sql" > /tmp/image-schema.sql
diff -u /tmp/canonical-schema.sql /tmp/image-schema.sql || true
git show "${head}:tests/test_schema_integrity.py" | cat -n
echo '== Workflow inventory and write-capable settings =='
git ls-tree -r --name-only "$head" .github/workflows | sort
while IFS= read -r workflow; do
[ -n "$workflow" ] || continue
echo "-- ${workflow}"
git show "${head}:${workflow}" | rg -n -i -C 4 \
'permissions:|contents:\s*write|pull-requests:\s*write|issues:\s*write|actions:\s*write|id-token:\s*write|workflow_dispatch|pull_request_target|git\s+push|gh\s+(api|pr|issue)' || true
done < <(git ls-tree -r --name-only "$head" .github/workflows | sort)
echo '== Generated coverage artifacts at exact head =='
git ls-tree -r --name-only "$head" | rg -n '(^|/)(\.coverage(?:\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '== Exact-head evidence and coverage/docstring commands =='
git ls-tree -r --name-only "$head" docs/superpowers/evidence | sort | while IFS= read -r evidence; do
echo "-- ${evidence}"
git show "${head}:${evidence}" | rg -n -i -C 3 \
'7d529a2b0297504367d1aa17e0cad37feeda7d7e|162e6f544e90545fbd7ffb4000a81a625a88a51a|coverage|branch|docstring|CI|Semgrep|Security|passed|success|red|green' || true
done
git show "${head}:pyproject.toml" | rg -n -i -C 4 'coverage|branch|docstring|ruff|pytest' || true
echo '== Exact-head check runs =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha,(.started_at // "null"),(.completed_at // "null"),.details_url] | `@tsv`' \
| sort
echo '== Exact-head commit statuses =='
gh api "repos/${repo}/commits/${head}/status" \
--jq '"state=\(.state) sha=\(.sha)", (.statuses[]? | [.context,.state,.updated_at,.target_url] | `@tsv`)'
echo '== Exact-head workflow runs =='
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,event,status,conclusion,headSha,createdAt,updatedAt,url \
--jq '.[] | [.databaseId,.name,.event,.status,(.conclusion // "null"),.headSha,.createdAt,.updatedAt,.url] | `@tsv`' \
| sort
echo '== Current PR state and exact-head status rollup =='
gh pr view 50 --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,statusCheckRollup \
--jq '{headRefOid,baseRefOid,mergeStateStatus,reviewDecision,statusCheckRollup:[.statusCheckRollup[]? | {name,status,conclusion,headSha,detailsUrl}]}'Length of output: 6894 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
base='162e6f544e90545fbd7ffb4000a81a625a88a51a'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Implementation definitions =='
for file in pg_llm_batch/durable_client.py pg_llm_batch/db.py; do
echo "-- $file"
git show "$head:$file" | rg -n \
'^(class DurableBatchAPIClient| def |def (persist_remote_batch_state|reserve_remote_batch_observation_order|validate_remote_resource_id|normalize_provider_metadata))' || true
done
echo '== Durable client persistence and reconciliation implementation =='
git show "$head:pg_llm_batch/durable_client.py" | cat -n | sed -n '1,380p'
echo '== Database lifecycle persistence implementation =='
git show "$head:pg_llm_batch/db.py" | cat -n | sed -n '1,620p'
echo '== Lifecycle contract test names =='
for file in \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_remote_batch_metadata_contract.py \
tests/test_schema_integrity.py
do
echo "-- $file"
git show "$head:$file" | rg -n '^def test_|^class Test' || true
done
echo '== Exact schema mirror comparison =='
git show "$head:pg_llm_batch/schema.sql" > /tmp/canonical-schema.sql
git show "$head:docker/postgres/init/02_schema.sql" > /tmp/image-schema.sql
if diff -u /tmp/canonical-schema.sql /tmp/image-schema.sql; then
echo 'schema_mirror=identical'
else
echo 'schema_mirror=different'
fi
git show "$head:tests/test_schema_integrity.py" | cat -n | sed -n '1,220p'
echo '== Standalone client export and client compatibility checks =='
git show "$head:pg_llm_batch/__init__.py" | cat -n
git show "$head:tests/test_remote_batch_lifecycle.py" | rg -n -C 5 'DurableBatchAPIClient|BatchAPIClient|standalone|client_options|Session' || true
echo '== Exact-head artifact inventory =='
git ls-tree -r --name-only "$head" | rg '(^|/)(\.coverage(\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '-- ignore rules'
git show "$head:.gitignore" | cat -n
echo '== Coverage and docstring configuration/evidence =='
git show "$head:pyproject.toml" | rg -n -i -C 4 'coverage|branch|docstring|ruff|pytest' || true
for evidence in $(git ls-tree -r --name-only "$head" docs/superpowers/evidence); do
echo "-- $evidence"
git show "$head:$evidence" | rg -n -i -C 2 \
'7d529a2b0297504367d1aa17e0cad37feeda7d7e|162e6f544e90545fbd7ffb4000a81a625a88a51a|coverage|branch|docstring|CI|Semgrep|Security|passed|success|failed|cancelled' || true
done
echo '== Workflow inventory and privileged settings =='
git ls-tree -r --name-only "$head" .github/workflows | sort
for workflow in $(git ls-tree -r --name-only "$head" .github/workflows); do
echo "-- $workflow"
git show "$head:$workflow" | rg -n -i -C 3 \
'permissions:|contents:\s*write|pull-requests:\s*write|issues:\s*write|actions:\s*write|id-token:\s*write|workflow_dispatch|pull_request_target|git\s+push|gh\s+(api|pr|issue)' || true
done
echo '== Exact-head checks =='
gh api "repos/$repo/commits/$head/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha] | join(" | ")' | sort
echo '== Exact-head workflow runs =='
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,status,conclusion,headSha,url \
--jq '.[] | [.databaseId,.name,.status,(.conclusion // "null"),.headSha,.url] | join(" | ")' | sort
echo '== Current PR exact-head status rollup =='
gh pr view 50 --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,statusCheckRollup \
--jq '{headRefOid,baseRefOid,mergeStateStatus,reviewDecision,statusCheckRollup:[.statusCheckRollup[]? | {name,status,conclusion,headSha}]}'Length of output: 83593
I found no defect in the requested controls.
The GitHub review decision is empty. An independent human approval remains required by repository policy. You are interacting with an AI system. |
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head7d529a2b0297504367d1aa17e0cad37feeda7d7e. -
Head SHA:
7d529a2b0297504367d1aa17e0cad37feeda7d7e -
Workflow run: 30981640093
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (7 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (7 files)"]
R1 --> V1["required checks"]
Evidence --> S2["Docs (12 files)"]
S2 --> I2["operator or user guidance"]
I2 --> R2["Review risk: Docs (12 files)"]
R2 --> V2["docs review"]
Evidence --> S3["Test (6 files)"]
S3 --> I3["regression suite"]
I3 --> R3["Review risk: Test (6 files)"]
R3 --> V3["targeted test run"]
|
@opencode-agent @cwl-noema-review @coderabbitai review Review exact current head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
base='162e6f544e90545fbd7ffb4000a81a625a88a51a'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Exact commit and current PR identity =='
git cat-file -e "${base}^{commit}"
git cat-file -e "${head}^{commit}"
git show -s --format='base=%H%nbase_subject=%s' "$base"
git show -s --format='head=%H%nparents=%P%nhead_subject=%s' "$head"
gh pr view 50 --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,isDraft,statusCheckRollup \
--jq '{headRefOid,baseRefOid,mergeStateStatus,reviewDecision,isDraft,statusCheckRollup:[.statusCheckRollup[]? | {name,status,conclusion,headSha}]}'
echo '== Changed paths in requested exact range =='
git diff --name-status --find-renames "$base" "$head"
echo '== Relevant source definitions =='
ast-grep outline pg_llm_batch/durable_client.py --items all --view compact
ast-grep outline pg_llm_batch/db.py --items all --view compact
rg -n -C 8 \
'def (_persist_snapshot|persist_remote_batch_state|reserve_remote_batch_observation_order|validate_endpoint_alias|validate_remote_resource_id)|observation_order|GREATEST|REMOTE_TERMINAL_STATUSES|from None|lifecycle_recorder' \
pg_llm_batch/durable_client.py pg_llm_batch/db.py
echo '== Lifecycle regression test inventory =='
for file in \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_remote_batch_metadata_contract.py \
tests/test_schema_integrity.py
do
echo "-- ${file}"
rg -n '^def test_' "$file" || true
done
echo '== Canonical and image schema comparison =='
if diff -u pg_llm_batch/schema.sql docker/postgres/init/02_schema.sql; then
echo 'schema_mirror=identical'
else
echo 'schema_mirror=different'
fi
sed -n '1,180p' tests/test_schema_integrity.py
echo '== Coverage/docstring/doctoring configuration and evidence =='
rg -n -i -C 4 'coverage|branch|docstring|APA|doctor|vale|write-good|language-tool' \
pyproject.toml README.md docs CHANGELOG.md .github 2>/dev/null || true
fd -t f . docs/superpowers/evidence | sort | while IFS= read -r file; do
if rg -q -i '7d529a2b0297504367d1aa17e0cad37feeda7d7e|APA|doctor|coverage|docstring' "$file"; then
echo "-- ${file}"
rg -n -i -C 3 '7d529a2b0297504367d1aa17e0cad37feeda7d7e|APA|doctor|coverage|docstring|passed|success' "$file"
fi
done
echo '== Exact-head workflow and check outcomes =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha] | `@tsv`' | sort
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,status,conclusion,headSha,url \
--jq '.[] | [.databaseId,.name,.status,(.conclusion // "null"),.headSha,.url] | `@tsv`' | sort
echo '== Workflow inventory and generated artifacts =='
fd -t f . .github/workflows | sort
git ls-files | rg '(^|/)(\.coverage(\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '== Repository branch-protection and rulesets =='
default_branch=$(gh repo view "$repo" --json defaultBranchRef --jq '.defaultBranchRef.name')
echo "default_branch=${default_branch}"
gh api "repos/${repo}/branches/${default_branch}/protection" 2>&1 || true
gh api "repos/${repo}/rulesets?includes_parents=true" 2>&1 || trueLength of output: 8666 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
base='162e6f544e90545fbd7ffb4000a81a625a88a51a'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Exact-head implementation structure =='
ast-grep outline pg_llm_batch/durable_client.py --items all --view signatures
ast-grep outline pg_llm_batch/db.py --items all --view signatures
echo '== Reservation, validation, reconciliation, and recovery path =='
sed -n '1,420p' pg_llm_batch/durable_client.py
echo '== Persistence upsert path =='
rg -n -C 18 \
'def (reserve_remote_batch_observation_order|persist_remote_batch_state)|INSERT INTO llm_remote_batch_jobs|ON CONFLICT|observation_order|GREATEST|REMOTE_TERMINAL_STATUSES|terminal|completed_at|metadata' \
pg_llm_batch/db.py
echo '== Relevant test assertions =='
for file in \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_remote_batch_metadata_contract.py \
tests/test_schema_integrity.py
do
echo "-- ${file}"
rg -n -C 4 \
'^def test_|reservation|provider.*call|newer|terminal|counter|timestamp|NUL|identifier|identity|redact|recovery|mirror|coverage|docstring' \
"$file" || true
done
echo '== Schema mirror =='
tail -n +2 docker/postgres/init/02_schema.sql > /tmp/image-schema-without-header.sql
if diff -u pg_llm_batch/schema.sql /tmp/image-schema-without-header.sql; then
echo 'schema_mirror=identical_after_image_header'
else
echo 'schema_mirror=different'
fi
sed -n '1,220p' tests/test_schema_integrity.py
echo '== Exact-head doctoring, coverage, and evidence =='
rg -n -i -C 4 'APA.?7|doctor|coverage|branch|docstring' \
pyproject.toml README.md CHANGELOG.md docs .github 2>/dev/null || true
git ls-files | rg '(^|/)(\.coverage(\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '== Exact-head raw checks and workflow runs =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha,.details_url] | `@tsv`' | sort
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,status,conclusion,headSha,url \
--jq '.[] | [.databaseId,.name,.status,(.conclusion // "null"),.headSha,.url] | `@tsv`' | sort
echo '== Review provenance and unresolved review threads =='
gh pr view 50 --repo "$repo" --json reviews \
--jq '.reviews[] | [.author.login,.state,.commit.oid,.submittedAt,(.body // "")] | `@tsv`' | sort
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number=50 -f query='
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
nodes {
isResolved
isOutdated
comments(first: 1) { nodes { author { login } commit { oid } body } }
}
}
}
}
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] |
select(.isResolved == false) |
{isOutdated, author: .comments.nodes[0].author.login, commit: .comments.nodes[0].commit.oid, body: .comments.nodes[0].body}'
echo '== Default-branch protections and repository rulesets =='
default_branch=$(gh repo view "$repo" --json defaultBranchRef --jq '.defaultBranchRef.name')
echo "default_branch=${default_branch}"
gh api "repos/${repo}/branches/${default_branch}/protection" || true
gh api "repos/${repo}/rulesets?includes_parents=true" || trueLength of output: 148606
I cannot approve this head. GitHub currently reports I also could not read the detailed branch-protection configuration. The GitHub API returned HTTP 403. The organization ruleset is active, but its required conditions were not available to this integration. Approval requires a successful replacement for the failed coverage-evidence run, removal or supersession of the exact-head changes-requested review, and a final branch-policy verification. You are interacting with an AI system. |
|
@opencode-agent @cwl-noema-review @coderabbitai review Review exact current head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
base='162e6f544e90545fbd7ffb4000a81a625a88a51a'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Exact commit and PR identity =='
git cat-file -e "${base}^{commit}"
git cat-file -e "${head}^{commit}"
git show -s --format='base=%H%nbase_subject=%s' "$base"
git show -s --format='head=%H%nhead_subject=%s' "$head"
gh pr view 50 --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,isDraft,statusCheckRollup \
--jq '{headRefOid,baseRefOid,mergeStateStatus,reviewDecision,isDraft,statusCheckRollup:[.statusCheckRollup[]? | {name,status,conclusion,headSha,detailsUrl}]}'
echo '== Exact range =='
git diff --name-status --find-renames "$base" "$head"
echo '== Source structure =='
ast-grep outline pg_llm_batch/durable_client.py --items all --view signatures
ast-grep outline pg_llm_batch/db.py --items all --view signatures
echo '== Validation, reservation, reconciliation, recovery, and upsert =='
rg -n -C 10 \
'def (_persist_snapshot|persist_remote_batch_state|reserve_remote_batch_observation_order|validate_endpoint_alias|validate_remote_resource_id|normalize_provider_metadata)|observation_order|GREATEST|REMOTE_TERMINAL_STATUSES|completed_at|from None|lifecycle_recorder|remote_batch_id' \
pg_llm_batch/durable_client.py pg_llm_batch/db.py
echo '== Contract test inventory =='
for file in \
tests/test_remote_batch_lifecycle.py \
tests/test_remote_batch_state_contracts.py \
tests/test_remote_batch_identity_contract.py \
tests/test_remote_batch_error_redaction.py \
tests/test_remote_batch_metadata_contract.py \
tests/test_schema_integrity.py
do
echo "-- ${file}"
rg -n -C 2 '^def test_|reservation|provider.*call|newer|terminal|counter|timestamp|NUL|identifier|identity|redact|recovery|mirror|docstring' "$file" || true
done
echo '== Schema parity and SQL object names =='
tail -n +2 docker/postgres/init/02_schema.sql > /tmp/image-schema.sql
if diff -u pg_llm_batch/schema.sql /tmp/image-schema.sql; then
echo 'schema_mirror=identical_after_required_image_header'
else
echo 'schema_mirror=different'
fi
rg -n -i 'create (table|sequence|index)|constraint ' pg_llm_batch/schema.sql docker/postgres/init/02_schema.sql
echo '== Coverage, documentation, package, container, and doctoring configuration =='
rg -n -i -C 3 'coverage|branch|docstring|APA.?7|doctor|package|container' \
pyproject.toml README.md CHANGELOG.md docs .github 2>/dev/null || true
git ls-files | rg '(^|/)(\.coverage(\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '== Exact-head workflow and check outcomes =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha,.details_url] | `@tsv`' | sort
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,event,status,conclusion,headSha,createdAt,updatedAt,url \
--jq '.[] | [.databaseId,.name,.event,.status,(.conclusion // "null"),.headSha,.createdAt,.updatedAt,.url] | `@tsv`' | sort
echo '== Exact-head coverage workflow details =='
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,status,conclusion,headSha,url \
--jq '.[] | select((.name | ascii_downcase | contains("coverage")) or (.name | ascii_downcase | contains("diagnostic"))) | [.databaseId,.name,.status,(.conclusion // "null"),.headSha,.url] | `@tsv`' | sort
echo '== Unresolved review threads and review provenance =='
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number=50 -f query='
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
nodes {
isResolved
isOutdated
comments(first: 1) { nodes { author { login } commit { oid } } }
}
}
}
}
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)'
gh pr view 50 --repo "$repo" --json reviews \
--jq '.reviews[] | [.author.login,.state,.commit.oid,.submittedAt] | `@tsv`' | sort
echo '== Available branch rules =='
default_branch=$(gh repo view "$repo" --json defaultBranchRef --jq '.defaultBranchRef.name')
echo "default_branch=${default_branch}"
gh api "repos/${repo}/branches/${default_branch}/protection" 2>&1 || true
gh api "repos/${repo}/rulesets?includes_parents=true" 2>&1 || trueLength of output: 149727 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Current exact-head OpenCode review =='
gh pr view 50 --repo "$repo" --json reviews \
--jq --arg head "$head" '
.reviews[]
| select(.author.login == "opencode-agent" and .commit.oid == $head)
| {id, state, submittedAt, body, commit: .commit.oid}
'
echo '== Review comments for the current exact-head OpenCode review =='
gh api "repos/${repo}/pulls/50/reviews" --paginate \
--jq --arg head "$head" '
.[]
| select(.user.login == "opencode-agent" and .commit_id == $head)
| [.id, .state, .submitted_at] | `@tsv`
' \
| while IFS=$'\t' read -r review_id state submitted_at; do
echo "-- review_id=${review_id} state=${state} submitted_at=${submitted_at}"
gh api "repos/${repo}/pulls/50/reviews/${review_id}/comments" --paginate \
--jq '.[] | {path, line, original_line, body, commit_id}'
done
echo '== Current PR review and merge state =='
gh pr view 50 --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,reviews \
--jq '{
headRefOid,
baseRefOid,
mergeStateStatus,
reviewDecision,
reviews: [.reviews[] | {author: .author.login, state, commit: .commit.oid, submittedAt}]
}'Length of output: 1691 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
head='7d529a2b0297504367d1aa17e0cad37feeda7d7e'
echo '== Current exact-head OpenCode review =='
gh api "repos/${repo}/pulls/50/reviews?per_page=100" --paginate > /tmp/pr50-reviews.json
jq --arg head "$head" '
.[]
| select(.user.login == "opencode-agent" and .commit_id == $head)
| {id, state, submitted_at, body, commit_id}
' /tmp/pr50-reviews.json
echo '== Review comments for the current exact-head OpenCode review =='
jq -r --arg head "$head" '
.[]
| select(.user.login == "opencode-agent" and .commit_id == $head)
| .id
' /tmp/pr50-reviews.json \
| while IFS= read -r review_id; do
[ -n "$review_id" ] || continue
echo "-- review_id=${review_id}"
gh api "repos/${repo}/pulls/50/reviews/${review_id}/comments?per_page=100" --paginate \
--jq '.[] | {path, line, original_line, body, commit_id}'
done
echo '== Current PR review and merge state =='
gh pr view 50 --repo "$repo" --json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,reviews \
| jq '{
headRefOid,
baseRefOid,
mergeStateStatus,
reviewDecision,
reviews: [.reviews[] | {author: .author.login, state, commit: .commit.oid, submittedAt}]
}'Length of output: 3579 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
gh api "repos/${repo}/pulls/50/reviews?per_page=100" --paginate > /tmp/pr50-reviews.json
echo '== All OpenCode REST review records =='
jq '
.[]
| select(.user.login == "opencode-agent")
| {
id,
state,
commit_id,
submitted_at,
body,
html_url
}
' /tmp/pr50-reviews.json
echo '== Comments on every OpenCode changes-requested review =='
jq -r '
.[]
| select(.user.login == "opencode-agent" and .state == "CHANGES_REQUESTED")
| .id
' /tmp/pr50-reviews.json \
| while IFS= read -r review_id; do
[ -n "$review_id" ] || continue
echo "-- review_id=${review_id}"
gh api "repos/${repo}/pulls/50/reviews/${review_id}/comments?per_page=100" --paginate \
--jq '.[] | {path, line, original_line, commit_id, body}'
doneLength of output: 1098
Verified controls:
I cannot submit approval. GitHub still reports The branch-protection API also returned HTTP 403. I could identify the active organization ruleset, but I could not inspect its required conditions. Resolve or dismiss the current exact-head changes-requested review. Then verify branch protection with sufficient permissions. You are interacting with an AI system. |
|
@opencode-agent @cwl-noema-review @coderabbitai review Review the current exact head only. Verify durable remote-batch lifecycle semantics under restart, retry, delayed/out-of-order provider observations, concurrent workers, identifier mismatch, and database failure; enforce monotonic counters, first terminal timestamp preservation, strictly newer observation ordering, transactionality, migration/schema parity, two-or-more-word snake_case database object names, bounded/redacted recovery diagnostics, 100% statement/branch/docstring evidence, realistic PostgreSQL tests, APA 7 doctoring, and protected-branch checks. Approve only if no current-head blocker remains. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/pg-llm-batch'
pr=50
echo '== Current pull request identity =='
gh pr view "$pr" --repo "$repo" \
--json headRefOid,baseRefOid,mergeStateStatus,reviewDecision,isDraft,statusCheckRollup \
--jq '{
headRefOid, baseRefOid, mergeStateStatus, reviewDecision, isDraft,
statusCheckRollup: [.statusCheckRollup[]? | {name,status,conclusion,headSha,detailsUrl}]
}'
head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
base="$(gh pr view "$pr" --repo "$repo" --json baseRefOid --jq .baseRefOid)"
printf 'head=%s\nbase=%s\n' "$head" "$base"
echo '== Exact range =='
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git show -s --format='head=%H%nsubject=%s%nparents=%P' "$head"
git diff --name-status --find-renames "$base" "$head"
echo '== Relevant implementation structure =='
ast-grep outline pg_llm_batch/durable_client.py --items all --view signatures
ast-grep outline pg_llm_batch/db.py --items all --view signatures
rg -n -C 10 \
'def (_persist_snapshot|persist_remote_batch_state|reserve_remote_batch_observation_order|validate_endpoint_alias|validate_remote_resource_id|normalize_provider_metadata)|observation_order|GREATEST|REMOTE_TERMINAL_STATUSES|completed_at|from None|lifecycle_recorder|remote_batch_id|input_file_id|output_file_id|error_file_id' \
pg_llm_batch/durable_client.py pg_llm_batch/db.py
echo '== Lifecycle and schema test inventory =='
for file in tests/test_remote_batch_lifecycle.py tests/test_remote_batch_state_contracts.py tests/test_remote_batch_identity_contract.py tests/test_remote_batch_error_redaction.py tests/test_remote_batch_metadata_contract.py tests/test_schema_integrity.py; do
echo "-- $file"
rg -n -C 2 '^def test_|restart|retry|concurrent|out.of.order|delayed|terminal|counter|timestamp|transaction|NUL|identifier|identity|redact|recovery|metadata|mirror|postgres|docstring|coverage' "$file" || true
done
echo '== Deployable schema parity and object identifiers =='
tail -n +2 docker/postgres/init/02_schema.sql >/tmp/pr50-image-schema-body.sql
if diff -u pg_llm_batch/schema.sql /tmp/pr50-image-schema-body.sql; then
echo 'schema_mirror=identical_after_required_header'
else
echo 'schema_mirror=different'
fi
rg -n -i 'create (table|sequence|index)|constraint ' pg_llm_batch/schema.sql
echo '== Documentation, doctoring, and generated-artifact controls =='
rg -n -i -C 3 'APA.?7|doctor|coverage|branch|docstring|postgres' pyproject.toml README.md CHANGELOG.md docs .github 2>/dev/null || true
git ls-files | rg '(^|/)(\.coverage(\..*)?|coverage\.xml|htmlcov/|\.pytest_cache/|__pycache__/)' || true
echo '== Workflow inventory and write-capable settings =='
fd -t f . .github/workflows | sort
rg -n -i -C 3 'permissions:|contents:\s*write|pull-requests:\s*write|issues:\s*write|actions:\s*write|id-token:\s*write|workflow_dispatch|pull_request_target|git\s+push|gh\s+(api|pr|issue)' .github/workflows || true
echo '== Exact-head check runs =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" --paginate \
--jq '.check_runs[] | [.name,.status,(.conclusion // "null"),.head_sha,.details_url] | `@tsv`' | sort
echo '== Exact-head workflow runs =='
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,event,status,conclusion,headSha,url \
--jq '.[] | [.databaseId,.name,.event,.status,(.conclusion // "null"),.headSha,.url] | `@tsv`' | sort
echo '== Unresolved threads and review provenance =='
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
nodes {
isResolved
isOutdated
comments(first: 1) { nodes { author { login } commit { oid } body } }
}
}
}
}
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)'
gh pr view "$pr" --repo "$repo" --json reviews \
--jq '.reviews[] | [.author.login,.state,.commit.oid,.submittedAt] | `@tsv`' | sort
echo '== Branch protection and rulesets =='
default_branch="$(gh repo view "$repo" --json defaultBranchRef --jq '.defaultBranchRef.name')"
printf 'default_branch=%s\n' "$default_branch"
gh api "repos/${repo}/branches/${default_branch}/protection" 2>&1 || true
gh api "repos/${repo}/rulesets?includes_parents=true" 2>&1 || trueLength of output: 176327 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Integration-marked test definitions =='
rg -n -C 5 '`@pytest`\.mark\.integration|pytestmark.*integration' tests
echo '== Durable lifecycle references in integration candidates =='
rg -n -i -C 5 \
'DurableBatchAPIClient|persist_remote_batch_state|reserve_remote_batch_observation_order|llm_remote_batch_jobs|llm_remote_batch_observation_sequence' \
tests
echo '== Integration test configuration and PostgreSQL service contract =='
rg -n -C 4 'integration|PG_LLM_BATCH_TEST_DSN|postgres|pg_tiktoken' \
pyproject.toml docker-compose.yml README.md .github/workflows/ci.yml 2>/dev/null || true
echo '== Exact source range around database execution and commit =='
sed -n '400,510p' pg_llm_batch/db.pyLength of output: 55516
I found one verification blocker. I cannot approve this head.
Add live PostgreSQL lifecycle integration coverage for concurrent and delayed observations. The tests should verify the actual database behavior for:
Static inspection found the requested implementation controls:
Two merge conditions also remain unresolved:
Add the live lifecycle integration tests, resolve or dismiss the current-head changes-requested review as appropriate, and verify branch rules with sufficient GitHub permissions. You are interacting with an AI system. |
Product gap
Remote provider batch state existed only in memory. Restarts, worker failover, delayed output availability, and provider/local split-brain failures therefore required callers to reconstruct lifecycle state. The deployable PostgreSQL image also carried a stale schema mirror, so a successful container build could initialize a database missing lifecycle and earlier integrity migrations.
What changed
DurableBatchAPIClientwhile preserving standaloneBatchAPIClient;llm_remote_batch_jobswith compound(endpoint_alias, remote_batch_id)identity and database-ownedllm_remote_batch_observation_sequence;field, redactedvalue,reason, and stablemessagefields;main;Test-first evidence
Lifecycle ordering, schema mirroring, identifier limits, optional remote fields, metadata normalization, provider-identifier redaction, poll identity reconciliation, and structured mismatch diagnostics were each introduced through failing tests before implementation. Immutable evidence is maintained under
docs/superpowers/evidence/.The poll identity regression was captured at exact RED head
5ae4463b38f6eec5bf4fcccf8d52d6cc6a725c2a. Hosted CI run30978399259failed with the intendedDID NOT RAISE GatewayErrorassertion (1 failed, 305 passed, 3 deselected) when a request forbatch-requestedreceivedbatch-other.The diagnostic-shape regression was captured at exact RED head
f3993034b00a0efa762568edbabe17d9611d8052. CI run30980060928failed only the new constructor-argument assertion on Python 3.10, 3.12, and 3.14 because the implementation passed the complete explanation as the positionalfieldargument. The exact expected bounded keyword structure was then implemented without exposing the mismatched provider identifier.Concurrency and security model
PostgreSQL
nextvalestablishes request order before network latency can reorder responses.INSERT ... ON CONFLICT DO UPDATEatomically accepts a row only when the incoming order is greater than the stored order, andGREATESTprevents sparse later observations from reducing known counters. Provider metadata is descriptive data, not a tenant authorization boundary. Hosts requiring evidentiary history must also emit immutable tenant-attributed audit events.Standards basis
The database concurrency contract follows current PostgreSQL sequence, conditional-expression, JSON, and atomic upsert documentation. Persisted fields follow the core OpenAI-compatible Batch object shape. Recovery-data redaction follows CWE-532 and OWASP logging guidance. APA 7th references are maintained in
docs/remote-batch-lifecycle.md.Exact-head merge gate
Current head SHA:
7d529a2b0297504367d1aa17e0cad37feeda7d7e.Current base SHA:
162e6f544e90545fbd7ffb4000a81a625a88a51a.Exact-head CI run
30980265212, SAST Semgrep run30980265183, and Security Scan run30980265213succeeded. CI passed Python 3.10, 3.12, and 3.14 tests, compilation, Ruff, complete public docstrings, 100% production statement and branch coverage, lock freshness, package builds, Compose validation, and both container builds. No actionable review thread remains.Merge remains prohibited until exact-head CodeRabbit, OpenCode, and repository-required review outcomes complete successfully; a qualifying independent approval is present; the central
.githubdependency stack is integrated; and branch protection and repository policy are satisfied without bypass. Earlier-head review evidence is not treated as current-head approval.This slice remains under
Unreleased; no version or release is published by this PR.