Skip to content

feat: persist TEPP accepted receipts as transport evidence (v2.12.11) - #496

Merged
seonghobae merged 19 commits into
feat/oidc-return-remember-login-v21219from
feat/tepp-accepted-receipt-v21211
Aug 24, 2026
Merged

feat: persist TEPP accepted receipts as transport evidence (v2.12.11)#496
seonghobae merged 19 commits into
feat/oidc-return-remember-login-v21219from
feat/tepp-accepted-receipt-v21211

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Product result

A live TEPP accepted / queued / running envelope that carries a remote run id no longer looks like a product failure. The local analysis run stays Running and stores the receipt as transport evidence. The receipt is not a calibrated measurement and does not invent a theta.

Root cause

ADR 0022 treated any non-completed TEPP envelope as Failed / tepp_result_not_persisted. TEPP's published AnalysisRunAccepted is a durable submission receipt, not a temporal measurement. Treating it as Failed hid a successful accept; treating it as Succeeded would manufacture a scientific result from transport evidence.

Issue #277. Completed-result polling remains blocked on ContextualWisdomLab/TEPP#156.

What this head changes

  • Classify TEPP envelopes: missing transport → Failed / tepp_not_available; completed+result → Succeeded + analysis_run_tepp_result; accepted/queued/running with a remote run id → persist analysis_run_tepp_accepted_receipt and stay Running; empty accepted → Failed / tepp_result_not_persisted.
  • Do not append a terminal status and do not mark the outbox delivered on a valid receipt (ADR 0023 / ADR 0162).
  • Seed stays Failed / tepp_not_available. Do not change seed to Running.
  • Detail may attach {remote_run_id, accepted_status_code, received_at}. Next-action copy says the receipt is not a calibrated score.
  • Login uses returnUrlFromLocation + rememberOidcReturnUrl and no longer mounts Admin settings with an undefined token, so this head's frontend gate is not poisoned by main.

Migration 0171 only (not 0103/0104/0105). ADR 0162 amends ADR 0022.

Local verification

Exact head: 288125acb1e6939ca0b99c0c4af2aacaadaffc79

  • uv run --extra dev --with asyncpg --with redis pytest tests/test_tepp_accepted_receipt.py tests/test_analysis_run_start.py tests/test_seed_tepp_run.py tests/test_migration_replay.py tests/test_static_sql_review_contracts.py: 48 passed
  • pnpm exec tsc -b: passed
  • pnpm exec vitest run src/App.test.tsx src/oidcReturnUrl.test.ts: 84 passed

No real records, identifiers, provider credentials, or runtime secrets are included. Synthetic fixtures only.

Remaining protected gates


Open in Devin Review

A live AnalysisRunAccepted envelope with a remote run id stays Running
and is stored as transport evidence. It is not a measurement and does
not invent a theta. Empty accepted envelopes and missing transport stay
Failed. Login no longer mounts Admin settings with an undefined token.

Refs: #277

Copy link
Copy Markdown
Contributor Author

@opencode-agent independent exact-head review requested. This identity cannot self-approve.

Head 5c0de352a4186d0ae8f22af476a6e87b3584a3f3:

  • Valid TEPP accepted/queued/running envelopes with a remote run id persist as transport evidence and leave the local run Running.
  • The receipt is not a measurement and does not invent a theta. Empty accepted envelopes stay Failed / tepp_result_not_persisted. Seed stays Failed / tepp_not_available.
  • Outbox stays claimed (not delivered) until a terminal status. Completed-result polling remains TEPP#156.
  • Login no longer mounts Admin settings with an undefined token.
  • Local pytest 48 passed; tsc -b passed; App + OIDC vitest 84 passed.

Please review this exact head. Squash-merge only after independent approval and current checks. Issues #79 and #87 stay open.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 09ed016f-ca2b-4e3d-aa55-89ab82c35445

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

