feat: complete llm sourcegen plan
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
You are generating a CASAN SRS artifact.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Preserve FR-01 through FR-05 exactly.
|
||||
- Include Purpose, Scope, Functional Requirements, Non Functional Requirements, and Metrics.
|
||||
- Do not include secrets or policy-bypass instructions.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating a CASAN Business Design artifact.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Preserve SCR-00 through SCR-04 exactly.
|
||||
- Include Screen Layout and API Boundary sections.
|
||||
- Keep frontend/backend boundaries concrete.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating a CASAN feature specification.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Preserve FR-01 through FR-05 exactly.
|
||||
- Include Requirements, Acceptance Criteria, role-filtering, validation rules, and Source Trace.
|
||||
- Do not choose implementation details beyond what is required to make behavior testable.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating a CASAN implementation plan.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Include Backend Modules, Tests, Build, and any requested retry-loop criteria.
|
||||
- When asked for the final plan, include Golden regression test and Rollback strategy verbatim.
|
||||
- Keep the plan aligned to the existing NestJS/Prisma/SQLite/React/Vite stack.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating a CASAN detail design artifact.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Include Backend Design, Authorization, and Progress Calculation sections.
|
||||
- Reference concrete services/controllers only when grounded in the architecture.
|
||||
- Preserve role-boundary behavior for employee, manager, and admin.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating CASAN test cases.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Preserve TC-01 through TC-06 exactly.
|
||||
- Cover login, employee isolation, manager visibility, invalid objective payload, progress update, and golden drift.
|
||||
- Keep tests executable by the existing backend/frontend test stack.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,24 @@
|
||||
You are generating CASAN implementation tasks.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Include Backend, Frontend, tests, and Golden regression work.
|
||||
- Keep tasks traceable to the implementation plan and acceptance criteria.
|
||||
- Do not mark unrelated future work as complete.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -0,0 +1,25 @@
|
||||
You are generating a CASAN implementation draft.
|
||||
|
||||
Rules:
|
||||
- Output markdown only.
|
||||
- Include Backend Source, Frontend Source, and Acceptance Gate sections.
|
||||
- Reference concrete source files and tests.
|
||||
- State clearly that this draft is not accepted until STEP12 test PASS.
|
||||
- Do not include shell commands that bypass harness policy.
|
||||
|
||||
Feature: {{featureId}}
|
||||
Module: {{moduleId}}
|
||||
Step: {{stepId}}
|
||||
Artifact: {{title}}
|
||||
|
||||
Extra instructions:
|
||||
{{extraInstructions}}
|
||||
|
||||
Requirement:
|
||||
{{requirement}}
|
||||
|
||||
Architecture:
|
||||
{{architecture}}
|
||||
|
||||
Reference structure:
|
||||
{{templateContent}}
|
||||
@@ -37,15 +37,49 @@ cat > "$WORK/.specify/scripts/bash/model-router.sh" <<'EOF'
|
||||
set -euo pipefail
|
||||
prompt_file="$1"
|
||||
out_json="$2"
|
||||
if grep -q "Business Design" "$prompt_file"; then
|
||||
cat > "$out_json" <<'JSON'
|
||||
{"text":"# Model Generated BD\n\n## Screen Layout\n- SCR-00 Login\n- SCR-01 Dashboard\n- SCR-02 Detail\n- SCR-03 Create Objective\n- SCR-04 Key Result Detail\n\n## API Boundary\nFrontend calls backend through src/lib/api.ts.\n","input_tokens":21,"output_tokens":34,"total_tokens":55}
|
||||
JSON
|
||||
else
|
||||
cat > "$out_json" <<'JSON'
|
||||
{"text":"# Model Generated SRS\n\n## Functional Requirements\n- FR-01 Login\n- FR-02 Create Objective\n- FR-03 Create Key Result\n- FR-04 Update Progress\n- FR-05 Dashboard\n\n## Non Functional Requirements\nAuthentication required.\n","input_tokens":20,"output_tokens":30,"total_tokens":50}
|
||||
JSON
|
||||
fi
|
||||
step="${CASAN_STEP_NAME:-unknown}"
|
||||
case "$step" in
|
||||
02-bd)
|
||||
text="# Model Generated BD\n\n## Screen Layout\n- SCR-00 Login\n- SCR-01 Dashboard\n- SCR-02 Detail\n- SCR-03 Create Objective\n- SCR-04 Key Result Detail\n\n## API Boundary\nFrontend calls backend through src/lib/api.ts.\n"
|
||||
;;
|
||||
03-spec)
|
||||
text="# Model Generated Spec\n\n## Requirements\n- FR-01 Login\n- FR-02 Create Objective\n- FR-03 Create Key Result\n- FR-04 Update Progress\n- FR-05 Dashboard\n\n## Acceptance Criteria\nEmployee isolation and manager visibility are testable.\n"
|
||||
;;
|
||||
05-plan)
|
||||
text="# Model Generated Plan\n\n## Backend Modules\nauth, users, objectives, key-results.\n\n## Tests\nBackend service tests and e2e tests.\n\n## Golden regression test\nCompare manager objective list with golden fixture.\n\n## Rollback strategy\nUse rollback-manager.sh checkpoints before overwrite.\n\n## Build\nRun npm test and npm run build.\n"
|
||||
;;
|
||||
07-dd)
|
||||
text="# Model Generated DD\n\n## Backend Design\nControllers call services and PrismaService.\n\n## Authorization\nEmployees only access owned objectives; managers/admins read all.\n\n## Progress Calculation\nProgress updates write ProgressUpdate and recalculate objective status.\n"
|
||||
;;
|
||||
08-testkit)
|
||||
text="# Model Generated Test Cases\n\n- TC-01 login rejects wrong password.\n- TC-02 employee list returns only own objectives.\n- TC-03 manager list returns all seeded objectives.\n- TC-04 invalid objective payload returns 400.\n- TC-05 progress patch updates a key result.\n- TC-06 golden manager objective response fails on drift.\n"
|
||||
;;
|
||||
09-tasks)
|
||||
text="# Model Generated Tasks\n\n- [X] Backend auth module with JWT and bcrypt.\n- [X] Frontend dashboard and detail pages.\n- [X] Backend and frontend tests.\n- [X] Golden regression evidence.\n"
|
||||
;;
|
||||
10-implement)
|
||||
text="# Model Generated Implementation Draft\n\n## Backend Source\n- backend/src/auth/auth.service.ts\n- backend/src/objectives/objectives.service.ts\n\n## Frontend Source\n- frontend/src/lib/api.ts\n- frontend/src/pages/DashboardPage.tsx\n\n## Acceptance Gate\nThis draft is not accepted until STEP12 test PASS.\n"
|
||||
;;
|
||||
*)
|
||||
text="# Model Generated SRS\n\n## Functional Requirements\n- FR-01 Login\n- FR-02 Create Objective\n- FR-03 Create Key Result\n- FR-04 Update Progress\n- FR-05 Dashboard\n\n## Non Functional Requirements\nAuthentication required.\n"
|
||||
;;
|
||||
esac
|
||||
python3 - "$out_json" "$text" <<'PY'
|
||||
import json, sys
|
||||
out, text = sys.argv[1], sys.argv[2]
|
||||
open(out, "w", encoding="utf-8").write(json.dumps({
|
||||
"timestamp": "2026-07-09T00:00:00Z",
|
||||
"text": text,
|
||||
"model_id": "mock:sourcegen",
|
||||
"role": "generate",
|
||||
"route": "mock:primary",
|
||||
"input_tokens": 21,
|
||||
"output_tokens": 34,
|
||||
"total_tokens": 55,
|
||||
"latency_ms": 1,
|
||||
"temperature": 0.2
|
||||
}) + "\n")
|
||||
PY
|
||||
EOF
|
||||
chmod +x "$WORK/.specify/scripts/bash/model-router.sh"
|
||||
|
||||
@@ -77,6 +111,89 @@ else
|
||||
fail "model generated BD was not accepted"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-spec.md" node scripts/casan-step.mjs 03-spec 1 >/dev/null
|
||||
)
|
||||
if grep -q "Model Generated Spec" "$WORK/docs/output/specs/001-okr-web-app/spec.md" \
|
||||
&& grep -q "source=model" "$WORK/docs/output/output_logs/001-okr-web-app/reports/03-spec-report.md"; then
|
||||
pass "source-gen wave B accepts model generated spec"
|
||||
else
|
||||
fail "model generated spec was not accepted"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-plan1.md" node scripts/casan-step.mjs 05-plan 1 >/dev/null
|
||||
CASAN_OUTPUT="$WORK/out-reviewplan1.md" node scripts/casan-step.mjs 06-reviewplan 1 >/dev/null
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-plan2.md" node scripts/casan-step.mjs 05-plan 2 >/dev/null
|
||||
CASAN_OUTPUT="$WORK/out-reviewplan2.md" node scripts/casan-step.mjs 06-reviewplan 2 >/dev/null
|
||||
)
|
||||
if grep -q "verdict: REJECTED" "$WORK/out-reviewplan1.md" \
|
||||
&& grep -q "verdict: APPROVED" "$WORK/out-reviewplan2.md" \
|
||||
&& grep -q "source=model" "$WORK/docs/output/output_logs/001-okr-web-app/reports/05-plan-report-attempt-2.md"; then
|
||||
pass "source-gen wave B preserves review-plan reject then retry loop"
|
||||
else
|
||||
fail "plan review loop did not reject then approve"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-dd.md" node scripts/casan-step.mjs 07-dd 1 >/dev/null
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-testkit.md" node scripts/casan-step.mjs 08-testkit 1 >/dev/null
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-tasks.md" node scripts/casan-step.mjs 09-tasks 1 >/dev/null
|
||||
)
|
||||
if grep -q "Model Generated DD" "$WORK/docs/output/ipa-docs/dd/dd-mod01-okr-management.md" \
|
||||
&& grep -q "Model Generated Test Cases" "$WORK/docs/output/ipa-docs/testcase/testcase-mod01-okr-management.md" \
|
||||
&& grep -q "Model Generated Tasks" "$WORK/docs/output/specs/001-okr-web-app/tasks.md"; then
|
||||
pass "source-gen wave C accepts model generated dd testkit and tasks"
|
||||
else
|
||||
fail "wave C model artifacts were not accepted"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_GEN_MODE=model CASAN_OUTPUT="$WORK/out-impl.md" node scripts/casan-step.mjs 10-implement 1 >/dev/null
|
||||
)
|
||||
if grep -q "Model Generated Implementation Draft" "$WORK/docs/output/specs/001-okr-web-app/implementation.md" \
|
||||
&& [[ ! -f "$WORK/docs/output/specs/001-okr-web-app/implementation.accepted.json" ]]; then
|
||||
pass "source-gen wave D creates implementation draft without accepting before tests"
|
||||
else
|
||||
fail "implementation draft acceptance gate was bypassed"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_SOURCEGEN_TEST_CMD='printf "unit tests pass\n"' CASAN_OUTPUT="$WORK/out-runtests-pass.md" node scripts/casan-step.mjs 12-runtests 1 >/dev/null
|
||||
)
|
||||
if grep -q "verdict: PASS" "$WORK/out-runtests-pass.md" \
|
||||
&& grep -q '"accepted": true' "$WORK/docs/output/specs/001-okr-web-app/implementation.accepted.json"; then
|
||||
pass "source-gen wave D accepts implementation only after STEP12 test pass"
|
||||
else
|
||||
fail "STEP12 did not accept passing implementation"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$WORK" || exit 1
|
||||
CASAN_SOURCEGEN_TEST_CMD='exit 9' CASAN_OUTPUT="$WORK/out-runtests-fail.md" node scripts/casan-step.mjs 12-runtests 1 >/dev/null
|
||||
)
|
||||
if grep -q "verdict: FAIL" "$WORK/out-runtests-fail.md" \
|
||||
&& [[ ! -f "$WORK/docs/output/specs/001-okr-web-app/implementation.accepted.json" ]]; then
|
||||
pass "source-gen wave D refuses implementation when STEP12 test fails"
|
||||
else
|
||||
fail "STEP12 accepted failing implementation"
|
||||
fi
|
||||
|
||||
if grep -q '"harness":"H5-sourcegen-audit"' "$WORK/.specify/logs/audit/sourcegen.jsonl" \
|
||||
&& grep -q '"prompt_sha256"' "$WORK/.specify/logs/audit/sourcegen.jsonl" \
|
||||
&& grep -q '"model_id":"mock:sourcegen"' "$WORK/.specify/logs/audit/sourcegen.jsonl" \
|
||||
&& grep -q '"harness":"H6-sourcegen-telemetry"' "$WORK/.specify/logs/level5/sourcegen-provider-usage.jsonl" \
|
||||
&& grep -q '"total_tokens":55' "$WORK/.specify/logs/level5/sourcegen-provider-usage.jsonl"; then
|
||||
pass "source-gen records prompt model and tokens into audit and telemetry"
|
||||
else
|
||||
fail "source-gen audit or telemetry is missing prompt/model/token evidence"
|
||||
fi
|
||||
|
||||
cat > "$WORK/.specify/scripts/bash/artifact-scan.sh" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
exit 2
|
||||
|
||||
Reference in New Issue
Block a user