feat(honesty): claims-need-evidence kernel, no_claim card field, CEO value test, implementer dispatch rules, ACCEPTANCE_EDITED, Honest Work ethos

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-10 16:40:21 +00:00
1 parent 3c8a65c36b
commit e5b8a65cf3
81 files changed
+953 -257

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
/**
* {{IMPLEMENTER_DISPATCH_RULES}} — rules for an implementing child agent.
*
* docs/designs/HONEST_WORK_GATE_INTEGRITY.md W7. Rendered into /spec's issue
* body template (the archived spec is the prompt `/spec --execute` pipes to
* `claude -p`, so the rules travel inside it) and into /ship Step 7's
* test-generation child prompt, before its LAST-line JSON protocol. One
* constant so the two cannot drift. The child's JSON contracts are untouched:
* gate-edit disclosure uses the prose the protocols already permit before the
* JSON line. test/dispatch-rules.test.ts pins the rendering sites.
*/
export const IMPLEMENTER_DISPATCH_RULES_HEADING = 'Rules for the implementing agent';
export const IMPLEMENTER_DISPATCH_RULES_ITEMS = [
'Acceptance criteria are the `protects / fails_when / no_claim` profile of each test: the observable it protects, the wrong result it rejects, and what green does not prove. Never "make the tests pass".',
'Real code and real tests land in the same change; a placeholder, a stub assertion or a test deferred to a follow-up is not done.',
'Any change to a test, validator, CI step, timeout, tolerance, threshold, snapshot or suppression pragma is reported on its own line in your summary with its justification, before any other result.',
'A reported command names the command and its observed result (exit status, counts, the failing line); a command you did not run is not reported, and stderr is never silenced in a command you cite.',
'Your report is a claim until the parent re-executes it: say what you verified, what you reused, and what you could not check.',
] as const;
/** The numbered list only; each rendering site supplies its own heading line (`## ` in the spec body, `label:` in a child prompt). */
export const IMPLEMENTER_DISPATCH_RULES = IMPLEMENTER_DISPATCH_RULES_ITEMS.map((rule, index) => `${index + 1}. ${rule}`).join('\n');
export function generateImplementerDispatchRules(): string {
return IMPLEMENTER_DISPATCH_RULES;
}
+2
View File
@@ -47,6 +47,7 @@ import { generateCommandReference, generateSnapshotFlags, generateBrowseSetup, g
import { generateDesignDocDiscovery } from './design-doc-discovery';
import { generateSharedLibsRubric, generateSafeGitPath } from './shared-libs';
import { generateTestValueBar, generateTestValueMessage } from './test-value';
import { generateImplementerDispatchRules } from './dispatch-rules';
import { generateQAScope, generateQAExploratory, generateQAFunctional, generateQAResource, generateQAReview, generateQAReviewPreflight, generateQAMethodReads } from './qa';
export const RESOLVERS: Record<string, ResolverFn> = {
@@ -115,6 +116,7 @@ export const RESOLVERS: Record<string, ResolverFn> = {
TEST_COVERAGE_GATE_SHIP: generateTestCoverageGateShip,
TEST_VALUE_BAR: generateTestValueBar,
TEST_VALUE_MESSAGE: generateTestValueMessage,
IMPLEMENTER_DISPATCH_RULES: generateImplementerDispatchRules,
TEST_FAILURE_TRIAGE: generateTestFailureTriage,
SPEC_REVIEW_LOOP: generateSpecReviewLoop,
DESIGN_SKETCH: generateDesignSketch,
+70 -2
View File
@@ -227,6 +227,69 @@ done
**Error handling:** a bound or chosen plan file that is unreadable (permissions, encoding) ${ship ? 'is an audit error, not "no plan": the parent applies its audit-failure recovery and skip/stop decision.' : '→ say "Plan file found but unreadable." and use the Fallback Intent Sources below; never report plan items as verified.'}`;
}
export const ACCEPTANCE_EDITED = 'ACCEPTANCE_EDITED';
/** Lower-cased heading keywords that mark a plan section as acceptance-bearing (awk ERE, applied after tolower). */
export const ACCEPTANCE_HEADING_PATTERN = '^#+ *[0-9.]* *(testable )?(acceptance|success criteria|verification|test plan|testing|done when|definition of done)';
/**
* RH-10 (spec-editing as progress): the parent diffs the plan's acceptance-bearing
* sections as they stand in the working tree against a baseline and reports
* ACCEPTANCE_EDITED beside the child's classes. Parent-only: the child's
* seven-field JSON contract is unchanged.
*/
function planAcceptanceEditedCheck(): string {
return `### Acceptance edits (parent-computed)
Run this after the child's report and before Gate Logic, with the bound plan path
substituted for \`<plan path>\`. It compares the plan's acceptance-bearing sections
(headings matching acceptance, success criteria, verification, test plan, testing,
done when, definition of done) as they stand in the working tree against a baseline:
the \`origin/<base>\` version when the plan exists there, else its first commit on this
branch, else \`baseline unavailable\` (plans outside the repository or not yet tracked).
\`\`\`bash
PLAN_FILE="<plan path>"
_REL=$(git ls-files --full-name --error-unmatch -- "$PLAN_FILE" 2>/dev/null | head -1)
_BASE_REF=""; _BASE_KIND=""
if [ -z "$_REL" ]; then
echo "ACCEPTANCE_BASELINE: unavailable (plan is not tracked in this repository)"
elif git cat-file -e "origin/<base>:$_REL" 2>/dev/null; then
_BASE_REF="origin/<base>"; _BASE_KIND="origin/<base>"
else
_FIRST=$(git log --diff-filter=A --format=%H "origin/<base>..HEAD" -- "$_REL" 2>/dev/null | tail -1)
if [ -n "$_FIRST" ]; then _BASE_REF="$_FIRST"; _BASE_KIND="first commit on branch ($_FIRST)"
else echo "ACCEPTANCE_BASELINE: unavailable (no origin/<base> version and no introducing commit)"; fi
fi
if [ -n "$_BASE_REF" ]; then
echo "ACCEPTANCE_BASELINE: $_BASE_KIND"
_ACC_TMP=$(mktemp -d) && trap 'rm -rf "$_ACC_TMP"' EXIT
_acc_sections() { awk 'BEGIN{keep=0} /^#+ /{keep = (tolower($0) ~ /${ACCEPTANCE_HEADING_PATTERN}/)} keep{print}'; }
git show "$_BASE_REF:$_REL" | _acc_sections > "$_ACC_TMP/base"
_acc_sections < "$PLAN_FILE" > "$_ACC_TMP/wtree"
if diff -u --label baseline --label working-tree "$_ACC_TMP/base" "$_ACC_TMP/wtree" > "$_ACC_TMP/diff"; then
echo "${ACCEPTANCE_EDITED}: none"
else
echo "${ACCEPTANCE_EDITED}: yes"; cat "$_ACC_TMP/diff"
fi
fi
\`\`\`
Read the result:
- \`${ACCEPTANCE_EDITED}: none\` — record \`Acceptance edits: none (baseline <kind>)\` for the PR body.
- \`${ACCEPTANCE_EDITED}: yes\` — for each plan item whose acceptance text the diff changed, add
\`[${ACCEPTANCE_EDITED}]\` beside the child's classification in the checklist summary. It is a
separate class: never fold it into CHANGED (CHANGED means the same goal was achieved by other
means and passes the gate). The original obligation is still audited: classify the item
against the baseline text, so an item that satisfies only its edited text is PARTIAL or
NOT DONE against the original and gated as such. The PR body names each one as a scope
change under \`## Plan Completion\` with the baseline and working-tree wording.
- \`ACCEPTANCE_BASELINE: unavailable\` — record \`Acceptance edits: baseline unavailable (<reason>)\`
in the PR body; never report \`none\`.
Limit: an item rewritten in the same commit that introduced the plan is invisible to this check.`;
}
/** Ship's child audit: the parent already bound the plan, so the child never searches. */
function planInputShip(): string {
return `### Plan input
@@ -402,9 +465,13 @@ The parent evaluates the completion checklist in priority order, including after
4. **All DONE or CHANGED:** Pass. "Plan completion: PASS — all items addressed." Continue.
**${ACCEPTANCE_EDITED} items** (parent-computed, see Acceptance edits above) are gated by their
classification against the original acceptance text, never by the edited text, and are
never counted as CHANGED. They do not add a gate of their own; they are reported.
**No plan file found:** Skip only the plan completion audit. Continue with Step 8.1, Scope Drift and Prior Learnings; Step 9 QA still runs.
**Include in PR body (Step 19):** Add a \`## Plan Completion\` section with the checklist summary.`;
**Include in PR body (Step 19):** Add a \`## Plan Completion\` section with the checklist summary, the \`Acceptance edits:\` line and each \`[${ACCEPTANCE_EDITED}]\` item named as a scope change.`;
}
function planReviewDeliveryIntegrity(): string {
@@ -529,9 +596,10 @@ export function generatePlanCompletionAuditShip(_ctx: TemplateContext): string {
return generatePlanCompletionAuditInner('ship');
}
/** `{{PLAN_COMPLETION_GATE_SHIP:discovery}}` renders the parent-side plan binding that runs before dispatch. */
/** `{{PLAN_COMPLETION_GATE_SHIP:discovery}}` renders the parent-side plan binding that runs before dispatch; `:acceptance` the parent-side ACCEPTANCE_EDITED check that runs after the child reports. */
export function generatePlanCompletionGateShip(_ctx: TemplateContext, args?: string[]): string {
if (args?.includes('discovery')) return generatePlanFileDiscovery(true);
if (args?.includes('acceptance')) return planAcceptanceEditedCheck();
return generatePlanCompletionAuditInner('ship', 'gate');
}
@@ -39,7 +39,7 @@ export function generateCompletionStatus(ctx: TemplateContext): string {
return `## Completion Status Protocol
When completing a skill workflow, report status using one of:
- **DONE** — completed with evidence.
- **DONE** — completed with evidence valid for the final consumed inputs; name reuse and anything not independently verified.
- **DONE_WITH_CONCERNS** — completed, but list concerns.
- **BLOCKED** — cannot proceed; state blocker and what was tried.
- **NEEDS_CONTEXT** — missing info; state exactly what is needed.
@@ -1,18 +1,32 @@
import type { TemplateContext } from '../types';
/**
* Evidence-before-claimed-limitations (fork port wave 2, D1).
* Claims Need Evidence: the preamble's honesty kernel (fork port wave 2, D1;
* extended by docs/designs/HONEST_WORK_GATE_INTEGRITY.md W4).
*
* The single highest-leverage judgment clause from the fork's live App Store
* releases: nine release failures in two days shared one root — the agent
* asserting folklore as fact ("the API can't do this", "X requires a
* password") instead of running the ten-second check that would have
* disproven it. Adapted as ONE directive into the shared preamble (the
* fork's full SHARED-JUDGMENT contract is deliberately not imported).
* Started as one directive: a claimed limitation ("the API can't do this")
* needs the verbatim error, documented statement or live probe, because nine
* App Store release failures in two days shared that one root. W4 widened it
* to a five-bullet kernel covering claimed executions, evidence kinds, failure
* disclosure and null results. It is a correctness rule, not prose style, so
* it renders for every tier that composes it (2–4) and for `terse` builds;
* tier 1 skills have no evidence claim to make. The bullets stay at or under
* KERNEL_MAX_BYTES; test/honesty-kernel.test.ts pins that budget.
*/
export function generateEvidenceDirective(ctx?: TemplateContext): string {
if (ctx?.explainLevel === 'terse') return '';
return `## Claimed Limitations Need Evidence
export const KERNEL_MAX_BYTES = 800;
A claimed limitation or requirement ("the API can't do this", "X requires a credential", "that's impossible on this platform") is a material claim. State one only with the verbatim error, the documented statement, or a live probe in hand — pattern-matching a failure to a familiar story is not evidence. When a cheap probe settles the question, run it BEFORE asking the user anything or declaring a step blocked.`;
export const EVIDENCE_KERNEL_HEADING = '## Claims Need Evidence';
export const EVIDENCE_KERNEL_BULLETS = [
'A claimed limitation ("the API can\'t", "X needs a credential") needs the verbatim error, documented statement or live probe; probe before asking or blocking.',
'A claimed execution ran and you saw its result: name the command and the revision or content fingerprint; never cite a command whose stderr was silenced.',
'State the evidence kind (static read, unit test, fixture/replay, live run, production) and never pass one off as another: a mock is not a live check. Reuse rules: Step 16.',
'Disclose any failure or missing coverage that would change the reader\'s conclusion; "done, unverified" is not "done".',
'A checked null result ("ran X, found nothing material") is a success; an unsupported positive claim is worse than silence. Agreeing agents, or repeated reads of one source, are one datum.',
] as const;
export function generateEvidenceDirective(_ctx?: TemplateContext): string {
return `${EVIDENCE_KERNEL_HEADING}
${EVIDENCE_KERNEL_BULLETS.map(bullet => `- ${bullet}`).join('\n')}`;
}
+14 -5
View File
@@ -17,6 +17,9 @@ export const QUESTIONS = [
] as const;
export const VALUE_CARD_FIELDS = ['protects', 'fails_when', 'why_new', 'seam'] as const;
/** Optional fifth field: one sentence on what green does not prove and which fixtures or mocks stand in for what. */
export const VALUE_CARD_OPTIONAL_FIELD = 'no_claim';
export const NO_CLAIM_EXAMPLES = ['provider acceptance (mocked provider; unit only)', 'none beyond protects'] as const;
export const CARD_FIELD_MAX_BYTES = 160;
export const CATALOG = [
@@ -93,8 +96,9 @@ export function generateTestValueMessage(ctx: TemplateContext, args?: string[]):
return degradedMessage(ctx, key as MessageKey);
}
// Measured renders plus 15%: plan 1897, ship 2742, qa 1036, audit 3712 bytes.
export const TEST_VALUE_BAR_MAX_BYTES: Record<TestValueBarMode, number> = { plan: 2182, ship: 3154, qa: 1192, audit: 4269 };
// Measured renders plus 15%: plan 2221, ship 3066, qa 1346, audit 4036 bytes
// (raised once for the optional `no_claim` card field and its two examples).
export const TEST_VALUE_BAR_MAX_BYTES: Record<TestValueBarMode, number> = { plan: 2555, ship: 3526, qa: 1548, audit: 4642 };
export function clampCardField(value: string): string {
const bytes = Buffer.from(value, 'utf8');
@@ -104,8 +108,12 @@ export function clampCardField(value: string): string {
return `${bytes.subarray(0, end).toString('utf8')}...`;
}
export function renderValueCard(card: Record<(typeof VALUE_CARD_FIELDS)[number], string>): string {
return `Value: ${VALUE_CARD_FIELDS.map(field => `${field}=${clampCardField(card[field])}`).join('; ')}`;
export type ValueCard = Record<(typeof VALUE_CARD_FIELDS)[number], string> & { [VALUE_CARD_OPTIONAL_FIELD]?: string };
export function renderValueCard(card: ValueCard): string {
const fields: string[] = [...VALUE_CARD_FIELDS];
if (card.no_claim !== undefined) fields.push(VALUE_CARD_OPTIONAL_FIELD);
return `Value: ${fields.map(field => `${field}=${clampCardField(card[field as keyof ValueCard]!)}`).join('; ')}`;
}
const EXAMPLE_CARD = renderValueCard({
@@ -113,6 +121,7 @@ const EXAMPLE_CARD = renderValueCard({
fails_when: 'the reason guard is removed or inverted',
why_new: 'billing.test.ts covers processPayment only',
seam: 'none',
no_claim: NO_CLAIM_EXAMPLES[0],
});
const EXAMPLE_REJECTED = 'Rejected (covered_elsewhere): "checkout renders"; checkout.e2e.ts:15 covers it, so extend that test.';
@@ -129,7 +138,7 @@ function cardRules(mode: TestValueBarMode, skillName: string): string {
qa: skillName === 'qa-only' ? 'Put it under each proposed test.' : 'Put it in the 8e.5 record.',
audit: 'Read cards from test header comments when present.',
}[mode];
return `Value card: \`Value: protects=<...>; fails_when=<...>; why_new=<...>; seam=none\` (seam: \`none\` or its name); each field at most ${CARD_FIELD_MAX_BYTES} UTF-8 bytes here (clamp to 157 plus \`...\`; written JSON keeps full values). ${where} A missing upstream card never blocks: derive it; ignore unknown fields.
return `Value card: \`Value: protects=<...>; fails_when=<...>; why_new=<...>; seam=none; no_claim=<...>\` (seam: \`none\` or its name; \`no_claim\`: one sentence on what green does not prove and which fixtures or mocks stand in for what, e.g. \`no_claim=${NO_CLAIM_EXAMPLES[0]}\` or \`no_claim=${NO_CLAIM_EXAMPLES[1]}\`; it never waives a required live check); each field at most ${CARD_FIELD_MAX_BYTES} UTF-8 bytes here (clamp to 157 plus \`...\`; written JSON keeps full values). ${where} A missing upstream card never blocks: derive it; ignore unknown fields.
Example: ${EXAMPLE_CARD}
${EXAMPLE_REJECTED}`;
+1 -1
View File
@@ -523,7 +523,7 @@ Repo: {owner/repo}
## Critical Paths
- {end-to-end flow that must work}
Value: protects={...}; fails_when={...}; why_new={...}; seam=none
Value: protects={...}; fails_when={...}; why_new={...}; seam=none; no_claim={...}
## Tests to Retire
- {existing test made obsolete by this plan and why, or none}