xcoder-dna 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +66 -0
- package/README.md +87 -2
- package/dist/agents/ai-chat-debate.d.ts +36 -0
- package/dist/agents/ai-chat-debate.js +300 -0
- package/dist/agents/ai-chat-report-writer.d.ts +7 -0
- package/dist/agents/ai-chat-report-writer.js +100 -0
- package/dist/agents/duplicate-detector.d.ts +41 -0
- package/dist/agents/duplicate-detector.js +65 -0
- package/dist/agents/genesis-agent.d.ts +61 -0
- package/dist/agents/genesis-agent.js +340 -0
- package/dist/agents/samurai-agent.d.ts +53 -0
- package/dist/agents/samurai-agent.js +279 -0
- package/dist/agents/sub-agent.d.ts +56 -0
- package/dist/agents/sub-agent.js +353 -0
- package/dist/backlog/backlog-requirement-validator.d.ts +10 -0
- package/dist/backlog/backlog-requirement-validator.js +60 -0
- package/dist/backlog/backlog-store.d.ts +29 -0
- package/dist/backlog/backlog-store.js +148 -0
- package/dist/backlog/po-agent.d.ts +16 -0
- package/dist/backlog/po-agent.js +121 -0
- package/dist/backlog/types.d.ts +25 -0
- package/dist/backlog/types.js +4 -0
- package/dist/bench/run.d.ts +11 -0
- package/dist/bench/run.js +185 -0
- package/dist/bench/types.d.ts +50 -0
- package/dist/bench/types.js +1 -0
- package/dist/cli/swarm.d.ts +10 -0
- package/dist/cli/swarm.js +100 -0
- package/dist/cli/task.d.ts +14 -0
- package/dist/cli/task.js +121 -0
- package/dist/cli/wbc-arg.d.ts +6 -0
- package/dist/cli/wbc-arg.js +40 -0
- package/dist/cli/wbc.d.ts +45 -0
- package/dist/cli/wbc.js +98 -0
- package/dist/commands/license.d.ts +9 -0
- package/dist/commands/license.js +140 -0
- package/dist/commands/release.d.ts +44 -0
- package/dist/commands/release.js +180 -0
- package/dist/commands/test.d.ts +50 -0
- package/dist/commands/test.js +385 -0
- package/dist/config/loadConfig.d.ts +82 -0
- package/dist/config/loadConfig.js +240 -0
- package/dist/config/secure-mode.d.ts +29 -0
- package/dist/config/secure-mode.js +63 -0
- package/dist/config/user-config.d.ts +39 -0
- package/dist/config/user-config.js +202 -0
- package/dist/engine/reasoning-engine.d.ts +21 -0
- package/dist/engine/reasoning-engine.js +59 -0
- package/dist/events/bus.d.ts +22 -0
- package/dist/events/bus.js +18 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +77 -0
- package/dist/indexing/ignoreRules.d.ts +1 -0
- package/dist/indexing/ignoreRules.js +53 -0
- package/dist/instance-swarm/instance-swarm-orchestrator.d.ts +57 -0
- package/dist/instance-swarm/instance-swarm-orchestrator.js +204 -0
- package/dist/instance-swarm/protocol-name-resolver.d.ts +23 -0
- package/dist/instance-swarm/protocol-name-resolver.js +64 -0
- package/dist/license/gate.d.ts +31 -0
- package/dist/license/gate.js +188 -0
- package/dist/license/http-client.d.ts +43 -0
- package/dist/license/http-client.js +195 -0
- package/dist/license/manager.d.ts +39 -0
- package/dist/license/manager.js +175 -0
- package/dist/license/receipt.d.ts +27 -0
- package/dist/license/receipt.js +108 -0
- package/dist/license/state-codec.d.ts +72 -0
- package/dist/license/state-codec.js +218 -0
- package/dist/license/state-paths.d.ts +17 -0
- package/dist/license/state-paths.js +64 -0
- package/dist/license/store.d.ts +44 -0
- package/dist/license/store.js +223 -0
- package/dist/license/trust-anchor.d.ts +24 -0
- package/dist/license/trust-anchor.js +74 -0
- package/dist/license/types.d.ts +34 -0
- package/dist/license/types.js +19 -0
- package/dist/llm/budget.d.ts +23 -0
- package/dist/llm/budget.js +58 -0
- package/dist/llm/client.d.ts +53 -0
- package/dist/llm/client.js +122 -0
- package/dist/llm/factory.d.ts +14 -0
- package/dist/llm/factory.js +32 -0
- package/dist/orchestrator/defect-logger.d.ts +31 -0
- package/dist/orchestrator/defect-logger.js +101 -0
- package/dist/orchestrator/defect-manager.d.ts +118 -0
- package/dist/orchestrator/defect-manager.js +338 -0
- package/dist/orchestrator/defect-migration.d.ts +14 -0
- package/dist/orchestrator/defect-migration.js +174 -0
- package/dist/orchestrator/defect-store.d.ts +48 -0
- package/dist/orchestrator/defect-store.js +76 -0
- package/dist/orchestrator/healing.d.ts +14 -0
- package/dist/orchestrator/healing.js +11 -0
- package/dist/orchestrator/interactive-steering.d.ts +64 -0
- package/dist/orchestrator/interactive-steering.js +107 -0
- package/dist/orchestrator/interrupt-handler.d.ts +30 -0
- package/dist/orchestrator/interrupt-handler.js +70 -0
- package/dist/orchestrator/lesson-manager.d.ts +25 -0
- package/dist/orchestrator/lesson-manager.js +122 -0
- package/dist/orchestrator/progress-summary.d.ts +15 -0
- package/dist/orchestrator/progress-summary.js +106 -0
- package/dist/orchestrator/reasoning-score.d.ts +49 -0
- package/dist/orchestrator/reasoning-score.js +117 -0
- package/dist/orchestrator/swarm.d.ts +36 -0
- package/dist/orchestrator/swarm.js +77 -0
- package/dist/orchestrator/task-factory.d.ts +15 -0
- package/dist/orchestrator/task-factory.js +176 -0
- package/dist/orchestrator/validation-gate.d.ts +23 -0
- package/dist/orchestrator/validation-gate.js +155 -0
- package/dist/protocol/react-contract.d.ts +136 -0
- package/dist/protocol/react-contract.js +698 -0
- package/dist/protocol/wks-protocol-manager.d.ts +22 -0
- package/dist/protocol/wks-protocol-manager.js +72 -0
- package/dist/sdlc-runtime/conversation-runner.d.ts +8 -0
- package/dist/sdlc-runtime/conversation-runner.js +64 -0
- package/dist/sdlc-runtime/dag-utils.d.ts +15 -0
- package/dist/sdlc-runtime/dag-utils.js +67 -0
- package/dist/sdlc-runtime/defect-integration.d.ts +7 -0
- package/dist/sdlc-runtime/defect-integration.js +99 -0
- package/dist/sdlc-runtime/execution-loop.d.ts +38 -0
- package/dist/sdlc-runtime/execution-loop.js +274 -0
- package/dist/sdlc-runtime/lesson-recorder.d.ts +9 -0
- package/dist/sdlc-runtime/lesson-recorder.js +27 -0
- package/dist/sdlc-runtime/plan-initializer.d.ts +47 -0
- package/dist/sdlc-runtime/plan-initializer.js +135 -0
- package/dist/sdlc-runtime/progress-persister.d.ts +10 -0
- package/dist/sdlc-runtime/progress-persister.js +34 -0
- package/dist/sdlc-runtime/protocol-loader.d.ts +10 -0
- package/dist/sdlc-runtime/protocol-loader.js +21 -0
- package/dist/sdlc-runtime/reporting.d.ts +24 -0
- package/dist/sdlc-runtime/reporting.js +68 -0
- package/dist/sdlc-runtime/sdlc-orchestrator.d.ts +59 -0
- package/dist/sdlc-runtime/sdlc-orchestrator.js +170 -0
- package/dist/sdlc-runtime/sdlc-skill.d.ts +44 -0
- package/dist/sdlc-runtime/sdlc-skill.js +148 -0
- package/dist/sdlc-runtime/steering-handler.d.ts +14 -0
- package/dist/sdlc-runtime/steering-handler.js +51 -0
- package/dist/sdlc-runtime/trace-recorder.d.ts +10 -0
- package/dist/sdlc-runtime/trace-recorder.js +7 -0
- package/dist/security/index.d.ts +16 -0
- package/dist/security/index.js +12 -0
- package/dist/security/input-screen.d.ts +30 -0
- package/dist/security/input-screen.js +75 -0
- package/dist/security/tool-call-guard.d.ts +16 -0
- package/dist/security/tool-call-guard.js +163 -0
- package/dist/security/untrusted-content.d.ts +34 -0
- package/dist/security/untrusted-content.js +63 -0
- package/dist/skills/advanced-dfir/SKILL.md +85 -0
- package/dist/skills/advanced-pentest-lab/SKILL.md +88 -0
- package/dist/skills/analyst/SKILL.md +55 -0
- package/dist/skills/architect/SKILL.md +54 -0
- package/dist/skills/aws/SKILL.md +92 -0
- package/dist/skills/azure/SKILL.md +90 -0
- package/dist/skills/bylaw-context.d.ts +45 -0
- package/dist/skills/bylaw-context.js +61 -0
- package/dist/skills/bylaw-review.d.ts +20 -0
- package/dist/skills/bylaw-review.js +101 -0
- package/dist/skills/conversation/SKILL.md +29 -0
- package/dist/skills/design-patterns/SKILL.md +190 -0
- package/dist/skills/devops/SKILL.md +55 -0
- package/dist/skills/directives.d.ts +20 -0
- package/dist/skills/directives.js +313 -0
- package/dist/skills/docker/SKILL.md +76 -0
- package/dist/skills/docker-expert/SKILL.md +56 -0
- package/dist/skills/enterprise-systems-analyst/SKILL.md +83 -0
- package/dist/skills/enterprise-systems-analyst/references/crm.md +41 -0
- package/dist/skills/enterprise-systems-analyst/references/erp.md +40 -0
- package/dist/skills/enterprise-systems-analyst/references/financial-systems.md +35 -0
- package/dist/skills/enterprise-systems-analyst/references/hcm.md +38 -0
- package/dist/skills/enterprise-systems-analyst/references/mrp.md +37 -0
- package/dist/skills/enterprise-systems-analyst/references/scm.md +32 -0
- package/dist/skills/ethical-hacking-methodology/SKILL.md +119 -0
- package/dist/skills/externalSkillLoader.d.ts +25 -0
- package/dist/skills/externalSkillLoader.js +65 -0
- package/dist/skills/externalSkillRegistry.d.ts +33 -0
- package/dist/skills/externalSkillRegistry.js +94 -0
- package/dist/skills/filesystem-management/SKILL.md +61 -0
- package/dist/skills/first-run-seed.d.ts +26 -0
- package/dist/skills/first-run-seed.js +75 -0
- package/dist/skills/git-vcs/SKILL.md +84 -0
- package/dist/skills/kafka/SKILL.md +89 -0
- package/dist/skills/kubernetes/SKILL.md +93 -0
- package/dist/skills/kubernetes-expert/SKILL.md +54 -0
- package/dist/skills/openshift/SKILL.md +93 -0
- package/dist/skills/pentester/SKILL.md +59 -0
- package/dist/skills/performance-tester/SKILL.md +57 -0
- package/dist/skills/playwright-ui-tester/SKILL.md +67 -0
- package/dist/skills/programmer/SKILL.md +58 -0
- package/dist/skills/project-scaffolding/SKILL.md +133 -0
- package/dist/skills/qa-engineer/SKILL.md +91 -0
- package/dist/skills/rca/SKILL.md +58 -0
- package/dist/skills/redhat/SKILL.md +92 -0
- package/dist/skills/rosa/SKILL.md +80 -0
- package/dist/skills/scrum-framework/SKILL.md +74 -0
- package/dist/skills/scrum-framework/references/artifacts_and_quality.md +79 -0
- package/dist/skills/scrum-framework/references/roles_and_events.md +105 -0
- package/dist/skills/scrum-master-agent/SKILL.md +74 -0
- package/dist/skills/scrum-master-agent/references/behaviors.md +56 -0
- package/dist/skills/sdlc-skill.d.ts +1 -0
- package/dist/skills/sdlc-skill.js +4 -0
- package/dist/skills/secops/SKILL.md +52 -0
- package/dist/skills/secure-architect.bylaws.d.ts +68 -0
- package/dist/skills/secure-architect.bylaws.js +525 -0
- package/dist/skills/seed-skills.d.ts +48 -0
- package/dist/skills/seed-skills.js +213 -0
- package/dist/skills/skill-authoring/SKILL.md +123 -0
- package/dist/skills/skill-header.d.ts +51 -0
- package/dist/skills/skill-header.js +163 -0
- package/dist/skills/skill-path-guard.d.ts +41 -0
- package/dist/skills/skill-path-guard.js +95 -0
- package/dist/skills/skillRouter.d.ts +51 -0
- package/dist/skills/skillRouter.js +90 -0
- package/dist/skills/skills-root.d.ts +64 -0
- package/dist/skills/skills-root.js +168 -0
- package/dist/skills/software-architect/SKILL.md +77 -0
- package/dist/skills/software-engineer/SKILL.md +74 -0
- package/dist/skills/solid-principles/SKILL.md +94 -0
- package/dist/skills/task-planning/SKILL.md +115 -0
- package/dist/skills/tester/SKILL.md +54 -0
- package/dist/skills/ubuntu/SKILL.md +87 -0
- package/dist/skills/ui-ux-design/SKILL.md +114 -0
- package/dist/skills/workspace-context/SKILL.md +103 -0
- package/dist/sprint/controller.d.ts +37 -0
- package/dist/sprint/controller.js +220 -0
- package/dist/sprint/dag-builder.d.ts +14 -0
- package/dist/sprint/dag-builder.js +105 -0
- package/dist/sprint/reporter.d.ts +11 -0
- package/dist/sprint/reporter.js +97 -0
- package/dist/sprint/state-store.d.ts +10 -0
- package/dist/sprint/state-store.js +71 -0
- package/dist/sprint/types.d.ts +24 -0
- package/dist/sprint/types.js +4 -0
- package/dist/store/file-version-store.d.ts +24 -0
- package/dist/store/file-version-store.js +73 -0
- package/dist/store/task-store.d.ts +90 -0
- package/dist/store/task-store.js +166 -0
- package/dist/task-ingest/architect-detailer.d.ts +43 -0
- package/dist/task-ingest/architect-detailer.js +141 -0
- package/dist/task-ingest/detail-schema.d.ts +9 -0
- package/dist/task-ingest/detail-schema.js +195 -0
- package/dist/task-ingest/detailed-run.d.ts +36 -0
- package/dist/task-ingest/detailed-run.js +108 -0
- package/dist/task-ingest/extract-id.d.ts +9 -0
- package/dist/task-ingest/extract-id.js +24 -0
- package/dist/task-ingest/index.d.ts +23 -0
- package/dist/task-ingest/index.js +14 -0
- package/dist/task-ingest/ingest.d.ts +45 -0
- package/dist/task-ingest/ingest.js +163 -0
- package/dist/task-ingest/list-ingested.d.ts +13 -0
- package/dist/task-ingest/list-ingested.js +30 -0
- package/dist/task-ingest/pending-filter.d.ts +30 -0
- package/dist/task-ingest/pending-filter.js +59 -0
- package/dist/task-ingest/scanner.d.ts +56 -0
- package/dist/task-ingest/scanner.js +216 -0
- package/dist/task-ingest/source-reader.d.ts +25 -0
- package/dist/task-ingest/source-reader.js +93 -0
- package/dist/task-ingest/spec-builder.d.ts +34 -0
- package/dist/task-ingest/spec-builder.js +89 -0
- package/dist/task-ingest/wbs-extract.d.ts +50 -0
- package/dist/task-ingest/wbs-extract.js +226 -0
- package/dist/task-ingest/wbs-parser.d.ts +36 -0
- package/dist/task-ingest/wbs-parser.js +170 -0
- package/dist/tools/apiTestTool.d.ts +37 -0
- package/dist/tools/apiTestTool.js +128 -0
- package/dist/tools/ast-tools.d.ts +183 -0
- package/dist/tools/ast-tools.js +853 -0
- package/dist/tools/browse-tool.d.ts +105 -0
- package/dist/tools/browse-tool.js +394 -0
- package/dist/tools/credential.d.ts +17 -0
- package/dist/tools/credential.js +32 -0
- package/dist/tools/dependency-graph.d.ts +23 -0
- package/dist/tools/dependency-graph.js +164 -0
- package/dist/tools/edit-tool.d.ts +34 -0
- package/dist/tools/edit-tool.js +95 -0
- package/dist/tools/file-header-manager.d.ts +27 -0
- package/dist/tools/file-header-manager.js +153 -0
- package/dist/tools/fs-tools.d.ts +154 -0
- package/dist/tools/fs-tools.js +337 -0
- package/dist/tools/git-tools.d.ts +79 -0
- package/dist/tools/git-tools.js +348 -0
- package/dist/tools/github-tool.d.ts +48 -0
- package/dist/tools/github-tool.js +147 -0
- package/dist/tools/globTool.d.ts +20 -0
- package/dist/tools/globTool.js +34 -0
- package/dist/tools/grepTool.d.ts +19 -0
- package/dist/tools/grepTool.js +44 -0
- package/dist/tools/index-freshness.d.ts +58 -0
- package/dist/tools/index-freshness.js +190 -0
- package/dist/tools/index-glob.d.ts +48 -0
- package/dist/tools/index-glob.js +175 -0
- package/dist/tools/load-skill-tool.d.ts +15 -0
- package/dist/tools/load-skill-tool.js +114 -0
- package/dist/tools/patch-tools.d.ts +58 -0
- package/dist/tools/patch-tools.js +153 -0
- package/dist/tools/playwright-tool.d.ts +66 -0
- package/dist/tools/playwright-tool.js +121 -0
- package/dist/tools/project-detect.d.ts +20 -0
- package/dist/tools/project-detect.js +87 -0
- package/dist/tools/prompt-guidance.d.ts +22 -0
- package/dist/tools/prompt-guidance.js +23 -0
- package/dist/tools/scheduleTool.d.ts +19 -0
- package/dist/tools/scheduleTool.js +181 -0
- package/dist/tools/search-tools.d.ts +27 -0
- package/dist/tools/search-tools.js +78 -0
- package/dist/tools/sed-tool.d.ts +66 -0
- package/dist/tools/sed-tool.js +402 -0
- package/dist/tools/shell-result.d.ts +11 -0
- package/dist/tools/shell-result.js +1 -0
- package/dist/tools/shell-tool.d.ts +45 -0
- package/dist/tools/shell-tool.js +141 -0
- package/dist/tools/siteCrawlerTool.d.ts +32 -0
- package/dist/tools/siteCrawlerTool.js +205 -0
- package/dist/tools/tool-registry.d.ts +67 -0
- package/dist/tools/tool-registry.js +596 -0
- package/dist/tools/validate-tool.d.ts +23 -0
- package/dist/tools/validate-tool.js +201 -0
- package/dist/tools/workspace-index.d.ts +46 -0
- package/dist/tools/workspace-index.js +173 -0
- package/dist/types.d.ts +222 -0
- package/dist/types.js +7 -0
- package/dist/updater/index.d.ts +14 -0
- package/dist/updater/index.js +120 -0
- package/dist/util/banner.d.ts +25 -0
- package/dist/util/banner.js +140 -0
- package/dist/util/command-suggester.d.ts +6 -0
- package/dist/util/command-suggester.js +25 -0
- package/dist/util/confirm-interrupt.d.ts +10 -0
- package/dist/util/confirm-interrupt.js +31 -0
- package/dist/util/continue-trigger.d.ts +11 -0
- package/dist/util/continue-trigger.js +20 -0
- package/dist/util/env-info.d.ts +18 -0
- package/dist/util/env-info.js +37 -0
- package/dist/util/file-access-log.d.ts +35 -0
- package/dist/util/file-access-log.js +140 -0
- package/dist/util/footer-manager.d.ts +124 -0
- package/dist/util/footer-manager.js +195 -0
- package/dist/util/footer-renderer.d.ts +67 -0
- package/dist/util/footer-renderer.js +319 -0
- package/dist/util/footer-state.d.ts +34 -0
- package/dist/util/footer-state.js +18 -0
- package/dist/util/footer-text.d.ts +51 -0
- package/dist/util/footer-text.js +74 -0
- package/dist/util/ids.d.ts +1 -0
- package/dist/util/ids.js +4 -0
- package/dist/util/levenshtein.d.ts +6 -0
- package/dist/util/levenshtein.js +34 -0
- package/dist/util/logger.d.ts +10 -0
- package/dist/util/logger.js +41 -0
- package/dist/util/logs.d.ts +26 -0
- package/dist/util/logs.js +88 -0
- package/dist/util/output-handler.d.ts +89 -0
- package/dist/util/output-handler.js +193 -0
- package/dist/util/output-interceptor.d.ts +18 -0
- package/dist/util/output-interceptor.js +49 -0
- package/dist/util/output-paths.d.ts +43 -0
- package/dist/util/output-paths.js +121 -0
- package/dist/util/package-json.d.ts +6 -0
- package/dist/util/package-json.js +36 -0
- package/dist/util/process-kill.d.ts +27 -0
- package/dist/util/process-kill.js +148 -0
- package/dist/util/protocol-error-logger.d.ts +33 -0
- package/dist/util/protocol-error-logger.js +73 -0
- package/dist/util/redact.d.ts +25 -0
- package/dist/util/redact.js +103 -0
- package/dist/util/scroll-region-guard.d.ts +33 -0
- package/dist/util/scroll-region-guard.js +63 -0
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.js +49 -0
- package/dist/util/terminal-output.d.ts +34 -0
- package/dist/util/terminal-output.js +1 -0
- package/dist/util/terminal-silent.d.ts +6 -0
- package/dist/util/terminal-silent.js +20 -0
- package/dist/util/terminal.d.ts +56 -0
- package/dist/util/terminal.js +124 -0
- package/dist/util/text-sanitize.d.ts +8 -0
- package/dist/util/text-sanitize.js +45 -0
- package/dist/util/thinking-spinner.d.ts +27 -0
- package/dist/util/thinking-spinner.js +189 -0
- package/dist/util/tool-error-logger.d.ts +33 -0
- package/dist/util/tool-error-logger.js +77 -0
- package/dist/util/tty.d.ts +13 -0
- package/dist/util/tty.js +16 -0
- package/dist/util/xcoder-paths.d.ts +56 -0
- package/dist/util/xcoder-paths.js +63 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +4 -0
- package/dist/worker-agent/to-subtask-node.d.ts +35 -0
- package/dist/worker-agent/to-subtask-node.js +41 -0
- package/dist/worker-agent/worker-orchestrator.d.ts +104 -0
- package/dist/worker-agent/worker-orchestrator.js +201 -0
- package/package.json +39 -4
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* secure-architect.bylaws.ts
|
|
3
|
+
*
|
|
4
|
+
* Hardcoded, immutable security bylaws for the Secure Solution/Software Architect role.
|
|
5
|
+
* Covers: core principles, microservices, UI, authentication/authorization, database, API,
|
|
6
|
+
* prompt security, AI/LLM, and server hardening (common, Linux/Ubuntu, Windows Server),
|
|
7
|
+
* plus cross-cutting controls.
|
|
8
|
+
*
|
|
9
|
+
* Levels follow RFC 2119 semantics:
|
|
10
|
+
* MUST - mandatory; a violation blocks the design from being approved.
|
|
11
|
+
* MUST_NOT - prohibited; a violation blocks the design from being approved.
|
|
12
|
+
* SHOULD - default expectation; deviation requires a documented, owned, accepted risk.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here is configurable at runtime. Every export is deeply frozen.
|
|
15
|
+
*/
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Utilities
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
function deepFreeze(value) {
|
|
20
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
21
|
+
Object.freeze(value);
|
|
22
|
+
for (const key of Object.keys(value)) {
|
|
23
|
+
deepFreeze(value[key]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Metadata
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
export const SKILL_META = deepFreeze({
|
|
32
|
+
name: "secure-architect",
|
|
33
|
+
role: "Secure Solution/Software Architect",
|
|
34
|
+
version: "1.0",
|
|
35
|
+
description: "Produces security-first system design artifacts: blueprints, threat models, solution " +
|
|
36
|
+
"designs, sequence diagrams, and hardened technology-stack decisions across " +
|
|
37
|
+
"microservices, UI, authentication, database, API, prompt, AI, and server " +
|
|
38
|
+
"(Linux/Ubuntu/Windows) layers.",
|
|
39
|
+
triggers: [
|
|
40
|
+
"design", "architecture", "blueprint", "solution design", "secure design",
|
|
41
|
+
"threat model", "tech stack", "how should we build", "diagram", "scalability",
|
|
42
|
+
"hardening", "authentication", "authorization", "microservices", "api",
|
|
43
|
+
"database", "prompt injection", "llm", "ai", "server", "ubuntu", "linux", "windows",
|
|
44
|
+
],
|
|
45
|
+
requiresTools: ["read_tool", "glob_tool", "grep_tool"],
|
|
46
|
+
composesWith: ["architect", "programmer", "devops", "secops", "analyst"],
|
|
47
|
+
});
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Bylaws
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
const CORE = [
|
|
52
|
+
{ id: "CORE-01", layer: "core", level: "MUST", title: "Least privilege",
|
|
53
|
+
rule: "Every user, service, token, container, and DB role gets the minimum access required, nothing more." },
|
|
54
|
+
{ id: "CORE-02", layer: "core", level: "MUST", title: "Defense in depth",
|
|
55
|
+
rule: "Never rely on a single control. Assume any one layer can fail." },
|
|
56
|
+
{ id: "CORE-03", layer: "core", level: "MUST", title: "Zero trust",
|
|
57
|
+
rule: "No implicit trust from network location. Authenticate and authorize every request, including service-to-service." },
|
|
58
|
+
{ id: "CORE-04", layer: "core", level: "MUST", title: "Secure by default",
|
|
59
|
+
rule: "The default configuration is the safe configuration. Insecure options are an explicit, documented opt-in." },
|
|
60
|
+
{ id: "CORE-05", layer: "core", level: "MUST", title: "Fail closed",
|
|
61
|
+
rule: "On error, timeout, or missing policy, deny. Never fail open." },
|
|
62
|
+
{ id: "CORE-06", layer: "core", level: "MUST", title: "Minimize attack surface",
|
|
63
|
+
rule: "Expose only what is required. Remove unused ports, endpoints, packages, and features." },
|
|
64
|
+
{ id: "CORE-07", layer: "core", level: "MUST_NOT", title: "Secrets in code, images, logs, or prompts",
|
|
65
|
+
rule: "Secrets are never stored in source code, container images, logs, or prompts. Use a secrets manager." },
|
|
66
|
+
{ id: "CORE-08", layer: "core", level: "MUST", title: "Auditability",
|
|
67
|
+
rule: "Security-relevant events are logged, tamper-evident, and free of secrets and unnecessary PII." },
|
|
68
|
+
{ id: "CORE-09", layer: "core", level: "MUST", title: "Validate at every trust boundary",
|
|
69
|
+
rule: "All input is hostile until validated, including output from LLMs and other internal services." },
|
|
70
|
+
{ id: "CORE-10", layer: "core", level: "MUST", title: "Threat model before build",
|
|
71
|
+
rule: "Identify trust boundaries and apply STRIDE per component and data flow (plus OWASP LLM Top 10 for AI features) before implementation begins." },
|
|
72
|
+
{ id: "CORE-11", layer: "core", level: "MUST_NOT", title: "Custom cryptography",
|
|
73
|
+
rule: "Do not invent cryptographic primitives or protocols. Use vetted libraries and standards." },
|
|
74
|
+
{ id: "CORE-12", layer: "core", level: "SHOULD", title: "Boring technology",
|
|
75
|
+
rule: "Prefer well-understood, actively maintained, widely audited technology unless a documented constraint demands otherwise." },
|
|
76
|
+
{ id: "CORE-13", layer: "core", level: "SHOULD", title: "Right-size the design",
|
|
77
|
+
rule: "Scale controls and architecture to data sensitivity and the real threat model. No service mesh for a single-user CLI tool." },
|
|
78
|
+
];
|
|
79
|
+
const MICROSERVICES = [
|
|
80
|
+
{ id: "MS-01", layer: "microservices", level: "MUST", title: "Single data owner",
|
|
81
|
+
rule: "One service owns one business capability and its data store. No databases shared between services." },
|
|
82
|
+
{ id: "MS-02", layer: "microservices", level: "MUST", title: "Contract-first",
|
|
83
|
+
rule: "Define OpenAPI / gRPC proto / AsyncAPI contracts with versioning and schema validation before implementation." },
|
|
84
|
+
{ id: "MS-03", layer: "microservices", level: "MUST", title: "Gateway at the edge",
|
|
85
|
+
rule: "Terminate TLS, authenticate, rate-limit, and apply WAF and request-size limits at an API gateway." },
|
|
86
|
+
{ id: "MS-04", layer: "microservices", level: "MUST", title: "Services re-validate identity",
|
|
87
|
+
rule: "Each service independently validates tokens. The gateway is never the only enforcement point." },
|
|
88
|
+
{ id: "MS-05", layer: "microservices", level: "MUST", title: "Service-to-service authentication",
|
|
89
|
+
rule: "Use mutual TLS (service mesh or SPIFFE/SPIRE) or short-lived signed workload tokens between services." },
|
|
90
|
+
{ id: "MS-06", layer: "microservices", level: "MUST_NOT", title: "Long-lived shared service keys",
|
|
91
|
+
rule: "No long-lived shared API keys between services." },
|
|
92
|
+
{ id: "MS-07", layer: "microservices", level: "MUST", title: "Default-deny networking",
|
|
93
|
+
rule: "Apply default-deny network policies (Kubernetes NetworkPolicy / security groups). Allow only required east-west paths." },
|
|
94
|
+
{ id: "MS-08", layer: "microservices", level: "MUST", title: "Resilience controls",
|
|
95
|
+
rule: "Set timeouts on every call; use retries with backoff and jitter, circuit breakers, bulkheads, idempotency keys, and bounded queues." },
|
|
96
|
+
{ id: "MS-09", layer: "microservices", level: "MUST", title: "Secure messaging",
|
|
97
|
+
rule: "Authenticate producers and consumers, encrypt in transit, validate message schemas, use dead-letter queues, and make consumers idempotent." },
|
|
98
|
+
{ id: "MS-10", layer: "microservices", level: "MUST", title: "Hardened containers",
|
|
99
|
+
rule: "Use minimal/distroless images, non-root user, read-only root filesystem, dropped Linux capabilities, pinned image digests, signed images, an SBOM per build, and CI image scanning." },
|
|
100
|
+
{ id: "MS-11", layer: "microservices", level: "MUST_NOT", title: "Privileged workloads",
|
|
101
|
+
rule: "No privileged containers or pods, and no host docker socket mounts." },
|
|
102
|
+
{ id: "MS-12", layer: "microservices", level: "MUST", title: "Runtime secrets",
|
|
103
|
+
rule: "Inject secrets at runtime from a vault/KMS-backed manager, rotate automatically, and separate per environment." },
|
|
104
|
+
{ id: "MS-13", layer: "microservices", level: "MUST", title: "Traceability without leakage",
|
|
105
|
+
rule: "Propagate correlation IDs and emit structured logs, metrics, and traces. Never log tokens, passwords, or full PII." },
|
|
106
|
+
{ id: "MS-14", layer: "microservices", level: "SHOULD", title: "Justify the split",
|
|
107
|
+
rule: "If a modular monolith meets the requirements, state so and justify before splitting into services." },
|
|
108
|
+
];
|
|
109
|
+
const UI = [
|
|
110
|
+
{ id: "UI-01", layer: "ui", level: "MUST", title: "Never trust the client",
|
|
111
|
+
rule: "All authorization and validation is enforced server-side. UI checks are UX only." },
|
|
112
|
+
{ id: "UI-02", layer: "ui", level: "MUST", title: "XSS prevention",
|
|
113
|
+
rule: "Use contextual output encoding and framework auto-escaping. Sanitize rich text with a vetted library (e.g., DOMPurify).",
|
|
114
|
+
refs: ["OWASP A03"] },
|
|
115
|
+
{ id: "UI-03", layer: "ui", level: "MUST_NOT", title: "Raw HTML injection",
|
|
116
|
+
rule: "Avoid innerHTML / dangerouslySetInnerHTML with any untrusted data." },
|
|
117
|
+
{ id: "UI-04", layer: "ui", level: "MUST", title: "Strict CSP and security headers",
|
|
118
|
+
rule: "Set a nonce/hash-based Content-Security-Policy without unsafe-inline or unsafe-eval, plus X-Content-Type-Options: nosniff, Referrer-Policy, Permissions-Policy, frame-ancestors, and HSTS." },
|
|
119
|
+
{ id: "UI-05", layer: "ui", level: "MUST", title: "CSRF protection",
|
|
120
|
+
rule: "Use SameSite cookies and anti-CSRF tokens for all cookie-authenticated state-changing requests." },
|
|
121
|
+
{ id: "UI-06", layer: "ui", level: "MUST", title: "Safe session storage",
|
|
122
|
+
rule: "Prefer HttpOnly + Secure + SameSite cookies. For SPAs, use the backend-for-frontend (BFF) pattern so tokens never reach the browser." },
|
|
123
|
+
{ id: "UI-07", layer: "ui", level: "MUST_NOT", title: "Tokens in localStorage or URLs",
|
|
124
|
+
rule: "Do not store tokens in localStorage, and never place secrets in URLs or query strings." },
|
|
125
|
+
{ id: "UI-08", layer: "ui", level: "MUST", title: "Explicit CORS allowlist",
|
|
126
|
+
rule: "Use an explicit origin allowlist. Never use '*' together with credentials." },
|
|
127
|
+
{ id: "UI-09", layer: "ui", level: "MUST", title: "Dependency hygiene",
|
|
128
|
+
rule: "Use lockfiles and SCA scanning, Subresource Integrity for third-party scripts, and minimize third-party JavaScript." },
|
|
129
|
+
{ id: "UI-10", layer: "ui", level: "MUST", title: "Sensitive data handling",
|
|
130
|
+
rule: "Mask secrets, disable autocomplete on sensitive fields where appropriate, and clear sensitive state on logout." },
|
|
131
|
+
{ id: "UI-11", layer: "ui", level: "MUST", title: "Server-side upload enforcement",
|
|
132
|
+
rule: "Client-side file type/size limits are UX only. Enforce them on the server." },
|
|
133
|
+
{ id: "UI-12", layer: "ui", level: "SHOULD", title: "Mobile and desktop clients",
|
|
134
|
+
rule: "Use the OS keystore/Keychain for secrets, ship no debug builds in release, pin certificates where justified, and secure deep links and IPC." },
|
|
135
|
+
{ id: "UI-13", layer: "ui", level: "MUST", title: "AI output in the UI is untrusted",
|
|
136
|
+
rule: "Escape LLM output, never execute it, label AI-generated content, and require confirmation before any AI-initiated action." },
|
|
137
|
+
];
|
|
138
|
+
const AUTHENTICATION = [
|
|
139
|
+
{ id: "AUTH-01", layer: "authentication", level: "MUST", title: "Standard protocols only",
|
|
140
|
+
rule: "Use OIDC / OAuth 2.1 (SAML for enterprise) via a proven identity provider. No custom auth protocols." },
|
|
141
|
+
{ id: "AUTH-02", layer: "authentication", level: "MUST", title: "Password storage",
|
|
142
|
+
rule: "Hash with Argon2id (preferred) or bcrypt/scrypt with tuned cost and unique salts. Check against breached-password lists.",
|
|
143
|
+
refs: ["OWASP Password Storage Cheat Sheet"] },
|
|
144
|
+
{ id: "AUTH-03", layer: "authentication", level: "MUST", title: "MFA for privileged access",
|
|
145
|
+
rule: "Require MFA for administrators and sensitive actions. Prefer phishing-resistant methods (WebAuthn/passkeys, FIDO2) over SMS/OTP." },
|
|
146
|
+
{ id: "AUTH-04", layer: "authentication", level: "MUST", title: "Short-lived tokens",
|
|
147
|
+
rule: "Access tokens live 5-15 minutes. Refresh tokens rotate with reuse detection and support server-side revocation." },
|
|
148
|
+
{ id: "AUTH-05", layer: "authentication", level: "MUST", title: "Session hardening",
|
|
149
|
+
rule: "Regenerate the session ID on login and privilege change. Enforce absolute and idle timeouts. Use Secure/HttpOnly/SameSite cookie flags." },
|
|
150
|
+
{ id: "AUTH-06", layer: "authentication", level: "MUST", title: "JWT validation",
|
|
151
|
+
rule: "Pin the algorithm (reject 'none'). Validate iss, aud, exp, and nbf. Use asymmetric signing (RS256/ES256/EdDSA) with key rotation via JWKS and minimal payloads." },
|
|
152
|
+
{ id: "AUTH-07", layer: "authentication", level: "MUST", title: "OAuth flow selection",
|
|
153
|
+
rule: "Use Authorization Code + PKCE for public clients and client credentials for machine-to-machine. Match redirect URIs strictly and validate state/nonce." },
|
|
154
|
+
{ id: "AUTH-08", layer: "authentication", level: "MUST_NOT", title: "Implicit flow",
|
|
155
|
+
rule: "Do not use the OAuth implicit flow." },
|
|
156
|
+
{ id: "AUTH-09", layer: "authentication", level: "MUST", title: "Brute-force and enumeration defense",
|
|
157
|
+
rule: "Apply rate limiting, progressive delays, and lockout with safe recovery. Return generic error messages (no user enumeration)." },
|
|
158
|
+
{ id: "AUTH-10", layer: "authentication", level: "MUST", title: "Secure account recovery",
|
|
159
|
+
rule: "Recovery tokens are single-use, short-lived, and rate-limited. Notify the user on recovery or credential change." },
|
|
160
|
+
{ id: "AUTH-11", layer: "authentication", level: "MUST", title: "Deny-by-default authorization",
|
|
161
|
+
rule: "Centralize policy (RBAC baseline; ABAC/ReBAC for fine-grained needs). Deny unless explicitly allowed." },
|
|
162
|
+
{ id: "AUTH-12", layer: "authentication", level: "MUST", title: "Object-level authorization",
|
|
163
|
+
rule: "Check ownership/permission on every object access at the API/service layer to prevent IDOR/BOLA.",
|
|
164
|
+
refs: ["OWASP API1:2023"] },
|
|
165
|
+
{ id: "AUTH-13", layer: "authentication", level: "MUST", title: "Separate admin plane",
|
|
166
|
+
rule: "Isolate the admin plane from the user plane. Require step-up authentication and auditing for privileged actions." },
|
|
167
|
+
{ id: "AUTH-14", layer: "authentication", level: "MUST", title: "Tenant isolation",
|
|
168
|
+
rule: "Derive tenant ID from the verified token, never from client input. Enforce isolation in queries (row-level security) and caches." },
|
|
169
|
+
];
|
|
170
|
+
const DATABASE = [
|
|
171
|
+
{ id: "DB-01", layer: "database", level: "MUST", title: "Per-service least-privilege accounts",
|
|
172
|
+
rule: "Each service uses a dedicated DB user with minimal grants. Use a separate migration role. No superuser/owner for the application and no shared credentials." },
|
|
173
|
+
{ id: "DB-02", layer: "database", level: "MUST", title: "Rotated credentials",
|
|
174
|
+
rule: "Use short-lived or regularly rotated database credentials issued from a secrets manager." },
|
|
175
|
+
{ id: "DB-03", layer: "database", level: "MUST", title: "No string-built queries",
|
|
176
|
+
rule: "Use parameterized queries/prepared statements or a safe ORM. Allowlist dynamic identifiers such as sort columns and table names.",
|
|
177
|
+
refs: ["OWASP A03"] },
|
|
178
|
+
{ id: "DB-04", layer: "database", level: "MUST", title: "Private network placement",
|
|
179
|
+
rule: "Databases sit in private subnets with no public IP, reachable only from allowlisted services." },
|
|
180
|
+
{ id: "DB-05", layer: "database", level: "MUST", title: "TLS to the database",
|
|
181
|
+
rule: "Enforce TLS 1.2+ for all connections and verify the server certificate." },
|
|
182
|
+
{ id: "DB-06", layer: "database", level: "MUST", title: "Encryption at rest",
|
|
183
|
+
rule: "Encrypt storage (disk/TDE) with KMS-managed keys. Use field-level encryption for highly sensitive data (PII, secrets, card data)." },
|
|
184
|
+
{ id: "DB-07", layer: "database", level: "MUST", title: "Hash what is never read back",
|
|
185
|
+
rule: "Hash, do not encrypt, any value that never needs to be recovered." },
|
|
186
|
+
{ id: "DB-08", layer: "database", level: "MUST_NOT", title: "Raw card data",
|
|
187
|
+
rule: "Do not store raw cardholder data unless PCI DSS scope has been explicitly accepted. Prefer tokenization.",
|
|
188
|
+
refs: ["PCI DSS"] },
|
|
189
|
+
{ id: "DB-09", layer: "database", level: "MUST", title: "Data minimization and retention",
|
|
190
|
+
rule: "Store only what is needed. Classify sensitive columns. Define retention, deletion, and anonymization (right to erasure)." },
|
|
191
|
+
{ id: "DB-10", layer: "database", level: "SHOULD", title: "Strong multi-tenant isolation",
|
|
192
|
+
rule: "Use row-level security or schema/database per tenant." },
|
|
193
|
+
{ id: "DB-11", layer: "database", level: "MUST", title: "Integrity controls",
|
|
194
|
+
rule: "Use constraints, foreign keys, and transactions. Add audit tables or CDC for sensitive changes." },
|
|
195
|
+
{ id: "DB-12", layer: "database", level: "MUST", title: "Backups",
|
|
196
|
+
rule: "Backups are encrypted, access-controlled, kept as an immutable/offsite copy, restore-tested regularly, and tied to defined RPO/RTO." },
|
|
197
|
+
{ id: "DB-13", layer: "database", level: "MUST", title: "Operational hygiene",
|
|
198
|
+
rule: "Patch on a cadence, disable default accounts and unused extensions, cap connection pools, and keep audit/slow-query logs free of sensitive values." },
|
|
199
|
+
{ id: "DB-14", layer: "database", level: "MUST", title: "NoSQL, cache, and search exposure",
|
|
200
|
+
rule: "Authentication is always on (Redis, MongoDB, Elasticsearch). Bind to private interfaces, disable dangerous commands, and guard against operator injection ($where, $ne)." },
|
|
201
|
+
];
|
|
202
|
+
const API = [
|
|
203
|
+
{ id: "API-01", layer: "api", level: "MUST", title: "Design against OWASP API Top 10",
|
|
204
|
+
rule: "Address BOLA, broken authentication, broken property-level authorization, unrestricted resource consumption, broken function-level authorization, SSRF, misconfiguration, improper inventory, and unsafe consumption of third-party APIs.",
|
|
205
|
+
refs: ["OWASP API Security Top 10 2023"] },
|
|
206
|
+
{ id: "API-02", layer: "api", level: "MUST", title: "Schema validation both directions",
|
|
207
|
+
rule: "Validate requests and responses against the contract. Reject unknown fields (mass-assignment protection)." },
|
|
208
|
+
{ id: "API-03", layer: "api", level: "MUST", title: "Allowlisted response DTOs",
|
|
209
|
+
rule: "Return explicit response objects. Never serialize internal entities or leak internal fields." },
|
|
210
|
+
{ id: "API-04", layer: "api", level: "MUST", title: "TLS everywhere",
|
|
211
|
+
rule: "Require TLS 1.2+ (prefer 1.3) and HSTS. Never place sensitive data in URLs." },
|
|
212
|
+
{ id: "API-05", layer: "api", level: "MUST", title: "Rate limits and quotas",
|
|
213
|
+
rule: "Limit per user/key/IP/tenant. Cap payload size, page size, batch size, and timeouts on all operations." },
|
|
214
|
+
{ id: "API-06", layer: "api", level: "MUST", title: "GraphQL controls",
|
|
215
|
+
rule: "Disable or gate introspection in production. Enforce depth and cost limits, prefer persisted queries, and apply per-field authorization." },
|
|
216
|
+
{ id: "API-07", layer: "api", level: "MUST", title: "Versioning and inventory",
|
|
217
|
+
rule: "Document versions and deprecation policy. Keep an API catalog and leave no shadow or debug endpoints." },
|
|
218
|
+
{ id: "API-08", layer: "api", level: "MUST", title: "Idempotency and webhook integrity",
|
|
219
|
+
rule: "Use idempotency keys for unsafe operations. Verify webhook signatures (HMAC, constant-time compare) with timestamp/nonce replay protection." },
|
|
220
|
+
{ id: "API-09", layer: "api", level: "MUST", title: "SSRF defense",
|
|
221
|
+
rule: "Block internal and metadata ranges (169.254.169.254, RFC1918, localhost), allowlist outbound destinations, and do not follow redirects blindly.",
|
|
222
|
+
refs: ["OWASP API7:2023"] },
|
|
223
|
+
{ id: "API-10", layer: "api", level: "MUST", title: "Safe error handling",
|
|
224
|
+
rule: "Use a consistent error format. Never expose stack traces, SQL errors, or internal paths. Keep 401/403/404 behavior generic to limit enumeration." },
|
|
225
|
+
{ id: "API-11", layer: "api", level: "MUST", title: "WebSocket and streaming security",
|
|
226
|
+
rule: "Authenticate on connect, re-validate on privileged messages, check origin, limit message size, and enforce heartbeat/idle timeouts." },
|
|
227
|
+
{ id: "API-12", layer: "api", level: "MUST", title: "Safe file handling",
|
|
228
|
+
rule: "Validate file type by content, enforce size limits, use randomized storage names, store outside the web root or in object storage, malware-scan, and serve with safe Content-Disposition and content type." },
|
|
229
|
+
];
|
|
230
|
+
const PROMPT = [
|
|
231
|
+
{ id: "PRM-01", layer: "prompt", level: "MUST", title: "All prompt inputs are untrusted",
|
|
232
|
+
rule: "User text, retrieved documents, web pages, emails, tool outputs, and file contents may carry injected instructions (direct and indirect prompt injection).",
|
|
233
|
+
refs: ["OWASP LLM01"] },
|
|
234
|
+
{ id: "PRM-02", layer: "prompt", level: "MUST", title: "Separate instructions from data",
|
|
235
|
+
rule: "Keep rules in the system prompt. Place untrusted content in clearly delimited, labelled data blocks with an explicit instruction never to follow instructions found inside them." },
|
|
236
|
+
{ id: "PRM-03", layer: "prompt", level: "MUST_NOT", title: "Secrets in prompts",
|
|
237
|
+
rule: "Never put API keys, credentials, internal URLs, or sensitive business logic in a prompt. Assume system prompts are extractable." },
|
|
238
|
+
{ id: "PRM-04", layer: "prompt", level: "MUST", title: "Least-privilege tools",
|
|
239
|
+
rule: "Expose only the tools the task needs, with narrow schemas. No open-ended 'run any command/SQL/URL' tools." },
|
|
240
|
+
{ id: "PRM-05", layer: "prompt", level: "MUST", title: "Prompts are code",
|
|
241
|
+
rule: "Version-control and review prompt templates. Test them in CI against an adversarial suite (jailbreak, injection, exfiltration)." },
|
|
242
|
+
{ id: "PRM-06", layer: "prompt", level: "SHOULD", title: "Input normalization and screening",
|
|
243
|
+
rule: "Apply length limits and unicode/zero-width/homoglyph normalization. Treat injection detection as a signal, never as the sole defense." },
|
|
244
|
+
{ id: "PRM-07", layer: "prompt", level: "MUST", title: "Schema-validate model output",
|
|
245
|
+
rule: "Validate output against a strict schema (JSON schema / structured outputs) before use." },
|
|
246
|
+
{ id: "PRM-08", layer: "prompt", level: "MUST_NOT", title: "Raw model output into interpreters",
|
|
247
|
+
rule: "Never pass raw model output into shells, SQL, eval, HTML, or file paths.",
|
|
248
|
+
refs: ["OWASP LLM02"] },
|
|
249
|
+
{ id: "PRM-09", layer: "prompt", level: "MUST", title: "Policy enforced in code",
|
|
250
|
+
rule: "A prompt instruction ('please don't...') is not a security boundary. Enforce policy outside the model." },
|
|
251
|
+
{ id: "PRM-10", layer: "prompt", level: "MUST", title: "Redacted, access-controlled prompt logs",
|
|
252
|
+
rule: "Log prompts and responses for audit with PII/secret redaction, access control, and a defined retention period." },
|
|
253
|
+
];
|
|
254
|
+
const AI = [
|
|
255
|
+
{ id: "AI-01", layer: "ai", level: "MUST", title: "Design against OWASP LLM Top 10",
|
|
256
|
+
rule: "Address prompt injection, insecure output handling, data poisoning, model DoS, supply-chain vulnerabilities, sensitive information disclosure, insecure plugin/tool design, excessive agency, overreliance, and model theft.",
|
|
257
|
+
refs: ["OWASP Top 10 for LLM Applications"] },
|
|
258
|
+
{ id: "AI-02", layer: "ai", level: "MUST", title: "Act with the user's permissions",
|
|
259
|
+
rule: "AI actions are bounded by the requesting user's permissions. Never act with a super-user or shared service identity.",
|
|
260
|
+
refs: ["OWASP LLM06"] },
|
|
261
|
+
{ id: "AI-03", layer: "ai", level: "MUST", title: "Human approval for high-impact actions",
|
|
262
|
+
rule: "Require human-in-the-loop confirmation for payments, deletions, external communications, deployments, and other irreversible actions." },
|
|
263
|
+
{ id: "AI-04", layer: "ai", level: "MUST", title: "Sandbox tools and code execution",
|
|
264
|
+
rule: "Run in isolation: no host network by default, resource limits, ephemeral filesystem, egress allowlist, and short-lived scoped credentials." },
|
|
265
|
+
{ id: "AI-05", layer: "ai", level: "MUST", title: "Authorize retrieval before context",
|
|
266
|
+
rule: "RAG must filter documents by the requesting user's access rights before they enter the model context. Isolate tenants in vector stores (namespaces/filters plus access control)." },
|
|
267
|
+
{ id: "AI-06", layer: "ai", level: "MUST", title: "Control data sent to models",
|
|
268
|
+
rule: "Classify what may leave the boundary. Redact or tokenize PII and secrets before sending to third-party providers. Confirm provider retention/training terms. Prefer private endpoints or regional hosting for regulated data." },
|
|
269
|
+
{ id: "AI-07", layer: "ai", level: "MUST", title: "Model and component supply chain",
|
|
270
|
+
rule: "Pin and verify model versions and weights (hashes/signatures). Scan model files and avoid unsafe pickle formats (prefer safetensors). Vet plugins, MCP servers, datasets, and embeddings. Maintain an AI-BOM." },
|
|
271
|
+
{ id: "AI-08", layer: "ai", level: "MUST", title: "Corpus provenance",
|
|
272
|
+
rule: "Require provenance and review for fine-tuning and RAG corpora. Write access to knowledge bases is a privileged operation." },
|
|
273
|
+
{ id: "AI-09", layer: "ai", level: "MUST", title: "Abuse and cost controls",
|
|
274
|
+
rule: "Set per-user token/request quotas, max context and output limits, concurrency caps, budget alerts, and a kill switch." },
|
|
275
|
+
{ id: "AI-10", layer: "ai", level: "SHOULD", title: "Grounding and fallback",
|
|
276
|
+
rule: "Ground factual answers with citations, define a fallback path for model failure or timeout, validate outputs, and surface uncertainty." },
|
|
277
|
+
{ id: "AI-11", layer: "ai", level: "MUST", title: "Red-team and continuous evaluation",
|
|
278
|
+
rule: "Red-team before release. Run continuous evals for injection, leakage, toxicity, and regressions. Monitor for anomalies and keep an AI incident response plan." },
|
|
279
|
+
{ id: "AI-12", layer: "ai", level: "SHOULD", title: "Governance and traceability",
|
|
280
|
+
rule: "Document intended use, limits, and data flows. Map to applicable regulation (EU AI Act, NIST AI RMF, ISO 42001). Record model and prompt versions per decision.",
|
|
281
|
+
refs: ["EU AI Act", "NIST AI RMF", "ISO/IEC 42001"] },
|
|
282
|
+
{ id: "AI-13", layer: "ai", level: "MUST", title: "Protect inference endpoints",
|
|
283
|
+
rule: "Authenticate and rate-limit inference APIs. Limit and monitor queries to resist model extraction." },
|
|
284
|
+
];
|
|
285
|
+
const SERVER_COMMON = [
|
|
286
|
+
{ id: "SRV-01", layer: "server-common", level: "MUST", title: "Minimal install and patching",
|
|
287
|
+
rule: "Remove unused services and packages. Patch the OS and dependencies on a defined cadence (automated for security updates, tested for the rest)." },
|
|
288
|
+
{ id: "SRV-02", layer: "server-common", level: "MUST", title: "Infrastructure as code",
|
|
289
|
+
rule: "Build immutable, reproducible servers (Terraform/Ansible/Packer). No manual snowflake changes." },
|
|
290
|
+
{ id: "SRV-03", layer: "server-common", level: "MUST", title: "Controlled admin access",
|
|
291
|
+
rule: "Admin access goes through a bastion/VPN/SSM with MFA. No directly exposed admin ports and no shared logins." },
|
|
292
|
+
{ id: "SRV-04", layer: "server-common", level: "MUST", title: "Host firewall",
|
|
293
|
+
rule: "Default-deny inbound. Restrict outbound (egress allowlist) where feasible." },
|
|
294
|
+
{ id: "SRV-05", layer: "server-common", level: "MUST", title: "Monitoring baseline",
|
|
295
|
+
rule: "Synchronize time (NTP/chrony), ship logs to a remote immutable store, run file-integrity monitoring, EDR/antimalware, and vulnerability scanning." },
|
|
296
|
+
{ id: "SRV-06", layer: "server-common", level: "MUST", title: "CIS baseline",
|
|
297
|
+
rule: "Conform to the applicable CIS Benchmark and verify compliance continuously.",
|
|
298
|
+
refs: ["CIS Benchmarks"] },
|
|
299
|
+
{ id: "SRV-07", layer: "server-common", level: "MUST", title: "Disk encryption and key protection",
|
|
300
|
+
rule: "Encrypt disks, protect and rotate keys, and separate dev/test/prod environments and accounts." },
|
|
301
|
+
{ id: "SRV-08", layer: "server-common", level: "MUST", title: "Modern TLS",
|
|
302
|
+
rule: "Allow modern ciphers only, use valid certificates with automated renewal (ACME), and disable TLS 1.0/1.1 and weak ciphers." },
|
|
303
|
+
{ id: "SRV-09", layer: "server-common", level: "MUST", title: "Tested recovery",
|
|
304
|
+
rule: "Backups are tested and a documented recovery runbook exists." },
|
|
305
|
+
];
|
|
306
|
+
const SERVER_LINUX = [
|
|
307
|
+
{ id: "LNX-01", layer: "server-linux", level: "MUST", title: "SSH hardening",
|
|
308
|
+
rule: "PermitRootLogin no; PasswordAuthentication no; key-based auth with modern keys (ed25519); restrict via AllowUsers/AllowGroups; set idle timeouts; add MFA where possible." },
|
|
309
|
+
{ id: "LNX-02", layer: "server-linux", level: "MUST", title: "Least-privilege sudo",
|
|
310
|
+
rule: "Scope sudo rules in /etc/sudoers.d. No passwordless sudo for human accounts." },
|
|
311
|
+
{ id: "LNX-03", layer: "server-linux", level: "MUST", title: "Firewall",
|
|
312
|
+
rule: "Use ufw/nftables with default-deny incoming, allow only required ports, and rate-limit SSH." },
|
|
313
|
+
{ id: "LNX-04", layer: "server-linux", level: "SHOULD", title: "Intrusion prevention and auditing",
|
|
314
|
+
rule: "Run fail2ban or CrowdSec. Run auditd with rules for authentication, sudo, and configuration changes." },
|
|
315
|
+
{ id: "LNX-05", layer: "server-linux", level: "MUST", title: "Mandatory access control",
|
|
316
|
+
rule: "Keep AppArmor enforcing (Ubuntu default; SELinux on RHEL family). Write profiles for custom services." },
|
|
317
|
+
{ id: "LNX-06", layer: "server-linux", level: "MUST", title: "Automated security patching",
|
|
318
|
+
rule: "Enable unattended-upgrades for security updates, use Livepatch where available, track Ubuntu Security Notices, and use Ubuntu Pro/ESM for extended coverage." },
|
|
319
|
+
{ id: "LNX-07", layer: "server-linux", level: "MUST", title: "Kernel and sysctl hardening",
|
|
320
|
+
rule: "Set net.ipv4.conf.all.rp_filter=1, disable source routing and ICMP redirects, net.ipv4.tcp_syncookies=1, kernel.kptr_restrict, kernel.dmesg_restrict, fs.protected_hardlinks/symlinks=1, kernel.yama.ptrace_scope. Disable unused kernel modules." },
|
|
321
|
+
{ id: "LNX-08", layer: "server-linux", level: "SHOULD", title: "Filesystem hardening",
|
|
322
|
+
rule: "Use separate /tmp, /var, /home partitions with nodev,nosuid,noexec where appropriate, umask 027, SUID/SGID audits, and LUKS encryption." },
|
|
323
|
+
{ id: "LNX-09", layer: "server-linux", level: "MUST", title: "Service isolation",
|
|
324
|
+
rule: "Run each app as a dedicated non-root user. Apply systemd sandboxing (NoNewPrivileges=yes, ProtectSystem=strict, ProtectHome=yes, PrivateTmp=yes, CapabilityBoundingSet=, RestrictAddressFamilies, SystemCallFilter). Bind apps to localhost/private interfaces behind a reverse proxy." },
|
|
325
|
+
{ id: "LNX-10", layer: "server-linux", level: "MUST", title: "Reverse proxy hardening",
|
|
326
|
+
rule: "Hide server version, set request/body/header limits and timeouts, add security headers, and apply rate limiting." },
|
|
327
|
+
{ id: "LNX-11", layer: "server-linux", level: "MUST", title: "Containers on Ubuntu",
|
|
328
|
+
rule: "Prefer rootless Docker/Podman with user namespaces and seccomp/AppArmor profiles. No --privileged and no docker socket mounts." },
|
|
329
|
+
{ id: "LNX-12", layer: "server-linux", level: "SHOULD", title: "Continuous verification",
|
|
330
|
+
rule: "Run Lynis and OpenSCAP/CIS-CAT, review open ports (ss -tulpn), and use rkhunter/chkrootkit as secondary checks." },
|
|
331
|
+
];
|
|
332
|
+
const SERVER_WINDOWS = [
|
|
333
|
+
{ id: "WIN-01", layer: "server-windows", level: "MUST", title: "Security baseline",
|
|
334
|
+
rule: "Prefer Server Core. Apply Microsoft Security Baselines / CIS Benchmarks via Group Policy or Intune. Remove unused roles and features." },
|
|
335
|
+
{ id: "WIN-02", layer: "server-windows", level: "MUST", title: "Patch management",
|
|
336
|
+
rule: "Patch via WSUS / Windows Update for Business / Azure Update Manager on a defined cadence." },
|
|
337
|
+
{ id: "WIN-03", layer: "server-windows", level: "MUST", title: "Tiered, least-privilege admin",
|
|
338
|
+
rule: "Use separate admin accounts and tiered administration. Deploy LAPS, the Protected Users group, and Credential Guard. Do not cache domain admin logons on member servers. Use gMSA for services. Disable built-in Administrator/Guest where possible." },
|
|
339
|
+
{ id: "WIN-04", layer: "server-windows", level: "MUST_NOT", title: "Internet-exposed RDP",
|
|
340
|
+
rule: "RDP is never exposed to the internet. Require NLA and MFA, and place it behind VPN / RD Gateway / bastion." },
|
|
341
|
+
{ id: "WIN-05", layer: "server-windows", level: "MUST", title: "Legacy protocol removal",
|
|
342
|
+
rule: "Disable SMBv1. Require SMB signing. Disable LLMNR, NetBIOS, and mDNS. Enforce TLS 1.2+ by disabling legacy SCHANNEL protocols." },
|
|
343
|
+
{ id: "WIN-06", layer: "server-windows", level: "MUST", title: "Remote management limits",
|
|
344
|
+
rule: "Restrict WinRM/PowerShell remoting to admin hosts. Enable script block logging and transcription; use Constrained Language Mode where feasible." },
|
|
345
|
+
{ id: "WIN-07", layer: "server-windows", level: "MUST", title: "Host firewall",
|
|
346
|
+
rule: "Keep Windows Defender Firewall enabled with default-deny inbound." },
|
|
347
|
+
{ id: "WIN-08", layer: "server-windows", level: "MUST", title: "Endpoint defense",
|
|
348
|
+
rule: "Run Microsoft Defender (or EDR) with tamper protection, ASR rules, and Exploit Protection. Enforce AppLocker/WDAC and BitLocker with TPM." },
|
|
349
|
+
{ id: "WIN-09", layer: "server-windows", level: "MUST", title: "Active Directory protection",
|
|
350
|
+
rule: "Protect Domain Controllers, rotate krbtgt, disable NTLM where feasible, enforce LDAP signing and channel binding, monitor privileged groups, and watch for Kerberoasting/DCSync indicators." },
|
|
351
|
+
{ id: "WIN-10", layer: "server-windows", level: "MUST", title: "IIS and service identities",
|
|
352
|
+
rule: "Run app pools and services under least-privilege identities. Remove default sites, disable directory browsing and unnecessary HTTP verbs, add security headers, and enable request filtering." },
|
|
353
|
+
{ id: "WIN-11", layer: "server-windows", level: "MUST", title: "Audit logging",
|
|
354
|
+
rule: "Enable advanced audit policy. Forward Security, Sysmon, and PowerShell logs to a SIEM and protect log integrity." },
|
|
355
|
+
{ id: "WIN-12", layer: "server-windows", level: "MUST_NOT", title: "Plaintext credentials",
|
|
356
|
+
rule: "Never store credentials in scripts or the registry in plaintext. Use DPAPI, a key vault, or Credential Manager patterns." },
|
|
357
|
+
];
|
|
358
|
+
const CROSS_CUTTING = [
|
|
359
|
+
{ id: "XC-01", layer: "cross-cutting", level: "MUST", title: "Secrets management",
|
|
360
|
+
rule: "Use a vault/KMS per environment with rotation. Scan CI and pre-commit for secrets (gitleaks/trufflehog). Revoke and rotate immediately on exposure." },
|
|
361
|
+
{ id: "XC-02", layer: "cross-cutting", level: "MUST", title: "Supply chain integrity",
|
|
362
|
+
rule: "Use lockfiles and dependency pinning, SCA, SBOMs (CycloneDX/SPDX), signed artifacts (Sigstore/cosign), protected branches, reviewed CI pipelines, and least-privilege CI tokens." },
|
|
363
|
+
{ id: "XC-03", layer: "cross-cutting", level: "MUST", title: "CI/CD security gates",
|
|
364
|
+
rule: "Run SAST, SCA, secret scan, IaC scan (tfsec/checkov), container scan, DAST on staging, and policy-as-code (OPA/Conftest)." },
|
|
365
|
+
{ id: "XC-04", layer: "cross-cutting", level: "MUST", title: "Centralized detection",
|
|
366
|
+
rule: "Keep centralized, structured, tamper-evident logs. Alert on authentication anomalies, privilege changes, and exfiltration patterns. Define retention." },
|
|
367
|
+
{ id: "XC-05", layer: "cross-cutting", level: "MUST", title: "Incident response",
|
|
368
|
+
rule: "Maintain a runbook with contacts, severity levels, containment steps, key-rotation procedure, and post-incident review." },
|
|
369
|
+
{ id: "XC-06", layer: "cross-cutting", level: "MUST", title: "Privacy by design",
|
|
370
|
+
rule: "Maintain a data inventory and lawful basis, handle DSARs, enforce retention and deletion, and follow breach-notification timelines." },
|
|
371
|
+
{ id: "XC-07", layer: "cross-cutting", level: "SHOULD", title: "Resilience planning",
|
|
372
|
+
rule: "Maintain a DR plan with documented RPO/RTO, multi-AZ as justified, and failure/chaos testing." },
|
|
373
|
+
];
|
|
374
|
+
export const BYLAWS = deepFreeze([
|
|
375
|
+
...CORE,
|
|
376
|
+
...MICROSERVICES,
|
|
377
|
+
...UI,
|
|
378
|
+
...AUTHENTICATION,
|
|
379
|
+
...DATABASE,
|
|
380
|
+
...API,
|
|
381
|
+
...PROMPT,
|
|
382
|
+
...AI,
|
|
383
|
+
...SERVER_COMMON,
|
|
384
|
+
...SERVER_LINUX,
|
|
385
|
+
...SERVER_WINDOWS,
|
|
386
|
+
...CROSS_CUTTING,
|
|
387
|
+
]);
|
|
388
|
+
// ---------------------------------------------------------------------------
|
|
389
|
+
// Process, deliverables, checklist, pitfalls
|
|
390
|
+
// ---------------------------------------------------------------------------
|
|
391
|
+
export const PROCESS = deepFreeze([
|
|
392
|
+
"Gather constraints: read wbs.md/existing docs; confirm data classification, compliance scope (GDPR, PCI-DSS, HIPAA, SOC 2, ISO 27001), user types, scale, latency, hosting target, and threat actors.",
|
|
393
|
+
"Define trust boundaries: internet->edge, UI->API, service->service, app->DB, app->LLM, tenant->tenant.",
|
|
394
|
+
"Threat model: STRIDE per component and data flow; OWASP LLM Top 10 for AI features; rank by likelihood x impact.",
|
|
395
|
+
"Decompose: components with single responsibilities and explicit contracts.",
|
|
396
|
+
"Define interaction: sequence diagrams including auth, failure, and abuse paths; mark sync/async boundaries and identity propagation.",
|
|
397
|
+
"Pick stack: justify each choice against constraints and security posture, not familiarity.",
|
|
398
|
+
"Specify controls: map every threat to a concrete control with an owner, or to a documented accepted risk.",
|
|
399
|
+
"Produce artifacts: blueprint.md, solution-design.md, threat-model.md, artifact.md.",
|
|
400
|
+
"Verify: walk SECURITY_CHECKLIST before declaring the design done.",
|
|
401
|
+
]);
|
|
402
|
+
export const OUTPUT_ARTIFACTS = deepFreeze([
|
|
403
|
+
"blueprint.md",
|
|
404
|
+
"solution-design.md",
|
|
405
|
+
"threat-model.md",
|
|
406
|
+
"artifact.md (deployment file list)",
|
|
407
|
+
"sequence diagrams (mermaid or ASCII) for any flow spanning >2 components, with authN/authZ/validation points marked",
|
|
408
|
+
"data-flow diagram with trust boundaries marked",
|
|
409
|
+
"threat table: Threat | Component | STRIDE/OWASP ref | Likelihood | Impact | Control | Residual risk",
|
|
410
|
+
"security checklist results with residual-risk register",
|
|
411
|
+
]);
|
|
412
|
+
export const SECURITY_CHECKLIST = deepFreeze([
|
|
413
|
+
"Trust boundaries identified and diagrammed",
|
|
414
|
+
"Threat model completed (STRIDE; OWASP LLM Top 10 if AI is involved)",
|
|
415
|
+
"AuthN: standard protocol, MFA for privileged users, token lifetimes and revocation defined",
|
|
416
|
+
"AuthZ: deny-by-default, object-level checks, tenant isolation enforced server-side",
|
|
417
|
+
"All input validated at every boundary; all output encoded for its context",
|
|
418
|
+
"Secrets in a vault; none in code, images, logs, or prompts",
|
|
419
|
+
"Encryption in transit (TLS 1.2+) and at rest; key management and rotation defined",
|
|
420
|
+
"Database least-privilege roles, parameterized access, private network, tested backups",
|
|
421
|
+
"API schema validation, rate limits, size limits, SSRF and mass-assignment protections",
|
|
422
|
+
"AI: excessive agency bounded, human approval for high-impact actions, RAG authorization, output treated as untrusted, cost/abuse quotas set",
|
|
423
|
+
"Servers hardened to baseline (CIS), patched, firewalled, least-privilege services, logged",
|
|
424
|
+
"Supply chain controls (pinning, SBOM, signing, scanning) in CI/CD",
|
|
425
|
+
"Logging/alerting without sensitive data; incident response path defined",
|
|
426
|
+
"Residual risks documented and accepted by an owner",
|
|
427
|
+
]);
|
|
428
|
+
export const COMMON_PITFALLS = deepFreeze([
|
|
429
|
+
"Authorization checked only in the UI or gateway; the service behind trusts everything (IDOR/BOLA).",
|
|
430
|
+
"Long-lived tokens or shared API keys between services that are never rotated.",
|
|
431
|
+
"Secrets committed to git, baked into images, or pasted into system prompts.",
|
|
432
|
+
"LLM output passed straight to a shell, SQL, or HTML renderer.",
|
|
433
|
+
"RAG that retrieves documents without checking the requesting user's access rights.",
|
|
434
|
+
"Agents running with a service/admin identity instead of the user's scoped permissions.",
|
|
435
|
+
"Databases, caches, or search clusters exposed to the internet without auth.",
|
|
436
|
+
"CORS '*' with credentials, missing CSP, or tokens stored in localStorage.",
|
|
437
|
+
"No egress restrictions, making SSRF and data exfiltration easy.",
|
|
438
|
+
"Under-specified error/retry behavior and rate limits, turning failures into DoS or data leaks.",
|
|
439
|
+
"Treating hardening as one-time instead of continuous patching, scanning, and monitoring.",
|
|
440
|
+
"Designing for hypothetical future scale or threats before the real threat model is addressed.",
|
|
441
|
+
"Controls that cripple usability get bypassed; test the secure path for ergonomics.",
|
|
442
|
+
]);
|
|
443
|
+
// ---------------------------------------------------------------------------
|
|
444
|
+
// Query helpers
|
|
445
|
+
// ---------------------------------------------------------------------------
|
|
446
|
+
export function getBylawsByLayer(layer) {
|
|
447
|
+
return BYLAWS.filter((b) => b.layer === layer);
|
|
448
|
+
}
|
|
449
|
+
export function getBylawById(id) {
|
|
450
|
+
return BYLAWS.find((b) => b.id === id);
|
|
451
|
+
}
|
|
452
|
+
export function getBylawsByLevel(level) {
|
|
453
|
+
return BYLAWS.filter((b) => b.level === level);
|
|
454
|
+
}
|
|
455
|
+
/** Layers a given task touches, inferred from keywords. Core and cross-cutting always apply. */
|
|
456
|
+
export function inferLayers(taskText) {
|
|
457
|
+
const t = taskText.toLowerCase();
|
|
458
|
+
const rules = [
|
|
459
|
+
["microservices", /microservice|service mesh|kubernetes|k8s|container|docker|message queue|kafka|rabbit/],
|
|
460
|
+
["ui", /\bui\b|frontend|front-end|browser|react|vue|angular|spa\b|web app|mobile app|desktop app/],
|
|
461
|
+
["authentication", /auth|login|oauth|oidc|saml|jwt|session|sso|mfa|password|rbac|permission/],
|
|
462
|
+
["database", /database|\bdb\b|sql|postgres|mysql|mongo|redis|elasticsearch|schema|migration/],
|
|
463
|
+
["api", /\bapi\b|rest|graphql|grpc|webhook|websocket|endpoint/],
|
|
464
|
+
["prompt", /prompt|system prompt|jailbreak|injection/],
|
|
465
|
+
["ai", /\bai\b|llm|model|rag|agent|embedding|vector|inference|mcp/],
|
|
466
|
+
["server-common", /server|host|vm\b|infrastructure|hardening/],
|
|
467
|
+
["server-linux", /linux|ubuntu|debian|rhel|systemd|ssh/],
|
|
468
|
+
["server-windows", /windows|active directory|\bad\b|iis|powershell|rdp/],
|
|
469
|
+
];
|
|
470
|
+
const hit = rules.filter(([, re]) => re.test(t)).map(([layer]) => layer);
|
|
471
|
+
return deepFreeze(["core", ...hit, "cross-cutting"]);
|
|
472
|
+
}
|
|
473
|
+
/** Render bylaws as plain text suitable for injecting into an agent's context. */
|
|
474
|
+
export function renderBylaws(layers) {
|
|
475
|
+
const selected = layers ? BYLAWS.filter((b) => layers.includes(b.layer)) : BYLAWS;
|
|
476
|
+
const lines = [
|
|
477
|
+
`# ${SKILL_META.name} bylaws v${SKILL_META.version}`,
|
|
478
|
+
"MUST / MUST_NOT violations block approval. SHOULD deviations need a documented, owned, accepted risk.",
|
|
479
|
+
"",
|
|
480
|
+
];
|
|
481
|
+
let current;
|
|
482
|
+
for (const b of selected) {
|
|
483
|
+
if (b.layer !== current) {
|
|
484
|
+
current = b.layer;
|
|
485
|
+
lines.push(`## ${current}`);
|
|
486
|
+
}
|
|
487
|
+
lines.push(`- [${b.id}] ${b.level} - ${b.title}: ${b.rule}`);
|
|
488
|
+
}
|
|
489
|
+
return lines.join("\n");
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Evaluate findings against the bylaws.
|
|
493
|
+
* - Any failed MUST / MUST_NOT blocks approval (accepted-risk is not allowed for them).
|
|
494
|
+
* - A failed SHOULD must be recorded as accepted-risk with a named owner.
|
|
495
|
+
* - Every in-scope bylaw must have a finding.
|
|
496
|
+
*/
|
|
497
|
+
export function evaluateReview(findings, layers) {
|
|
498
|
+
const scope = layers ? BYLAWS.filter((b) => layers.includes(b.layer)) : BYLAWS;
|
|
499
|
+
const byId = new Map(findings.map((f) => [f.bylawId, f]));
|
|
500
|
+
const blocking = [];
|
|
501
|
+
const unreviewed = [];
|
|
502
|
+
const invalid = [];
|
|
503
|
+
for (const b of scope) {
|
|
504
|
+
const f = byId.get(b.id);
|
|
505
|
+
if (!f) {
|
|
506
|
+
unreviewed.push(b.id);
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
if (f.status === "accepted-risk") {
|
|
510
|
+
if (b.level !== "SHOULD")
|
|
511
|
+
invalid.push(b.id);
|
|
512
|
+
else if (!f.riskOwner)
|
|
513
|
+
invalid.push(b.id);
|
|
514
|
+
}
|
|
515
|
+
else if (f.status === "fail") {
|
|
516
|
+
blocking.push(b.id);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return deepFreeze({
|
|
520
|
+
approved: blocking.length === 0 && unreviewed.length === 0 && invalid.length === 0,
|
|
521
|
+
blocking,
|
|
522
|
+
unreviewed,
|
|
523
|
+
invalid,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Idempotent, non-destructive seeding of the home skills directory.
|
|
3
|
+
*
|
|
4
|
+
* On first run the shipped packs are copied to ~/.xcoder/skills so the user
|
|
5
|
+
* owns an editable tree that survives uninstall. Precision matters here, so
|
|
6
|
+
* ownership is tracked with a per-file SHA-256 manifest:
|
|
7
|
+
*
|
|
8
|
+
* absent -> write (created)
|
|
9
|
+
* present, hashes match -> leave alone (unchanged)
|
|
10
|
+
* present, differs, IN manifest -> overwrite (repaired)
|
|
11
|
+
* present, differs, NOT in manifest -> never touch (preserved)
|
|
12
|
+
* extra pack not in source -> never touch (preserved)
|
|
13
|
+
*
|
|
14
|
+
* There are NO deletes anywhere in this module — the one failure mode that
|
|
15
|
+
* cannot be undone is deleting a file the user wrote.
|
|
16
|
+
*/
|
|
17
|
+
/** Per-file ownership record written next to the seeded tree. */
|
|
18
|
+
export interface SkillsManifestFile {
|
|
19
|
+
schemaVersion: 1;
|
|
20
|
+
generatedAt: string;
|
|
21
|
+
generator: "installer" | "first-run";
|
|
22
|
+
/** packName -> { relativePosixPath -> lowercase hex sha256 } */
|
|
23
|
+
packs: Record<string, Record<string, string>>;
|
|
24
|
+
}
|
|
25
|
+
export interface SeedSkillsHomeOptions {
|
|
26
|
+
/** The shipped packs directory (the repo/installer `skills/` folder). */
|
|
27
|
+
sourceDir: string;
|
|
28
|
+
homeDir?: string;
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
manifestPath?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SeedSkillsHomeResult {
|
|
33
|
+
action: "created" | "repaired" | "unchanged" | "skipped";
|
|
34
|
+
written: string[];
|
|
35
|
+
updated: string[];
|
|
36
|
+
preserved: string[];
|
|
37
|
+
errors: {
|
|
38
|
+
path: string;
|
|
39
|
+
reason: string;
|
|
40
|
+
}[];
|
|
41
|
+
manifestPath: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Seed the home skills directory from the shipped packs.
|
|
45
|
+
*
|
|
46
|
+
* Never throws: every failure is recorded in `errors` and the run continues.
|
|
47
|
+
*/
|
|
48
|
+
export declare function seedSkillsHome(opts: SeedSkillsHomeOptions): Promise<SeedSkillsHomeResult>;
|