fix(contract): preserve publication error artifacts #90

Merged
pdurlej merged 1 commit from contract-pr-publication-error-artifact into main 2026-06-17 21:28:29 +02:00
Collaborator

Acting as codex.

Why

The live platform smoke in pdurlej/platform#788 showed that patchwarden contract-pr --execute can successfully produce a passing contract-run.json, then fail while publishing the Forgejo commit status when the runner token lacks write:repository.

Before this change, that failure left only partial artifacts plus the step log. That weakens Patchwarden's contract surface: operators and follow-up agents need a machine-readable reason when the policy verdict passed but publication failed.

What changed

  • Keep publication failures as technical failures (exit_code=2).
  • Still write contract-publication.json, comment.md, and the top-level contract-pr result when status/comment publication fails.
  • Add optional publication_error with stage, message, and status_code.
  • Mark the comment action as failed when publication stops before or during comment upsert.
  • Cover status-publication and comment-publication failures with regression tests and JSON Schema validation.

Verification

  • PYTHONPATH=src python3 -m pytest -q tests/test_contract_publish.py tests/test_contract_pipeline.py tests/test_artifact_schema_contract.py tests/test_cli_publish_contract.py tests/test_cli_contract_pr.py
  • PYTHONPATH=src python3 -m pytest -q
  • git diff --check
  • Local patchwarden contract-pr dry-run with PR #788-shaped metadata writes complete artifacts.

No credential, runner, workflow, or Forgejo permission changes are included.

Acting as codex. ## Why The live platform smoke in `pdurlej/platform#788` showed that `patchwarden contract-pr --execute` can successfully produce a passing `contract-run.json`, then fail while publishing the Forgejo commit status when the runner token lacks `write:repository`. Before this change, that failure left only partial artifacts plus the step log. That weakens Patchwarden's contract surface: operators and follow-up agents need a machine-readable reason when the policy verdict passed but publication failed. ## What changed - Keep publication failures as technical failures (`exit_code=2`). - Still write `contract-publication.json`, `comment.md`, and the top-level `contract-pr` result when status/comment publication fails. - Add optional `publication_error` with `stage`, `message`, and `status_code`. - Mark the comment action as `failed` when publication stops before or during comment upsert. - Cover status-publication and comment-publication failures with regression tests and JSON Schema validation. ## Verification - `PYTHONPATH=src python3 -m pytest -q tests/test_contract_publish.py tests/test_contract_pipeline.py tests/test_artifact_schema_contract.py tests/test_cli_publish_contract.py tests/test_cli_contract_pr.py` - `PYTHONPATH=src python3 -m pytest -q` - `git diff --check` - Local `patchwarden contract-pr` dry-run with PR #788-shaped metadata writes complete artifacts. No credential, runner, workflow, or Forgejo permission changes are included.
claude force-pushed contract-pr-publication-error-artifact from 1a5580b6a4 to e98dc401e4 2026-06-11 00:59:27 +02:00 Compare
Collaborator

Iskra judgment

Field Value
Target pdurlej/patchwarden#pull_request#90
Priority p2
Action patchwarden_candidate
Scores reach 4 / impact 4 / confidence 5
Piotr fit high
Effort small
Labels judge/p2, judge/patchwarden-candidate
Judge iskra via openclaw

Rationale: This is P2 Patchwarden-candidate reliability work because preserving publication error artifacts makes failed contract-pr execution auditable for operators and follow-up agents.

Caveat: Review should confirm publication_error never records secret-bearing request data and stays safe for artifact consumers.

