Skip to content

feat(hub): add decision model control plane - #301

Merged
alliscode merged 8 commits into
build/hub/newfrom
alliscode-hub-decision-control-plane
Nov 19, 2026
Merged

alliscode merged 8 commits into
build/hub/newfrom
alliscode-hub-decision-control-plane

Conversation

@alliscode

@alliscode alliscode commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

Teams need Hub to coordinate customer-specific decision-model training without moving private screenshots, credentials, or model artifacts into Hub. This adds the backend contract that lets repository administrators opt in, review measured candidates, explicitly promote or reject them, evaluate Builds through the promoted model, and withdraw training data from customer-operated runtimes.

What changes

Hub now prepares and pins training inputs from accepted learnings and Build artifacts, transfers private tasksets to the customer-operated runtime, and uses BullMQ to submit, poll, recover, and cancel bounded training jobs.

flowchart LR
  evidence[Accepted learnings and Build screenshots] --> taskset[Pinned private taskset]
  taskset --> runtime[Customer-operated runtime]
  runtime --> candidate[Measured candidate]
  candidate --> decision[Administrator review]
  decision --> promoted[Promoted model]
  promoted --> evaluation[Saved Build findings]
Loading

PostgreSQL stores repository settings, job and candidate references, held-out metrics, attributed usage and cost, rejection decisions, promotion history, saved Build findings, and content-free runtime copy and deletion receipt references. It does not store runtime credentials, tasksets, screenshots, learning text in findings, adapters, reports, or weights.

The API exposes authoritative preflight coverage, absolute and per-learning candidate metrics, runtime duration and usage, rejection, rollback availability, promotion history, saved findings, and safe withdrawal status. Repository-administrator authority remains behind an explicit seam until broader repository roles are modeled.

The runtime client uses the merged taskset upload, cancellation, hard-credit-budget, authoritative usage, generation-checked promotion, copy disclosure, and deletion receipt contracts. A withdrawal blocks new upload, training, promotion, rollback, and evaluation while Hub reconciles deletion receipts after retries or restart. Activation still needs the concrete taskset source that combines stored Build screenshots with accepted-learning exports and registers these processors in the worker composition.

@alliscode
alliscode requested review from a team and nshki as code owners November 19, 2026 17:30
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical issues can expose private learning data, break repository isolation, and leave paid training untracked while prematurely releasing credit reservations.

29 open issues

And 9 more that still need to be addressed.

What changed in this PR

Adds Hub’s backend contracts for repository-specific decision-model training, administrator candidate review, promotion, rollback, and saved Build evaluations. Training and model artifacts remain on customer-operated infrastructure. Activation still requires the concrete taskset source.

Changes:

  • Adds administrator APIs for settings, training jobs, candidate decisions, and Build evaluation.
  • Introduces the runtime client, background processing, persistence, usage accounting, and security audits.
  • Adds database migrations, automated coverage, configuration examples, and operating documentation.
