Skip to content

Ci/fmt probe - #5415

Open
Mustaqeem66 wants to merge 7 commits into
tinyhumansai:mainfrom
Mustaqeem66:ci/fmt-probe
Open

Ci/fmt probe#5415
Mustaqeem66 wants to merge 7 commits into
tinyhumansai:mainfrom
Mustaqeem66:ci/fmt-probe

Conversation

@Mustaqeem66

@Mustaqeem66 Mustaqeem66 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • What changed and why.
  • Keep this to 3-6 bullets focused on user-visible or architecture-impacting changes.

Problem

  • What issue or risk this PR addresses.
  • Include context needed for reviewers to evaluate correctness quickly.

Solution

  • How the implementation solves the problem.
  • Note important design decisions and tradeoffs.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/ci-lite.yml. Run pnpm test:coverage and pnpm test:rust locally; PRs below 80% on changed lines will not merge.
  • Coverage matrix updated — added/removed/renamed feature rows in docs/TEST-COVERAGE-MATRIX.md reflect this change (or N/A: behaviour-only change)
  • All affected feature IDs from the matrix are listed in the PR description under ## Related
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md)
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Runtime/platform impact (desktop/mobile/web/CLI), if any.
  • Performance, security, migration, or compatibility implications.

Related

  • Closes:
  • Follow-up PR(s)/TODOs:

AI Authored PR Metadata (required for Codex/Linear PRs)

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

  • Key:
  • URL:

Commit & Branch

  • Branch:
  • Commit SHA:

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck
  • Focused tests:
  • Rust fmt/check (if changed):
  • Tauri fmt/check (if changed):

Validation Blocked

  • command:
  • error:
  • impact:

Behavior Changes

  • Intended behavior change:
  • User-visible effect:

Parity Contract

  • Legacy behavior preserved:
  • Guard/fallback/dispatch parity checks:

Duplicate / Superseded PR Handling

  • Duplicate PR(s):
  • Canonical PR:
  • Resolution (closed/superseded/updated):

Summary by CodeRabbit

  • Bug Fixes

    • Improved deduplication settlement across successful and failed flow runs.
    • Preserved run-specific deduplication behavior when flows are edited during execution.
    • Ensured commit and release operations remain properly serialized.
    • Improved handling of disabled flows, duplicate dispatches, and graph changes.
  • Tests

    • Added comprehensive coverage for event handling, deduplication, flow edits, and fallback scenarios.

Mustaqeem66 and others added 5 commits August 3, 2026 22:57
Moves the `mod tests` block out of `flows/bus.rs` into a sibling
`bus_tests.rs`, using the `#[cfg(test)] #[path = "..."] mod tests;`
convention already used throughout this crate (`subconscious/factory.rs`,
`skills/ops.rs`, `config/schema/channels.rs`, `platform/about_app/catalog.rs`,
and ~170 other sites).

Pure move: the test bodies are unchanged apart from being dedented one
level now that they are no longer nested inside an inline `mod tests { .. }`.
Also adds the tests for the tinyhumansai#5268 item 2 fix (settle dedup state from the
graph the run actually executed).
Closes tinyhumansai#5268 (item 2).

`DedupCommitSubscriber` settled a finished run's `dedup` nodes by reading
the flow's CURRENT saved graph. A flow edited while a run was still in
flight was therefore mis-settled: a `dedup` node the run had written
`tentative` keys under, but which was deleted or renamed before
`FlowRunFinished` fired, was no longer found — so those keys were neither
committed nor released, and the items silently reprocessed on the flow's
next run. The converse also held: a node added after the run started was
settled by a run that never executed it.

`DedupCommitSubscriber` now also handles `DomainEvent::FlowRunStarted`
(already published by `flows::ops::flows_run{,_detached}` right after the
`flow_runs` row insert, and already tagged "cron" so the existing domain
filter admits it) and pins that run's dedup node ids into the existing
per-flow `flow_state` KV table under `dedup::run_nodes:<run_id>`.
Settlement prefers that snapshot and clears it once the run is settled.

- No schema migration: reuses the `flow_state` table the dedup keys
  already live in. The `dedup::` double-colon prefix cannot collide with
  the engine's `dedup:<node_id>:<committed|tentative>` keys.
- Zero added I/O for the common case: a graph with no `dedup` node writes
  no snapshot at all, so an absent key stays an unambiguous "no snapshot".
- Falls back to the saved graph when no snapshot exists (runs in flight
  across the upgrade, resumed runs, or a failed snapshot write), so the
  degraded path is exactly the historical behaviour.

Also moves the test module to `bus_tests.rs` per the crate-wide
`#[cfg(test)] #[path = "..."] mod tests;` convention.
CI's `cargo fmt --all -- --check` gate rejected the previous revision.
Three formatting-sensitive constructs are reworked, each matched against a
formatter-clean precedent already in the tree rather than guessed at:

* `dedup_node_ids_in` broke a method chain as `flow.graph` / `.nodes` / …,
  merging the chain parent with its first field access. The same expression
  elsewhere in this file is written with the parent alone on its own line, so
  the receiver is now bound to a `nodes` local and the chain starts from it —
  the shape `flows/ops.rs` already uses at the same indent level.

* `clear_run_snapshot` had an `if let Err(e) = store::kv_delete(...)` line
  sitting exactly on the 100-column limit. The key is hoisted into a local,
  which shortens the line and matches how `snapshotted_dedup_node_ids`
  immediately above already builds the same key.

* `handle` had been rewritten from the original `if let` into a `match` with a
  nested `match` inside a block arm, which changed formatting that was
  previously known-good for no behavioural benefit. The `FlowRunFinished`
  block is restored verbatim and the new `FlowRunStarted` handling is a short
  `if let` above it, delegating to a new `snapshot_run_nodes` method that
  holds the graph load.

No behaviour change: the same snapshot is written at run start, read at
settlement, and cleared afterwards. Pure formatting and extraction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Mustaqeem66
Mustaqeem66 requested a review from a team August 5, 2026 19:39
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change snapshots deduplication nodes when a flow run starts, uses the snapshot during completion settlement, falls back to the saved graph when needed, and removes the snapshot afterward. It also moves bus tests into bus_tests.rs and adds broad event-bus coverage.

Changes

Run-scoped deduplication settlement

Layer / File(s) Summary
Run-start snapshot capture
src/openhuman/flows/bus.rs, src/openhuman/flows/bus_tests.rs
FlowRunStarted captures deduplication-node IDs in run-scoped flow state. Tests cover isolation, graph changes, key compatibility, and event-driven capture.
Snapshot-based settlement and locking
src/openhuman/flows/bus.rs, src/openhuman/flows/bus_tests.rs
FlowRunFinished settles nodes from the snapshot or saved-graph fallback. Per-flow locking, cleanup, success, failure, cancellation, and concurrency behavior are tested.
Event-bus behavior coverage
src/openhuman/flows/bus.rs, src/openhuman/flows/bus_tests.rs
The inline tests move to bus_tests.rs. Tests cover trigger matching, dispatch deduplication, disabled flows, digest generation, filtering, rendering, and metadata.

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

Sequence Diagram(s)

sequenceDiagram
  participant FlowRunStarted
  participant FlowStateStore
  participant FlowRunFinished
  participant DedupNodes
  FlowRunStarted->>FlowStateStore: save dedup-node IDs by run ID
  FlowRunFinished->>FlowStateStore: load snapshot or saved-graph fallback
  FlowRunFinished->>DedupNodes: commit or release deduplication keys
  FlowRunFinished->>FlowStateStore: delete run snapshot
Loading

Possibly related PRs

Suggested reviewers: graycyrus

Poem

A rabbit watched the flow runs start,
And stored each node ID by heart.
At finish, keys commit or clear,
With locks that keep each path sincere.
Tests now hop through every chart.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the CI and Rust formatting aspect of the changes, but it does not describe the primary dedup settlement and test changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

Warning

⚠️ This pull request shows signs of AI-generated slop (redundant_comments, description_diff_mismatch, ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

The PR introduces per-run dedup-node snapshots intended to preserve settlement behavior when flows are edited during execution, and moves the event-bus unit tests into a dedicated file.

  • Records dedup-node IDs when FlowRunStarted is handled.
  • Prefers the snapshot when settling FlowRunFinished.
  • Clears snapshots after settlement.
  • Extracts the existing and newly added tests into bus_tests.rs.

Confidence Score: 4/5

The PR does not yet appear safe to merge because flow edits and authoritative empty snapshots can still make one run settle dedup state for the wrong graph or another overlapping run.

The start handler asynchronously reloads the saved flow instead of preserving the graph already selected for execution, and dedup-free runs write no authoritative snapshot, causing finish-time fallback to the current graph. These paths can leave executed tentative keys unsettled or commit/delete tentative state belonging to another run.

Files Needing Attention: src/openhuman/flows/bus.rs

Important Files Changed

Filename Overview
src/openhuman/flows/bus.rs Adds start-time dedup snapshots and finish-time cleanup, but the two previously reported graph-consistency paths remain reachable.
src/openhuman/flows/bus_tests.rs Extracts the former inline test module and adds snapshot-focused coverage without changing production behavior itself.

Sequence Diagram

sequenceDiagram
  participant Runner as Flow runner
  participant Bus as Event bus
  participant Subscriber as Dedup subscriber
  participant Store as Flow/KV store
  Runner->>Store: Load flow selected for execution
  Runner->>Bus: Publish FlowRunStarted
  Runner->>Runner: Execute loaded flow
  Bus-->>Subscriber: Deliver start event asynchronously
  Subscriber->>Store: Reload current flow
  Subscriber->>Store: Write run-node snapshot
  Runner->>Bus: Publish FlowRunFinished
  Bus-->>Subscriber: Deliver finish event
  Subscriber->>Store: Read snapshot or current-flow fallback
  Subscriber->>Store: Settle dedup state and clear snapshot
Loading

Reviews (2): Last reviewed commit: "ci: remove the temporary rustfmt probe w..." | Re-trigger Greptile

Comment thread src/openhuman/flows/bus.rs
Comment thread src/openhuman/flows/bus.rs
Comment thread .github/workflows/fmt-probe.yml Outdated

@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: aa3bfab37c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openhuman/flows/bus.rs

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

🧹 Nitpick comments (1)
src/openhuman/flows/bus.rs (1)

730-739: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log the malformed or empty snapshot branch.

snapshotted_dedup_node_ids returns None silently when the stored value is not an array, or when it holds no usable strings. The read-error branch above warns, so an operator can see it. The malformed branch produces no log line at all, so a corrupt snapshot is indistinguishable from "no snapshot" in the logs while settlement silently degrades to the saved graph.

Add a branch diagnostic that keeps the same fallback behavior.

♻️ Proposed diagnostic for the malformed-snapshot branch
-        let ids: Vec<String> = value
-            .as_array()?
-            .iter()
-            .filter_map(Value::as_str)
-            .map(str::to_string)
-            .collect();
-        if ids.is_empty() {
-            return None;
-        }
-        Some(ids)
+        let ids: Vec<String> = match value.as_array() {
+            Some(items) => items
+                .iter()
+                .filter_map(Value::as_str)
+                .map(str::to_string)
+                .collect(),
+            None => Vec::new(),
+        };
+        if ids.is_empty() {
+            tracing::warn!(
+                target: "flows", %namespace, %run_id,
+                "[dedup-commit] this run's dedup snapshot is not a non-empty string array — \
+                 falling back to the flow's saved graph"
+            );
+            return None;
+        }
+        Some(ids)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/flows/bus.rs` around lines 730 - 739, Update
snapshotted_dedup_node_ids to log a warning when the stored value is not an
array or when filtering yields no usable string IDs, while preserving its
existing None fallback behavior. Keep valid non-empty snapshots returning
Some(ids), and include enough context in the diagnostic to identify the
malformed or empty snapshot.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/openhuman/flows/bus.rs`:
- Around line 730-739: Update snapshotted_dedup_node_ids to log a warning when
the stored value is not an array or when filtering yields no usable string IDs,
while preserving its existing None fallback behavior. Keep valid non-empty
snapshots returning Some(ids), and include enough context in the diagnostic to
identify the malformed or empty snapshot.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d89899e-250e-43c8-8670-cd4b8e6c22e7

📥 Commits

Reviewing files that changed from the base of the PR and between e29bfc6 and 57f4acb.

📒 Files selected for processing (2)
  • src/openhuman/flows/bus.rs
  • src/openhuman/flows/bus_tests.rs

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