Skip to content

feat(observability): instrument durable checkpoint operations - #61

Closed
seonghobae wants to merge 186 commits into
agent/persistent-result-checkpoint-storefrom
agent/checkpoint-opentelemetry-observability
Closed

seonghobae wants to merge 186 commits into
agent/persistent-result-checkpoint-storefrom
agent/checkpoint-opentelemetry-observability

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Product and acquisition gap

The durable result-checkpoint store provides tenant isolation, exact compare-and-swap advancement, and caller-owned transaction coupling, but operators also need storage-agnostic, low-cardinality OpenTelemetry signals that preserve confidentiality and never change checkpoint semantics.

Implemented bounded vertical slice

  • keeps OpenTelemetryCheckpointStore opt-in and compatible with package-owned or host-owned checkpoint stores;
  • keeps host-owned tracer/meter injection and adds no mandatory OpenTelemetry SDK, exporter, processor, collector, or global-provider configuration;
  • emits fixed operation, transaction-owner, outcome, and finite error.type values only;
  • excludes tenant, consumer, batch, endpoint, file, digest, cursor, DSN, provider payload, exception message, and dynamic exception-class values;
  • keeps package operation spans storage-agnostic and does not fabricate db.system.name;
  • disables automatic exception recording/status-on-exception, then explicitly sets the host OpenTelemetry API's StatusCode.ERROR without a description on failed checkpoint spans when available;
  • leaves successful spans Unset and contains tracer, meter, span, status, optional API, and clock failures as observer-only failures;
  • preserves caller-owned transaction semantics and exact application result/exception identity;
  • reconciles the prerequisite fresh-PostgreSQL-image checkpoint migration installation; and
  • updates AGENTS, CLAUDE, architecture, ADR 0008, operator guidance, doctoring, CHANGELOG, and deterministic contracts. Doctoring records OpenTelemetry semantic conventions 1.44.0 in APA 7 form.

No branch-writing workflow, generated coverage database, build product, cache, version bump, publication, or release authority is added.

Strict red-green-refactor evidence

  • Stacked prerequisite branch: agent/persistent-result-checkpoint-store; current exact tip 90854868c7099b93087ceea07982675174112f24 (PR feat(checkpoint): persist resumable result progress #60).
  • Error-status RED test-only head: 4a292443e7bcf67c50a1718106406dcec4eb16a8.
  • Production Error-status implementation: b9f0a5a4a986d7ba678752d3bc3ecd01f081db9b.
  • Authoritative-doc/refactor head: 50efd2c7e8ec2ac995925534c00c3bee24bc4b13.
  • Prerequisite-reconciliation RED head: a08f20b0e956a5bb768533888737a6150947015a required the checkpoint migration in the fresh bundled PostgreSQL image before the Dockerfile fix.
  • Prerequisite-reconciliation GREEN head: 8a2deeb14c23d9db97bbad1d4c68837b6c8591cc installed the reviewed migration under /docker-entrypoint-initdb.d/04_result_stream_checkpoints.sql.
  • A downstream integration run for stacked PR feat(audit): persist append-only checkpoint acceptance trail #62 (31138736624) then exposed two valid predecessor-contract defects before feat(observability): instrument durable checkpoint operations #61 had same-head workflow evidence: the concurrency regression still expected db.system.name=postgresql despite the storage-agnostic production/ADR contract, and the operator documentation missed an exact required Error-status phrase by capitalization. Those permanent tests were already RED in that integration run.
  • b4f301e8bef7e31088e0f3eab0737ea1d685ee9c corrected the concurrency test to enforce the intended storage-agnostic attribute set without changing production code.
  • Current head f3059450f1f263ed59979ae94fb7bf5b621616be aligns operator documentation with the existing explicit Error-status contract.

Current exact-head staged evidence

  • Head: f3059450f1f263ed59979ae94fb7bf5b621616be.
  • Current base branch tip: 90854868c7099b93087ceea07982675174112f24 (agent/persistent-result-checkpoint-store). Connector base_sha metadata may represent an older merge base and is not treated as current-base evidence.
  • CI 31138841164: success on the exact current head. Container builds, coverage/docstrings/lint/package, and Python 3.10/3.12/3.14 jobs all completed successfully.
  • Release Acceptance 31138841209: success on the exact current head.
  • CodeRabbit commit status: success on the exact current head; automated status is not independent approval.
  • Unresolved inline review threads: zero on current inspection.
  • Existing author COMMENTED review is audit history only; no qualifying independent non-author GitHub APPROVED review exists.
  • No queued, pending, cancelled, skipped-required, absent, predecessor-head, or stale-base result is counted as success. Opaque repository protections/check surfaces unavailable through the current connector remain unproven rather than assumed green.

Dependency and merge boundary

Required order remains:

.github#790 -> pg-llm-batch#53 -> #55 -> #56 -> #57 -> #58 -> #59 -> #60 -> this PR.

This PR remains a stacked draft. It must not be marked ready or merged until every prerequisite integrates into main, the branch is retargeted, and fresh integrated exact-head/exact-base quality, security, dependency, packaging, provenance, supply-chain, release-acceptance, and independent-review evidence succeeds under repository protection. A qualifying independent non-author GitHub APPROVED review and zero unresolved valid findings remain mandatory. No staged-base evidence is reusable as final integrated release evidence.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Review only exact current head 50efd2c7e8ec2ac995925534c00c3bee24bc4b13 against exact stacked base ff183ecc8050e90850b55100cc12d9eb83e6c032; do not mutate the branch or merge. Verify the OpenTelemetry Recording Errors contract: failed checkpoint spans explicitly set the host StatusCode.ERROR with no status description while successful spans remain Unset, automatic exception recording remains disabled, protected exception data cannot enter span status/attributes, optional OpenTelemetry API/status mutation failures remain observer-only, storage-agnostic span semantics remain intact, and deterministic statement/branch/docstring coverage remains 100%. Treat absent, queued, pending, cancelled, skipped-required, rate-limited, predecessor-head, or stale-base CI/review evidence as non-success.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

@seonghobae I will review PR #61 at exact head 50efd2c7e8ec2ac995925534c00c3bee24bc4b13 against exact base ff183ecc8050e90850b55100cc12d9eb83e6c032.

I will not modify the branch or merge the pull request. I will verify the specified OpenTelemetry error-status contract, confidentiality, observer-failure isolation, storage-agnostic semantics, and deterministic coverage requirements. I will treat non-qualifying CI and review evidence as non-success.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor Author

@opencode-agent @cwl-noema-review

Independent review-only request for exact current head 50efd2c7e8ec2ac995925534c00c3bee24bc4b13 against exact stacked base ff183ecc8050e90850b55100cc12d9eb83e6c032. Do not mutate the branch or merge. Verify explicit OpenTelemetry Error status without descriptions on failed checkpoint operations, Unset status on success, confidentiality/cardinality, optional-API and observer-failure isolation, transaction ownership, storage-agnostic interoperability, current OpenTelemetry semantic-convention alignment, and permanent deterministic regressions. Absence or queueing of exact-head CI/Release Acceptance remains a blocker and predecessor evidence must not be reused.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exact-head review note for 50efd2c7e8ec2ac995925534c00c3bee24bc4b13 over stacked base ff183ecc8050e90850b55100cc12d9eb83e6c032: current OpenTelemetry Recording Errors guidance requires failed operations to set span status Error and error.type, while successful operations leave status unset. The predecessor head set bounded error.type but deliberately disabled automatic status-on-exception without replacing it with an explicit confidential Error status, so failed checkpoint spans remained Unset. A test-only RED commit 4a292443e7bcf67c50a1718106406dcec4eb16a8 captured that gap. Production now lazily resolves the host OpenTelemetry API's StatusCode.ERROR, explicitly sets it with no description only on failed operations, leaves success Unset, contains import/status observer failures, and still sanitizes span-context exit to (None, None, None). Authoritative AGENTS/CLAUDE/architecture/ADR/operator/doctoring/CHANGELOG contracts and deterministic regressions were synchronized, including OpenTelemetry semantic conventions 1.44.0 APA-7 doctoring. No branch-writing workflow or generated evidence artifact was introduced. This author review is audit evidence only and is not independent approval. Exact-head CI/Release Acceptance remain absent/queued upstream and are not counted as success; CodeRabbit exact-head full review is currently rate-limited.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@opencode-agent @cwl-noema-review

Review-only request for exact current stacked head f3059450f1f263ed59979ae94fb7bf5b621616be against actual predecessor tip 90854868c7099b93087ceea07982675174112f24. Do not mutate branches, mark ready, or merge. Verify storage-agnostic OpenTelemetry semantics, explicit failed-span StatusCode.ERROR with no confidential description, successful-span Unset status, fixed low-cardinality attributes, absence of fabricated db.system.name, exact application result/exception identity, observer/cancellation/process-control isolation, caller-owned transaction preservation, optional API interoperability, fresh PostgreSQL image migration installation, and APA 7 semantic-convention citations. Submit actionable findings as review comments; formal approval is reserved for final integrated-main exact-head evidence.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_sha='f3059450f1f263ed59979ae94fb7bf5b621616be'
base_sha='90854868c7099b93087ceea07982675174112f24'

echo '=== Local commit availability ==='
git cat-file -t "$head_sha"
git cat-file -t "$base_sha"

echo '=== Commit range summary ==='
git diff --stat "$base_sha" "$head_sha"
git diff --name-status "$base_sha" "$head_sha"

echo '=== Changed Python outlines ==='
git diff --name-only "$base_sha" "$head_sha" -- '*.py' |
while IFS= read -r file; do
  [ -n "$file" ] || continue
  echo "--- $file"
  ast-grep outline "$file" --items all --type class,function --view expanded || true
done

echo '=== OpenTelemetry and checkpoint references in changed files ==='
git diff --name-only "$base_sha" "$head_sha" |
while IFS= read -r file; do
  [ -n "$file" ] || continue
  rg -n -i -C 3 \
    'OpenTelemetry|opentelemetry|Checkpoint|StatusCode|db\.system\.name|docker-entrypoint-initdb|semantic conventions|APA' \
    "$file" || true
done

echo '=== Exact-head GitHub checks and reviews ==='
gh api "repos/ContextualWisdomLab/pg-llm-batch/commits/$head_sha/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`' || true
gh api "repos/ContextualWisdomLab/pg-llm-batch/commits/$head_sha/status" \
  --jq '.statuses[] | [.context, .state, .target_url] | `@tsv`' || true
gh pr view 61 --repo ContextualWisdomLab/pg-llm-batch \
  --json headRefOid,baseRefOid,isDraft,reviews,reviewThreads,statusCheckRollup \
  || true

Length of output: 87587


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== Telemetry implementation ==='
nl -ba pg_llm_batch/checkpoint_telemetry.py | sed -n '1,380p'

echo '=== Durable checkpoint-store public operation definitions ==='
ast-grep outline pg_llm_batch/checkpoint_store.py \
  --items all --type class,function --match 'Checkpoint|load|save' --view expanded || true
rg -n -A35 -B8 \
  'def (load|load_in_transaction|save|save_in_transaction)\s*\(' \
  pg_llm_batch/checkpoint_store.py || true

echo '=== Exception-boundary and status regression tests ==='
nl -ba tests/test_checkpoint_telemetry_exception_boundary.py | sed -n '1,180p'
nl -ba tests/test_checkpoint_telemetry_span_status.py | sed -n '1,280p'
nl -ba tests/test_checkpoint_telemetry.py | sed -n '230,540p'
nl -ba tests/test_checkpoint_telemetry_storage_semantics.py | sed -n '1,160p'

echo '=== Container migration installation ==='
fd -a -i 'Dockerfile*' .
fd -a -i '*result*checkpoint*.sql' .
rg -n -C 4 'result_stream_checkpoints|docker-entrypoint-initdb\.d' . \
  -g 'Dockerfile*' -g '*.sql' -g '*.yml' -g '*.yaml' || true

echo '=== PR review state and unresolved review threads ==='
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number=61 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      isDraft
      headRefOid
      baseRefOid
      reviewDecision
      reviews(first: 100) {
        nodes { author { login } state commit { oid } }
      }
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 20) { nodes { author { login } body path line } }
        }
      }
    }
  }
}' --jq '{
  isDraft: .data.repository.pullRequest.isDraft,
  headRefOid: .data.repository.pullRequest.headRefOid,
  baseRefOid: .data.repository.pullRequest.baseRefOid,
  reviewDecision: .data.repository.pullRequest.reviewDecision,
  reviews: .data.repository.pullRequest.reviews.nodes,
  unresolvedThreads: [
    .data.repository.pullRequest.reviewThreads.nodes[]
    | select(.isResolved == false)
  ]
}' || true

Length of output: 2510


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== Telemetry implementation ==='
cat -n pg_llm_batch/checkpoint_telemetry.py | sed -n '1,380p'

echo '=== Durable checkpoint-store public operation definitions ==='
ast-grep outline pg_llm_batch/checkpoint_store.py \
  --items all --type class,function --match 'Checkpoint|load|save' --view expanded || true
rg -n -A35 -B8 \
  'def (load|load_in_transaction|save|save_in_transaction)\s*\(' \
  pg_llm_batch/checkpoint_store.py || true

echo '=== Exception-boundary and status regression tests ==='
cat -n tests/test_checkpoint_telemetry_exception_boundary.py | sed -n '1,180p'
cat -n tests/test_checkpoint_telemetry_span_status.py | sed -n '1,280p'
cat -n tests/test_checkpoint_telemetry.py | sed -n '230,540p'
cat -n tests/test_checkpoint_telemetry_storage_semantics.py | sed -n '1,160p'

echo '=== Container migration installation ==='
fd -a -i 'Dockerfile*' .
fd -a -i '*result*checkpoint*.sql' .
rg -n -C 4 'result_stream_checkpoints|docker-entrypoint-initdb\.d' . \
  -g 'Dockerfile*' -g '*.sql' -g '*.yml' -g '*.yaml' || true

