Skip to content

feat(hub): review suggested learning updates - #402

Draft
nshki wants to merge 4 commits into
nshki/feat/hub/learning-update-suggestionsfrom
nshki/feat/hub/review-learning-updates
Draft

nshki wants to merge 4 commits into
nshki/feat/hub/learning-update-suggestionsfrom
nshki/feat/hub/review-learning-updates

Conversation

@nshki

@nshki nshki commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

Hub now asks Copilot for better wording when later Builds keep showing the same problem with a learning. Those suggestions only wait in the learning store, though. People need to see them, decide whether to use them, and compare how the old wording did against the new one.

What changes

An active learning's detail view now shows a Suggested update section when Copilot has one. It shows the issue, the new wording, why Copilot suggested it, and links to the Builds that showed the issue. For example, "Use one primary button per form" gets a suggestion that says which button wins when two actions are equal.

People who can decide on learnings can apply or dismiss the suggestion, and both need a reason. Apply update opens the suggested title and wording in a form so they can adjust it first. Agents then get it as the learning's next version. Dismiss closes it, and Copilot only suggests the same issue again after new Builds show it.

The detail view also gains an Earlier guidance section. It lists each wording agents had before, with the scores that wording got, so people can tell whether an update helped. When the last check found too few Builds to suggest anything, Observed outcomes says so.

These decisions use the same durable decision record as edits. Hub stores the suggestion's ID on it and checks the suggestion is still open and belongs to the learning before running anything. Both decisions pass the record's ID to the package. After a crash, recovery asks the package whether the apply landed, and counts a dismissal as Hub's own only when it carries that ID. An apply that saved the new wording but stopped before closing the suggestion still counts as applied, because agents already get the wording.

sequenceDiagram
    participant P as Person
    participant H as Hub
    participant L as Learning package
    P->>H: Apply update (reason, wording)
    H->>H: Save decision record with suggestion ID
    H->>L: updates (check the suggestion is open and this learning's)
    H->>L: apply-update --operation-id
    L-->>H: New version
    H->>H: Finish decision and write audit
    Note over H,L: After a crash, recovery asks the package<br/>whether this operation landed
Loading

Needs design review

  • After a crash between saving the new wording and closing the suggestion, recovery counts the apply as successful but leaves the suggestion marked stale. Finishing it properly would mean re-running the apply, which needs the reason Hub doesn't keep.
  • The apply form always sends a title, prefilled with the current one when the suggestion keeps it. This follows the edit form. A suggested title can't be left empty, since the package rejects that.
  • Applied wording can be up to 2,000 characters, so the server rejects a longer suggestion until someone shortens it.
  • Hub hides a suggestion when any score behind it no longer has a Build or its screenshot was withheld. The page only links Builds, never the raw scores.
  • Copilot's wording isn't filtered for instructions aimed at agents. A person reads it, can edit it, and gives a reason before it reaches agents, the same as an edit.
  • The learning package gains an optional operation ID on dismissals, so Hub can tell its own dismissal from another administrator's.

Storybook screenshots

Hub/Pages/Learnings › Suggested Update (light, 1280×1500)

Suggested update with issue, new wording, reasoning, Build links, and Apply and Dismiss buttons

Hub/Pages/Learnings › Applying Suggested Update (light, 1280×1500)

Apply update dialog with title, guidance, and reason fields

Hub/Pages/Learnings › Earlier Guidance (light, 1280×1500)

Earlier guidance section listing version 2 wording and its score

Hub/Pages/Learnings › Update Needs More Evidence (light, 1280×1500)

Observed outcomes with a note that not enough Builds show the same issue

@nshki
nshki added this pull request to stack #367 November 26, 2026 10:48
@nshki
nshki requested an adaptive review from Copilot November 26, 2026 10:48

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

An outdated database constraint blocks every apply/dismiss request, while consent-filtering and decision-recovery flaws can expose withdrawn details or falsely record successful actions.

10 open issues
What changed in this PR

Connects Hub’s generated learning-update suggestions to its review workflow, letting authorized users revise guidance and compare results across versions.

Changes:

  • Adds suggested-update details and apply/dismiss forms that require a reason.
  • Extends decision APIs, persistence, audit types, and crash recovery for suggestion decisions.
  • Displays earlier guidance and insufficient-evidence feedback, with supporting stories, tests, and documentation.
File Description
hub/​server/​routes/​api/​learnings/​types.ts Extends history dependencies with updates and earlier guidance.
hub/​server/​routes/​api/​learnings/​decision/​post/​index.ts Validates apply and dismiss requests.
hub/​server/​routes/​api/​learnings/​create-learnings-route-dependencies/​learning-outcomes.db.test.ts Updates history fixtures for the expanded response.
hub/​server/​routes/​api/​learnings/​create-learnings-route-dependencies/​index.ts Projects historical outcomes and persists proposal IDs.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​index.ts Accepts the new decision event types.
hub/​server/​repositories/​security-audits/​create-security-audit/​types.ts Extends typed learning-decision audits.
hub/​server/​repositories/​learning-update-runs/​find-latest-learning-update-result/​index.ts Reads the latest successful update-check result.
hub/​server/​repositories/​learning-decision-operations/​create-learning-decision-operation/​index.ts Supports suggestion decisions and proposal IDs.
hub/​server/​domains/​learning/​types.ts Defines suggestion and earlier-guidance domain types.
hub/​server/​domains/​learning/​reconcile-learning-decision-operation/​index.ts Adds recovery paths for suggestion decisions.
hub/​server/​domains/​learning/​reconcile-learning-decision-operation/​index.test.ts Covers completed and partially saved applies.
hub/​server/​domains/​learning/​get-learning-history/​index.ts Loads open suggestions and groups historical wording with scores.
hub/​server/​domains/​learning/​get-learning-history/​index.test.ts Covers suggestion filtering and historical scores.
hub/​server/​domains/​learning/​execute-learning-decision/​index.ts Checks proposal ownership and invokes package decisions.
hub/​server/​domains/​learning/​execute-learning-decision/​index.test.ts Covers apply arguments and cross-learning rejection.
hub/​server/​domains/​learning/​create-learning-job-processors/​index.ts Extends recovery audit typing.
hub/​schema/​migrations/​20261228090000_learning_update_decisions/​migration.sql Adds the persisted proposal-ID column.
hub/​schema/​learning-decision-operation.prisma Models the optional proposal ID.
hub/​docs/​learning-foundation.md Documents suggestion review and earlier guidance.
hub/​client/​pages/​learnings-page/​stories.tsx Adds suggestion, apply-dialog, and historical-guidance stories.
hub/​client/​features/​learnings-library/​types.ts Adds presentation types for the new detail sections.
hub/​client/​features/​learnings-library/​styles.css Styles suggested wording and earlier-guidance groups.
hub/​client/​features/​learnings-library/​index.tsx Renders suggestions, decision dialogs, and earlier guidance.
hub/​client/​application/​hub/​view-models/​learnings-library/​index.ts Maps history into detail sections and Build links.
hub/​client/​application/​hub/​view-models/​learnings-library/​index.test.ts Covers suggestion support-link mapping.
hub/​client/​application/​hub/​routes/​settings-learnings/​index.tsx Builds apply and dismiss request bodies.
hub/​client/​application/​hub/​learnings-contracts/​types.ts Extends browser request and response types.
hub/​client/​application/​hub/​learnings-contracts/​index.ts Validates expanded history and decision contracts.

Review effort: Max (adaptive)

nshki and others added 4 commits November 26, 2026 03:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
@nshki
nshki force-pushed the nshki/feat/hub/review-learning-updates branch from 080181c to 7c552cf Compare November 26, 2026 11:51
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