Skip to content

feat: consume TEPP terminal result contract - #656

Merged
seonghobae merged 2 commits into
feat/tepp-accepted-receipt-v21211from
feat/tepp-terminal-result-v220
Aug 25, 2026
Merged

feat: consume TEPP terminal result contract#656
seonghobae merged 2 commits into
feat/tepp-accepted-receipt-v21211from
feat/tepp-terminal-result-v220

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Product gap

TEPP accepted receipts are transport evidence, not measurements. TEPP PR #157
now publishes strict status and terminal-result v1 DTOs, so a Running
LineageWeave run can consume provider-authoritative completion without
resubmitting work or inventing a theta.

Change

  • add a pluggable TEPP status-read port without guessing a provider HTTP URL;
  • validate the exact v1 status/result shape, 64 KiB bound, RFC 3339 completion
    time, every request/receipt binding, lowercase SHA-256 digest, bounded
    identity-free summary, and terminal failure code;
  • read a stored accepted receipt on retry instead of replaying submission;
  • keep accepted/running local state Running and crash-resumable;
  • persist a succeeded terminal DTO before Succeeded, or append the validated
    terminal failure without a measurement;
  • reject a changed canonical terminal payload for the same local/remote run;
  • record ADR 0178, current gap evidence, and changelog fragment.

TEPP issue #249 owns the executable provider HTTP status route and retry-policy
evidence. This PR does not implement statistical arithmetic, a provider URL,
poll cadence, backoff coefficient, score, or theta.

Evidence

  • uv run --extra dev --extra backend pytest -q tests/test_tepp_client.py tests/test_tepp_accepted_receipt.py tests/test_analysis_run_start.py — 64 passed
  • uv run --extra dev --extra backend pytest -q — 1087 passed, 16 skipped
  • uv run --extra dev --extra backend python -m compileall -q lineageweave backend tests
  • git diff --check

Closes #277 only after the provider HTTP status service is available; this
stacked consumer slice intentionally leaves the issue open.


Open in Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 25, 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: e1c1bbb0-8126-4658-99a2-f17c7fd66436

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.

@seonghobae
seonghobae merged commit 5c662a3 into feat/tepp-accepted-receipt-v21211 Aug 25, 2026
2 of 4 checks passed

@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 3 potential issues.

Open in Devin Review

Comment on lines +295 to +296
except TeppInvalidResponse:
return TeppSubmissionOutcome(_FAILED, "tepp_result_not_persisted", None, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Invalid status payload permanently fails a receipt-bearing run

A TeppInvalidResponse from a status read maps to _FAILED (analysis_run_start.py:295-296); _deliver_tepp_measurement then appends a terminal Failed and marks the outbox delivered, unlike TeppNotAvailable which stays Running. One malformed status payload permanently fails a run that holds a durable accepted receipt, with no later retry. ADR 0178 documents fail-closed on invalid/mismatched, and no production status transport is wired yet, so impact today is nil.

Open in Devin Review

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

Comment on lines +343 to +354
existing = await conn.fetchrow(
"""
select remote_run_id, result_sha256
from analysis_run_tepp_result
where analysis_run_id = $1
""",
analysis_run_id,
)
if existing is not None:
return (
str(existing["remote_run_id"]) == remote_run_id
and str(existing["result_sha256"]) == result_sha256

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: Stored result digest recomputes the DTO, not TEPP's artifact digest

_persist_tepp_result stores result_sha256 as a hash of the full canonical terminal DTO, not TEPP's terminal['result_sha256']. The replay-rejection check (analysis_run_start.py:343-354) compares against this recomputed value. Since the DTO embeds TEPP's digest, a changed provider digest still changes the stored hash and is rejected, so the reject-changed-digest contract holds. Noted only so the column is not mistaken for TEPP's artifact digest.

Open in Devin Review

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

Comment on lines +223 to +228
state = response["run_state"]
terminal = response["terminal_result"]
if state in {"accepted", "running"}:
return terminal is None
if state not in {"succeeded", "failed"} or not isinstance(terminal, dict):
return False

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: Status validator rejects 'queued' that the submit path accepts

_valid_analysis_run_status accepts run_state only in {accepted, running, succeeded, failed}, so a queued status response is rejected and mapped to _FAILED, whereas the submit path treats queued as a valid transport state. This matches the documented v1 status contract, which omits queued; confirm TEPP's status endpoint never emits it.

Open in Devin Review

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

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