Skip to content

chore: CI/CD optimization (rust-optimizer audit — A1, C2, A3, A4, A6, C1, D2, F1) - #102

Merged
pacphi merged 37 commits into
mainfrom
chore/rust-ci-optimization
Jul 27, 2026
Merged

chore: CI/CD optimization (rust-optimizer audit — A1, C2, A3, A4, A6, C1, D2, F1)#102
pacphi merged 37 commits into
mainfrom
chore/rust-ci-optimization

Conversation

@pacphi

@pacphi pacphi commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Applies all findings from the rust-optimizer CI/CD audit (OPTIMIZATION_SPEC.md), delivered as 9 gated autopilot phases:

# Finding What changed
0 (blocker fix) Pre-existing markdown-formatting debt resolved so make format-check gates cleanly
1 A3 CARGO_INCREMENTAL=0 / CARGO_PROFILE_TEST_DEBUG=0
2 A6 cargo-audit via taiki-e/install-action (prebuilt binary, not compiled from source)
3 D2 if-no-files-found: ignore on Playwright artifact uploads
4 C1 concurrency cancel-in-progress group
5 A4 lld fast linker (.cargo/config.toml + CI install step)
6 C2 backend-lint/backend-test run in parallel; new ci-success aggregation job
7 A1 Build-once via cargo nextest archive — backend-test consumes a prebuilt archive instead of recompiling
8 F1 Resolved all 13 cargo-machete unused-dependency hits (12 removed, 1 documented ignore)

Every phase has a machine-checked Definition of Done and a real green gate (make format-check/lint/build/test/test-integration/audit), not just a code review. Full history: .autopilot/runs/rust-ci-optimization.jsonl.

Notable findings caught during review (not just applied blindly)

  • Phase 7 (A1): a reviewer subagent caught that cargo-nextest doesn't run doctests — a real, previously-passing doctest in finima-auth would have silently stopped running in CI. Fixed with a separate cargo test --workspace --doc step, verified against the actual doctest. Also pinned cargo-nextest@0.9.140 in both the archive-build and archive-consume jobs to avoid an archive-format mismatch from independent unpinned installs.
  • Phase 8 (F1): every "unused" dependency was verified via grep for zero source usage, then proven by cargo build --workspace + full cargo test --workspace against a real Postgres test DB (403/403 tests green). tokenizers in finima-llm was left as a documented cargo-machete ignore rather than blindly removed, since it's gated behind the optional candle feature (heavy ML deps) that this environment can't cheaply build to verify.

