-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(templates): stop propose from skipping the specs artifact #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clay-good
wants to merge
11
commits into
main
Choose a base branch
from
fix/propose-includes-specs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6ea91d8
fix(templates): stop propose from skipping the specs artifact
clay-good 6c02889
fix(templates): sweep for unwritten artifacts instead of gating on bl…
clay-good a8bab6d
fix(templates): make the ready sweep repeat and drop ambiguous wording
clay-good 7e31d8c
fix(templates): allow skipping only artifacts the schema marks condit…
clay-good 18a6c12
fix(templates): terminate the sweep when only skipped artifacts remain
clay-good 30d39c6
fix(templates): report required artifacts, not "all", on completion
clay-good bb1d33a
fix(templates): scope the artifact loop to the apply dependency closure
clay-good 5a95821
fix(status): expose requires edges so propose can compute the require…
clay-good 0457058
test(artifact-workflow): assert the new requires edge in status JSON …
clay-good c90dea9
fix(templates): retitle the create step off "apply-ready"; doc drift
clay-good c259a6f
chore(changeset): patch bump for propose specs fix and status --json …
clay-good File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { | ||
| getOpsxProposeSkillTemplate, | ||
| getOpsxProposeCommandTemplate, | ||
| getFfChangeSkillTemplate, | ||
| getOpsxFfCommandTemplate, | ||
| } from '../../../src/core/templates/skill-templates.js'; | ||
| import { loadSchema } from '../../../src/core/artifact-graph/schema.js'; | ||
|
|
||
| const skill = getOpsxProposeSkillTemplate(); | ||
| const command = getOpsxProposeCommandTemplate(); | ||
|
|
||
| // Both delivery surfaces carry the same body; every assertion runs against each. | ||
| const proposeBodies: Array<[string, string]> = [ | ||
| ['propose skill', skill.instructions], | ||
| ['propose command', command.content], | ||
| ]; | ||
|
|
||
| // ff runs the identical artifact loop, so it needs the identical guard. | ||
| const loopBodies: Array<[string, string]> = [ | ||
| ...proposeBodies, | ||
| ['ff skill', getFfChangeSkillTemplate().instructions], | ||
| ['ff command', getOpsxFfCommandTemplate().content], | ||
| ]; | ||
|
|
||
| const repoRoot = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '../../..'); | ||
| const defaultSchema = loadSchema(path.join(repoRoot, 'schemas', 'spec-driven', 'schema.yaml')); | ||
|
|
||
| const READY_GUARD = 'Before stopping, sweep for artifacts still `ready` and repeat until none remain'; | ||
| const STOP_CONDITION = 'Stop when all `applyRequires` artifacts are done'; | ||
|
|
||
| /** The opening list that tells the agent which artifacts propose will produce. */ | ||
| function artifactPreamble(body: string): string { | ||
| const start = body.indexOf("I'll create a change with"); | ||
| const end = body.indexOf('When ready to implement'); | ||
| expect(start).toBeGreaterThanOrEqual(0); | ||
| expect(end).toBeGreaterThan(start); | ||
| return body.slice(start, end); | ||
| } | ||
|
|
||
| describe('propose templates', () => { | ||
| // Issue #788/#1260: the preamble advertised proposal/design/tasks only, so | ||
| // agents treated specs as optional and produced changes with no spec at all. | ||
| it('advertises every artifact the default schema defines (#788, #1260)', () => { | ||
| const ids = defaultSchema.artifacts.map(artifact => artifact.id); | ||
| expect(ids).toContain('specs'); | ||
|
|
||
| for (const [label, body] of proposeBodies) { | ||
| const preamble = artifactPreamble(body); | ||
| for (const id of ids) { | ||
| expect(preamble, `${label} preamble is missing the "${id}" artifact`).toContain(id); | ||
| } | ||
| expect(preamble, label).toContain('specs/<capability>/spec.md'); | ||
| } | ||
| }); | ||
|
|
||
| it('marks the spec as a delta inside the change directory, not the main spec', () => { | ||
| for (const [label, body] of proposeBodies) { | ||
| const preamble = artifactPreamble(body); | ||
| expect(preamble, label).toContain( | ||
| 'a delta spec inside the change directory, not the main spec' | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| it('presents the artifact list as schema-derived, not fixed', () => { | ||
| for (const [label, body] of proposeBodies) { | ||
| const preamble = artifactPreamble(body); | ||
| expect(preamble, label).toContain('the artifacts your schema defines'); | ||
| expect(preamble, label).toContain('default spec-driven schema'); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe('artifact loop guards (propose and ff)', () => { | ||
| // `status` is file-existence based (detectCompleted), so writing tasks.md before | ||
| // specs flips tasks to done and satisfies the applyRequires stop condition with | ||
| // specs never created. The guard is a stop-time sweep for leftover `ready` | ||
| // artifacts. It deliberately does NOT forbid writing a `blocked` artifact: | ||
| // tasks is blocked on design too, and docs/concepts.md states dependencies are | ||
| // enablers, not gates ("You can skip design if you don't need it") — forbidding | ||
| // it would deadlock propose for every change that skips design. | ||
| it('sweeps for leftover ready artifacts before stopping (#788, #1260)', () => { | ||
| for (const [label, body] of loopBodies) { | ||
| expect(body, label).toContain(READY_GUARD); | ||
| expect(body, label).toContain('Create every remaining `ready` artifact'); | ||
| } | ||
| }); | ||
|
|
||
| // A required artifact (specs) must not be skippable: `openspec validate` | ||
| // rejects a change with no deltas. The only machine-readable signal for | ||
| // "optional" is the artifact's own instruction text — spec-driven's design | ||
| // says "create only if any apply", specs says nothing of the kind — so the | ||
| // skip permission is anchored there rather than granted unconditionally. | ||
| it('permits skipping only artifacts their own instruction marks conditional', () => { | ||
| for (const [label, body] of loopBodies) { | ||
| expect(body, label).toContain( | ||
| 'skip one only when its own `instruction` says it is conditional' | ||
| ); | ||
| // No unconditional "or just say you skipped it" escape hatch. | ||
| expect(body, label).not.toMatch(/or tell the user which one you are skipping/i); | ||
| } | ||
| }); | ||
|
|
||
| it('never forbids writing a blocked artifact, which would deadlock on optional design', () => { | ||
| // Property, not the one sentence the rejected first attempt used: any | ||
| // rewording that prohibits writing blocked artifacts reintroduces the | ||
| // deadlock, so match the shape rather than the exact string. | ||
| for (const [label, body] of loopBodies) { | ||
| expect(body, label).not.toMatch(/(never|do not|don't)\s+(write|create)[^.\n]{0,60}blocked/i); | ||
| expect(body, label).not.toMatch(/only\s+(write|create)[^.\n]{0,60}\bready\b/i); | ||
| } | ||
| }); | ||
|
|
||
| it('places the guard before the stop condition it protects', () => { | ||
| for (const [label, body] of loopBodies) { | ||
| const guardAt = body.indexOf(READY_GUARD); | ||
| const stopAt = body.indexOf(STOP_CONDITION); | ||
| // Both must exist; indexOf returning -1 must not silently satisfy the order. | ||
| expect(guardAt, `${label} is missing the ready-sweep guard`).toBeGreaterThan(-1); | ||
| expect(stopAt, `${label} is missing the stop condition`).toBeGreaterThan(-1); | ||
| expect(guardAt, label).toBeLessThan(stopAt); | ||
| } | ||
| }); | ||
|
|
||
| // The specs artifact `generates` a glob (specs/**/*.md), so an agent told only | ||
| // to "write it to resolvedOutputPath" would create a directory named `**`. | ||
| it('tells the agent how to resolve a glob output path', () => { | ||
| for (const [label, body] of loopBodies) { | ||
| expect(body, label).toContain( | ||
| 'If `resolvedOutputPath` is a glob pattern, choose the concrete file path' | ||
| ); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.