Skip to content

fix(execution): corrige falsy-safe defaults no ResultAggregator#611

Open
nikolasdehor wants to merge 2 commits intoSynkraAI:mainfrom
nikolasdehor:fix/result-aggregator-falsy-waveindex
Open

fix(execution): corrige falsy-safe defaults no ResultAggregator#611
nikolasdehor wants to merge 2 commits intoSynkraAI:mainfrom
nikolasdehor:fix/result-aggregator-falsy-waveindex

Conversation

@nikolasdehor
Copy link
Contributor

@nikolasdehor nikolasdehor commented Mar 18, 2026

Resumo

Substitui || por ?? (nullish coalescing) em todos os defaults do ResultAggregator.

Problema

waveIndex: waveResults.waveIndex || waveResults.wave trata 0 como falsy, causando waveIndex: undefined quando o valor real é 0 (primeira wave).

Mesmo problema em: rootPath, reportDir, maxHistory, agentId, filesModified, duration, output, startedAt.

Fix

Substituição direta de || por ?? em 15 ocorrências. O operador ?? só substitui quando o valor é null ou undefined, preservando 0, '', e false como valores válidos.

Arquivos

Arquivo Mudança
.aiox-core/core/execution/result-aggregator.js `

Plano de teste

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of default and missing values across execution, aggregation, and reporting so zero, empty, or false values are preserved rather than treated as missing. This improves accuracy of metrics, timings, file-change tracking, and report naming (per-wave vs all-waves), and reduces inadvertent data-loss in saved checkpoints and summaries.

…falsy-safe

waveIndex 0 era tratado como undefined por causa de || (OR lógico que
trata 0 como falsy). Substitui todas as ocorrências de || para defaults
por ?? (nullish coalescing) que só substitui null/undefined.

Afeta: waveIndex, startedAt, rootPath, reportDir, maxHistory,
agentId, filesModified, duration, output.
@vercel
Copy link

vercel bot commented Mar 18, 2026

@nikolasdehor is attempting to deploy a commit to the Pedro Valério Lopez's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added area: agents Agent system related area: workflows Workflow system related squad mcp type: test Test coverage and quality area: core Core framework (.aios-core/core/) area: installer Installer and setup (packages/installer/) area: synapse SYNAPSE context engine area: cli CLI tools (bin/, packages/aios-pro-cli/) area: pro Pro features (pro/) area: health-check Health check system area: docs Documentation (docs/) area: devops CI/CD, GitHub Actions (.github/) labels Mar 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Walkthrough

Replaced many logical OR (||) defaults with nullish coalescing (??) across core execution code, changing defaulting semantics for configuration, aggregation, checkpointing, and duration/metrics. The install manifest timestamps and SHA256 hashes were updated to match the edits.

Changes

Cohort / File(s) Summary
Result aggregation changes
core/execution/result-aggregator.js
Replaced `
Execution state/checkpointing
core/execution/build-state-manager.js
Switched `
Wave execution logic
core/execution/wave-executor.js
Changed task/wave fallback defaults and duration aggregations from `
Manifest and metadata
install-manifest.yaml
Updated generated_at timestamp and SHA256 hashes for modified core files (result-aggregator.js, build-state-manager.js, wave-executor.js, plus one data file) to reflect code changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes a fix to falsy-safe defaults in ResultAggregator, which is the primary focus of changes across multiple execution modules, though it's in Portuguese and partially addresses the broader changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

…nager

Mesma classe de bug do ResultAggregator: operadores || tratam 0 como
falsy, causando defaults incorretos quando o valor real é 0 (ex: duration,
totalSubtasks, waveIndex). Corrige 11 ocorrências em 2 módulos.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.aiox-core/core/execution/result-aggregator.js (1)

369-369: ⚠️ Potential issue | 🟠 Major

Incomplete fix: waveIndex || 'all' still treats 0 as falsy.

The PR correctly preserves waveIndex: 0 in the aggregation logic, but this line still uses ||, causing wave 0 reports to be named wave-results-all.json instead of wave-results-0.json. This undermines the fix.

🐛 Proposed fix
-    const reportName = filename || `wave-results-${aggregation.waveIndex || 'all'}.json`;
+    const reportName = filename ?? `wave-results-${aggregation.waveIndex ?? 'all'}.json`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.aiox-core/core/execution/result-aggregator.js at line 369, The reportName
assignment uses `||` which treats 0 as falsy, causing waveIndex 0 to become
'all'; update the expression that builds `reportName` (the `reportName` variable
using `filename` and `aggregation.waveIndex`) to use a nullish check so 0 is
preserved (e.g., use `aggregation.waveIndex ?? 'all'` or an explicit check for
undefined/null) so waveIndex 0 yields `wave-results-0.json`.
🧹 Nitpick comments (1)
.aiox-core/core/execution/result-aggregator.js (1)

313-313: Minor inconsistency: filesModified || [] still uses ||.

For consistency with the other changes in this file, consider updating to ??. While functionally equivalent here (empty arrays are truthy), aligning the pattern makes the codebase more predictable.

♻️ Optional consistency fix
-    const allFiles = tasks.flatMap((t) => t.filesModified || []);
+    const allFiles = tasks.flatMap((t) => t.filesModified ?? []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.aiox-core/core/execution/result-aggregator.js at line 313, Update the
nullish-coalescing usage for consistency: in the expression that builds allFiles
(the const allFiles = tasks.flatMap((t) => t.filesModified || []);), replace the
fallback operator `||` with `??` so it reads use of `filesModified ?? []` inside
the tasks.flatMap callback; keep the rest of the logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.aiox-core/core/execution/result-aggregator.js:
- Line 369: The reportName assignment uses `||` which treats 0 as falsy, causing
waveIndex 0 to become 'all'; update the expression that builds `reportName` (the
`reportName` variable using `filename` and `aggregation.waveIndex`) to use a
nullish check so 0 is preserved (e.g., use `aggregation.waveIndex ?? 'all'` or
an explicit check for undefined/null) so waveIndex 0 yields
`wave-results-0.json`.

---

Nitpick comments:
In @.aiox-core/core/execution/result-aggregator.js:
- Line 313: Update the nullish-coalescing usage for consistency: in the
expression that builds allFiles (the const allFiles = tasks.flatMap((t) =>
t.filesModified || []);), replace the fallback operator `||` with `??` so it
reads use of `filesModified ?? []` inside the tasks.flatMap callback; keep the
rest of the logic unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5533a5c7-bbb1-47c0-b3f8-63eb16f145a1

📥 Commits

Reviewing files that changed from the base of the PR and between f74e3e7 and 6b590b6.

📒 Files selected for processing (2)
  • .aiox-core/core/execution/result-aggregator.js
  • .aiox-core/install-manifest.yaml

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.aiox-core/core/execution/wave-executor.js:
- Line 67: Summary: The object property assignments use "tasks: context.tasks ??
[]" which lets non-array falsy values (e.g., '', false) pass through and later
break code like wave.tasks.map; normalize to arrays. Fix: replace uses of
"tasks: context.tasks ?? []" (and the similar occurrence around the second
mention) with a normalization that ensures an array, e.g. set tasks to
Array.isArray(context.tasks) ? context.tasks : [] (or wrap non-array single
values in [context.tasks] if intended), and update any construction sites that
create "wave" so wave.tasks is always an array before being iterated (reference
the property assignment where tasks is set and the downstream wave.tasks.map
usage).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 74a87338-175c-44c3-b11a-319990df05d5

📥 Commits

Reviewing files that changed from the base of the PR and between 6b590b6 and 93f7737.

📒 Files selected for processing (3)
  • .aiox-core/core/execution/build-state-manager.js
  • .aiox-core/core/execution/wave-executor.js
  • .aiox-core/install-manifest.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .aiox-core/install-manifest.yaml

{
index: 1,
tasks: context.tasks || [],
tasks: context.tasks ?? [],
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Normalize tasks to arrays before use to avoid runtime failures.

With ??, values like ''/false now pass through instead of falling back to []. Downstream, this can break at Line 94 (wave.tasks.map(...)) and during wave execution.

🛠️ Proposed fix
@@
-      analysis = {
+      analysis = {
         waves: [
           {
             index: 1,
-            tasks: context.tasks ?? [],
+            tasks: Array.isArray(context.tasks) ? context.tasks : [],
           },
         ],
       };
@@
-      this.emit('wave_started', {
+      const waveTasks = Array.isArray(wave.tasks) ? wave.tasks : [];
+      this.emit('wave_started', {
         waveIndex: wave.index,
-        tasks: wave.tasks.map((t) => ({ id: t.id, description: t.description })),
-        totalTasks: wave.tasks.length,
+        tasks: waveTasks.map((t) => ({ id: t.id, description: t.description })),
+        totalTasks: waveTasks.length,
       });
@@
-    const tasks = wave.tasks ?? [];
+    const tasks = Array.isArray(wave.tasks) ? wave.tasks : [];

As per coding guidelines, "Check for proper input validation on public API methods."

Also applies to: 151-151

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.aiox-core/core/execution/wave-executor.js at line 67, Summary: The object
property assignments use "tasks: context.tasks ?? []" which lets non-array falsy
values (e.g., '', false) pass through and later break code like wave.tasks.map;
normalize to arrays. Fix: replace uses of "tasks: context.tasks ?? []" (and the
similar occurrence around the second mention) with a normalization that ensures
an array, e.g. set tasks to Array.isArray(context.tasks) ? context.tasks : []
(or wrap non-array single values in [context.tasks] if intended), and update any
construction sites that create "wave" so wave.tasks is always an array before
being iterated (reference the property assignment where tasks is set and the
downstream wave.tasks.map usage).

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

area: agents Agent system related area: cli CLI tools (bin/, packages/aios-pro-cli/) area: core Core framework (.aios-core/core/) area: devops CI/CD, GitHub Actions (.github/) area: docs Documentation (docs/) area: health-check Health check system area: installer Installer and setup (packages/installer/) area: pro Pro features (pro/) area: synapse SYNAPSE context engine area: workflows Workflow system related mcp squad type: test Test coverage and quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant