wtf-p 0.7.4 → 0.8.1
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/README.md +10 -10
- package/bin/commands/install-logic.js +1 -1
- package/bin/lib/adapter-compiler.js +305 -78
- package/bin/lib/clio-registration.js +159 -41
- package/bin/lib/manifest.js +11 -3
- package/bin/uninstall.js +22 -6
- package/package.json +3 -3
- package/protocol/actions/checkpoint.json +10 -1
- package/protocol/actions/execute-outline.json +10 -2
- package/protocol/actions/export-latex.json +15 -2
- package/protocol/actions/plan-revision.json +17 -4
- package/protocol/actions/polish-prose.json +13 -3
- package/protocol/actions/research-gap.json +16 -3
- package/protocol/actions/verify-work.json +7 -2
- package/protocol/project/README.md +37 -0
- package/protocol/project/schemas/interaction.schema.json +100 -0
- package/protocol/project/templates/interaction.json +16 -0
- package/protocol/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/protocol/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/protocol/skills/wtfp-plan-section/SKILL.md +1 -1
- package/protocol/skills/wtfp-plan-section/references/actions.md +4 -3
- package/protocol/skills/wtfp-research-literature/SKILL.md +1 -1
- package/protocol/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/protocol/skills/wtfp-write-section/SKILL.md +1 -1
- package/protocol/skills/wtfp-write-section/references/actions.md +1 -1
- package/protocol/workflows/checkpoint.md +2 -2
- package/protocol/workflows/execute-outline.md +2 -2
- package/protocol/workflows/export-latex.md +4 -4
- package/protocol/workflows/plan-revision.md +4 -3
- package/protocol/workflows/plan-section.md +2 -2
- package/protocol/workflows/polish-prose.md +3 -3
- package/protocol/workflows/research-gap.md +2 -2
- package/protocol/workflows/verify-work.md +3 -3
- package/protocol/workflows/write-section.md +2 -2
- package/vendors/antigravity/.wtfp-generated.json +172 -172
- package/vendors/antigravity/actions/checkpoint.json +10 -1
- package/vendors/antigravity/actions/execute-outline.json +10 -2
- package/vendors/antigravity/actions/export-latex.json +15 -2
- package/vendors/antigravity/actions/plan-revision.json +17 -4
- package/vendors/antigravity/actions/polish-prose.json +13 -3
- package/vendors/antigravity/actions/research-gap.json +16 -3
- package/vendors/antigravity/actions/verify-work.json +7 -2
- package/vendors/antigravity/plugin.json +2 -1
- package/vendors/antigravity/project/README.md +37 -0
- package/vendors/antigravity/project/schemas/interaction.schema.json +100 -0
- package/vendors/antigravity/project/templates/interaction.json +16 -0
- package/vendors/antigravity/rules/wtfp-project-state.md +41 -1
- package/vendors/antigravity/{commands/wtfp-add-todo.md → skills/wtfp-add-todo/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-analyze-bib.md → skills/wtfp-analyze-bib/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-audit-milestone.md → skills/wtfp-audit-milestone/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-check-refs.md → skills/wtfp-check-refs/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-check-todos.md → skills/wtfp-check-todos/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-checkpoint.md → skills/wtfp-checkpoint/SKILL.md} +4 -3
- package/vendors/antigravity/{commands/wtfp-contribute.md → skills/wtfp-contribute/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-create-outline.md → skills/wtfp-create-outline/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-create-poster.md → skills/wtfp-create-poster/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-create-slides.md → skills/wtfp-create-slides/SKILL.md} +2 -1
- package/vendors/antigravity/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/antigravity/{commands/wtfp-discuss-section.md → skills/wtfp-discuss-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-execute-outline.md → skills/wtfp-execute-outline/SKILL.md} +4 -3
- package/vendors/antigravity/{commands/wtfp-export-latex.md → skills/wtfp-export-latex/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-help.md → skills/wtfp-help/SKILL.md} +3 -2
- package/vendors/antigravity/{commands/wtfp-insert-section.md → skills/wtfp-insert-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-list-assumptions.md → skills/wtfp-list-assumptions/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-map-project.md → skills/wtfp-map-project/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-new-paper.md → skills/wtfp-new-paper/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-pause-writing.md → skills/wtfp-pause-writing/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-plan-milestone-gaps.md → skills/wtfp-plan-milestone-gaps/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-plan-revision.md → skills/wtfp-plan-revision/SKILL.md} +10 -4
- package/vendors/antigravity/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/antigravity/{commands/wtfp-polish-prose.md → skills/wtfp-polish-prose/SKILL.md} +9 -4
- package/vendors/antigravity/{commands/wtfp-progress.md → skills/wtfp-progress/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-quick.md → skills/wtfp-quick/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-remove-section.md → skills/wtfp-remove-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-report-bug.md → skills/wtfp-report-bug/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-request-feature.md → skills/wtfp-request-feature/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-research-gap.md → skills/wtfp-research-gap/SKILL.md} +2 -1
- package/vendors/antigravity/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/antigravity/{commands/wtfp-resume-writing.md → skills/wtfp-resume-writing/SKILL.md} +2 -1
- package/vendors/antigravity/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/antigravity/{commands/wtfp-review-section.md → skills/wtfp-review-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-settings.md → skills/wtfp-settings/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-submit-milestone.md → skills/wtfp-submit-milestone/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-update.md → skills/wtfp-update/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-verify-work.md → skills/wtfp-verify-work/SKILL.md} +5 -4
- package/vendors/antigravity/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/antigravity/workflows/checkpoint.md +2 -2
- package/vendors/antigravity/workflows/execute-outline.md +2 -2
- package/vendors/antigravity/workflows/export-latex.md +4 -4
- package/vendors/antigravity/workflows/plan-revision.md +4 -3
- package/vendors/antigravity/workflows/plan-section.md +2 -2
- package/vendors/antigravity/workflows/polish-prose.md +3 -3
- package/vendors/antigravity/workflows/research-gap.md +2 -2
- package/vendors/antigravity/workflows/verify-work.md +3 -3
- package/vendors/antigravity/workflows/write-section.md +2 -2
- package/vendors/claude/.claude-plugin/marketplace.json +2 -2
- package/vendors/claude/.claude-plugin/plugin.json +1 -1
- package/vendors/claude/.wtfp-generated.json +84 -76
- package/vendors/claude/actions/checkpoint.json +10 -1
- package/vendors/claude/actions/execute-outline.json +10 -2
- package/vendors/claude/actions/export-latex.json +15 -2
- package/vendors/claude/actions/plan-revision.json +17 -4
- package/vendors/claude/actions/polish-prose.json +13 -3
- package/vendors/claude/actions/research-gap.json +16 -3
- package/vendors/claude/actions/verify-work.json +7 -2
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-argument-verifier.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-coherence-checker.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-plan-checker.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-reviewer.md +3 -3
- package/vendors/claude/ai.iowarp.clio/fleets/wtfp-draft-review.md +1 -1
- package/vendors/claude/ai.iowarp.clio/fleets/wtfp-plan-section.md +1 -1
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/add-todo.md +8 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +22 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +10 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-refs.md +22 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-todos.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/checkpoint.md +11 -2
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-outline.md +21 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-poster.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-slides.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/discuss-section.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/execute-outline.md +24 -3
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/export-latex.md +14 -4
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/help.md +1 -1
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/insert-section.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +6 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/map-project.md +8 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/new-paper.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/pause-writing.md +8 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-revision.md +17 -3
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-section.md +24 -3
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/polish-prose.md +28 -3
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/progress.md +7 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/quick.md +21 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/research-gap.md +25 -2
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/resume-writing.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/review-section.md +19 -1
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/settings.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +9 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/verify-work.md +12 -3
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/write-section.md +24 -3
- package/vendors/claude/commands/checkpoint.md +2 -2
- package/vendors/claude/commands/execute-outline.md +2 -2
- package/vendors/claude/commands/export-latex.md +4 -4
- package/vendors/claude/commands/plan-revision.md +8 -3
- package/vendors/claude/commands/plan-section.md +2 -2
- package/vendors/claude/commands/polish-prose.md +7 -3
- package/vendors/claude/commands/research-gap.md +2 -2
- package/vendors/claude/commands/verify-work.md +3 -3
- package/vendors/claude/commands/write-section.md +2 -2
- package/vendors/claude/output-styles/wtfp-academic-writing.md +5 -5
- package/vendors/claude/plugin.json +1 -1
- package/vendors/claude/project/README.md +37 -0
- package/vendors/claude/project/schemas/interaction.schema.json +100 -0
- package/vendors/claude/project/templates/interaction.json +16 -0
- package/vendors/claude/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/claude/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/claude/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/claude/workflows/checkpoint.md +2 -2
- package/vendors/claude/workflows/execute-outline.md +2 -2
- package/vendors/claude/workflows/export-latex.md +4 -4
- package/vendors/claude/workflows/plan-revision.md +4 -3
- package/vendors/claude/workflows/plan-section.md +2 -2
- package/vendors/claude/workflows/polish-prose.md +3 -3
- package/vendors/claude/workflows/research-gap.md +2 -2
- package/vendors/claude/workflows/verify-work.md +3 -3
- package/vendors/claude/workflows/write-section.md +2 -2
- package/vendors/clio-extension/.wtfp-generated.json +240 -0
- package/vendors/clio-extension/actions/add-todo.json +52 -0
- package/vendors/clio-extension/actions/analyze-bib.json +97 -0
- package/vendors/clio-extension/actions/audit-milestone.json +63 -0
- package/vendors/clio-extension/actions/check-refs.json +80 -0
- package/vendors/clio-extension/actions/check-todos.json +52 -0
- package/vendors/clio-extension/actions/checkpoint.json +85 -0
- package/vendors/clio-extension/actions/contribute.json +57 -0
- package/vendors/clio-extension/actions/create-outline.json +84 -0
- package/vendors/clio-extension/actions/create-poster.json +54 -0
- package/vendors/clio-extension/actions/create-slides.json +54 -0
- package/vendors/clio-extension/actions/discuss-section.json +76 -0
- package/vendors/clio-extension/actions/execute-outline.json +124 -0
- package/vendors/clio-extension/actions/export-latex.json +78 -0
- package/vendors/clio-extension/actions/help.json +30 -0
- package/vendors/clio-extension/actions/insert-section.json +61 -0
- package/vendors/clio-extension/actions/list-assumptions.json +35 -0
- package/vendors/clio-extension/actions/map-project.json +71 -0
- package/vendors/clio-extension/actions/new-paper.json +70 -0
- package/vendors/clio-extension/actions/pause-writing.json +71 -0
- package/vendors/clio-extension/actions/plan-milestone-gaps.json +57 -0
- package/vendors/clio-extension/actions/plan-revision.json +71 -0
- package/vendors/clio-extension/actions/plan-section.json +100 -0
- package/vendors/clio-extension/actions/polish-prose.json +79 -0
- package/vendors/clio-extension/actions/progress.json +51 -0
- package/vendors/clio-extension/actions/quick.json +70 -0
- package/vendors/clio-extension/actions/remove-section.json +63 -0
- package/vendors/clio-extension/actions/report-bug.json +47 -0
- package/vendors/clio-extension/actions/request-feature.json +47 -0
- package/vendors/clio-extension/actions/research-gap.json +115 -0
- package/vendors/clio-extension/actions/resume-writing.json +65 -0
- package/vendors/clio-extension/actions/review-section.json +83 -0
- package/vendors/clio-extension/actions/settings.json +47 -0
- package/vendors/clio-extension/actions/submit-milestone.json +77 -0
- package/vendors/clio-extension/actions/update.json +42 -0
- package/vendors/clio-extension/actions/verify-work.json +68 -0
- package/vendors/clio-extension/actions/write-section.json +115 -0
- package/vendors/clio-extension/clio-coder-extension.yaml +76 -0
- package/vendors/clio-extension/compatibility/action-availability.json +295 -0
- package/vendors/clio-extension/project/schemas/checkpoint.schema.json +102 -0
- package/vendors/clio-extension/project/schemas/common.schema.json +33 -0
- package/vendors/clio-extension/project/schemas/config.schema.json +69 -0
- package/vendors/clio-extension/project/schemas/decisions.schema.json +31 -0
- package/vendors/clio-extension/project/schemas/evidence.schema.json +48 -0
- package/vendors/clio-extension/project/schemas/interaction.schema.json +100 -0
- package/vendors/clio-extension/project/schemas/manifest.schema.json +102 -0
- package/vendors/clio-extension/project/schemas/outline.schema.json +67 -0
- package/vendors/clio-extension/project/schemas/section.schema.json +95 -0
- package/vendors/clio-extension/project/schemas/source.schema.json +73 -0
- package/vendors/clio-extension/project/schemas/state.schema.json +58 -0
- package/vendors/clio-extension/project/schemas/validation.schema.json +74 -0
- package/vendors/clio-extension/runtime/claim-coverage.cjs +332 -0
- package/vendors/clio-extension/runtime/desk-trust.cjs +112 -0
- package/vendors/clio-extension/runtime/extension.test.ts +1567 -0
- package/vendors/clio-extension/runtime/extension.ts +3074 -0
- package/vendors/clio-extension/runtime/json-schema.cjs +304 -0
- package/vendors/clio-extension/runtime/package.json +3 -0
- package/vendors/clio-extension/runtime/write-guard.json +566 -0
- package/vendors/clio-extension/skins/wtfp.json +20 -0
- package/vendors/codex/plugins/wtfp/.codex-plugin/plugin.json +1 -1
- package/vendors/codex/plugins/wtfp/.wtfp-generated.json +36 -28
- package/vendors/codex/plugins/wtfp/actions/checkpoint.json +10 -1
- package/vendors/codex/plugins/wtfp/actions/execute-outline.json +10 -2
- package/vendors/codex/plugins/wtfp/actions/export-latex.json +15 -2
- package/vendors/codex/plugins/wtfp/actions/plan-revision.json +17 -4
- package/vendors/codex/plugins/wtfp/actions/polish-prose.json +13 -3
- package/vendors/codex/plugins/wtfp/actions/research-gap.json +16 -3
- package/vendors/codex/plugins/wtfp/actions/verify-work.json +7 -2
- package/vendors/codex/plugins/wtfp/plugin.json +1 -1
- package/vendors/codex/plugins/wtfp/project/README.md +37 -0
- package/vendors/codex/plugins/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/codex/plugins/wtfp/project/templates/interaction.json +16 -0
- package/vendors/codex/plugins/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/codex/plugins/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/codex/plugins/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/codex/plugins/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/export-latex.md +4 -4
- package/vendors/codex/plugins/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/codex/plugins/wtfp/workflows/plan-section.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/codex/plugins/wtfp/workflows/research-gap.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/verify-work.md +3 -3
- package/vendors/codex/plugins/wtfp/workflows/write-section.md +2 -2
- package/vendors/copilot/.wtfp-generated.json +43 -35
- package/vendors/copilot/marketplace.json +2 -2
- package/vendors/copilot/plugins/wtfp/.claude-plugin/plugin.json +1 -1
- package/vendors/copilot/plugins/wtfp/.wtfp-generated.json +42 -34
- package/vendors/copilot/plugins/wtfp/actions/checkpoint.json +10 -1
- package/vendors/copilot/plugins/wtfp/actions/execute-outline.json +10 -2
- package/vendors/copilot/plugins/wtfp/actions/export-latex.json +15 -2
- package/vendors/copilot/plugins/wtfp/actions/plan-revision.json +17 -4
- package/vendors/copilot/plugins/wtfp/actions/polish-prose.json +13 -3
- package/vendors/copilot/plugins/wtfp/actions/research-gap.json +16 -3
- package/vendors/copilot/plugins/wtfp/actions/verify-work.json +7 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-checkpoint.md +2 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-execute-outline.md +2 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-revision.md +8 -3
- package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-section.md +2 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-polish-prose.md +7 -3
- package/vendors/copilot/plugins/wtfp/commands/wtfp-verify-work.md +3 -3
- package/vendors/copilot/plugins/wtfp/commands/wtfp-write-section.md +2 -2
- package/vendors/copilot/plugins/wtfp/project/README.md +37 -0
- package/vendors/copilot/plugins/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/copilot/plugins/wtfp/project/templates/interaction.json +16 -0
- package/vendors/copilot/plugins/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/plugins/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/plugins/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/plugins/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/export-latex.md +4 -4
- package/vendors/copilot/plugins/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/copilot/plugins/wtfp/workflows/plan-section.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/copilot/plugins/wtfp/workflows/research-gap.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/verify-work.md +3 -3
- package/vendors/copilot/plugins/wtfp/workflows/write-section.md +2 -2
- package/vendors/copilot/project/.github/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/project/.github/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/project/.github/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/project/.github/wtfp/actions/checkpoint.json +10 -1
- package/vendors/copilot/project/.github/wtfp/actions/execute-outline.json +10 -2
- package/vendors/copilot/project/.github/wtfp/actions/export-latex.json +15 -2
- package/vendors/copilot/project/.github/wtfp/actions/plan-revision.json +17 -4
- package/vendors/copilot/project/.github/wtfp/actions/polish-prose.json +13 -3
- package/vendors/copilot/project/.github/wtfp/actions/research-gap.json +16 -3
- package/vendors/copilot/project/.github/wtfp/actions/verify-work.json +7 -2
- package/vendors/copilot/project/.github/wtfp/project/README.md +37 -0
- package/vendors/copilot/project/.github/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/copilot/project/.github/wtfp/project/templates/interaction.json +16 -0
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/project/.github/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/export-latex.md +4 -4
- package/vendors/copilot/project/.github/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/copilot/project/.github/wtfp/workflows/plan-section.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/copilot/project/.github/wtfp/workflows/research-gap.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/verify-work.md +3 -3
- package/vendors/copilot/project/.github/wtfp/workflows/write-section.md +2 -2
- package/vendors/gemini/.wtfp-generated.json +61 -53
- package/vendors/gemini/actions/checkpoint.json +10 -1
- package/vendors/gemini/actions/execute-outline.json +10 -2
- package/vendors/gemini/actions/export-latex.json +15 -2
- package/vendors/gemini/actions/plan-revision.json +17 -4
- package/vendors/gemini/actions/polish-prose.json +13 -3
- package/vendors/gemini/actions/research-gap.json +16 -3
- package/vendors/gemini/actions/verify-work.json +7 -2
- package/vendors/gemini/commands/wtfp/add-todo.toml +37 -0
- package/vendors/gemini/commands/wtfp/check-todos.toml +37 -0
- package/vendors/gemini/commands/wtfp/checkpoint.toml +49 -3
- package/vendors/gemini/commands/wtfp/create-outline.toml +37 -0
- package/vendors/gemini/commands/wtfp/create-poster.toml +40 -3
- package/vendors/gemini/commands/wtfp/create-slides.toml +40 -3
- package/vendors/gemini/commands/wtfp/discuss-section.toml +42 -4
- package/vendors/gemini/commands/wtfp/execute-outline.toml +51 -6
- package/vendors/gemini/commands/wtfp/help.toml +37 -0
- package/vendors/gemini/commands/wtfp/insert-section.toml +42 -4
- package/vendors/gemini/commands/wtfp/list-assumptions.toml +42 -4
- package/vendors/gemini/commands/wtfp/map-project.toml +37 -0
- package/vendors/gemini/commands/wtfp/new-paper.toml +37 -0
- package/vendors/gemini/commands/wtfp/pause-writing.toml +37 -0
- package/vendors/gemini/commands/wtfp/plan-milestone-gaps.toml +38 -1
- package/vendors/gemini/commands/wtfp/plan-revision.toml +310 -11
- package/vendors/gemini/commands/wtfp/plan-section.toml +44 -6
- package/vendors/gemini/commands/wtfp/polish-prose.toml +281 -7
- package/vendors/gemini/commands/wtfp/progress.toml +37 -0
- package/vendors/gemini/commands/wtfp/quick.toml +39 -2
- package/vendors/gemini/commands/wtfp/resume-writing.toml +37 -0
- package/vendors/gemini/commands/wtfp/review-section.toml +38 -1
- package/vendors/gemini/commands/wtfp/settings.toml +37 -0
- package/vendors/gemini/commands/wtfp/submit-milestone.toml +40 -3
- package/vendors/gemini/commands/wtfp/verify-work.toml +48 -6
- package/vendors/gemini/commands/wtfp/write-section.toml +41 -4
- package/vendors/gemini/gemini-extension.json +1 -1
- package/vendors/gemini/project/README.md +37 -0
- package/vendors/gemini/project/schemas/interaction.schema.json +100 -0
- package/vendors/gemini/project/templates/interaction.json +16 -0
- package/vendors/gemini/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/gemini/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/gemini/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/gemini/workflows/checkpoint.md +2 -2
- package/vendors/gemini/workflows/execute-outline.md +2 -2
- package/vendors/gemini/workflows/export-latex.md +4 -4
- package/vendors/gemini/workflows/plan-revision.md +4 -3
- package/vendors/gemini/workflows/plan-section.md +2 -2
- package/vendors/gemini/workflows/polish-prose.md +3 -3
- package/vendors/gemini/workflows/research-gap.md +2 -2
- package/vendors/gemini/workflows/verify-work.md +3 -3
- package/vendors/gemini/workflows/write-section.md +2 -2
- package/vendors/opencode/.wtfp-generated.json +60 -52
- package/vendors/opencode/actions/checkpoint.json +10 -1
- package/vendors/opencode/actions/execute-outline.json +10 -2
- package/vendors/opencode/actions/export-latex.json +15 -2
- package/vendors/opencode/actions/plan-revision.json +17 -4
- package/vendors/opencode/actions/polish-prose.json +13 -3
- package/vendors/opencode/actions/research-gap.json +16 -3
- package/vendors/opencode/actions/verify-work.json +7 -2
- package/vendors/opencode/commands/wtfp/add-todo.md +37 -0
- package/vendors/opencode/commands/wtfp/check-todos.md +37 -0
- package/vendors/opencode/commands/wtfp/checkpoint.md +49 -3
- package/vendors/opencode/commands/wtfp/create-outline.md +37 -0
- package/vendors/opencode/commands/wtfp/create-poster.md +40 -3
- package/vendors/opencode/commands/wtfp/create-slides.md +40 -3
- package/vendors/opencode/commands/wtfp/discuss-section.md +42 -4
- package/vendors/opencode/commands/wtfp/execute-outline.md +51 -6
- package/vendors/opencode/commands/wtfp/help.md +37 -0
- package/vendors/opencode/commands/wtfp/insert-section.md +42 -4
- package/vendors/opencode/commands/wtfp/list-assumptions.md +42 -4
- package/vendors/opencode/commands/wtfp/map-project.md +37 -0
- package/vendors/opencode/commands/wtfp/new-paper.md +37 -0
- package/vendors/opencode/commands/wtfp/pause-writing.md +37 -0
- package/vendors/opencode/commands/wtfp/plan-milestone-gaps.md +38 -1
- package/vendors/opencode/commands/wtfp/plan-revision.md +310 -11
- package/vendors/opencode/commands/wtfp/plan-section.md +44 -6
- package/vendors/opencode/commands/wtfp/polish-prose.md +281 -7
- package/vendors/opencode/commands/wtfp/progress.md +37 -0
- package/vendors/opencode/commands/wtfp/quick.md +39 -2
- package/vendors/opencode/commands/wtfp/resume-writing.md +37 -0
- package/vendors/opencode/commands/wtfp/review-section.md +38 -1
- package/vendors/opencode/commands/wtfp/settings.md +37 -0
- package/vendors/opencode/commands/wtfp/submit-milestone.md +40 -3
- package/vendors/opencode/commands/wtfp/verify-work.md +48 -6
- package/vendors/opencode/commands/wtfp/write-section.md +41 -4
- package/vendors/opencode/project/README.md +37 -0
- package/vendors/opencode/project/schemas/interaction.schema.json +100 -0
- package/vendors/opencode/project/templates/interaction.json +16 -0
- package/vendors/opencode/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/opencode/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/opencode/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/opencode/workflows/checkpoint.md +2 -2
- package/vendors/opencode/workflows/execute-outline.md +2 -2
- package/vendors/opencode/workflows/export-latex.md +4 -4
- package/vendors/opencode/workflows/plan-revision.md +4 -3
- package/vendors/opencode/workflows/plan-section.md +2 -2
- package/vendors/opencode/workflows/polish-prose.md +3 -3
- package/vendors/opencode/workflows/research-gap.md +2 -2
- package/vendors/opencode/workflows/verify-work.md +3 -3
- package/vendors/opencode/workflows/write-section.md +2 -2
- package/vendors/plugin/.wtfp-generated.json +75 -67
- package/vendors/plugin/actions/checkpoint.json +10 -1
- package/vendors/plugin/actions/execute-outline.json +10 -2
- package/vendors/plugin/actions/export-latex.json +15 -2
- package/vendors/plugin/actions/plan-revision.json +17 -4
- package/vendors/plugin/actions/polish-prose.json +13 -3
- package/vendors/plugin/actions/research-gap.json +16 -3
- package/vendors/plugin/actions/verify-work.json +7 -2
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-argument-verifier.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-coherence-checker.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-plan-checker.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-reviewer.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/{fleets → playbooks}/wtfp-draft-review.md +1 -1
- package/vendors/plugin/ai.iowarp.clio/{fleets → playbooks}/wtfp-plan-section.md +1 -1
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/add-todo.md +19 -12
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +34 -19
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +22 -25
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-refs.md +34 -15
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-todos.md +23 -13
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/checkpoint.md +23 -29
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-outline.md +33 -25
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-poster.md +9 -0
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-slides.md +9 -0
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/discuss-section.md +21 -17
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/execute-outline.md +38 -30
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/export-latex.md +26 -21
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/help.md +2 -2
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/insert-section.md +21 -13
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +6 -0
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/map-project.md +19 -14
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/new-paper.md +21 -17
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/pause-writing.md +19 -18
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +21 -15
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-revision.md +25 -18
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-section.md +36 -30
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/polish-prose.md +38 -18
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/progress.md +7 -0
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/quick.md +35 -15
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/research-gap.md +37 -23
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/resume-writing.md +21 -23
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/review-section.md +31 -20
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/settings.md +21 -9
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +21 -25
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/verify-work.md +24 -18
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/write-section.md +38 -31
- package/vendors/plugin/compatibility/action-availability.json +18 -3
- package/vendors/plugin/plugin.json +7 -7
- package/vendors/plugin/project/README.md +37 -0
- package/vendors/plugin/project/schemas/interaction.schema.json +100 -0
- package/vendors/plugin/project/templates/interaction.json +16 -0
- package/vendors/plugin/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/plugin/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/plugin/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/plugin/workflows/checkpoint.md +2 -2
- package/vendors/plugin/workflows/execute-outline.md +2 -2
- package/vendors/plugin/workflows/export-latex.md +4 -4
- package/vendors/plugin/workflows/plan-revision.md +4 -3
- package/vendors/plugin/workflows/plan-section.md +2 -2
- package/vendors/plugin/workflows/polish-prose.md +3 -3
- package/vendors/plugin/workflows/research-gap.md +2 -2
- package/vendors/plugin/workflows/verify-work.md +3 -3
- package/vendors/plugin/workflows/write-section.md +2 -2
- package/vendors/antigravity/commands/wtfp-plan-section.md +0 -78
- package/vendors/antigravity/commands/wtfp-write-section.md +0 -77
|
@@ -0,0 +1,1567 @@
|
|
|
1
|
+
// Generated by WTF-P adapter compiler v5 from clio/runtime/extension.test.ts; do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Package tests for the WTF-P desk, run by `clio-coder extensions test
|
|
4
|
+
* vendors/clio-extension`. Each case builds a small valid project in a
|
|
5
|
+
* task-owned TMPDIR and drives the desk the way Clio does: tool calls,
|
|
6
|
+
* interviews, hooks and observations. The kit serves no plugin unless a case
|
|
7
|
+
* passes one. Answers here are simulated interview events, not a human's:
|
|
8
|
+
* they test the desk's bookkeeping, never an author's judgment.
|
|
9
|
+
*/
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { createHash, createHmac } from "node:crypto";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
14
|
+
import os, { homedir } from "node:os";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { test } from "node:test";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { createExtensionTestHost } from "@iowarp/clio-coder/extensions/testing";
|
|
19
|
+
|
|
20
|
+
const ROOT = fileURLToPath(new URL("../", import.meta.url));
|
|
21
|
+
const PROJECT = "desk-test";
|
|
22
|
+
const AT = "2026-10-01T12:00:00Z";
|
|
23
|
+
const GATE = "checkpoint-framing";
|
|
24
|
+
const PLAN_GATE = "approve-initial";
|
|
25
|
+
const PLAN_URI = "project://sections/introduction/plans/initial";
|
|
26
|
+
const PLAN_FILE = ".planning/sections/introduction/plans/initial.md";
|
|
27
|
+
|
|
28
|
+
type Json = Record<string, unknown>;
|
|
29
|
+
type Host = Awaited<ReturnType<typeof createExtensionTestHost>>;
|
|
30
|
+
|
|
31
|
+
function put(workspace: string, relative: string, value: unknown): void {
|
|
32
|
+
mkdirSync(path.dirname(path.join(workspace, relative)), { recursive: true });
|
|
33
|
+
writeFileSync(path.join(workspace, relative), typeof value === "string" ? value : `${JSON.stringify(value, null, 2)}\n`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function project(): string {
|
|
37
|
+
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
38
|
+
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-test-"));
|
|
39
|
+
put(workspace, ".planning/project.json", {
|
|
40
|
+
schema: "wtfp.project.manifest/v1",
|
|
41
|
+
protocol_version: 1,
|
|
42
|
+
id: PROJECT,
|
|
43
|
+
title: "Logging on Shared Memory",
|
|
44
|
+
document_type: "research-article",
|
|
45
|
+
core_argument: "Shared memory removes the flush bottleneck without weakening durability.",
|
|
46
|
+
target: { audience: "Storage researchers", word_limit: 100 },
|
|
47
|
+
requirements: { must_have: [], should_have: [], out_of_scope: [] },
|
|
48
|
+
created_at: AT,
|
|
49
|
+
updated_at: AT,
|
|
50
|
+
artifacts: {
|
|
51
|
+
manifest: "project://manifest",
|
|
52
|
+
config: "project://config",
|
|
53
|
+
state: "project://state",
|
|
54
|
+
decisions: "project://decisions",
|
|
55
|
+
outline: "project://structure/outline",
|
|
56
|
+
materials: [],
|
|
57
|
+
manuscripts: ["project://paper/introduction"],
|
|
58
|
+
deliverables: [],
|
|
59
|
+
archives: [],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
put(workspace, ".planning/config.json", {
|
|
63
|
+
schema: "wtfp.project.config/v1",
|
|
64
|
+
project_id: PROJECT,
|
|
65
|
+
interaction_mode: "standard",
|
|
66
|
+
depth: "standard",
|
|
67
|
+
output_format: "markdown",
|
|
68
|
+
language: "en-US",
|
|
69
|
+
citation_style: "author-date",
|
|
70
|
+
gates: { confirm_outline: true, confirm_plan: true, confirm_write: true, confirm_review: true, confirm_delivery: true },
|
|
71
|
+
workflow: { research: true, plan_validation: true, argument_validation: true, coherence_validation: true },
|
|
72
|
+
safety: { destructive_requires_authorization: true, external_publish_requires_authorization: true, backup_before_major_edits: true },
|
|
73
|
+
parallelism: { enabled: false, max_workers: 1 },
|
|
74
|
+
});
|
|
75
|
+
put(workspace, ".planning/state.json", {
|
|
76
|
+
schema: "wtfp.project.state/v1",
|
|
77
|
+
project_id: PROJECT,
|
|
78
|
+
revision: 3,
|
|
79
|
+
phase: "writing",
|
|
80
|
+
status: "active",
|
|
81
|
+
current_section_uri: "project://sections/introduction",
|
|
82
|
+
progress: { sections_total: 1, sections_complete: 0, word_target: 100, word_count: 0 },
|
|
83
|
+
active_checkpoint_uris: [`project://checkpoints/${GATE}`, `project://checkpoints/${PLAN_GATE}`],
|
|
84
|
+
last_transition: { from: "planning", to: "writing", reason: "The plan is linked.", at: AT },
|
|
85
|
+
updated_at: AT,
|
|
86
|
+
});
|
|
87
|
+
put(workspace, ".planning/structure/outline.json", {
|
|
88
|
+
schema: "wtfp.project.outline/v1",
|
|
89
|
+
project_id: PROJECT,
|
|
90
|
+
revision: 1,
|
|
91
|
+
thesis: "Shared memory removes the flush bottleneck without weakening durability.",
|
|
92
|
+
target_words: 100,
|
|
93
|
+
sections: [
|
|
94
|
+
{
|
|
95
|
+
id: "introduction",
|
|
96
|
+
title: "Introduction",
|
|
97
|
+
goal: "State the flush bottleneck and the contribution.",
|
|
98
|
+
argument_role: "setup",
|
|
99
|
+
word_target: 100,
|
|
100
|
+
wave: 1,
|
|
101
|
+
depends_on: [],
|
|
102
|
+
claim_ids: [],
|
|
103
|
+
research: { required: false, topics: [] },
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
updated_at: AT,
|
|
107
|
+
});
|
|
108
|
+
put(workspace, ".planning/sections/introduction/section.json", {
|
|
109
|
+
schema: "wtfp.project.section/v1",
|
|
110
|
+
id: "introduction",
|
|
111
|
+
project_id: PROJECT,
|
|
112
|
+
outline_uri: "project://structure/outline",
|
|
113
|
+
title: "Introduction",
|
|
114
|
+
goal: "State the flush bottleneck and the contribution.",
|
|
115
|
+
status: "planned",
|
|
116
|
+
word_target: 100,
|
|
117
|
+
word_count: 0,
|
|
118
|
+
wave: 1,
|
|
119
|
+
depends_on: [],
|
|
120
|
+
claims: [],
|
|
121
|
+
artifacts: { plans: [PLAN_URI], reviews: [], manuscript: "project://paper/introduction" },
|
|
122
|
+
checkpoint_uris: [`project://checkpoints/${GATE}`, `project://checkpoints/${PLAN_GATE}`],
|
|
123
|
+
validation_uris: [],
|
|
124
|
+
updated_at: AT,
|
|
125
|
+
});
|
|
126
|
+
put(workspace, PLAN_FILE, "# Plan\n\n1. State the bottleneck.\n2. State the contribution.\n");
|
|
127
|
+
put(workspace, `.planning/checkpoints/${GATE}.json`, {
|
|
128
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
129
|
+
id: GATE,
|
|
130
|
+
project_id: PROJECT,
|
|
131
|
+
kind: "decision",
|
|
132
|
+
status: "pending",
|
|
133
|
+
blocking: true,
|
|
134
|
+
scope_uri: "project://sections/introduction",
|
|
135
|
+
request: "Lead with the protocol or with the workflow?",
|
|
136
|
+
options: [
|
|
137
|
+
{ id: "protocol-first", label: "Protocol first", implication: "Lead with interoperability." },
|
|
138
|
+
{ id: "workflow-first", label: "Workflow first", implication: "Lead with the end-to-end process." },
|
|
139
|
+
],
|
|
140
|
+
resume_action: "write-section",
|
|
141
|
+
created_at: AT,
|
|
142
|
+
});
|
|
143
|
+
put(workspace, `.planning/checkpoints/${PLAN_GATE}.json`, {
|
|
144
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
145
|
+
id: PLAN_GATE,
|
|
146
|
+
project_id: PROJECT,
|
|
147
|
+
kind: "decision",
|
|
148
|
+
status: "pending",
|
|
149
|
+
blocking: true,
|
|
150
|
+
scope_uri: PLAN_URI,
|
|
151
|
+
request: "Approve the introduction plan?",
|
|
152
|
+
options: [
|
|
153
|
+
{ id: "approve", label: "Approve", implication: "The writer drafts from exactly this plan." },
|
|
154
|
+
{ id: "revise", label: "Revise", implication: "The plan is rewritten before drafting." },
|
|
155
|
+
],
|
|
156
|
+
resume_action: "write-section",
|
|
157
|
+
created_at: AT,
|
|
158
|
+
});
|
|
159
|
+
// Eleven body words: front matter, the heading, the citation key and the code block do not count.
|
|
160
|
+
put(
|
|
161
|
+
workspace,
|
|
162
|
+
"paper/introduction.md",
|
|
163
|
+
"---\ntitle: Introduction\n---\n# Introduction\n\nShared memory changes the cost of logging [@smith2024]. It's a well-known trade-off.\n\n```c\nint flush = 1;\n```\n",
|
|
164
|
+
);
|
|
165
|
+
return workspace;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const read = (workspace: string, relative: string): Json => JSON.parse(readFileSync(path.join(workspace, relative), "utf8")) as Json;
|
|
169
|
+
const sha = (workspace: string, relative: string): string => createHash("sha256").update(readFileSync(path.join(workspace, relative))).digest("hex");
|
|
170
|
+
const interactions = (workspace: string): Json[] => {
|
|
171
|
+
const directory = path.join(workspace, ".planning/interactions");
|
|
172
|
+
return existsSync(directory) ? readdirSync(directory).sort().map((name) => read(workspace, `.planning/interactions/${name}`)) : [];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
function tree(workspace: string, relative = "."): Record<string, string> {
|
|
176
|
+
const out: Record<string, string> = {};
|
|
177
|
+
for (const entry of readdirSync(path.join(workspace, relative), { withFileTypes: true })) {
|
|
178
|
+
const child = path.join(relative, entry.name);
|
|
179
|
+
if (entry.isDirectory()) Object.assign(out, tree(workspace, child));
|
|
180
|
+
else out[child] = sha(workspace, child);
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const canonical = (value: unknown): string =>
|
|
186
|
+
Array.isArray(value)
|
|
187
|
+
? `[${value.map(canonical).join(",")}]`
|
|
188
|
+
: value !== null && typeof value === "object"
|
|
189
|
+
? `{${Object.keys(value).sort().map((name) => `${JSON.stringify(name)}:${canonical((value as Json)[name])}`).join(",")}}`
|
|
190
|
+
: JSON.stringify(value);
|
|
191
|
+
|
|
192
|
+
/** An interaction sealed the way the desk seals one, for tests that need a valid seal on a changed record. */
|
|
193
|
+
const resealed = (body: Json, key: Buffer): Json => ({
|
|
194
|
+
...body,
|
|
195
|
+
seal: { method: "hmac-sha256", key_id: createHash("sha256").update(key).digest("hex").slice(0, 16), mac: createHmac("sha256", key).update(canonical(body)).digest("hex") },
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const SERVED = { id: "wtfp", prompts: ["wtfp:check-todos", "wtfp:plan-section", "wtfp:progress", "wtfp:write-section", "wtfp:research-gap"] };
|
|
199
|
+
|
|
200
|
+
async function withDesk(run: (host: Host, workspace: string) => Promise<void>, plugin: typeof SERVED | null = null): Promise<void> {
|
|
201
|
+
const workspace = project();
|
|
202
|
+
const host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin }), workspace);
|
|
203
|
+
try {
|
|
204
|
+
await run(host, workspace);
|
|
205
|
+
} finally {
|
|
206
|
+
await host.dispose();
|
|
207
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function ask(host: Host, checkpoint: string): Promise<string> {
|
|
212
|
+
const asked = await host.tool("gate", { checkpoint });
|
|
213
|
+
assert.equal(asked.interview?.id, "gate-one", asked.text);
|
|
214
|
+
return asked.interview?.step.key as string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function answer(host: Host, checkpoint: string, choice: string): Promise<string> {
|
|
218
|
+
const key = await ask(host, checkpoint);
|
|
219
|
+
const done = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice } });
|
|
220
|
+
return "done" in done ? done.text : `step ${done.step.key}`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const blocked = (result: { effects?: Array<{ kind: string }> }): string | null => {
|
|
224
|
+
const effect = result.effects?.find((entry) => entry.kind === "block_tool") as { reason?: string } | undefined;
|
|
225
|
+
return effect ? (effect.reason ?? "") : null;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const write = (host: Host, target: string) => host.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: target } });
|
|
229
|
+
|
|
230
|
+
const rewriteOf = (result: { effects?: Array<{ kind: string }> }): Json | null =>
|
|
231
|
+
(result.effects?.find((effect) => effect.kind === "rewrite_tool_input") as { args?: Json } | undefined)?.args ?? null;
|
|
232
|
+
|
|
233
|
+
// --- the host's facts ------------------------------------------------------------
|
|
234
|
+
// Clio 0.6.3 sends a before_tool hook where a path-taking tool lands and, for
|
|
235
|
+
// dispatch, the plan admission parsed, and judges a rewritten call again. The
|
|
236
|
+
// desk judges only those, so the test host models them as Clio resolves them,
|
|
237
|
+
// with the test process's own access.
|
|
238
|
+
|
|
239
|
+
/** The WTF-P recipes Clio runs read-only: the reviewers, whose recipes are Clio's read-only class. */
|
|
240
|
+
const READ_ONLY_RECIPES = new Set(["wtfp-argument-verifier", "wtfp-coherence-checker", "wtfp-plan-checker", "wtfp-section-reviewer"]);
|
|
241
|
+
|
|
242
|
+
/** A path with its existing part resolved through links; the rest is kept as named. */
|
|
243
|
+
function physical(file: string): string {
|
|
244
|
+
let head = file;
|
|
245
|
+
const rest: string[] = [];
|
|
246
|
+
while (!existsSync(head) && path.dirname(head) !== head) {
|
|
247
|
+
rest.unshift(path.basename(head));
|
|
248
|
+
head = path.dirname(head);
|
|
249
|
+
}
|
|
250
|
+
return path.join(realpathSync(head), ...rest);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Where a write through `joined` lands, as Clio's canonicalizeRawPath walks it
|
|
255
|
+
* (src/core/path-canonical.ts): a link at any component, dangling or not, is
|
|
256
|
+
* read and the walk goes on from its target, a `..` after a link steps up from
|
|
257
|
+
* the link's target, and a missing component ends the walk. Null for a loop,
|
|
258
|
+
* more than 40 links, or a component that cannot be inspected.
|
|
259
|
+
*/
|
|
260
|
+
function clioWalk(joined: string): string | null {
|
|
261
|
+
const { root } = path.parse(joined);
|
|
262
|
+
const parts = joined.slice(root.length).split(path.sep).filter((part) => part !== "" && part !== ".");
|
|
263
|
+
const up = parts.indexOf("..");
|
|
264
|
+
const pending = up === -1 ? [] : parts.slice(up);
|
|
265
|
+
let cursor = path.resolve(path.join(root, ...(up === -1 ? parts : parts.slice(0, up))));
|
|
266
|
+
const real = (file: string): string | null => {
|
|
267
|
+
try {
|
|
268
|
+
return path.resolve(realpathSync(file));
|
|
269
|
+
} catch {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
let current = real(cursor);
|
|
274
|
+
while (current === null) {
|
|
275
|
+
const parent = path.dirname(cursor);
|
|
276
|
+
if (parent === cursor) return null;
|
|
277
|
+
pending.unshift(path.basename(cursor));
|
|
278
|
+
cursor = parent;
|
|
279
|
+
current = real(cursor);
|
|
280
|
+
}
|
|
281
|
+
let hops = 0;
|
|
282
|
+
while (pending.length > 0) {
|
|
283
|
+
const part = pending.shift() as string;
|
|
284
|
+
if (part === "..") {
|
|
285
|
+
current = path.dirname(current);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const next = path.join(current, part);
|
|
289
|
+
let target: string;
|
|
290
|
+
try {
|
|
291
|
+
target = readlinkSync(next);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
294
|
+
if (code === "EINVAL") {
|
|
295
|
+
current = next;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
299
|
+
if (!pending.includes("..")) return path.resolve(next, ...pending);
|
|
300
|
+
current = next;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
hops += 1;
|
|
306
|
+
if (hops > 40) return null;
|
|
307
|
+
if (path.isAbsolute(target)) current = path.parse(target).root;
|
|
308
|
+
pending.unshift(...target.split(path.sep).filter(Boolean));
|
|
309
|
+
}
|
|
310
|
+
return current;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Where Clio lands a tool's path: `@` dropped, Unicode spaces plain, `~` expanded, then Clio's physical walk from the workspace it runs in. */
|
|
314
|
+
function clioTarget(raw: string, workspace: string): Json {
|
|
315
|
+
let spelled = (raw.startsWith("@") ? raw.slice(1) : raw).replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/gu, " ");
|
|
316
|
+
if (spelled === "~") spelled = homedir();
|
|
317
|
+
else if (spelled.startsWith("~/")) spelled = homedir() + spelled.slice(1);
|
|
318
|
+
const real = realpathSync(workspace);
|
|
319
|
+
// Clio runs in the workspace, so its own /proc/self/cwd is the workspace.
|
|
320
|
+
if (spelled === "/proc/self/cwd" || spelled.startsWith("/proc/self/cwd/")) spelled = real + spelled.slice("/proc/self/cwd".length);
|
|
321
|
+
const landed = clioWalk(path.isAbsolute(spelled) ? spelled : `${real}${path.sep}${spelled}`);
|
|
322
|
+
const at = landed ?? (path.isAbsolute(spelled) ? spelled : `${real}${path.sep}${spelled}`);
|
|
323
|
+
const relative = path.relative(real, at);
|
|
324
|
+
const inside = landed !== null && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
325
|
+
return { arg: "path", path: at, resolved: landed !== null, workspacePath: inside ? relative.split(path.sep).join("/") || "." : null };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* A dispatch call as Clio's admission hands it to hooks (src/tools/dispatch-arguments.ts
|
|
330
|
+
* prepareDispatchArguments, src/tools/dispatch-admission.ts): `tasks` an array, a
|
|
331
|
+
* lone `task` moved into it, and either Clio's private resolved plan or the
|
|
332
|
+
* reason preparation failed. Clio refuses a `./` root and parallel writers
|
|
333
|
+
* without roots before any hook; these tests send no other failing shape.
|
|
334
|
+
*/
|
|
335
|
+
function clioPrepare(args: Json): Json {
|
|
336
|
+
const next: Json = { ...args };
|
|
337
|
+
if (typeof next.tasks === "string" && /^\s*[[{]/u.test(next.tasks)) {
|
|
338
|
+
try {
|
|
339
|
+
next.tasks = JSON.parse(next.tasks) as unknown;
|
|
340
|
+
} catch {
|
|
341
|
+
// Clio leaves the string and reports the shape itself.
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (next.tasks !== undefined && !Array.isArray(next.tasks)) next.tasks = [next.tasks];
|
|
345
|
+
if (next.tasks === undefined && typeof next.task === "string") {
|
|
346
|
+
const { task, ...rest } = next;
|
|
347
|
+
Object.assign(next, { ...rest, tasks: [{ task }] });
|
|
348
|
+
delete next.task;
|
|
349
|
+
}
|
|
350
|
+
if (args.list === true || args.apply_winner !== undefined || !Array.isArray(next.tasks)) return next;
|
|
351
|
+
const items = (next.tasks as unknown[]).map((task) => (typeof task === "string" ? { task } : (task as Json)));
|
|
352
|
+
const declared = items.map((item) => ((item.intent as Json | undefined)?.write_roots ?? (args.intent as Json | undefined)?.write_roots ?? []) as string[]);
|
|
353
|
+
const writers = items.filter((item, index) => !READ_ONLY_RECIPES.has(agentOf(item, args)) && declared[index] !== undefined);
|
|
354
|
+
const failure = declared.flat().some((root) => /^\.\/./u.test(root.trim()))
|
|
355
|
+
? "write_roots entries may not start with ./"
|
|
356
|
+
: writers.length > 1 && declared.some((roots, index) => !READ_ONLY_RECIPES.has(agentOf(items[index] as Json, args)) && roots.filter((root) => !/^\.\/?$/u.test(root.trim())).length === 0)
|
|
357
|
+
? "parallel writers need disjoint intent.write_roots"
|
|
358
|
+
: null;
|
|
359
|
+
return failure === null ? { ...next, __clio_resolved_dispatch_plan: { resolvedBy: "clio" } } : { ...next, __clio_dispatch_plan_preparation_error: failure };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function agentOf(item: Json, args: Json): string {
|
|
363
|
+
const named = typeof item.agent === "string" ? item.agent : typeof args.agent === "string" ? args.agent : "";
|
|
364
|
+
return named.trim() || "coder";
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The plan Clio's admission reports for prepared arguments: write roots trimmed, without `.`, deduplicated and sorted, with their physical boundaries. */
|
|
368
|
+
function clioPlan(prepared: Json, workspace: string): Json {
|
|
369
|
+
const real = realpathSync(workspace);
|
|
370
|
+
if (prepared.list === true) return { kind: "list" };
|
|
371
|
+
if (prepared.apply_winner !== undefined) return { kind: "apply-winner", branch: String((prepared.apply_winner as Json).branch ?? ""), cwd: real };
|
|
372
|
+
const items = ((prepared.tasks ?? []) as unknown[]).map((task) => (typeof task === "string" ? { task } : (task as Json)));
|
|
373
|
+
const shared = (prepared.intent as Json | undefined)?.write_roots;
|
|
374
|
+
return {
|
|
375
|
+
kind: "tasks",
|
|
376
|
+
mode: "single",
|
|
377
|
+
tasks: items.map((item) => {
|
|
378
|
+
const spelledCwd = typeof item.cwd === "string" ? item.cwd : typeof prepared.cwd === "string" ? prepared.cwd : ".";
|
|
379
|
+
const cwd = physical(path.resolve(real, spelledCwd.trim() || "."));
|
|
380
|
+
const agent = agentOf(item, prepared);
|
|
381
|
+
// Clio runs a read-only recipe's worker read-only, with no write roots (src/tools/dispatch.ts writerLanding).
|
|
382
|
+
const readOnly = READ_ONLY_RECIPES.has(agent);
|
|
383
|
+
const roots = readOnly ? [] : [...new Set((((item.intent as Json | undefined)?.write_roots ?? shared ?? []) as string[]).map((root) => root.trim()).filter((root) => !/^\.\/?$/u.test(root)))].sort();
|
|
384
|
+
return { role: "task", agent, cwd, writeRoots: roots, writeBoundaries: roots.map((root) => physical(path.resolve(cwd, root))), worktree: item.worktree === true, readOnly };
|
|
385
|
+
}),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** A before_tool event as Clio 0.6.3 sends it, unless the test sent its own facts. */
|
|
390
|
+
function withFacts(event: Json, workspace: string): Json {
|
|
391
|
+
if (event.point !== "before_tool" || "target" in event || "dispatch" in event) return event;
|
|
392
|
+
const args = (event.args ?? {}) as Json;
|
|
393
|
+
if (event.tool === "dispatch") {
|
|
394
|
+
const prepared = clioPrepare(args);
|
|
395
|
+
return typeof prepared.__clio_dispatch_plan_preparation_error === "string" ? { ...event, args: prepared } : { ...event, args: prepared, dispatch: clioPlan(prepared, workspace) };
|
|
396
|
+
}
|
|
397
|
+
const raw = args.path ?? args.file_path ?? args.filePath;
|
|
398
|
+
if (["write", "edit", "artifact"].includes(event.tool as string) && typeof raw === "string" && raw.trim().length > 0)
|
|
399
|
+
return { ...event, target: clioTarget(event.tool === "artifact" ? raw.trim() : raw, workspace) };
|
|
400
|
+
return event;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* The test host as Clio 0.6.3 runs the desk: each before_tool event carries
|
|
405
|
+
* Clio's facts; a dispatch Clio could not prepare is refused by Clio with its
|
|
406
|
+
* own reason when no hook refused it first; and a call the desk rewrites is
|
|
407
|
+
* admitted afresh, so a plan-scale one, which needs the operator's approval,
|
|
408
|
+
* is refused, and any other is judged again with the plan of what it starts.
|
|
409
|
+
* An event marked `bare` reaches the desk as Clio 0.6.2 sends it.
|
|
410
|
+
*/
|
|
411
|
+
function withClioFacts(host: Host, workspace: string): Host {
|
|
412
|
+
const hook = host.hook.bind(host);
|
|
413
|
+
const refuse = (reason: string) => ({ effects: [{ kind: "block_tool", reason }] });
|
|
414
|
+
const judged = async (event: Json, options?: Json) => {
|
|
415
|
+
if (event.bare === true) {
|
|
416
|
+
const { bare: _bare, ...sent } = event;
|
|
417
|
+
return hook(sent as never, options as never);
|
|
418
|
+
}
|
|
419
|
+
const sent = withFacts(event, workspace);
|
|
420
|
+
const first = await hook(sent as never, options as never);
|
|
421
|
+
if (event.point !== "before_tool" || event.tool !== "dispatch" || "dispatch" in event) return first;
|
|
422
|
+
const failure = (sent.args as Json).__clio_dispatch_plan_preparation_error;
|
|
423
|
+
if (typeof failure === "string") return blocked(first) === null ? refuse(`Clio: ${failure}`) : first;
|
|
424
|
+
const rewritten = rewriteOf(first);
|
|
425
|
+
if (rewritten === null || blocked(first) !== null) return first;
|
|
426
|
+
if ((((sent.dispatch as Json).tasks as unknown[]) ?? []).length > 1) return refuse("extension wtfp rewrote dispatch input into a call that would need operator approval");
|
|
427
|
+
const second = await hook(withFacts({ ...event, args: rewritten }, workspace) as never, options as never);
|
|
428
|
+
const refused = blocked(second);
|
|
429
|
+
return refused === null ? first : refuse(`extension wtfp rewrote dispatch input into a call that is blocked: ${refused}`);
|
|
430
|
+
};
|
|
431
|
+
return new Proxy(host, { get: (target, key) => (key === "hook" ? judged : Reflect.get(target, key)) }) as Host;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** The write roots a confining rewrite hands its single worker, wherever the rewrite put them. */
|
|
435
|
+
const rootsOf = (rewrite: Json | null): unknown =>
|
|
436
|
+
((((rewrite?.tasks as Json[] | undefined)?.[0]?.intent ?? rewrite?.intent) as Json | undefined)?.write_roots);
|
|
437
|
+
|
|
438
|
+
// --- record writes -------------------------------------------------------------
|
|
439
|
+
|
|
440
|
+
test("record writes at the revision or digest the caller read and refuses stale, blind and invalid writes", () =>
|
|
441
|
+
withDesk(async (host, workspace) => {
|
|
442
|
+
const state = read(workspace, ".planning/state.json");
|
|
443
|
+
const written = await host.tool("record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 });
|
|
444
|
+
assert.equal(written.isError, undefined, written.text);
|
|
445
|
+
assert.equal((written.data as Json).revision, 4);
|
|
446
|
+
const stale = await host.tool("record", { uri: "project://state", record: { ...state, phase: "ready" }, expect_revision: 3 });
|
|
447
|
+
assert.match(stale.text, /revision 4, not 3/);
|
|
448
|
+
const blind = await host.tool("record", { uri: "project://state", record: { ...state, phase: "ready" } });
|
|
449
|
+
assert.match(blind.text, /already exists; read it with extension_wtfp__read_record/);
|
|
450
|
+
const invalid = await host.tool("record", { uri: "project://state", record: { ...state, phase: "drafting" }, expect_revision: 4 });
|
|
451
|
+
assert.match(invalid.text, /would not validate/);
|
|
452
|
+
assert.deepEqual([read(workspace, ".planning/state.json").phase, read(workspace, ".planning/state.json").revision], ["reviewing", 4]);
|
|
453
|
+
|
|
454
|
+
// Two writers read the same section bytes; only the first lands (R1).
|
|
455
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
456
|
+
const seen = (await host.tool("read_record", { uri: "project://sections/introduction" })).data as Json;
|
|
457
|
+
assert.equal(seen.sha256, sha(workspace, ".planning/sections/introduction/section.json"));
|
|
458
|
+
const first = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, goal: "First writer." }, expect_sha256: seen.sha256 });
|
|
459
|
+
assert.equal(first.isError, undefined, first.text);
|
|
460
|
+
const second = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, goal: "Second writer." }, expect_sha256: seen.sha256 });
|
|
461
|
+
assert.match(second.text, /changed since it was read/);
|
|
462
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").goal, "First writer.");
|
|
463
|
+
|
|
464
|
+
const gone = await host.tool("record", { uri: "project://sources/never-made", record: {}, expect_sha256: "0".repeat(64) });
|
|
465
|
+
assert.match(gone.text, /holds wtfp.project.source\/v1|no longer exists/);
|
|
466
|
+
}));
|
|
467
|
+
|
|
468
|
+
test("record refuses wrong type, id, project and unknown fields without touching the destination", () =>
|
|
469
|
+
withDesk(async (host, workspace) => {
|
|
470
|
+
const before = sha(workspace, ".planning/sections/introduction/section.json");
|
|
471
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
472
|
+
const expect_sha256 = before;
|
|
473
|
+
const cases: Array<[Json, RegExp]> = [
|
|
474
|
+
[{ ...section, schema: "wtfp.project.source/v1" }, /holds wtfp.project.section\/v1/],
|
|
475
|
+
[{ ...section, id: "methods" }, /whose id is introduction/],
|
|
476
|
+
[{ ...section, project_id: "another-project" }, /belongs to project another-project/],
|
|
477
|
+
[{ ...section, surprise: true }, /would not validate: .*unknown property surprise|surprise/],
|
|
478
|
+
];
|
|
479
|
+
for (const [record, pattern] of cases) {
|
|
480
|
+
const refused = await host.tool("record", { uri: "project://sections/introduction", record, expect_sha256 });
|
|
481
|
+
assert.equal(refused.isError, true);
|
|
482
|
+
assert.match(refused.text, pattern);
|
|
483
|
+
}
|
|
484
|
+
assert.equal(sha(workspace, ".planning/sections/introduction/section.json"), before);
|
|
485
|
+
}));
|
|
486
|
+
|
|
487
|
+
test("no record write or file write escapes through a symbolic link", () =>
|
|
488
|
+
withDesk(async (host, workspace) => {
|
|
489
|
+
const outside = mkdtempSync(path.join(process.env.TMPDIR as string, "wtfp-outside-"));
|
|
490
|
+
try {
|
|
491
|
+
symlinkSync(outside, path.join(workspace, ".planning/sections/escape"));
|
|
492
|
+
const section = { ...read(workspace, ".planning/sections/introduction/section.json"), id: "escape", title: "Escape" };
|
|
493
|
+
const refused = await host.tool("record", { uri: "project://sections/escape", record: section });
|
|
494
|
+
assert.match(refused.text, /symbolic link/);
|
|
495
|
+
assert.deepEqual(readdirSync(outside), []);
|
|
496
|
+
// A link that lands in paper/ is judged where it lands (W2).
|
|
497
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
498
|
+
assert.match(blocked(await write(host, "drafts/introduction.md")) ?? "", /cannot be written yet/);
|
|
499
|
+
// Clio follows a dangling link to its target, here outside the project, and refuses the write if the link changes after the hook.
|
|
500
|
+
symlinkSync(path.join(outside, "missing"), path.join(workspace, "paper/dangling.md"));
|
|
501
|
+
assert.equal(blocked(await write(host, "paper/dangling.md")), null);
|
|
502
|
+
// A link Clio cannot resolve, such as a loop, is refused.
|
|
503
|
+
symlinkSync("loop", path.join(workspace, "paper/loop"));
|
|
504
|
+
assert.match(blocked(await write(host, "paper/loop/draft.md")) ?? "", /could not resolve/);
|
|
505
|
+
} finally {
|
|
506
|
+
rmSync(outside, { recursive: true, force: true });
|
|
507
|
+
}
|
|
508
|
+
}));
|
|
509
|
+
|
|
510
|
+
test("a readback that differs from what was written is reported against the file it names", () =>
|
|
511
|
+
withDesk(async (host, workspace) => {
|
|
512
|
+
const state = read(workspace, ".planning/state.json");
|
|
513
|
+
process.env.WTFP_DESK_TEST_FAULT = "tamper-after-rename";
|
|
514
|
+
try {
|
|
515
|
+
const result = await host.tool("record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 });
|
|
516
|
+
assert.equal(result.isError, true);
|
|
517
|
+
assert.match(result.text, /readback of \.planning\/state\.json differs from what was written/);
|
|
518
|
+
assert.match(result.text, /^Committed, but/, "a write that landed is never reported as not written");
|
|
519
|
+
} finally {
|
|
520
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
521
|
+
}
|
|
522
|
+
}));
|
|
523
|
+
|
|
524
|
+
// --- author gates --------------------------------------------------------------
|
|
525
|
+
|
|
526
|
+
test("a gate answer is recorded as a sealed interaction bound to what the author saw", () =>
|
|
527
|
+
withDesk(async (host, workspace) => {
|
|
528
|
+
const text = await answer(host, GATE, "workflow-first");
|
|
529
|
+
assert.match(text, /Recorded the author's answer: checkpoint-framing: Workflow first/);
|
|
530
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
531
|
+
assert.equal(checkpoint.status, "resolved");
|
|
532
|
+
assert.deepEqual(
|
|
533
|
+
[(checkpoint.resolution as Json).resolved_by, (checkpoint.resolution as Json).selected_option],
|
|
534
|
+
["author", "workflow-first"],
|
|
535
|
+
);
|
|
536
|
+
assert.deepEqual(read(workspace, ".planning/state.json").active_checkpoint_uris, [`project://checkpoints/${PLAN_GATE}`]);
|
|
537
|
+
const [interaction] = interactions(workspace);
|
|
538
|
+
assert.equal(interaction?.channel, "attested-interview");
|
|
539
|
+
assert.equal(interaction?.outcome, "selected");
|
|
540
|
+
assert.equal(interaction?.selected_option, "workflow-first");
|
|
541
|
+
assert.match(String((interaction?.seal as Json).mac), /^[a-f0-9]{64}$/);
|
|
542
|
+
const seen = (await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json;
|
|
543
|
+
assert.equal(seen.trust, "attested");
|
|
544
|
+
// The answer cannot be applied twice (G4).
|
|
545
|
+
const again = await host.tool("gate", { checkpoint: GATE });
|
|
546
|
+
assert.match(again.text, /already resolved by the author at this desk/);
|
|
547
|
+
}));
|
|
548
|
+
|
|
549
|
+
test("cancelling, headless asking and keeping a gate pending never resolve it (G2)", () =>
|
|
550
|
+
withDesk(async (host, workspace) => {
|
|
551
|
+
let key = await ask(host, GATE);
|
|
552
|
+
const cancelled = await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "operator" });
|
|
553
|
+
assert.match("done" in cancelled ? cancelled.text : "", /stays pending/);
|
|
554
|
+
key = await ask(host, GATE);
|
|
555
|
+
const headless = await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "headless" });
|
|
556
|
+
assert.match("done" in headless ? headless.text : "", /headless session; the gate stays pending and authorizes nothing/);
|
|
557
|
+
const kept = await answer(host, GATE, "__keep");
|
|
558
|
+
assert.match(kept, /kept checkpoint-framing pending/);
|
|
559
|
+
assert.equal(read(workspace, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
560
|
+
assert.deepEqual(interactions(workspace).map((entry) => entry.outcome), ["kept-pending"]);
|
|
561
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")));
|
|
562
|
+
}));
|
|
563
|
+
|
|
564
|
+
test("an answer that was not offered, replayed, or meant for another desk records nothing (G3, G4)", () =>
|
|
565
|
+
withDesk(async (host, workspace) => {
|
|
566
|
+
const key = await ask(host, GATE);
|
|
567
|
+
const offered = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "__resolve" } });
|
|
568
|
+
assert.match("done" in offered ? offered.text : "", /not one of the options offered/);
|
|
569
|
+
const replay = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "workflow-first" } });
|
|
570
|
+
assert.match("done" in replay ? replay.text : "", /matches no open question/);
|
|
571
|
+
const forged = await host.interview({ id: "gate-one", step: "gate.0123456789ab", nav: "next", answers: { choice: "workflow-first" } });
|
|
572
|
+
assert.match("done" in forged ? forged.text : "", /matches no open question/);
|
|
573
|
+
const other = project();
|
|
574
|
+
const elsewhere = withClioFacts(await createExtensionTestHost(ROOT, { workspace: other }), other);
|
|
575
|
+
try {
|
|
576
|
+
const foreign = await elsewhere.interview({ id: "gate-one", step: await ask(host, GATE), nav: "next", answers: { choice: "workflow-first" } });
|
|
577
|
+
assert.match("done" in foreign ? foreign.text : "", /matches no open question/);
|
|
578
|
+
assert.equal(read(other, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
579
|
+
} finally {
|
|
580
|
+
await elsewhere.dispose();
|
|
581
|
+
rmSync(other, { recursive: true, force: true });
|
|
582
|
+
}
|
|
583
|
+
assert.equal(read(workspace, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
584
|
+
assert.deepEqual(interactions(workspace), []);
|
|
585
|
+
}));
|
|
586
|
+
|
|
587
|
+
test("a question that changes while it is open sets the old answer aside and asks again (G3)", () =>
|
|
588
|
+
withDesk(async (host, workspace) => {
|
|
589
|
+
const key = await ask(host, PLAN_GATE);
|
|
590
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\n1. A different plan.\n");
|
|
591
|
+
const stale = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "approve" } });
|
|
592
|
+
assert.ok(!("done" in stale), "a changed subject is asked again");
|
|
593
|
+
assert.equal(read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`).status, "pending");
|
|
594
|
+
assert.deepEqual(interactions(workspace).map((entry) => entry.outcome), ["discarded-stale"]);
|
|
595
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
596
|
+
const key2 = "step" in stale ? stale.step.key : "";
|
|
597
|
+
put(workspace, `.planning/checkpoints/${PLAN_GATE}.json`, { ...checkpoint, request: "Approve the rewritten plan?" });
|
|
598
|
+
const stale2 = await host.interview({ id: "gate-one", step: key2, nav: "next", answers: { choice: "approve" } });
|
|
599
|
+
assert.ok(!("done" in stale2));
|
|
600
|
+
assert.equal(read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`).status, "pending");
|
|
601
|
+
}));
|
|
602
|
+
|
|
603
|
+
test("an agent cannot fabricate, unblock, rescope or expire an author gate through any write path it has (G1)", () =>
|
|
604
|
+
withDesk(async (host, workspace) => {
|
|
605
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
606
|
+
const expect_sha256 = sha(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
607
|
+
const resolution = { resolved_by: "author", selected_option: "workflow-first", summary: "The author chose it.", resolved_at: AT };
|
|
608
|
+
const attempts: Array<[Json, RegExp]> = [
|
|
609
|
+
[{ ...checkpoint, status: "resolved", resolution }, /only the author's answer at the desk/],
|
|
610
|
+
[{ ...checkpoint, status: "resolved", resolution: { ...resolution, resolved_by: "policy" } }, /resolved only by the author/],
|
|
611
|
+
[{ ...checkpoint, blocking: false }, /cannot be made nonblocking/],
|
|
612
|
+
[{ ...checkpoint, scope_uri: "project://sections/elsewhere" }, /cannot change scope/],
|
|
613
|
+
[{ ...checkpoint, status: "expired" }, /cannot be expired by the agent/],
|
|
614
|
+
];
|
|
615
|
+
for (const [record, pattern] of attempts) {
|
|
616
|
+
const refused = await host.tool("record", { uri: `project://checkpoints/${GATE}`, record, expect_sha256 });
|
|
617
|
+
assert.match(refused.text, pattern);
|
|
618
|
+
}
|
|
619
|
+
const interaction = await host.tool("record", { uri: "project://interactions/fake", record: { schema: "wtfp.project.interaction/v1", id: "fake" } });
|
|
620
|
+
assert.match(interaction.text, /only the desk records an author's answer/);
|
|
621
|
+
const first = await write(host, `.planning/checkpoints/${GATE}.json`);
|
|
622
|
+
assert.match(blocked(first) ?? "", /portable record; write it with extension_wtfp__record/);
|
|
623
|
+
assert.ok(first.effects?.some((effect) => effect.kind === "protect_path"), "the desk asks the host to protect its answers from shell mutation");
|
|
624
|
+
assert.match(blocked(await write(host, ".planning/interactions/fake.json")) ?? "", /written only by the desk/);
|
|
625
|
+
const shell = await host.hook({ point: "before_tool", tool: "bash", turnId: "t1", args: { command: "python3 -c 'open(\".planning/interactions/x.json\",\"w\")'" } });
|
|
626
|
+
assert.match(blocked(shell) ?? "", /desk's own records/);
|
|
627
|
+
|
|
628
|
+
// A resolution written straight to disk is not the author's answer: it holds its scope and is offered for confirmation.
|
|
629
|
+
put(workspace, `.planning/checkpoints/${GATE}.json`, { ...checkpoint, status: "resolved", resolution });
|
|
630
|
+
const seen = (await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json;
|
|
631
|
+
assert.equal(seen.trust, "unattested");
|
|
632
|
+
await answer(host, PLAN_GATE, "approve");
|
|
633
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /not observed by this desk and must be confirmed/);
|
|
634
|
+
const gates = await host.command("check-todos");
|
|
635
|
+
assert.match(gates.interview?.step.title ?? "", /Confirm a recorded answer/);
|
|
636
|
+
const confirmed = await host.interview({ id: "gate", step: gates.interview?.step.key as string, nav: "next", answers: { choice: "workflow-first" } });
|
|
637
|
+
assert.match("done" in confirmed ? confirmed.text : "", /Recorded: checkpoint-framing: Workflow first/);
|
|
638
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
639
|
+
}));
|
|
640
|
+
|
|
641
|
+
test("nonblocking policy resolutions and state snapshots are not author gates", () =>
|
|
642
|
+
withDesk(async (host, workspace) => {
|
|
643
|
+
const note = {
|
|
644
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
645
|
+
id: "note-figure-style",
|
|
646
|
+
project_id: PROJECT,
|
|
647
|
+
kind: "human-action",
|
|
648
|
+
status: "pending",
|
|
649
|
+
blocking: false,
|
|
650
|
+
scope_uri: "project://sections/introduction",
|
|
651
|
+
request: "Pick a figure palette when convenient.",
|
|
652
|
+
options: [],
|
|
653
|
+
resume_action: "write-section",
|
|
654
|
+
created_at: AT,
|
|
655
|
+
};
|
|
656
|
+
const created = await host.tool("record", { uri: "project://checkpoints/note-figure-style", record: note });
|
|
657
|
+
assert.equal(created.isError, undefined, created.text);
|
|
658
|
+
const policy = { resolved_by: "policy", summary: "The configured default palette applies.", resolved_at: AT };
|
|
659
|
+
const resolved = await host.tool("record", {
|
|
660
|
+
uri: "project://checkpoints/note-figure-style",
|
|
661
|
+
record: { ...note, status: "resolved", resolution: policy },
|
|
662
|
+
expect_sha256: sha(workspace, ".planning/checkpoints/note-figure-style.json"),
|
|
663
|
+
});
|
|
664
|
+
assert.equal(resolved.isError, undefined, resolved.text);
|
|
665
|
+
assert.equal(((await host.tool("read_record", { uri: "project://checkpoints/note-figure-style" })).data as Json).trust, "policy");
|
|
666
|
+
const forged = await host.tool("record", {
|
|
667
|
+
uri: "project://checkpoints/blocking-by-policy",
|
|
668
|
+
record: { ...note, id: "blocking-by-policy", blocking: true, status: "resolved", resolution: policy },
|
|
669
|
+
});
|
|
670
|
+
assert.match(forged.text, /resolved only by the author/);
|
|
671
|
+
const snapshot = await host.tool("record", {
|
|
672
|
+
uri: "project://checkpoints/snapshot-before-revision",
|
|
673
|
+
record: {
|
|
674
|
+
...note,
|
|
675
|
+
id: "snapshot-before-revision",
|
|
676
|
+
kind: "state-snapshot",
|
|
677
|
+
status: "available",
|
|
678
|
+
request: "State before the revision.",
|
|
679
|
+
snapshot: { archive_uri: "project://archives/checkpoints/snapshot-before-revision", resources: [{ uri: "project://state", revision: 3, sha256: sha(workspace, ".planning/state.json") }] },
|
|
680
|
+
},
|
|
681
|
+
});
|
|
682
|
+
assert.equal(snapshot.isError, undefined, snapshot.text);
|
|
683
|
+
await answer(host, GATE, "protocol-first");
|
|
684
|
+
await answer(host, PLAN_GATE, "approve");
|
|
685
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null, "neither the policy-resolved note nor the snapshot holds the section");
|
|
686
|
+
assert.match((await host.command("check-todos")).text, /No pending gates/);
|
|
687
|
+
}));
|
|
688
|
+
|
|
689
|
+
// --- approved plans and write boundaries ---------------------------------------------
|
|
690
|
+
|
|
691
|
+
test("the manuscript waits for an author-approved plan whose exact bytes were approved (W1)", () =>
|
|
692
|
+
withDesk(async (host, workspace) => {
|
|
693
|
+
await answer(host, GATE, "protocol-first");
|
|
694
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /has not answered "Approve the introduction plan\?"/);
|
|
695
|
+
const declined = project();
|
|
696
|
+
const other = withClioFacts(await createExtensionTestHost(ROOT, { workspace: declined }), declined);
|
|
697
|
+
try {
|
|
698
|
+
await answer(other, GATE, "protocol-first");
|
|
699
|
+
await answer(other, PLAN_GATE, "revise");
|
|
700
|
+
assert.match(blocked(await write(other, "paper/introduction.md")) ?? "", /answered "revise" on approve-initial, not approve/);
|
|
701
|
+
} finally {
|
|
702
|
+
await other.dispose();
|
|
703
|
+
rmSync(declined, { recursive: true, force: true });
|
|
704
|
+
}
|
|
705
|
+
await answer(host, PLAN_GATE, "approve");
|
|
706
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
707
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
708
|
+
assert.equal((ready.data as Json).ready, true, ready.text);
|
|
709
|
+
// A linked plan is immutable, and changing its bytes anyway voids the approval.
|
|
710
|
+
assert.match(blocked(await write(host, PLAN_FILE)) ?? "", /linked plans are immutable/);
|
|
711
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\n1. Something the author never saw.\n");
|
|
712
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /plan changed after the author approved it/);
|
|
713
|
+
rmSync(path.join(workspace, PLAN_FILE));
|
|
714
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /does not resolve to a plan file/);
|
|
715
|
+
// A status alone never stands in for a plan.
|
|
716
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
717
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, artifacts: { plans: [], reviews: [], manuscript: "project://paper/introduction" } });
|
|
718
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /no plan is linked/);
|
|
719
|
+
// Nested and variant manuscript paths are the same section's manuscript.
|
|
720
|
+
assert.ok(blocked(await write(host, "paper/introduction/results.md")));
|
|
721
|
+
assert.ok(blocked(await write(host, "paper/introduction.v2.md")));
|
|
722
|
+
assert.equal(blocked(await write(host, "paper/unrelated-notes.md")), null);
|
|
723
|
+
}));
|
|
724
|
+
|
|
725
|
+
test("literature-heavy sections wait for verified evidence behind their required claims", () =>
|
|
726
|
+
withDesk(async (host, workspace) => {
|
|
727
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
728
|
+
const [entry] = outline.sections as Json[];
|
|
729
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
730
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
731
|
+
put(workspace, ".planning/sections/introduction/section.json", {
|
|
732
|
+
...section,
|
|
733
|
+
claims: [{ id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] }],
|
|
734
|
+
});
|
|
735
|
+
await answer(host, GATE, "protocol-first");
|
|
736
|
+
await answer(host, PLAN_GATE, "approve");
|
|
737
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
738
|
+
assert.equal((ready.data as Json).ready, false);
|
|
739
|
+
assert.match(ready.text, /1 required claim lacks verified evidence \(claim-flush\); run research-gap first/);
|
|
740
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /research-gap/);
|
|
741
|
+
// Verified, full-text support makes it ready; a contradiction on record, an invalid record or a reused id takes that back.
|
|
742
|
+
put(workspace, ".planning/sources/source-flush.json", {
|
|
743
|
+
schema: "wtfp.project.source/v1", id: "source-flush", project_id: PROJECT, kind: "journal-article", title: "Flush Costs", creators: ["A. Author"], year: 2025,
|
|
744
|
+
identifiers: { doi: "10.1234/flush" }, citation_key: "author2025", status: "verified",
|
|
745
|
+
provenance: { discovered_via: "scholarly-index", inspection_depth: "full-text", verified_at: AT },
|
|
746
|
+
});
|
|
747
|
+
const support = {
|
|
748
|
+
schema: "wtfp.project.evidence/v1", id: "evidence-flush", project_id: PROJECT, source_uri: "project://sources/source-flush", claim_id: "claim-flush", relation: "supports",
|
|
749
|
+
statement: "Flushes dominate.", locator: { kind: "section", value: "3" }, interpretation: "Direct measurement.", confidence: "high", inspection_depth: "full-text", verified_at: AT,
|
|
750
|
+
};
|
|
751
|
+
put(workspace, ".planning/evidence/evidence-flush.json", support);
|
|
752
|
+
const linked = read(workspace, ".planning/sections/introduction/section.json");
|
|
753
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...linked, claims: [{ ...(linked.claims as Json[])[0], evidence_uris: ["project://evidence/evidence-flush"] }] });
|
|
754
|
+
const readyNow = async () => ((await host.tool("readiness", { section: "introduction" })).data as Json).ready;
|
|
755
|
+
assert.equal(await readyNow(), true);
|
|
756
|
+
put(workspace, ".planning/evidence/evidence-against.json", { ...support, id: "evidence-against", relation: "contradicts" });
|
|
757
|
+
assert.equal(await readyNow(), false, "an unlinked contradiction contests the claim");
|
|
758
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-against.json"));
|
|
759
|
+
const { statement: _statement, ...statementless } = support;
|
|
760
|
+
put(workspace, ".planning/evidence/evidence-flush.json", statementless);
|
|
761
|
+
assert.equal(await readyNow(), false, "an evidence record that fails its schema supports nothing");
|
|
762
|
+
put(workspace, ".planning/evidence/evidence-flush.json", support);
|
|
763
|
+
// A second copy can only sit away from the protocol file, so it is the copy that is ignored, and reported.
|
|
764
|
+
put(workspace, ".planning/evidence/evidence-flush-copy.json", { ...support, relation: "contradicts" });
|
|
765
|
+
assert.equal(await readyNow(), true);
|
|
766
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/evidence\/evidence-flush-copy\.json/);
|
|
767
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-flush-copy.json"));
|
|
768
|
+
assert.equal(await readyNow(), true);
|
|
769
|
+
// project://evidence/evidence-flush resolves to one file; the same record anywhere else is not it.
|
|
770
|
+
writeFileSync(path.join(workspace, ".planning/evidence/renamed.json"), readFileSync(path.join(workspace, ".planning/evidence/evidence-flush.json")));
|
|
771
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-flush.json"));
|
|
772
|
+
assert.equal(await readyNow(), false, "evidence away from its protocol file supports nothing");
|
|
773
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/evidence\/renamed\.json/);
|
|
774
|
+
// A manuscript the desk will not follow cannot have its citations checked, and says so.
|
|
775
|
+
rmSync(path.join(workspace, "paper/introduction.md"));
|
|
776
|
+
symlinkSync(path.join(workspace, ".planning/project.json"), path.join(workspace, "paper/introduction.md"));
|
|
777
|
+
assert.match((await host.command("validate")).text, /manuscript-unread project:\/\/sections\/introduction/);
|
|
778
|
+
// A drafted section whose manuscript link names nothing under paper/ is reported too.
|
|
779
|
+
const linked2 = read(workspace, ".planning/sections/introduction/section.json");
|
|
780
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...linked2, status: "writing", artifacts: { ...(linked2.artifacts as Json), manuscript: "project://materials/notes" } });
|
|
781
|
+
assert.match((await host.command("validate")).text, /manuscript-unread project:\/\/sections\/introduction: project:\/\/materials\/notes could not be checked/);
|
|
782
|
+
}, SERVED));
|
|
783
|
+
|
|
784
|
+
test("a section file counts only for the section whose id names its directory", () =>
|
|
785
|
+
withDesk(async (host, workspace) => {
|
|
786
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
787
|
+
const [entry] = outline.sections as Json[];
|
|
788
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
789
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
790
|
+
const claims = [{ id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] }];
|
|
791
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, claims });
|
|
792
|
+
await answer(host, GATE, "protocol-first");
|
|
793
|
+
await answer(host, PLAN_GATE, "approve");
|
|
794
|
+
const readyNow = async () => ((await host.tool("readiness", { section: "introduction" })).data as Json).ready;
|
|
795
|
+
assert.equal(await readyNow(), false, "the unsupported required claim holds the section");
|
|
796
|
+
// Renaming the record inside the file must not move its claims out of the section the outline names.
|
|
797
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, id: "intro-other", claims });
|
|
798
|
+
assert.equal(await readyNow(), false);
|
|
799
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")));
|
|
800
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/sections\/introduction\/section\.json/);
|
|
801
|
+
}, SERVED));
|
|
802
|
+
|
|
803
|
+
test("a renamed section record cannot make a pending plan gate look superseded", () =>
|
|
804
|
+
withDesk(async (host, workspace) => {
|
|
805
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
806
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, id: "intro-other", artifacts: { ...(section.artifacts as Json), plans: [PLAN_URI, "project://sections/introduction/plans/decoy"] } });
|
|
807
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
808
|
+
const expired = await host.tool("record", { uri: `project://checkpoints/${PLAN_GATE}`, record: { ...checkpoint, status: "expired" }, expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) });
|
|
809
|
+
assert.match(expired.text, /cannot be expired by the agent/);
|
|
810
|
+
}));
|
|
811
|
+
|
|
812
|
+
test("turning a gate off needs the author's confirmation at the desk", () =>
|
|
813
|
+
withDesk(async (host, workspace) => {
|
|
814
|
+
const config = read(workspace, ".planning/config.json");
|
|
815
|
+
const proposal = { ...config, gates: { ...(config.gates as Json), confirm_plan: false } };
|
|
816
|
+
const expect_sha256 = sha(workspace, ".planning/config.json");
|
|
817
|
+
const asked = await host.tool("record", { uri: "project://config", record: proposal, expect_sha256 });
|
|
818
|
+
assert.equal(asked.interview?.id, "confirm-write");
|
|
819
|
+
assert.match(JSON.stringify(asked.interview?.step.intro), /gates.confirm_plan: on → off/);
|
|
820
|
+
const declined = await host.interview({ id: "confirm-write", step: asked.interview?.step.key as string, nav: "next", answers: { choice: "decline" } });
|
|
821
|
+
assert.match("done" in declined ? declined.text : "", /kept the current settings/);
|
|
822
|
+
assert.equal(((read(workspace, ".planning/config.json").gates as Json).confirm_plan), true);
|
|
823
|
+
const again = await host.tool("record", { uri: "project://config", record: proposal, expect_sha256 });
|
|
824
|
+
const approved = await host.interview({ id: "confirm-write", step: again.interview?.step.key as string, nav: "next", answers: { choice: "approve" } });
|
|
825
|
+
assert.match("done" in approved ? approved.text : "", /approved the change/);
|
|
826
|
+
assert.equal(((read(workspace, ".planning/config.json").gates as Json).confirm_plan), false);
|
|
827
|
+
assert.deepEqual(interactions(workspace).map((entry) => `${entry.kind}:${entry.outcome}`).sort(), ["record-change:approved", "record-change:declined"]);
|
|
828
|
+
// With confirm_plan off, a contained linked plan stands without approval once no gate holds the section.
|
|
829
|
+
rmSync(path.join(workspace, `.planning/checkpoints/${PLAN_GATE}.json`));
|
|
830
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /has not answered "Lead with the protocol/);
|
|
831
|
+
await answer(host, GATE, "protocol-first");
|
|
832
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
833
|
+
}));
|
|
834
|
+
|
|
835
|
+
test("an armed action writes only what its contract declares, for the section it names, until its turn ends", () =>
|
|
836
|
+
withDesk(async (host, workspace) => {
|
|
837
|
+
const armed = await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section introduction" });
|
|
838
|
+
assert.match(JSON.stringify(armed.effects), /plan-section introduction: files stay under \.planning\/sections\/introduction\/plans/);
|
|
839
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /may write only under \.planning\/sections\/introduction\/plans/);
|
|
840
|
+
assert.equal(blocked(await write(host, ".planning/sections/introduction/plans/second.md")), null);
|
|
841
|
+
assert.ok(blocked(await write(host, ".planning/sections/methods/plans/second.md")));
|
|
842
|
+
const manifest = read(workspace, ".planning/project.json");
|
|
843
|
+
const undeclared = await host.tool("record", { uri: "project://manifest", record: { ...manifest, title: "Retitled" }, expect_sha256: sha(workspace, ".planning/project.json") });
|
|
844
|
+
assert.match(undeclared.text, /plan-section does not declare updating project:\/\/manifest/);
|
|
845
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
846
|
+
assert.ok(!blocked(await write(host, ".planning/sections/methods/notes.md")), "the guard disarms when its turn ends");
|
|
847
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
848
|
+
assert.match(blocked(await write(host, ".planning/sections/introduction/notes.md")) ?? "", /declares no file outputs/);
|
|
849
|
+
}, SERVED));
|
|
850
|
+
|
|
851
|
+
test("WTF-P workers are dispatched only inside their action and only to manuscripts that are ready (W3)", () =>
|
|
852
|
+
withDesk(async (host, workspace) => {
|
|
853
|
+
const dispatch = (args: Json) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args });
|
|
854
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." })) ?? "", /run only inside the WTF-P action/);
|
|
855
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
856
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." })) ?? "", /would have no manuscript it may write/);
|
|
857
|
+
await answer(host, GATE, "protocol-first");
|
|
858
|
+
await answer(host, PLAN_GATE, "approve");
|
|
859
|
+
const allowed = await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." });
|
|
860
|
+
assert.deepEqual(rootsOf(rewriteOf(allowed)), [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"]);
|
|
861
|
+
assert.ok(!Object.keys(rewriteOf(allowed) ?? {}).some((key) => key.startsWith("__clio_")), "Clio recomputes its own admission keys for a rewritten call");
|
|
862
|
+
const narrowed = await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["."] } });
|
|
863
|
+
assert.deepEqual(rootsOf(rewriteOf(narrowed)), [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"]);
|
|
864
|
+
// Roots that already are the confinement, in any order, need no rewrite.
|
|
865
|
+
assert.equal(rewriteOf(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["paper/introduction/", "paper/introduction.md", ".planning/sections/introduction/summary.md"] } })), null);
|
|
866
|
+
assert.match(
|
|
867
|
+
blocked(await dispatch({ tasks: [{ agent: "wtfp-section-writer", task: "a" }, { agent: "wtfp-section-writer", task: "b" }] })) ?? "",
|
|
868
|
+
/Clio: parallel writers need disjoint intent\.write_roots/,
|
|
869
|
+
);
|
|
870
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src"] } })) ?? "", /lie outside what write-section may write/);
|
|
871
|
+
assert.ok(existsSync(path.join(workspace, "paper/introduction.md")));
|
|
872
|
+
// A root the action itself grants is refused when a link makes it lead somewhere else.
|
|
873
|
+
symlinkSync(path.join(workspace, ".planning/sections"), path.join(workspace, "paper/introduction"));
|
|
874
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft." })) ?? "", /paper\/introduction\/ does not lead where it reads/);
|
|
875
|
+
}, SERVED));
|
|
876
|
+
|
|
877
|
+
test("the guard judges the file Clio's tools open, however the path is spelled (W2)", () =>
|
|
878
|
+
withDesk(async (host, workspace) => {
|
|
879
|
+
const manuscript = path.join(workspace, "paper/introduction.md");
|
|
880
|
+
for (const spelling of ["@paper/introduction.md", `~/${path.relative(homedir(), manuscript)}`, "paper/./introduction.md"])
|
|
881
|
+
assert.match(blocked(await write(host, spelling)) ?? "", /cannot be written yet/, spelling);
|
|
882
|
+
assert.match(blocked(await write(host, "@.planning/config.json")) ?? "", /portable record/);
|
|
883
|
+
// The kernel reads a link before the `..` after it, so latest/.. is paper/, not the workspace.
|
|
884
|
+
mkdirSync(path.join(workspace, "paper/introduction"), { recursive: true });
|
|
885
|
+
symlinkSync(path.join(workspace, "paper/introduction"), path.join(workspace, "latest"));
|
|
886
|
+
assert.match(blocked(await write(host, "latest/../introduction.md")) ?? "", /cannot be written yet/);
|
|
887
|
+
// The artifact tool trims its path and writes it like write does.
|
|
888
|
+
const artifact = await host.hook({ point: "before_tool", tool: "artifact", turnId: "t1", args: { kind: "report", path: " paper/introduction.md ", content: "x" } });
|
|
889
|
+
assert.match(blocked(artifact) ?? "", /cannot be written yet/);
|
|
890
|
+
const script = await host.hook({ point: "before_tool", tool: "run_script", turnId: "t1", args: { interpreter: "python3", script: "x.py", args: [".planning/interactions/x.json"] } });
|
|
891
|
+
assert.match(blocked(script) ?? "", /desk's own records/);
|
|
892
|
+
const manifest = readFileSync(path.join(ROOT, "clio-coder-extension.yaml"), "utf8");
|
|
893
|
+
const hooked = /on: before_tool, tools: \[([^\]]*)\]/u.exec(manifest)?.[1]?.split(/,\s*/u) ?? [];
|
|
894
|
+
for (const tool of ["write", "edit", "artifact", "dispatch", "bash", "run_script", "job"]) assert.ok(hooked.includes(tool), `${tool} is hooked`);
|
|
895
|
+
}));
|
|
896
|
+
|
|
897
|
+
test("where Clio resolves a call's landing and dispatch plan, the desk judges what Clio resolved", () =>
|
|
898
|
+
withDesk(async (host, workspace) => {
|
|
899
|
+
const real = realpathSync(workspace);
|
|
900
|
+
const manuscript = path.join(real, "paper/introduction.md");
|
|
901
|
+
const landed = (args: Json, target: unknown) => host.hook({ point: "before_tool", tool: "write", turnId: "t1", args, target });
|
|
902
|
+
// The landing Clio sends is the file the tool opens, whatever the call spells.
|
|
903
|
+
assert.match(blocked(await landed({ path: "notes.md" }, { arg: "path", path: manuscript, resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
904
|
+
// A path the desk could not inspect is judged where Clio says it lands.
|
|
905
|
+
assert.match(blocked(await landed({ path: "/proc/self/cwd/paper/introduction.md" }, { arg: "path", path: manuscript, resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
906
|
+
// A worker's write in a task worktree is judged at the checkout path it merges into.
|
|
907
|
+
assert.match(blocked(await landed({ path: "paper/introduction.md" }, { arg: "path", path: "/elsewhere/worktree/paper/introduction.md", resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
908
|
+
// Without a workspace path, the desk maps Clio's physical path itself.
|
|
909
|
+
assert.match(blocked(await landed({ path: "x" }, { arg: "path", path: manuscript, resolved: true })) ?? "", /cannot be written yet/);
|
|
910
|
+
assert.equal(blocked(await landed({ path: "/elsewhere/notes.md" }, { arg: "path", path: "/elsewhere/notes.md", resolved: true, workspacePath: null })), null);
|
|
911
|
+
assert.match(blocked(await landed({ path: "loop/x" }, { arg: "path", path: path.join(real, "loop/x"), resolved: false, workspacePath: null })) ?? "", /Clio could not resolve/);
|
|
912
|
+
assert.match(blocked(await landed({ path: "x" }, { arg: "path", path: 7, resolved: true })) ?? "", /form the desk cannot read/);
|
|
913
|
+
|
|
914
|
+
const dispatch = (args: Json, plan: unknown) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args, dispatch: plan });
|
|
915
|
+
const task = (agent: string, extra: Json = {}) => ({ role: "task", agent, cwd: real, writeRoots: [], writeBoundaries: [], worktree: false, readOnly: false, ...extra });
|
|
916
|
+
const plan = (...tasks: Json[]) => ({ kind: "tasks", mode: "single", tasks });
|
|
917
|
+
const coder = { agent: "coder", task: "x", intent: { write_roots: ["src"] } };
|
|
918
|
+
assert.equal(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src"], writeBoundaries: [path.join(real, "src")] })))), null);
|
|
919
|
+
// Clio resolves auto; a WTF-P agent it picks outside its action is refused like one named.
|
|
920
|
+
assert.match(blocked(await dispatch({ agent: "auto", task: "Draft." }, plan(task("wtfp-section-writer")))) ?? "", /run only inside the WTF-P action/);
|
|
921
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { cwd: path.join(real, "paper") })))) ?? "", /cwd moves the write roots/);
|
|
922
|
+
assert.match(
|
|
923
|
+
blocked(await dispatch(coder, { kind: "tasks", mode: "compete", candidates: 2, tasks: [task("coder", { role: "candidate", worktree: true }), task("verifier", { role: "judge", readOnly: true })] })) ?? "",
|
|
924
|
+
/refuses worktree writers/,
|
|
925
|
+
);
|
|
926
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src"] })))) ?? "", /form the desk cannot read/, "every root has its boundary");
|
|
927
|
+
// A root lands where Clio says: one that resolves elsewhere does not lead where it reads, and one on the whole project is no boundary.
|
|
928
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["drafts/"], writeBoundaries: [path.join(real, "paper")] })))) ?? "", /drafts\/ does not lead where it reads/);
|
|
929
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src", "."], writeBoundaries: [path.join(real, "src"), real] })))) ?? "", /intent\.write_roots/);
|
|
930
|
+
assert.match(blocked(await dispatch({}, { kind: "apply-winner", branch: "winner", cwd: real })) ?? "", /compete winner/);
|
|
931
|
+
assert.equal(blocked(await dispatch({}, { kind: "list" })), null);
|
|
932
|
+
assert.match(blocked(await dispatch(coder, plan({ agent: "coder" }))) ?? "", /form the desk cannot read/);
|
|
933
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { agent: 7 })))) ?? "", /form the desk cannot read/);
|
|
934
|
+
// Outside an action, a worker Clio runs read-only needs no roots either.
|
|
935
|
+
assert.equal(blocked(await dispatch({ agent: "auto", task: "Look." }, plan(task("scout", { readOnly: true })))), null);
|
|
936
|
+
// Clio could not prepare this call and refuses it itself, with its own reason.
|
|
937
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", __clio_dispatch_plan_preparation_error: "write_roots entries may not start with ./" }, undefined)), null);
|
|
938
|
+
// A host that has sent facts once lacks them for a call only when Clio failed on it, and the desk says so.
|
|
939
|
+
assert.match(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: "src/x.md" }, bare: true } as never)) ?? "", /Clio sent no landing for this call/);
|
|
940
|
+
assert.match(blocked(await dispatch(coder, { kind: "council-of-elders", tasks: [] })) ?? "", /form the desk cannot read/, "an unknown plan is no plan");
|
|
941
|
+
// A name that starts with `..` is still inside the project.
|
|
942
|
+
assert.equal(blocked(await dispatch({ ...coder, intent: { write_roots: ["..notes/"] } }, plan(task("coder", { writeRoots: ["..notes/"], writeBoundaries: [path.join(real, "..notes")] })))), null);
|
|
943
|
+
// Inside an action, a review loop's reviewer only judges: the builder is confined and the gate role leaves the count alone.
|
|
944
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
945
|
+
await answer(host, GATE, "protocol-first");
|
|
946
|
+
await answer(host, PLAN_GATE, "approve");
|
|
947
|
+
// Clio admits a rewritten call afresh, without the approval a review loop needs, so the desk names the exact roots instead of rewriting.
|
|
948
|
+
const roots = [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"];
|
|
949
|
+
const review = [task("wtfp-section-writer", { role: "builder" }), task("wtfp-section-reviewer", { role: "reviewer", readOnly: true })];
|
|
950
|
+
const loop = await dispatch({ agent: "wtfp-section-writer", tasks: [{ task: "Draft the introduction." }], review: { reviewer: "wtfp-section-reviewer" } }, { kind: "tasks", mode: "review", tasks: review });
|
|
951
|
+
assert.match(blocked(loop) ?? "", /task 1 \(wtfp-section-writer\): \.planning\/sections\/introduction\/summary\.md, paper\/introduction\.md, paper\/introduction\//);
|
|
952
|
+
const sent = { ...review[0], writeRoots: roots, writeBoundaries: roots.map((root) => path.join(real, root)) };
|
|
953
|
+
const confined = await dispatch({ agent: "wtfp-section-writer", tasks: [{ task: "Draft the introduction.", intent: { write_roots: roots } }], review: { reviewer: "wtfp-section-reviewer" } }, { kind: "tasks", mode: "review", tasks: [sent, review[1]] });
|
|
954
|
+
assert.equal(blocked(confined), null, "a loop that already names its roots runs as approved");
|
|
955
|
+
assert.equal(rewriteOf(confined), null);
|
|
956
|
+
// A worker Clio runs read-only needs no write roots, whatever its recipe is called.
|
|
957
|
+
const reader = await dispatch({ agent: "auto", tasks: [{ task: "Review the introduction." }] }, plan(task("scout", { readOnly: true })));
|
|
958
|
+
assert.equal(blocked(reader), null);
|
|
959
|
+
assert.equal(rewriteOf(reader), null);
|
|
960
|
+
// The desk takes that from Clio: a reviewer Clio does not report read-only is confined like any writer.
|
|
961
|
+
assert.deepEqual(rootsOf(rewriteOf(await dispatch({ agent: "wtfp-section-reviewer", tasks: [{ task: "Review." }] }, plan(task("wtfp-section-reviewer"))))), roots);
|
|
962
|
+
// A task Clio keeps as a string is confined as a task object, and Clio's private keys are left for Clio to recompute.
|
|
963
|
+
const spelled = await dispatch({ agent: "wtfp-section-writer", tasks: ["Draft."], __clio_resolved_dispatch_plan: { resolvedBy: "clio" } }, plan(task("wtfp-section-writer")));
|
|
964
|
+
assert.deepEqual(rewriteOf(spelled), { agent: "wtfp-section-writer", tasks: [{ task: "Draft.", intent: { write_roots: roots } }] });
|
|
965
|
+
// Clio's own artifact directory is no project file, but a landing elsewhere in the project, such as through a link, is judged there.
|
|
966
|
+
const artifact = (target: unknown) => host.hook({ point: "before_tool", tool: "artifact", turnId: "t1", args: { kind: "plan", content: "x" }, target });
|
|
967
|
+
assert.equal(blocked(await artifact({ arg: "path", path: path.join(real, ".clio-coder/artifacts/plan.md"), resolved: true, workspacePath: ".clio-coder/artifacts/plan.md" })), null);
|
|
968
|
+
assert.match(blocked(await artifact({ arg: "path", path: path.join(real, "src/plan.md"), resolved: true, workspacePath: "src/plan.md" })) ?? "", /may write only under/);
|
|
969
|
+
}, SERVED));
|
|
970
|
+
|
|
971
|
+
test("a Clio that sends no landing or dispatch plan is refused inside a WTF-P project or action and left alone elsewhere", async () => {
|
|
972
|
+
await withDesk(async (host) => {
|
|
973
|
+
const bare = (tool: string, args: Json) => host.hook({ point: "before_tool", tool, turnId: "t1", args, bare: true } as never);
|
|
974
|
+
assert.match(blocked(await bare("write", { path: "src/notes.md" })) ?? "", /needs Clio 0\.6\.3/);
|
|
975
|
+
assert.match(blocked(await bare("dispatch", { agent: "coder", task: "x", intent: { write_roots: ["src/"] } })) ?? "", /needs Clio 0\.6\.3/);
|
|
976
|
+
assert.equal(blocked(await bare("dispatch", { list: true })), null);
|
|
977
|
+
assert.equal(blocked(await bare("bash", { command: "ls" })), null);
|
|
978
|
+
});
|
|
979
|
+
const folder = mkdtempSync(path.join(process.env.TMPDIR as string, "wtfp-no-project-"));
|
|
980
|
+
const host = await createExtensionTestHost(ROOT, { workspace: folder, plugin: null });
|
|
981
|
+
try {
|
|
982
|
+
const bare = (tool: string, args: Json) => host.hook({ point: "before_tool", tool, turnId: "t1", args } as never);
|
|
983
|
+
assert.equal(blocked(await bare("write", { path: "notes.md" })), null, "a folder that is no WTF-P project is not the desk's to guard");
|
|
984
|
+
assert.equal(blocked(await bare("dispatch", { agent: "coder", task: "x" })), null);
|
|
985
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:new-paper durable workflows" });
|
|
986
|
+
assert.match(blocked(await bare("write", { path: "notes.md" })) ?? "", /needs Clio 0\.6\.3/, "inside a WTF-P action it is");
|
|
987
|
+
await host.hook({ point: "prompt_submit", text: "thanks" });
|
|
988
|
+
// With Clio 0.6.3's facts, only the WTF-P recipes are the desk's business there.
|
|
989
|
+
const facts = withClioFacts(host, folder);
|
|
990
|
+
symlinkSync(os.tmpdir(), path.join(folder, "elsewhere"));
|
|
991
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "coder", task: "x", cwd: "..", intent: { write_roots: ["elsewhere/"] } } } as never)), null);
|
|
992
|
+
assert.match(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "wtfp-section-writer", task: "x" } } as never)) ?? "", /run only inside the WTF-P action/);
|
|
993
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "coder", task: "x" }, dispatch: { kind: "council-of-elders" } } as never)), null, "a plan the desk cannot read is no plan, and this folder is not its to guard");
|
|
994
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: "x.md" }, target: { path: 7 } } as never)), null);
|
|
995
|
+
// Once this Clio has sent facts, a call it sends none for failed in Clio, and an armed action says so.
|
|
996
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:new-paper durable workflows" });
|
|
997
|
+
assert.match(blocked(await bare("write", { path: "notes.md" })) ?? "", /Clio sent no landing for this call/);
|
|
998
|
+
} finally {
|
|
999
|
+
await host.dispose();
|
|
1000
|
+
rmSync(folder, { recursive: true, force: true });
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
/** Loads the desk the way Clio's runtime child does, prints the before_tool verdict for each call, then the result of each desk tool call. */
|
|
1005
|
+
const HARNESS = `
|
|
1006
|
+
import { pathToFileURL } from "node:url";
|
|
1007
|
+
const [entry, workspace, calls, toolCalls = "[]"] = process.argv.slice(2);
|
|
1008
|
+
const hooks = new Map();
|
|
1009
|
+
const tools = new Map();
|
|
1010
|
+
const noop = () => {};
|
|
1011
|
+
const kv = () => {
|
|
1012
|
+
const map = new Map();
|
|
1013
|
+
return {
|
|
1014
|
+
async get(key) { return map.has(key) ? { value: structuredClone(map.get(key)), version: 1 } : { value: undefined, version: 0 }; },
|
|
1015
|
+
async set(key, value) { map.set(key, structuredClone(value)); return { ok: true }; },
|
|
1016
|
+
async delete(key) { map.delete(key); },
|
|
1017
|
+
async keys() { return [...map.keys()]; },
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
const ctx = { snapshot: { plugin: null, workspace, sessionId: "s", generation: 1, mode: "interactive", activeWorkspace: null }, requestId: "r", signal: new AbortController().signal, options: {}, state: kv(), store: kv() };
|
|
1021
|
+
const module = await import(pathToFileURL(entry).href);
|
|
1022
|
+
module.default({ handle: noop, action: noop, tool: (name, handler) => tools.set(name, handler), interview: noop, on: noop, hook: (point, handler) => hooks.set(point, handler) });
|
|
1023
|
+
const verdicts = [];
|
|
1024
|
+
for (const call of JSON.parse(calls)) {
|
|
1025
|
+
const out = await hooks.get("before_tool")({ point: "before_tool", turnId: "t1", ...call }, ctx);
|
|
1026
|
+
verdicts.push(out?.effects?.find((effect) => effect.kind === "block_tool")?.reason ?? null);
|
|
1027
|
+
}
|
|
1028
|
+
const results = [];
|
|
1029
|
+
for (const [name, input] of JSON.parse(toolCalls)) {
|
|
1030
|
+
const out = await tools.get(name)(input, ctx);
|
|
1031
|
+
results.push({ isError: out.isError ?? false, text: out.text });
|
|
1032
|
+
}
|
|
1033
|
+
console.log(JSON.stringify(toolCalls === "[]" ? verdicts : { verdicts, results }));
|
|
1034
|
+
`;
|
|
1035
|
+
|
|
1036
|
+
test("under the read and write access Clio grants the desk, it judges every call by the landing and plan Clio sends (W2)", async () => {
|
|
1037
|
+
const workspace = project();
|
|
1038
|
+
const harness = path.join(process.env.TMPDIR as string, `wtfp-host-harness-${process.pid}-${Date.now()}.mjs`);
|
|
1039
|
+
try {
|
|
1040
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
1041
|
+
mkdirSync(path.join(workspace, "notes"));
|
|
1042
|
+
symlinkSync(path.join(workspace, ".planning"), path.join(workspace, "notes/records"));
|
|
1043
|
+
writeFileSync(harness, HARNESS);
|
|
1044
|
+
// The flags Clio 0.6.2 builds from the manifest (runtimePermissionArgs in runtime-process-v2.ts).
|
|
1045
|
+
const declared = /fs: \{ read: \[([^\]]*)\], write: \[([^\]]*)\] \}/u.exec(readFileSync(path.join(ROOT, "clio-coder-extension.yaml"), "utf8"));
|
|
1046
|
+
assert.ok(declared, "the manifest declares its file access");
|
|
1047
|
+
const entries = (list: string): string[] => list.split(",").map((entry) => entry.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
1048
|
+
const directory = (root: string): string => (root.endsWith(path.sep) ? root : `${root}${path.sep}`);
|
|
1049
|
+
const read = entries(declared[1] as string).map((entry) => directory(entry === "workspace" ? workspace : entry === "home" ? homedir() : path.join(workspace, entry)));
|
|
1050
|
+
const write = entries(declared[2] as string).filter((entry) => entry !== "store").map((entry) => directory(path.join(workspace, entry)));
|
|
1051
|
+
const calls: Array<[Json, boolean]> = [
|
|
1052
|
+
[{ tool: "write", args: { path: "paper/introduction.md" } }, true],
|
|
1053
|
+
[{ tool: "write", args: { path: "drafts/introduction.md" } }, true],
|
|
1054
|
+
[{ tool: "write", args: { path: "notes/records/config.json" } }, true],
|
|
1055
|
+
[{ tool: "write", args: { path: "src/notes.md" } }, false],
|
|
1056
|
+
[{ tool: "dispatch", args: { agent: "coder", task: "x", intent: { write_roots: ["drafts/"] } } }, true],
|
|
1057
|
+
[{ tool: "dispatch", args: { agent: "coder", task: "x", intent: { write_roots: ["src/"] } } }, false],
|
|
1058
|
+
...(existsSync("/proc/self/cwd") ? ([[{ tool: "write", args: { path: "/proc/self/cwd/paper/introduction.md" } }, true]] as Array<[Json, boolean]>) : []),
|
|
1059
|
+
];
|
|
1060
|
+
const run = spawnSync(
|
|
1061
|
+
process.execPath,
|
|
1062
|
+
["--permission", ...[directory(ROOT), harness, ...read].map((root) => `--allow-fs-read=${root}`), ...write.map((root) => `--allow-fs-write=${root}`), harness, path.join(ROOT, "runtime/extension.ts"), workspace, JSON.stringify(calls.map(([call]) => withFacts({ point: "before_tool", ...call }, workspace)))],
|
|
1063
|
+
{ cwd: workspace, encoding: "utf8", timeout: 60000 },
|
|
1064
|
+
);
|
|
1065
|
+
assert.equal(run.status, 0, run.stderr);
|
|
1066
|
+
const verdicts = JSON.parse(run.stdout) as Array<string | null>;
|
|
1067
|
+
calls.forEach(([call, refused], index) => assert.equal(verdicts[index] !== null, refused, `${JSON.stringify(call)}: ${verdicts[index]}`));
|
|
1068
|
+
} finally {
|
|
1069
|
+
rmSync(harness, { force: true });
|
|
1070
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
test("under the write access Clio grants the desk, which refuses every flush, a record write still lands whole", () => {
|
|
1075
|
+
const workspace = project();
|
|
1076
|
+
const harness = path.join(process.env.TMPDIR as string, `wtfp-host-harness-${process.pid}-${Date.now()}.mjs`);
|
|
1077
|
+
try {
|
|
1078
|
+
writeFileSync(harness, HARNESS);
|
|
1079
|
+
const state = read(workspace, ".planning/state.json");
|
|
1080
|
+
const run = spawnSync(
|
|
1081
|
+
process.execPath,
|
|
1082
|
+
[
|
|
1083
|
+
"--permission",
|
|
1084
|
+
...[`${ROOT}${path.sep}`, harness, `${workspace}${path.sep}`].map((root) => `--allow-fs-read=${root}`),
|
|
1085
|
+
`--allow-fs-write=${path.join(workspace, ".planning")}${path.sep}`,
|
|
1086
|
+
harness,
|
|
1087
|
+
path.join(ROOT, "runtime/extension.ts"),
|
|
1088
|
+
workspace,
|
|
1089
|
+
"[]",
|
|
1090
|
+
JSON.stringify([["record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 }]]),
|
|
1091
|
+
],
|
|
1092
|
+
{ cwd: workspace, encoding: "utf8", timeout: 60000 },
|
|
1093
|
+
);
|
|
1094
|
+
assert.equal(run.status, 0, run.stderr);
|
|
1095
|
+
const { results } = JSON.parse(run.stdout) as { results: Array<{ isError: boolean; text: string }> };
|
|
1096
|
+
assert.equal(results[0]?.isError, false, results[0]?.text);
|
|
1097
|
+
assert.deepEqual([read(workspace, ".planning/state.json").phase, read(workspace, ".planning/state.json").revision], ["reviewing", 4]);
|
|
1098
|
+
const leftovers = readdirSync(path.join(workspace, ".planning"), { recursive: true }).map(String).filter((name) => name.endsWith(".partial"));
|
|
1099
|
+
assert.deepEqual(leftovers, [], "no staged file is left behind");
|
|
1100
|
+
} finally {
|
|
1101
|
+
rmSync(harness, { force: true });
|
|
1102
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
test("a manuscript nested under another section's stem is judged by every section it belongs to", () =>
|
|
1107
|
+
withDesk(async (host, workspace) => {
|
|
1108
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
1109
|
+
const [entry] = outline.sections as Json[];
|
|
1110
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [entry, { ...entry, id: "appendix", title: "Appendix" }] });
|
|
1111
|
+
const intro = read(workspace, ".planning/sections/introduction/section.json");
|
|
1112
|
+
put(workspace, ".planning/sections/appendix/section.json", {
|
|
1113
|
+
...intro,
|
|
1114
|
+
id: "appendix",
|
|
1115
|
+
title: "Appendix",
|
|
1116
|
+
artifacts: { plans: [], reviews: [], manuscript: "project://paper/introduction/appendix" },
|
|
1117
|
+
checkpoint_uris: [],
|
|
1118
|
+
});
|
|
1119
|
+
await answer(host, GATE, "protocol-first");
|
|
1120
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1121
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
1122
|
+
assert.match(blocked(await write(host, "paper/introduction/appendix.md")) ?? "", /Appendix cannot be written yet/);
|
|
1123
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1124
|
+
const result = await host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "wtfp-section-writer", task: "Draft." } });
|
|
1125
|
+
const roots = rootsOf(rewriteOf(result));
|
|
1126
|
+
assert.deepEqual(roots, [".planning/sections/introduction/summary.md", "paper/introduction.md"], "no worker root covers the appendix");
|
|
1127
|
+
}, SERVED));
|
|
1128
|
+
|
|
1129
|
+
test("dispatch is judged as Clio parses it, and no worker gets an unbounded or record-covering root (W3)", () =>
|
|
1130
|
+
withDesk(async (host, workspace) => {
|
|
1131
|
+
const dispatch = (args: Json) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args });
|
|
1132
|
+
// Clio trims agent ids and accepts a batch as a JSON string or a single object.
|
|
1133
|
+
for (const args of [
|
|
1134
|
+
{ tasks: [{ agent: "wtfp-section-writer ", task: "Draft." }] },
|
|
1135
|
+
{ tasks: JSON.stringify([{ agent: "wtfp-section-writer", task: "Draft." }]) },
|
|
1136
|
+
{ tasks: { agent: "wtfp-section-writer", task: "Draft." } },
|
|
1137
|
+
{ agent: " wtfp-section-writer", task: "Draft." },
|
|
1138
|
+
])
|
|
1139
|
+
assert.match(blocked(await dispatch(args)) ?? "", /run only inside the WTF-P action/, JSON.stringify(args));
|
|
1140
|
+
// Outside an action, a generic worker must name roots that leave the records and gated manuscripts alone.
|
|
1141
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x" })) ?? "", /intent\.write_roots/);
|
|
1142
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["."] } })) ?? "", /intent\.write_roots/);
|
|
1143
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["paper/"] } })) ?? "", /paper\/introduction\.md/);
|
|
1144
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: [".planning/sections/"] } })) ?? "", /\.planning/);
|
|
1145
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src/"] } })), null);
|
|
1146
|
+
// Every spelling the section's manuscript can take is held, not only the file that exists now.
|
|
1147
|
+
for (const root of ["paper/introduction.tex", "paper/introduction.typ", "paper/introduction", "paper/introduction.v2.md"])
|
|
1148
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: [root] } })) ?? "", /may not change/, root);
|
|
1149
|
+
assert.match(blocked(await dispatch({ apply_winner: { branch: "clio-coder/compete/g/1" } })) ?? "", /cannot see what/);
|
|
1150
|
+
// Clio resolves write roots against a worker's cwd, and fixes a boundary where a root physically leads.
|
|
1151
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", cwd: "paper", intent: { write_roots: ["introduction.md"] } })) ?? "", /cwd/);
|
|
1152
|
+
assert.match(blocked(await dispatch({ tasks: [{ agent: "coder", task: "x", cwd: ".planning", intent: { write_roots: ["checkpoints/"] } }] })) ?? "", /cwd/);
|
|
1153
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", cwd: ".", intent: { write_roots: ["src/"] } })), null);
|
|
1154
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
1155
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["drafts/"] } })) ?? "", /does not lead where it reads/);
|
|
1156
|
+
// An action that declares no file outputs never hands a writer an empty list, which Clio reads as no boundary.
|
|
1157
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1158
|
+
assert.match(blocked(await dispatch({ tasks: [{ agent: "wtfp-section-planner", task: "x" }] })) ?? "", /declares no file outputs/);
|
|
1159
|
+
const reviewer = await dispatch({ tasks: [{ agent: "wtfp-plan-checker", task: "x" }] });
|
|
1160
|
+
assert.equal(blocked(reviewer), null, "a read-only reviewer needs no roots");
|
|
1161
|
+
assert.equal(rewriteOf(reviewer), null, "and is not given an empty list");
|
|
1162
|
+
// Without a named section, a planner would get every section's directory, records included.
|
|
1163
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1164
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section" });
|
|
1165
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-planner", task: "x" })) ?? "", /name the section/);
|
|
1166
|
+
}, SERVED));
|
|
1167
|
+
|
|
1168
|
+
test("changes that loosen what the desk holds wait for the author at the desk", () =>
|
|
1169
|
+
withDesk(async (host, workspace) => {
|
|
1170
|
+
const asks = async (uri: string, file: string, record: Json, expect: Json) => {
|
|
1171
|
+
const before = sha(workspace, file);
|
|
1172
|
+
const result = await host.tool("record", { uri, record, ...expect });
|
|
1173
|
+
assert.equal(result.interview?.id, "confirm-write", `${uri}: ${result.text}`);
|
|
1174
|
+
assert.equal(sha(workspace, file), before, `${uri} was not written before the author answered`);
|
|
1175
|
+
return JSON.stringify(result.interview?.step.intro);
|
|
1176
|
+
};
|
|
1177
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1178
|
+
const section = read(workspace, sectionFile);
|
|
1179
|
+
const artifacts = section.artifacts as Json;
|
|
1180
|
+
assert.match(
|
|
1181
|
+
await asks("project://sections/introduction", sectionFile, { ...section, artifacts: { ...artifacts, manuscript: "project://paper/elsewhere" } }, { expect_sha256: sha(workspace, sectionFile) }),
|
|
1182
|
+
/manuscript/,
|
|
1183
|
+
);
|
|
1184
|
+
assert.match(await asks("project://sections/introduction", sectionFile, { ...section, artifacts: { ...artifacts, plans: [] } }, { expect_sha256: sha(workspace, sectionFile) }), /plan history/);
|
|
1185
|
+
const claim = { id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] };
|
|
1186
|
+
put(workspace, sectionFile, { ...section, claims: [claim] });
|
|
1187
|
+
assert.match(
|
|
1188
|
+
await asks("project://sections/introduction", sectionFile, { ...section, claims: [{ ...claim, evidence_required: false }] }, { expect_sha256: sha(workspace, sectionFile) }),
|
|
1189
|
+
/claim-flush/,
|
|
1190
|
+
);
|
|
1191
|
+
const outlineFile = ".planning/structure/outline.json";
|
|
1192
|
+
const outline = read(workspace, outlineFile);
|
|
1193
|
+
const [entry] = outline.sections as Json[];
|
|
1194
|
+
assert.match(await asks("project://structure/outline", outlineFile, { ...outline, sections: [{ ...entry, id: "intro-renamed" }] }, { expect_revision: 1 }), /introduction/);
|
|
1195
|
+
put(workspace, outlineFile, { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
1196
|
+
assert.match(await asks("project://structure/outline", outlineFile, { ...outline, sections: [{ ...entry, research: { required: false, topics: [] } }] }, { expect_revision: 1 }), /research/);
|
|
1197
|
+
const configFile = ".planning/config.json";
|
|
1198
|
+
const config = read(workspace, configFile);
|
|
1199
|
+
assert.match(
|
|
1200
|
+
await asks("project://config", configFile, { ...config, safety: { ...(config.safety as Json), backup_before_major_edits: false } }, { expect_sha256: sha(workspace, configFile) }),
|
|
1201
|
+
/safety\.backup_before_major_edits/,
|
|
1202
|
+
);
|
|
1203
|
+
put(workspace, configFile, { ...config, interaction_mode: "guided" });
|
|
1204
|
+
assert.match(await asks("project://config", configFile, { ...config, interaction_mode: "standard" }, { expect_sha256: sha(workspace, configFile) }), /guided → standard/);
|
|
1205
|
+
}));
|
|
1206
|
+
|
|
1207
|
+
test("a pending plan gate cannot be retired by briefly linking a decoy plan", () =>
|
|
1208
|
+
withDesk(async (host, workspace) => {
|
|
1209
|
+
await answer(host, GATE, "protocol-first");
|
|
1210
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1211
|
+
const section = read(workspace, sectionFile);
|
|
1212
|
+
const decoy = { ...(section.artifacts as Json), plans: [PLAN_URI, "project://sections/introduction/plans/decoy"] };
|
|
1213
|
+
assert.equal((await host.tool("record", { uri: "project://sections/introduction", record: { ...section, artifacts: decoy }, expect_sha256: sha(workspace, sectionFile) })).isError, undefined);
|
|
1214
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
1215
|
+
await host.tool("record", { uri: `project://checkpoints/${PLAN_GATE}`, record: { ...checkpoint, status: "expired" }, expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) });
|
|
1216
|
+
const restored = await host.tool("record", { uri: "project://sections/introduction", record: section, expect_sha256: sha(workspace, sectionFile) });
|
|
1217
|
+
assert.equal(restored.interview?.id, "confirm-write", "unlinking the decoy rewrites the plan history, so the author is asked");
|
|
1218
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")), "the manuscript still waits on an approved current plan");
|
|
1219
|
+
}));
|
|
1220
|
+
|
|
1221
|
+
test("the author approves a plan under the desk's own label, whatever the checkpoint calls its options", () =>
|
|
1222
|
+
withDesk(async (host, workspace) => {
|
|
1223
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
1224
|
+
const swapped = await host.tool("record", {
|
|
1225
|
+
uri: `project://checkpoints/${PLAN_GATE}`,
|
|
1226
|
+
record: {
|
|
1227
|
+
...checkpoint,
|
|
1228
|
+
options: [
|
|
1229
|
+
{ id: "approve", label: "Send it back for revision", implication: "The plan is rewritten." },
|
|
1230
|
+
{ id: "revise", label: "Approve", implication: "Draft from this plan." },
|
|
1231
|
+
],
|
|
1232
|
+
},
|
|
1233
|
+
expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`),
|
|
1234
|
+
});
|
|
1235
|
+
assert.equal(swapped.isError, undefined, swapped.text);
|
|
1236
|
+
const asked = await host.tool("gate", { checkpoint: PLAN_GATE });
|
|
1237
|
+
const options = asked.interview?.step.questions[0]?.options ?? [];
|
|
1238
|
+
const approve = options.find((option) => option.value === "approve");
|
|
1239
|
+
assert.match(approve?.label ?? "", /^Approve this plan/);
|
|
1240
|
+
assert.ok(!options.some((option) => option.value !== "approve" && /approve/iu.test(option.label)), "no other option may read as approval");
|
|
1241
|
+
}));
|
|
1242
|
+
|
|
1243
|
+
test("a seal counts only in the exact form the desk writes", () =>
|
|
1244
|
+
withDesk(async (host, workspace) => {
|
|
1245
|
+
await answer(host, GATE, "protocol-first");
|
|
1246
|
+
const [name] = readdirSync(path.join(workspace, ".planning/interactions"));
|
|
1247
|
+
const file = `.planning/interactions/${name}`;
|
|
1248
|
+
const interaction = read(workspace, file);
|
|
1249
|
+
const seal = interaction.seal as Json;
|
|
1250
|
+
for (const altered of [{ ...seal, mac: String(seal.mac).toUpperCase() }, { ...seal, method: "none" }]) {
|
|
1251
|
+
put(workspace, file, { ...interaction, seal: altered });
|
|
1252
|
+
assert.notEqual(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested", JSON.stringify(altered));
|
|
1253
|
+
}
|
|
1254
|
+
// Even sealed with this machine's key, only an answer given at the desk's interview counts.
|
|
1255
|
+
const key = Buffer.from(String((await host.store.get("seal-key")).value), "hex");
|
|
1256
|
+
const { seal: _seal, ...body } = interaction;
|
|
1257
|
+
put(workspace, file, resealed({ ...body, channel: "host-prompt" }, key));
|
|
1258
|
+
assert.notEqual(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested", "a host-prompt answer");
|
|
1259
|
+
put(workspace, file, interaction);
|
|
1260
|
+
assert.equal(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested");
|
|
1261
|
+
}));
|
|
1262
|
+
|
|
1263
|
+
test("a sealed answer stands only behind the exact question, option and project it answered", () =>
|
|
1264
|
+
withDesk(async (host, workspace) => {
|
|
1265
|
+
await answer(host, GATE, "protocol-first");
|
|
1266
|
+
const trust = async () => ((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust;
|
|
1267
|
+
assert.equal(await trust(), "attested");
|
|
1268
|
+
const checkpointFile = `.planning/checkpoints/${GATE}.json`;
|
|
1269
|
+
const checkpoint = read(workspace, checkpointFile);
|
|
1270
|
+
const resolution = checkpoint.resolution as Json;
|
|
1271
|
+
put(workspace, checkpointFile, { ...checkpoint, resolution: { ...resolution, selected_option: "workflow-first" } });
|
|
1272
|
+
assert.equal(await trust(), "unattested", "a hand-swapped option");
|
|
1273
|
+
put(workspace, checkpointFile, { ...checkpoint, request: "A question the author never saw." });
|
|
1274
|
+
assert.equal(await trust(), "unattested", "a rewritten question");
|
|
1275
|
+
put(workspace, checkpointFile, checkpoint);
|
|
1276
|
+
const [name] = readdirSync(path.join(workspace, ".planning/interactions"));
|
|
1277
|
+
const interaction = read(workspace, `.planning/interactions/${name}`);
|
|
1278
|
+
const { seal: _seal, ...body } = interaction;
|
|
1279
|
+
const key = Buffer.from(String((await host.store.get("seal-key")).value), "hex");
|
|
1280
|
+
put(workspace, `.planning/interactions/${name}`, resealed({ ...body, project_id: "another-project" }, key));
|
|
1281
|
+
assert.equal(await trust(), "unattested", "an answer sealed for another project");
|
|
1282
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /not observed by this desk/);
|
|
1283
|
+
}));
|
|
1284
|
+
|
|
1285
|
+
test("recovery finishes only a journal of the desk's own record writes", () =>
|
|
1286
|
+
withDesk(async (host, workspace) => {
|
|
1287
|
+
put(workspace, "notes/draft.md", "Unplanned prose.\n");
|
|
1288
|
+
const digest = createHash("sha256").update("Unplanned prose.\n").digest("hex");
|
|
1289
|
+
const before = sha(workspace, "paper/introduction.md");
|
|
1290
|
+
for (const entries of [
|
|
1291
|
+
[{ file: "paper/introduction.md", staging: "notes/draft.md", sha256: digest }],
|
|
1292
|
+
[{ file: ".planning/state.json", staging: "notes/draft.md", sha256: digest }],
|
|
1293
|
+
]) {
|
|
1294
|
+
put(workspace, ".planning/.wtfp-journal.json", { schema: "wtfp.clio-journal/v1", at: AT, entries });
|
|
1295
|
+
assert.match((await host.command("validate")).text, /Set aside a journal/);
|
|
1296
|
+
}
|
|
1297
|
+
assert.equal(sha(workspace, "paper/introduction.md"), before);
|
|
1298
|
+
assert.equal(read(workspace, ".planning/state.json").revision, 3);
|
|
1299
|
+
assert.ok(existsSync(path.join(workspace, "notes/draft.md")));
|
|
1300
|
+
}));
|
|
1301
|
+
|
|
1302
|
+
// --- durability and recovery ---------------------------------------------------------
|
|
1303
|
+
|
|
1304
|
+
test("measure_section counts body words by the desk's one method and commits the section and state together", () =>
|
|
1305
|
+
withDesk(async (host, workspace) => {
|
|
1306
|
+
const measured = await host.tool("measure_section", { section: "introduction" });
|
|
1307
|
+
assert.equal(measured.isError, undefined, measured.text);
|
|
1308
|
+
assert.deepEqual(measured.data, { words: 11, target: 100, file: "paper/introduction.md", total: 11 });
|
|
1309
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").word_count, 11);
|
|
1310
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 11);
|
|
1311
|
+
assert.equal(read(workspace, ".planning/state.json").revision, 4);
|
|
1312
|
+
}));
|
|
1313
|
+
|
|
1314
|
+
test("a failure between paired writes leaves a journal the next write completes; one before the commit point leaves nothing (R2)", () =>
|
|
1315
|
+
withDesk(async (host, workspace) => {
|
|
1316
|
+
process.env.WTFP_DESK_TEST_FAULT = "between-renames";
|
|
1317
|
+
try {
|
|
1318
|
+
const failed = await host.tool("measure_section", { section: "introduction" });
|
|
1319
|
+
assert.equal(failed.isError, true);
|
|
1320
|
+
assert.match(failed.text, /injected fault at between-renames/);
|
|
1321
|
+
assert.match(failed.text, /^Committed; recovery pending: injected fault at between-renames/);
|
|
1322
|
+
} finally {
|
|
1323
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
1324
|
+
}
|
|
1325
|
+
assert.ok(existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1326
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").word_count, 11);
|
|
1327
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 0);
|
|
1328
|
+
const before = tree(workspace);
|
|
1329
|
+
const progress = await host.command("progress");
|
|
1330
|
+
assert.match(progress.text, /interrupted record write awaits recovery/);
|
|
1331
|
+
assert.deepEqual(tree(workspace), before, "progress reads and never repairs");
|
|
1332
|
+
const validated = await host.command("validate");
|
|
1333
|
+
assert.match(validated.text, /Completed an interrupted write of \.planning\/sections\/introduction\/section\.json, \.planning\/state\.json/);
|
|
1334
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 11);
|
|
1335
|
+
assert.ok(!existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1336
|
+
|
|
1337
|
+
process.env.WTFP_DESK_TEST_FAULT = "before-commit";
|
|
1338
|
+
const sectionBefore = sha(workspace, ".planning/sections/introduction/section.json");
|
|
1339
|
+
try {
|
|
1340
|
+
writeFileSync(path.join(workspace, "paper/introduction.md"), "Just four words here.\n");
|
|
1341
|
+
const failed = await host.tool("measure_section", { section: "introduction" });
|
|
1342
|
+
assert.match(failed.text, /injected fault at before-commit/);
|
|
1343
|
+
} finally {
|
|
1344
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
1345
|
+
}
|
|
1346
|
+
assert.equal(sha(workspace, ".planning/sections/introduction/section.json"), sectionBefore);
|
|
1347
|
+
assert.ok(!existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1348
|
+
assert.deepEqual(
|
|
1349
|
+
readdirSync(path.join(workspace, ".planning/sections/introduction")).filter((name) => name.endsWith(".partial")),
|
|
1350
|
+
[],
|
|
1351
|
+
);
|
|
1352
|
+
}));
|
|
1353
|
+
|
|
1354
|
+
test("a fresh process trusts only answers it can verify and reports drift instead of inventing state (L1)", async () => {
|
|
1355
|
+
const workspace = project();
|
|
1356
|
+
let key: unknown;
|
|
1357
|
+
const first = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "first" }), workspace);
|
|
1358
|
+
try {
|
|
1359
|
+
await answer(first, GATE, "protocol-first");
|
|
1360
|
+
await answer(first, PLAN_GATE, "approve");
|
|
1361
|
+
key = (await first.store.get("seal-key")).value;
|
|
1362
|
+
assert.match(String(key), /^[a-f0-9]{64}$/);
|
|
1363
|
+
} finally {
|
|
1364
|
+
await first.dispose();
|
|
1365
|
+
}
|
|
1366
|
+
const resumed = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "resumed" }), workspace);
|
|
1367
|
+
const elsewhere = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "other-machine" }), workspace);
|
|
1368
|
+
try {
|
|
1369
|
+
await resumed.store.set("seal-key", key);
|
|
1370
|
+
assert.equal(blocked(await write(resumed, "paper/introduction.md")), null, "the same machine's key verifies the sealed answers");
|
|
1371
|
+
assert.match(blocked(await write(elsewhere, "paper/introduction.md")) ?? "", /not observed by this desk/);
|
|
1372
|
+
const validated = await resumed.command("validate");
|
|
1373
|
+
assert.match(validated.text, /words-unmeasured/);
|
|
1374
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\nChanged between sessions.\n");
|
|
1375
|
+
assert.match(blocked(await write(resumed, "paper/introduction.md")) ?? "", /plan changed after the author approved it/);
|
|
1376
|
+
} finally {
|
|
1377
|
+
await resumed.dispose();
|
|
1378
|
+
await elsewhere.dispose();
|
|
1379
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
|
|
1383
|
+
// --- simulated lifecycle rehearsal --------------------------------------------------------
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* SIMULATED: every "author" answer below is a scripted interview event, not a
|
|
1387
|
+
* person. This rehearses the desk's bookkeeping across a whole section
|
|
1388
|
+
* lifecycle; it is never evidence that an author decided anything.
|
|
1389
|
+
*/
|
|
1390
|
+
test("SIMULATED rehearsal: initialize, outline, reject then approve a plan, draft through an interruption, review, revise, pause and resume in a fresh process", async () => {
|
|
1391
|
+
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
1392
|
+
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-rehearsal-"));
|
|
1393
|
+
const ID = "rehearsal";
|
|
1394
|
+
const S = "evaluation";
|
|
1395
|
+
let host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin: SERVED, sessionId: "s1" }), workspace);
|
|
1396
|
+
const turn = async (command: string) => {
|
|
1397
|
+
await host.observe({ event: "turn_end", turnId: "t", outcome: "completed", usage: null });
|
|
1398
|
+
const armed = await host.hook({ point: "prompt_submit", text: command });
|
|
1399
|
+
assert.equal(armed.effects?.[0]?.kind, "notify_operator", `${command} did not arm`);
|
|
1400
|
+
};
|
|
1401
|
+
const write = async (uri: string, change: (record: Json | null) => Json) => {
|
|
1402
|
+
const seen = (await host.tool("read_record", { uri })).data as Json;
|
|
1403
|
+
const record = change(seen.exists ? (seen.record as Json) : null);
|
|
1404
|
+
const expect = !seen.exists ? {} : typeof seen.revision === "number" ? { expect_revision: seen.revision } : { expect_sha256: seen.sha256 };
|
|
1405
|
+
const result = await host.tool("record", { uri, record, ...expect });
|
|
1406
|
+
assert.equal(result.isError, undefined, `${uri}: ${result.text}`);
|
|
1407
|
+
};
|
|
1408
|
+
const file = async (relative: string, text: string) => {
|
|
1409
|
+
assert.equal(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: relative } })), null, `writing ${relative} was refused`);
|
|
1410
|
+
put(workspace, relative, text);
|
|
1411
|
+
};
|
|
1412
|
+
const ask = async (checkpoint: string, choice: string) => {
|
|
1413
|
+
const asked = await host.tool("gate", { checkpoint });
|
|
1414
|
+
const done = await host.interview({ id: "gate-one", step: asked.interview?.step.key as string, nav: "next", answers: { choice } });
|
|
1415
|
+
assert.ok("done" in done, `answering ${checkpoint} was asked again`);
|
|
1416
|
+
return done.text;
|
|
1417
|
+
};
|
|
1418
|
+
const checkpoint = (id: string, scope: string, request: string, options: Array<[string, string]>): Json => ({
|
|
1419
|
+
schema: "wtfp.project.checkpoint/v1", id, project_id: ID, kind: "decision", status: "pending", blocking: true,
|
|
1420
|
+
scope_uri: scope, request, options: options.map(([option, label]) => ({ id: option, label, implication: `${label}.` })),
|
|
1421
|
+
resume_action: "write-section", created_at: AT,
|
|
1422
|
+
});
|
|
1423
|
+
const sectionUri = `project://sections/${S}`;
|
|
1424
|
+
try {
|
|
1425
|
+
await turn("/wtfp:new-paper durable workflows");
|
|
1426
|
+
await write("project://manifest", () => ({
|
|
1427
|
+
schema: "wtfp.project.manifest/v1", protocol_version: 1, id: ID, title: "Resilient Checkpoint Coordination",
|
|
1428
|
+
document_type: "research-article", core_argument: "Coordinated incremental checkpoints reduce interruption.",
|
|
1429
|
+
target: { audience: "Systems researchers", word_limit: 120 }, requirements: { must_have: [], should_have: [], out_of_scope: [] },
|
|
1430
|
+
created_at: AT, updated_at: AT,
|
|
1431
|
+
artifacts: { manifest: "project://manifest", config: "project://config", state: "project://state", decisions: "project://decisions", outline: "project://structure/outline", materials: [], manuscripts: [], deliverables: [], archives: [] },
|
|
1432
|
+
}));
|
|
1433
|
+
await write("project://config", () => ({ schema: "wtfp.project.config/v1", project_id: ID, interaction_mode: "standard", depth: "standard", output_format: "markdown", language: "en-US", gates: { confirm_outline: true, confirm_plan: true, confirm_write: true, confirm_review: true, confirm_delivery: true }, workflow: { research: true, plan_validation: true, argument_validation: true, coherence_validation: true }, safety: { destructive_requires_authorization: true, external_publish_requires_authorization: true, backup_before_major_edits: true }, parallelism: { enabled: false, max_workers: 1 } }));
|
|
1434
|
+
await write("project://state", () => ({ schema: "wtfp.project.state/v1", project_id: ID, revision: 0, phase: "initialized", status: "active", current_section_uri: null, progress: { sections_total: 0, sections_complete: 0, word_target: 120, word_count: 0 }, active_checkpoint_uris: [], updated_at: AT }));
|
|
1435
|
+
await write("project://decisions", () => ({ schema: "wtfp.project.decisions/v1", project_id: ID, revision: 0, items: [], updated_at: AT }));
|
|
1436
|
+
const entry = { id: S, title: "Evaluation", goal: "Report the measurements.", argument_role: "evidence", word_target: 120, wave: 1, depends_on: [], claim_ids: [], research: { required: false, topics: [] } };
|
|
1437
|
+
await write("project://structure/outline", () => ({ schema: "wtfp.project.outline/v1", project_id: ID, revision: 0, thesis: "Coordinated incremental checkpoints reduce interruption.", target_words: 120, sections: [entry], updated_at: AT }));
|
|
1438
|
+
|
|
1439
|
+
await turn("/wtfp:create-outline");
|
|
1440
|
+
await write("project://structure/outline", (outline) => ({ ...(outline as Json), sections: [{ ...entry, goal: "Report the synthetic interruption measurements." }] }));
|
|
1441
|
+
await write(sectionUri, () => ({ schema: "wtfp.project.section/v1", id: S, project_id: ID, outline_uri: "project://structure/outline", title: "Evaluation", goal: "Report the synthetic interruption measurements.", status: "not-started", word_target: 120, word_count: 0, wave: 1, depends_on: [], claims: [], artifacts: { plans: [], reviews: [], manuscript: `project://paper/${S}` }, checkpoint_uris: [], validation_uris: [], updated_at: AT }));
|
|
1442
|
+
await write("project://state", (state) => ({ ...(state as Json), phase: "outlining", progress: { ...((state as Json).progress as Json), sections_total: 1 } }));
|
|
1443
|
+
|
|
1444
|
+
await turn(`/wtfp:discuss-section ${S}`);
|
|
1445
|
+
await file(`.planning/sections/${S}/context.md`, "# Context\n\nReport only the supplied synthetic observations.\n");
|
|
1446
|
+
await write("project://checkpoints/framing", () => checkpoint("framing", sectionUri, "Lead with interruption time or recovery coverage?", [["interruption", "Interruption time"], ["coverage", "Recovery coverage"]]));
|
|
1447
|
+
assert.match(await ask("framing", "interruption"), /Recorded the author's answer/);
|
|
1448
|
+
await write(sectionUri, (section) => ({ ...(section as Json), checkpoint_uris: ["project://checkpoints/framing"], artifacts: { ...((section as Json).artifacts as Json), context: `${sectionUri}/context` } }));
|
|
1449
|
+
|
|
1450
|
+
await turn(`/wtfp:plan-section ${S}`);
|
|
1451
|
+
await file(`.planning/sections/${S}/plans/first.md`, "# Plan\n\n1. Report every measurement at once.\n");
|
|
1452
|
+
await write("project://checkpoints/approve-first", () => checkpoint("approve-first", `${sectionUri}/plans/first`, "Approve the evaluation plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
1453
|
+
assert.match(await ask("approve-first", "revise"), /Revise/, "the author's rejection is recorded, not approval");
|
|
1454
|
+
await file(`.planning/sections/${S}/plans/second.md`, "# Plan\n\n1. Lead with interruption time.\n2. Bound every claim to the synthetic workload.\n");
|
|
1455
|
+
await write("project://checkpoints/approve-second", () => checkpoint("approve-second", `${sectionUri}/plans/second`, "Approve the revised evaluation plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
1456
|
+
assert.match(await ask("approve-second", "approve"), /Approve/);
|
|
1457
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "planned", artifacts: { ...((section as Json).artifacts as Json), plans: [`${sectionUri}/plans/second`] } }));
|
|
1458
|
+
await write("project://state", (state) => ({ ...(state as Json), phase: "planning", current_section_uri: sectionUri }));
|
|
1459
|
+
|
|
1460
|
+
await turn(`/wtfp:write-section ${S}`);
|
|
1461
|
+
assert.equal((((await host.tool("readiness", { section: S })).data) as Json).ready, true);
|
|
1462
|
+
const dispatched = await host.hook({ point: "before_tool", tool: "dispatch", turnId: "t", args: { agent: "wtfp-section-writer", task: "Draft the evaluation." } });
|
|
1463
|
+
assert.ok(dispatched.effects?.some((effect) => effect.kind === "rewrite_tool_input"), "the writer is dispatched with confined roots");
|
|
1464
|
+
await file(`paper/${S}.md`, "# Evaluation\n\nCoordinated incremental checkpoints reduced measured interruption in the synthetic workload.\n");
|
|
1465
|
+
process.env.WTFP_DESK_TEST_FAULT = "between-renames";
|
|
1466
|
+
try {
|
|
1467
|
+
assert.match((await host.tool("measure_section", { section: S })).text, /injected fault/);
|
|
1468
|
+
} finally {
|
|
1469
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
1470
|
+
}
|
|
1471
|
+
assert.match((await host.command("validate")).text, /Completed an interrupted write/);
|
|
1472
|
+
await file(`.planning/sections/${S}/summary.md`, "Drafted from the second plan; eleven body words.\n");
|
|
1473
|
+
await write("project://manifest", (manifest) => ({ ...(manifest as Json), artifacts: { ...((manifest as Json).artifacts as Json), manuscripts: [`project://paper/${S}`] } }));
|
|
1474
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "reviewing", artifacts: { ...((section as Json).artifacts as Json), summary: `${sectionUri}/summary` } }));
|
|
1475
|
+
|
|
1476
|
+
await turn(`/wtfp:review-section ${S}`);
|
|
1477
|
+
await file(`.planning/sections/${S}/reviews/first.md`, "# Review\n\nThe sentence needs the workload size.\n");
|
|
1478
|
+
await write("project://validations/review-first", () => ({ schema: "wtfp.project.validation/v1", id: "review-first", project_id: ID, subject_uri: sectionUri, validator_role: "section-reviewer", action_id: "review-section", status: "issues-found", checks: [{ id: "scope", status: "failed", summary: "Workload size is missing.", evidence: ["paper/evaluation.md"] }], issues: [{ severity: "error", summary: "State the workload size." }], next_actions: [{ action: "plan-revision", reason: "One error to fix." }], effects_applied: [], executed_at: AT }));
|
|
1479
|
+
await write(sectionUri, (section) => ({ ...(section as Json), validation_uris: ["project://validations/review-first"], artifacts: { ...((section as Json).artifacts as Json), reviews: [`${sectionUri}/reviews/first`] } }));
|
|
1480
|
+
|
|
1481
|
+
await turn(`/wtfp:plan-revision ${S}`);
|
|
1482
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `.planning/sections/${S}/plans/second.md` } })), "the approved plan cannot be edited in place");
|
|
1483
|
+
await file(`.planning/sections/${S}/plans/revision.md`, "# Revision plan\n\n1. Add the workload size to the measured sentence.\n");
|
|
1484
|
+
await write("project://checkpoints/approve-revision", () => checkpoint("approve-revision", `${sectionUri}/plans/revision`, "Approve the revision plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
1485
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), "plan-revision never writes the manuscript");
|
|
1486
|
+
assert.match(await ask("approve-revision", "approve"), /Approve/);
|
|
1487
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "writing", artifacts: { ...((section as Json).artifacts as Json), plans: [`${sectionUri}/plans/second`, `${sectionUri}/plans/revision`] } }));
|
|
1488
|
+
|
|
1489
|
+
await turn(`/wtfp:write-section ${S}`);
|
|
1490
|
+
await file(`paper/${S}.md`, "# Evaluation\n\nIn the synthetic 512-node workload, coordinated incremental checkpoints reduced measured interruption.\n");
|
|
1491
|
+
assert.equal((await host.tool("measure_section", { section: S })).isError, undefined);
|
|
1492
|
+
|
|
1493
|
+
await turn("/wtfp:pause-writing");
|
|
1494
|
+
await file(`.planning/sections/${S}/handoff.md`, "Resume by verifying the revised evaluation.\n");
|
|
1495
|
+
await write("project://checkpoints/resume", () => ({ ...checkpoint("resume", sectionUri, "Which action resumes the work?", [["verify", "Verify the section"], ["review", "Review again"]]), kind: "human-action", resume_action: "verify-work" }));
|
|
1496
|
+
await write(sectionUri, (section) => ({ ...(section as Json), checkpoint_uris: ["project://checkpoints/framing", "project://checkpoints/resume"], artifacts: { ...((section as Json).artifacts as Json), handoff: `${sectionUri}/handoff` } }));
|
|
1497
|
+
await write("project://state", (state) => ({ ...(state as Json), status: "paused", phase: "writing", active_checkpoint_uris: ["project://checkpoints/resume"] }));
|
|
1498
|
+
|
|
1499
|
+
// A fresh process: no session state, the same machine's store.
|
|
1500
|
+
const key = (await host.store.get("seal-key")).value;
|
|
1501
|
+
await host.dispose();
|
|
1502
|
+
host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin: SERVED, sessionId: "s2" }), workspace);
|
|
1503
|
+
await host.store.set("seal-key", key);
|
|
1504
|
+
const progress = await host.command("progress");
|
|
1505
|
+
assert.match(progress.text, /evaluation: writing .* plan approved/);
|
|
1506
|
+
assert.match(progress.text, /Next: \/wtfp:check-todos \(Gate waiting on you: Which action resumes the work\?\)/);
|
|
1507
|
+
await turn("/wtfp:resume-writing");
|
|
1508
|
+
assert.match(await ask("resume", "verify"), /Verify the section/);
|
|
1509
|
+
await write("project://state", (state) => ({ ...(state as Json), status: "active" }));
|
|
1510
|
+
const validated = await host.command("validate");
|
|
1511
|
+
assert.doesNotMatch(validated.text, /^(blocker|error) /m, validated.text);
|
|
1512
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), "resume-writing declares no manuscript output");
|
|
1513
|
+
await host.observe({ event: "turn_end", turnId: "t", outcome: "completed", usage: null });
|
|
1514
|
+
assert.equal((((await host.tool("readiness", { section: S })).data) as Json).ready, true);
|
|
1515
|
+
assert.equal(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), null, "the approved revision still authorizes the manuscript");
|
|
1516
|
+
const decisions = interactions(workspace).map((entry) => `${entry.subject_uri}:${entry.outcome}:${entry.selected_option ?? ""}`).sort();
|
|
1517
|
+
assert.deepEqual(decisions, [
|
|
1518
|
+
"project://checkpoints/approve-first:selected:revise",
|
|
1519
|
+
"project://checkpoints/approve-revision:selected:approve",
|
|
1520
|
+
"project://checkpoints/approve-second:selected:approve",
|
|
1521
|
+
"project://checkpoints/framing:selected:interruption",
|
|
1522
|
+
"project://checkpoints/resume:selected:verify",
|
|
1523
|
+
]);
|
|
1524
|
+
} finally {
|
|
1525
|
+
await host.dispose();
|
|
1526
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
|
|
1530
|
+
// --- the desk itself -------------------------------------------------------------------
|
|
1531
|
+
|
|
1532
|
+
test("the desk enters with its four regions and clears its ambient UI when left in a folder with no project", async () => {
|
|
1533
|
+
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
1534
|
+
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-empty-"));
|
|
1535
|
+
const host = withClioFacts(await createExtensionTestHost(ROOT, { workspace }), workspace);
|
|
1536
|
+
try {
|
|
1537
|
+
const entered = await host.command("desk");
|
|
1538
|
+
assert.deepEqual(entered.workspace, { enter: "desk" });
|
|
1539
|
+
assert.deepEqual(Object.keys(entered.regions ?? {}), ["header", "board", "rail", "footer"]);
|
|
1540
|
+
assert.match(JSON.stringify(entered.band), /new-paper/);
|
|
1541
|
+
const left = await host.observe({ event: "workspace_leave", workspace: "desk" });
|
|
1542
|
+
assert.deepEqual(left, { text: "", status: null, band: null, islands: null });
|
|
1543
|
+
assert.ok(!existsSync(path.join(workspace, ".planning")), "drawing the desk creates nothing");
|
|
1544
|
+
} finally {
|
|
1545
|
+
await host.dispose();
|
|
1546
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1550
|
+
test("without its plugin the desk names only its own commands and never a /wtfp: prompt", () =>
|
|
1551
|
+
withDesk(async (host, workspace) => {
|
|
1552
|
+
const before = statSync(path.join(workspace, ".planning/state.json")).mtimeMs;
|
|
1553
|
+
const outputs: unknown[] = [];
|
|
1554
|
+
for (const name of ["desk", "progress", "help", "checkpoints", "validate"]) outputs.push(await host.command(name));
|
|
1555
|
+
for (const id of ["next", "help"]) outputs.push(await host.action(id));
|
|
1556
|
+
outputs.push(await host.action("section", "introduction"));
|
|
1557
|
+
outputs.push(await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" }));
|
|
1558
|
+
outputs.push(await write(host, "src/notes.md"));
|
|
1559
|
+
await host.hook({ point: "prompt_submit", text: "plain text" });
|
|
1560
|
+
outputs.push(await write(host, "paper/introduction.md"));
|
|
1561
|
+
outputs.push(await host.observe({ event: "session_open", reason: "startup" }));
|
|
1562
|
+
const emitted = JSON.stringify(outputs);
|
|
1563
|
+
assert.doesNotMatch(emitted, /\/wtfp:/);
|
|
1564
|
+
assert.match(emitted, /\/ext:wtfp:check-todos/);
|
|
1565
|
+
assert.match(emitted, /needs the WTF-P plugin|not installed and enabled/);
|
|
1566
|
+
assert.equal(statSync(path.join(workspace, ".planning/state.json")).mtimeMs, before);
|
|
1567
|
+
}));
|