312 lines
38 KiB
Markdown
312 lines
38 KiB
Markdown
# JobTracker programme decisions and assumptions
|
|
|
|
## DEC-001 — Programme source paths
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** The source files are exactly `docs/todo/work.md` and `docs/todo/ollama.md`; no fallback path search was needed.
|
|
- **Reason/evidence:** Both exact files exist and were read completely (922 and 825 lines respectively).
|
|
- **Alternatives considered:** `docs/work-programmes/` content-based discovery, required only if names differed.
|
|
- **Consequences:** Original references in the master plan use these paths and line ranges.
|
|
- **User approval required:** No; factual discovery.
|
|
- **Reversible:** Yes, update paths if the sources move.
|
|
|
|
## DEC-002 — One authoritative plan, compatibility pointer only
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** `docs/work-programmes/master-work-plan.md` is authoritative. The older requested `docs/plans/post-audit-ux-reliability-program.md` will point to it instead of duplicating the checklist.
|
|
- **Reason/evidence:** The current request explicitly requires one authoritative record; `work.md:46-59` requires the older plan path, and `docs/plans/` did not exist.
|
|
- **Alternatives considered:** duplicate both full plans; rejected because they would drift.
|
|
- **Consequences:** Legacy references remain valid without a second status source.
|
|
- **User approval required:** No; directly reconciles both instructions.
|
|
- **Reversible:** Yes.
|
|
|
|
## DEC-003 — Canonical origin precedes identity recovery
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** SEC-001/SEC-002 precede Microsoft legacy relinking and email change/recovery.
|
|
- **Reason/evidence:** JT-002 security URLs currently fall back to request Host; recovery built first could send attacker-controlled links.
|
|
- **Alternatives considered:** follow the suggested identity-first order; rejected as unsafe.
|
|
- **Consequences:** SEC-001 is the first implementation package.
|
|
- **User approval required:** No; safer dependency ordering was requested.
|
|
- **Reversible:** No practical reason to reverse.
|
|
|
|
## DEC-004 — Scoped production authority
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Production mutation authority applies only to the production-local-AI inventory/benchmark/install/configuration/rollout described in `ollama.md`, and only after its backup/rollback gates. Other production deployment still requires explicit instruction.
|
|
- **Reason/evidence:** `work.md:15` prohibits production deploy; `ollama.md:3` and the current request authorize scoped AI work.
|
|
- **Alternatives considered:** treat either instruction as globally overriding the other; rejected as over-broad.
|
|
- **Consequences:** repository work continues; PROD items remain blocked without documented access.
|
|
- **User approval required:** No; this is the narrow intersection of explicit instructions.
|
|
- **Reversible:** Yes with new authority.
|
|
|
|
## DEC-005 — ADR-004 is superseded for the scoped local-first programme
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Implement one central local-first routing policy with controlled external fallback, while retaining existing models/configuration for rollback.
|
|
- **Reason/evidence:** ADR-004 and current architecture choose one deployment provider; `ollama.md:398-451,574-608` explicitly requires ordered routing/fallback and the user asked to execute it.
|
|
- **Alternatives considered:** keep one provider and ignore the new programme; scatter fallback in callers; both rejected.
|
|
- **Consequences:** ADR-004 must later be superseded/updated in its own cohesive package. No provider change occurs before privacy/entitlement/queue controls.
|
|
- **User approval required:** Already supplied by the programme request.
|
|
- **Reversible:** Yes; old provider path/config remains for rollback.
|
|
|
|
## DEC-006 — Free means no AI in the target policy
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** The target external plan model is Free (no AI, core non-AI tracking) and Pro (defined AI capabilities). Preserve existing user data and internal `Premium` compatibility while migrating behavior.
|
|
- **Reason/evidence:** `work.md:636-719` is explicit; current roadmap/code instead permits limited Free AI and uses `Premium`.
|
|
- **Alternatives considered:** retain existing limited Free AI; rejected because it contradicts the new programme.
|
|
- **Consequences:** POL-001 requires a deliberate server-side policy/compatibility package; copy changes cannot precede enforcement.
|
|
- **User approval required:** Already supplied.
|
|
- **Reversible:** Product policy is reversible later; data migration should remain additive.
|
|
|
|
## DEC-007 — One durable operation foundation
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Strategy Snapshot, CV processing and other long AI work share OPS-001/AI-001; feature packages supply handlers/results/UI only.
|
|
- **Reason/evidence:** Both programmes specify the same state, idempotency, retry, notification and restart requirements and explicitly warn against duplicate implementations.
|
|
- **Alternatives considered:** separate CV and Strategy queues; rejected as duplicated infrastructure and inconsistent behavior.
|
|
- **Consequences:** AI-003/AI-004 depend on the common foundation.
|
|
- **User approval required:** No; explicitly requested.
|
|
- **Reversible:** The model can be extended; duplicate queues should not be introduced.
|
|
|
|
## DEC-008 — New-table ownership is unresolved until provider-safe design
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Do not create operation/deletion tables until their package selects one schema owner and proves fresh/upgrade SQLite and MariaDB behavior.
|
|
- **Reason/evidence:** `docs/infrastructure/database-ownership.md` mandates reconciler DDL for current cross-provider tables, while audit JT-019 identifies dual schema ownership as a risk and the Phase 0 identity design prefers a real EF migration.
|
|
- **Alternatives considered:** silently follow either document; rejected because the conflict is material.
|
|
- **Consequences:** no migration is created in SEC-001; OPS-001 records the eventual choice and rollback evidence.
|
|
- **User approval required:** No now; ask only if the evidence leaves materially different safe choices.
|
|
- **Reversible:** Yes before schema deployment.
|
|
|
|
## DEC-009 — Production access is currently blocked, not guessed
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Mark production inventory/benchmark/rollout blocked while continuing safe repository work.
|
|
- **Reason/evidence:** existing backup/verification docs say this environment has no route or production credentials; only CI secret names and `/opt/job-tracker/app` are documented.
|
|
- **Alternatives considered:** guess SSH host/user or scan; explicitly prohibited.
|
|
- **Consequences:** PROD-001/003/004 and REL-001 cannot be `DONE`; sanitized templates/harnesses can still be built.
|
|
- **User approval required:** No.
|
|
- **Reversible:** Immediately when documented access is provided.
|
|
|
|
## DEC-010 — One canonical origin replaces provider callback overrides
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** `App:PublicBaseUrl` now builds Gmail and Microsoft Graph callback URLs; the old provider-specific redirect variables are removed from Compose and the example environment.
|
|
- **Reason/evidence:** Independent callback origins contradicted SEC-001's single-origin trust boundary and allowed configuration drift. Provider registrations must use the documented paths under the canonical origin.
|
|
- **Alternatives considered:** Accept overrides only after equality validation; rejected because it preserves duplicate configuration with no supported separate-origin use case.
|
|
- **Consequences:** Operators with legacy redirect variables must register/use `<APP_PUBLIC_BASE_URL>/api/gmail/oauth/callback` and `/api/microsoft-graph/oauth/callback`. Existing variables no longer affect the application.
|
|
- **User approval required:** No; this implements the approved canonical-origin prerequisite.
|
|
- **Reversible:** Yes by restoring validated overrides, but only if a real separate-origin requirement is established.
|
|
|
|
## DEC-011 — Dedicated one-hop nginx trust network
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Nginx and backend share a dedicated internal `WEB_PROXY_SUBNET`; forwarded headers are accepted for one hop only from that configured CIDR. Production Compose has no host-bound app or Ollama ports; development port bindings require `docker-compose.dev.yml` explicitly.
|
|
- **Reason/evidence:** Docker's dynamic/default/shared networks cannot safely identify nginx as the trusted hop, and the old auto-loaded override disabled proxy trust while exposing ports.
|
|
- **Alternatives considered:** clear all known proxy collections; trust the external shared network; assign a single static container IP. The first two trust too much, while a dedicated CIDR tolerates container replacement without pinning one container address.
|
|
- **Consequences:** production must inventory Docker networks and set a non-overlapping `WEB_PROXY_SUBNET` before deploy. External Traefik still requires separate operator verification.
|
|
- **User approval required:** No; this is the scoped security prerequisite.
|
|
- **Reversible:** Yes via version rollback and previous environment, but rollback must not reopen host ports unintentionally.
|
|
|
|
## DEC-012 — Nginx Host is derived, not separately configured
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** The frontend container derives nginx's exact server name at startup from `APP_PUBLIC_BASE_URL`; no second host setting exists. Unknown Hosts receive nginx 444 except `/health`.
|
|
- **Reason/evidence:** Hard-coding the current domain or introducing an independent nginx-host variable would violate the single canonical-origin contract and create drift.
|
|
- **Alternatives considered:** application-only Host rejection; separate `APP_EXTERNAL_HOST`; operator-only Traefik filtering. Each leaves one repository boundary weak or duplicates authority.
|
|
- **Consequences:** the frontend container fails fast on malformed/unsupported origins; IPv6 host literals are currently outside the deploy preflight contract.
|
|
- **User approval required:** No.
|
|
- **Reversible:** Yes; broaden only with matching parser, nginx and deployment tests.
|
|
|
|
## DEC-013 — Microsoft sign-in has one tenant-qualified trust path
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Microsoft ID tokens are accepted only by the exchange/link validator, which requires the configured account mode plus exact GUID `tid`/`oid` and issuer agreement. The raw Microsoft bearer scheme is removed. Email-like claims are metadata, not verified ownership.
|
|
- **Reason/evidence:** The UI already exchanges Microsoft tokens for local sessions; maintaining a second issuer-disabled API bearer path duplicated and weakened the trust decision. `oid` alone is tenant-scoped.
|
|
- **Alternatives considered:** harden both bearer and exchange paths; retain `common` implicitly in Production; use `sub` or email as identity. Each adds duplicated policy or preserves the audited ambiguity.
|
|
- **Consequences:** undocumented raw-token API clients stop working; Production must choose a tenant mode. Legacy identity ownership remains unresolved until SEC-004 and Microsoft must not be enabled there first.
|
|
- **User approval required:** No; this is the validated P0-1A contract.
|
|
- **Reversible:** The account mode is configurable; raw bearer support should return only with a documented requirement and the same policy/tests.
|
|
|
|
## DEC-014 — Split email ownership from session revocation
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Split the original SEC-005 into SEC-005A (session/recovery revocation) and SEC-005B (registration/pending email plus migration/UI).
|
|
- **Reason/evidence:** The revocation work uses the existing schema and is independently testable/rollbackable; pending email requires a coordinated database and frontend contract. Keeping both under one active item violated the requested small-package cycle.
|
|
- **Alternatives considered:** keep one broad item; rejected because its status could not accurately distinguish verified security behavior from an unstarted migration/UI flow.
|
|
- **Consequences:** SEC-004 depends on both children. Original source/audit references remain on each, so no requirement was lost.
|
|
- **User approval required:** No; this is tracking granularity within approved scope.
|
|
- **Reversible:** Yes by presenting them as one release, but their verification remains separate.
|
|
|
|
## DEC-015 — Pending email uses Identity tokens and one provider-aware EF migration
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Store only the proposed address and request time, rotate the Identity security stamp for each replacement request, and use the built-in change-email token. Add both fields through one EF migration whose SQLite and MariaDB column types are explicit; do not duplicate these Identity columns in the startup reconciler.
|
|
- **Reason/evidence:** The active email must remain authoritative until proof. Identity already binds tokens to user, new email, purpose and security stamp; stamp rotation makes the latest request win without another token table. Dry-run SQL showed SQLite-scaffolded types were unsafe for MariaDB until the migration branched by provider. Audit/schema decision P0-4B assigns these Identity fields to EF.
|
|
- **Alternatives considered:** immediately replace `Email`; store plaintext confirmation tokens; add a request table/nonce abstraction; add the same columns to startup reconciliation. The first two are unsafe, and the latter two add duplicate state/ownership without a demonstrated need.
|
|
- **Consequences:** deployment must run `20260802205800_AddPendingEmailChange` before the new API version. SQLite uses `TEXT`; MariaDB uses `varchar(320)` and `datetime(6)`. Rolling-version and MariaDB execution still require verification.
|
|
- **User approval required:** No; this is the smallest implementation of the approved ownership contract.
|
|
- **Reversible:** Yes via the migration `Down` before data relies on pending requests; active email data is unchanged.
|
|
|
|
## DEC-016 — SEC-005B remains short of local browser verification
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Mark SEC-005B `IMPLEMENTED — NOT VERIFIED`, not `VERIFIED LOCALLY` or `DONE`.
|
|
- **Reason/evidence:** all automated suites and an isolated API runtime pass, but the in-app browser denied localhost because its administrator policy check could not be verified. SMTP and MariaDB execution are also unavailable.
|
|
- **Alternatives considered:** infer browser behavior from component tests or claim the existing Docker UI; rejected because the running containers are old images and the programme forbids inferred test claims.
|
|
- **Consequences:** SEC-004 repository work can proceed, but SEC-005B retains explicit browser/provider/production acceptance checks.
|
|
- **User approval required:** No; truthful status accounting is required.
|
|
- **Reversible:** Yes immediately after the blocked checks pass.
|
|
|
|
## DEC-017 — Canonical Microsoft ownership never backfills legacy evidence
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Add nullable bounded `MicrosoftTenantId`/`MicrosoftObjectId` with one unique composite index, use only that pair for ownership, and leave every legacy subject/email row null-canonical until explicit dual-proof relinking.
|
|
- **Reason/evidence:** `oid` is tenant-scoped, legacy subjects may be `oid` or `sub`, and provider email is mutable metadata. A disposable migration rehearsal preserved duplicate legacy values and enforced unique proven pairs. The recovery ceremony requires both a purpose-bound token delivered to the confirmed app email and a fresh Microsoft token for the same pair.
|
|
- **Alternatives considered:** backfill from `common`, legacy subject, email or next-seen token; retain email fallback; add a general identity-provider framework. Each would merge unproven identities or add unrelated abstraction.
|
|
- **Consequences:** ambiguous/unconfirmed legacy users require operator assistance; production needs a counts-only inventory and relink window. Link/unlink revoke sessions, and passwordless unlink is refused until a safe provider reauthentication path exists.
|
|
- **User approval required:** No; this implements the approved JT-001 safety contract.
|
|
- **Reversible:** Additive schema is reversible before canonical data is relied upon. Application rollback must never restore email auto-linking.
|
|
|
|
## DEC-018 — Keep MariaDB date work in SQL and bound SQLite fallback by owner/job
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Branch only at the affected `DateTimeOffset` query roots: SQLite materializes owner/job-scoped rows before ordering or range comparison; MariaDB keeps server-side ordering, filtering, aggregation and pagination.
|
|
- **Reason/evidence:** the real SQLite provider throws before execution, while Pomelo generates the required SQL. Changing all timestamp storage would require a risky migration and editing response endpoints individually would leave CV cleanup/reprocess siblings broken. Real-provider tests and fresh HTTP rehearsal pass.
|
|
- **Alternatives considered:** global timestamp conversion/schema rewrite; always materialize on every provider; modify historical migrations; catch-and-retry translation exceptions. These add migration risk, production performance cost or hide separate JT-019 ownership drift.
|
|
- **Consequences:** SQLite work is bounded by tenant/job and current entitlement limits but still happens in memory; production MariaDB behavior is unchanged. If per-user AI history grows materially, a later UTC scalar column/index migration may be measured and designed.
|
|
- **User approval required:** No; this is the smallest root-cause correction within CORE-001.
|
|
- **Reversible:** Yes; revert the provider branches and relational test, with no data rollback.
|
|
|
|
## DEC-019 — Keep the editable interview board canonical and move the generated brief
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Keep `GET /interview-prep` for the durable editable `InterviewPrepItem` board, move the distinct cached/generated `InterviewPrepNote` response to `GET /interview-prep/brief`, and delete the unused flat timeline action so the grouped/filterable timeline remains canonical.
|
|
- **Reason/evidence:** both interview representations have active repository UI callers and incompatible DTOs, while only the newer timeline has a caller. Overloading by query parameter or deleting one live feature would preserve ambiguity or break behavior. Reflection and isolated HTTP tests now show one action per method/path with owner 200, other user 404 and anonymous 401.
|
|
- **Alternatives considered:** delete either interview feature; retain the old path with a discriminator; rename the editable board; merge DTOs. Each creates unnecessary compatibility state or breaks the current workspace contract.
|
|
- **Consequences:** undocumented direct consumers of the generated brief must adopt `/brief`; repository clients/docs are updated. No data or schema changes.
|
|
- **User approval required:** No; this is the smallest cohesive repair of confirmed JT-004.
|
|
- **Reversible:** Yes by restoring the route/client and flat action, but rollback also restores the exploitable availability defect and is not recommended.
|
|
|
|
## DEC-020 — Attachment final paths are the durable operation identity
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Represent recoverable attachment mutations as `<final>.uploading` and `<final>.deleting`; do not add a separate JSON journal, schema or periodic worker. Reconcile once after database initialization and preserve unknown plain files.
|
|
- **Reason/evidence:** every final path is already generated, unique and root-bounded. The suffix plus row existence encodes every required recovery decision, and real-SQLite failure injection proves upload promotion, delete restore/purge and idempotent restart behavior. A second journal would introduce dual durable state and another crash-ordering problem.
|
|
- **Alternatives considered:** JSON operation journal; database operation table; object-store abstraction; periodic/multi-replica reconciler. None is required for the current single-filesystem deployment and each adds coordination or migration cost.
|
|
- **Consequences:** recovery retries on safe restart rather than a timer; persistent failures remain observable until restart/operator action. Multi-replica or high-volume deployments must first add a lease and measured periodic reconciliation. SEC-009 must reuse these root/quarantine rules.
|
|
- **User approval required:** No; this is the smallest implementation of the approved JT-010 recovery contract.
|
|
- **Reversible:** Yes after draining/reviewing all suffix markers. No schema rollback exists; unknown plain orphans must never be guessed away.
|
|
|
|
## DEC-021 — Worker enumeration bypasses filters once, then re-enters owner scope
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** `BackgroundTenantRunner` may ignore tenant filters only to enumerate non-empty job owners. Each owner is processed sequentially in a new scope whose live `CurrentUserService` restores all normal query filters. Rules, reminders, daily export and enrichment receive separate default-false switches.
|
|
- **Reason/evidence:** hosted scopes have no HTTP identity and therefore returned zero rows. Leaving services on while fixing that root cause would unexpectedly start status mutations, file exports, email and AI calls. Real-SQLite tests prove owner filtering, per-owner settings, failure isolation and fake-only side effects.
|
|
- **Alternatives considered:** unfiltered queries throughout each worker; a privileged DbContext; automatic activation under legacy settings; a distributed scheduler. These enlarge the trust boundary, create rollout risk or solve unmeasured scale.
|
|
- **Consequences:** workers remain inert until explicitly enabled after OPS/POL prerequisites. Execution is sequential/single-instance; leasing and durable operations are the next package. Existing backup, probe and CV-run handling remain unchanged.
|
|
- **User approval required:** No; this is the requested safe foundation and does not activate production work.
|
|
- **Reversible:** Yes by keeping switches false and reverting the runner/service changes. Already-generated exports or user-visible mutations require separate reviewed rollback.
|
|
|
|
## DEC-022 — Durable operations are EF-owned and store references, not payloads
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Split OPS-001 into independently reviewable OPS-001A state/schema, OPS-001B notifications and OPS-001C APIs/UI. `UserOperations` is owned only by a provider-conditional EF migration; the startup reconciler does not create or alter it. The row stores bounded policy/subject references and no generic raw payload.
|
|
- **Reason/evidence:** a manually branched migration produces correct SQLite and bounded MariaDB DDL, avoiding the repository's old SQLite-type failure while reducing JT-019 dual ownership. CV/Strategy inputs already have durable domain IDs; copying private text into a queue row is unnecessary. Concurrent SQLite tests prove one idempotent row and one lease winner.
|
|
- **Alternatives considered:** extend `CvExtractionRun`; reconciler plus no-op migration; generic JSON payload; external queue/Redis; one large schema/UI package. These duplicate feature state, preserve dual ownership, increase private-data copies/infrastructure, or prevent small rollbackable review.
|
|
- **Consequences:** feature producers reference domain rows and must re-check entitlement/privacy before work. Notifications/API/UI follow without changing the operation identity. MariaDB execution remains a deployment gate.
|
|
- **User approval required:** No; this resolves the recorded DEC-008 conflict using repository evidence and the requested smallest reliable design.
|
|
- **Reversible:** Yes before consumers rely on rows; stop producers/drain rows before `Down`. Additive table may remain during application rollback.
|
|
|
|
## DEC-023 — One current generic notification is atomic with terminal operation state
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Store one owner-scoped `UserNotification` per current terminal operation outcome, committed in the same relational transaction. Use generic bounded text, no email delivery and no private operation/failure content. A manual retry removes the prior notification so the next terminal outcome can replace it.
|
|
- **Reason/evidence:** a unique nullable operation foreign key supplies database idempotency; a forced notification-write failure proves the terminal update rolls back. This reuses OPS-001A rather than introducing an outbox framework or a second queue.
|
|
- **Alternatives considered:** transient frontend notifications; email outbox; multiple immutable notifications per retry attempt; generic event bus. Transient state fails restart recovery, email is not authorized, and the latter two add delivery/history machinery not required by either programme.
|
|
- **Consequences:** OPS-001C can expose stable read/dismiss state without creating another notification model. Historical retry-attempt notifications are not retained; operation attempt/failure fields remain the technical state. MariaDB execution remains a deployment gate.
|
|
- **User approval required:** No; this implements the approved persistent-notification prerequisite without external side effects.
|
|
- **Reversible:** Yes before API/UI consumers rely on it. Older application versions tolerate the additive table; schema `Down` deletes notification state.
|
|
|
|
## DEC-024 — Operation APIs expose state, not worker internals
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Expose authenticated owner list/detail/cancel/retry and notification list/count/read/dismiss APIs, but no generic operation-create endpoint. Return only bounded user-facing state; omit idempotency keys, lease tokens, provider/model fields, raw failure text and result references. Use bounded polling rather than realtime infrastructure.
|
|
- **Reason/evidence:** feature producers must enforce entitlement/privacy and durable subject references before admission, so a generic create endpoint would bypass later policy. Existing Axios, MUI and browser events cover the UI without a dependency. Two-user HTTP checks prove copied identifiers return 404.
|
|
- **Alternatives considered:** WebSockets/SignalR; a generic JSON task API; exposing the full entity; merging reminders and operation notifications. These add infrastructure, unsafe authority or misleading counts without a current need.
|
|
- **Consequences:** AI-003/004 own feature admission and result navigation. The operation page polls every 15 seconds while mounted; the shell polls unread count every 60 seconds. Realtime delivery can be reconsidered only if measured UX/load requires it.
|
|
- **User approval required:** No; this is the smallest implementation of both programmes' stable status and notification contract.
|
|
- **Reversible:** Yes. UI/API removal leaves durable operation/notification data intact; application rollback can retain additive tables.
|
|
|
|
## DEC-025 — Public Pro policy uses live roles while retaining legacy billing identifiers
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Expose only `free` and `pro`; make Free AI entitlement and limits zero; authorize explicit AI actions with one live database-role policy; recheck queued/background work at execution; preserve the internal `Premium` Identity role and `Stripe:PricePremium` configuration key for billing/data compatibility.
|
|
- **Reason/evidence:** the new programme supersedes the old limited-Free-AI model. Claim-only authorization would let an already-issued session retain AI after downgrade, while renaming the persisted role/config now adds migration and rollback risk without changing user-visible behavior. Core job create/detail and deterministic enrichment were traced separately because they must still work when their optional model call is skipped.
|
|
- **Alternatives considered:** static `RequireRole`; guards copied into every controller; renaming the Identity role/config; wrapping every summarizer call in a new provider abstraction; blocking whole controllers. These leave stale-claim/worker bypasses, add scattered checks, create needless migration risk, pre-empt POL-002/AI-002, or hide existing non-AI data.
|
|
- **Consequences:** explicit locked APIs return stable `pro_required`; Admin maps to Pro; UI receives `ai`/`proThemes`; existing AI history and non-AI editing remain accessible. Usage accounting outside AI Workspace remains incomplete and blocks provider rollout/full POL-001 verification. PRODUCT-001 still owns removal of invented landing-page price/tier claims.
|
|
- **User approval required:** No; the programme explicitly requires Free=no-AI and centralized enforcement.
|
|
- **Reversible:** Yes as one repository-only policy/UI change with no schema update. Workers must remain off while rolling back to avoid restoring an entitlement bypass.
|
|
|
|
## DEC-026 — Classify synthetic AI workloads before finalizing privacy routing
|
|
|
|
- **Date:** 2026-08-02
|
|
- **Decision:** Advance PROD-002 immediately after POL-001 and before POL-002, even though the recommended list placed the general privacy policy first.
|
|
- **Reason/evidence:** POL-002 explicitly depends on task type, privacy class, payload shape, latency and fallback suitability. POL-001 produced the reachable-call inventory, and PROD-002 can safely classify it and create synthetic fixtures without production access or provider calls. Writing policy first would either duplicate this inventory or invent categories without fixtures.
|
|
- **Alternatives considered:** keep POL-002 next and revise it later; perform PROD-001 hardware inventory first; start queue implementation. The first creates churn, while the latter two are blocked by production access or need the privacy contract.
|
|
- **Consequences:** PROD-002 is the sole in-progress item; POL-002 follows with evidence-backed classes. No production/provider action is introduced.
|
|
- **User approval required:** No; the user directed dependency-aware reordering and conflict recording.
|
|
- **Reversible:** Yes; documentation/fixtures can be revised before routing code depends on them.
|
|
|
|
## DEC-027 — External AI needs two administrator/user gates and defaults to local
|
|
|
|
- **Date:** 2026-08-03
|
|
- **Decision:** Persist `AiEnabled` and `ExternalAiProcessingAllowed` per user; preserve AI-enabled behaviour for existing accounts, default external consent to false, and permit an external `/cv/*` request only when backend and sidecar administrator gates, a supported configured provider, live Pro entitlement, AI-enabled preference and explicit user consent all agree. Background calls without an authenticated request fail safe to local.
|
|
- **Reason/evidence:** the existing global sidecar `AI_PROVIDER` could route full CV data externally without a user decision. One backend policy plus a sidecar permission header closes that execution path without deleting rollback provider configuration or inventing the final AI-002 router.
|
|
- **Alternatives considered:** remove Gemini/Groq; rely on UI/local storage consent; trust one environment flag; refactor every AI interface now; silently use external when configured. These either break rollback compatibility, are bypassable, or prematurely duplicate AI-001/002.
|
|
- **Consequences:** disabling AI is enforced from live database state; external processing is off by default and needs deliberate two-sided configuration. True local-first fallback triggers, operation policy snapshots, provider/reason persistence, payload minimization and cost controls remain explicit AI-001/002 gates, so POL-002 is not overstated as fully verified.
|
|
- **User approval required:** No; this is the smallest safe implementation of the programme's explicit privacy controls and preserves provider configurations.
|
|
- **Reversible:** Yes. Application rollback should leave the additive preference columns in place; turning both administrator gates off immediately restores local-only processing without data loss.
|
|
|
|
## DEC-028 — Durable AI work extends UserOperations with a default-off typed worker
|
|
|
|
- **Date:** 2026-08-03
|
|
- **Decision:** Reuse OPS-001A/B/C for every long AI task. Add one task-handler worker and one admission service; expose no generic create endpoint. Admission stores only a domain subject reference and policy snapshot, enforces Pro/privacy/capacity/idempotency/deadline, and returns the existing stable status URL. Start at one worker and keep it disabled until real handlers and rollout checks pass.
|
|
- **Reason/evidence:** the existing operation store already supplies persistent states, atomic claims, leases, retries, cancellation, restart recovery, notifications and owner APIs/UI. A second CV/Strategy queue or Redis would duplicate proven state. A generic create API would let callers bypass task-specific ownership and payload validation.
|
|
- **Alternatives considered:** separate in-memory channel; Redis/Hangfire; one worker per feature; synchronous provider calls; generic public task creation; unbounded hosted-service parallelism. These lose restart state, duplicate infrastructure, expand authority or fail the congestion requirement.
|
|
- **Consequences:** AI-003/004 only add typed handlers/producers. Current capacity serialization is process-local for the documented single-backend deployment; database reservation is required before multiple backend replicas. Provider/model semaphores and circuit/provenance remain AI-002 responsibilities.
|
|
- **User approval required:** No; this follows both programmes' explicit instruction to reuse the smallest reliable existing infrastructure.
|
|
- **Reversible:** Yes. Keep the worker switch false, remove admission/worker registrations, and retain operation rows/API history. No new schema was added in this slice.
|
|
|
|
## DEC-029 — One sequential sidecar router owns local-first fallback
|
|
|
|
- **Date:** 2026-08-09
|
|
- **Decision:** Keep provider execution behind the existing sidecar boundary, make Ollama the default primary, permit at most one sequential external fallback, and carry the backend's rechecked privacy/task decision through the AI-001 execution scope. Reuse existing operation provider/model/progress fields for provenance; add no queue/provider schema or dependency.
|
|
- **Reason/evidence:** every generative `/cv/*` path already converges on one `_provider_generate` family, while deterministic tasks and `/summarize` must remain local. Sidecar fake-transport tests prove local success, consent/config/task/cost denials, schema fallback, circuit behavior, external failure and no parallel duplicate call. Backend tests prove policy propagation and success/failure provenance.
|
|
- **Alternatives considered:** provider selection in each controller; browser-selected providers; a second provider abstraction in .NET; simultaneous local/cloud racing; a new circuit/attempt table; increasing synchronous timeouts. These scatter policy, expose authority, duplicate the established boundary, risk double charge/output, add unneeded schema, or mask the queued-operation root cause.
|
|
- **Consequences:** `AI_ROUTING_MODE` supports `local_only`, `local_first` and explicitly gated `external_only`; invalid values fail closed. New durable task IDs stay local until allowlisted. The current circuit is process-local and one AI worker is the effective single-model concurrency limit. Per-request prompt size limits external spend/exposure, but complete monthly cross-feature accounting and model selection remain rollout gates.
|
|
- **User approval required:** No; this directly implements the approved local-first programme without invoking a provider or production service.
|
|
- **Reversible:** Yes. Set `EXTERNAL_AI_ENABLED=false` or `AI_ROUTING_MODE=local_only`; the older `AI_PROVIDER`/model configuration is retained. Existing nullable operation fields and AI history remain readable.
|
|
|
|
## DEC-030 — Strategy generation is one typed operation and one structured inference
|
|
|
|
- **Date:** 2026-08-09
|
|
- **Decision:** Make Focus Plan GET cache-only and move generation to typed `strategy.snapshot` work on the shared queue. Encode only job and at most four attachment IDs, reuse active operations, and replace four sequential model calls with one bounded JSON response whose complete shape is validated before the unique cache row is updated. Keep Strategy absent from the external fallback allowlist.
|
|
- **Reason/evidence:** the traced button/GET path owned four serial model calls and had no restart/cancel/retry identity. AI-001/002 already provide every needed state/policy/routing primitive. One structured inference reduces timeout exposure and makes publication atomic without a second queue or schema.
|
|
- **Alternatives considered:** increase HTTP/proxy timeouts; keep GET as a command; add a Strategy queue/table; store prompts/private text in operation payload; four model calls inside the worker; race external/local providers. These retain the root failure, duplicate infrastructure/private data/output, or violate established routing safety.
|
|
- **Consequences:** existing cached `FocusPlanDto` remains readable, while generation now returns 202 and the UI resumes by operation ID/context. Retry can overwrite only the same unique result row. Worker activation and real-model tuning remain rollout gates; operation records provide deduplication/provenance, not full monthly billing accounting.
|
|
- **User approval required:** No; both programmes explicitly require durable Strategy work and consolidation with AI-001/002.
|
|
- **Reversible:** Yes. Keep the worker off and revert `a621226`; no schema/dependency changed. Cancel or drain queued `strategy.snapshot` rows before removing the handler.
|
|
|
|
## DEC-031 — CV extraction runs own review data; UserOperations own execution
|
|
|
|
- **Date:** 2026-08-09
|
|
- **Decision:** Keep `CvExtractionRun` as the artifact/result/review record and make one typed `cv.process` operation reference its numeric ID. Replace the unbounded channel and separate hosted service with AI-001 admission/leases/retries/cancellation/notifications. Upload returns 202 after persistence; no raw CV payload is duplicated into operation state.
|
|
- **Reason/evidence:** the complete trace showed useful persistent review state but two competing execution mechanisms: synchronous upload and a process-local channel. Reusing both existing models gives restart-safe orchestration without a new queue/schema and preserves the mandatory accept/discard gate.
|
|
- **Alternatives considered:** raise proxy timeouts; keep synchronous upload; add a second CV queue/table; store raw CVs/prompts in operation payloads; replace extraction runs with generic operations. These retain the 504/lost-wakeup path, duplicate infrastructure/private data, or discard domain review/version history.
|
|
- **Consequences:** all four long CV actions share one default-off worker and operation UI. Parser-version/process isolation remains SEC-006/007; browser/model/MariaDB/production gates remain before rollout. Existing clients must accept the upload endpoint's 202 operation response.
|
|
- **User approval required:** No; both programmes explicitly require one durable operation foundation and preservation of human review.
|
|
- **Reversible:** Yes. Keep the worker off, revert `c3c5af8`, and retain operation/extraction rows. Cancel or drain `cv.process` rows before removing the handler.
|