# Testing

[中文](testing.zh.md)

Stateboard has two public entry points. Test the copyable Prompt and installable Skill independently before comparing their behavior.

## 1. Static Validation

Run:

```bash
npm ci --ignore-scripts
node scripts/validate-repository.mjs
git diff --check
npm run html:validate
```

The validator checks:

- English/Chinese Markdown mirror coverage
- Skill frontmatter and referenced files
- canonical Prompt copies under `docs/prompts/`
- embedded Prompt parity across all five GitHub Pages languages
- local Markdown and HTML links
- forbidden public-path, private-ID, and credential patterns
- anonymized evidence-case schema

## 2. Prompt-Only Clean Room

Run `prompts/stateboard-sync-prompt.md` in an environment where no Stateboard or legacy project-state Skill can be discovered.

Use Markdown-only output:

```text
What I want to organize: the supplied anonymous evidence fixture
Sync to: Markdown only
Target location: reply directly here
Automatic refresh: not needed
```

Acceptance:

- external write-tool calls: `0`
- one durable project-state task per real project
- 3-5 useful next actions
- an explicit evidence decision and checked layers
- evidence samples separate coverage (`checked`, `unavailable`, `not-applicable`) from change (`changed`, `no-change`, `unknown`)
- readable current evidence without a valid comparison uses `checked` + `unknown`; it is not mislabeled `unavailable`
- a successful empty read remains `checked`; configured-schedule Run Health includes every required field
- no unsupported claim that tests, CI, deployment, or release succeeded
- run health says automatic refresh is not scheduled
- `BASELINE` is used only with explicit never-established state; `NO_NEW` retains any supplied prior project state
- delivery, scheduler health, and output self-checks appear under Run Health/Sync Result, not project EvidenceSample layers
- one changed artifact maps to one signal layer; docs and test-source changes are not double-counted

## 3. Skill-Only Clean Room

Use an isolated Codex profile that contains only the repository version of `stateboard-codex`. Record the loaded Skill path and a content hash before the run. Do not allow `codex-project-state-to-todo` or another overlapping Skill in the test profile.

Invoke:

```text
$stateboard-codex

What to organize: the supplied anonymous evidence fixture
Destination: Markdown only
Target location: reply directly here
Automatic refresh: not needed
```

The Skill must satisfy the same semantic acceptance rules as the Prompt. Exact prose does not need to match.

## 4. Evidence Regression Cases

Use `tests/evidence-cases.json`. Required cases include:

Create the local git/non-git fixtures first:

```bash
node scripts/create-evidence-fixtures.mjs --output /tmp/stateboard-evidence-fixtures
node scripts/verify-evidence-fixtures.mjs --output /tmp/stateboard-evidence-fixtures
node scripts/verify-manifest-script.mjs
node scripts/verify-task-semantic-hash.mjs
node scripts/verify-atomic-private-state.mjs
```

The generator only replaces a directory named `stateboard-evidence-fixtures` after it has created a safety marker there. It refuses existing unmarked directories. Use a fixture directory outside the Stateboard checkout so project-level agent instructions and repo-local Skills cannot affect the clean-room runs.

- confirmed first run where no cursor has ever existed -> `BASELINE`
- expected cursor missing despite readable current source -> `INDETERMINATE`
- docs-only progress -> `CHANGED`
- uncommitted engineering progress -> `CHANGED`
- clean worktree with commits after the cursor -> `CHANGED`
- CI configuration change after checking a readable result source with no current run -> `CHANGED`, but no CI-success claim
- test result first observed after the cursor and tied to the current revision -> `CHANGED`
- release/deployment result only -> `CHANGED`
- ignored noise only with complete coverage -> `NO_NEW`
- missing or incomparable required evidence -> `INDETERMINATE`
- missed scheduled slot -> project evidence and run health reported separately
- ambiguous same-name destination tasks -> ask before writing
- unknown write result -> reconcile before retrying
- source fingerprint changes during destination write -> keep the previous cursor and require a rescan
- destination ETag changes without a semantic-hash change -> metadata drift, not project progress
- success time -> recorded only after read-back, source recheck, and atomic state commit
- private state safety -> the atomic-write helper rejects invalid/insecure input, cursor corruption/regression, active locks, and unapproved stale locks; it preserves the previous state on failure and leaves the final state at `0600`
- privacy-only cleanup -> sanitize the task without changing its `NO_NEW` decision
- `.wrangler/cache` change only -> ignored noise, while tracked generated deliverables remain observable
- manifest/noise-policy migration -> approved replacement baseline, `INDETERMINATE`, then a second comparability run

CI executes a deterministic evidence evaluator against all 22 anonymous cases, including staged-only Git changes, and verifies generated fixtures, manifest behavior, destination semantic hashing, and private-state fault boundaries. Prompt/Skill agent behavior still requires clean-room runs and independent parity review; a green deterministic workflow alone is not a full agent behavior pass.

## 5. Parity Review

Give the Prompt and Skill outputs for the same fixture to a separate judge. The judge checks semantic parity for:

- active projects and project identity
- evidence decision and coverage
- priority and next actions
- unsupported claims
- privacy and external-write boundaries

## 6. Optional Live Sync

Run only after the user approves a destination and write permission. Use a dedicated test list/page, never a production list for the first write.

Run twice and verify:

- the first run creates or adopts one project task
- the mapping stores an immutable project key and private destination ID
- the second run updates the same destination task
- priority/title changes do not create a duplicate
- search/read or the write return confirms the destination item
- no project task is marked complete

Do not create or update recurring automation during a live-sync test unless the user separately requests it and confirms frequency, exact time, and timezone.

## 7. Public-Readiness Audit

Before publishing:

- scan the current tree and every reachable commit
- keep real project names, local paths, task IDs, automation IDs, thread IDs, cursors, and run records out of public files
- keep test outputs under ignored `output/`
- confirm localized Prompt files and GitHub Pages still match the canonical versions
- verify the deployed Pages URL and Prompt copy buttons after merge

Unreachable objects in a local `.git` database are a separate destructive-cleanup concern. Do not run reflog expiration or garbage collection as part of normal publishing without explicit approval.
