Skip to content

feat(product_workflow): expose get_run_state on RebornServicesApi facade#3735

Open
italic-jinxin wants to merge 2 commits into
reborn-integrationfrom
feat/services-facade-3627
Open

feat(product_workflow): expose get_run_state on RebornServicesApi facade#3735
italic-jinxin wants to merge 2 commits into
reborn-integrationfrom
feat/services-facade-3627

Conversation

@italic-jinxin
Copy link
Copy Markdown
Contributor

@italic-jinxin italic-jinxin commented May 17, 2026

Summary

Adds the fourth M2 facade method called out in issue #3627: a WebUI-facing
get_run_state on RebornServicesApi so route handlers can read run state
without importing TurnCoordinator, HostRuntime, dispatcher, run-state
stores, or DB stores. The other three methods named in the ticket
(submit_turn, cancel_run, resolve_gate) already exist on the trait;
this PR completes the set.

The new RebornGetRunStateResponse is a stable DTO suitable for M1 and M5:
it deliberately omits TurnRunState's M3-internal fields — raw scope,
source_binding_ref, reply_target_binding_ref, and resolved_model_route
— and mirrors the wire shape of RebornSubmitTurnResponse for
turn_id / resolved_run_profile_id / resolved_run_profile_version.

get_run_state reuses the existing assert_thread_owned_by ownership probe
that cancel_run and resolve_gate already enforce, so a caller sharing a
(tenant, agent, project) scope cannot read another user's run by guessing
run_id. The cross-user case surfaces as NotFound rather than Forbidden
to avoid leaking the existence of another user's thread.

Method locations

Method Trait declaration Impl
submit_turn RebornServicesApi (existing) RebornServices::submit_turn
cancel_run RebornServicesApi (existing) RebornServices::cancel_run
resolve_gate RebornServicesApi (existing) RebornServices::resolve_gate
get_run_state RebornServicesApi (new) RebornServices::get_run_state (new)

All four live in crates/ironclaw_product_workflow/src/reborn_services.rs.

Acceptance criteria

  • ✅ Route handlers can submit/cancel/resolve/read state through one trait
    whose surface depends only on WebUiAuthenticatedCaller, request DTOs,
    and RebornServicesError. The static facade_source_avoids_forbidden_runtime_dependencies
    grep test guards the import boundary.
  • ✅ Facade only touches TurnCoordinator through the published M3 method
    set (submit_turn, resume_turn, cancel_run, get_run_state).
  • ✅ Outputs are stable DTOs in reborn_services/types.rs — strongly typed
    newtypes for run IDs/cursors/refs, String for fields that already
    appear stringified elsewhere in the facade (turn_id,
    resolved_run_profile_id), and explicit omission of M3-internal fields.
  • ✅ Caller-level tests in tests/reborn_services_contract.rs drive the
    trait directly with a fake TurnCoordinator and a real or stubbed
    SessionThreadService. Tests cover: stable-DTO redaction, validation
    for blank/non-UUID inputs, ScopeNotFoundNotFound mapping, and
    the cross-user ownership probe (which must short-circuit before
    TurnCoordinator is touched). The pre-existing facade-source grep
    test continues to lock the M2/M3 import boundary.
  • ✅ Errors flow exclusively through RebornServicesError /
    RebornServicesErrorCode (the M2 taxonomy). The validation test
    asserts that error JSON does not contain TurnCoordinator or
    HostRuntime substrings.

Change Type

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI/Infrastructure
  • Security
  • Dependencies

Linked Issue

Closes #3627

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all --benches --tests --examples --all-features -- -D warnings
  • cargo build
  • Relevant tests pass:
  • cargo test --features integration if database-backed or integration behavior changed
  • Manual testing:
  • If a coding agent was used and supports it, review-pr or pr-shepherd --fix was run before requesting review

Security Impact

Database Impact

Blast Radius

Rollback Plan

Review Follow-Through


Review track:

@italic-jinxin italic-jinxin self-assigned this May 17, 2026
@github-actions github-actions Bot added size: M 50-199 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: experienced 6-19 merged PRs labels May 17, 2026
@italic-jinxin italic-jinxin requested a review from serrrfirat May 17, 2026 13:47
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 the get_run_state endpoint to the RebornServices API, enabling the retrieval of run states through a stable DTO. The implementation includes mandatory ownership verification to prevent unauthorized cross-user access and provides comprehensive test coverage for validation, error mapping, and security. Review feedback highlighted that the security checks and the structure of the data transfer objects align with best practices for resource authorization and API stability.

Comment thread crates/ironclaw_product_workflow/src/reborn_services.rs
Comment thread crates/ironclaw_product_workflow/src/reborn_services/types.rs
Copy link
Copy Markdown
Collaborator

@serrrfirat serrrfirat left a comment

Choose a reason for hiding this comment

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

Approved after focused review passes.

Reviewed from three angles:

  • Security/correctness: no findings. The new get_run_state path validates request IDs, performs the thread ownership probe before coordinator access, maps missing run state through the stable facade error taxonomy, and does not expose backend/internal error details.
  • Paranoid review: no Critical/High/Medium/Low/Nit findings across correctness, edge cases, DTO leakage, error handling, architecture boundary, and test coverage.
  • Multi-tenancy correctness: no findings. The method derives TurnScope from the authenticated caller, verifies thread ownership with owner_user_id before calling TurnCoordinator, returns 404 for cross-user probes, and has caller-level regression coverage proving cross-user reads short-circuit before coordinator access.

Validation checked locally:

  • cargo test -p ironclaw_product_workflow
  • cargo clippy -p ironclaw_product_workflow --all-targets -- -D warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: experienced 6-19 merged PRs risk: low Changes to docs, tests, or low-risk modules size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reborn WebUI Beta] Implement RebornServices submit/cancel/resolve facade methods

2 participants