echo '=== PR review state and unresolved review threads ==='
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number=61 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      isDraft
      headRefOid
      baseRefOid
      reviewDecision
      reviews(first: 100) {
        nodes { author { login } state commit { oid } }
      }
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 20) { nodes { author { login } body path line } }
        }
      }
    }
  }
}' --jq '{
  isDraft: .data.repository.pullRequest.isDraft,
  headRefOid: .data.repository.pullRequest.headRefOid,
  baseRefOid: .data.repository.pullRequest.baseRefOid,
  reviewDecision: .data.repository.pullRequest.reviewDecision,
  reviews: .data.repository.pullRequest.reviews.nodes,
  unresolvedThreads: [
    .data.repository.pullRequest.reviewThreads.nodes[]
    | select(.isResolved == false)
  ]
}' || true

Length of output: 53180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== Checkpoint migration files ==='
fd -a -i --glob '*result*checkpoint*.sql' . || true
fd -a -i --glob '*checkpoint*.sql' . || true

echo '=== Dockerfiles ==='
fd -a -i --glob 'Dockerfile*' . -x sh -c 'echo "--- $1"; cat -n "$1"' sh {} \;

echo '=== Migration installation references ==='
rg -n -C 5 'result_stream_checkpoints|docker-entrypoint-initdb\.d|checkpoint.*\.sql' . \
  -g 'Dockerfile*' -g '*.sql' -g '*.yml' -g '*.yaml' || true

echo '=== Status-resolution test coverage ==='
rg -n -C 5 'StatusCode|_resolve_error_status|optional API|optional.*status|AttributeError' \
  tests/test_checkpoint_telemetry*.py pg_llm_batch/checkpoint_telemetry.py

echo '=== Exact PR state and unresolved threads ==='
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-llm-batch' -F number=61 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      isDraft
      headRefOid
      baseRefOid
      reviewDecision
      reviews(first: 100) {
        nodes { author { login } state commit { oid } }
      }
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 20) { nodes { author { login } body path line } }
        }
      }
    }
  }
}' --jq '{
  isDraft: .data.repository.pullRequest.isDraft,
  headRefOid: .data.repository.pullRequest.headRefOid,
  baseRefOid: .data.repository.pullRequest.baseRefOid,
  reviewDecision: .data.repository.pullRequest.reviewDecision,
  reviews: .data.repository.pullRequest.reviews.nodes,
  unresolvedThreads: [
    .data.repository.pullRequest.reviewThreads.nodes[]
    | select(.isResolved == false)
  ]
}'

Length of output: 38342


@seonghobae I reviewed f3059450f1f263ed59979ae94fb7bf5b621616be against the requested predecessor 90854868c7099b93087ceea07982675174112f24.

