aios-core 4.2.15 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.aios-core/cli/commands/validate/index.js +1 -1
- package/.aios-core/core/code-intel/code-intel-client.js +19 -5
- package/.aios-core/core/code-intel/helpers/creation-helper.js +183 -0
- package/.aios-core/core/code-intel/helpers/devops-helper.js +166 -0
- package/.aios-core/core/code-intel/helpers/planning-helper.js +248 -0
- package/.aios-core/core/code-intel/helpers/qa-helper.js +187 -0
- package/.aios-core/core/code-intel/helpers/story-helper.js +146 -0
- package/.aios-core/core/code-intel/hook-runtime.js +186 -0
- package/.aios-core/core/code-intel/index.js +2 -0
- package/.aios-core/core/code-intel/providers/code-graph-provider.js +8 -0
- package/.aios-core/core/code-intel/providers/provider-interface.js +9 -0
- package/.aios-core/core/code-intel/providers/registry-provider.js +515 -0
- package/.aios-core/core/config/schemas/framework-config.schema.json +155 -7
- package/.aios-core/core/config/schemas/project-config.schema.json +329 -15
- package/.aios-core/core/config/template-overrides.js +84 -0
- package/.aios-core/core/docs/troubleshooting-guide.md +1 -1
- package/.aios-core/core/doctor/checks/agent-memory.js +63 -0
- package/.aios-core/core/doctor/checks/claude-md.js +56 -0
- package/.aios-core/core/doctor/checks/code-intel.js +131 -0
- package/.aios-core/core/doctor/checks/commands-count.js +81 -0
- package/.aios-core/core/doctor/checks/core-config.js +53 -0
- package/.aios-core/core/doctor/checks/entity-registry.js +53 -0
- package/.aios-core/core/doctor/checks/git-hooks.js +50 -0
- package/.aios-core/core/doctor/checks/graph-dashboard.js +48 -0
- package/.aios-core/core/doctor/checks/hooks-claude-count.js +118 -0
- package/.aios-core/core/doctor/checks/ide-sync.js +85 -0
- package/.aios-core/core/doctor/checks/index.js +46 -0
- package/.aios-core/core/doctor/checks/node-version.js +33 -0
- package/.aios-core/core/doctor/checks/npm-packages.js +35 -0
- package/.aios-core/core/doctor/checks/rules-files.js +61 -0
- package/.aios-core/core/doctor/checks/settings-json.js +121 -0
- package/.aios-core/core/doctor/checks/skills-count.js +72 -0
- package/.aios-core/core/doctor/fix-handler.js +165 -0
- package/.aios-core/core/doctor/formatters/json.js +14 -0
- package/.aios-core/core/doctor/formatters/text.js +59 -0
- package/.aios-core/core/doctor/index.js +94 -0
- package/.aios-core/core/graph-dashboard/cli.js +361 -0
- package/.aios-core/core/graph-dashboard/data-sources/code-intel-source.js +234 -0
- package/.aios-core/core/graph-dashboard/data-sources/metrics-source.js +95 -0
- package/.aios-core/core/graph-dashboard/data-sources/registry-source.js +106 -0
- package/.aios-core/core/graph-dashboard/formatters/dot-formatter.js +45 -0
- package/.aios-core/core/graph-dashboard/formatters/html-formatter.js +1437 -0
- package/.aios-core/core/graph-dashboard/formatters/json-formatter.js +13 -0
- package/.aios-core/core/graph-dashboard/formatters/mermaid-formatter.js +59 -0
- package/.aios-core/core/graph-dashboard/index.js +21 -0
- package/.aios-core/core/graph-dashboard/renderers/stats-renderer.js +217 -0
- package/.aios-core/core/graph-dashboard/renderers/status-renderer.js +125 -0
- package/.aios-core/core/graph-dashboard/renderers/tree-renderer.js +119 -0
- package/.aios-core/core/health-check/base-check.js +1 -1
- package/.aios-core/core/health-check/check-registry.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/build-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/ci-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/deployment-readiness.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/docker-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/env-file.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/index.js +1 -1
- package/.aios-core/core/health-check/checks/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/disk-space.js +1 -1
- package/.aios-core/core/health-check/checks/local/environment-vars.js +1 -1
- package/.aios-core/core/health-check/checks/local/git-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/ide-detection.js +1 -1
- package/.aios-core/core/health-check/checks/local/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/memory.js +1 -1
- package/.aios-core/core/health-check/checks/local/network.js +1 -1
- package/.aios-core/core/health-check/checks/local/npm-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/shell-environment.js +1 -1
- package/.aios-core/core/health-check/checks/project/agent-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/aios-directory.js +1 -1
- package/.aios-core/core/health-check/checks/project/dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/project/framework-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/index.js +1 -1
- package/.aios-core/core/health-check/checks/project/node-version.js +1 -1
- package/.aios-core/core/health-check/checks/project/package-json.js +1 -1
- package/.aios-core/core/health-check/checks/project/task-definitions.js +1 -1
- package/.aios-core/core/health-check/checks/project/workflow-dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/repository/branch-protection.js +1 -1
- package/.aios-core/core/health-check/checks/repository/commit-history.js +1 -1
- package/.aios-core/core/health-check/checks/repository/conflicts.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-repo.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-status.js +1 -1
- package/.aios-core/core/health-check/checks/repository/gitignore.js +1 -1
- package/.aios-core/core/health-check/checks/repository/index.js +1 -1
- package/.aios-core/core/health-check/checks/repository/large-files.js +1 -1
- package/.aios-core/core/health-check/checks/repository/lockfile-integrity.js +1 -1
- package/.aios-core/core/health-check/checks/services/api-endpoints.js +1 -1
- package/.aios-core/core/health-check/checks/services/claude-code.js +1 -1
- package/.aios-core/core/health-check/checks/services/gemini-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/github-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/index.js +1 -1
- package/.aios-core/core/health-check/checks/services/mcp-integration.js +1 -1
- package/.aios-core/core/health-check/engine.js +1 -1
- package/.aios-core/core/health-check/healers/backup-manager.js +1 -1
- package/.aios-core/core/health-check/healers/index.js +1 -1
- package/.aios-core/core/health-check/index.js +9 -2
- package/.aios-core/core/health-check/reporters/console.js +1 -1
- package/.aios-core/core/health-check/reporters/index.js +1 -1
- package/.aios-core/core/health-check/reporters/json.js +1 -1
- package/.aios-core/core/health-check/reporters/markdown.js +1 -1
- package/.aios-core/core/ids/layer-classifier.js +65 -0
- package/.aios-core/core/ids/registry-updater.js +49 -0
- package/.aios-core/core/index.esm.js +1 -1
- package/.aios-core/core/index.js +1 -1
- package/.aios-core/core/session/context-detector.js +2 -7
- package/.aios-core/core/synapse/context/context-tracker.js +9 -1
- package/.aios-core/core/synapse/engine.js +33 -13
- package/.aios-core/core/synapse/memory/memory-bridge.js +17 -43
- package/.aios-core/core/synapse/memory/synapse-memory-provider.js +201 -0
- package/.aios-core/core/synapse/runtime/hook-runtime.js +40 -2
- package/.aios-core/core/synapse/session/session-manager.js +3 -2
- package/.aios-core/core/synapse/utils/atomic-write.js +79 -0
- package/.aios-core/core-config.yaml +34 -1
- package/.aios-core/data/aios-kb.md +2 -2
- package/.aios-core/data/capability-detection.js +290 -0
- package/.aios-core/data/entity-registry.yaml +10450 -2129
- package/.aios-core/data/mcp-discipline.js +166 -0
- package/.aios-core/data/mcp-tool-examples.yaml +215 -0
- package/.aios-core/data/tok2-validation.js +168 -0
- package/.aios-core/data/tok3-token-comparison.js +123 -0
- package/.aios-core/data/tool-registry.yaml +648 -0
- package/.aios-core/data/tool-search-validation.js +174 -0
- package/.aios-core/data/workflow-chains.yaml +156 -0
- package/.aios-core/development/agents/aios-master.md +17 -10
- package/.aios-core/development/agents/analyst/MEMORY.md +33 -0
- package/.aios-core/development/agents/analyst.md +17 -10
- package/.aios-core/development/agents/architect/MEMORY.md +39 -0
- package/.aios-core/development/agents/architect.md +17 -10
- package/.aios-core/development/agents/data-engineer/MEMORY.md +32 -0
- package/.aios-core/development/agents/data-engineer.md +17 -10
- package/.aios-core/development/agents/dev/MEMORY.md +46 -0
- package/.aios-core/development/agents/dev.md +18 -11
- package/.aios-core/development/agents/devops/MEMORY.md +39 -0
- package/.aios-core/development/agents/devops.md +44 -10
- package/.aios-core/development/agents/pm/MEMORY.md +38 -0
- package/.aios-core/development/agents/pm.md +17 -10
- package/.aios-core/development/agents/po/MEMORY.md +45 -0
- package/.aios-core/development/agents/po.md +17 -10
- package/.aios-core/development/agents/qa/MEMORY.md +42 -0
- package/.aios-core/development/agents/qa.md +18 -11
- package/.aios-core/development/agents/sm/MEMORY.md +31 -0
- package/.aios-core/development/agents/sm.md +17 -10
- package/.aios-core/development/agents/squad-creator.md +18 -9
- package/.aios-core/development/agents/ux/MEMORY.md +31 -0
- package/.aios-core/development/agents/ux-design-expert.md +16 -9
- package/.aios-core/development/checklists/issue-triage-checklist.md +35 -0
- package/.aios-core/development/checklists/memory-audit-checklist.md +53 -0
- package/.aios-core/development/scripts/issue-triage.js +171 -0
- package/.aios-core/development/scripts/populate-entity-registry.js +412 -19
- package/.aios-core/development/scripts/unified-activation-pipeline.js +31 -10
- package/.aios-core/development/tasks/analyze-project-structure.md +48 -0
- package/.aios-core/development/tasks/apply-qa-fixes.md +7 -0
- package/.aios-core/development/tasks/architect-analyze-impact.md +8 -1
- package/.aios-core/development/tasks/brownfield-create-epic.md +41 -0
- package/.aios-core/development/tasks/brownfield-create-story.md +7 -0
- package/.aios-core/development/tasks/build-autonomous.md +7 -0
- package/.aios-core/development/tasks/create-deep-research-prompt.md +7 -0
- package/.aios-core/development/tasks/create-doc.md +44 -0
- package/.aios-core/development/tasks/create-next-story.md +17 -0
- package/.aios-core/development/tasks/create-suite.md +7 -0
- package/.aios-core/development/tasks/dev-develop-story.md +9 -1
- package/.aios-core/development/tasks/execute-checklist.md +7 -0
- package/.aios-core/development/tasks/github-devops-github-pr-automation.md +56 -0
- package/.aios-core/development/tasks/github-devops-pre-push-quality-gate.md +70 -0
- package/.aios-core/development/tasks/github-issue-triage.md +118 -0
- package/.aios-core/development/tasks/health-check.yaml +206 -171
- package/.aios-core/development/tasks/kb-mode-interaction.md +3 -3
- package/.aios-core/development/tasks/plan-create-context.md +47 -1
- package/.aios-core/development/tasks/plan-create-implementation.md +55 -0
- package/.aios-core/development/tasks/po-close-story.md +7 -0
- package/.aios-core/development/tasks/pr-automation.md +5 -5
- package/.aios-core/development/tasks/qa-create-fix-request.md +7 -0
- package/.aios-core/development/tasks/qa-fix-issues.md +7 -0
- package/.aios-core/development/tasks/qa-gate.md +56 -0
- package/.aios-core/development/tasks/qa-review-story.md +32 -1
- package/.aios-core/development/tasks/release-management.md +7 -0
- package/.aios-core/development/tasks/resolve-github-issue.md +608 -0
- package/.aios-core/development/tasks/review-contributor-pr.md +152 -0
- package/.aios-core/development/tasks/setup-llm-routing.md +1 -1
- package/.aios-core/development/tasks/spec-critique.md +8 -0
- package/.aios-core/development/tasks/spec-gather-requirements.md +7 -0
- package/.aios-core/development/tasks/spec-research-dependencies.md +4 -0
- package/.aios-core/development/tasks/spec-write-spec.md +5 -0
- package/.aios-core/development/tasks/triage-github-issues.md +356 -0
- package/.aios-core/development/tasks/validate-agents.md +4 -0
- package/.aios-core/development/tasks/validate-next-story.md +17 -0
- package/.aios-core/development/templates/agent-handoff-tmpl.yaml +48 -0
- package/.aios-core/development/templates/code-intel-integration-pattern.md +199 -0
- package/.aios-core/development/templates/ptc-entity-validation.md +113 -0
- package/.aios-core/development/templates/ptc-qa-gate.md +100 -0
- package/.aios-core/development/templates/ptc-research-aggregation.md +94 -0
- package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
- package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
- package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
- package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
- package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
- package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
- package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
- package/.aios-core/development/templates/squad/agent-template.md +11 -0
- package/.aios-core/development/templates/squad/task-template.md +21 -0
- package/.aios-core/development/templates/squad-template/LICENSE +21 -21
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-COMPLETE.md +1 -1
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.2-SUMMARY.md +1 -1
- package/.aios-core/framework-config.yaml +8 -0
- package/.aios-core/index.esm.js +1 -1
- package/.aios-core/index.js +1 -1
- package/.aios-core/infrastructure/integrations/ai-providers/index.js +1 -1
- package/.aios-core/infrastructure/schemas/task-v3-schema.json +6 -0
- package/.aios-core/infrastructure/scripts/collect-tool-usage.js +311 -0
- package/.aios-core/infrastructure/scripts/generate-optimization-report.js +497 -0
- package/.aios-core/infrastructure/scripts/generate-settings-json.js +300 -0
- package/.aios-core/infrastructure/scripts/git-config-detector.js +65 -9
- package/.aios-core/infrastructure/scripts/ide-sync/index.js +3 -1
- package/.aios-core/infrastructure/scripts/ide-sync/transformers/github-copilot.js +184 -0
- package/.aios-core/infrastructure/scripts/repository-detector.js +3 -3
- package/.aios-core/infrastructure/templates/aios-sync.yaml.template +182 -182
- package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
- package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
- package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
- package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
- package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
- package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
- package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
- package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
- package/.aios-core/install-manifest.yaml +613 -305
- package/.aios-core/lib/build.json +1 -0
- package/.aios-core/local-config.yaml.template +71 -71
- package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
- package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
- package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
- package/.aios-core/monitor/hooks/notification.py +29 -29
- package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
- package/.aios-core/monitor/hooks/pre_compact.py +29 -29
- package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
- package/.aios-core/monitor/hooks/stop.py +29 -29
- package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
- package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
- package/.aios-core/product/templates/adr.hbs +125 -125
- package/.aios-core/product/templates/dbdr.hbs +241 -241
- package/.aios-core/product/templates/epic.hbs +212 -212
- package/.aios-core/product/templates/ide-rules/claude-rules.md +125 -0
- package/.aios-core/product/templates/pmdr.hbs +186 -186
- package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
- package/.aios-core/product/templates/prd.hbs +201 -201
- package/.aios-core/product/templates/story.hbs +263 -263
- package/.aios-core/product/templates/task.hbs +170 -170
- package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
- package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
- package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
- package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
- package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
- package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
- package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
- package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
- package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
- package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
- package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
- package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
- package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
- package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
- package/.aios-core/product/templates/tmpl-view.sql +177 -177
- package/.aios-core/scripts/pm.sh +0 -0
- package/.aios-core/user-guide.md +15 -15
- package/.aios-core/utils/filters/constants.js +10 -0
- package/.aios-core/utils/filters/content-filter.js +223 -0
- package/.aios-core/utils/filters/field-filter.js +126 -0
- package/.aios-core/utils/filters/index.js +180 -0
- package/.aios-core/utils/filters/schema-filter.js +157 -0
- package/.claude/CLAUDE.md +62 -0
- package/.claude/hooks/enforce-architecture-first.py +196 -196
- package/.claude/hooks/enforce-git-push-authority.sh +33 -0
- package/.claude/hooks/mind-clone-governance.py +192 -192
- package/.claude/hooks/read-protection.py +151 -151
- package/.claude/hooks/slug-validation.py +176 -176
- package/.claude/hooks/sql-governance.py +182 -182
- package/.claude/hooks/synapse-engine.cjs +28 -5
- package/.claude/hooks/write-path-validation.py +194 -194
- package/.claude/rules/agent-authority.md +105 -0
- package/.claude/rules/agent-handoff.md +97 -0
- package/.claude/rules/agent-memory-imports.md +15 -0
- package/.claude/rules/coderabbit-integration.md +101 -0
- package/.claude/rules/ids-principles.md +119 -0
- package/.claude/rules/story-lifecycle.md +145 -0
- package/.claude/rules/tool-examples.md +64 -0
- package/.claude/rules/tool-response-filtering.md +57 -0
- package/.claude/rules/workflow-execution.md +150 -0
- package/LICENSE +33 -33
- package/bin/aios-graph.js +9 -0
- package/bin/aios-init.js +2 -2
- package/bin/aios-minimal.js +0 -0
- package/bin/aios.js +17 -221
- package/bin/utils/detect-fsmonitor.js +70 -0
- package/bin/utils/framework-guard.js +238 -0
- package/bin/utils/validate-publish.js +108 -0
- package/package.json +6 -3
- package/packages/aios-install/bin/aios-install.js +0 -0
- package/packages/aios-install/bin/edmcp.js +0 -0
- package/packages/aios-pro-cli/bin/aios-pro.js +2 -0
- package/packages/installer/src/config/templates/core-config-template.js +25 -0
- package/packages/installer/src/installer/brownfield-upgrader.js +68 -5
- package/packages/installer/src/merger/index.js +3 -0
- package/packages/installer/src/merger/strategies/index.js +6 -0
- package/packages/installer/src/merger/strategies/yaml-merger.js +181 -0
- package/packages/installer/src/updater/index.js +4 -4
- package/packages/installer/src/wizard/i18n.js +321 -3
- package/packages/installer/src/wizard/ide-config-generator.js +173 -25
- package/packages/installer/src/wizard/index.js +119 -1
- package/packages/installer/src/wizard/pro-setup.js +137 -121
- package/packages/installer/tests/unit/artifact-copy-pipeline/artifact-copy-pipeline.test.js +271 -0
- package/packages/installer/tests/unit/claude-md-template-v5/claude-md-template-v5.test.js +192 -0
- package/packages/installer/tests/unit/doctor/doctor-checks.test.js +610 -0
- package/packages/installer/tests/unit/doctor/doctor-orchestrator.test.js +134 -0
- package/packages/installer/tests/unit/entity-registry-bootstrap.test.js +186 -0
- package/packages/installer/tests/unit/generate-settings-json/generate-settings-json.test.js +309 -0
- package/packages/installer/tests/unit/ide-sync-integration/ide-sync-integration.test.js +230 -0
- package/packages/installer/tests/unit/merger/strategies.test.js +2 -2
- package/packages/installer/tests/unit/merger/yaml-merger.test.js +327 -0
- package/scripts/check-markdown-links.py +352 -352
- package/scripts/dashboard-parallel-dev.sh +0 -0
- package/scripts/dashboard-parallel-phase3.sh +0 -0
- package/scripts/dashboard-parallel-phase4.sh +0 -0
- package/scripts/install-monitor-hooks.sh +0 -0
- package/scripts/package-synapse.js +2 -1
- package/pro/README.md +0 -66
- package/pro/license/degradation.js +0 -220
- package/pro/license/errors.js +0 -450
- package/pro/license/feature-gate.js +0 -354
- package/pro/license/index.js +0 -181
- package/pro/license/license-api.js +0 -651
- package/pro/license/license-cache.js +0 -523
- package/pro/license/license-crypto.js +0 -303
|
@@ -172,6 +172,14 @@ class PipelineMetrics {
|
|
|
172
172
|
/** Hard pipeline timeout in milliseconds. */
|
|
173
173
|
const PIPELINE_TIMEOUT_MS = 100;
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* NOG-18: Default active layers (L0-L2 only).
|
|
177
|
+
* L3-L7 produced 0 rules in NOG-17 audit — disabled for performance.
|
|
178
|
+
* Set SYNAPSE_LEGACY_MODE=true to re-enable full 8-layer processing.
|
|
179
|
+
*/
|
|
180
|
+
const DEFAULT_ACTIVE_LAYERS = [0, 1, 2];
|
|
181
|
+
const LEGACY_MODE = process.env.SYNAPSE_LEGACY_MODE === 'true';
|
|
182
|
+
|
|
175
183
|
/**
|
|
176
184
|
* Orchestrates the 8-layer SYNAPSE context injection pipeline.
|
|
177
185
|
*
|
|
@@ -229,21 +237,33 @@ class SynapseEngine {
|
|
|
229
237
|
const metrics = new PipelineMetrics();
|
|
230
238
|
metrics.totalStart = process.hrtime.bigint();
|
|
231
239
|
|
|
232
|
-
// 1. Calculate bracket
|
|
240
|
+
// 1. Calculate bracket (or use fixed layers in non-legacy mode)
|
|
233
241
|
const promptCount = (session && session.prompt_count) || 0;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
let contextPercent, bracket, activeLayers, tokenBudget;
|
|
243
|
+
|
|
244
|
+
if (LEGACY_MODE) {
|
|
245
|
+
// Full 8-layer processing with bracket-based filtering
|
|
246
|
+
contextPercent = estimateContextPercent(promptCount);
|
|
247
|
+
bracket = calculateBracket(contextPercent);
|
|
248
|
+
const layerConfig = getActiveLayers(bracket);
|
|
249
|
+
tokenBudget = getTokenBudget(bracket);
|
|
250
|
+
|
|
251
|
+
// Guard: no layer config (invalid bracket — should not happen)
|
|
252
|
+
if (!layerConfig) {
|
|
253
|
+
metrics.totalEnd = process.hrtime.bigint();
|
|
254
|
+
return { xml: '', metrics: metrics.getSummary() };
|
|
255
|
+
}
|
|
256
|
+
activeLayers = layerConfig.layers;
|
|
257
|
+
} else {
|
|
258
|
+
// NOG-18: Simplified — always load L0-L2, skip bracket calculation.
|
|
259
|
+
// L3-L7 produced 0 rules (require session context that never exists).
|
|
260
|
+
// Bracket management replaced by native /compact.
|
|
261
|
+
contextPercent = estimateContextPercent(promptCount);
|
|
262
|
+
bracket = calculateBracket(contextPercent);
|
|
263
|
+
activeLayers = DEFAULT_ACTIVE_LAYERS;
|
|
264
|
+
tokenBudget = getTokenBudget(bracket);
|
|
243
265
|
}
|
|
244
266
|
|
|
245
|
-
const activeLayers = layerConfig.layers;
|
|
246
|
-
|
|
247
267
|
// 2. Execute layers sequentially
|
|
248
268
|
const results = [];
|
|
249
269
|
const previousLayers = [];
|
|
@@ -323,7 +343,7 @@ class SynapseEngine {
|
|
|
323
343
|
needsHandoffWarning(bracket),
|
|
324
344
|
);
|
|
325
345
|
|
|
326
|
-
return { xml, metrics: summary };
|
|
346
|
+
return { xml, metrics: summary, bracket };
|
|
327
347
|
}
|
|
328
348
|
|
|
329
349
|
/**
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory Bridge —
|
|
2
|
+
* Memory Bridge — MIS consumer for SYNAPSE engine.
|
|
3
3
|
*
|
|
4
4
|
* Connects SynapseEngine to the Memory Intelligence System (MIS)
|
|
5
|
-
* via
|
|
5
|
+
* via SynapseMemoryProvider. Implements bracket-aware retrieval with
|
|
6
6
|
* agent-scoped sector filtering and token budget enforcement.
|
|
7
7
|
*
|
|
8
8
|
* Consumer-only: reads from MIS APIs, never modifies memory stores.
|
|
9
|
-
* Graceful no-op when
|
|
9
|
+
* Graceful no-op when MIS module is not installed.
|
|
10
10
|
*
|
|
11
11
|
* @module core/synapse/memory/memory-bridge
|
|
12
|
-
* @version
|
|
12
|
+
* @version 2.0.0
|
|
13
13
|
* @created Story SYN-10 - Pro Memory Bridge (Feature-Gated MIS Consumer)
|
|
14
|
+
* @migrated Story INS-4.11 - Removed pro feature gate (AC9)
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
'use strict';
|
|
@@ -39,15 +40,15 @@ const BRACKET_LAYER_MAP = {
|
|
|
39
40
|
const DEFAULT_SECTORS = ['semantic'];
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* MemoryBridge —
|
|
43
|
+
* MemoryBridge — MIS consumer for SYNAPSE engine.
|
|
43
44
|
*
|
|
44
45
|
* Provides bracket-aware memory retrieval with:
|
|
45
|
-
* - Feature gate check (sync, <1ms)
|
|
46
46
|
* - Agent-scoped sector filtering
|
|
47
47
|
* - Token budget enforcement
|
|
48
48
|
* - Session-level caching
|
|
49
49
|
* - Timeout protection (<15ms)
|
|
50
50
|
* - Error catch-all with warn-and-proceed
|
|
51
|
+
* - Graceful no-op when MIS module is not installed
|
|
51
52
|
*/
|
|
52
53
|
class MemoryBridge {
|
|
53
54
|
/**
|
|
@@ -57,32 +58,12 @@ class MemoryBridge {
|
|
|
57
58
|
constructor(options = {}) {
|
|
58
59
|
this._timeout = options.timeout || BRIDGE_TIMEOUT_MS;
|
|
59
60
|
this._provider = null;
|
|
60
|
-
this._featureGate = null;
|
|
61
61
|
this._initialized = false;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Lazy-load
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
_init() {
|
|
71
|
-
if (this._initialized) return;
|
|
72
|
-
this._initialized = true;
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const { featureGate } = require('../../../../pro/license/feature-gate');
|
|
76
|
-
this._featureGate = featureGate;
|
|
77
|
-
} catch {
|
|
78
|
-
// Pro not installed — feature gate unavailable
|
|
79
|
-
this._featureGate = null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Lazy-load the SynapseMemoryProvider (pro).
|
|
85
|
-
* Only loaded when feature gate confirms availability.
|
|
65
|
+
* Lazy-load the SynapseMemoryProvider (open-source).
|
|
66
|
+
* Gracefully returns null if MIS dependencies are not available.
|
|
86
67
|
*
|
|
87
68
|
* @private
|
|
88
69
|
* @returns {object|null} Provider instance or null
|
|
@@ -91,11 +72,11 @@ class MemoryBridge {
|
|
|
91
72
|
if (this._provider) return this._provider;
|
|
92
73
|
|
|
93
74
|
try {
|
|
94
|
-
const { SynapseMemoryProvider } = require('
|
|
75
|
+
const { SynapseMemoryProvider } = require('./synapse-memory-provider');
|
|
95
76
|
this._provider = new SynapseMemoryProvider();
|
|
96
77
|
return this._provider;
|
|
97
78
|
} catch {
|
|
98
|
-
// Provider not available
|
|
79
|
+
// Provider or MIS not available — graceful degradation
|
|
99
80
|
return null;
|
|
100
81
|
}
|
|
101
82
|
}
|
|
@@ -105,7 +86,7 @@ class MemoryBridge {
|
|
|
105
86
|
*
|
|
106
87
|
* Returns an array of memory hint objects suitable for injection
|
|
107
88
|
* into the SYNAPSE pipeline. Gracefully returns [] when:
|
|
108
|
-
* -
|
|
89
|
+
* - MIS module is not installed
|
|
109
90
|
* - Bracket is FRESH (no memory needed)
|
|
110
91
|
* - Provider fails or times out
|
|
111
92
|
* - Any error occurs
|
|
@@ -117,19 +98,13 @@ class MemoryBridge {
|
|
|
117
98
|
*/
|
|
118
99
|
async getMemoryHints(agentId, bracket, tokenBudget) {
|
|
119
100
|
try {
|
|
120
|
-
// 1.
|
|
121
|
-
this._init();
|
|
122
|
-
if (!this._featureGate || !this._featureGate.isAvailable('pro.memory.synapse')) {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 2. Bracket check — FRESH needs no memory
|
|
101
|
+
// 1. Bracket check — FRESH needs no memory
|
|
127
102
|
const bracketConfig = BRACKET_LAYER_MAP[bracket];
|
|
128
103
|
if (!bracketConfig || bracketConfig.layer === 0) {
|
|
129
104
|
return [];
|
|
130
105
|
}
|
|
131
106
|
|
|
132
|
-
//
|
|
107
|
+
// 2. Calculate effective token budget
|
|
133
108
|
const effectiveBudget = Math.min(
|
|
134
109
|
bracketConfig.maxTokens,
|
|
135
110
|
tokenBudget > 0 ? tokenBudget : bracketConfig.maxTokens,
|
|
@@ -139,19 +114,19 @@ class MemoryBridge {
|
|
|
139
114
|
return [];
|
|
140
115
|
}
|
|
141
116
|
|
|
142
|
-
//
|
|
117
|
+
// 3. Load provider
|
|
143
118
|
const provider = this._getProvider();
|
|
144
119
|
if (!provider) {
|
|
145
120
|
return [];
|
|
146
121
|
}
|
|
147
122
|
|
|
148
|
-
//
|
|
123
|
+
// 4. Execute with timeout protection
|
|
149
124
|
const hints = await this._executeWithTimeout(
|
|
150
125
|
() => provider.getMemories(agentId, bracket, effectiveBudget),
|
|
151
126
|
this._timeout,
|
|
152
127
|
);
|
|
153
128
|
|
|
154
|
-
//
|
|
129
|
+
// 5. Enforce token budget on results
|
|
155
130
|
return this._enforceTokenBudget(hints || [], effectiveBudget);
|
|
156
131
|
} catch (error) {
|
|
157
132
|
// Catch-all: warn and proceed with empty results
|
|
@@ -233,7 +208,6 @@ class MemoryBridge {
|
|
|
233
208
|
*/
|
|
234
209
|
_reset() {
|
|
235
210
|
this._provider = null;
|
|
236
|
-
this._featureGate = null;
|
|
237
211
|
this._initialized = false;
|
|
238
212
|
}
|
|
239
213
|
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synapse Memory Provider — MIS retrieval for SYNAPSE engine.
|
|
3
|
+
*
|
|
4
|
+
* Implements the provider interface consumed by MemoryBridge.
|
|
5
|
+
* Open-source: no feature gate required.
|
|
6
|
+
*
|
|
7
|
+
* Responsibilities:
|
|
8
|
+
* - Agent-scoped memory retrieval using AGENT_SECTOR_PREFERENCES
|
|
9
|
+
* - Progressive disclosure layer selection based on bracket
|
|
10
|
+
* - Session-level caching (keyed by agentId-bracket)
|
|
11
|
+
* - Token budget respect
|
|
12
|
+
*
|
|
13
|
+
* @module core/synapse/memory/synapse-memory-provider
|
|
14
|
+
* @version 2.0.0
|
|
15
|
+
* @created Story SYN-10 - Pro Memory Bridge (Feature-Gated MIS Consumer)
|
|
16
|
+
* @migrated Story INS-4.11 - Moved from pro/ to open-source (AC9)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const { estimateTokens } = require('../utils/tokens');
|
|
22
|
+
|
|
23
|
+
/** Default sectors for unknown agents. */
|
|
24
|
+
const DEFAULT_SECTORS = ['semantic'];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Agent sector preferences for memory retrieval.
|
|
28
|
+
* Defines which cognitive sectors each agent prefers.
|
|
29
|
+
*
|
|
30
|
+
* Moved from pro/memory/memory-loader.js to open-source.
|
|
31
|
+
*/
|
|
32
|
+
const AGENT_SECTOR_PREFERENCES = {
|
|
33
|
+
dev: ['procedural', 'semantic'],
|
|
34
|
+
qa: ['reflective', 'episodic'],
|
|
35
|
+
architect: ['semantic', 'reflective'],
|
|
36
|
+
pm: ['episodic', 'semantic'],
|
|
37
|
+
po: ['episodic', 'semantic'],
|
|
38
|
+
sm: ['procedural', 'episodic'],
|
|
39
|
+
devops: ['procedural', 'episodic'],
|
|
40
|
+
analyst: ['semantic', 'reflective'],
|
|
41
|
+
'data-engineer': ['procedural', 'semantic'],
|
|
42
|
+
'ux-design-expert': ['reflective', 'procedural'],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Bracket → retrieval configuration.
|
|
47
|
+
*/
|
|
48
|
+
const BRACKET_CONFIG = {
|
|
49
|
+
MODERATE: { layer: 1, limit: 3, minRelevance: 0.7 },
|
|
50
|
+
DEPLETED: { layer: 2, limit: 5, minRelevance: 0.5 },
|
|
51
|
+
CRITICAL: { layer: 3, limit: 10, minRelevance: 0.3 },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* SynapseMemoryProvider — Open-source memory retrieval.
|
|
56
|
+
*
|
|
57
|
+
* Provides memories from MIS for SYNAPSE engine injection.
|
|
58
|
+
* Session-level caching avoids repeated MIS queries for
|
|
59
|
+
* the same agent + bracket combination.
|
|
60
|
+
*
|
|
61
|
+
* Uses lazy-loading for MemoryLoader to gracefully degrade
|
|
62
|
+
* when the MIS module is not installed.
|
|
63
|
+
*/
|
|
64
|
+
class SynapseMemoryProvider {
|
|
65
|
+
/**
|
|
66
|
+
* @param {object} [options={}]
|
|
67
|
+
* @param {string} [options.projectDir] - Project directory for MemoryLoader
|
|
68
|
+
*/
|
|
69
|
+
constructor(options = {}) {
|
|
70
|
+
this._projectDir = options.projectDir || process.cwd();
|
|
71
|
+
this._loader = null;
|
|
72
|
+
/** @type {Map<string, Array>} Session-level cache keyed by `${agentId}-${bracket}` */
|
|
73
|
+
this._cache = new Map();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Lazy-load MemoryLoader.
|
|
78
|
+
* Gracefully returns null if pro/memory module is not available.
|
|
79
|
+
*
|
|
80
|
+
* @private
|
|
81
|
+
* @returns {object|null}
|
|
82
|
+
*/
|
|
83
|
+
_getLoader() {
|
|
84
|
+
if (this._loader) return this._loader;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const { MemoryLoader } = require('../../../../pro/memory/memory-loader');
|
|
88
|
+
this._loader = new MemoryLoader(this._projectDir);
|
|
89
|
+
return this._loader;
|
|
90
|
+
} catch {
|
|
91
|
+
// MIS module not available — graceful degradation
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get memories for SYNAPSE engine injection.
|
|
98
|
+
*
|
|
99
|
+
* Uses bracket to determine:
|
|
100
|
+
* - Which MIS layer to query (1=metadata, 2=chunks, 3=full)
|
|
101
|
+
* - How many results to return
|
|
102
|
+
* - Minimum relevance threshold
|
|
103
|
+
*
|
|
104
|
+
* Results are cached per session (agentId + bracket).
|
|
105
|
+
*
|
|
106
|
+
* @param {string} agentId - Active agent ID
|
|
107
|
+
* @param {string} bracket - Context bracket (MODERATE, DEPLETED, CRITICAL)
|
|
108
|
+
* @param {number} tokenBudget - Max tokens for memory hints
|
|
109
|
+
* @returns {Promise<Array<{content: string, source: string, relevance: number, tokens: number}>>}
|
|
110
|
+
*/
|
|
111
|
+
async getMemories(agentId, bracket, tokenBudget) {
|
|
112
|
+
// Cache lookup
|
|
113
|
+
const cacheKey = `${agentId}-${bracket}`;
|
|
114
|
+
if (this._cache.has(cacheKey)) {
|
|
115
|
+
return this._cache.get(cacheKey);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Get bracket config
|
|
119
|
+
const config = BRACKET_CONFIG[bracket];
|
|
120
|
+
if (!config) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Get loader (lazy-load, graceful if unavailable)
|
|
125
|
+
const loader = this._getLoader();
|
|
126
|
+
if (!loader) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Get agent sectors
|
|
131
|
+
const sectors = AGENT_SECTOR_PREFERENCES[agentId] || DEFAULT_SECTORS;
|
|
132
|
+
|
|
133
|
+
// Query MIS via MemoryLoader
|
|
134
|
+
const memories = await loader.queryMemories(agentId, {
|
|
135
|
+
sectors,
|
|
136
|
+
layer: config.layer,
|
|
137
|
+
limit: config.limit,
|
|
138
|
+
minRelevance: config.minRelevance,
|
|
139
|
+
tokenBudget,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Transform to hint format
|
|
143
|
+
const hints = this._transformToHints(memories, tokenBudget);
|
|
144
|
+
|
|
145
|
+
// Cache results
|
|
146
|
+
this._cache.set(cacheKey, hints);
|
|
147
|
+
|
|
148
|
+
return hints;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Transform MIS memory results into hint format.
|
|
153
|
+
*
|
|
154
|
+
* @private
|
|
155
|
+
* @param {Array} memories - Raw memories from MemoryLoader
|
|
156
|
+
* @param {number} tokenBudget - Max tokens
|
|
157
|
+
* @returns {Array<{content: string, source: string, relevance: number, tokens: number}>}
|
|
158
|
+
*/
|
|
159
|
+
_transformToHints(memories, tokenBudget) {
|
|
160
|
+
if (!Array.isArray(memories) || memories.length === 0) {
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const hints = [];
|
|
165
|
+
let tokensUsed = 0;
|
|
166
|
+
|
|
167
|
+
for (const memory of memories) {
|
|
168
|
+
const content = memory.content || memory.summary || memory.title || '';
|
|
169
|
+
const tokens = estimateTokens(content);
|
|
170
|
+
|
|
171
|
+
if (tokensUsed + tokens > tokenBudget) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
hints.push({
|
|
176
|
+
content,
|
|
177
|
+
source: memory.source || memory.sector || 'memory',
|
|
178
|
+
relevance: memory.relevance || memory.attention || 0,
|
|
179
|
+
tokens,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
tokensUsed += tokens;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return hints;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Clear the session cache.
|
|
190
|
+
*/
|
|
191
|
+
clearCache() {
|
|
192
|
+
this._cache.clear();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = {
|
|
197
|
+
SynapseMemoryProvider,
|
|
198
|
+
AGENT_SECTOR_PREFERENCES,
|
|
199
|
+
BRACKET_CONFIG,
|
|
200
|
+
DEFAULT_SECTORS,
|
|
201
|
+
};
|
|
@@ -3,9 +3,34 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
|
+
const DEFAULT_STALE_TTL_HOURS = 168; // 7 days
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Read stale session TTL from core-config.yaml.
|
|
10
|
+
* Falls back to DEFAULT_STALE_TTL_HOURS (168h = 7 days).
|
|
11
|
+
*
|
|
12
|
+
* @param {string} cwd - Working directory
|
|
13
|
+
* @returns {number} TTL in hours
|
|
14
|
+
*/
|
|
15
|
+
function getStaleSessionTTL(cwd) {
|
|
16
|
+
try {
|
|
17
|
+
const yaml = require('js-yaml');
|
|
18
|
+
const configPath = path.join(cwd, '.aios-core', 'core-config.yaml');
|
|
19
|
+
if (!fs.existsSync(configPath)) return DEFAULT_STALE_TTL_HOURS;
|
|
20
|
+
const config = yaml.load(fs.readFileSync(configPath, 'utf8'));
|
|
21
|
+
const ttl = config && config.synapse && config.synapse.session && config.synapse.session.staleTTLHours;
|
|
22
|
+
return typeof ttl === 'number' && ttl > 0 ? ttl : DEFAULT_STALE_TTL_HOURS;
|
|
23
|
+
} catch (_err) {
|
|
24
|
+
return DEFAULT_STALE_TTL_HOURS;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
/**
|
|
7
29
|
* Resolve runtime dependencies for Synapse hook execution.
|
|
8
30
|
*
|
|
31
|
+
* On the first prompt of a session (prompt_count === 0), runs
|
|
32
|
+
* cleanStaleSessions() fire-and-forget to remove expired sessions.
|
|
33
|
+
*
|
|
9
34
|
* @param {{cwd?: string, session_id?: string, sessionId?: string}} input
|
|
10
35
|
* @returns {{
|
|
11
36
|
* engine: import('../engine').SynapseEngine,
|
|
@@ -21,7 +46,7 @@ function resolveHookRuntime(input) {
|
|
|
21
46
|
if (!fs.existsSync(synapsePath)) return null;
|
|
22
47
|
|
|
23
48
|
try {
|
|
24
|
-
const { loadSession } = require(
|
|
49
|
+
const { loadSession, cleanStaleSessions } = require(
|
|
25
50
|
path.join(cwd, '.aios-core', 'core', 'synapse', 'session', 'session-manager.js'),
|
|
26
51
|
);
|
|
27
52
|
const { SynapseEngine } = require(
|
|
@@ -32,7 +57,20 @@ function resolveHookRuntime(input) {
|
|
|
32
57
|
const session = loadSession(sessionId, sessionsDir) || { prompt_count: 0 };
|
|
33
58
|
const engine = new SynapseEngine(synapsePath);
|
|
34
59
|
|
|
35
|
-
|
|
60
|
+
// AC3: Run cleanup on first prompt only (fire-and-forget)
|
|
61
|
+
if (session.prompt_count === 0) {
|
|
62
|
+
try {
|
|
63
|
+
const ttlHours = getStaleSessionTTL(cwd);
|
|
64
|
+
const removed = cleanStaleSessions(sessionsDir, ttlHours);
|
|
65
|
+
if (removed > 0 && process.env.DEBUG === '1') {
|
|
66
|
+
console.error(`[hook-runtime] Cleaned ${removed} stale session(s) (TTL: ${ttlHours}h)`);
|
|
67
|
+
}
|
|
68
|
+
} catch (_cleanupErr) {
|
|
69
|
+
// Fire-and-forget: never block hook execution
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { engine, session, sessionId, sessionsDir, cwd };
|
|
36
74
|
} catch (error) {
|
|
37
75
|
if (process.env.DEBUG === '1') {
|
|
38
76
|
console.error(`[hook-runtime] Failed to resolve runtime: ${error.message}`);
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
const fs = require('fs');
|
|
19
19
|
const path = require('path');
|
|
20
|
+
const { atomicWriteSync } = require('../utils/atomic-write');
|
|
20
21
|
|
|
21
22
|
const SCHEMA_VERSION = '2.0';
|
|
22
23
|
const DEFAULT_MAX_AGE_HOURS = 24;
|
|
@@ -132,7 +133,7 @@ function createSession(sessionId, cwd, sessionsDir) {
|
|
|
132
133
|
const filePath = resolveSessionFile(sessionId, dir);
|
|
133
134
|
|
|
134
135
|
try {
|
|
135
|
-
|
|
136
|
+
atomicWriteSync(filePath, JSON.stringify(session, null, 2));
|
|
136
137
|
} catch (error) {
|
|
137
138
|
if (error.code === 'EACCES' || error.code === 'EPERM') {
|
|
138
139
|
console.error(`[synapse:session] Error: Permission denied creating session ${sessionId}`);
|
|
@@ -227,7 +228,7 @@ function updateSession(sessionId, sessionsDir, updates) {
|
|
|
227
228
|
const filePath = resolveSessionFile(sessionId, sessionsDir);
|
|
228
229
|
|
|
229
230
|
try {
|
|
230
|
-
|
|
231
|
+
atomicWriteSync(filePath, JSON.stringify(session, null, 2));
|
|
231
232
|
} catch (error) {
|
|
232
233
|
if (error.code === 'EACCES' || error.code === 'EPERM') {
|
|
233
234
|
console.error(`[synapse:session] Error: Permission denied writing session ${sessionId}`);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic Write Utility
|
|
3
|
+
*
|
|
4
|
+
* Writes files atomically using write-to-tmp + rename pattern.
|
|
5
|
+
* Prevents file corruption on unexpected exit (crash, kill, power loss).
|
|
6
|
+
*
|
|
7
|
+
* Pattern:
|
|
8
|
+
* 1. Write data to {filePath}.tmp.{pid}
|
|
9
|
+
* 2. On Windows: unlink target if exists (rename won't overwrite)
|
|
10
|
+
* 3. Rename tmp → target (atomic on POSIX, near-atomic on Windows)
|
|
11
|
+
* 4. On failure: clean up tmp file
|
|
12
|
+
*
|
|
13
|
+
* @module core/synapse/utils/atomic-write
|
|
14
|
+
* @version 1.0.0
|
|
15
|
+
* @created Story NOG-12 - State Persistence Hardening
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const IS_WINDOWS = process.platform === 'win32';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Write data to a file atomically.
|
|
27
|
+
*
|
|
28
|
+
* Writes to a temporary file first, then renames to the target path.
|
|
29
|
+
* If the process crashes between write and rename, the original file
|
|
30
|
+
* remains intact and the orphaned .tmp file is harmless.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} filePath - Target file path
|
|
33
|
+
* @param {string} data - Data to write
|
|
34
|
+
* @param {string} [encoding='utf8'] - File encoding
|
|
35
|
+
* @throws {Error} If write or rename fails (original file preserved)
|
|
36
|
+
*/
|
|
37
|
+
function atomicWriteSync(filePath, data, encoding = 'utf8') {
|
|
38
|
+
const tmpPath = `${filePath}.tmp.${process.pid}`;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Ensure parent directory exists
|
|
42
|
+
const dir = path.dirname(filePath);
|
|
43
|
+
if (!fs.existsSync(dir)) {
|
|
44
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Step 1: Write to temporary file
|
|
48
|
+
fs.writeFileSync(tmpPath, data, encoding);
|
|
49
|
+
|
|
50
|
+
// Step 2: On Windows, unlink target first (rename won't overwrite)
|
|
51
|
+
if (IS_WINDOWS) {
|
|
52
|
+
try {
|
|
53
|
+
fs.unlinkSync(filePath);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (err.code !== 'ENOENT') {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
// ENOENT = target doesn't exist yet, that's fine
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Step 3: Atomic rename
|
|
63
|
+
fs.renameSync(tmpPath, filePath);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
// Clean up tmp file on failure
|
|
66
|
+
try {
|
|
67
|
+
fs.unlinkSync(tmpPath);
|
|
68
|
+
} catch (_cleanupErr) {
|
|
69
|
+
// Ignore cleanup errors
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.error(`[atomic-write] Failed to write ${filePath}: ${error.message}`);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
atomicWriteSync,
|
|
79
|
+
};
|
|
@@ -162,6 +162,9 @@ projectStatus:
|
|
|
162
162
|
statusFile: .aios/project-status.yaml
|
|
163
163
|
maxModifiedFiles: 5
|
|
164
164
|
maxRecentCommits: 2
|
|
165
|
+
synapse:
|
|
166
|
+
session:
|
|
167
|
+
staleTTLHours: 168 # 7 days — sessions older than this are cleaned up on first prompt
|
|
165
168
|
agentIdentity:
|
|
166
169
|
greeting:
|
|
167
170
|
preference: auto
|
|
@@ -321,7 +324,7 @@ ideSync:
|
|
|
321
324
|
github-copilot:
|
|
322
325
|
enabled: true
|
|
323
326
|
path: .github/agents
|
|
324
|
-
format:
|
|
327
|
+
format: github-copilot
|
|
325
328
|
cursor:
|
|
326
329
|
enabled: true
|
|
327
330
|
path: .cursor/rules/agents
|
|
@@ -352,4 +355,34 @@ autoClaude:
|
|
|
352
355
|
enabled: false
|
|
353
356
|
qa:
|
|
354
357
|
enabled: false
|
|
358
|
+
# Boundary Mapping — Framework-Project Separation (Epic BM)
|
|
359
|
+
# Controls deterministic protection of framework core files via Claude Code deny rules.
|
|
360
|
+
# When frameworkProtection is true (default), .claude/settings.json includes deny rules
|
|
361
|
+
# that block Edit/Write operations on L1/L2 paths listed in 'protected' below.
|
|
362
|
+
# Set to false for framework contributors who need to edit core files directly.
|
|
363
|
+
# NOTE: This flag is read by the installer during settings.json generation.
|
|
364
|
+
# Changing this value alone does NOT add/remove deny rules — re-run the installer.
|
|
365
|
+
# SINGLE SOURCE OF TRUTH: Both pre-commit hook (framework-guard.js) and
|
|
366
|
+
# the installer read protected/exceptions from here. Do NOT hardcode paths elsewhere.
|
|
367
|
+
boundary:
|
|
368
|
+
frameworkProtection: false # TEMPORARY: TOK-3 contributor mode — re-enable after story
|
|
369
|
+
# L1/L2 paths — blocked from editing in project mode
|
|
370
|
+
# Glob syntax: ** matches any depth, * matches single segment
|
|
371
|
+
protected:
|
|
372
|
+
- .aios-core/core/**
|
|
373
|
+
- .aios-core/development/tasks/**
|
|
374
|
+
- .aios-core/development/templates/**
|
|
375
|
+
- .aios-core/development/checklists/**
|
|
376
|
+
- .aios-core/development/workflows/**
|
|
377
|
+
- .aios-core/infrastructure/**
|
|
378
|
+
- .aios-core/constitution.md
|
|
379
|
+
- bin/aios.js
|
|
380
|
+
- bin/aios-init.js
|
|
381
|
+
# L3 paths — mutable exceptions (allowed even within .aios-core/)
|
|
382
|
+
exceptions:
|
|
383
|
+
- .aios-core/data/**
|
|
384
|
+
- .aios-core/development/agents/*/MEMORY.md
|
|
385
|
+
- .aios-core/core/config/schemas/**
|
|
386
|
+
- .aios-core/core/config/template-overrides.js
|
|
387
|
+
|
|
355
388
|
# Memory Intelligence System (Epic MIS) configuration placeholder — MIS-2+
|
|
@@ -86,7 +86,7 @@ AIOS transforms you into a "Vibe CEO" - directing a team of specialized AI agent
|
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
88
|
# Interactive installation (recommended)
|
|
89
|
-
npx
|
|
89
|
+
npx aios-core install
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
**Installation Steps**:
|
|
@@ -889,7 +889,7 @@ Squads extend AIOS-Method beyond traditional software development into ANY domai
|
|
|
889
889
|
3. **Install via CLI**:
|
|
890
890
|
|
|
891
891
|
```bash
|
|
892
|
-
npx
|
|
892
|
+
npx aios-core install
|
|
893
893
|
# Select "Install squad" option
|
|
894
894
|
```
|
|
895
895
|
|