Structured openclaw.judge.v0 payload
<!-- openclaw.judge.v0 -->
{
  "confidence": 5,
  "effort_hint": "small",
  "escalation": {
    "kind": "patchwarden_review",
    "reason": "This changes Patchwarden contract-pr failure artifacts and should be reviewed in the Patchwarden lane."
  },
  "evidence_refs": [
    {
      "note": "PR preserves machine-readable artifacts when contract-pr policy passes but Forgejo status or comment publication fails.",
      "type": "forgejo",
      "value": "pr-title-body-labels-and-target-snapshot"
    },
    {
      "note": "Body says publication failures remain technical failures with exit_code=2 while still writing contract-publication, comment, and top-level result artifacts.",
      "type": "forgejo",
      "value": "pr-body-what-changed"
    },
    {
      "note": "Body ties the change to a live platform smoke where status publication failed because the runner token lacked repository write scope.",
      "type": "forgejo",
      "value": "pr-body-why"
    }
  ],
  "impact": 4,
  "judge_actor": {
    "name": "iskra",
    "runtime": "openclaw"
  },
  "judged_at": "2026-06-12T01:14:00Z",
  "labels_to_apply": [
    "judge/p2",
    "judge/patchwarden-candidate"
  ],
  "piotr_fit": "high",
  "priority": "p2",
  "rationale_summary": "This is P2 Patchwarden-candidate reliability work because preserving publication error artifacts makes failed contract-pr execution auditable for operators and follow-up agents.",
  "reach": 4,
  "recommended_next_action": "patchwarden_candidate",
  "rerun_reason": "no_prior_judgment",
  "schema": "openclaw.judge.v0",
  "target": {
    "kind": "pull_request",
    "number": 90,
    "repo": "pdurlej/patchwarden"
  },
  "target_snapshot": {
    "body_hash": "sha256:e12197c187d31812c3f5406971810f02c4982e1547ad53212b7e243aa2dcd7d1",
    "commit_count": 1,
    "evidence_hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "head_sha": "e98dc401e413a195ab64f49233b8d7162c4acea0",
    "labels": [],
    "labels_hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "state": "open",
    "title_hash": "sha256:33a3b5d2b91fff258b6a8d1f924904ebcf39dc95899566c9e63d12b16695a24a",
    "updated_at": "2026-06-11T00:59:27+02:00"
  },
  "top_caveat": "Review should confirm publication_error never records secret-bearing request data and stays safe for artifact consumers."
}
<!-- /openclaw.judge.v0 -->
### Iskra judgment | Field | Value | | --- | --- | | Target | `pdurlej/patchwarden#pull_request#90` | | Priority | p2 | | Action | patchwarden_candidate | | Scores | reach 4 / impact 4 / confidence 5 | | Piotr fit | high | | Effort | small | | Labels | `judge/p2`, `judge/patchwarden-candidate` | | Judge | `iskra` via `openclaw` | **Rationale:** This is P2 Patchwarden-candidate reliability work because preserving publication error artifacts makes failed contract-pr execution auditable for operators and follow-up agents. **Caveat:** Review should confirm publication_error never records secret-bearing request data and stays safe for artifact consumers. <details> <summary>Structured openclaw.judge.v0 payload</summary> ```json <!-- openclaw.judge.v0 --> { "confidence": 5, "effort_hint": "small", "escalation": { "kind": "patchwarden_review", "reason": "This changes Patchwarden contract-pr failure artifacts and should be reviewed in the Patchwarden lane." }, "evidence_refs": [ { "note": "PR preserves machine-readable artifacts when contract-pr policy passes but Forgejo status or comment publication fails.", "type": "forgejo", "value": "pr-title-body-labels-and-target-snapshot" }, { "note": "Body says publication failures remain technical failures with exit_code=2 while still writing contract-publication, comment, and top-level result artifacts.", "type": "forgejo", "value": "pr-body-what-changed" }, { "note": "Body ties the change to a live platform smoke where status publication failed because the runner token lacked repository write scope.", "type": "forgejo", "value": "pr-body-why" } ], "impact": 4, "judge_actor": { "name": "iskra", "runtime": "openclaw" }, "judged_at": "2026-06-12T01:14:00Z", "labels_to_apply": [ "judge/p2", "judge/patchwarden-candidate" ], "piotr_fit": "high", "priority": "p2", "rationale_summary": "This is P2 Patchwarden-candidate reliability work because preserving publication error artifacts makes failed contract-pr execution auditable for operators and follow-up agents.", "reach": 4, "recommended_next_action": "patchwarden_candidate", "rerun_reason": "no_prior_judgment", "schema": "openclaw.judge.v0", "target": { "kind": "pull_request", "number": 90, "repo": "pdurlej/patchwarden" }, "target_snapshot": { "body_hash": "sha256:e12197c187d31812c3f5406971810f02c4982e1547ad53212b7e243aa2dcd7d1", "commit_count": 1, "evidence_hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "head_sha": "e98dc401e413a195ab64f49233b8d7162c4acea0", "labels": [], "labels_hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "state": "open", "title_hash": "sha256:33a3b5d2b91fff258b6a8d1f924904ebcf39dc95899566c9e63d12b16695a24a", "updated_at": "2026-06-11T00:59:27+02:00" }, "top_caveat": "Review should confirm publication_error never records secret-bearing request data and stays safe for artifact consumers." } <!-- /openclaw.judge.v0 --> ``` </details>
pdurlej deleted branch contract-pr-publication-error-artifact 2026-06-17 21:28:29 +02:00
Sign in to join this conversation.
No reviewers
No labels
agent/claude-code
agent/codex
agent/gemini
agent/hermes
agent/iskra
agent/ollama
agent/patchwarden
area:business-model
area:competitive
area:discovery
area:forgejo
area:metrics
area:product-strategy
area:v0-core
cagan-grade-approved
client:platform
dependency/blocked
dependency/blocks-others
dependency/cross-repo
dependency/needs-confirmation
domain:agents
domain:ci
domain:docs
domain:forgejo
domain:infra
domain:memory
domain:runtime
domain:signal
domain:ux
flow/architecture
flow/blocked
flow/deployed
flow/done
flow/implementation
flow/intake
flow/maintained
flow/observed
flow/ready
flow/refining
flow/retired
flow/review
judge/codex-candidate
judge/hermes-candidate
judge/low-confidence
judge/needs-refinement
judge/operator-needed
judge/p0
judge/p1
judge/p2
judge/p3
judge/park
judge/patchwarden-candidate
judge/stale-priority
kind/adr
kind/bug
kind/chore
kind/feature
kind/infra
kind/ops
kind/refactor
kind/research
kind:artifact
kind:decision
kind:dogfood
kind:epic
kind:implementation
kind:research
merge/auto
merge/manual
merge/manual-dependency-conflict
merge/manual-failing-tests
merge/manual-merge-conflict
merge/manual-missing-review
merge/manual-operator-preference
merge/manual-red-zone
merge/manual-security-sensitive
merge/manual-unclear-scope
merge/manual-unknown
mode:operator-only
mode:patchwarden-iskra-approved
mode:safe-auto
observed/erroring
observed/needs-followup
observed/pending
observed/retire-candidate
observed/unused
observed/used
priority:p0
priority:p1
priority:p2
priority:p3
ready-for-agent
review:claude-reviewed
review:codex-reviewed
review:dziadek-reviewed
review:needs-human
safety:external-write
safety:no-prod-mutation
safety:prod-impact
safety:secret-touch
size/large
size/medium
size/small
size/tiny
size/unknown
source/adr
source/agent-generated
source/manual
source/operator-chat
source/voice-note
status:blocked
status:blocked-on-discovery
status:cagan-grade-review-pending
status:codex-ready
status:merged:pending-evidence
status:needs-evidence
status:needs-operator-decision
status:operator-needed
status:parked
tier:0-anchor
tier:0-platform-substrate
tier:1-core
tier:1-iskra-value-layer
tier:2-supporting
tier:2-tools-products-modules
type:bug
type:chore
type:docs
type:feat
type:policy
type:research
wave:1-foundation
wave:2-positioning
wave:3-validation
wave:4-economics
wave:5-operating
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/patchwarden!90
No description provided.