File Description
hub/​test/​database/​decision-model-migration/​index.db.test.ts Adds migration upgrade coverage.
hub/​server/​routes/​types.ts Adds decision-model route dependencies.
hub/​server/​routes/​index.ts Registers decision-model endpoints.
hub/​server/​routes/​api/​security-audits/​present-security-audit/​index.ts Presents decision-model audit details.
hub/​server/​routes/​api/​decision-model/​types.ts Defines overview and route contracts.
hub/​server/​routes/​api/​decision-model/​training-jobs/​post/​index.ts Accepts training requests.
hub/​server/​routes/​api/​decision-model/​training-jobs/​get/​index.ts Returns training-job state.
hub/​server/​routes/​api/​decision-model/​training-jobs/​cancel/​post/​index.ts Exposes training cancellation.
hub/​server/​routes/​api/​decision-model/​rollback/​post/​index.ts Exposes generation-checked rollback.
hub/​server/​routes/​api/​decision-model/​respond-decision-model-error/​index.ts Maps domain and runtime errors.
hub/​server/​routes/​api/​decision-model/​read-decision-model-session/​index.ts Restores the requesting session.
hub/​server/​routes/​api/​decision-model/​read-administrator/​index.ts Requires administrator access.
hub/​server/​routes/​api/​decision-model/​patch/​index.ts Validates and saves settings.
hub/​server/​routes/​api/​decision-model/​index.test.ts Covers access and API presentation.
hub/​server/​routes/​api/​decision-model/​get/​index.ts Returns the repository overview.
hub/​server/​routes/​api/​decision-model/​create-decision-model-route-dependencies/​index.ts Composes API dependencies and projections.
hub/​server/​routes/​api/​decision-model/​candidates/​rejection/​post/​index.ts Accepts candidate rejection reasons.
hub/​server/​routes/​api/​decision-model/​candidates/​promotion/​post/​index.ts Exposes candidate promotion.
hub/​server/​routes/​api/​decision-model/​builds/​evaluation/​post/​index.ts Requests Build evaluation.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​types.ts Extends parsed audit types.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​index.ts Validates decision-model audit events.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​index.test.ts Covers new audit-event types.
hub/​server/​repositories/​security-audits/​get-security-audit-data/​index.ts Builds stored audit projections.
hub/​server/​repositories/​security-audits/​create-security-audit/​types.ts Defines decision-model audit contracts.
hub/​server/​repositories/​decision-training-jobs/​update-decision-training-job/​index.ts Persists conditional state and usage updates.
hub/​server/​repositories/​decision-training-jobs/​sum-decision-training-usage/​index.ts Aggregates recorded credit usage.
hub/​server/​repositories/​decision-training-jobs/​list-active-decision-training-jobs/​index.ts Selects jobs for recovery.
hub/​server/​repositories/​decision-training-jobs/​get-decision-training-job/​index.ts Reads repository-scoped jobs.
hub/​server/​repositories/​decision-training-jobs/​decision-training-jobs.db.test.ts Covers reservations and terminal transitions.
hub/​server/​repositories/​decision-training-jobs/​create-or-get-decision-training-job/​index.ts Creates or reuses keyed requests.
hub/​server/​repositories/​decision-model-promotions/​save-decision-model-promotion/​index.ts Records promotion history.
hub/​server/​repositories/​decision-model-promotions/​get-decision-model-promotion/​index.ts Reads the latest promotion.
hub/​server/​repositories/​decision-model-configurations/​save-decision-model-configuration/​index.ts Saves versioned repository settings.
hub/​server/​repositories/​decision-model-configurations/​get-decision-model-overview/​index.ts Loads recent control-plane records.
hub/​server/​repositories/​decision-model-configurations/​get-decision-model-configuration/​index.ts Reads repository settings.
hub/​server/​repositories/​decision-candidates/​save-decision-candidate/​index.ts Persists immutable candidate evidence.
hub/​server/​repositories/​decision-candidates/​reject-decision-candidate/​index.ts Records candidate rejection.
hub/​server/​repositories/​decision-candidates/​get-decision-candidate/​index.ts Looks up repository candidates.
hub/​server/​repositories/​decision-candidates/​decision-candidates.db.test.ts Covers metrics, usage, and rejection.
hub/​server/​repositories/​decision-build-evaluations/​save-decision-build-evaluation/​index.ts Persists Build findings and references.
hub/​server/​integrations/​postgres/​with-decision-model-control-lock/​index.ts Serializes decision-control operations.
hub/​server/​integrations/​postgres/​with-decision-model-control-lock/​index.db.test.ts Covers contention and connection loss.
hub/​server/​integrations/​decision-runtime/​create-decision-runtime-client/​types.ts Defines runtime integration contracts.
hub/​server/​integrations/​decision-runtime/​create-decision-runtime-client/​index.ts Implements authenticated runtime requests.
hub/​server/​integrations/​decision-runtime/​create-decision-runtime-client/​index.test.ts Covers requests and response validation.
hub/​server/​integrations/​decision-runtime/​create-decision-runtime-client/​errors.ts Defines typed runtime failures.
hub/​server/​index.ts Validates optional runtime configuration.
hub/​server/​domains/​decision-model/​validate-decision-model-settings/​index.ts Enforces settings bounds.
hub/​server/​domains/​decision-model/​validate-decision-model-settings/​index.test.ts Covers settings validation boundaries.
hub/​server/​domains/​decision-model/​types.ts Defines domain and persistence interfaces.
hub/​server/​domains/​decision-model/​rollback-decision-candidate/​index.ts Coordinates rollback and persistence.
hub/​server/​domains/​decision-model/​request-decision-training/​index.ts Prepares and reserves training requests.
hub/​server/​domains/​decision-model/​reject-decision-candidate/​index.ts Coordinates protected rejection decisions.
hub/​server/​domains/​decision-model/​read-decision-runtime-configuration/​index.ts Reads runtime connection configuration.
hub/​server/​domains/​decision-model/​promote-decision-candidate/​index.ts Coordinates generation-checked promotion.
hub/​server/​domains/​decision-model/​process-decision-training-job/​index.ts Uploads, submits, and polls training.
hub/​server/​domains/​decision-model/​prepare-decision-taskset/​index.ts Validates and pins preparation inputs.
hub/​server/​domains/​decision-model/​jobs/​recover-decision-training.ts Defines the recovery schedule.
hub/​server/​domains/​decision-model/​jobs/​decision-training.ts Defines training payloads and retries.
hub/​server/​domains/​decision-model/​evaluate-build-with-decision-model/​index.ts Evaluates Builds and saves findings.
hub/​server/​domains/​decision-model/​errors.ts Defines control-plane domain errors.
hub/​server/​domains/​decision-model/​create-decision-model-store/​index.ts Composes transactions, accounting, and audits.
hub/​server/​domains/​decision-model/​create-decision-model-job-processors/​index.ts Creates training and recovery processors.
hub/​server/​domains/​decision-model/​create-decision-model-job-processors/​index.test.ts Covers scheduling and polling outcomes.
hub/​server/​domains/​decision-model/​create-current-administrator-decision-authorization/​index.ts Isolates current administrator authorization.
hub/​server/​domains/​decision-model/​cancel-decision-training/​index.ts Coordinates cancellation and terminal outcomes.
hub/​server/​create-app/​index.ts Wires dependencies and route-specific parsing.
hub/​schema/​repository.prisma Adds repository control-plane relations.
hub/​schema/​migrations/​20261203150000_decision_model_ux_contracts/​migration.sql Adds metrics, rejection, and usage fields.
hub/​schema/​migrations/​20261203140000_decision_model_control_plane/​migration.sql Creates control-plane tables and constraints.
hub/​schema/​membership.prisma Adds administrator attribution relations.
hub/​schema/​decision-training-job.prisma Models pinned training jobs.
hub/​schema/​decision-training-job-state.enum.prisma Defines persisted training states.
hub/​schema/​decision-promotion-operation.enum.prisma Defines promotion and rollback operations.
hub/​schema/​decision-model-promotion.prisma Models promotion generations and history.
hub/​schema/​decision-model-configuration.prisma Models repository opt-in and limits.
hub/​schema/​decision-candidate.prisma Models candidate evidence and rejection.
hub/​schema/​decision-build-evaluation.prisma Models saved Build evaluations.
hub/​schema/​build.prisma Links Builds to evaluations.
hub/​docs/​README.md Links the control-plane guide.
hub/​docs/​decision-model-control-plane.md Documents contracts, lifecycle, and activation.
hub/​docs/​database.md Documents persistence invariants.
hub/​docs/​background-jobs.md Describes training and recovery jobs.
hub/​docs/​architecture.md Summarizes the new backend boundary.
hub/​.env.example Adds optional runtime configuration examples.

Review effort: Max (adaptive)

@alliscode
alliscode force-pushed the alliscode-hub-decision-control-plane branch 2 times, most recently from 451ea15 to d21c08f Compare November 19, 2026 20:43
Ben Thomas and others added 8 commits November 19, 2026 13:21
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@alliscode
alliscode force-pushed the alliscode-hub-decision-control-plane branch from d21c08f to d5f57de Compare November 19, 2026 21:24
@alliscode
alliscode merged commit fa05671 into build/hub/new Nov 19, 2026
51 checks passed
@alliscode
alliscode deleted the alliscode-hub-decision-control-plane branch November 19, 2026 21:37
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.

3 participants