Skip to content

fix(core): make build attempt logs JSON-safe - #694

Merged
rafaelscosta merged 2 commits into
mainfrom
devops/issue-621-safe-json-logs-20260508
May 8, 2026
Merged

fix(core): make build attempt logs JSON-safe#694
rafaelscosta merged 2 commits into
mainfrom
devops/issue-621-safe-json-logs-20260508

Conversation

@rafaelscosta

@rafaelscosta rafaelscosta commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add JSON-safe log detail serialization for BuildStateManager attempt logs.
  • Preserve circular references as [Circular] and normalize Error, Map, Set, BigInt, Date, RegExp, function, and symbol values into stable data shapes.
  • Add focused regression coverage for circular and non-JSON log details.
  • Regenerate .aiox-core/install-manifest.yaml for the changed core file hash.

Issue

Contributes to #621 by delivering the Data Integrity slice for circular reference serialization in build attempt JSON logs.

Validation

  • node -c .aiox-core/core/execution/build-state-manager.js
  • jest tests/core/build-state-manager.test.js --runInBand
  • npm run generate:manifest
  • npm run validate:manifest
  • git diff --check
  • npm run lint (0 errors, 114 baseline warnings)
  • npm run typecheck
  • node scripts/validate-package-completeness.js (34/34 passed after initializing pro submodule)
  • node bin/utils/validate-publish.js (PASS after initializing pro submodule)
  • npm test -- --runInBand --forceExit (11 skipped, 330 passed, 330/341 suites; 149 skipped, 8336 passed, 8485 tests)

Notes

  • .aiox-core/data/entity-registry.yaml was touched by test/pre-commit hooks and intentionally restored before push as a volatile generated artifact.
  • The pre-push registry hook reported a non-blocking missing js-yaml in this temp worktree, but the same validation was run successfully with canonical NODE_PATH before publication.

Summary by CodeRabbit

  • Bug Fixes

    • Improved attempt logging to safely handle complex/non-JSON values (circular references, errors, BigInt, Date, RegExp, Map/Set, functions), preventing logging failures and ensuring stable, readable log output.
  • Tests

    • Added tests verifying resilient serialization of circular references and various non-serializable data types in attempt logs.

@vercel

vercel Bot commented May 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aiox-core Ready Ready Preview, Comment May 8, 2026 4:33am

Request Review

@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 May 8, 2026
@coderabbitai

coderabbitai Bot commented May 8, 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: CHILL

Plan: Pro

Run ID: afb6df71-1500-49c7-86cc-fe4a6dee8674

📥 Commits

Reviewing files that changed from the base of the PR and between f112ebd and 5959b05.

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

Walkthrough

Adds sanitizeLogValue and stringifyLogDetails to produce JSON-safe representations of arbitrary values and uses them in _logAttempt; two tests validate circular-reference and complex-type logging; install manifest metadata updated.

Changes

Resilient Build Attempt Logging

Layer / File(s) Summary
Serialization Utilities
.aiox-core/core/execution/build-state-manager.js
sanitizeLogValue(value, seen) and stringifyLogDetails(value) added to convert arbitrary values (BigInt, Error, Date, RegExp, Map, Set, functions, symbols, circular refs, nested containers) into JSON-safe forms with fallbacks.
Logging Integration
.aiox-core/core/execution/build-state-manager.js
_logAttempt now uses stringifyLogDetails(details) instead of JSON.stringify(details).
Test Coverage
tests/core/build-state-manager.test.js
Two new AC7 tests: circular-reference serialization (expects [Circular] in log) and complex-type serialization (Errors with cause, Map/Set with BigInt, functions) asserting stable string fragments.
Manifest Update
.aiox-core/install-manifest.yaml
Auto-generated generated_at timestamp and core/execution/build-orchestrator.js hash/size updated.

Sequence Diagram(s)

sequenceDiagram
  participant Code
  participant LogAttempt
  participant StringifyLogDetails
  participant FileSystem
  Code->>LogAttempt: _logAttempt(details)
  LogAttempt->>StringifyLogDetails: stringifyLogDetails(details)
  StringifyLogDetails->>StringifyLogDetails: sanitizeLogValue(details)
  StringifyLogDetails-->>LogAttempt: safeString
  LogAttempt->>FileSystem: append build-attempts.log
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

area: core, type: test

Suggested reviewers

  • Pedrovaleriolopez
  • oalanicolas
🚥 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 PR title 'fix(core): make build attempt logs JSON-safe' directly and clearly summarizes the main change: adding JSON-safe serialization for build attempt logs to handle circular references and non-serializable values.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devops/issue-621-safe-json-logs-20260508

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.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage Report

Coverage report not available

📈 Full coverage report available in Codecov


Generated by PR Automation (Story 6.1)

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In @.aiox-core/core/execution/build-state-manager.js:
- Around line 128-133: The code currently preserves raw Error.stack when
building safeError in the build-state-manager (the value instanceof Error
branch), which can leak paths; change this so safeError.stack is not persisted
by default — set safeError.stack = '[redacted]' (or omit the property) unless an
explicit debug flag is enabled (e.g., check process.env.DEBUG_STACKS or a
runtime config flag like DEBUG_ERROR_STACKS), and only include the real
value.stack when that flag is true; ensure the rest of the code that writes
build-attempts.log uses this safeError object.

In `@tests/core/build-state-manager.test.js`:
- Line 592: The test currently asserts an exact function source string which is
brittle; update the assertion that checks the serialized "callback" in the test
(the line using expect(content).toContain('"callback":"() => \'ignored\'"')) to
use a pattern-based check instead (e.g., assert that the serialized payload
contains the token ignored via a regex or string match) so it verifies presence
of the callback's intent rather than the exact Function.prototype.toString()
output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7713488e-3e3a-4ad8-92f9-ada1cb429270

📥 Commits

Reviewing files that changed from the base of the PR and between 514b193 and f112ebd.

📒 Files selected for processing (3)
  • .aiox-core/core/execution/build-state-manager.js
  • .aiox-core/install-manifest.yaml
  • tests/core/build-state-manager.test.js

Comment thread .aiox-core/core/execution/build-state-manager.js
Comment thread tests/core/build-state-manager.test.js Outdated
@rafaelscosta
rafaelscosta merged commit d81dd4c into main May 8, 2026
40 checks passed
@rafaelscosta
rafaelscosta deleted the devops/issue-621-safe-json-logs-20260508 branch May 8, 2026 04:37
tuanmedeiros pushed a commit to tuanmedeiros/aios-core-synkraay that referenced this pull request Jun 2, 2026
* fix(core): make build attempt logs json-safe

* fix(core): redact error stacks in attempt logs
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