akm-cli 0.9.0-rc.1 → 0.9.0-rc.13
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/CHANGELOG.md +1190 -52
- package/README.md +62 -37
- package/SECURITY.md +46 -31
- package/dist/akm +162 -38
- package/dist/akm-migrate +44 -0
- package/dist/assets/backends/schtasks-template.xml +2 -1
- package/dist/assets/hints/cli-hints-full.md +268 -118
- package/dist/assets/hints/cli-hints-short.md +87 -24
- package/dist/assets/{profiles → improve-strategies}/catchup.json +3 -1
- package/dist/assets/{profiles → improve-strategies}/consolidate.json +3 -1
- package/dist/assets/{profiles → improve-strategies}/default.json +6 -7
- package/dist/assets/improve-strategies/frequent.json +15 -0
- package/dist/assets/{profiles → improve-strategies}/graph-refresh.json +4 -2
- package/dist/assets/{profiles → improve-strategies}/memory-focus.json +4 -1
- package/dist/assets/{profiles → improve-strategies}/proactive-maintenance.json +5 -5
- package/dist/assets/{profiles → improve-strategies}/quick.json +4 -2
- package/dist/assets/improve-strategies/reflect-distill.json +30 -0
- package/dist/assets/{profiles → improve-strategies}/thorough.json +1 -1
- package/dist/assets/prompts/consolidate-system.md +5 -5
- package/dist/assets/prompts/extract-session.md +2 -6
- package/dist/assets/prompts/memory-infer-user.md +2 -3
- package/dist/assets/prompts/reflect-llm-framed-contract.md +11 -0
- package/dist/assets/prompts/reflect-llm-schema-contract.md +3 -0
- package/dist/assets/prompts/reflect-output-repair.md +3 -0
- package/dist/assets/stash-skeleton/README.md +38 -10
- package/dist/assets/stash-skeleton/facts/conventions/assets/agent.md +8 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/command.md +8 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/fact.md +14 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/knowledge.md +13 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/lesson.md +9 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/memory.md +11 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/script.md +9 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/skill.md +9 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/workflow.md +8 -0
- package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +100 -0
- package/dist/assets/stash-skeleton/facts/conventions/domains.md +64 -0
- package/dist/assets/stash-skeleton/facts/conventions/organization.md +136 -0
- package/dist/assets/tasks/core/extract.yml +3 -2
- package/dist/assets/tasks/core/improve.yml +2 -1
- package/dist/assets/tasks/core/index-refresh.yml +1 -0
- package/dist/assets/tasks/core/sync.yml +1 -0
- package/dist/assets/tasks/core/version-check.yml +2 -1
- package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +5 -0
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +8 -0
- package/dist/assets/tasks/improve/akm-improve-consolidate.yml +5 -0
- package/dist/assets/tasks/improve/akm-improve-frequent.yml +5 -0
- package/dist/assets/tasks/improve/akm-improve-nightly.yml +5 -0
- package/dist/assets/templates/html/health.html +5 -4
- package/dist/assets/workflows/workflow-template.md +31 -15
- package/dist/cli/invocation.js +279 -0
- package/dist/cli/parse-args.js +5 -90
- package/dist/cli/retired-commands.js +78 -0
- package/dist/cli/shared.js +158 -48
- package/dist/cli-node.mjs +2 -1
- package/dist/cli.js +747 -293
- package/dist/commands/agent/agent-dispatch.js +19 -18
- package/dist/commands/agent/agent-support.js +0 -24
- package/dist/commands/agent/contribute-cli.js +43 -97
- package/dist/commands/completions.js +80 -23
- package/dist/commands/config-cli.js +44 -281
- package/dist/commands/env/env-binding.js +13 -9
- package/dist/commands/env/env-cli.js +76 -159
- package/dist/commands/env/env.js +12 -163
- package/dist/commands/env/marker-path.js +6 -0
- package/dist/commands/env/secret-cli.js +45 -61
- package/dist/commands/env/secret.js +32 -62
- package/dist/commands/feedback-cli.js +179 -85
- package/dist/commands/health/accept-rate.js +58 -0
- package/dist/commands/health/advisories.js +7 -8
- package/dist/commands/health/checks.js +279 -94
- package/dist/commands/health/html-report.js +197 -578
- package/dist/commands/health/improve-metrics.js +277 -246
- package/dist/commands/health/llm-usage.js +19 -19
- package/dist/commands/health/md-report.js +16 -7
- package/dist/commands/health/metrics.js +67 -32
- package/dist/commands/health/renderers.js +47 -0
- package/dist/commands/health/report-view-model.js +508 -0
- package/dist/commands/health/stash-exposure.js +1 -1
- package/dist/commands/health/surfaces.js +16 -56
- package/dist/commands/health/task-runs.js +3 -67
- package/dist/{migrate-storage-node.mjs → commands/health/types-checks.js} +1 -5
- package/dist/commands/health/types-improve.js +29 -0
- package/dist/{output/text/save.js → commands/health/types-metrics.js} +1 -2
- package/dist/commands/health/types-result.js +7 -0
- package/dist/commands/health/types-runs.js +4 -0
- package/dist/commands/health/types-session-log.js +4 -0
- package/dist/commands/health/types-windows.js +4 -0
- package/dist/commands/health/types.js +26 -21
- package/dist/commands/health/windows.js +2 -3
- package/dist/commands/health.js +296 -167
- package/dist/commands/improve/anti-collapse.js +5 -5
- package/dist/commands/improve/autonomy-gate.js +68 -0
- package/dist/commands/improve/collapse-detector.js +65 -52
- package/dist/commands/improve/consolidate/chunking.js +9 -7
- package/dist/commands/improve/consolidate/eligibility.js +1 -23
- package/dist/commands/improve/consolidate/merge.js +4 -0
- package/dist/commands/improve/consolidate.js +454 -1354
- package/dist/commands/improve/content-hash.js +39 -0
- package/dist/commands/improve/distill/content-repair.js +4 -10
- package/dist/commands/improve/distill/promote-memory.js +89 -64
- package/dist/commands/improve/distill/quality-gate.js +118 -42
- package/dist/commands/improve/distill-guards.js +1 -1
- package/dist/commands/improve/distill-promotion-policy.js +33 -888
- package/dist/commands/improve/distill.js +607 -363
- package/dist/commands/improve/eligibility.js +165 -79
- package/dist/commands/improve/extract-cli.js +35 -126
- package/dist/commands/improve/extract-prompt.js +6 -35
- package/dist/commands/improve/extract.js +640 -391
- package/dist/commands/improve/feedback-valence.js +2 -12
- package/dist/commands/improve/improve-cli.js +134 -135
- package/dist/commands/improve/improve-result-file.js +30 -50
- package/dist/commands/improve/improve-run-types.js +4 -0
- package/dist/commands/improve/improve-strategies.js +135 -0
- package/dist/commands/improve/improve.js +904 -701
- package/dist/commands/improve/locks.js +64 -111
- package/dist/commands/improve/loop-stages.js +1110 -923
- package/dist/commands/improve/memory/derived-ref.js +124 -0
- package/dist/commands/improve/memory/memory-belief.js +79 -7
- package/dist/commands/improve/memory/memory-contradiction-detect.js +49 -52
- package/dist/commands/improve/memory/memory-improve.js +25 -37
- package/dist/commands/improve/outcome-loop.js +25 -88
- package/dist/commands/improve/preparation.js +1034 -813
- package/dist/commands/improve/proactive-maintenance.js +34 -9
- package/dist/commands/improve/proposal-envelope.js +31 -0
- package/dist/commands/improve/reflect.js +983 -794
- package/dist/commands/improve/run-context.js +119 -0
- package/dist/commands/improve/salience.js +24 -127
- package/dist/commands/improve/session-asset.js +7 -3
- package/dist/commands/improve/shared.js +14 -34
- package/dist/commands/improve/source-identity.js +28 -0
- package/dist/commands/improve/triage.js +20 -17
- package/dist/commands/lint/base-linter.js +340 -313
- package/dist/commands/lint/env-key-rules.js +31 -47
- package/dist/commands/lint/index.js +185 -30
- package/dist/commands/{events.js → log.js} +28 -38
- package/dist/commands/migrate-cli.js +54 -0
- package/dist/commands/migration-tool.js +55 -0
- package/dist/commands/observability-cli.js +70 -208
- package/dist/commands/proposal/diff-format.js +50 -0
- package/dist/commands/proposal/drain-policies.js +0 -6
- package/dist/commands/proposal/drain.js +91 -40
- package/dist/commands/proposal/proposal-cli.js +134 -132
- package/dist/commands/proposal/proposal-types.js +56 -0
- package/dist/commands/proposal/proposal.js +83 -65
- package/dist/commands/proposal/propose-cli.js +88 -0
- package/dist/commands/proposal/propose.js +105 -88
- package/dist/commands/proposal/repository.js +1303 -278
- package/dist/commands/proposal/validators/proposal-quality-validators.js +16 -6
- package/dist/commands/proposal/validators/proposal-validators.js +61 -12
- package/dist/commands/proposal/validators/proposals.js +6 -8
- package/dist/commands/read/curate.js +78 -73
- package/dist/commands/read/knowledge.js +510 -13
- package/dist/commands/read/registry-search.js +2 -2
- package/dist/commands/read/remember-cli.js +84 -15
- package/dist/commands/read/search-cli.js +203 -96
- package/dist/commands/read/search.js +126 -94
- package/dist/commands/read/show.js +226 -250
- package/dist/commands/registry-cli.js +34 -60
- package/dist/commands/remember.js +18 -57
- package/dist/commands/sources/add-cli.js +104 -49
- package/dist/commands/sources/bundle-cli.js +166 -0
- package/dist/commands/sources/bundle-config-ops.js +63 -0
- package/dist/commands/sources/info.js +27 -15
- package/dist/commands/sources/init.js +30 -40
- package/dist/commands/sources/installed-stashes.js +469 -172
- package/dist/commands/sources/schema-repair.js +10 -9
- package/dist/commands/sources/self-update.js +182 -121
- package/dist/commands/sources/source-add.js +169 -178
- package/dist/commands/sources/source-clone.js +144 -41
- package/dist/commands/sources/source-manage.js +94 -59
- package/dist/commands/sources/sources-cli.js +64 -205
- package/dist/commands/sources/stash-cli.js +91 -54
- package/dist/commands/sources/stash-skeleton.js +1 -1
- package/dist/commands/tasks/tasks-cli.js +106 -104
- package/dist/commands/tasks/tasks.js +445 -262
- package/dist/commands/workflow-cli.js +75 -228
- package/dist/core/action-contributors.js +1 -1
- package/dist/core/activation-policy.js +49 -0
- package/dist/core/adapter/adapters/agent-skills-adapter.js +181 -0
- package/dist/core/adapter/adapters/akm-adapter.js +528 -0
- package/dist/core/adapter/adapters/akm-lint.js +392 -0
- package/dist/core/adapter/adapters/akm-metadata.js +387 -0
- package/dist/core/adapter/adapters/akm-task-adapter.js +149 -0
- package/dist/core/adapter/adapters/akm-workflow-adapter.js +180 -0
- package/dist/core/adapter/adapters/claude-adapter.js +61 -0
- package/dist/core/adapter/adapters/dotenv-adapter.js +187 -0
- package/dist/core/adapter/adapters/generic-files-adapter.js +119 -0
- package/dist/core/adapter/adapters/index.js +80 -0
- package/dist/core/adapter/adapters/llm-wiki-adapter.js +419 -0
- package/dist/core/adapter/adapters/okf-adapter.js +391 -0
- package/dist/core/adapter/adapters/opencode-adapter.js +68 -0
- package/dist/core/adapter/adapters/shared.js +286 -0
- package/dist/core/adapter/adapters/tool-dir-shared.js +217 -0
- package/dist/core/adapter/adapters/website-snapshot-adapter.js +155 -0
- package/dist/core/adapter/bundle-adapter.js +4 -0
- package/dist/core/adapter/detect-adapter.js +17 -0
- package/dist/core/adapter/recognize-match.js +44 -0
- package/dist/core/adapter/registry.js +56 -0
- package/dist/core/adapter/types.js +4 -0
- package/dist/core/asset/akm-markdown.js +30 -0
- package/dist/core/asset/asset-placement.js +243 -0
- package/dist/core/asset/asset-ref.js +110 -79
- package/dist/core/asset/asset-serialize.js +20 -0
- package/dist/core/asset/frontmatter.js +28 -12
- package/dist/core/asset/markdown.js +40 -51
- package/dist/core/asset/resolve-ref.js +274 -0
- package/dist/core/asset/stash-meta.js +2 -2
- package/dist/core/bundle-id.js +51 -0
- package/dist/core/common.js +281 -86
- package/dist/core/config/config-io.js +42 -128
- package/dist/core/config/config-schema.js +233 -855
- package/dist/core/config/config-sources.js +162 -39
- package/dist/core/config/config-types.js +16 -11
- package/dist/core/config/config-version.js +29 -0
- package/dist/core/config/config-walker.js +126 -37
- package/dist/core/config/config.js +154 -331
- package/dist/core/config/deep-merge.js +41 -0
- package/dist/core/config/engine-semantics.js +28 -0
- package/dist/core/config/experimental.js +21 -0
- package/dist/core/config/schema/embedding.js +38 -0
- package/dist/core/config/schema/engines.js +116 -0
- package/dist/core/config/schema/experimental.js +47 -0
- package/dist/core/config/schema/feedback.js +31 -0
- package/dist/core/config/schema/improve-processes.js +389 -0
- package/dist/core/config/schema/improve.js +94 -0
- package/dist/core/config/schema/index-config.js +176 -0
- package/dist/core/config/schema/output.js +18 -0
- package/dist/core/config/schema/primitives.js +94 -0
- package/dist/core/config/schema/search.js +30 -0
- package/dist/core/config/schema/setup.js +18 -0
- package/dist/core/config/schema/sources-bundles.js +169 -0
- package/dist/core/config/schema/workflow.js +29 -0
- package/dist/core/env-secret-ref.js +155 -20
- package/dist/core/errors.js +17 -15
- package/dist/core/events-types.js +4 -0
- package/dist/core/events.js +46 -128
- package/dist/core/extra-params.js +62 -0
- package/dist/core/file-change.js +17 -0
- package/dist/core/file-lock.js +202 -57
- package/dist/core/fs-txn.js +392 -0
- package/dist/core/git-message.js +59 -0
- package/dist/core/improve-result.js +167 -0
- package/dist/core/lesson-lint.js +1 -17
- package/dist/core/logs-db.js +1 -1
- package/dist/core/maintenance-barrier.js +135 -0
- package/dist/core/migration-operation.js +44 -0
- package/dist/core/mutation-target.js +78 -0
- package/dist/core/paths.js +22 -25
- package/dist/core/platform.js +10 -0
- package/dist/core/recognition-util.js +128 -0
- package/dist/core/redaction.js +392 -0
- package/dist/core/standards/resolve-standards-context.js +36 -65
- package/dist/core/standards/resolve-stash-standards.js +2 -2
- package/dist/core/standards/resolve-type-conventions.js +5 -5
- package/dist/core/state/migrations.js +242 -11
- package/dist/core/state-db.js +98 -10
- package/dist/core/structured.js +1 -1
- package/dist/core/subprocess.js +303 -0
- package/dist/core/text-truncation.js +9 -5
- package/dist/core/time.js +20 -0
- package/dist/core/type-presentation.js +130 -0
- package/dist/core/warn.js +0 -3
- package/dist/core/write-source.js +834 -118
- package/dist/indexer/bundle-identity-guard.js +92 -0
- package/dist/indexer/db/graph-db.js +1 -25
- package/dist/indexer/db/llm-cache.js +1 -1
- package/dist/indexer/ensure-index.js +30 -9
- package/dist/indexer/graph/graph-boost.js +9 -30
- package/dist/indexer/graph/graph-extraction.js +41 -27
- package/dist/indexer/graph/graph-types.js +4 -0
- package/dist/indexer/index-writer-lock.js +93 -49
- package/dist/indexer/index-written-assets.js +100 -53
- package/dist/indexer/indexer.js +746 -329
- package/dist/indexer/init.js +18 -25
- package/dist/indexer/installations.js +142 -0
- package/dist/indexer/passes/dir-staleness.js +18 -10
- package/dist/indexer/passes/memory-inference.js +25 -15
- package/dist/indexer/passes/metadata.js +412 -243
- package/dist/indexer/scan/doc-to-entry.js +160 -0
- package/dist/indexer/scan/drain-dir.js +134 -0
- package/dist/indexer/search/db-search.js +292 -108
- package/dist/indexer/search/fts-query.js +64 -0
- package/dist/indexer/search/ranking-contributors.js +145 -25
- package/dist/indexer/search/ranking-types.js +4 -0
- package/dist/indexer/search/ranking.js +28 -71
- package/dist/indexer/search/search-attribution.js +67 -0
- package/dist/indexer/search/search-fields.js +18 -3
- package/dist/indexer/search/search-hit-enrichers.js +30 -40
- package/dist/indexer/search/search-source.js +157 -111
- package/dist/indexer/search/semantic-status.js +4 -1
- package/dist/indexer/usage/usage-events.js +10 -30
- package/dist/indexer/walk/file-context.js +3 -45
- package/dist/indexer/walk/matchers.js +42 -73
- package/dist/indexer/walk/path-resolver.js +11 -5
- package/dist/indexer/walk/walker.js +42 -14
- package/dist/integrations/agent/builder-shared.js +7 -0
- package/dist/integrations/agent/builders.js +5 -58
- package/dist/integrations/agent/config.js +3 -143
- package/dist/integrations/agent/detect.js +17 -2
- package/dist/integrations/agent/engine-resolution.js +231 -0
- package/dist/integrations/agent/index.js +1 -2
- package/dist/integrations/agent/model-aliases.js +8 -3
- package/dist/integrations/agent/profiles.js +6 -99
- package/dist/integrations/agent/prompts.js +46 -18
- package/dist/integrations/agent/runner-dispatch.js +78 -13
- package/dist/integrations/agent/runner.js +76 -208
- package/dist/integrations/agent/spawn.js +48 -279
- package/dist/integrations/harnesses/aider/agent-builder.js +9 -8
- package/dist/integrations/harnesses/aider/index.js +2 -12
- package/dist/integrations/harnesses/amazonq/agent-builder.js +10 -16
- package/dist/integrations/harnesses/amazonq/index.js +3 -17
- package/dist/integrations/harnesses/claude/agent-builder.js +2 -3
- package/dist/integrations/harnesses/claude/config-import.js +1 -3
- package/dist/integrations/harnesses/claude/index.js +1 -14
- package/dist/integrations/harnesses/claude/session-log.js +27 -75
- package/dist/integrations/harnesses/codex/agent-builder.js +8 -7
- package/dist/integrations/harnesses/codex/index.js +2 -13
- package/dist/integrations/harnesses/copilot/agent-builder.js +9 -9
- package/dist/integrations/harnesses/copilot/index.js +1 -13
- package/dist/integrations/harnesses/gemini/agent-builder.js +8 -9
- package/dist/integrations/harnesses/gemini/index.js +1 -13
- package/dist/integrations/harnesses/ids.js +24 -0
- package/dist/integrations/harnesses/index.js +31 -33
- package/dist/integrations/harnesses/opencode/agent-builder.js +23 -5
- package/dist/integrations/harnesses/opencode/config-import.js +1 -3
- package/dist/integrations/harnesses/opencode/index.js +1 -18
- package/dist/integrations/harnesses/opencode/session-log.js +67 -125
- package/dist/integrations/harnesses/opencode-sdk/harness.js +3 -17
- package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +274 -191
- package/dist/integrations/harnesses/openhands/agent-builder.js +12 -10
- package/dist/integrations/harnesses/openhands/index.js +2 -12
- package/dist/integrations/harnesses/pi/agent-builder.js +11 -18
- package/dist/integrations/harnesses/pi/index.js +3 -16
- package/dist/integrations/harnesses/shared.js +17 -0
- package/dist/integrations/harnesses/types.js +38 -34
- package/dist/integrations/lockfile.js +211 -24
- package/dist/integrations/session-logs/index.js +24 -40
- package/dist/integrations/session-logs/provider-base.js +113 -0
- package/dist/llm/client.js +182 -110
- package/dist/llm/embedders/deterministic.js +2 -2
- package/dist/llm/embedders/remote.js +21 -9
- package/dist/llm/feature-gate.js +17 -57
- package/dist/llm/graph-extract.js +12 -13
- package/dist/llm/index-passes.js +8 -42
- package/dist/llm/memory-infer.js +144 -1
- package/dist/llm/metadata-enhance.js +45 -30
- package/dist/llm/structured-call.js +16 -8
- package/dist/llm/usage-persist.js +30 -5
- package/dist/llm/usage-telemetry.js +59 -6
- package/dist/output/cli-hints.js +1 -2
- package/dist/output/command-registry.js +27 -0
- package/dist/output/context.js +22 -7
- package/dist/output/format-exempt.js +80 -0
- package/dist/output/generic-render.js +251 -0
- package/dist/output/html-render.js +11 -16
- package/dist/output/render-registry.js +57 -0
- package/dist/output/renderers.js +15 -281
- package/dist/output/shapes/curate.js +10 -1
- package/dist/output/shapes/events.js +12 -7
- package/dist/output/shapes/helpers.js +58 -84
- package/dist/output/shapes/passthrough.js +8 -40
- package/dist/output/shapes/proposal/producer.js +15 -7
- package/dist/output/shapes/registry.js +12 -6
- package/dist/output/shapes.js +0 -9
- package/dist/output/text/{init.js → bundle-create.js} +3 -1
- package/dist/output/text/bundle-show.js +7 -0
- package/dist/output/text/command-format.js +562 -0
- package/dist/output/text/env.js +1 -3
- package/dist/output/text/events.js +8 -7
- package/dist/output/text/helpers.js +15 -1375
- package/dist/output/text/proposal/producer.js +4 -2
- package/dist/output/text/proposal-format.js +202 -0
- package/dist/output/text/registry-commands.js +1 -2
- package/dist/output/text/registry.js +12 -6
- package/dist/output/text/show-directives.js +117 -0
- package/dist/output/text/show-format.js +103 -0
- package/dist/output/text/sync.js +5 -0
- package/dist/output/text/workflow-format.js +332 -0
- package/dist/output/text/workflow.js +1 -2
- package/dist/output/text.js +10 -19
- package/dist/registry/factory.js +4 -6
- package/dist/registry/origin-resolve.js +16 -27
- package/dist/registry/providers/skills-sh.js +3 -3
- package/dist/registry/providers/static-index.js +15 -25
- package/dist/registry/resolve.js +43 -94
- package/dist/registry/semver.js +43 -0
- package/dist/runtime.js +81 -12
- package/dist/scripts/akm-migrate.js +35529 -0
- package/dist/setup/detect.js +5 -7
- package/dist/setup/detected-engines.js +136 -0
- package/dist/setup/engine-config.js +100 -0
- package/dist/setup/registry-stash-loader.js +3 -3
- package/dist/setup/semantic-assets.js +12 -9
- package/dist/setup/setup.js +444 -208
- package/dist/setup/steps/connection-shared.js +120 -0
- package/dist/setup/steps/connection.js +108 -305
- package/dist/setup/steps/platforms.js +13 -12
- package/dist/setup/steps/semantic.js +15 -3
- package/dist/setup/steps/sources.js +21 -15
- package/dist/setup/steps/stashdir.js +6 -4
- package/dist/setup/steps/tasks.js +236 -119
- package/dist/setup/steps.js +3 -2
- package/dist/sources/freshness.js +39 -0
- package/dist/sources/provider-factory.js +11 -17
- package/dist/sources/providers/filesystem.js +2 -3
- package/dist/sources/providers/git-install.js +278 -34
- package/dist/sources/providers/git-provider.js +54 -56
- package/dist/sources/providers/git-stash.js +420 -91
- package/dist/sources/providers/git.js +2 -2
- package/dist/sources/providers/npm.js +16 -19
- package/dist/sources/providers/provider-utils.js +47 -22
- package/dist/sources/providers/sync-from-ref.js +3 -9
- package/dist/sources/providers/website.js +2 -2
- package/dist/sources/resolve.js +11 -10
- package/dist/sources/snapshot-fetchers/types.js +4 -0
- package/dist/sources/{website-ingest.js → snapshot-fetchers/website-ingest.js} +110 -41
- package/dist/storage/database.js +60 -4
- package/dist/storage/engines/sqlite-migrations.js +156 -5
- package/dist/storage/locations.js +1 -2
- package/dist/storage/repositories/canaries-repository.js +1 -1
- package/dist/storage/repositories/events-repository.js +51 -11
- package/dist/storage/repositories/improve-runs-repository.js +6 -32
- package/dist/storage/repositories/index-connection.js +79 -0
- package/dist/storage/repositories/index-db.js +4 -3
- package/dist/storage/repositories/index-entries-repository.js +863 -0
- package/dist/{indexer/db/entry-mapper.js → storage/repositories/index-entry-mapper.js} +19 -2
- package/dist/storage/repositories/index-entry-types.js +4 -0
- package/dist/storage/repositories/index-fts-repository.js +167 -0
- package/dist/storage/repositories/index-llm-cache-repository.js +108 -0
- package/dist/storage/repositories/index-meta-repository.js +49 -0
- package/dist/{indexer/db/schema.js → storage/repositories/index-schema.js} +226 -100
- package/dist/storage/repositories/index-sql.js +12 -0
- package/dist/storage/repositories/index-utility-repository.js +356 -0
- package/dist/storage/repositories/index-vec-repository.js +250 -0
- package/dist/storage/repositories/outcome-repository.js +119 -0
- package/dist/storage/repositories/proposals-repository.js +317 -75
- package/dist/storage/repositories/registry-cache.js +1 -1
- package/dist/storage/repositories/salience-repository.js +172 -0
- package/dist/storage/repositories/task-history-repository.js +110 -3
- package/dist/storage/repositories/workflow-runs-repository.js +68 -35
- package/dist/tasks/backends/cron.js +169 -46
- package/dist/tasks/backends/exec-utils.js +76 -3
- package/dist/tasks/backends/index.js +6 -9
- package/dist/tasks/backends/launchd.js +292 -55
- package/dist/tasks/backends/schtasks.js +557 -70
- package/dist/tasks/backends/types.js +4 -0
- package/dist/tasks/command-executable.js +93 -0
- package/dist/tasks/embedded.js +56 -38
- package/dist/tasks/parser.js +156 -64
- package/dist/tasks/resolve-akm-bin.js +144 -51
- package/dist/tasks/runner.js +377 -209
- package/dist/tasks/schedule.js +108 -19
- package/dist/tasks/scheduler-invocation.js +296 -0
- package/dist/tasks/schema.js +1 -1
- package/dist/tasks/task-id.js +35 -0
- package/dist/tasks/validator.js +30 -16
- package/dist/workflows/authoring/authoring.js +96 -148
- package/dist/workflows/authoring/scope-key.js +1 -1
- package/dist/workflows/cli.js +0 -20
- package/dist/workflows/concurrency-policy.js +15 -0
- package/dist/workflows/exec/brief.js +25 -59
- package/dist/workflows/exec/frozen-judge.js +47 -0
- package/dist/workflows/exec/native-executor.js +157 -94
- package/dist/workflows/exec/report.js +365 -200
- package/dist/workflows/exec/run-workflow.js +46 -40
- package/dist/workflows/exec/scheduler.js +12 -41
- package/dist/workflows/exec/step-work.js +239 -205
- package/dist/workflows/exec/workflow-engine-gate.js +67 -0
- package/dist/workflows/ir/compile.js +141 -283
- package/dist/workflows/ir/freeze.js +233 -0
- package/dist/workflows/ir/plan-hash.js +40 -5
- package/dist/workflows/ir/schema.js +537 -1
- package/dist/workflows/parser.js +878 -306
- package/dist/workflows/program/expressions.js +20 -208
- package/dist/workflows/program/schema.js +7 -10
- package/dist/workflows/renderer.js +99 -121
- package/dist/workflows/resource-limits.js +22 -0
- package/dist/workflows/runtime/checkin.js +1 -1
- package/dist/workflows/runtime/plan-classifier.js +131 -0
- package/dist/workflows/runtime/runs.js +200 -113
- package/dist/workflows/runtime/unit-checkin.js +1 -1
- package/dist/workflows/runtime/unit-phases.js +20 -0
- package/dist/workflows/runtime/workflow-asset-loader.js +235 -97
- package/dist/workflows/schema.js +1 -11
- package/dist/workflows/validate-summary.js +4 -26
- package/dist/workflows/validator.js +52 -30
- package/docs/README.md +42 -78
- package/docs/migration/README.md +8 -0
- package/docs/migration/release-notes/0.6.0.md +1 -1
- package/docs/migration/release-notes/0.7.0.md +9 -8
- package/docs/migration/release-notes/0.9.0.md +158 -14
- package/docs/migration/v0.7-to-v0.8.md +46 -47
- package/docs/migration/v0.8-to-v0.9.md +844 -0
- package/docs/reference/README.md +12 -0
- package/docs/reference/data-and-telemetry.md +333 -0
- package/package.json +21 -17
- package/schemas/akm-asset-envelope.json +93 -0
- package/schemas/akm-config.json +4636 -0
- package/schemas/akm-task.json +87 -0
- package/{dist/schemas → schemas}/akm-workflow.json +127 -82
- package/dist/akm-migrate-storage +0 -38
- package/dist/assets/help/help-accept.md +0 -12
- package/dist/assets/help/help-improve.md +0 -84
- package/dist/assets/help/help-proposals.md +0 -17
- package/dist/assets/help/help-propose.md +0 -17
- package/dist/assets/help/help-reject.md +0 -11
- package/dist/assets/profiles/frequent.json +0 -13
- package/dist/assets/profiles/recombine-only.json +0 -21
- package/dist/assets/profiles/reflect-distill.json +0 -30
- package/dist/assets/profiles/synthesize.json +0 -15
- package/dist/assets/prompts/procedural-system.md +0 -44
- package/dist/assets/prompts/recombine-system.md +0 -40
- package/dist/assets/prompts/staleness-detect-system.md +0 -6
- package/dist/assets/tasks/core/backup.yml +0 -4
- package/dist/assets/tasks/graph-refresh-weekly.yml +0 -10
- package/dist/assets/templates/html/default.html +0 -78
- package/dist/assets/templates/html/vendor/echarts.min.js +0 -45
- package/dist/assets/wiki/index-template.md +0 -12
- package/dist/assets/wiki/ingest-workflow-template.md +0 -83
- package/dist/assets/wiki/log-template.md +0 -8
- package/dist/assets/wiki/schema-template.md +0 -61
- package/dist/cli/config-migrate.js +0 -150
- package/dist/cli/config-validate.js +0 -39
- package/dist/commands/graph/graph-cli.js +0 -124
- package/dist/commands/graph/graph.js +0 -487
- package/dist/commands/improve/calibration.js +0 -161
- package/dist/commands/improve/dedup.js +0 -482
- package/dist/commands/improve/extract-watch.js +0 -140
- package/dist/commands/improve/hot-probation.js +0 -45
- package/dist/commands/improve/improve-auto-accept.js +0 -276
- package/dist/commands/improve/improve-profiles.js +0 -168
- package/dist/commands/improve/procedural.js +0 -398
- package/dist/commands/improve/recombine.js +0 -818
- package/dist/commands/improve/schema-similarity-gate.js +0 -168
- package/dist/commands/lint/agent-linter.js +0 -44
- package/dist/commands/lint/command-linter.js +0 -44
- package/dist/commands/lint/default-linter.js +0 -16
- package/dist/commands/lint/fact-linter.js +0 -39
- package/dist/commands/lint/knowledge-linter.js +0 -16
- package/dist/commands/lint/memory-linter.js +0 -61
- package/dist/commands/lint/registry.js +0 -41
- package/dist/commands/lint/skill-linter.js +0 -45
- package/dist/commands/lint/task-linter.js +0 -50
- package/dist/commands/lint/workflow-linter.js +0 -81
- package/dist/commands/proposal/legacy-import.js +0 -115
- package/dist/commands/sources/history.js +0 -196
- package/dist/commands/tasks/default-tasks.js +0 -186
- package/dist/commands/wiki-cli.js +0 -292
- package/dist/core/asset/asset-registry.js +0 -76
- package/dist/core/asset/asset-spec.js +0 -316
- package/dist/core/config/config-migration.js +0 -602
- package/dist/core/deep-merge.js +0 -38
- package/dist/core/eval/rank-metrics.js +0 -113
- package/dist/core/ripgrep/install.js +0 -163
- package/dist/core/ripgrep/resolve.js +0 -81
- package/dist/indexer/db/db.js +0 -1414
- package/dist/indexer/manifest.js +0 -170
- package/dist/indexer/passes/metadata-contributors.js +0 -31
- package/dist/indexer/usage/unmigrated-vaults-guard.js +0 -94
- package/dist/integrations/harnesses/opencode-sdk/index.js +0 -25
- package/dist/llm/call-ai.js +0 -62
- package/dist/llm/memory-infer-impl.js +0 -138
- package/dist/output/shapes/distill.js +0 -14
- package/dist/output/shapes/history.js +0 -11
- package/dist/output/text/distill.js +0 -6
- package/dist/output/text/enable-disable.js +0 -8
- package/dist/output/text/history.js +0 -6
- package/dist/output/text/wiki.js +0 -16
- package/dist/registry/build-index.js +0 -386
- package/dist/schemas/akm-config.json +0 -14225
- package/dist/scripts/migrate-storage.js +0 -13169
- package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +0 -10169
- package/dist/scripts/migrations/v16-to-v17.js +0 -141
- package/dist/setup/legacy-config.js +0 -106
- package/dist/storage/repositories/consolidation-repository.js +0 -38
- package/dist/storage/repositories/recombine-repository.js +0 -213
- package/dist/wiki/wiki-templates.js +0 -15
- package/dist/wiki/wiki.js +0 -1012
- package/dist/workflows/authoring/workflow-program-template.yaml +0 -31
- package/dist/workflows/db.js +0 -350
- package/dist/workflows/exec/watch.js +0 -116
- package/dist/workflows/program/parser.js +0 -760
- package/dist/workflows/program/project.js +0 -105
- package/docs/data-and-telemetry.md +0 -227
- package/docs/migration/release-notes/0.9.0-beta.60.md +0 -19
- /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/registry.js +0 -0
- /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/youtube.js +0 -0
|
@@ -9,159 +9,38 @@
|
|
|
9
9
|
* strict superset of the skill's report.html; this module computes the 17
|
|
10
10
|
* `%%TOKEN%%` replacements it consumes.
|
|
11
11
|
*
|
|
12
|
+
* Structure (chunk-9 WI-9.5a / H2, anchors C.6): `./report-view-model.ts`
|
|
13
|
+
* holds the pure `AkmHealthResult`→`HealthReportViewModel` extractor — every
|
|
14
|
+
* computed number/string/series the report shows, with NO HTML. This module
|
|
15
|
+
* holds the thin VM→HTML fragment renderers (one per template section) plus
|
|
16
|
+
* `buildHealthHtmlReplacements`, the extract-then-render glue that produces
|
|
17
|
+
* the 17-token replacement map.
|
|
18
|
+
*
|
|
12
19
|
* Determinism: nothing here depends on Date.now()/Math.random(). Runs are
|
|
13
20
|
* sorted by startedAt; `%%GENERATED_AT%%` derives from the latest run (or the
|
|
14
21
|
* window anchor), so output is byte-identical for identical inputs.
|
|
22
|
+
*
|
|
23
|
+
* ECharts delivery (chunk-9 WI-9.4d, anchors C.1): CDN-only. The vendored
|
|
24
|
+
* `~1MB` `echarts.min.js` self-contained/"inline" mode was removed along with
|
|
25
|
+
* the asset itself — `buildEchartsTag` always emits a `<script src>` tag
|
|
26
|
+
* pointed at the jsDelivr CDN, so viewing the report now requires network
|
|
27
|
+
* access. There is no env var or option to opt back into an offline report.
|
|
15
28
|
*/
|
|
16
|
-
import fs from "node:fs";
|
|
17
|
-
import path from "node:path";
|
|
18
29
|
import { escapeHtml } from "../../output/html-render.js";
|
|
19
|
-
import { getDirname } from "../../runtime.js";
|
|
20
30
|
import { pkgVersion } from "../../version.js";
|
|
21
|
-
import {
|
|
22
|
-
/**
|
|
23
|
-
* Distill skip-reasons hidden from the breakdown chart. `no new signal since
|
|
24
|
-
* last proposal` is the steady-state "nothing changed, nothing to do" outcome —
|
|
25
|
-
* it dominates the histogram and drowns out the actionable reasons, so it is
|
|
26
|
-
* intentionally excluded from the chart (the count still lives in the data).
|
|
27
|
-
*/
|
|
28
|
-
const DISTILL_REASONS_HIDDEN = new Set(["no new signal since last proposal"]);
|
|
29
|
-
const ECHARTS_CDN = "https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js";
|
|
30
|
-
const ECHARTS_VENDOR_PATH = path.join(getDirname(import.meta.url), "../../assets/templates/html/vendor/echarts.min.js");
|
|
31
|
-
// ── Small formatters (ports of render.py helpers) ───────────────────────────
|
|
31
|
+
import { buildHealthReportViewModel, compact, fmtMs, humanize, num, } from "./report-view-model.js";
|
|
32
32
|
const esc = escapeHtml;
|
|
33
33
|
/** Emit a <time> element that the browser's JS will reformat to the viewer's local timezone. */
|
|
34
34
|
function isoTimeTag(iso) {
|
|
35
35
|
const fallback = iso.slice(0, 16).replace("T", " ");
|
|
36
36
|
return `<time data-iso="${esc(iso)}">${esc(fallback)}</time>`;
|
|
37
37
|
}
|
|
38
|
-
function num(value) {
|
|
39
|
-
return Math.round(value).toLocaleString("en-US");
|
|
40
|
-
}
|
|
41
|
-
/** Compact token/count formatter, e.g. 127345 → "127K", 1_500_000 → "1.5M". */
|
|
42
|
-
function compact(value) {
|
|
43
|
-
const v = Math.round(value);
|
|
44
|
-
if (Math.abs(v) >= 1_000_000)
|
|
45
|
-
return `${(v / 1_000_000).toFixed(1).replace(/\.0$/, "")}M`;
|
|
46
|
-
if (Math.abs(v) >= 1_000)
|
|
47
|
-
return `${(v / 1_000).toFixed(1).replace(/\.0$/, "")}K`;
|
|
48
|
-
return String(v);
|
|
49
|
-
}
|
|
50
|
-
/** Humanize a camelCase / kebab / snake enum into reader-facing text. */
|
|
51
|
-
function humanize(raw) {
|
|
52
|
-
return raw
|
|
53
|
-
.replace(/[-_]/g, " ")
|
|
54
|
-
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
55
|
-
.replace(/\s+/g, " ")
|
|
56
|
-
.trim()
|
|
57
|
-
.replace(/^./, (c) => c.toUpperCase());
|
|
58
|
-
}
|
|
59
|
-
function fmtMs(ms) {
|
|
60
|
-
return ms ? `${(ms / 60000).toFixed(1)}m` : "—";
|
|
61
|
-
}
|
|
62
|
-
function pct(rate, digits) {
|
|
63
|
-
return `${(rate * 100).toFixed(digits)}%`;
|
|
64
|
-
}
|
|
65
38
|
function trendClass(direction) {
|
|
66
39
|
return direction === "up" ? "trend-up" : direction === "down" ? "trend-down" : "trend-flat";
|
|
67
40
|
}
|
|
68
41
|
function trendLabel(direction) {
|
|
69
42
|
return direction === "up" ? "▲ up" : direction === "down" ? "▼ watch" : "— flat";
|
|
70
43
|
}
|
|
71
|
-
/** pctChange may be a number or an "+inf"/"-inf" sentinel (prior window was 0). */
|
|
72
|
-
function coercePct(raw) {
|
|
73
|
-
if (typeof raw === "number")
|
|
74
|
-
return raw;
|
|
75
|
-
if (typeof raw !== "string")
|
|
76
|
-
return undefined;
|
|
77
|
-
const s = raw.trim().toLowerCase();
|
|
78
|
-
if (s === "+inf" || s === "inf" || s === "infinity" || s === "+infinity")
|
|
79
|
-
return 1e9;
|
|
80
|
-
if (s === "-inf" || s === "-infinity")
|
|
81
|
-
return -1e9;
|
|
82
|
-
const parsed = Number.parseFloat(s.replace(/%$/, ""));
|
|
83
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
84
|
-
}
|
|
85
|
-
function reshapeRun(r) {
|
|
86
|
-
const cons = r.consolidation;
|
|
87
|
-
const mi = r.memoryInference;
|
|
88
|
-
const ge = r.graphExtraction;
|
|
89
|
-
const wall = r.wallTimeMs || 0;
|
|
90
|
-
const consMs = cons.durationMs || 0;
|
|
91
|
-
const miMs = mi.durationMs || 0;
|
|
92
|
-
const geMs = ge.durationMs || 0;
|
|
93
|
-
return {
|
|
94
|
-
id: r.id,
|
|
95
|
-
taskId: r.taskId ?? "manual",
|
|
96
|
-
startedAt: r.startedAt,
|
|
97
|
-
completedAt: r.completedAt,
|
|
98
|
-
wallTimeMs: wall,
|
|
99
|
-
ok: r.ok,
|
|
100
|
-
mode: r.scope.mode,
|
|
101
|
-
consDurationMs: consMs,
|
|
102
|
-
miDurationMs: miMs,
|
|
103
|
-
geDurationMs: geMs,
|
|
104
|
-
otherMs: Math.max(0, wall - consMs - miMs - geMs),
|
|
105
|
-
consRan: cons.ran,
|
|
106
|
-
promoted: cons.promoted,
|
|
107
|
-
merged: cons.merged,
|
|
108
|
-
deleted: cons.deleted,
|
|
109
|
-
contradicted: cons.contradicted,
|
|
110
|
-
judgedNoAction: cons.judgedNoAction,
|
|
111
|
-
processed: cons.processed,
|
|
112
|
-
failedChunks: cons.failedChunks,
|
|
113
|
-
totalChunks: cons.totalChunks,
|
|
114
|
-
miWritten: mi.written || mi.writes || 0,
|
|
115
|
-
miConsidered: mi.considered,
|
|
116
|
-
miYieldRate: mi.yieldRate,
|
|
117
|
-
miCacheHits: mi.cacheHits,
|
|
118
|
-
geEntities: ge.entities,
|
|
119
|
-
geRelations: ge.relations,
|
|
120
|
-
geCacheHitRate: ge.cacheHitRate,
|
|
121
|
-
geFailures: ge.failures,
|
|
122
|
-
distillSkipped: r.actions.distill.skipped,
|
|
123
|
-
distillQueued: r.actions.distill.queued,
|
|
124
|
-
distillLlmFailed: r.actions.distill.llmFailed,
|
|
125
|
-
distillByReason: r.actions.distill.skippedByReason,
|
|
126
|
-
reflectOk: r.actions.reflect.ok,
|
|
127
|
-
reflectFailed: r.actions.reflect.failed,
|
|
128
|
-
derived: r.memorySummary.derived,
|
|
129
|
-
eligible: r.memorySummary.eligible,
|
|
130
|
-
lintFlagged: r.lintFlagged,
|
|
131
|
-
lintFixed: r.lintFixed,
|
|
132
|
-
reflectsWithErrorContext: r.reflectsWithErrorContext,
|
|
133
|
-
orphansPurged: r.orphansPurged,
|
|
134
|
-
evalCasesWritten: r.evalCasesWritten,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
// ── Trend classification (port of collect.py classify) ──────────────────────
|
|
138
|
-
function classify(deltas, metricKeys, lowerIsBetter = false) {
|
|
139
|
-
const changes = metricKeys
|
|
140
|
-
.map((key) => coercePct(deltas[key]?.pctChange))
|
|
141
|
-
.filter((c) => c !== undefined);
|
|
142
|
-
if (changes.length === 0)
|
|
143
|
-
return "flat";
|
|
144
|
-
const avg = changes.reduce((acc, c) => acc + c, 0) / changes.length;
|
|
145
|
-
if (Math.abs(avg) < 5)
|
|
146
|
-
return "flat";
|
|
147
|
-
const direction = avg > 0 ? "up" : "down";
|
|
148
|
-
if (lowerIsBetter)
|
|
149
|
-
return avg > 0 ? "down" : "up";
|
|
150
|
-
return direction;
|
|
151
|
-
}
|
|
152
|
-
function buildTrend(deltas) {
|
|
153
|
-
const decisionQuality = classify(deltas, ["improve.memoryInference.yieldRate", "improve.consolidation.promoted"]);
|
|
154
|
-
const outputVolume = classify(deltas, [
|
|
155
|
-
"improve.consolidation.promoted",
|
|
156
|
-
"improve.memoryInference.written",
|
|
157
|
-
"improve.sessionExtraction.proposalsCreated",
|
|
158
|
-
]);
|
|
159
|
-
const failures = classify(deltas, ["improve.graphExtraction.failures"], true);
|
|
160
|
-
const latency = classify(deltas, ["improve.wallTime.medianMs", "improve.wallTime.p95Ms"], true);
|
|
161
|
-
const score = [decisionQuality, outputVolume, failures, latency].reduce((acc, d) => acc + (d === "up" ? 1 : d === "down" ? -1 : 0), 0);
|
|
162
|
-
const overall = score >= 1 ? "improving" : score <= -1 ? "degrading" : "mixed";
|
|
163
|
-
return { decisionQuality, outputVolume, failures, latency, overall };
|
|
164
|
-
}
|
|
165
44
|
function deltaPill(deltas, key, lowerIsBetter = false) {
|
|
166
45
|
const raw = deltas[key]?.pctChange;
|
|
167
46
|
if (raw === undefined)
|
|
@@ -192,238 +71,106 @@ function passCard(title, desc) {
|
|
|
192
71
|
`<div class="title">${esc(title)}</div>` +
|
|
193
72
|
`<div class="desc">${esc(desc)}</div></div></div>`);
|
|
194
73
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const blocked = check.status !== "pass" || status.toLowerCase().includes("block");
|
|
202
|
-
const entries = typeof evidence.entryCount === "number" ? evidence.entryCount : 0;
|
|
203
|
-
const embeddings = typeof evidence.embeddingCount === "number" ? evidence.embeddingCount : 0;
|
|
204
|
-
return { blocked, detail: `${num(entries)} entries, ${num(embeddings)} embeddings` };
|
|
205
|
-
}
|
|
74
|
+
// ── Status badges (presentation constants) ───────────────────────────────────
|
|
75
|
+
const badgeByStatus = {
|
|
76
|
+
pass: { badge: "badge-pass", dot: "dot-pass", label: "PASS" },
|
|
77
|
+
warn: { badge: "badge-warn", dot: "dot-warn", label: "WARN" },
|
|
78
|
+
fail: { badge: "badge-fail", dot: "dot-fail", label: "FAIL" },
|
|
79
|
+
};
|
|
206
80
|
// ── ECharts delivery ─────────────────────────────────────────────────────────
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return 0;
|
|
212
|
-
const n = Number(m[1]);
|
|
213
|
-
const mult = { m: 60_000, h: 3_600_000, d: 86_400_000, w: 604_800_000 }[m[2].toLowerCase()] ?? 0;
|
|
214
|
-
return n * mult;
|
|
81
|
+
const ECHARTS_CDN = "https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js";
|
|
82
|
+
/** Always CDN — see the module docstring's chunk-9 WI-9.4d note. */
|
|
83
|
+
function buildEchartsTag() {
|
|
84
|
+
return `<script src="${ECHARTS_CDN}"></script>`;
|
|
215
85
|
}
|
|
216
86
|
/**
|
|
217
|
-
* Build the time-slice `<option>`s for the report's filter bar, DERIVED from
|
|
218
|
-
* actual report window so the choices always make
|
|
219
|
-
* 1d–21d list was useless on a 24h or 7d report).
|
|
220
|
-
* sub-window options carry their cutoff in
|
|
221
|
-
* filteredRuns), largest first
|
|
87
|
+
* Build the time-slice `<option>`s for the report's filter bar, DERIVED from
|
|
88
|
+
* the actual report window (`vm.sliceCandidates`) so the choices always make
|
|
89
|
+
* sense (the old hard-coded 1d–21d list was useless on a 24h or 7d report).
|
|
90
|
+
* "All" is the default; the sub-window options carry their cutoff in
|
|
91
|
+
* milliseconds (consumed by filteredRuns), largest first.
|
|
222
92
|
*/
|
|
223
|
-
function buildSliceOptions(
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const DAY = 86_400_000;
|
|
227
|
-
const candidates = [
|
|
228
|
-
[6 * HOUR, "6h"],
|
|
229
|
-
[12 * HOUR, "12h"],
|
|
230
|
-
[DAY, "1d"],
|
|
231
|
-
[3 * DAY, "3d"],
|
|
232
|
-
[7 * DAY, "7d"],
|
|
233
|
-
[14 * DAY, "14d"],
|
|
234
|
-
];
|
|
235
|
-
const subs = candidates
|
|
236
|
-
.filter(([ms]) => windowMs > 0 && ms < windowMs)
|
|
237
|
-
.sort((a, b) => b[0] - a[0])
|
|
238
|
-
.slice(0, 4);
|
|
239
|
-
const opts = [`<option value="all" selected>All (${esc(window)})</option>`];
|
|
240
|
-
for (const [ms, label] of subs)
|
|
93
|
+
function buildSliceOptions(vm) {
|
|
94
|
+
const opts = [`<option value="all" selected>All (${esc(vm.window)})</option>`];
|
|
95
|
+
for (const [ms, label] of vm.sliceCandidates)
|
|
241
96
|
opts.push(`<option value="${ms}">Last ${label}</option>`);
|
|
242
97
|
return opts.join("\n ");
|
|
243
98
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
99
|
+
// ── Fragment renderers (VM → HTML; one per template section) ────────────────
|
|
100
|
+
function renderSinceHuman(vm) {
|
|
101
|
+
return vm.sinceIso ? `${isoTimeTag(vm.sinceIso)} → now` : `last ${esc(vm.window)}`;
|
|
102
|
+
}
|
|
103
|
+
function renderStatusBadgeHtml(vm) {
|
|
104
|
+
const badge = badgeByStatus[vm.status];
|
|
105
|
+
const statusBadge = `<span class="badge-pill ${badge.badge}"><span class="dot ${badge.dot}"></span>${badge.label}</span>`;
|
|
106
|
+
const failBadge = `<span class="badge-pill ${vm.failOk ? "badge-pass" : "badge-warn"}">` +
|
|
107
|
+
`<span class="dot ${vm.failOk ? "dot-pass" : "dot-warn"}"></span>${vm.taskFailRate} Fail Rate</span>`;
|
|
108
|
+
return `${statusBadge}\n ${failBadge}`;
|
|
252
109
|
}
|
|
253
|
-
// ── Main builder ─────────────────────────────────────────────────────────────
|
|
254
110
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* fragments, matching the skill template. Advisories and "what to watch" are
|
|
259
|
-
* merged + de-duplicated into a single prioritized `%%ACTION_ITEMS_HTML%%`.
|
|
111
|
+
* Executive-summary block: quick numbers, trend pills, period-over-period
|
|
112
|
+
* deltas, the current-run snapshot, the window facts, the synthesized verdict
|
|
113
|
+
* sentence, and the freshness line.
|
|
260
114
|
*/
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
const runs = (result.runs ?? []).map(reshapeRun).sort((a, b) => a.startedAt.localeCompare(b.startedAt));
|
|
264
|
-
const improve = result.improve;
|
|
265
|
-
const proposals = opts.proposals;
|
|
266
|
-
const sem = readSemSearch(result.advisories);
|
|
267
|
-
const trend = buildTrend(deltas);
|
|
268
|
-
// ── Aggregates (collect.py step 6) ─────────────────────────────────────────
|
|
269
|
-
const cons = improve.consolidation;
|
|
270
|
-
const mi = improve.memoryInference;
|
|
271
|
-
const ge = improve.graphExtraction;
|
|
272
|
-
const wallTime = improve.wallTime;
|
|
273
|
-
// WS-5: perf telemetry, coverage, and degradation metrics.
|
|
274
|
-
const perf = improve.perfTelemetry ?? {
|
|
275
|
-
dedupPoolSize: 0,
|
|
276
|
-
llmPoolSize: 0,
|
|
277
|
-
judgedCacheSkipped: 0,
|
|
278
|
-
embedMs: 0,
|
|
279
|
-
embedCacheHits: 0,
|
|
280
|
-
embedCacheMisses: 0,
|
|
281
|
-
overBudgetRuns: 0,
|
|
282
|
-
runsWithTelemetry: 0,
|
|
283
|
-
};
|
|
284
|
-
const coverage = improve.coverage;
|
|
285
|
-
const degradation = improve.degradation;
|
|
286
|
-
const minting = improve.enrichmentMinting;
|
|
287
|
-
// #576: real per-stage LLM token/time accounting (replaces the GPU-time
|
|
288
|
-
// proxy). Optional-guarded so reports built from older health JSON without
|
|
289
|
-
// the aggregate still render.
|
|
290
|
-
const llm = result.metrics.llmUsage ?? {
|
|
291
|
-
calls: 0,
|
|
292
|
-
totalDurationMs: 0,
|
|
293
|
-
promptTokens: 0,
|
|
294
|
-
completionTokens: 0,
|
|
295
|
-
totalTokens: 0,
|
|
296
|
-
reasoningTokens: 0,
|
|
297
|
-
byStage: {},
|
|
298
|
-
};
|
|
299
|
-
const totalRuns = runs.length;
|
|
300
|
-
const failedRuns = runs.filter((r) => !r.ok).length;
|
|
301
|
-
const invoked = improve.invoked || totalRuns;
|
|
302
|
-
const completed = improve.completed || totalRuns - failedRuns;
|
|
303
|
-
const miWritten = mi.written || mi.writes || 0;
|
|
304
|
-
const completionRate = invoked ? `${Math.round((100 * completed) / invoked)}%` : "0%";
|
|
305
|
-
const taskFailRate = pct(result.metrics.taskFailRate, 1);
|
|
306
|
-
const agentFailRate = pct(result.metrics.agentFailureRate, 2);
|
|
307
|
-
const miYieldRate = pct(mi.yieldRate, 1);
|
|
308
|
-
const medianDurMin = (wallTime.medianMs / 60000).toFixed(1);
|
|
309
|
-
const p95DurMin = (wallTime.p95Ms / 60000).toFixed(1);
|
|
310
|
-
const avgPromoted = totalRuns ? String(Math.round(cons.promoted / totalRuns)) : "0";
|
|
311
|
-
const chunkFail = `${num(cons.failedChunks)} / ${num(cons.totalChunks)}`;
|
|
312
|
-
// ── Meta (collect.py steps 10-11) ──────────────────────────────────────────
|
|
313
|
-
const sinceIso = result.since;
|
|
314
|
-
const reportDate = sinceIso.slice(0, 10);
|
|
315
|
-
const sinceHuman = sinceIso ? `${isoTimeTag(sinceIso)} → now` : `last ${esc(opts.window)}`;
|
|
316
|
-
const reportTitle = reportDate ? `AKM Health Report — ${reportDate}` : "AKM Health Report";
|
|
317
|
-
const lastRun = runs[runs.length - 1];
|
|
318
|
-
const generatedAt = lastRun ? lastRun.completedAt || lastRun.startedAt || sinceIso : sinceIso;
|
|
319
|
-
const latest = [...runs].reverse().find((r) => r.ok) ?? lastRun;
|
|
320
|
-
// Freshness: surface the newest run's timestamp + the generated-at anchor in
|
|
321
|
-
// the exec card. Staleness is computed deterministically (no Date.now()) from
|
|
322
|
-
// the gap between the window start (`since`) and the newest run we have: if no
|
|
323
|
-
// run landed in the window, or the newest run sits in the first 25% of a
|
|
324
|
-
// window wider than the 6h threshold (i.e. a long idle tail), we flag stale.
|
|
325
|
-
const STALE_MS = 6 * 60 * 60 * 1000;
|
|
326
|
-
const latestRunMs = lastRun ? Date.parse(lastRun.completedAt || lastRun.startedAt) : NaN;
|
|
327
|
-
const sinceMs = Date.parse(sinceIso);
|
|
328
|
-
const generatedMs = Date.parse(generatedAt);
|
|
329
|
-
const idleTailMs = Number.isFinite(latestRunMs) && Number.isFinite(generatedMs) ? Math.max(0, generatedMs - latestRunMs) : 0;
|
|
330
|
-
const isStale = totalRuns === 0 || (Number.isFinite(latestRunMs) && Number.isFinite(sinceMs) && idleTailMs > STALE_MS);
|
|
331
|
-
const latestRunHuman = lastRun ? isoTimeTag(lastRun.completedAt || lastRun.startedAt) : "—";
|
|
332
|
-
// ── Status badges ──────────────────────────────────────────────────────────
|
|
333
|
-
const badgeByStatus = {
|
|
334
|
-
pass: { badge: "badge-pass", dot: "dot-pass", label: "PASS" },
|
|
335
|
-
warn: { badge: "badge-warn", dot: "dot-warn", label: "WARN" },
|
|
336
|
-
fail: { badge: "badge-fail", dot: "dot-fail", label: "FAIL" },
|
|
337
|
-
};
|
|
338
|
-
const badge = badgeByStatus[result.status];
|
|
339
|
-
const statusBadge = `<span class="badge-pill ${badge.badge}"><span class="dot ${badge.dot}"></span>${badge.label}</span>`;
|
|
340
|
-
const failOk = result.metrics.taskFailRate < TASK_FAIL_RATE_WARN;
|
|
341
|
-
const failBadge = `<span class="badge-pill ${failOk ? "badge-pass" : "badge-warn"}">` +
|
|
342
|
-
`<span class="dot ${failOk ? "dot-pass" : "dot-warn"}"></span>${taskFailRate} Fail Rate</span>`;
|
|
343
|
-
// ── Executive summary ──────────────────────────────────────────────────────
|
|
115
|
+
function renderExecSummary(vm) {
|
|
116
|
+
const badge = badgeByStatus[vm.status];
|
|
344
117
|
const li = (k, vHtml) => `<li><span class="k">${esc(k)}</span><span class="v">${vHtml}</span></li>`;
|
|
345
118
|
const trendLi = (k, d) => li(k, `<span class="trend-pill ${d === "flat" ? "flat" : d}">${d}</span>`);
|
|
346
119
|
const quickNumbers = [
|
|
347
|
-
li("Task fail rate", taskFailRate),
|
|
348
|
-
li("Agent fail rate", agentFailRate),
|
|
349
|
-
li("Improve completion", `${num(completed)} / ${num(invoked)} (${completionRate})`),
|
|
350
|
-
li("MI yield rate", miYieldRate),
|
|
351
|
-
li("MI written", num(miWritten)),
|
|
352
|
-
li("Consolidation promoted", num(
|
|
353
|
-
li("Consolidation judged: no action", `<abbr title="Candidates the consolidator reviewed but intentionally left unchanged (the 'judgedNoAction' field).">${num(
|
|
354
|
-
li("Chunk failure", chunkFail),
|
|
355
|
-
li("Median wall time", fmtMs(wallTime.medianMs)),
|
|
356
|
-
li("P95 wall time", fmtMs(wallTime.p95Ms)),
|
|
120
|
+
li("Task fail rate", vm.taskFailRate),
|
|
121
|
+
li("Agent fail rate", vm.agentFailRate),
|
|
122
|
+
li("Improve completion", `${num(vm.completed)} / ${num(vm.invoked)} (${vm.completionRate})`),
|
|
123
|
+
li("MI yield rate", vm.miYieldRate),
|
|
124
|
+
li("MI written", num(vm.miWritten)),
|
|
125
|
+
li("Consolidation promoted", num(vm.consolidation.promoted)),
|
|
126
|
+
li("Consolidation judged: no action", `<abbr title="Candidates the consolidator reviewed but intentionally left unchanged (the 'judgedNoAction' field).">${num(vm.consolidation.judgedNoAction)}</abbr>`),
|
|
127
|
+
li("Chunk failure", vm.chunkFail),
|
|
128
|
+
li("Median wall time", fmtMs(vm.wallTime.medianMs)),
|
|
129
|
+
li("P95 wall time", fmtMs(vm.wallTime.p95Ms)),
|
|
357
130
|
].join("");
|
|
358
131
|
const trendRows = [
|
|
359
|
-
trendLi("Decision quality", trend.decisionQuality),
|
|
360
|
-
trendLi("Output volume", trend.outputVolume),
|
|
361
|
-
trendLi("Failures", trend.failures),
|
|
362
|
-
trendLi("Latency", trend.latency),
|
|
132
|
+
trendLi("Decision quality", vm.trend.decisionQuality),
|
|
133
|
+
trendLi("Output volume", vm.trend.outputVolume),
|
|
134
|
+
trendLi("Failures", vm.trend.failures),
|
|
135
|
+
trendLi("Latency", vm.trend.latency),
|
|
363
136
|
].join("");
|
|
364
137
|
const deltaRows = [
|
|
365
|
-
li("Promoted", deltaPill(deltas, "improve.consolidation.promoted")),
|
|
366
|
-
li("MI written", deltaPill(deltas, "improve.memoryInference.written")),
|
|
367
|
-
li("MI yield", deltaPill(deltas, "improve.memoryInference.yieldRate")),
|
|
368
|
-
li("Median wall", deltaPill(deltas, "improve.wallTime.medianMs", true)),
|
|
369
|
-
li("P95 wall", deltaPill(deltas, "improve.wallTime.p95Ms", true)),
|
|
138
|
+
li("Promoted", deltaPill(vm.deltas, "improve.consolidation.promoted")),
|
|
139
|
+
li("MI written", deltaPill(vm.deltas, "improve.memoryInference.written")),
|
|
140
|
+
li("MI yield", deltaPill(vm.deltas, "improve.memoryInference.yieldRate")),
|
|
141
|
+
li("Median wall", deltaPill(vm.deltas, "improve.wallTime.medianMs", true)),
|
|
142
|
+
li("P95 wall", deltaPill(vm.deltas, "improve.wallTime.p95Ms", true)),
|
|
370
143
|
].join("");
|
|
371
|
-
const snapRows = latest
|
|
144
|
+
const snapRows = vm.latest
|
|
372
145
|
? [
|
|
373
|
-
li("Run id", `<code>${esc(latest.id.slice(0, 28))}</code>`),
|
|
374
|
-
li("Completed", isoTimeTag(latest.completedAt || latest.startedAt)),
|
|
375
|
-
li("Status", latest.ok ? "✅ ok" : "❌ failed"),
|
|
376
|
-
li("Wall time", fmtMs(latest.wallTimeMs)),
|
|
377
|
-
li("Reflect ok/fail", `${latest.reflectOk} / ${latest.reflectFailed}`),
|
|
378
|
-
li("Promoted", String(latest.promoted)),
|
|
379
|
-
li("Judged: no action", `<abbr title="Candidates reviewed but intentionally left unchanged on this run.">${latest.judgedNoAction}</abbr>`),
|
|
380
|
-
li("MI written", String(latest.miWritten)),
|
|
381
|
-
li("Graph entities/relations", `${latest.geEntities} / ${latest.geRelations}`),
|
|
146
|
+
li("Run id", `<code>${esc(vm.latest.id.slice(0, 28))}</code>`),
|
|
147
|
+
li("Completed", isoTimeTag(vm.latest.completedAt || vm.latest.startedAt)),
|
|
148
|
+
li("Status", vm.latest.ok ? "✅ ok" : "❌ failed"),
|
|
149
|
+
li("Wall time", fmtMs(vm.latest.wallTimeMs)),
|
|
150
|
+
li("Reflect ok/fail", `${vm.latest.reflectOk} / ${vm.latest.reflectFailed}`),
|
|
151
|
+
li("Promoted", String(vm.latest.promoted)),
|
|
152
|
+
li("Judged: no action", `<abbr title="Candidates reviewed but intentionally left unchanged on this run.">${vm.latest.judgedNoAction}</abbr>`),
|
|
153
|
+
li("MI written", String(vm.latest.miWritten)),
|
|
154
|
+
li("Graph entities/relations", `${vm.latest.geEntities} / ${vm.latest.geRelations}`),
|
|
382
155
|
].join("")
|
|
383
156
|
: '<li><span class="k">No runs in window</span><span class="v">—</span></li>';
|
|
384
157
|
const windowRows = [
|
|
385
|
-
li("Report window", esc(
|
|
386
|
-
li("Compare window", esc(
|
|
387
|
-
li("Runs", `${num(totalRuns)} (${failedRuns} failed)`),
|
|
388
|
-
li("
|
|
389
|
-
li("
|
|
390
|
-
li("
|
|
391
|
-
li("
|
|
158
|
+
li("Report window", esc(vm.window)),
|
|
159
|
+
li(vm.comparisonMode === "custom" ? "Comparison windows" : "Compare window", esc(vm.compare)),
|
|
160
|
+
li("Runs", `${num(vm.totalRuns)} (${vm.failedRuns} failed)`),
|
|
161
|
+
li("Included result rows", num(vm.includedResultRows)),
|
|
162
|
+
li("Invalid result rows skipped", num(vm.skippedInvalidResultRows)),
|
|
163
|
+
li("Stash derived", `<abbr title="Whole-stash recount of derived assets at report time — not a per-run sum.">${num(vm.memorySummary.derived)}</abbr>`),
|
|
164
|
+
li("Stash eligible", `<abbr title="Whole-stash recount of eligible assets at report time — not a per-run sum.">${num(vm.memorySummary.eligible)}</abbr>`),
|
|
165
|
+
li("Pending proposals", String(vm.proposals.length)),
|
|
166
|
+
li("Semantic search", vm.sem.blocked ? "BLOCKED" : "OK"),
|
|
392
167
|
].join("");
|
|
393
|
-
const overallEmoji = trend.overall === "improving" ? "📈" : trend.overall === "degrading" ? "📉" : "↔️";
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
// alongside the trend; only a degraded status (WARN/FAIL) leads with them.
|
|
400
|
-
const concerns = [];
|
|
401
|
-
if (failedRuns > 0)
|
|
402
|
-
concerns.push(`${failedRuns} failed run${failedRuns === 1 ? "" : "s"}`);
|
|
403
|
-
if (sem.blocked)
|
|
404
|
-
concerns.push("semantic search blocked");
|
|
405
|
-
if (proposals.length > 0)
|
|
406
|
-
concerns.push(`${proposals.length} pending proposal${proposals.length === 1 ? "" : "s"}`);
|
|
407
|
-
const trendClause = trend.overall === "improving"
|
|
408
|
-
? "throughput and latency improving"
|
|
409
|
-
: trend.overall === "degrading"
|
|
410
|
-
? "throughput or latency degrading"
|
|
411
|
-
: "throughput and latency steady";
|
|
412
|
-
const verdictWord = badge.label;
|
|
413
|
-
let verdictRest;
|
|
414
|
-
if (result.status === "pass") {
|
|
415
|
-
const watch = concerns.length > 0 ? `; watch: ${concerns.slice(0, 3).join(", ")}` : "";
|
|
416
|
-
verdictRest = `healthy, ${trendClause}${watch}`;
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
const lead = concerns.length > 0 ? concerns.slice(0, 3).join("; ") : trendClause;
|
|
420
|
-
verdictRest = trend.overall === "degrading" && concerns.length > 0 ? `${lead}; ${trendClause}` : lead;
|
|
421
|
-
}
|
|
422
|
-
const verdictSentence = `${verdictWord} — ${esc(verdictRest)}.`;
|
|
423
|
-
const verdictHtml = `<div class="verdict ${result.status}"><b>Verdict:</b> ${verdictSentence}</div>`;
|
|
424
|
-
// ── Freshness line ─────────────────────────────────────────────────────────
|
|
425
|
-
const freshnessHtml = `<div class="freshness${isStale ? " stale" : ""}">${isStale ? "⚠️ Stale: " : ""}Latest run ${latestRunHuman} · generated ${isoTimeTag(generatedAt)}${isStale ? " — no recent activity (newest run older than the 6h freshness threshold)." : "."}</div>`;
|
|
426
|
-
const execSummary = `
|
|
168
|
+
const overallEmoji = vm.trend.overall === "improving" ? "📈" : vm.trend.overall === "degrading" ? "📉" : "↔️";
|
|
169
|
+
const verdictSentence = `${vm.verdictWord} — ${esc(vm.verdictRest)}.`;
|
|
170
|
+
const verdictHtml = `<div class="verdict ${vm.status}"><b>Verdict:</b> ${verdictSentence}</div>`;
|
|
171
|
+
const latestRunHuman = vm.lastRun ? isoTimeTag(vm.lastRun.completedAt || vm.lastRun.startedAt) : "—";
|
|
172
|
+
const freshnessHtml = `<div class="freshness${vm.isStale ? " stale" : ""}">${vm.isStale ? "⚠️ Stale: " : ""}Latest run ${latestRunHuman} · generated ${isoTimeTag(vm.generatedAt)}${vm.isStale ? " — no recent activity (newest run older than the 6h freshness threshold)." : "."}</div>`;
|
|
173
|
+
return `
|
|
427
174
|
<h2>${overallEmoji} Executive Summary
|
|
428
175
|
<span class="badge-pill ${badge.badge}" style="font-size:11px;">
|
|
429
176
|
<span class="dot ${badge.dot}"></span>${badge.label}</span></h2>
|
|
@@ -435,7 +182,7 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
435
182
|
<ul>${quickNumbers}</ul>
|
|
436
183
|
</div>
|
|
437
184
|
<div>
|
|
438
|
-
<h4
|
|
185
|
+
<h4>${vm.comparisonMode === "custom" ? `Trend: ${esc(vm.compare)}` : `Trend vs prior ${esc(vm.compare)}`}</h4>
|
|
439
186
|
<ul>${trendRows}</ul>
|
|
440
187
|
<h4 style="margin-top:14px;">Period-over-period deltas</h4>
|
|
441
188
|
<ul>${deltaRows}</ul>
|
|
@@ -449,200 +196,55 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
449
196
|
<ul>${windowRows}</ul>
|
|
450
197
|
</div>
|
|
451
198
|
</div>
|
|
452
|
-
<div class="overall">Overall trend: <b>${esc(trend.overall)}</b> ${overallEmoji}
|
|
453
|
-
· based on decision quality, output volume, failures, and latency vs the prior window.</div>`.trim();
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
const
|
|
199
|
+
<div class="overall">Overall trend: <b>${esc(vm.trend.overall)}</b> ${overallEmoji}
|
|
200
|
+
· based on decision quality, output volume, failures, and latency ${vm.comparisonMode === "custom" ? "across the selected windows" : "vs the prior window"}.</div>`.trim();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Color is a health SIGNAL, not decoration: green/yellow/red where a card has
|
|
204
|
+
* a meaningful threshold; "neutral" for purely-informational counts. Cards
|
|
205
|
+
* are ordered by operator priority (failures first, informational counts
|
|
206
|
+
* last).
|
|
207
|
+
*/
|
|
208
|
+
function renderKpiCards(vm) {
|
|
209
|
+
const semValue = vm.sem.blocked ? "BLOCKED" : "OK";
|
|
210
|
+
const semColor = vm.sem.blocked ? "red" : "green";
|
|
211
|
+
const semStyle = vm.sem.blocked ? "font-size:18px;" : "";
|
|
212
|
+
const completionColor = vm.completionPct >= 99 ? "green" : vm.completionPct >= 90 ? "yellow" : "red";
|
|
464
213
|
const kpiCard = (color, label, value, sub, valueStyle = "") => `<div class="kpi-card ${color}">
|
|
465
214
|
<div class="label">${label}</div>
|
|
466
215
|
<div class="value"${valueStyle ? ` style="${valueStyle}"` : ""}>${value}</div>
|
|
467
216
|
<div class="sub">${sub}</div>
|
|
468
217
|
</div>`;
|
|
469
|
-
|
|
470
|
-
kpiCard(failedRuns === 0 ? "green" : "red", "Failed Runs", String(failedRuns), `of ${num(totalRuns)} runs · ${taskFailRate} task fail`),
|
|
471
|
-
kpiCard(completionColor, "Completion Rate", completionRate, `${num(completed)} / ${num(invoked)} invoked`),
|
|
472
|
-
kpiCard("neutral", "Median Duration", `${medianDurMin}m`, `p95 = ${p95DurMin}m`),
|
|
473
|
-
kpiCard("blue", "Total Promoted", num(
|
|
474
|
-
kpiCard("blue", "MI Written", num(miWritten), `${miYieldRate} yield rate`),
|
|
475
|
-
kpiCard("purple", "Graph Entities", num(
|
|
476
|
-
kpiCard("neutral", "Stash Derived", num(
|
|
218
|
+
return [
|
|
219
|
+
kpiCard(vm.failedRuns === 0 ? "green" : "red", "Failed Runs", String(vm.failedRuns), `of ${num(vm.totalRuns)} runs · ${vm.taskFailRate} task fail`),
|
|
220
|
+
kpiCard(completionColor, "Completion Rate", vm.completionRate, `${num(vm.completed)} / ${num(vm.invoked)} invoked`),
|
|
221
|
+
kpiCard("neutral", "Median Duration", `${vm.medianDurMin}m`, `p95 = ${vm.p95DurMin}m`),
|
|
222
|
+
kpiCard("blue", "Total Promoted", num(vm.consolidation.promoted), `avg ${vm.avgPromoted} / run`),
|
|
223
|
+
kpiCard("blue", "MI Written", num(vm.miWritten), `${vm.miYieldRate} yield rate`),
|
|
224
|
+
kpiCard("purple", "Graph Entities", num(vm.graphExtraction.entities), `+${num(vm.graphExtraction.relations)} relations`),
|
|
225
|
+
kpiCard("neutral", "Stash Derived", num(vm.memorySummary.derived), `of ${num(vm.memorySummary.eligible)} eligible (whole-stash)`),
|
|
477
226
|
// #576: real LLM work — duration leads, tokens compact, not a GPU proxy.
|
|
478
|
-
kpiCard(llm.calls > 0 ? "purple" : "neutral", "🧠 LLM Work", `${llmTokensCompact} tok`, `${fmtMs(llm.totalDurationMs)} · ${num(llm.calls)} calls · ${compact(llm.reasoningTokens)} reasoning`),
|
|
479
|
-
kpiCard(semColor, "Semantic Search", semValue, esc(sem.detail), semStyle),
|
|
480
|
-
kpiCard(proposals.length > 0 ? "yellow" : "neutral", "Pending Proposals", String(proposals.length), `from ${esc(
|
|
227
|
+
kpiCard(vm.llm.calls > 0 ? "purple" : "neutral", "🧠 LLM Work", `${vm.llmTokensCompact} tok`, `${fmtMs(vm.llm.totalDurationMs)} · ${num(vm.llm.calls)} calls · ${compact(vm.llm.reasoningTokens)} reasoning`),
|
|
228
|
+
kpiCard(semColor, "Semantic Search", semValue, esc(vm.sem.detail), semStyle),
|
|
229
|
+
kpiCard(vm.proposals.length > 0 ? "yellow" : "neutral", "Pending Proposals", String(vm.proposals.length), `from ${esc(vm.window)} batch`),
|
|
481
230
|
].join("\n");
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
.sort();
|
|
486
|
-
const runsJsConst = `const RUNS = ${JSON.stringify(runs)};`;
|
|
487
|
-
// ── Summary table rows ─────────────────────────────────────────────────────
|
|
488
|
-
// Optional 4th element = a glossary tooltip rendered as <abbr title>.
|
|
489
|
-
const summaryRows = [
|
|
490
|
-
["Task fail rate", taskFailRate, "flat"],
|
|
491
|
-
["Agent fail rate", agentFailRate, "flat"],
|
|
492
|
-
["Improve completion", `${num(completed)} / ${num(invoked)}`, "flat"],
|
|
493
|
-
[
|
|
494
|
-
"MI yield rate",
|
|
495
|
-
miYieldRate,
|
|
496
|
-
trend.decisionQuality,
|
|
497
|
-
"Memory-inference yield: share of considered candidates that produced a written fact.",
|
|
498
|
-
],
|
|
499
|
-
["MI written", num(miWritten), trend.outputVolume, "Memory-inference: facts written this window."],
|
|
500
|
-
["Consolidation promoted", num(cons.promoted), trend.outputVolume],
|
|
501
|
-
["Consolidation merged", num(cons.merged), "flat"],
|
|
502
|
-
["Consolidation deleted", num(cons.deleted), "flat"],
|
|
503
|
-
["Consolidation contradicted", num(cons.contradicted), "flat"],
|
|
504
|
-
[
|
|
505
|
-
"Consolidation judged: no action",
|
|
506
|
-
num(cons.judgedNoAction),
|
|
507
|
-
"flat",
|
|
508
|
-
"Candidates reviewed but intentionally left unchanged (the 'judgedNoAction' field).",
|
|
509
|
-
],
|
|
510
|
-
["Chunk failure", chunkFail, "flat"],
|
|
511
|
-
["Graph entities", num(ge.entities), "up"],
|
|
512
|
-
["Graph relations", num(ge.relations), "up"],
|
|
513
|
-
[
|
|
514
|
-
"Stash derived",
|
|
515
|
-
num(improve.memorySummary.derived),
|
|
516
|
-
"up",
|
|
517
|
-
"Whole-stash recount of derived assets at report time — not a per-run sum.",
|
|
518
|
-
],
|
|
519
|
-
["Median wall time", fmtMs(wallTime.medianMs), trend.latency],
|
|
520
|
-
["P95 wall time", fmtMs(wallTime.p95Ms), trend.latency],
|
|
521
|
-
// #576: real LLM accounting (replaces the GPU-time proxy).
|
|
522
|
-
["LLM calls", num(llm.calls), "flat"],
|
|
523
|
-
["LLM total tokens", num(llm.totalTokens), "flat"],
|
|
524
|
-
["LLM prompt tokens", num(llm.promptTokens), "flat"],
|
|
525
|
-
["LLM completion tokens", num(llm.completionTokens), "flat"],
|
|
526
|
-
[
|
|
527
|
-
"LLM reasoning tokens",
|
|
528
|
-
num(llm.reasoningTokens),
|
|
529
|
-
"flat",
|
|
530
|
-
"Tokens spent on model reasoning/thinking, billed separately from prompt and completion.",
|
|
531
|
-
],
|
|
532
|
-
["LLM wall time", fmtMs(llm.totalDurationMs), trend.latency],
|
|
533
|
-
];
|
|
534
|
-
// #612 — auto-accept gate calibration. Only surface when the gate actually
|
|
535
|
-
// acted on proposals in the window (samples > 0); a default ungated install
|
|
536
|
-
// reports an empty summary and we omit the rows to keep the table parity-clean.
|
|
537
|
-
const calibration = improve.calibration;
|
|
538
|
-
if (calibration && calibration.samples > 0) {
|
|
539
|
-
summaryRows.push([
|
|
540
|
-
"Calibration samples",
|
|
541
|
-
num(calibration.samples),
|
|
542
|
-
"flat",
|
|
543
|
-
"Auto-accept gate decisions (auto-accepted + auto-rejected) the calibration join measured this window.",
|
|
544
|
-
], [
|
|
545
|
-
"Calibration accept rate",
|
|
546
|
-
String(calibration.overallAcceptRate),
|
|
547
|
-
"flat",
|
|
548
|
-
"Realized accept rate of acted-on gate decisions (auto-accepted / total acted-on).",
|
|
549
|
-
], [
|
|
550
|
-
"Calibration gap",
|
|
551
|
-
String(calibration.calibrationGap),
|
|
552
|
-
"flat",
|
|
553
|
-
"Mean predicted confidence minus realized accept rate. Positive = the gate is over-confident.",
|
|
554
|
-
]);
|
|
555
|
-
}
|
|
556
|
-
// WS-5: denominator-fixed coverage rows (only when we have real data).
|
|
557
|
-
if (coverage && !Number.isNaN(coverage.rate)) {
|
|
558
|
-
summaryRows.push([
|
|
559
|
-
"Coverage rate",
|
|
560
|
-
pct(coverage.rate, 1),
|
|
561
|
-
"flat",
|
|
562
|
-
"Distinct accepted refs / total stash assets (denominator-fixed). Shows what fraction of the corpus has been touched.",
|
|
563
|
-
], [
|
|
564
|
-
"Eligible fraction",
|
|
565
|
-
pct(coverage.eligibleFraction, 1),
|
|
566
|
-
"flat",
|
|
567
|
-
"Eligible assets / total stash assets. Fraction the improve pipeline actively considers.",
|
|
568
|
-
], [
|
|
569
|
-
"Coverage accepted",
|
|
570
|
-
num(coverage.acceptedProposals),
|
|
571
|
-
"flat",
|
|
572
|
-
"Total accepted proposals in the window (raw volume — includes repeated rewrites of the same asset).",
|
|
573
|
-
], [
|
|
574
|
-
"Churn ratio",
|
|
575
|
-
Number.isFinite(coverage.churnRatio) ? num(coverage.churnRatio) : "—",
|
|
576
|
-
Number.isFinite(coverage.churnRatio) && coverage.churnRatio > 1.5 ? "down" : "flat",
|
|
577
|
-
"Accepted proposals / distinct refs touched. >1.5 = the loop is repeatedly rewriting the same assets (churn, not coverage).",
|
|
578
|
-
]);
|
|
579
|
-
}
|
|
580
|
-
// Enrichment-vs-minting policy rollup (reporting-only).
|
|
581
|
-
if (minting && Number.isFinite(minting.share)) {
|
|
582
|
-
summaryRows.push([
|
|
583
|
-
"Enrichment-lane minted share",
|
|
584
|
-
pct(minting.share, 1),
|
|
585
|
-
minting.share > 0.05 ? "down" : "flat",
|
|
586
|
-
`New assets minted by enrichment lanes / their accepted total (${minting.minted} minted vs ${minting.updated} updated). Enrichment lanes are ratified to edit existing assets only; WARN >5%, FAIL >15%.`,
|
|
587
|
-
]);
|
|
588
|
-
}
|
|
589
|
-
// WS-5: perf telemetry rows (only when at least one run reported telemetry).
|
|
590
|
-
if (perf.runsWithTelemetry > 0) {
|
|
591
|
-
const embedCacheTotal = perf.embedCacheHits + perf.embedCacheMisses;
|
|
592
|
-
const embedCacheHitRate = embedCacheTotal > 0 ? pct(perf.embedCacheHits / embedCacheTotal, 1) : "—";
|
|
593
|
-
summaryRows.push([
|
|
594
|
-
"Embed cache hit rate",
|
|
595
|
-
embedCacheHitRate,
|
|
596
|
-
"flat",
|
|
597
|
-
"Fraction of embedding lookups served from cache (>95% is healthy). Aggregated across WS-5 runs.",
|
|
598
|
-
], [
|
|
599
|
-
"Embed wall time",
|
|
600
|
-
fmtMs(perf.embedMs),
|
|
601
|
-
"flat",
|
|
602
|
-
"Cumulative embedding wall-clock time across consolidation runs in the window.",
|
|
603
|
-
], [
|
|
604
|
-
"Judged-cache skipped",
|
|
605
|
-
num(perf.judgedCacheSkipped),
|
|
606
|
-
"flat",
|
|
607
|
-
"Candidates skipped by the judged-cache (not sent to LLM). Higher = more efficient reuse of prior judgments.",
|
|
608
|
-
], [
|
|
609
|
-
"Dedup pool size",
|
|
610
|
-
num(perf.dedupPoolSize),
|
|
611
|
-
"flat",
|
|
612
|
-
"Average memory pool size after deduplication (before judged-cache narrowing). WS-5 perf telemetry.",
|
|
613
|
-
], [
|
|
614
|
-
"Over-budget consolidation runs",
|
|
615
|
-
String(perf.overBudgetRuns),
|
|
616
|
-
perf.overBudgetRuns > 0 ? "down" : "flat",
|
|
617
|
-
"Runs where consolidation alone exceeded the total run budget (estimatedBudgetFractionUsed > 1.0).",
|
|
618
|
-
]);
|
|
619
|
-
}
|
|
620
|
-
// WS-5: degradation metrics rows.
|
|
621
|
-
if (degradation) {
|
|
622
|
-
summaryRows.push([
|
|
623
|
-
"Corpus diversity (Gini)",
|
|
624
|
-
num(degradation.corpusCentroidDistance),
|
|
625
|
-
degradation.entrenchmentFlagged || degradation.salienceUniformityFlagged ? "down" : "flat",
|
|
626
|
-
"Gini coefficient of retrieval_salience for top-100 ranked assets. Two-tailed: >0.35 = entrenchment risk; <0.08 = collapsed toward uniform (ranking no longer discriminates).",
|
|
627
|
-
], [
|
|
628
|
-
"Merge fidelity contradiction rate",
|
|
629
|
-
pct(degradation.mergeFidelityContradictionRate, 1),
|
|
630
|
-
"flat",
|
|
631
|
-
"Fraction of consolidated proposals that involved a contradiction, from consolidation result envelopes.",
|
|
632
|
-
]);
|
|
633
|
-
}
|
|
634
|
-
const summaryRowsHtml = summaryRows
|
|
231
|
+
}
|
|
232
|
+
function renderSummaryRowsHtml(vm) {
|
|
233
|
+
return vm.summaryRows
|
|
635
234
|
.map(([label, value, t, tip]) => {
|
|
636
235
|
const labelHtml = tip ? `<abbr title="${esc(tip)}">${esc(label)}</abbr>` : esc(label);
|
|
637
236
|
return (` <tr><td>${labelHtml}</td><td>${esc(value)}</td>` +
|
|
638
237
|
`<td class="trend ${trendClass(t)}">${trendLabel(t)}</td></tr>`);
|
|
639
238
|
})
|
|
640
239
|
.join("\n");
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Merge + de-duplicate advisories and the old "what to watch" cards (built
|
|
243
|
+
* from the same VM data — invalid rows, sem-blocked, proposals, tail-latency,
|
|
244
|
+
* failed-runs, …) into ONE prioritized list (P1/P2/P3 + a remediation command
|
|
245
|
+
* per item), keyed so each concern appears exactly once.
|
|
246
|
+
*/
|
|
247
|
+
function renderActionItems(vm) {
|
|
646
248
|
const items = [];
|
|
647
249
|
const seen = new Set();
|
|
648
250
|
const pushItem = (item) => {
|
|
@@ -651,8 +253,18 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
651
253
|
seen.add(item.key);
|
|
652
254
|
items.push(item);
|
|
653
255
|
};
|
|
256
|
+
if (vm.invalidRuns.length > 0) {
|
|
257
|
+
pushItem({
|
|
258
|
+
key: "invalid-improve-result-rows",
|
|
259
|
+
prio: "P2",
|
|
260
|
+
cls: "warn",
|
|
261
|
+
title: `${vm.invalidRuns.length} invalid improve result row${vm.invalidRuns.length === 1 ? "" : "s"} skipped`,
|
|
262
|
+
descHtml: `Excluded from result-derived metrics: ${vm.invalidRuns.map((run) => `<code>${esc(run.id)}</code>`).join(", ")}.`,
|
|
263
|
+
remedy: `akm health --since=${vm.window} --group-by run`,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
654
266
|
// Hard advisories from the health check engine (own remediation in message).
|
|
655
|
-
for (const a of
|
|
267
|
+
for (const a of vm.advisories) {
|
|
656
268
|
if (a.status !== "warn" && a.status !== "fail")
|
|
657
269
|
continue;
|
|
658
270
|
pushItem({
|
|
@@ -664,58 +276,53 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
664
276
|
});
|
|
665
277
|
}
|
|
666
278
|
// Failed runs in window.
|
|
667
|
-
if (failedRuns > 0) {
|
|
279
|
+
if (vm.failedRuns > 0) {
|
|
668
280
|
pushItem({
|
|
669
281
|
key: "failed-runs",
|
|
670
282
|
prio: "P1",
|
|
671
283
|
cls: "fail",
|
|
672
|
-
title: `${failedRuns} failed run${failedRuns === 1 ? "" : "s"} in window`,
|
|
673
|
-
descHtml: `Task fail rate ${esc(taskFailRate)}. Inspect failed runs (ok=false) for early-exit or harness errors.`,
|
|
674
|
-
remedy: `akm health --since=${
|
|
284
|
+
title: `${vm.failedRuns} failed run${vm.failedRuns === 1 ? "" : "s"} in window`,
|
|
285
|
+
descHtml: `Task fail rate ${esc(vm.taskFailRate)}. Inspect failed runs (ok=false) for early-exit or harness errors.`,
|
|
286
|
+
remedy: `akm health --since=${vm.window} --group-by run`,
|
|
675
287
|
});
|
|
676
288
|
}
|
|
677
289
|
// Semantic search blocked.
|
|
678
|
-
if (sem.blocked) {
|
|
290
|
+
if (vm.sem.blocked) {
|
|
679
291
|
pushItem({
|
|
680
292
|
key: "semantic-search-blocked",
|
|
681
293
|
prio: "P2",
|
|
682
294
|
cls: "warn",
|
|
683
295
|
title: "Semantic search blocked",
|
|
684
|
-
descHtml: `Embedding provider unreachable. ${esc(sem.detail)}. Curate falls back to keyword search — relevance scoring degraded.`,
|
|
685
|
-
remedy: "akm config
|
|
296
|
+
descHtml: `Embedding provider unreachable. ${esc(vm.sem.detail)}. Curate falls back to keyword search — relevance scoring degraded.`,
|
|
297
|
+
remedy: "akm config list",
|
|
686
298
|
});
|
|
687
299
|
}
|
|
688
300
|
// Pending proposals to drain.
|
|
689
|
-
if (proposals.length > 0) {
|
|
690
|
-
const
|
|
691
|
-
for (const p of proposals)
|
|
692
|
-
bySource.set(p.source, (bySource.get(p.source) ?? 0) + 1);
|
|
693
|
-
const srcSummary = [...bySource.entries()]
|
|
694
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
695
|
-
.map(([source, count]) => `${count} via ${esc(source)}`)
|
|
696
|
-
.join(", ");
|
|
301
|
+
if (vm.proposals.length > 0) {
|
|
302
|
+
const srcSummary = vm.proposalsBySource.map(([source, count]) => `${count} via ${esc(source)}`).join(", ");
|
|
697
303
|
pushItem({
|
|
698
304
|
key: "drain-proposals",
|
|
699
305
|
prio: "P2",
|
|
700
306
|
cls: "warn",
|
|
701
|
-
title: `Drain ${proposals.length} pending proposal${proposals.length === 1 ? "" : "s"}`,
|
|
307
|
+
title: `Drain ${vm.proposals.length} pending proposal${vm.proposals.length === 1 ? "" : "s"}`,
|
|
702
308
|
descHtml: `Proposals generated this batch (${srcSummary}). Review before the queue grows further.`,
|
|
703
309
|
remedy: "akm proposal list",
|
|
704
310
|
});
|
|
705
311
|
}
|
|
706
312
|
// High tail latency.
|
|
707
|
-
if (wallTime.p95Ms && wallTime.medianMs && wallTime.p95Ms / wallTime.medianMs > 2.5) {
|
|
313
|
+
if (vm.wallTime.p95Ms && vm.wallTime.medianMs && vm.wallTime.p95Ms / vm.wallTime.medianMs > 2.5) {
|
|
708
314
|
pushItem({
|
|
709
315
|
key: "tail-latency",
|
|
710
316
|
prio: "P3",
|
|
711
317
|
cls: "warn",
|
|
712
|
-
title: `High tail latency: p95=${fmtMs(wallTime.p95Ms)}, median=${fmtMs(wallTime.medianMs)}`,
|
|
318
|
+
title: `High tail latency: p95=${fmtMs(vm.wallTime.p95Ms)}, median=${fmtMs(vm.wallTime.medianMs)}`,
|
|
713
319
|
descHtml: "P95 is well above median. Consolidation/LLM phase dominates wall time on slow runs. " +
|
|
714
320
|
"Check for slow chunks or LLM rate limiting.",
|
|
715
321
|
});
|
|
716
322
|
}
|
|
717
323
|
// Stale freshness.
|
|
718
|
-
if (isStale && totalRuns > 0) {
|
|
324
|
+
if (vm.isStale && vm.totalRuns > 0) {
|
|
325
|
+
const latestRunHuman = vm.lastRun ? isoTimeTag(vm.lastRun.completedAt || vm.lastRun.startedAt) : "—";
|
|
719
326
|
pushItem({
|
|
720
327
|
key: "stale",
|
|
721
328
|
prio: "P3",
|
|
@@ -725,7 +332,7 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
725
332
|
});
|
|
726
333
|
}
|
|
727
334
|
// WS-5: corpus entrenchment flag.
|
|
728
|
-
if (degradation?.entrenchmentFlagged) {
|
|
335
|
+
if (vm.degradation?.entrenchmentFlagged) {
|
|
729
336
|
pushItem({
|
|
730
337
|
key: "corpus-entrenchment",
|
|
731
338
|
prio: "P2",
|
|
@@ -733,12 +340,12 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
733
340
|
title: "Corpus entrenchment risk: retrieval_salience Gini > 0.35",
|
|
734
341
|
descHtml: "A small set of assets dominates retrieval — retrieval diversity is low. " +
|
|
735
342
|
"Review top-ranked assets for stale or over-represented content. " +
|
|
736
|
-
`Corpus diversity proxy: ${esc(String(degradation.corpusCentroidDistance))}.`,
|
|
343
|
+
`Corpus diversity proxy: ${esc(String(vm.degradation.corpusCentroidDistance))}.`,
|
|
737
344
|
remedy: "akm health --format json | jq '.improve.degradation'",
|
|
738
345
|
});
|
|
739
346
|
}
|
|
740
347
|
// Low-tail companion: salience distribution collapsed toward uniform.
|
|
741
|
-
if (degradation?.salienceUniformityFlagged) {
|
|
348
|
+
if (vm.degradation?.salienceUniformityFlagged) {
|
|
742
349
|
pushItem({
|
|
743
350
|
key: "salience-uniformity-collapse",
|
|
744
351
|
prio: "P2",
|
|
@@ -746,25 +353,25 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
746
353
|
title: "Salience distribution collapsed: retrieval_salience Gini < 0.08",
|
|
747
354
|
descHtml: "The top-100 salience scores are near-uniform (uniform baseline ≈ 0.1) — " +
|
|
748
355
|
"ranking currently carries little to no discrimination between assets. " +
|
|
749
|
-
`Corpus diversity proxy: ${esc(String(degradation.corpusCentroidDistance))}.`,
|
|
356
|
+
`Corpus diversity proxy: ${esc(String(vm.degradation.corpusCentroidDistance))}.`,
|
|
750
357
|
remedy: "akm health --format json | jq '.improve.degradation'",
|
|
751
358
|
});
|
|
752
359
|
}
|
|
753
360
|
// WS-5: over-budget consolidation advisory.
|
|
754
|
-
if (perf.overBudgetRuns > 0) {
|
|
361
|
+
if (vm.perf.overBudgetRuns > 0) {
|
|
755
362
|
pushItem({
|
|
756
363
|
key: "over-budget-consolidation",
|
|
757
364
|
prio: "P2",
|
|
758
365
|
cls: "warn",
|
|
759
|
-
title: `${perf.overBudgetRuns} consolidation run${perf.overBudgetRuns === 1 ? "" : "s"} exceeded budget`,
|
|
366
|
+
title: `${vm.perf.overBudgetRuns} consolidation run${vm.perf.overBudgetRuns === 1 ? "" : "s"} exceeded budget`,
|
|
760
367
|
descHtml: "Consolidation phase wall time exceeded the total run budget on these runs. " +
|
|
761
|
-
"Consider increasing the timeout or reducing the consolidation pool via
|
|
762
|
-
remedy: "akm config
|
|
368
|
+
"Consider increasing the timeout or reducing the consolidation pool via strategy config.",
|
|
369
|
+
remedy: "akm config list",
|
|
763
370
|
});
|
|
764
371
|
}
|
|
765
372
|
// Session-log notes (informational, lowest priority).
|
|
766
|
-
if (
|
|
767
|
-
const patterns =
|
|
373
|
+
if (vm.sessionLogAdvisories.length > 0) {
|
|
374
|
+
const patterns = vm.sessionLogAdvisories
|
|
768
375
|
.slice(0, 6)
|
|
769
376
|
.map((p) => `<li>${esc(p.topic)}</li>`)
|
|
770
377
|
.join("");
|
|
@@ -772,17 +379,18 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
772
379
|
key: "session-log-notes",
|
|
773
380
|
prio: "P3",
|
|
774
381
|
cls: "warn",
|
|
775
|
-
title: `${
|
|
382
|
+
title: `${vm.sessionLogAdvisories.length} session-log note(s) (informational)`,
|
|
776
383
|
descHtml: `<ul style="margin:4px 0 0 16px;padding:0;">${patterns}</ul>`,
|
|
777
384
|
});
|
|
778
385
|
}
|
|
779
386
|
items.sort((a, b) => PRIO_RANK[a.prio] - PRIO_RANK[b.prio]);
|
|
780
|
-
|
|
387
|
+
return items.length > 0
|
|
781
388
|
? items.map(actionItemCard).join("\n")
|
|
782
389
|
: passCard("No action items", "All checks passed and nothing needs attention for this window.");
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
390
|
+
}
|
|
391
|
+
function renderProposalRowsHtml(vm) {
|
|
392
|
+
return vm.proposals.length > 0
|
|
393
|
+
? vm.proposals
|
|
786
394
|
.map((p, i) => {
|
|
787
395
|
const tagCls = p.source === "extract" ? "tag-extract" : "tag-consolidate";
|
|
788
396
|
return (`<tr><td>${i + 1}</td><td><code>${esc(p.ref)}</code></td>` +
|
|
@@ -791,24 +399,35 @@ export function buildHealthHtmlReplacements(result, opts) {
|
|
|
791
399
|
})
|
|
792
400
|
.join("\n")
|
|
793
401
|
: '<tr><td colspan="4" style="text-align:center;color:var(--muted);">No pending proposals</td></tr>';
|
|
402
|
+
}
|
|
403
|
+
// ── Main builder: extract-then-render glue ──────────────────────────────────
|
|
404
|
+
/**
|
|
405
|
+
* Compute all 17 `%%TOKEN%%` replacements for the health HTML template.
|
|
406
|
+
* There is deliberately NO standalone `%%OVERALL_STATUS%%` token — the
|
|
407
|
+
* overall status is embedded in the pre-rendered badge / exec-summary
|
|
408
|
+
* fragments, matching the skill template. Advisories and "what to watch" are
|
|
409
|
+
* merged + de-duplicated into a single prioritized `%%ACTION_ITEMS_HTML%%`.
|
|
410
|
+
*/
|
|
411
|
+
export function buildHealthHtmlReplacements(result, opts) {
|
|
412
|
+
const vm = buildHealthReportViewModel(result, opts);
|
|
794
413
|
return {
|
|
795
|
-
"%%ECHARTS_TAG%%": buildEchartsTag(
|
|
796
|
-
"%%REPORT_TITLE%%": esc(reportTitle),
|
|
797
|
-
"%%WINDOW%%": esc(
|
|
798
|
-
"%%SINCE_HUMAN%%":
|
|
799
|
-
"%%RUN_COUNT%%": num(totalRuns),
|
|
800
|
-
"%%STATUS_BADGE_HTML%%":
|
|
801
|
-
"%%EXEC_SUMMARY_HTML%%":
|
|
802
|
-
"%%KPI_CARDS_HTML%%":
|
|
803
|
-
"%%RUNS_JS_CONST%%":
|
|
804
|
-
"%%DISTILL_REASONS_JSON%%": JSON.stringify(distillReasons),
|
|
805
|
-
"%%SLICE_OPTIONS_HTML%%": buildSliceOptions(
|
|
806
|
-
"%%LLM_BY_STAGE_JSON%%": JSON.stringify(llm.byStage ?? {}),
|
|
807
|
-
"%%SUMMARY_ROWS_HTML%%":
|
|
808
|
-
"%%ACTION_ITEMS_HTML%%":
|
|
809
|
-
"%%PROPOSAL_ROWS_HTML%%":
|
|
810
|
-
"%%PROPOSAL_COUNT%%": String(proposals.length),
|
|
811
|
-
"%%GENERATED_AT%%": esc(generatedAt),
|
|
414
|
+
"%%ECHARTS_TAG%%": buildEchartsTag(),
|
|
415
|
+
"%%REPORT_TITLE%%": esc(vm.reportTitle),
|
|
416
|
+
"%%WINDOW%%": esc(vm.window),
|
|
417
|
+
"%%SINCE_HUMAN%%": renderSinceHuman(vm),
|
|
418
|
+
"%%RUN_COUNT%%": num(vm.totalRuns),
|
|
419
|
+
"%%STATUS_BADGE_HTML%%": renderStatusBadgeHtml(vm),
|
|
420
|
+
"%%EXEC_SUMMARY_HTML%%": renderExecSummary(vm),
|
|
421
|
+
"%%KPI_CARDS_HTML%%": renderKpiCards(vm),
|
|
422
|
+
"%%RUNS_JS_CONST%%": `const RUNS = ${JSON.stringify(vm.runs)};`,
|
|
423
|
+
"%%DISTILL_REASONS_JSON%%": JSON.stringify(vm.distillReasons),
|
|
424
|
+
"%%SLICE_OPTIONS_HTML%%": buildSliceOptions(vm),
|
|
425
|
+
"%%LLM_BY_STAGE_JSON%%": JSON.stringify(vm.llm.byStage ?? {}),
|
|
426
|
+
"%%SUMMARY_ROWS_HTML%%": renderSummaryRowsHtml(vm),
|
|
427
|
+
"%%ACTION_ITEMS_HTML%%": renderActionItems(vm),
|
|
428
|
+
"%%PROPOSAL_ROWS_HTML%%": renderProposalRowsHtml(vm),
|
|
429
|
+
"%%PROPOSAL_COUNT%%": String(vm.proposals.length),
|
|
430
|
+
"%%GENERATED_AT%%": esc(vm.generatedAt),
|
|
812
431
|
"%%AKM_VERSION%%": esc(pkgVersion),
|
|
813
432
|
};
|
|
814
433
|
}
|