Files
growqr-backend/docs/backend-dead-code.md
2026-06-05 22:01:00 +05:30

7.6 KiB

Backend Dead Code Inventory

PRM-46 inventory pass for growqr-backend.

No source code was deleted in this pass. Static search and manual inspection were used. Typecheck was run successfully with pnpm typecheck.

Summary

The codebase is mostly wired, but it contains several compatibility, demo, and partially superseded paths. The main cleanup risk is accidentally removing code still used by the frontend's older workflow screens or by demo environments.

Candidates

Priority Candidate Recommendation Evidence
High src/actors/product-service-actors.ts Keep for now; consider deleting only after confirming no Rivet clients call these actors. Actors are registered in src/actors/registry.ts, but local code routes service calls through src/routes/services.ts and src/services/product-service-clients.ts directly. No local getOrCreate references for interviewServiceActor, roleplayServiceActor, or resumeServiceActor were found.
High Legacy /workflows/job-application* route aliases in src/routes/workflows.ts and large portions of src/actors/user-actor.ts workflow state Keep until frontend migration is verified; likely cleanup after DB-backed workflow runs fully replace it. job-application aliases call userActor; newer /workflow-runs path uses workflowRuns, workflowRunModules, and workflowRunActor/executeWorkflowModule. Two workflow systems coexist.
High src/workflows/module-runner.ts synchronous execution from routes Keep, but consolidate behind workflowRunActor before cleanup. Used both by workflowRunActor and directly by route handlers. Direct route use undercuts actor durability, but the module runner itself is active.
Medium src/workflows/smoke-test.ts Keep as script if used manually; otherwise convert to documented test or remove. Only referenced by package.json script workflows:smoke; not part of app runtime.
Medium scripts/rivet-actors.ts Keep if used by ops; document or remove if not. Standalone admin script; not imported by source. It relies on RIVET_ENDPOINT, RIVET_NAMESPACE, and admin token defaults.
Medium Demo home seeder src/home/seed-demo-home.ts and /home/seed-demo Keep in staging/demo only; move behind explicit environment gate. src/routes/home.ts exposes a seed endpoint. Schema has generatedBy: "demo" for notifications. This is live source behavior rather than isolated fixture code.
Medium Static fallback mission registry vs persisted registry (src/missions/registry.ts and src/missions/postgres-registry.ts) Keep both until migration/backfill is confirmed; then decide whether DB registry or static registry is source of truth. routes/missions.ts reads persisted definitions, while actor factory and conversations read static definitions. postgres-registry falls back to static definitions.
Medium Duplicate mission actor wrappers (career-transition-actor.ts, salary-negotiation-war-room-actor.ts, promotion-readiness-actor.ts, personal-brand-opportunity-engine-actor.ts) Keep; low-cost wrappers are active. Thin wrappers are mapped in routes, registry, event actor, and actor registry.
Medium src/events/projectors/projection-agent.ts LLM insight path Keep, but verify product use. Referenced by userEventActor and reducer-types, so not dead. It can silently fall back when no LLM API key exists.
Medium Legacy Redis observers in src/events/redis-consumer.ts Keep until services emit canonical Grow Events. Comments state these observe existing service A2A traffic. They are enabled by INTERVIEW_REDIS_URL, ROLEPLAY_REDIS_URL, and RESUME_REDIS_URL.
Medium events audit table in src/db/schema.ts Keep until old frontend timelines and route writes are audited. Older user/service paths still import/use events table, while newer Grow Event tables also exist.
Low src/workflows/registry.ts and src/missions/registry.ts duplicate product concepts Keep; consolidate later. Workflows are commercial product definitions; missions are actor-backed variants. The overlap is intentional but duplicative.
Low docker/opencode/workspace-template/*/README.md placeholders Keep as template docs or remove if generated workspaces no longer need empty folders. Template-only files are not runtime code, but useful for preserving folder structure.
Low docs/architecture.html Keep unless replaced by Markdown architecture docs. Existing doc artifact, not source.

Unused or Underused Env Vars / Config Values

Env/config Recommendation Evidence
config.required Keep or remove after scanning call sites; currently exported but not used in local source. required is attached to config, but no local config.required( references were found.
clerkPublishableKey Keep if clients read backend config elsewhere; otherwise remove from backend config. Defined in config.ts and .env.example, but backend auth uses secret key.
opencodeApiKey Keep only if future direct OpenCode auth requires it; currently llmApiKey consumes OPENCODE_API_KEY. Defined separately in config; most OpenCode runtime calls use per-container password, not this field.
userServiceUrl Keep; used by missions profile lookup. routes/missions.ts fetches /api/v1/users/me.
legacyServiceTaskObserverGroup Keep while legacy Redis observers exist. Used in redis-consumer.ts.
migrationVersion, promptVersion, opencodeImageVersion Keep; active Docker rollout labels. Used by docker/manager.ts and Docker build metadata.

Stale or Demo-Oriented Behavior

  • Demo generated home notifications and /home/seed-demo should move to a staging/demo module or be guarded by config.environment.
  • service-agents.ts includes demo-like defaults, such as formula_version: "workflow-demo" and synthetic Q Score fallback summaries.
  • config.ts defaults many production-sensitive values to local/dev values, including Gitea admin credentials, service token fallback, A2A key, and localhost URLs.
  • Docker/OpenCode scripts are active but dev-biased, using image tags like growqr/opencode:dev.

Prompt Workflow Inventory

All prompt workflow files under prompts/workflows/* are referenced by src/workflows/registry.ts through promptPath values:

  • career-transition/orchestrator.md
  • interview-to-offer/interview-plan.md
  • salary-negotiation-war-room/orchestrator.md
  • promotion-readiness/orchestrator.md
  • personal-brand-opportunity-engine/orchestrator.md

Additional interview-to-offer prompt files (resume-analysis.md, story-bank.md, final-readiness-report.md) are not referenced by workflowDefinitions directly in this pass. Recommendation: keep until OpenCode/agent prompt loading is audited, then either wire them into module definitions or archive them.

Delete/Keep Decisions Before Cleanup

Do not delete yet:

  • userActor workflow code
  • product-service-actors
  • static mission/workflow registries
  • Redis legacy observers
  • demo home seeder
  • standalone scripts

Good first cleanup after approval:

  1. Move demo seeding to src/staging and guard it with a staging/demo environment.
  2. Remove or document unused config fields (config.required, clerkPublishableKey, opencodeApiKey) after a second pass across frontend/deployment references.
  3. Convert workflows:smoke into a real test or delete the script.
  4. Consolidate mission actor type mapping into one helper and remove duplicate mapping functions.

Verification

pnpm typecheck passed:

tsc -p tsconfig.json --noEmit