Skip to content

feat(cdp): let a caller bound hog and liquid rendering with a deadline - #133495

Merged
trunk-io[bot] merged 13 commits into
feat/node-store-upload-routefrom
feat/node-store-render-deadline
Nov 11, 2026
Merged

trunk-io[bot] merged 13 commits into
feat/node-store-upload-routefrom
feat/node-store-render-deadline

Conversation

@Silthus

@Silthus Silthus commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge gate: passed. fleet proof gate passes on 024fd7b (shadow diff, review at HEAD, CI green, judge fail accepted by standing rule). Layer 3 of 4 in the node-store attachment stack: #133482, #131833, this PR, then #131944. The stack merges from its top PR.

Problem

  • A send that attaches files must answer the caller within a fixed time, even while it renders a long template to size the email (PostHog/michaelr-context#77).
  • Hog and Liquid rendering stop only at their own per-invocation limits, so the caller cannot bound one render by a shorter deadline.

Note

🟢 Merge risk: low · two-way door

Changes

  • HogInputsService.buildInputs takes an optional deadline signal, and a passed deadline fails the inputs with the deadline error.
  • A Hog render or a Liquid render stops at the earlier of its own limit and the deadline. Liquid checks the deadline before each leaf, and Hog checks it again after waiting for the event loop.
  • A Hog render queued behind another render leaves the queue once the deadline passes, so buildInputs settles at once. Renders under one deadline share one abort listener.
  • Nothing passes a deadline until feat(cdp): send transactional email files by reference #131944, so no current send behaves differently.

How did you test this code?

Test rationale: the new cases in hog-inputs.service.test.ts drive buildInputs with a deadline. They fail if a render outlives the deadline, if a passed deadline is ignored while an input waits for the event loop or after a Hog input yields it, if a queued input keeps waiting behind another render after the deadline (also once one of its own leaves holds the queue), if a Liquid input of many leaves runs more than one leaf past the deadline, or if a render ends with its own error in place of the deadline error. Breaking the Liquid deadline cap, the Hog deadline passthrough, or the shared abort listener turned a case red.

  • Shadow run, the PR base e7a3351 against this head: 5,000 concurrent real execHog renders per trial, without a deadline, half under one deadline, and each under its own. Every render finished in order with its result at both commits, within trial noise; a render with its own deadline pays about 6 µs for its listener.
  • nodejs/src/cdp/dev/hog-exec-queue-bench.test.ts times queuing and dropping 50,000 renders under one deadline. CI skips dev/, so it runs by hand; a filter-based removal and a listener per waiter each went past its 1 s ceiling.

Release status

  • No feature flag controls this change

Docs update

  • None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5

Skills: /writing-tests, /writing-pr-descriptions, /stacking-prs

More context for AI agents

🤖 Generated with Claude Code

HogInputsService.buildInputs takes an optional deadline signal. A hog
render and a liquid render stop at the earlier of their own limit and the
deadline, and a passed deadline fails the inputs with the deadline error.
The deadline records when it expires, so a render checks the clock as well
as the signal. No caller passes a deadline yet, so no send changes.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus Silthus self-assigned this Nov 11, 2026
@Silthus
Silthus added this pull request to stack #133496 November 11, 2026 11:12
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

⚠️ Duplication (TypeScript) — 1 new duplicated block (worst 160 tokens)

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

First copy Second copy Lines Tokens
nodejs/src/cdp/services/hog-inputs.service.test.ts:419 nodejs/src/cdp/services/hog-inputs.service.test.ts:555 28 160

Silthus and others added 2 commits November 11, 2026 11:23
…es or after a hog yield

A liquid input renders each of its leaves in turn, and a leaf that starts
after the deadline still got a millisecond, so a large object could keep
rendering toward the invocation budget. Each leaf now checks the deadline
before it renders. A hog render could also finish just before the deadline
and then return after it, from the event-loop yield, as a success; the
deadline is now checked once more after that yield.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test now checks how far the clock moves past the deadline, which the
caller waits on, rather than how often a property was read.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@parameterai

parameterai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Risk: No findings

The only change since the last review is a merge of origin/master into the deadline branch; the PR's own deadline code (deadline.ts, hog-exec.ts, sempahore.ts, liquid.ts) is byte-identical to what was reviewed at 9d0d9e3. I reviewed the merged-in code that touches the PR's area plus the highest-risk new surfaces (credentials-service auth, admin console results, CDP integration decrypt-failure and rebuildable-inputs handling, workflows email sandbox) and found no vulnerability introduced by this change.

Sentinel reviewed 9702e97 · Review settings

@stamphog
stamphog Bot requested a review from a team November 11, 2026 11:58
@stamphog

stamphog Bot commented Nov 11, 2026

Copy link
Copy Markdown

Review requests went to the owners of the changed code. These owners were not requested because their part of this change looks trivial:

  • @PostHog/team-ingestion: Your only change is a new generated Hog bytecode fixture file used by the tests, with no runtime code or test assertions changed, so this PR doesn't need your review.

If you were listed here and want to review, you can still assign yourself as a reviewer.

@veria-ai

veria-ai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 5e7d68d: 1 Should fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

Comment thread nodejs/src/cdp/utils/hog-exec.ts Resolved

@stamphog stamphog 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.

Not approved — this change needs a human reviewer.

Re-add the stamphog label to request another review once you have addressed this.

@PostHog's current-head concern about deadline enforcement during semaphore waits remains unresolved. Make semaphore acquisition deadline-aware, remove expired waiters, and add queue-contention coverage before re-requesting review.

  • Author wrote 0% of the modified lines and has 9 merged PRs in these paths (familiarity MODERATE).
  • PostHog Review (Standard) reviewed the current head: 1 finding, posted on the PR.
  • posthog[bot] reviewed the current head.
  • @PostHog, nodejs/src/cdp/utils/hog-exec.ts: The deadline is checked only inside semaphore.run, after acquisition. In nodejs/src/cdp/utils/sempahore.ts:6–11, queued acquisition waits without cancellation, so an expired render remains pending behind preceding renders. The current code does not fix the reviewer's request for abortable acquisition and removal of expired waiters.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 102L, 4F substantive, 436L/6F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1d-complex (436L, 6F, single-area, feat)
stamphog 2.7.0 .stamphog/policy.yml @ 5e7d68d · reviewed head 5e7d68d

…ts deadline passes

A render that queues behind another one now leaves the queue when its
deadline passes, so buildInputs settles with the deadline error at once
rather than after the earlier renders finish.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed a1a6e32: 1 Should fix.

Comment thread nodejs/src/cdp/utils/sempahore.ts Resolved
An input of many hog leaves queues one waiter per leaf under one deadline.
Removing each with a filter made the abort quadratic and blocked the event
loop; a set removes each waiter at once.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 32d13cc: 1 Should fix.

This is review round 3 on this pull request. When findings keep coming back in the same code, the approach is usually the problem. Before the next fix, check whether a different design would remove the whole class of findings.

Comment thread nodejs/src/cdp/utils/sempahore.ts Resolved
Silthus and others added 5 commits November 11, 2026 12:15
The wall-clock bound on dropping queued renders moves to an in-band serial
bench, so runner contention in the parallel suite cannot fail it.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wall-clock bound belongs in a benchmark, not in a suite CI runs. The bench
now sits with the other dev-only runs, which Jest skips in CI.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ders

Each queued leaf added its own abort listener, and the signal scans its
listeners on every add, so queuing thousands of leaves under one deadline
blocked the event loop. Waiters on one signal now share a listener.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…akes the render queue

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…timers

The leaf that held the render queue waited on a fake timer, so the tests
after it found the queue taken and hung.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 024fd7b: 1 Should fix.

This is review round 4 on this pull request. When findings keep coming back in the same code, the approach is usually the problem. Before the next fix, check whether a different design would remove the whole class of findings.

A hog input that fails with the deadline's own reason rethrows it
unchanged, so a second build on the same deadline no longer fails with a
TypeError while stamping a different bytecode contract.

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…der-deadline

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus
Silthus requested a review from a team as a code owner November 11, 2026 14:10
@Silthus
Silthus requested a review from a team as a code owner November 11, 2026 14:10
@github-actions github-actions Bot added the feature/agent-infra Feature Tag: Agent infra label Nov 11, 2026

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 9702e97: 1 Must fix, 5 Should fix. This pull request is large, so the review ran in 4 parts with less depth than usual.

This is review round 5 on this pull request. When findings keep coming back in the same code, the approach is usually the problem. Before the next fix, check whether a different design would remove the whole class of findings.

…er-deadline

Refs PostHog/michaelr-context#77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the feature/agent-infra Feature Tag: Agent infra label Nov 11, 2026
@trunk-io

trunk-io Bot commented Nov 11, 2026

Copy link
Copy Markdown

This pull request is queued for merge as part of 131944, which will merge 133482, 131833, 133495, 131944.

@trunk-io
trunk-io Bot merged commit eb82e44 into master Nov 11, 2026
238 checks passed
@trunk-io
trunk-io Bot deleted the feat/node-store-render-deadline branch November 11, 2026 15:57
@trunk-io

trunk-io Bot commented Nov 11, 2026

Copy link
Copy Markdown

This pull request was merged into master as part of stacked PR 131944.

@deployment-status-posthog

deployment-status-posthog Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-11-11 16:27 UTC Run
prod-us ✅ Deployed 2026-11-11 18:14 UTC Run
prod-eu ✅ Deployed 2026-11-11 17:23 UTC Run

This table shows the posthog release only. Hogstation shows every service that this PR reaches, Kargo services included.

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