Code quality: DRY, readability, and Rust/sqlx practice (gap analysis §10) #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Improve DRY, readability, and Rust/library practice from gap analysis §10. Not a feature dump — keep behavior unless a listed item is already superseded by another issue (then hook that issue instead of conflicting).
Source:
gaps/GAP_1788152435.md§10 (and §9 cost notes that are code-quality).Current codebase
DRY
FixtureBundleconstructors copied incollect.rstests,pipeline.rstests,tests/issue_plan.rs.long_body/sample_bodyparagraph padders duplicated;fixtures/happy-week/replicate.jsonrepeats one paragraph ~30 times for word count.migrations/001_init.sqlandstore.rsmigrate().skills/and.cursor/skills/.invariants::CANONICAL_ADDRESSES, CL8Y-webtokenDirectory.ts, DEXtokenlist.json.search.rsis a 14-line wrapper.write_publish_templatevs unusedDraftMrJSON.telegram_bot_token,gitlab_token,github_token,Config::default_repos(),secrets::redact,TELEGRAM_RETENTION_DAYSunused,SourceKind::onchain_authoritativeunused by search.tests/issue_plan.rsrun_withusesmem::forgetonTempDir.Readability
pipeline.rs~621 lines (stage machine + plan + IO + tests).plan_weekserde_json::from_str.unwrap_or_elsefirst-line fallback hides bad model JSON.--skip-imageinverted (Replicate/image issue should replace with--image).onchain_authoritativeincludesRepo(READMEs are not onchain).Rust / library
reqwest+ tokio only for Postgres; future API should be async.sqlx::migrate!.Predictor: Send + Syncwith&mut selfcreate.serde_yaml0.9 unmaintained.Error::Http(String)everywhere.envfeature unused; config is manualstd::env::var.Regex::newon every lint/sanitize/redact call.cargo testin CI / Makefileretest/AGENTS.md(intentional flake hunt — document or drop one).1.80vs CIrust:1.86.Why this is needed
Dead fields and duplicated fixtures slow every live-collector MR.
pipeline.rssize makes editor/grounding work risky. Regex-per-call and duplicated SQL already caused drift.Constraints / guardrails
includeof CL8Y-web as a crate.skills/if that is the repo convention (CL8Y-web does this) — then add a one-line “keep in sync” note instead of inventing a generator, or make.cursor/skillssymlinks if GitLab supports them.Relevant files
src/pipeline.rs,src/store.rs,src/lib.rs,src/config.rs,src/invariants.rs,src/lint.rs,src/mdx.rs,src/telegram.rs,src/search.rs,src/publish.rs,tests/issue_plan.rs,migrations/001_init.sql,Cargo.toml,.gitlab-ci.yml,AGENTS.md,Makefile,skills/**,.cursor/skills/**Recommended direction
tests/common/mod.rsforFixtureBundle,long_body,run_weektemp dirs withoutmem::forget.include_str!("../migrations/001_init.sql")or sqlx migrate (coordinate with Postgres issue).pipelineintoplan.rs/emit.rs/stage.rs.OnceLock<Regex>for lint/mdx/telegram.onchain_authoritative: only indexer kinds (and not Repo, not telegram, not web).plan_week: fail if plan JSON invalid (no silent first-line topic) or log a structured fallback flag inplan.json.serde_yamlif a small change; otherwise note defer.Acceptance criteria
mem::forgetgone.pipeline.rssplit or reduced with a documented module map indocs/architecture.md.onchain_authoritative()false forRepo,Telegram, and web-search (when added).AGENTS.mdduplicatecargo testexplained or single invocation.Test plan — functional paths
cargo test --all-targetstwice (or once if retest dropped) green.cargo clippy --all-targets -- -D warningsgreen.Test plan — attack, hack, and abuse
Refactor-only, but regressions:
javascript:/ unofficial addresses.Verification criteria
marked as related to #7