Follow-ups intentionally left open (not in this PR's scope)

  • pl-orphan-wsdeps: 3 root [workspace.dependencies] entries (axum-extra, aws-config, bytes) now have zero consumers workspace-wide after the per-crate removals above — cargo machete doesn't check the shared manifest itself. Separate cleanup.

Test plan

  • make format-check / make lint / make build / make test / make test-integration / make audit all green locally
  • Full cargo test --workspace (403 tests) against a real Postgres test DB, twice (before and after the nextest-archive restructuring)
  • CI green on this PR

pacphi added 30 commits July 26, 2026 19:03
Decomposes OPTIMIZATION_SPEC.md's findings into an autopilot pipeline:
A3, A6, D2, C1, A4, C2, A1, F1 (spec's own suggested_sequence), with A1
depending on C2 (both touch the same ci.yml job block) and A1/F1 flagged
as risk_phases. Autonomy: reviewed. Mirrored into beads as epic
finima-w2q with 8 child issues for a queryable work-graph view.
- ci.yml: add CARGO_INCREMENTAL=0 / CARGO_PROFILE_TEST_DEBUG=0 (finding A3).
- Makefile: prune .agents/ from format-check-md/lint-md globs — an untracked
  vendor dump under .agents/ was crashing prettier entirely via an unrelated
  package.json declaring prettier-plugin-svelte.
- pipeline.yml/profile.yml: fix yamllint violations introduced when authoring
  them (colon/brace spacing, line length).
- OPTIMIZATION_SPEC.md: prettier --write (my own artifact's formatting).

build/lint/test all green. format_check still red on 9 pre-existing markdown
files unrelated to this phase (confirmed via git stash against HEAD) —
recorded as blocker blk-fmt0 in .autopilot/discovered/rust-ci-optimization.jsonl.
No gate-PASSED marker: phase 0 stops here pending a human decision on how to
handle the pre-existing docs-formatting debt.
Promotes blk-fmt0 (pre-existing markdown-formatting debt breaking the
shared make format-check Tier-1 gate) into its own phase rather than
dismissing or fixing it out-of-band, per user decision. Renumbers the
original 8 A-F phases to 1-8 and gives each an explicit depends_on: [0]
(not just phase 1) since format_check gates every phase's gate, not
only the first one. Mirrored in beads: new issue finima-w2q.9 blocks
finima-w2q.1..8.
…ngth

Missed in ba96f48 — the deliverable line for the new phase 0 exceeded
the 200-char yamllint limit.
Resolves blocker blk-fmt0: prettier --write (formatting only, no
wording changes — verified via diff) on the 9 pre-existing markdown
files that were failing make format-check, a Tier-1 check on every
phase's gate. make format-check/lint/build/test all green.

DoD: cmd: make format-check ✓
A3: CARGO_INCREMENTAL="0" / CARGO_PROFILE_TEST_DEBUG="0" added to
.github/workflows/ci.yml's top-level env block. Deliverable already
existed from earlier session work; this phase verified it against the
gate rather than re-implementing.

DoD: grep CARGO_INCREMENTAL:.*0 ✓, grep CARGO_PROFILE_TEST_DEBUG:.*0 ✓,
cmd: make lint ✓, cmd: make test ✓
A6: backend-audit job installs cargo-audit via taiki-e/install-action
(prebuilt binary) instead of `cargo install cargo-audit --locked`
(compiling from source every run). .github/scripts/cargo-audit.sh and
audit-ignore untouched.

DoD: grep taiki-e/install-action ✓, grep:absent cargo install
cargo-audit ✓, cmd: make audit ✓
D2: if-no-files-found: ignore added to the playwright-report and
playwright-traces upload-artifact steps so a run producing neither
(e.g. failing before the browser starts) doesn't fail the upload step
itself.

DoD: grep if-no-files-found: ignore ✓
C1: concurrency group added to ci.yml (scoped to workflow+ref) with
cancel-in-progress: true, so superseded PR pushes cancel in-flight
runs instead of piling up.

DoD: grep cancel-in-progress:.*true ✓
A4: .cargo/config.toml pins -Clink-arg=-fuse-ld=lld for
x86_64-unknown-linux-gnu (the ubuntu-latest CI target; no effect on
local macOS builds). lld installed via apt-get in the four CI jobs
that compile Rust: backend-lint, backend-test, llm-test, e2e-test.

DoD: grep fuse-ld=lld in .cargo/config.toml ✓, cmd: make build ✓,
cmd: make test ✓
C2: removed `needs: backend-lint` from backend-test and llm-test so
they run in parallel with backend-lint instead of waiting on it.
Added a ci-success aggregation job that needs every always-run
required job (validate-markdown, validate-yaml, backend-lint,
backend-test, backend-audit, frontend-lint, frontend-test) so branch
protection can point at one check. llm-test and e2e-test stay excluded
since they're conditional on vars.LLM_TESTS_ENABLED/vars.E2E_ENABLED.

DoD: grep:absent needs: backend-lint ✓, grep ci-success ✓,
cmd: make lint ✓, cmd: make test ✓
A1: new backend-test-archive job builds the test-profile workspace
once via `cargo nextest archive`, uploads it as an artifact; backend-test
downloads and runs it via `cargo nextest run --archive-file --workspace-remap .`
instead of recompiling with `cargo test --workspace`. postgres service
stays on backend-test (the consumer), matching pipeline.yml's own
convention note. llm-test is deliberately left untouched (different
feature flags/ignored-test semantics can't safely share this archive).

Two real bugs found and fixed via adversarial review before this
commit, not after:
- cargo-nextest doesn't run doctests — added a separate
  `cargo test --workspace --doc` step (verified against a real,
  previously-passing doctest in finima-auth::magic_link).
- cargo-nextest was installed unpinned in both jobs via taiki-e/install-action,
  risking an archive-format mismatch if the two installs resolved
  different versions — pinned cargo-nextest@0.9.140 in both.
Also dropped an overly-aggressive retention-days: 1 on the archive
artifact (would break re-running a failed job after a day).

Empirically validated twice end-to-end (not just YAML review): full
403-test nextest run + doctests, against a real Postgres test DB.

DoD: grep nextest archive ✓, grep archive-file ✓, cmd: make test ✓,
cmd: make test-integration ✓
F1: resolved all 13 cargo-machete unused-dependency hits.

Removed (confirmed zero source-code references via grep, then proven
by cargo build --workspace + full cargo test --workspace against a
real Postgres test DB):
- finima-feed: serde_json, uuid
- finima-api: axum-extra, base64, aws-config, bytes (storage.rs builds
  its S3 client manually via aws-sdk-s3 + aws-credential-types; never
  touches aws_config::load_from_env()/SdkConfig)
- finima-ingest: serde_json, tracing
- finima-db: tokio, tracing (from [dependencies] only — the
  [dev-dependencies] tokio used by #[tokio::test] is untouched)
- finima-auth: serde_json
- finima-llm: finima-core (zero references anywhere in the crate,
  including the candle-gated candle_backend.rs module; the crate's own
  README claimed a dependency "for AppError conversion" that no longer
  exists — LlmError is fully self-contained via thiserror — fixed)

Documented-ignored rather than removed:
- finima-llm: tokenizers, via [package.metadata.cargo-machete]. It's
  gated behind the optional `candle` feature (heavy ML deps: mistralrs/
  hf-hub) not exercised by this repo's default build path, so its
  removal can't be cheaply/safely verified here — the compiler is the
  arbiter, and this one requires a build I can't run in this
  environment. Left as a rationale-documented false-positive-risk
  ignore, not a blind removal.

Adversarial review (qe-security-reviewer subagent) confirmed no
transitive-dependency breakage across the workspace and flagged one
real defect (fixed: the stale README line above) plus one genuine
out-of-scope finding, recorded as parking-lot item pl-orphan-wsdeps:
3 root [workspace.dependencies] entries (axum-extra, aws-config,
bytes) now have zero consumers workspace-wide — cargo machete doesn't
check the shared manifest itself, only per-crate declarations. Left
for a dedicated follow-up since it touches the shared root Cargo.toml.

DoD: cmd: cargo machete ✓ (0 hits), cmd: cargo build --workspace ✓,
cmd: make test ✓ (+ full cargo test --workspace verified with a real
test DB: every crate "ok", 0 failed)
pacphi added 6 commits July 26, 2026 21:20
…e PASSED

All 9 phases (0-8, findings A1/C1/C2/A3/A4/A6/D2/F1 + the docs-format
blocker fix) are gate-PASSED. Reviewed the full accumulated diff across
.github/workflows/ci.yml, .cargo/config.toml, Makefile, 6 crate
Cargo.toml files, and finima-llm/README.md for duplication or dead
seams — none found. The repeated "Install lld"/taiki-e/install-action
steps across 3-4 jobs are inherent to GitHub Actions' per-job runner
isolation (no shared state between jobs without a reusable/composite
action, which is a bigger architectural change out of scope here), not
refactor-worthy duplication.

Full gate re-verified green end-to-end: format_check, lint, build,
test, test_integration, audit all pass.

Open parking-lot item for a future pass: pl-orphan-wsdeps (3 orphaned
root [workspace.dependencies] entries — axum-extra, aws-config, bytes
— now unused workspace-wide after phase 8's per-crate removals).

Pipeline complete.
…s dependency removals

Missed staging this alongside c228fab — Cargo.lock now reflects the
12 removed dependencies (aws-config and its transitive tree, plus the
others), verified via the same cargo build --workspace / cargo test
--workspace runs from phase 8's gate.
@pacphi

pacphi commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…arkdown / Validate YAML)

Local `make format-check`/`make lint` masked these because their
markdown/yaml sub-targets are wrapped in `|| true` — the actual CI
jobs (DavidAnson/markdownlint-cli2-action, direct yamllint) hard-fail
on the same checks with no such fallback. Verified against the exact
tracked-file sets and CI-equivalent invocations before pushing, not
just against the soft-failing local wrapper.

- AGENTS.md / CLAUDE.md: added blank lines around the PUSH TO REMOTE
  fenced code block (MD031), added a language tag to the commit-message
  fence (MD040, AGENTS.md only).
- OPTIMIZATION_SPEC.md: promoted the 8 finding headers from h3 to h2
  (MD001 heading-increment) to match "## Not a finding" and the top-level
  h1 — no h2 existed between them.
- .autopilot/profile.yml: reverted brace spacing to yamllint's default
  (no inner spaces) — it had been reformatted to prettier's style
  (which wants spaces) during an earlier phase, which is what CI's
  Validate YAML job actually flagged.
- .prettierignore: excluded .autopilot/ (matches the existing precedent
  for .claude/, .claude-flow/, .swarm/) so prettier and yamllint stop
  fighting over this directory's brace-spacing convention going forward.

Verified via the CI-equivalent commands directly (not the soft-failing
local wrapper): `git ls-files '*.md' | xargs markdownlint-cli2` → 0
issues in 73 files; `git ls-files '*.yaml' '*.yml' | xargs yamllint -c
.yamllint.yaml` → clean.
@pacphi
pacphi merged commit 6c6d7ff into main Jul 27, 2026
14 checks passed
@pacphi
pacphi deleted the chore/rust-ci-optimization branch July 27, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant