Skip to content

Add LHP NOC callback support#23

Merged
Svaag merged 1 commit into
mainfrom
feat/lhp-v1-callback-support
Jun 22, 2026
Merged

Add LHP NOC callback support#23
Svaag merged 1 commit into
mainfrom
feat/lhp-v1-callback-support

Conversation

@Svaag

@Svaag Svaag commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • parse NOC LHP-v1 pointers from approved GitHub issues
  • fetch authoritative handoff payloads from NOC CaseService using HMAC-signed internal requests
  • render request.md from structured LHP fields while keeping issue prose as sanitized untrusted background
  • optionally post accepted, investigating, change_planned, needs_human, and blocked callbacks to NOC
  • add tests for pointer parsing, signed fetches, sanitized request rendering, daemon execution, and fetch-failure blocking

Validation

  • uv run --group dev mypy src
  • uv run --group dev pytest

Notes

  • human loop:approved gate remains unchanged
  • callback/fetch require ENGINEERING_LOOP_NOC_LHP_BASE_URL, ENGINEERING_LOOP_NOC_LHP_SECRET, and ENGINEERING_LOOP_LHP_CALLBACK_ENABLED=1
  • GitHub issue body is not treated as authoritative input

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b78179332a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +190 to +191
def _signature(secret: str, method: str, path: str, timestamp: str, body: Any) -> str:
message = "\n".join([_token(method.upper()) or "GET", path, _token(timestamp), json.dumps(body, sort_keys=True, separators=(",", ":"), ensure_ascii=False)]).encode()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sign the timestamp value exactly as sent

For every signed LHP request, datetime.now(UTC).isoformat() includes +00:00, but _token(timestamp) strips the + before building the HMAC message while the unmodified value is sent in X-NOC-Loop-Timestamp. A CaseService verifier that signs the header value it receives will compute a different digest and reject both payload fetches and callbacks, so NOC-origin LHP issues will always block once signature verification is enabled.

Useful? React with 👍 / 👎.

Comment on lines +535 to +542
post_lhp_update(
lhp_pointer,
lhp_config,
update_type="change_planned",
status="change_planned",
summary=report.detail,
evidence=evidence,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep callback failures from failing completed runs

When callbacks are enabled, a transient webhook/network error from the optional change_planned callback propagates out of post_lhp_update; at this point the draft PR has already been published, but the outer except converts the daemon result to error and skips the ledger update/reporting of the PR URL. Callback delivery should be isolated or caught here so a NOC outage does not make an otherwise successful engineering run look failed.

Useful? React with 👍 / 👎.

@Svaag Svaag force-pushed the feat/lhp-v1-callback-support branch from b781793 to 81149f2 Compare June 22, 2026 21:20
@Svaag Svaag merged commit eb37b1c into main Jun 22, 2026
4 checks passed
@Svaag Svaag deleted the feat/lhp-v1-callback-support branch June 22, 2026 21:24

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81149f2fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

status="blocked",
summary=f"Could not fetch authoritative NOC LHP payload: {type(exc).__name__}: {exc}",
)
return _finish(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Count failed LHP fetch attempts in the ledger

When an approved LHP issue is selected but CaseService is unavailable or the LHP client is misconfigured, this early return exits before the update_ledger call later in daemon_once. Because the issue remains approved and the daily run count is unchanged, every timer invocation can immediately retry the same failing fetch and emit another accepted/blocked callback plus notifications, bypassing the daemon's per-day run throttle for this new failure path.

Useful? React with 👍 / 👎.

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