Skip to content

refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package) - #84858

Open
andrexibiza wants to merge 8 commits into
NousResearch:mainfrom
andrexibiza:campaign/webhook-rendering-extraction
Open

refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package)#84858
andrexibiza wants to merge 8 commits into
NousResearch:mainfrom
andrexibiza:campaign/webhook-rendering-extraction

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Part of the Webhook Feature Package Feature Package.

Behavior-preserving verbatim extraction of the prompt-rendering cluster from gateway/platforms/webhook.py into gateway/platforms/webhook_rendering.py:

  • _render_prompt (dot-notation payload access, {__raw__} truncation, {event_type})
  • _render_delivery_extra (string template rendering, non-string passthrough)

Composed as WebhookRenderingMixin into WebhookAdapter MRO. Call sites resolve through the mixin.

Verification (57 passed)

  • tests/gateway/test_webhook_rendering_seam.py — new seam test
  • tests/gateway/test_webhook_adapter.py + test_webhook_signature_rate_limit.py + test_webhook_integration.py + test_webhook_dynamic_routes.py + test_webhook_deliver_only.py + test_webhook_profile_admission_seam.py — no behavior change
  • git diff --check clean; webhook.py 1308 lines, webhook_rendering.py 60 lines (both < 2000)

5×2×3

Blind implementer + blind witness on this lane. Also made the profile admission seam test MRO-robust (assert membership + method identity instead of exact prefix) so adding further mixins does not break the seam contract.

Related #85054

andrexibiza and others added 5 commits August 12, 2026 16:33
Behavior-preserving verbatim extraction of _render_prompt and
_render_delivery_extra from gateway/platforms/webhook.py into
gateway/platforms/webhook_rendering.py as WebhookRenderingMixin,
composed into WebhookAdapter MRO.

Also make the profile admission seam test MRO-robust (assert membership
+ method identity instead of an exact prefix) so adding further mixins
does not break the seam contract.
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Aug 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #84835: this stacked extraction also drops multiplex_profile_allowlist when resolving served profiles. Please resolve that admission regression before this slice is merged; the rendering extraction remains complementary to #84849.

@andrexibiza andrexibiza changed the title refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Revolution) refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package) Aug 15, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package)

Byte-identical extraction, and test_webhook_rendering_seam.py covers the real semantics rather than just the seam. Observations:

  1. Truncation can emit invalid JSON inside template output_render_prompt truncates serialized dict/list values at 2000 chars (json.dumps(value, indent=2)[:2000]), which can cut mid-string and produce a fenced block that is not parseable JSON. [SUPERSEDED by #90236] webhook Task 10 historical campaign lineage #85523 fixes the {__raw__} case with a structural envelope; consider applying the same envelope treatment to nested-value truncation so downstream parsers never receive a raw character slice.

  2. Router extraction duplicated across the series — the hermes_cli/web_routers/webhooks.py + web_server.py change is identical in refactor(webhook): extract webhook API router + profile admission (Webhook Feature Package) #84835/refactor(webhook): extract signature validation into webhook_auth mixin (Webhook Feature Package) #84849/refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package) #84858/refactor(webhook): extract delivery into webhook_delivery mixin (Webhook Feature Package) #84939 against the same base; merge conflicts are guaranteed unless it lands once and the others rebase.

  3. _render_delivery_extra does not recurse — string values are rendered as templates but nested dict/list values pass through unrendered; if a deliver_extra contains a nested {"repo": "{org}/x"} template, it is not expanded. Pre-existing behavior, but worth documenting since the extraction is the moment to write it down.

  4. Good: the {__raw__} 4000-char cap and the missing-key passthrough ({key} literal) are preserved exactly.

Copy link
Copy Markdown
Contributor Author

Decision recorded against current main 3a034356a237341452b7afebd3a2bfd21021609f and the live webhook train.

Do not land this old stacked head independently. The canonical order is:

  1. refactor(webhook): extract webhook API router + profile admission (Webhook Feature Package) #84835 owns the REST-router/profile-admission extraction once; all duplicate router/profile commits must disappear from sibling branches.
  2. Restack refactor(webhook): extract prompt rendering into webhook_rendering mixin (Webhook Feature Package) #84858 as a rendering-only extraction on that canonical base, preserving the multiplex allowlist fix and proving the MRO/seam.
  3. refactor(webhook): isolate explicit provider signature authority #85318 carries the explicit signature contract and supersedes the older auth-extraction-only shape in refactor(webhook): extract signature validation into webhook_auth mixin (Webhook Feature Package) #84849.
  4. Retarget [SUPERSEDED by #90236] webhook Task 10 historical campaign lineage #85523 onto the extracted owners and finish intake/idempotency/raw-payload behavior there.

That order makes webhook_rendering.py the canonical owner before Task 10 changes {__raw__:N}, total UTF-8 envelope bounds, nested-value structural truncation, and default-prompt rendering. It also prevents the same router extraction from landing four times.

The current 10-file head is not landable: it includes duplicated structural commits and preserves rendering behavior that Task 10 must change. Narrow, rebase in the order above, recompute the rendering golden window, then run the composed #85318/#85523 webhook matrix.

@alt-glitch alt-glitch added P3 Low — cosmetic, nice to have platform/webhook Webhook / API server and removed P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/webhook Webhook / API server sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants