6 Commits

Author SHA1 Message Date
Dicklesworthstone 78ea1ecb43 fix(e2e): bind strict-RCH evidence to immutable runs (coding_agent_session_search-k13gt) 2026-07-28 16:27:50 -04:00
Jeffrey Emanuel 4072a3b992 feat(tests): scripts/**/*.sh rch-compliance + set-e arithmetic guard (coding_agent_session_search-tafss)
Adds an automated regression test that scans shell scripts under scripts/
for two bug classes:

1. Bare `cargo build|test|bench|clippy|run|check|fmt|update|install` outside
   the rch-wrapped form. Originating beads (vq9l5/yzh2t/zlzpk) correctly
   wrapped their target scripts; the test prevents future regressions.

2. `set -e` + `((VAR++))` / `((VAR--))` arithmetic-abort idiom — bash
   evaluates the post-increment expression to 0 when VAR was 0, which
   set -e treats as failure. Subsumes coding_agent_session_search-iaor8
   (the zlzpk polish bead, closed as superseded by this scanner).

Also introduces `scripts/lib/run_cargo.sh` — a single-source-of-truth
helper that scripts can `source` to get a consistent rch-wrapped cargo
invocation (logs cmd/cwd/target/rch_bin to stderr; defaults RCH_BIN
and RCH_TARGET_DIR; defends against missing rch with a clear error).

Files:
- scripts/lib/run_cargo.sh: shared helper.
- tests/scripts_rch_compliance.rs: 8 tests — 2 live-fire (no bare cargo,
  no set-e arithmetic against HEAD), 1 helper-presence check, 5 synthetic
  fixtures (violating, clean, set-e + ++, no-set-e + ++, safe-form +=,
  comment-immune).
- scripts/tests/tafss_compliance_scanner_e2e.sh: orchestrator script.
2026-05-09 03:43:47 -04:00
Dicklesworthstone 66cee37273 chore(repo): reorganize evidence trees + harden tracked-artifact hygiene
Pulls all of the long-form evidence the project has been accumulating
into a small, named set of `docs/` subtrees and tightens `.gitignore`
plus the CI hygiene gate so freshly-generated scratch artifacts cannot
quietly become tracked again. Pure repo-hygiene change: no application
code, schema, or build behavior is touched.

New canonical locations under `docs/`:

- `docs/artifacts/` is the durable home for evidence we want to keep
  reviewable in-tree: migration baselines, refactor proof bundles, the
  no-mock CI audit, and per-pass simplification dashboards. A new
  `docs/artifacts/README.md` documents the policy: anything under here
  is curated evidence, not scratch.
- `docs/artifacts/migration-baseline/` absorbs the entire former
  `.beads/migration_baseline/` tree (BASELINE_SUMMARY, SUMMARY, all
  `baseline_*.{log,txt,json}` outputs, the `search_quality/*.json` and
  `search_queries/q*.json` fixtures, and `binary_size.txt`) plus a new
  `fs_verification.log` so the migration evidence is not buried under a
  beads daemon directory.
- `docs/artifacts/refactor-runs/` collects every dated
  `20260424T*` … `20260427T*` and `20260428T*` codex/repeated-simplify
  pass directory that previously lived under `refactor/artifacts/`.
  Every per-pass report (`pass1_*.md` … `pass10_*.md`, `DASHBOARD.md`,
  `architecture.md`, `baseline.md`, plus the Twelfth/Thirteenth
  twelve-pass dashboards) moves verbatim — only the path changes.
- `docs/artifacts/no-mock-audit.md` replaces
  `test-results/no_mock_audit.md` as the durable copy of the no-mock
  policy report; the `test-results/` directory is now treated as
  ephemeral.
- `docs/assets/` becomes the project's image / screenshot home, with a
  new `docs/assets/README.md`. `cass_illustration.webp`,
  `gh_og_share_image.jpg`, and `screenshots/screenshot_0{1,2,3}.webp`
  move out of the repo root into `docs/assets/images/` and
  `docs/assets/screenshots/`.
- `docs/planning/` gains the formerly root-level
  `cli-robot-enhancements.md` and the dated investigation
  `2026-05-05-franken-agent-detection.md` (now under
  `docs/planning/sessions/`), so all planning material is in one
  predictable subtree.
- `docs/reference/E2E_LOGGING_SCHEMA.md` is added as the durable
  schema definition for the JSONL E2E log, replacing inline references
  to `tests/e2e/exports/setup-metadata.json` paths.
- `tests/policies/` becomes the home for machine-enforced policy
  inputs. `test-results/no_mock_allowlist.json` moves to
  `tests/policies/no_mock_allowlist.json` so that CI-relevant policy
  files survive `test-results/` being ignored.
- `tests/performance/lighthouse-budget.json` moves to
  `tests/fixtures/performance/lighthouse-budget.json` to consolidate
  test inputs under `tests/fixtures/`.

Tracked-artifact hygiene (`.gitignore`):

- Search-demo data: keeps the frozen v1 index and `watch_state.json`
  visible (`!tests/fixtures/search_demo_data/index/`,
  `!.../watch_state.json`, `!.../v1/**`) while ignoring later
  scratch generations (`v*/` minus `v1/`), `index-run.lock`, the
  doctor scratch directory, and the `.lexical-publish-backups/`
  staging tree.
- Test outputs: `test-results/*` is now ignored wholesale (no
  per-file allowlist; durable inputs live under `tests/policies/`).
  `/test-results-*.txt`, `claude-upgrade-progress.json`,
  `tests/test-results/`, `tests/tests/`, `tests/e2e/exports/`,
  `tests/e2e/pages_preview/`, `tests/artifacts/`, `tests/e2e/.env.test`,
  and root-level `/artifacts/` and `tmp/` are all explicitly ignored.
- Local SQLite sidecars: `*.db-wal`, `*.db-shm`, `*.db-journal`,
  `*.sqlite-wal`, `*.sqlite-shm`, `*.sqlite-journal`, `*.sqlite3-wal`,
  `*.sqlite3-shm`, `*.sqlite3-journal` are added globally so
  process-local journal files cannot leak in next to a deliberately
  checked-in fixture DB. Root-level `/*.db`, `/*.db-wal`,
  `/*.db-shm`, `/*.sqlite`, `/*.sqlite-wal`, `/*.sqlite-shm` follow
  the same rule.
- Aider state: `.aider.chat.history.md` and friends remain ignored
  globally, with an explicit
  `!tests/fixtures/aider/.aider.chat.history.md` exception so the
  intentional fixture survives.
- Root noise: `/cass_illustration.webp`, `/gh_og_share_image.*`,
  `/screenshots/`, `/UPGRADE_LOG.md`, `/refactor/`, `/perf/`,
  `/*.log`, `/*.mcp.json`, `cline.mcp.json`, `opencode.json`,
  `*.mcp.json.*.bak`, and `__pycache__/` plus `.ruff_cache/` are
  explicitly ignored at root so future regenerations of these
  artifacts do not become tracked.
- Preserved-by-name carve-out: an explicit
  `!docs/planning/MODES_OF_REASONING_REPORT_AND_ANALYSIS_OF_PROJECT.md`
  re-include line guards against developer-level globals that still
  match the pre-reorganization scratch filename.

Ephemeral artifact removals (now ignored):

- `.ntm/logs/am-coding_agent_session_search.log`,
  `.ntm/logs/bd-coding_agent_session_search.log`,
  `.ntm/logs/cm-coding_agent_session_search.log`, and
  `.ntm/summaries/coding_agent_session_search-20260407-115237.json`
  (~230 lines, all NTM session bookkeeping).
- `tests/e2e/.env.test` (regenerated per run).
- `tests/e2e/exports/setup-metadata.json`, `test-basic.html`,
  `test-encrypted.html`, `test-large.html`, `test-no-cdn.html`,
  `test-tool-calls.html`, `test-unicode.html` (~41,400 lines of
  generated Playwright export HTML).
- `tests/e2e/pages_preview/bundle/{private,site}/*` — the entire
  generated preview bundle (HTML, JS, CSS, payload chunk, master-key
  + integrity-fingerprint scratch). All produced by the preview build
  step.
- `tests/e2e/pages_preview/db/agent_search.db{,-shm,-wal}`,
  `tests/e2e/pages_preview/encrypt/{config.json,payload/chunk-00000.bin}`,
  `tests/e2e/pages_preview/export/export.db`,
  `tests/e2e/pages_preview/preview-server.log` (binary test DBs and
  encrypt/export scratch produced by the preview server).
- `tests/tests/test-results/e2e/placeholder` (zero-byte placeholder).

Total: ~52,900 deletion lines removed, all generated test artifacts
that the new `.gitignore` patterns now block from re-entering the tree.

CI gate (`.github/workflows/ci.yml` + `scripts/validate_ci.sh`):

- A new "Run repository artifact hygiene check" step runs
  `./scripts/validate_ci.sh --artifact-hygiene-only` first, before the
  no-mock policy check, so the build fails fast if any of the patterns
  above ever become tracked again.
- The no-mock workflow step is repointed at the new policy location
  (`tests/policies/no_mock_allowlist.json`); the in-workflow
  remediation guidance string in `AUDIT_REPORT` is updated to match.
- `scripts/migration_e2e_validate.sh` and `scripts/lib/e2e_log.sh`
  are repointed to the new schema doc and policy paths.
- `tests/e2e/reporters/jsonl-reporter.ts` and `tests/util/e2e_log.rs`
  reference the moved schema doc.

Companion docs (no behavioral change):

- `README.md` updates `<img>` `src` attributes for the project
  illustration and the three TUI screenshots to point at the new
  `docs/assets/...` paths, and adds a Remote Archive Safety subsection
  documenting that `cass doctor`/`health`/`status` JSON treats
  `remote_source_*` gaps as preservation signals (no behavior change,
  doc only).
- `docs/planning/TESTING.md` adds an "Artifact hygiene check" intro
  paragraph and a Doctor-V2 filesystem-portability section that names
  the `CASS_TEST_DOCTOR_RENAME_FAILURE=cross-device` simulation and
  the `fallback_kind: cross_device_copy_replace` evidence contract.
- `docs/planning/UPGRADE_LOG.md`, `docs/ftui_visual_parity_*` are
  re-pointed at the new artifact paths.
- `tests/fixtures/README.md` and `tests/fixtures/sources/probe/README.md`
  pick up the new path references.
2026-05-06 12:33:33 -04:00
Dicklesworthstone 6837bdee91 docs(testing): Add model fixtures and SSH test documentation
Expand TESTING.md with comprehensive documentation for test fixtures:

Model Fixtures for Semantic Search:
- Document embedder fixture (xenova-paraphrase-minilm-l3-v2-int8, ~17 MB)
- Document reranker fixture (xenova-ms-marco-minilm-l6-v2, ~22 MB)
- Add usage examples with fixture_helpers module
- Document checksum verification workflow
- Include model source attribution (Apache-2.0 licensed)

SSH Test Fixtures:
- Document Docker-based SSH test infrastructure
- Describe probe fixtures for various SSH scenarios:
  - indexed_host.json (847 sessions)
  - not_indexed_host.json (cass not indexed)
  - no_cass_host.json (cass not installed)
  - unreachable_host.json (connection failures)
- Add SshTestServer usage examples

scripts/lib/e2e_log.sh:
- Add E2E logging utilities for shell test scripts
- Structured JSON log output for CI integration

tests/util/e2e_log.rs:
- Add Rust E2E logging utilities
- Match shell script format for consistency

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-27 17:22:13 -06:00
Dicklesworthstone f3d29dde68 feat: add verbose shell e2e logging + export specs 2026-01-27 16:56:58 -06:00
Dicklesworthstone e4ec128d7f feat(e2e): Add unified JSONL logging infrastructure for E2E tests
Introduce a consistent structured logging schema across all E2E test
runners (Rust, Shell, Playwright) to enable unified log aggregation,
CI integration, and debugging.

New files:
- tests/util/e2e_log.rs: Rust E2E logger with typed event emission
- scripts/lib/e2e_log.sh: Shell E2E logging library (source-able)
- scripts/tests/run_all.sh: Orchestrated runner for all E2E suites
- tests/e2e/reporters/jsonl-reporter.ts: Playwright JSONL reporter

Event types in the unified schema:
- run_start: Test run begins with environment metadata
- test_start: Individual test begins (name, suite, file, line)
- test_end: Test completes (status, duration, error details)
- run_end: Summary statistics (total, passed, failed, skipped)
- log: General log messages with severity levels
- phase_start/phase_end: Multi-phase run tracking

Output locations:
- test-results/e2e/rust_*.jsonl - Rust E2E logs
- test-results/e2e/shell_*.jsonl - Shell script logs
- test-results/e2e/playwright_*.jsonl - Playwright logs
- test-results/e2e/combined.jsonl - Aggregated from all suites
- test-results/e2e/summary.md - Human-readable summary

Updated files:
- tests/util/mod.rs: Export e2e_log module
- tests/playwright.config.ts: Register JSONL reporter
- TESTING.md: Document the logging infrastructure and usage

Example Rust usage:
  let logger = E2eLogger::new("my_test", None)?;
  logger.test_start("test_name", "suite", Some("file.rs"), Some(42))?;
  logger.test_pass("test_name", "suite", duration_ms)?;

Example Shell usage:
  source scripts/lib/e2e_log.sh
  e2e_init "shell" "my_script"
  e2e_test_start "test_name" "suite"
  e2e_test_pass "test_name" "suite" "$duration_ms"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:54:31 -05:00