I found one actionable issue.

  • Optional status resolution can break wrapper construction. In pg_llm_batch/checkpoint_telemetry.py Line 146, StatusCode.ERROR is read outside the try block. If opentelemetry.trace imports but exposes an incompatible or failing StatusCode.ERROR, that exception escapes OpenTelemetryCheckpointStore.__init__. This violates the documented contract that optional status-code resolution failures are observer-only. Resolve the member inside the containment block and add a regression test for an importable API that lacks or fails while resolving ERROR.

I found no other actionable defects in the requested scope. The implementation uses storage-agnostic operation spans, omits db.system.name, uses fixed attributes and finite error.type values, disables automatic exception recording and status-on-exception, preserves the application result and exception identity through tested observer failures, and delegates transaction methods without changing cursor ownership.

The PostgreSQL image installs the checkpoint migration at /docker-entrypoint-initdb.d/04_result_stream_checkpoints.sql. The operator documentation, ADR, and doctoring material state the Error-without-description contract and include the requested APA 7 OpenTelemetry references.

Exact-head checks succeeded for container builds, coverage/docstrings/lint/package, Python 3.10/3.12/3.14 tests, and reproducible wheel/sdist. PR #61 remains a draft. No independent approval exists. I did not approve, mark ready, merge, or modify the branch.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor Author

Exact-current-base ancestry audit (no branch mutation): source head f3059450f1f263ed59979ae94fb7bf5b621616be; live stacked base agent/persistent-result-checkpoint-store tip 90854868c7099b93087ceea07982675174112f24. Git comparison is 45 ahead / 2 behind, merge base ff183ecc8050e90850b55100cc12d9eb83e6c032.

The two base-only changes are already byte-identical on this source head: docker/postgres/Dockerfile is blob 8f77cef53d84c1bb20108361b9439c38f3bc4b36 at both tips, and tests/test_checkpoint_store_container_installation.py is blob 4f8cd3490948d659869537492f185250c0abd6c4 at both tips. This is ancestry drift, not a known content deficit.

Do not treat the prior exact-head CI/Release Acceptance evidence as proof against the live base after any reconciliation. Reconcile the prerequisite ancestry only through a single reviewed branch-writer path, then regenerate every exact-head/exact-base gate. No temporary workflow, duplicate repair path, force update, merge, or protection bypass was created in this audit.

seonghobae commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Current head/base audit after non-force ancestry reconciliation:

  • source head: d23fc6eade6959fa19e22b39337c14dc65b21ab5
  • exact stacked base: efe2c81f8a9cd8301461fe8ae3ce9d5901652185
  • ancestry: 49 ahead / 0 behind
  • reconciliation was accepted only after GitHub's candidate merge commit compared as ahead-only with files=[]; no source-tree bytes changed, no force update was used
  • CI 31166277982: completed / success for this pull-request run, but this branch predates the permanent exact-source checkout assertion introduced later in the stack; the job steps do not prove git rev-parse HEAD equals this source SHA. Treat it as supporting PR-event evidence only, not exact-source merge evidence.
  • Release Acceptance 31166278005: completed / success and explicitly checked out the exact pull-request head before materializing two clean exact-head source trees
  • CodeRabbit commit status: success
  • unresolved inline review threads: 0
  • submitted review remains author COMMENTED; no qualifying independent non-author APPROVED review exists

The earlier f305.../908548... evidence and the synthetic merge result are stale/supporting evidence only. The successful CI run above is likewise not promoted to exact-source evidence without an in-job source-SHA assertion. Fresh exact-source CI is required after integration. Branch-protection, ruleset, and security surfaces unavailable through the connector remain unproven rather than assumed green, so this stacked draft is not merge-authorized.

Copy link
Copy Markdown
Contributor Author

Superseded by #78. The direct non-force predecessor merge probe #77 was deterministically non-mergeable after #60 moved to its current linearized head. The #61 feature delta was then replayed exactly onto current #60 head 6b2e19e3503ef3671aa2d2f974df7561ba1e1ca0: the five feature-modified overlap blobs were byte-identical between the former and current prerequisite baselines, and replacement head 64eea7edb28e391634a5d13c83495d20c6388c81 is exactly one commit ahead/zero behind with exactly the same 17 feature files. Fresh replacement CI 31285605089 and Release Acceptance 31285605090 are successful. This old branch is preserved as development/RED-review history only; its checks and reviews do not transfer to #78.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant