Skip to content

test(reborn): extract trigger-prompt materializer into shared test support - #5609

Merged
henrypark133 merged 2 commits into
mainfrom
reborn-test-support-materializer
Jul 4, 2026
Merged

henrypark133 merged 2 commits into
mainfrom
reborn-test-support-materializer

Conversation

@henrypark133

Copy link
Copy Markdown
Collaborator

test(reborn): extract trigger-prompt materializer into shared test support

Summary

Follow-up committed on the #5584 review thread: the Reborn integration harness's triggered-submit path (tests/support/reborn/triggered_submit.rs) hand-mirrored the production trigger-prompt materialization logic. This extracts a single shared, cfg-gated helper that calls the REAL production materializer instead.

What changed

  • crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs: new materialize_trigger_prompt_for_test under #[cfg(any(test, feature = "test-support"))] — returns (TriggerMaterializedPrompt, TurnScope) by driving the real ConversationContentRefMaterializer::materialize_prompt (authorize + validate + resolve + record + content-ref) plus one idempotent second resolve to recover the TurnScope. Compiles out of default builds (verified).
  • crates/ironclaw_reborn_composition/src/test_support/trigger_materializer.rs: re-export home.
  • tests/support/reborn/triggered_submit.rs: submit_triggered_turn_scripted now calls the shared helper instead of hand-mirroring — net −67 lines.
  • Two crate-tier unit tests: positive scope/content-ref match; negative unsafe-prompt reject.

Why it matters (harness-fidelity fix)

The old hand-mirrored path skipped validate_trusted_trigger_prompt — triggered-submit integration tests could accept prompts production would reject. Integration-level flip-check: forcing an injection-pattern prompt through the harness now correctly fails every triggered-gate scenario with "rejected by safety scan".

Verification

  • cargo build -p ironclaw_reborn_composition (default features) — new code compiled out
  • cargo build --tests --all-features; cargo clippy --all --tests --examples --all-features -- -D warnings — clean
  • Crate-tier materializer tests + reborn_group_triggers under --features integration — green

Zero production-behavior change; the wave-4 coverage PR stacks on this.

🤖 Generated with Claude Code

… (wave-4 lane C)

Committed follow-up on PR #5584's review thread: submit_triggered_turn_scripted
hand-mirrored ConversationContentRefMaterializer::materialize_prompt
(trigger_resolve_request + record_trigger_prompt + the content-ref shape,
field-by-field) instead of reusing it, and — as flagged — deliberately
SKIPPED authorize_trigger_fire and validate_trusted_trigger_prompt. Flagged
as a drift trap (trusted-trigger materialization is an ownership boundary,
AGENTS.md:61); the review agreed the fix is a #[cfg(feature = "test-support")]
materializer helper returning (TriggerMaterializedPrompt, TurnScope) living
beside the real materializer, held out of #5584 as a fast-follow with this
exact shape.

New production-crate (test-support-gated, compiles out of default builds)
surface in ironclaw_reborn_composition:
- trigger_poller_trusted_submit.rs: materialize_trigger_prompt_for_test,
  #[cfg(any(test, feature = "test-support"))] — runs the REAL production
  pipeline via ConversationContentRefMaterializer::materialize_prompt
  (authorize + validate + resolve + record + content-ref), then an
  idempotent second resolve_or_create_binding_with_trusted_scope call (safe
  — same request, same already-created binding) to also return the
  TurnScope the trait method computes internally but never exposes. Plus
  two crate-tier unit tests: positive (returned scope/content-ref match an
  independent ground-truth resolve) and negative (an unsafe prompt is
  rejected by the REAL safety validator).
- test_support/trigger_materializer.rs: pub, feature="test-support"-gated
  thin wrapper re-exported from test_support/mod.rs — the established
  wrap_project_create_capability_for_test-style pattern.

tests/support/reborn/triggered_submit.rs: submit_triggered_turn_scripted now
calls this ONE production-owned helper instead of hand-mirroring; deletes
~90 net lines of duplicated resolve/thread-record/content-ref logic.

Verified default-features build of ironclaw_reborn_composition stays
warning-free (function/import correctly compile out). Flip-checked at the
INTEGRATION level (not just the new crate-unit tests): forced an
injection-pattern prompt through submit_triggered_turn_scripted — every
triggered-gate scenario correctly failed with "rejected by safety scan",
proving the old hand-mirrored path's skip of validate_trusted_trigger_prompt
is now closed. Reverted before commit. All touched integration test bins
(reborn_group_triggers, reborn_integration_triggered_submit, plus every
other wave-4 lane-C bin) rerun green after the extraction.
Copilot AI review requested due to automatic review settings July 3, 2026 21:03

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7fb03aec-e6ca-467b-9795-3b548caa7989

📥 Commits

Reviewing files that changed from the base of the PR and between 1911c56 and 4fe4b29.

📒 Files selected for processing (3)
  • crates/ironclaw_reborn_composition/src/test_support/trigger_materializer.rs
  • crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs
  • tests/reborn_integration_triggered_submit.rs

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Test support for triggered submissions now uses the production trusted-trigger prompt materialization flow, including returning the resolved scope for harness registration.
  • Bug Fixes

    • Triggered-submission integration tests now assert the real resolved scope and verify the actual prompt content reference format.
    • Unsafe trusted-trigger prompts are rejected via the same validation pathway as real execution.
  • Tests

    • Added integration coverage for successful scripted submissions (scope + content ref) and a new case ensuring unsafe prompts are rejected with the expected safety error.

Walkthrough

Adds a test-support seam for trusted-trigger prompt materialization, exposes it from test_support, and refactors the scripted triggered-submit harness to use the shared helper and verify the returned TurnScope. Adds coverage for unsafe prompt rejection through the same path.

Changes

Trigger prompt test materializer

Layer / File(s) Summary
Production materializer helper
crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs
Adds a tuple-returning trusted-trigger materialization path that yields TriggerMaterializedPrompt and TurnScope, keeps the existing prompt-only trait behavior, and adds tests for scope equality and unsafe-prompt rejection.
test-support export seam
crates/ironclaw_reborn_composition/src/test_support/mod.rs, crates/ironclaw_reborn_composition/src/test_support/trigger_materializer.rs
Declares the new test-support module, documents it in the seam list, and re-exports materialize_trigger_prompt_for_test behind the feature gate.
Scripted triggered-submit harness
tests/support/reborn/triggered_submit.rs, tests/reborn_integration_triggered_submit.rs
Switches the scripted submit path to the shared helper, uses the returned TurnScope for gateway registration and result validation, and adds an unsafe-prompt integration test.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TestHarness
  participant submit_triggered_turn_scripted
  participant materialize_trigger_prompt_for_test
  participant trusted_trigger_fire_submitter

  TestHarness->>submit_triggered_turn_scripted: invoke with TriggerFire
  submit_triggered_turn_scripted->>materialize_trigger_prompt_for_test: materialize prompt and scope
  materialize_trigger_prompt_for_test-->>submit_triggered_turn_scripted: (materialized_prompt, turn_scope)
  submit_triggered_turn_scripted->>trusted_trigger_fire_submitter: submit(materialized_prompt)
  trusted_trigger_fire_submitter-->>submit_triggered_turn_scripted: Accepted{submitted_scope}
  submit_triggered_turn_scripted-->>TestHarness: TriggeredSubmission
Loading

Possibly related PRs

  • nearai/ironclaw#5516: Also touches the reborn triggered-submit harness and trusted-trigger submission flow in tests/support/reborn/triggered_submit.rs.
  • nearai/ironclaw#5584: Overlaps on the same triggered-submit seam and the refactor toward real trusted-trigger materialization.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has summary and verification, but it omits most required template sections like Change Type, Linked Issue, Security Impact, and rollback. Add the missing template sections and fill them out, especially Change Type, Linked Issue, Security Impact, Trust-Boundary Checklist, Database Impact, Blast Radius, Rollback Plan, and Review Follow-Through.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the change: it names the reborn test-support extraction of the trigger-prompt materializer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a production-owned test helper materialize_trigger_prompt_for_test to drive trusted-trigger prompt materialization in integration tests. This replaces hand-mirrored steps in the integration-test harness, avoiding potential drift in binding resolution, thread recording, and content reference generation. The integration-test harness has been refactored to use this helper, and unit tests have been added to verify its behavior. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ 3 Reborn crate(s) have 0 int-tier coverage (target: 0) — ironclaw_reborn_identity, ironclaw_reborn_traces, ironclaw_webui_v2

Reborn integration-tier coverage

Line coverage (Reborn crates): 17.15% — 11039 / 64362 lines

Per-crate breakdown (11 crates, lowest-covered first)
Crate Line % Covered / Total
ironclaw_reborn_identity 0% 0 / 230
ironclaw_reborn_traces 0% 0 / 6769
ironclaw_webui_v2 0% 0 / 2785
ironclaw_reborn_event_store 0.73% 6 / 825
ironclaw_reborn_config 1.31% 15 / 1142
ironclaw_product_adapter_registry 5.12% 25 / 488
ironclaw_product_workflow 7.22% 715 / 9905
ironclaw_product_adapters 12.55% 283 / 2255
ironclaw_reborn 23.38% 2036 / 8707
ironclaw_reborn_composition 25.44% 7948 / 31242
ironclaw_product_context 78.57% 11 / 14

This signal is informational: coverage never gates the PR — not the percentage, not the per-crate holes, not the 0-coverage callout.

@railway-app

railway-app Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the ironclaw-pr-5609 environment in ironclaw-ci-preview

Service Status Web Updated (UTC)
ironclaw ✅ Success (View Logs) Web Jul 4, 2026 at 3:33 am

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Code Review (multi-agent)

Intent: Extract Reborn trigger-prompt materialization into shared test support using the real production materializer to improve harness fidelity.

Stats: 3 findings (from 5 raw, 3 after dedup) across 3 files. Reviewers run: security, bugs, performance, tests, conventions, local-patterns, maintainability, approach. Reviewers failed: none. Body-only: 0

tests

  1. Medium Unsafe prompt rejection is not covered through the harness (tests/support/reborn/triggered_submit.rs:219-226, confidence 75) - anchor: tests/support/reborn/triggered_submit.rs:219
    The crate-tier helper test covers unsafe prompts directly, but no integration test drives RebornIntegrationHarness::submit_triggered_turn_scripted with an unsafe prompt to prove this public harness seam propagates the production validator rejection.

maintainability

  1. Medium Recover the scope from the real materializer instead of resolving twice (crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs:472-486, confidence 75) - anchor: crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs:472
    The helper calls materialize_prompt, then rebuilds the same trusted binding request and resolves again solely to recover TurnScope, coupling test support to idempotency and duplicated private resolve inputs. Also flagged by: performance/Low, approach/Medium.

local-patterns

  1. Low Module docs carry PR-thread archaeology (crates/ironclaw_reborn_composition/src/test_support/trigger_materializer.rs:4-13, confidence 75) - anchor: crates/ironclaw_reborn_composition/src/test_support/project_create.rs:3; crates/ironclaw_reborn_composition/src/test_support/skill_activation.rs:64
    The new module rustdoc embeds a PR review quote and AGENTS.md:61 line-number reference instead of stable seam-oriented prose, which can go stale as docs move.

Comment thread tests/support/reborn/triggered_submit.rs
Comment thread crates/ironclaw_reborn_composition/src/trigger_poller_trusted_submit.rs Outdated
Comment thread crates/ironclaw_reborn_composition/src/test_support/trigger_materializer.rs Outdated
@ironloopai

ironloopai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

IronLoop Review Status

Head: 4fe4b29b0052b62f5f02c2ecc5ecf0e183f6ec9f
Updated: 2026-07-04T03:27:07.932Z
Admission: webhook accepted the request and IronLoop persisted review state before this projection.

Current reviewers:

Reviewer State What it means Last update
none Queued No reviewer jobs scheduled yet. n/a

Recent activity:

Time Reviewer State Detail
n/a n/a Waiting No progress events recorded yet.

Commands:

  • @ironloop review
  • @ironloop review <agent-alias>
  • @ironloop status

@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-5609 July 4, 2026 03:27 Destroyed
@henrypark133
henrypark133 merged commit 3aef468 into main Jul 4, 2026
108 checks passed
@henrypark133
henrypark133 deleted the reborn-test-support-materializer branch July 4, 2026 05:45

This branch was successfully deployed

No deployments
ironclaw-ci-preview / ironclaw-pr-5609 — 4fe4b29b Deployed Jul 4, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules size: L 200-499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants