self-evolving-workflow 0.0.0-stage → 0.1.4
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/LICENSE +27 -0
- package/README.md +195 -2
- package/dist/agent-memory-prompts.d.ts +13 -0
- package/dist/agent-memory-prompts.js +55 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/closeout.d.ts +105 -0
- package/dist/closeout.js +473 -0
- package/dist/code.d.ts +39 -0
- package/dist/code.js +124 -0
- package/dist/codex-memory.d.ts +24 -0
- package/dist/codex-memory.js +217 -0
- package/dist/common.d.ts +16 -0
- package/dist/common.js +52 -0
- package/dist/context-envelope.d.ts +59 -0
- package/dist/context-envelope.js +23 -0
- package/dist/host-adapters.d.ts +34 -0
- package/dist/host-adapters.js +151 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +90 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +13 -0
- package/dist/knowledge-cli.d.ts +198 -0
- package/dist/knowledge-cli.js +761 -0
- package/dist/knowledge-reads.d.ts +72 -0
- package/dist/knowledge-reads.js +201 -0
- package/dist/memory-config.d.ts +44 -0
- package/dist/memory-config.js +204 -0
- package/dist/memory-evidence.d.ts +13 -0
- package/dist/memory-evidence.js +40 -0
- package/dist/memory-history.d.ts +46 -0
- package/dist/memory-history.js +432 -0
- package/dist/memory.d.ts +96 -0
- package/dist/memory.js +362 -0
- package/dist/retrospective.d.ts +57 -0
- package/dist/retrospective.js +240 -0
- package/dist/search.d.ts +36 -0
- package/dist/search.js +112 -0
- package/dist/skill-addition.d.ts +25 -0
- package/dist/skill-addition.js +89 -0
- package/dist/skill-design.d.ts +96 -0
- package/dist/skill-design.js +226 -0
- package/dist/skill-replay.d.ts +55 -0
- package/dist/skill-replay.js +448 -0
- package/dist/skill-route.d.ts +30 -0
- package/dist/skill-route.js +75 -0
- package/dist/transcript-evidence.d.ts +3 -0
- package/dist/transcript-evidence.js +58 -0
- package/dist/upstream/chunker.d.ts +24 -0
- package/dist/upstream/chunker.js +96 -0
- package/dist/upstream/file-protocol.d.ts +45 -0
- package/dist/upstream/file-protocol.js +117 -0
- package/dist/upstream/frontmatter.d.ts +47 -0
- package/dist/upstream/frontmatter.js +86 -0
- package/dist/upstream/graph-search.d.ts +33 -0
- package/dist/upstream/graph-search.js +67 -0
- package/dist/upstream/l1-extraction.d.ts +26 -0
- package/dist/upstream/l1-extraction.js +405 -0
- package/dist/upstream/llm.d.ts +8 -0
- package/dist/upstream/llm.js +1 -0
- package/dist/upstream/merge.d.ts +50 -0
- package/dist/upstream/merge.js +153 -0
- package/dist/upstream/prompts.d.ts +53 -0
- package/dist/upstream/prompts.js +181 -0
- package/dist/upstream/search-utils.d.ts +34 -0
- package/dist/upstream/search-utils.js +55 -0
- package/dist/upstream/slug.d.ts +26 -0
- package/dist/upstream/slug.js +103 -0
- package/dist/upstream/template.d.ts +29 -0
- package/dist/upstream/template.js +80 -0
- package/dist/upstream/tokenize.d.ts +4 -0
- package/dist/upstream/tokenize.js +29 -0
- package/dist/wiki-change.d.ts +76 -0
- package/dist/wiki-change.js +299 -0
- package/dist/wiki-entry.d.ts +26 -0
- package/dist/wiki-entry.js +93 -0
- package/dist/wiki-ingest.d.ts +12 -0
- package/dist/wiki-ingest.js +126 -0
- package/dist/wiki-migration.d.ts +16 -0
- package/dist/wiki-migration.js +268 -0
- package/dist/wiki-tokens.d.ts +1 -0
- package/dist/wiki-tokens.js +46 -0
- package/dist/wiki.d.ts +103 -0
- package/dist/wiki.js +330 -0
- package/dist/workflow-cli.d.ts +2 -0
- package/dist/workflow-cli.js +319 -0
- package/dist/workflow-install.d.ts +37 -0
- package/dist/workflow-install.js +148 -0
- package/dist/workflow-knowledge.d.ts +18 -0
- package/dist/workflow-knowledge.js +32 -0
- package/dist/workflow-mcp.d.ts +2 -0
- package/dist/workflow-mcp.js +137 -0
- package/dist/workflow-names.d.ts +4 -0
- package/dist/workflow-names.js +31 -0
- package/dist/workflow-runtime.d.ts +735 -0
- package/dist/workflow-runtime.js +747 -0
- package/dist/workflow-skills.d.ts +48 -0
- package/dist/workflow-skills.js +141 -0
- package/docs/images/impeccable-skill.png +0 -0
- package/docs/images/workflow-overview.png +0 -0
- package/docs/images/workflow-skills.png +0 -0
- package/package.json +77 -4
- package/skills/ew-impeccable/LICENSE +191 -0
- package/skills/ew-impeccable/NOTICE.md +19 -0
- package/skills/ew-impeccable/SKILL.md +91 -0
- package/skills/ew-impeccable/UPSTREAM.md +23 -0
- package/skills/ew-impeccable/reference/adapt.md +314 -0
- package/skills/ew-impeccable/reference/adapt.native.md +60 -0
- package/skills/ew-impeccable/reference/android.md +46 -0
- package/skills/ew-impeccable/reference/animate.md +91 -0
- package/skills/ew-impeccable/reference/audit.md +138 -0
- package/skills/ew-impeccable/reference/audit.native.md +141 -0
- package/skills/ew-impeccable/reference/bolder.md +35 -0
- package/skills/ew-impeccable/reference/clarify.md +96 -0
- package/skills/ew-impeccable/reference/colorize.md +88 -0
- package/skills/ew-impeccable/reference/craft-floor.md +44 -0
- package/skills/ew-impeccable/reference/craft.md +5 -0
- package/skills/ew-impeccable/reference/critique.md +808 -0
- package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
- package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
- package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
- package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
- package/skills/ew-impeccable/reference/delight.md +72 -0
- package/skills/ew-impeccable/reference/distill.md +113 -0
- package/skills/ew-impeccable/reference/doctor.md +56 -0
- package/skills/ew-impeccable/reference/document.md +418 -0
- package/skills/ew-impeccable/reference/extract.md +68 -0
- package/skills/ew-impeccable/reference/harden.md +338 -0
- package/skills/ew-impeccable/reference/hooks.md +113 -0
- package/skills/ew-impeccable/reference/init.md +133 -0
- package/skills/ew-impeccable/reference/ios.md +51 -0
- package/skills/ew-impeccable/reference/layout.md +86 -0
- package/skills/ew-impeccable/reference/live-setup.md +102 -0
- package/skills/ew-impeccable/reference/live.md +326 -0
- package/skills/ew-impeccable/reference/new-work.md +209 -0
- package/skills/ew-impeccable/reference/onboard.md +236 -0
- package/skills/ew-impeccable/reference/operate.md +61 -0
- package/skills/ew-impeccable/reference/optimize.md +260 -0
- package/skills/ew-impeccable/reference/overdrive.md +127 -0
- package/skills/ew-impeccable/reference/polish.md +105 -0
- package/skills/ew-impeccable/reference/quieter.md +101 -0
- package/skills/ew-impeccable/reference/routing.md +20 -0
- package/skills/ew-impeccable/reference/shape.md +59 -0
- package/skills/ew-impeccable/reference/typeset.md +82 -0
- package/skills/ew-impeccable/reference/visualize.md +46 -0
- package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
- package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
- package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
- package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
- package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
- package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
- package/skills/ew-impeccable/scripts/context.mjs +1521 -0
- package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
- package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
- package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
- package/skills/ew-impeccable/scripts/detect.mjs +30 -0
- package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
- package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
- package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
- package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
- package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
- package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
- package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
- package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
- package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
- package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
- package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
- package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
- package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
- package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
- package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
- package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
- package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
- package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
- package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
- package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
- package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
- package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
- package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
- package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
- package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
- package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
- package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
- package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
- package/skills/ew-impeccable/scripts/hook.mjs +79 -0
- package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
- package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
- package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
- package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
- package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
- package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
- package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
- package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
- package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
- package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
- package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
- package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
- package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
- package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
- package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
- package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
- package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
- package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
- package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
- package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
- package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
- package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
- package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
- package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
- package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
- package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
- package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
- package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
- package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
- package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
- package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
- package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
- package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
- package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
- package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
- package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
- package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
- package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
- package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
- package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
- package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
- package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
- package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
- package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
- package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
- package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
- package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
- package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
- package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
- package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
- package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
- package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
- package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
- package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
- package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
- package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
- package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
- package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
- package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
- package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
- package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
- package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
- package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
- package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
- package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
- package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
- package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
- package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
- package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
- package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
- package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
- package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
- package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
- package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
- package/skills/ew-impeccable/scripts/live.mjs +334 -0
- package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/ew-impeccable/scripts/palette.mjs +628 -0
- package/skills/ew-impeccable/scripts/pin.mjs +352 -0
- package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
- package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
- package/skills/ew-knowledge/SKILL.md +35 -0
- package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
- package/skills/ew-knowledge/references/knowledge-route.md +73 -0
- package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
- package/skills/ew-odyssey/SKILL.md +106 -0
- package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
- package/skills/ew-odyssey/references/odyssey-base.md +104 -0
- package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
- package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
- package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
- package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
- package/skills/ew-odyssey/references/odyssey-review.md +233 -0
- package/skills/ew-odyssey/references/odyssey-security.md +231 -0
- package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
- package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
- package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
- package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
- package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
- package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
- package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
- package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
- package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
- package/skills/ew-orchestrate/SKILL.md +89 -0
- package/skills/ew-orchestrate/references/auto-policy.md +66 -0
- package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
- package/skills/ew-orchestrate/references/companion-route.md +40 -0
- package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
- package/skills/ew-orchestrate/references/goal.md +51 -0
- package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
- package/skills/ew-orchestrate/references/planning.md +54 -0
- package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
- package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
- package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
- package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
- package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
- package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
- package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
- package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
- package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
- package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
- package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
- package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
- package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
- package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
- package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
- package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
- package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
- package/skills/ew-skill-design/SKILL.md +30 -0
- package/skills/ew-skill-design/references/package-contract.md +40 -0
- package/skills/ew-skill-design/references/validation.md +21 -0
- package/skills/team-swarm/SKILL.md +68 -0
- package/skills/team-swarm/references/mcp-coordination.md +14 -0
- package/skills/team-swarm/roles/analyst/role.md +181 -0
- package/skills/team-swarm/roles/ant/role.md +149 -0
- package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
- package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
- package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
- package/skills/team-swarm/roles/coordinator/role.md +170 -0
- package/skills/team-swarm/roles/scorer/role.md +150 -0
- package/skills/team-swarm/scripts/aco.py +646 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +111 -0
- package/skills/team-swarm/scripts/test_aco.py +606 -0
- package/skills/team-swarm/specs/ant-output-schema.md +127 -0
- package/skills/team-swarm/specs/convergence-criteria.md +108 -0
- package/skills/team-swarm/specs/pheromone-schema.md +125 -0
- package/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/skills/team-swarm/specs/swarm-protocol.md +119 -0
- package/skills/workflow-evolve/SKILL.md +64 -0
- package/skills/workflow-evolve/references/agy-gate.md +27 -0
- package/skills/workflow-evolve/references/auto-loop.md +23 -0
- package/skills/workflow-evolve/references/history-review.md +15 -0
- package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
- package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
- package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
- package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
- package/workflows/index.json +33 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
"""End-to-end tests for team-swarm scripts.
|
|
2
|
+
|
|
3
|
+
Runs each scenario in a clean tmp directory and asserts on outputs.
|
|
4
|
+
No external test framework — runnable as `python test_aco.py`.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import tempfile
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Optional
|
|
14
|
+
|
|
15
|
+
SCRIPT_DIR = Path(__file__).parent
|
|
16
|
+
ACO = SCRIPT_DIR / "aco.py"
|
|
17
|
+
|
|
18
|
+
# Import modules directly for unit-level tests
|
|
19
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
20
|
+
from pheromone import PheromoneState, edge_key # noqa: E402
|
|
21
|
+
from scoring import FallbackScorer, ScriptScorer, hallucination_check, resolve_score # noqa: E402
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# ---------------------------------------------------------------------------
|
|
25
|
+
# Helpers
|
|
26
|
+
# ---------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
PASS = 0
|
|
29
|
+
FAIL = 0
|
|
30
|
+
FAILED_NAMES = []
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def run_aco(session: Path, *args, expect_exit: int = 0) -> dict:
|
|
34
|
+
"""Invoke aco.py CLI, return parsed stdout JSON."""
|
|
35
|
+
cmd = [sys.executable, "-B", str(ACO), "--session", str(session), *args]
|
|
36
|
+
proc = subprocess.run(cmd, capture_output=True, text=True)
|
|
37
|
+
if proc.returncode != expect_exit:
|
|
38
|
+
raise AssertionError(
|
|
39
|
+
f"exit={proc.returncode} (expected {expect_exit})\n"
|
|
40
|
+
f"cmd: {' '.join(cmd)}\nstdout: {proc.stdout}\nstderr: {proc.stderr}"
|
|
41
|
+
)
|
|
42
|
+
if not proc.stdout.strip():
|
|
43
|
+
return {}
|
|
44
|
+
return json.loads(proc.stdout.strip().splitlines()[-1])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def check(name: str, cond: bool, detail: str = ""):
|
|
48
|
+
global PASS, FAIL
|
|
49
|
+
if cond:
|
|
50
|
+
PASS += 1
|
|
51
|
+
print(f" PASS {name}")
|
|
52
|
+
else:
|
|
53
|
+
FAIL += 1
|
|
54
|
+
FAILED_NAMES.append(name)
|
|
55
|
+
print(f" FAIL {name} {detail}")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def section(title: str):
|
|
59
|
+
print(f"\n=== {title} ===")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def write_config(session: Path, overrides: Optional[dict] = None) -> dict:
|
|
63
|
+
cfg = {
|
|
64
|
+
"swarm": {"n_ants": 3, "max_iterations": 3, "elite_keep": 2},
|
|
65
|
+
"aco": {"alpha": 1.0, "beta": 2.0, "rho": 0.2, "q": 1.0,
|
|
66
|
+
"tau_init": 1.0, "tau_min": 0.01, "tau_max": 10.0},
|
|
67
|
+
"task_space": {"type": "graph",
|
|
68
|
+
"nodes": ["a", "b", "c", "d", "e"],
|
|
69
|
+
"max_path_length": 3,
|
|
70
|
+
"start_nodes": "any",
|
|
71
|
+
"edges": "complete"},
|
|
72
|
+
"scoring": {"mode": "fallback", "self_score_discount": 0.5},
|
|
73
|
+
"ant_prompt": {"objective": "test", "evidence_requirements": []},
|
|
74
|
+
"convergence": {
|
|
75
|
+
"max_iterations": 3,
|
|
76
|
+
"stagnation": {"enabled": True, "patience": 2, "min_delta": 0.01},
|
|
77
|
+
"entropy_floor": {"enabled": True, "threshold": 0.1},
|
|
78
|
+
"target_score": {"enabled": True, "value": 0.95},
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
if overrides:
|
|
82
|
+
_deep_merge(cfg, overrides)
|
|
83
|
+
session.mkdir(parents=True, exist_ok=True)
|
|
84
|
+
(session / "swarm-config.json").write_text(json.dumps(cfg))
|
|
85
|
+
return cfg
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _deep_merge(base: dict, overrides: dict):
|
|
89
|
+
for k, v in overrides.items():
|
|
90
|
+
if isinstance(v, dict) and isinstance(base.get(k), dict):
|
|
91
|
+
_deep_merge(base[k], v)
|
|
92
|
+
else:
|
|
93
|
+
base[k] = v
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def write_ant(session: Path, iteration: int, ant_idx: int,
|
|
97
|
+
path: list, self_score: float = 0.6, self_confidence: float = 0.7,
|
|
98
|
+
outputs: Optional[Path] = None) -> Path:
|
|
99
|
+
artifacts = outputs if outputs is not None else session / "artifacts"
|
|
100
|
+
artifacts.mkdir(exist_ok=True)
|
|
101
|
+
decisions = [
|
|
102
|
+
{"from": path[i], "to": path[i + 1], "rationale": "r",
|
|
103
|
+
"guided_by": "pheromone", "deviation_from_hint": False}
|
|
104
|
+
for i in range(len(path) - 1)
|
|
105
|
+
]
|
|
106
|
+
art = {
|
|
107
|
+
**({"_meta": {"kind": "swarm-ant-result", "schema": "swarm-ant-result/1.0",
|
|
108
|
+
"role": "evidence"}} if outputs is not None else {}),
|
|
109
|
+
"schema_version": "1.0",
|
|
110
|
+
"ant_id": f"ANT-{iteration}-{ant_idx}",
|
|
111
|
+
"iteration": iteration,
|
|
112
|
+
"assignment": {"start_node": path[0], "max_path_length": 3},
|
|
113
|
+
"path": path,
|
|
114
|
+
"path_decisions": decisions,
|
|
115
|
+
"self_score": self_score,
|
|
116
|
+
"self_confidence": self_confidence,
|
|
117
|
+
"evidence": [f"src/{path[-1]}.ts:{ant_idx}"],
|
|
118
|
+
"candidate_solution": {"type": "string", "summary": f"sol-{ant_idx}",
|
|
119
|
+
"content": str(path)},
|
|
120
|
+
}
|
|
121
|
+
p = artifacts / f"ant-{iteration}-{ant_idx}.json"
|
|
122
|
+
p.write_text(json.dumps(art))
|
|
123
|
+
return p
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# ---------------------------------------------------------------------------
|
|
127
|
+
# Unit tests — pheromone.py
|
|
128
|
+
# ---------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
def test_pheromone_unit():
|
|
131
|
+
section("pheromone.py unit")
|
|
132
|
+
|
|
133
|
+
s = PheromoneState.initialize(["a", "b", "c"], {})
|
|
134
|
+
check("init creates n*(n-1)/2 edges", len(s.tau) == 3, f"got {len(s.tau)}")
|
|
135
|
+
check("init uses default alpha=1.0", s.metadata["alpha"] == 1.0)
|
|
136
|
+
check("init uses default rho=0.2", s.metadata["rho"] == 0.2)
|
|
137
|
+
check("init all tau equal", len(set(s.tau.values())) == 1)
|
|
138
|
+
|
|
139
|
+
s.evaporate()
|
|
140
|
+
check("evaporate reduces by rho", abs(s.tau[edge_key("a", "b")] - 0.8) < 1e-9,
|
|
141
|
+
f"got {s.tau[edge_key('a', 'b')]}")
|
|
142
|
+
|
|
143
|
+
s.deposit(["a", "b", "c"], 0.5)
|
|
144
|
+
expected_ab = 0.8 + 0.5 * 1.0
|
|
145
|
+
check("deposit adds q*score per edge",
|
|
146
|
+
abs(s.tau[edge_key("a", "b")] - expected_ab) < 1e-9,
|
|
147
|
+
f"got {s.tau[edge_key('a', 'b')]}, expected {expected_ab}")
|
|
148
|
+
|
|
149
|
+
s.metadata["tau_max"] = 2.0
|
|
150
|
+
s.tau[edge_key("a", "b")] = 100.0
|
|
151
|
+
s.clip()
|
|
152
|
+
check("clip enforces tau_max", s.tau[edge_key("a", "b")] == 2.0)
|
|
153
|
+
check("clip enforces tau_min on small values",
|
|
154
|
+
all(v >= s.metadata["tau_min"] for v in s.tau.values()))
|
|
155
|
+
|
|
156
|
+
stats = s.stats()
|
|
157
|
+
check("stats has entropy field", "entropy" in stats)
|
|
158
|
+
check("stats entropy is positive", stats["entropy"] > 0)
|
|
159
|
+
|
|
160
|
+
probs = s.select_neighbors("a", ["a", "b", "c"])
|
|
161
|
+
check("select_neighbors excludes current node", "a" not in probs)
|
|
162
|
+
check("select_neighbors probs sum to 1",
|
|
163
|
+
abs(sum(probs.values()) - 1.0) < 1e-9, f"got {sum(probs.values())}")
|
|
164
|
+
|
|
165
|
+
empty = PheromoneState.initialize(["a"], {})
|
|
166
|
+
check("single-node init produces 0 edges", len(empty.tau) == 0)
|
|
167
|
+
check("empty stats handles 0-edge case", empty.stats()["entropy"] == 0.0)
|
|
168
|
+
|
|
169
|
+
s2 = PheromoneState.initialize(["a", "b", "c"], {})
|
|
170
|
+
with tempfile.TemporaryDirectory() as td:
|
|
171
|
+
p = Path(td) / "p.json"
|
|
172
|
+
s2.save(p)
|
|
173
|
+
s3 = PheromoneState.load(p)
|
|
174
|
+
check("save/load roundtrip preserves tau", s2.tau == s3.tau)
|
|
175
|
+
check("save/load preserves metadata", s2.metadata == s3.metadata)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# ---------------------------------------------------------------------------
|
|
179
|
+
# Unit tests — scoring.py
|
|
180
|
+
# ---------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
def test_scoring_unit():
|
|
183
|
+
section("scoring.py unit")
|
|
184
|
+
|
|
185
|
+
fb = FallbackScorer(discount=0.5)
|
|
186
|
+
artifact = {"self_score": 0.8, "self_confidence": 0.6}
|
|
187
|
+
expected = 0.8 * 0.6 * 0.5
|
|
188
|
+
check("FallbackScorer = self * conf * discount",
|
|
189
|
+
abs(fb.score(artifact) - expected) < 1e-9)
|
|
190
|
+
|
|
191
|
+
artifact_missing = {}
|
|
192
|
+
check("FallbackScorer handles missing fields",
|
|
193
|
+
fb.score(artifact_missing) == 0.0)
|
|
194
|
+
|
|
195
|
+
with tempfile.TemporaryDirectory() as td:
|
|
196
|
+
rule = Path(td) / "rule.py"
|
|
197
|
+
rule.write_text("def score(ant_artifact):\n return ant_artifact.get('self_score', 0) * 2\n")
|
|
198
|
+
ss = ScriptScorer(rule)
|
|
199
|
+
check("ScriptScorer loads user rule", ss.score({"self_score": 0.3}) == 0.6)
|
|
200
|
+
check("ScriptScorer clamps > 1.0", ss.score({"self_score": 0.9}) == 1.0)
|
|
201
|
+
check("ScriptScorer clamps < 0.0", ss.score({"self_score": -0.5}) == 0.0)
|
|
202
|
+
|
|
203
|
+
check("hallucination_check true at diff > 0.4",
|
|
204
|
+
hallucination_check(0.9, 0.4) is True)
|
|
205
|
+
check("hallucination_check false at diff < 0.4",
|
|
206
|
+
hallucination_check(0.5, 0.4) is False)
|
|
207
|
+
|
|
208
|
+
artifact_v = {"ant_id": "X", "self_score": 0.5, "self_confidence": 0.5}
|
|
209
|
+
score, src = resolve_score(artifact_v, {"X": 0.9}, None, fb)
|
|
210
|
+
check("resolve_score prefers verified", score == 0.9 and src == "verified_llm")
|
|
211
|
+
|
|
212
|
+
score, src = resolve_score(artifact_v, {}, None, fb)
|
|
213
|
+
check("resolve_score falls back when no verified",
|
|
214
|
+
src == "fallback_self")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
# ---------------------------------------------------------------------------
|
|
218
|
+
# CLI integration — full pipeline (3 iterations, fallback scoring)
|
|
219
|
+
# ---------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
def test_full_pipeline_3_iterations():
|
|
222
|
+
section("aco.py — full 3-iteration pipeline (fallback scoring)")
|
|
223
|
+
|
|
224
|
+
with tempfile.TemporaryDirectory() as td:
|
|
225
|
+
session = Path(td)
|
|
226
|
+
write_config(session)
|
|
227
|
+
|
|
228
|
+
r = run_aco(session, "init")
|
|
229
|
+
check("init: status ok", r["status"] == "ok")
|
|
230
|
+
check("init: 5 nodes -> 10 edges", r["n_edges"] == 10)
|
|
231
|
+
check("init: pheromone file exists",
|
|
232
|
+
(session / "pheromone" / "current.json").exists())
|
|
233
|
+
check("init: task-space file exists",
|
|
234
|
+
(session / "task-space.json").exists())
|
|
235
|
+
check("init: init.json frozen",
|
|
236
|
+
(session / "pheromone" / "init.json").exists())
|
|
237
|
+
|
|
238
|
+
best_history = []
|
|
239
|
+
entropy_history = []
|
|
240
|
+
|
|
241
|
+
for k in range(1, 4):
|
|
242
|
+
sel = run_aco(session, "select", "--iter", str(k))
|
|
243
|
+
check(f"iter{k} select: 3 assignments", len(sel["assignments"]) == 3)
|
|
244
|
+
check(f"iter{k} select: ant_ids correct",
|
|
245
|
+
all(a["ant_id"] == f"ANT-{k}-{i+1}" for i, a in enumerate(sel["assignments"])))
|
|
246
|
+
check(f"iter{k} select: edge_preferences not empty",
|
|
247
|
+
all(a["edge_preferences"] for a in sel["assignments"]))
|
|
248
|
+
|
|
249
|
+
paths_by_quality = [
|
|
250
|
+
(["a", "b", "c"], 0.9, 0.9),
|
|
251
|
+
(["b", "d", "e"], 0.6, 0.7),
|
|
252
|
+
(["c", "e", "a"], 0.4, 0.5),
|
|
253
|
+
]
|
|
254
|
+
for i, (path, ss, sc) in enumerate(paths_by_quality, 1):
|
|
255
|
+
write_ant(session, k, i, path, ss, sc)
|
|
256
|
+
|
|
257
|
+
up = run_aco(session, "update", "--iter", str(k))
|
|
258
|
+
check(f"iter{k} update: 3 ants processed", up["n_ants_processed"] == 3)
|
|
259
|
+
check(f"iter{k} update: best_score > 0", up["best_score"] > 0)
|
|
260
|
+
check(f"iter{k} update: stats has entropy", "entropy" in up["stats"])
|
|
261
|
+
|
|
262
|
+
best_history.append(up["best_score"])
|
|
263
|
+
entropy_history.append(up["stats"]["entropy"])
|
|
264
|
+
|
|
265
|
+
check(f"iter{k} history snapshot exists",
|
|
266
|
+
(session / "pheromone" / "history" / f"{k}.json").exists())
|
|
267
|
+
check(f"iter{k} trails written",
|
|
268
|
+
(session / "trails" / f"{k}.jsonl").exists())
|
|
269
|
+
|
|
270
|
+
check("best_score stable after iter1 (same ants each iter)",
|
|
271
|
+
best_history[0] == best_history[-1])
|
|
272
|
+
check("entropy decreases over iterations (concentration)",
|
|
273
|
+
entropy_history[0] >= entropy_history[-1],
|
|
274
|
+
f"start={entropy_history[0]:.3f} end={entropy_history[-1]:.3f}")
|
|
275
|
+
|
|
276
|
+
cv = run_aco(session, "converged")
|
|
277
|
+
check("converged: returns triggered_by list", isinstance(cv["triggered_by"], list))
|
|
278
|
+
check("converged: triggers stagnation (best unchanged)",
|
|
279
|
+
"stagnation" in cv["triggered_by"])
|
|
280
|
+
check("converged: also triggers max_iterations",
|
|
281
|
+
"max_iterations" in cv["triggered_by"])
|
|
282
|
+
check("converged: true after triggers", cv["converged"] is True)
|
|
283
|
+
|
|
284
|
+
rep = run_aco(session, "report")
|
|
285
|
+
check("report: has best", rep["best"] is not None)
|
|
286
|
+
check("report: top_k present", len(rep["top_k"]) > 0)
|
|
287
|
+
check("report: convergence curve len == iters",
|
|
288
|
+
len(rep["convergence_curve"]) == 3)
|
|
289
|
+
check("report: iterations_completed == 3", rep["iterations_completed"] == 3)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def test_run_scoped_outputs():
|
|
293
|
+
section("aco.py — v3 Run-scoped outputs and metadata")
|
|
294
|
+
|
|
295
|
+
with tempfile.TemporaryDirectory() as td:
|
|
296
|
+
run_dir = Path(td) / "run"
|
|
297
|
+
session = run_dir / "work" / "team"
|
|
298
|
+
write_config(session)
|
|
299
|
+
run_args = ("--run-dir", str(run_dir))
|
|
300
|
+
run_aco(session, *run_args, "init")
|
|
301
|
+
selected = run_aco(session, *run_args, "select", "--iter", "1")
|
|
302
|
+
start = selected["assignments"][0]["start_node"]
|
|
303
|
+
output = write_ant(session, 1, 1, [start], outputs=run_dir / "outputs")
|
|
304
|
+
valid = output.read_text()
|
|
305
|
+
changed = json.loads(valid)
|
|
306
|
+
changed["_meta"]["kind"] = "different-artifact"
|
|
307
|
+
output.write_text(json.dumps(changed))
|
|
308
|
+
rejected = run_aco(session, *run_args, "update", "--iter", "1", expect_exit=1)
|
|
309
|
+
check("v3 update rejects an invalid ant contract without recording the round",
|
|
310
|
+
"invalid ant artifact contract" in rejected["message"]
|
|
311
|
+
and not (session / "pheromone" / "updates" / "1.json").exists())
|
|
312
|
+
output.write_text(valid)
|
|
313
|
+
up = run_aco(session, *run_args, "update", "--iter", "1")
|
|
314
|
+
check("v3 update reads outputs/ ant", up["n_ants_processed"] == 1)
|
|
315
|
+
rep = run_aco(session, *run_args, "report")
|
|
316
|
+
check("v3 report self-describes its artifact",
|
|
317
|
+
rep["_meta"] == {"kind": "swarm-report", "schema": "swarm-report/1.0",
|
|
318
|
+
"role": "attachment"})
|
|
319
|
+
check("v3 report includes best solution", rep["best"]["ant_id"] == "ANT-1-1")
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
# ---------------------------------------------------------------------------
|
|
323
|
+
# CLI integration — target_score convergence
|
|
324
|
+
# ---------------------------------------------------------------------------
|
|
325
|
+
|
|
326
|
+
def test_target_score_convergence():
|
|
327
|
+
section("aco.py — target_score triggers early convergence")
|
|
328
|
+
|
|
329
|
+
with tempfile.TemporaryDirectory() as td:
|
|
330
|
+
session = Path(td)
|
|
331
|
+
write_config(session, {
|
|
332
|
+
"convergence": {"target_score": {"enabled": True, "value": 0.30}},
|
|
333
|
+
})
|
|
334
|
+
run_aco(session, "init")
|
|
335
|
+
run_aco(session, "select", "--iter", "1")
|
|
336
|
+
write_ant(session, 1, 1, ["a", "b"], 0.9, 0.9)
|
|
337
|
+
write_ant(session, 1, 2, ["b", "c"], 0.6, 0.6)
|
|
338
|
+
write_ant(session, 1, 3, ["c", "d"], 0.4, 0.4)
|
|
339
|
+
up = run_aco(session, "update", "--iter", "1")
|
|
340
|
+
|
|
341
|
+
check("best_score above target", up["best_score"] >= 0.30)
|
|
342
|
+
cv = run_aco(session, "converged")
|
|
343
|
+
check("converged after 1 iter (target hit)",
|
|
344
|
+
cv["converged"] is True and "target_score" in cv["triggered_by"])
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# ---------------------------------------------------------------------------
|
|
348
|
+
# CLI integration — hallucination detection (verified scores file)
|
|
349
|
+
# ---------------------------------------------------------------------------
|
|
350
|
+
|
|
351
|
+
def test_hallucination_flagging():
|
|
352
|
+
section("aco.py — hallucination flagging with verified scores")
|
|
353
|
+
|
|
354
|
+
with tempfile.TemporaryDirectory() as td:
|
|
355
|
+
session = Path(td)
|
|
356
|
+
write_config(session)
|
|
357
|
+
run_aco(session, "init")
|
|
358
|
+
run_aco(session, "select", "--iter", "1")
|
|
359
|
+
|
|
360
|
+
write_ant(session, 1, 1, ["a", "b"], self_score=0.95, self_confidence=0.9)
|
|
361
|
+
write_ant(session, 1, 2, ["b", "c"], self_score=0.85, self_confidence=0.8)
|
|
362
|
+
write_ant(session, 1, 3, ["c", "d"], self_score=0.7, self_confidence=0.7)
|
|
363
|
+
|
|
364
|
+
scores_dir = session / "scores"
|
|
365
|
+
scores_dir.mkdir(exist_ok=True)
|
|
366
|
+
(scores_dir / "iter-1-scores.json").write_text(json.dumps({
|
|
367
|
+
"iteration": 1, "scorer_type": "llm",
|
|
368
|
+
"scores": {
|
|
369
|
+
"ANT-1-1": {"verified_score": 0.20, "rationale": "weak"},
|
|
370
|
+
"ANT-1-2": {"verified_score": 0.80, "rationale": "ok"},
|
|
371
|
+
"ANT-1-3": {"verified_score": 0.65, "rationale": "ok"},
|
|
372
|
+
},
|
|
373
|
+
}))
|
|
374
|
+
|
|
375
|
+
up = run_aco(session, "update", "--iter", "1")
|
|
376
|
+
check("ANT-1-1 flagged as hallucination (|0.95-0.20|=0.75 > 0.4)",
|
|
377
|
+
"ANT-1-1" in up["hallucinations_flagged"])
|
|
378
|
+
check("ANT-1-2 NOT flagged (|0.85-0.80|=0.05 < 0.4)",
|
|
379
|
+
"ANT-1-2" not in up["hallucinations_flagged"])
|
|
380
|
+
check("ANT-1-3 NOT flagged (|0.7-0.65|=0.05 < 0.4)",
|
|
381
|
+
"ANT-1-3" not in up["hallucinations_flagged"])
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
# ---------------------------------------------------------------------------
|
|
385
|
+
# CLI integration — invalid artifact handling
|
|
386
|
+
# ---------------------------------------------------------------------------
|
|
387
|
+
|
|
388
|
+
def test_invalid_artifacts():
|
|
389
|
+
section("aco.py — invalid artifacts handled gracefully")
|
|
390
|
+
|
|
391
|
+
with tempfile.TemporaryDirectory() as td:
|
|
392
|
+
session = Path(td)
|
|
393
|
+
write_config(session)
|
|
394
|
+
run_aco(session, "init")
|
|
395
|
+
run_aco(session, "select", "--iter", "1")
|
|
396
|
+
|
|
397
|
+
write_ant(session, 1, 1, ["a", "b"])
|
|
398
|
+
|
|
399
|
+
artifacts = session / "artifacts"
|
|
400
|
+
(artifacts / "ant-1-2.json").write_text(json.dumps({
|
|
401
|
+
"schema_version": "1.0", "ant_id": "ANT-1-2", "iteration": 1,
|
|
402
|
+
"path": ["a", "ZZZ_NOT_A_NODE"],
|
|
403
|
+
"path_decisions": [{"from": "a", "to": "ZZZ_NOT_A_NODE", "rationale": "x",
|
|
404
|
+
"guided_by": "x", "deviation_from_hint": False}],
|
|
405
|
+
"self_score": 0.5, "self_confidence": 0.5,
|
|
406
|
+
"evidence": ["x"], "candidate_solution": {"summary": "x"},
|
|
407
|
+
}))
|
|
408
|
+
|
|
409
|
+
(artifacts / "ant-1-3.json").write_text("{ malformed json")
|
|
410
|
+
|
|
411
|
+
up = run_aco(session, "update", "--iter", "1")
|
|
412
|
+
check("only 1 valid ant processed (2 rejected)",
|
|
413
|
+
up["n_ants_processed"] == 1, f"got {up['n_ants_processed']}")
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_config_validation():
|
|
417
|
+
section("aco.py — config validation error paths")
|
|
418
|
+
|
|
419
|
+
with tempfile.TemporaryDirectory() as td:
|
|
420
|
+
session = Path(td)
|
|
421
|
+
session.mkdir(exist_ok=True)
|
|
422
|
+
(session / "swarm-config.json").write_text(json.dumps({"task_space": {}, "aco": {}}))
|
|
423
|
+
r = run_aco(session, "init", expect_exit=2)
|
|
424
|
+
check("missing nodes -> exit 2", r["status"] == "error")
|
|
425
|
+
check("error message mentions nodes",
|
|
426
|
+
"nodes" in r["message"] or "auto_discover" in r["message"])
|
|
427
|
+
|
|
428
|
+
with tempfile.TemporaryDirectory() as td:
|
|
429
|
+
session = Path(td)
|
|
430
|
+
session.mkdir(exist_ok=True)
|
|
431
|
+
r = run_aco(session, "init", expect_exit=2)
|
|
432
|
+
check("missing config -> exit 2", r["status"] == "error")
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def test_idempotent_update():
|
|
436
|
+
section("aco.py — update is idempotent (re-running same iter is safe)")
|
|
437
|
+
|
|
438
|
+
with tempfile.TemporaryDirectory() as td:
|
|
439
|
+
session = Path(td)
|
|
440
|
+
write_config(session)
|
|
441
|
+
run_aco(session, "init")
|
|
442
|
+
run_aco(session, "select", "--iter", "1")
|
|
443
|
+
write_ant(session, 1, 1, ["a", "b"], 0.8, 0.8)
|
|
444
|
+
write_ant(session, 1, 2, ["b", "c"], 0.6, 0.7)
|
|
445
|
+
final_ant = write_ant(session, 1, 3, ["c", "d"], 0.4, 0.5)
|
|
446
|
+
|
|
447
|
+
current = session / "pheromone" / "current.json"
|
|
448
|
+
original = current.read_bytes()
|
|
449
|
+
up1 = run_aco(session, "update", "--iter", "1")
|
|
450
|
+
projection = [current, session / "best.json",
|
|
451
|
+
session / "pheromone" / "history" / "1.json",
|
|
452
|
+
session / "trails" / "1.jsonl"]
|
|
453
|
+
expected = [path.read_bytes() for path in projection]
|
|
454
|
+
up2 = run_aco(session, "update", "--iter", "1")
|
|
455
|
+
check("update replay keeps full result and projection stable",
|
|
456
|
+
up1 == up2 and expected == [path.read_bytes() for path in projection])
|
|
457
|
+
current.write_bytes(original)
|
|
458
|
+
projection[2].unlink()
|
|
459
|
+
check("report recovers committed but interrupted update",
|
|
460
|
+
run_aco(session, "report")["iterations_completed"] == 1
|
|
461
|
+
and expected == [path.read_bytes() for path in projection])
|
|
462
|
+
content = json.loads(final_ant.read_text())
|
|
463
|
+
content["self_score"] = 0.9
|
|
464
|
+
final_ant.write_text(json.dumps(content))
|
|
465
|
+
conflict = run_aco(session, "update", "--iter", "1", expect_exit=1)
|
|
466
|
+
check("changed retry is rejected without altering projected state",
|
|
467
|
+
"inputs changed" in conflict["message"]
|
|
468
|
+
and expected == [path.read_bytes() for path in projection])
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def test_run_selection_replay():
|
|
472
|
+
section("aco.py — Run selection survives coordinator restart")
|
|
473
|
+
with tempfile.TemporaryDirectory() as td:
|
|
474
|
+
run_dir = Path(td) / "run"
|
|
475
|
+
session = run_dir / "work" / "team"
|
|
476
|
+
write_config(session, {"swarm": {"n_ants": 1}})
|
|
477
|
+
run_args = ("--run-dir", str(run_dir))
|
|
478
|
+
run_aco(session, *run_args, "init")
|
|
479
|
+
selected = run_aco(session, *run_args, "select", "--iter", "1")
|
|
480
|
+
selection = session / "assignments" / "1.json"
|
|
481
|
+
check("selection is persisted before dispatch", selection.is_file()
|
|
482
|
+
and json.loads(selection.read_text(encoding="utf-8")) == selected)
|
|
483
|
+
check("reopened selection returns original assignments",
|
|
484
|
+
run_aco(session, *run_args, "select", "--iter", "1") == selected)
|
|
485
|
+
start = selected["assignments"][0]["start_node"]
|
|
486
|
+
write_ant(session, 1, 1, ["b" if start == "a" else "a"], outputs=run_dir / "outputs")
|
|
487
|
+
mismatch = run_aco(session, *run_args, "update", "--iter", "1", expect_exit=1)
|
|
488
|
+
check("update rejects an ant from the wrong start", "saved assignment" in mismatch["message"])
|
|
489
|
+
write_ant(session, 1, 1, [start], outputs=run_dir / "outputs")
|
|
490
|
+
run_aco(session, *run_args, "update", "--iter", "1")
|
|
491
|
+
check("selection replays after a committed update",
|
|
492
|
+
run_aco(session, *run_args, "select", "--iter", "1") == selected)
|
|
493
|
+
selected["assignments"][0]["start_node"] = "b" if start == "a" else "a"
|
|
494
|
+
selection.write_text(json.dumps(selected), encoding="utf-8")
|
|
495
|
+
drift = run_aco(session, *run_args, "update", "--iter", "1", expect_exit=1)
|
|
496
|
+
check("replay rejects a changed assignment batch", "inputs changed" in drift["message"])
|
|
497
|
+
skipped = run_aco(session, *run_args, "select", "--iter", "3", expect_exit=1)
|
|
498
|
+
check("future iteration cannot skip controller state", "expected iteration 2" in skipped["message"])
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
def test_run_llm_scoring():
|
|
502
|
+
section("aco.py — Run requires a complete LLM score batch or an explicit fallback")
|
|
503
|
+
with tempfile.TemporaryDirectory() as td:
|
|
504
|
+
run_dir = Path(td) / "run"
|
|
505
|
+
session = run_dir / "work" / "team"
|
|
506
|
+
write_config(session, {"swarm": {"n_ants": 2}, "scoring": {"mode": "llm"}})
|
|
507
|
+
run_args = ("--run-dir", str(run_dir))
|
|
508
|
+
run_aco(session, *run_args, "init")
|
|
509
|
+
scores = session / "scores" / "iter-1-scores.json"
|
|
510
|
+
update = (*run_args, "update", "--iter", "1")
|
|
511
|
+
for index in (1, 2):
|
|
512
|
+
write_ant(session, 1, index, ["a", "b"], self_score=0.8, outputs=run_dir / "outputs")
|
|
513
|
+
missing = run_aco(session, *update, expect_exit=1)
|
|
514
|
+
check("missing LLM result requires a decision", "scores file" in missing["message"])
|
|
515
|
+
batch = {"iteration": 1, "scorer_type": "llm",
|
|
516
|
+
"scores": {"ANT-1-1": {"verified_score": 0.75, "rationale": "matches the evidence"}}}
|
|
517
|
+
scores.write_text(json.dumps(batch), encoding="utf-8")
|
|
518
|
+
partial = run_aco(session, *update, expect_exit=1)
|
|
519
|
+
check("partial LLM batch cannot commit controller state", "ANT-1-2" in partial["message"]
|
|
520
|
+
and not (session / "pheromone" / "updates" / "1.json").exists())
|
|
521
|
+
batch["scores"]["ANT-1-2"] = {"verified_score": True, "rationale": "invalid score type"}
|
|
522
|
+
scores.write_text(json.dumps(batch), encoding="utf-8")
|
|
523
|
+
invalid = run_aco(session, *update, expect_exit=1)
|
|
524
|
+
check("boolean score rejected", "invalid verified score" in invalid["message"])
|
|
525
|
+
batch["iteration"] = 2
|
|
526
|
+
batch["scores"]["ANT-1-2"]["verified_score"] = 0.65
|
|
527
|
+
scores.write_text(json.dumps(batch), encoding="utf-8")
|
|
528
|
+
wrong = run_aco(session, *update, expect_exit=1)
|
|
529
|
+
check("score batch from a different iteration rejected", "iteration 1" in wrong["message"])
|
|
530
|
+
batch["iteration"] = 1
|
|
531
|
+
scores.write_text(json.dumps(batch), encoding="utf-8")
|
|
532
|
+
scored = run_aco(session, *update)
|
|
533
|
+
check("verified scores used and replayed", scored["mean_score"] == 0.7
|
|
534
|
+
and run_aco(session, *update) == scored)
|
|
535
|
+
for index in (1, 2):
|
|
536
|
+
write_ant(session, 2, index, ["b", "c"], outputs=run_dir / "outputs")
|
|
537
|
+
fallback = (*run_args, "update", "--iter", "2", "--allow-score-fallback")
|
|
538
|
+
run_aco(session, *fallback)
|
|
539
|
+
receipts = [json.loads((session / "pheromone" / "updates" / f"{i}.json").read_text(encoding="utf-8"))
|
|
540
|
+
for i in (1, 2)]
|
|
541
|
+
check("receipts retain an actionable scoring choice for recovery",
|
|
542
|
+
[receipt["scoring"] for receipt in receipts] == ["llm", "fallback"])
|
|
543
|
+
report = run_aco(session, *run_args, "report")
|
|
544
|
+
check("both scoring sources visible in report",
|
|
545
|
+
{trail["source"] for trail in report["top_k"]} == {"verified_llm", "fallback_self"})
|
|
546
|
+
disagrees = run_aco(session, *run_args, "update", "--iter", "2", expect_exit=1)
|
|
547
|
+
check("replay preserves the explicit fallback decision", "inputs changed" in disagrees["message"])
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def test_auto_discover_from_glob():
|
|
551
|
+
section("aco.py — auto_discover_from glob")
|
|
552
|
+
|
|
553
|
+
with tempfile.TemporaryDirectory() as td:
|
|
554
|
+
td_path = Path(td)
|
|
555
|
+
for name in ["alpha.txt", "beta.txt", "gamma.txt"]:
|
|
556
|
+
(td_path / name).write_text("data")
|
|
557
|
+
|
|
558
|
+
session = td_path / "session"
|
|
559
|
+
session.mkdir()
|
|
560
|
+
(session / "swarm-config.json").write_text(json.dumps({
|
|
561
|
+
"swarm": {"n_ants": 2}, "aco": {},
|
|
562
|
+
"task_space": {"auto_discover_from": str(td_path / "*.txt"),
|
|
563
|
+
"max_path_length": 2},
|
|
564
|
+
"scoring": {"mode": "fallback"},
|
|
565
|
+
"ant_prompt": {"objective": "x"},
|
|
566
|
+
"convergence": {"max_iterations": 1},
|
|
567
|
+
}))
|
|
568
|
+
r = run_aco(session, "init")
|
|
569
|
+
check("auto_discover finds 3 files", r["n_nodes"] == 3,
|
|
570
|
+
f"got {r['n_nodes']}")
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
# ---------------------------------------------------------------------------
|
|
574
|
+
# Main
|
|
575
|
+
# ---------------------------------------------------------------------------
|
|
576
|
+
|
|
577
|
+
def main():
|
|
578
|
+
print("=" * 60)
|
|
579
|
+
print("team-swarm scripts test suite")
|
|
580
|
+
print("=" * 60)
|
|
581
|
+
|
|
582
|
+
test_pheromone_unit()
|
|
583
|
+
test_scoring_unit()
|
|
584
|
+
test_full_pipeline_3_iterations()
|
|
585
|
+
test_run_scoped_outputs()
|
|
586
|
+
test_target_score_convergence()
|
|
587
|
+
test_hallucination_flagging()
|
|
588
|
+
test_invalid_artifacts()
|
|
589
|
+
test_config_validation()
|
|
590
|
+
test_idempotent_update()
|
|
591
|
+
test_run_selection_replay()
|
|
592
|
+
test_run_llm_scoring()
|
|
593
|
+
test_auto_discover_from_glob()
|
|
594
|
+
|
|
595
|
+
print("\n" + "=" * 60)
|
|
596
|
+
print(f"Results: {PASS} passed, {FAIL} failed")
|
|
597
|
+
if FAILED_NAMES:
|
|
598
|
+
print("\nFailed tests:")
|
|
599
|
+
for name in FAILED_NAMES:
|
|
600
|
+
print(f" - {name}")
|
|
601
|
+
print("=" * 60)
|
|
602
|
+
sys.exit(0 if FAIL == 0 else 1)
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
if __name__ == "__main__":
|
|
606
|
+
main()
|