github-advanced-security[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Resolved the live ADR-number collision on exact head 49fae1bd2ca1b5aea91a3d967a3004a17812f107 by keeping the earlier ontology claimant at ADR 0157 and renumbering this later TEPP accepted-receipt ADR to the next monotonic free number, ADR 0162. The change is reference-only: the ADR file/title, exact architecture/docstring/migration references, and the existing ADR contract test name/path. No product semantics or dependencies changed.\n\nPush-time ownership audit: protected main and all 53 open PR changed-file sets had no docs/adr/0162-* claimant; >100-file PRs #258/#417/#490 were REST-paginated separately. Exact composed-head validation: uv run --frozen --extra dev --extra backend pytest -q tests/test_documentation_hygiene.py tests/test_tepp_accepted_receipt.py18 passed; stale ADR 0157/old path/test-name scan empty; git diff HEAD^ --check clean.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Exact-head follow-up at e40a9a12b5f1f00997a77f1336860069872e511b closes the bounded receipt replay test gap only:

  • changed remote_run_id for an existing local receipt returns False without another insert;
  • changed request_sha256 for the same remote run returns False without another insert.

No production code or fixture abstraction changed. Fresh exact-head CodeGraph worktree evidence:

  • receipt/start/migration plus documentation hygiene: 36 passed in 2.95s;
  • git diff --check: passed;
  • diff: tests/test_tepp_accepted_receipt.py, +42/-0.

Hosted checks must evaluate this new head; no prior-head result is being reused.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

Still needs independent exact-head APPROVE. Author/bot COMMENTED reviews are not an approval. Do not self-approve.

devin-ai-integration[bot]

This comment was marked as resolved.

github-code-quality[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Resolved the current open-stack migration filename collision without changing ADR 0162 or TEPP receipt behavior.

  • renamed only the idempotent migration and rollback from 0106 to unused 0171
  • updated the existing replay selector, ADR reference, docstring, and tests
  • local exact-head validation: 55 passed; shellcheck docker/postgres-init/migrate.sh; sh -n docker/postgres-init/migrate.sh; git diff --check

Exact pushed head: 288125ac.

devin-ai-integration[bot]

This comment was marked as resolved.

…v21219' into feat/tepp-accepted-receipt-v21211
Existing volumes still replay 0171. A Running TEPP receipt names the
next action as a status check, not a calibrated score.
@seonghobae
seonghobae changed the base branch from main to feat/oidc-return-remember-login-v21219 August 23, 2026 22:24

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +988 to +998
elif outcome.persist_kind == _PERSIST_RECEIPT and outcome.envelope is not None:
if await _persist_tepp_accepted_receipt(
conn,
analysis_run_id=analysis_run_id,
envelope=outcome.envelope,
request=request,
knowledge_cutoff=locked["knowledge_cutoff"],
):
return False
status_code = _FAILED
failure_code = "tepp_receipt_not_persisted"

@devin-ai-integration devin-ai-integration Bot Aug 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Conflicting re-check revokes a durable receipt

A re-check envelope classified as a receipt but carrying a remote run id or request digest that differs from the stored receipt makes _persist_tepp_accepted_receipt return False, so analysis_run_start.py:988-998 marks the run Failed / tepp_receipt_not_persisted and delivers the outbox. This revokes a previously Running acceptance. ADR 0162 documents this as fail-closed, so it reads as intentional.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

This PR added one new, properly-documented nosemgrep suppression
(with a preceding Safe SQL: reason, matching the required pattern)
but never updated the hardcoded EXPECTED_SQL_SUPPRESSION_COUNT
constant. Verified all 39 suppressions pass the format checks; only
the count was stale. Verified: 1054 Python tests pass.
Resolved 6 conflicts:
- CHANGELOG.md: reordered this PR's 2.12.11 entry below the base's
  now-renumbered 2.12.20 entry (no more duplicate 2.12.19 version).
- docker/postgres-init/migrate.sh: unioned migration allowlist across
  0171 (this PR's TEPP-receipt migration) and 0173 (base's clock-skew
  migration).
- tests/test_migration_replay.py: kept both replay tests, ordered
  numerically.
- backend/app/analysis_run_start.py: base's clock-skew fix (#524)
  dropped the timestamp parameter from _append_status entirely (ADR
  0171 - never bind Python datetime.now as occurrence). Removed this
  PR's now-incompatible now/finished clamping and the stale extra
  positional arg to _append_status, which would have raised a
  TypeError at runtime had it been merged as a naive union.
- tests/test_analysis_run_start.py: merged import lists.
- frontend/src/App.test.tsx: kept this PR's superset assertion
  (checks both sessionStorage and localStorage via the shared
  OIDC_RETURN_URL_STORAGE_KEY constant).

Verified: 1059 Python tests pass, frontend build/lint clean, 362
frontend tests pass.
Resolve migrate.sh whitelist conflict as a union: keep 0171 (this
PR's TEPP accepted-receipt migration) and add 0172 + 0177 (landed
from base via PR #527/#529).
@seonghobae
seonghobae merged commit a861ce0 into feat/oidc-return-remember-login-v21219 Aug 24, 2026
4 checks passed
seonghobae added a commit that referenced this pull request Aug 24, 2026
- Snapshot: protected main 63876eb (#422), 37 open PRs, 19 open issues.
- Record the org-wide Strix provider failure (NIM ~70s / OpenAI-direct ~5s
  exits) and its durable repair ContextualWisdomLab/.github#1263, including
  the ten base-merged paths the prior merge commit had reverted and how they
  were restored.
- Record the ADR 0109 shared login repair applied to eight pre-repair
  branches (#521, #522, #552-556 set, #558, #560), verified locally with
  frontend lint/test/build before each push.
- Replace stale §3 inventory with the current 37-head queue grouped by
  product surface, SKOS/leftover-map ladder, repairs, integration, and docs.
- Refresh §5 rows whose referenced PRs have since landed (#496/#507/#515,
  #544/#559 channel-weight hardening) and rewrite §10 as the autonomous
  ascending-order merge loop.
- Note #368 closed as superseded.

Co-authored-by: seonghobae <seonghobae@users.noreply.github.com>
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.

2 participants