From 35e901a7df524d95136528a8fb976adfa0d748f5 Mon Sep 17 00:00:00 2001 From: Mariano Fuentes Date: Thu, 7 May 2026 14:36:29 +0100 Subject: [PATCH 1/3] fix(onboarding): prevent mitigation steps flashing complete (#2786) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: address cubic review findings on onboarding PR P1: Add metadata.set('policies', true) after policy fan-out so the tracker boolean flag is set. P1: Log batchTriggerAndWait failures in vendor/risk mitigation fan-outs instead of silently ignoring them. P2: Strip {{#if}}/{{/if}} markers from mixed-content nodes so template syntax doesn't leak into rendered policies. P2: Fix stale onboardingTriggerJobId locking publish button in ToDoOverview. Co-Authored-By: Claude Opus 4.7 (1M context) * fix: strip only first marker occurrence to preserve nested conditionals The global regex flag in stripMarkerText would remove ALL matching {{#if}}/{{/if}} markers in a subtree, corrupting boundaries of nested conditional blocks. Removed the g flag so only the first occurrence (the one that triggered the match) is stripped. Co-Authored-By: Claude Opus 4.7 (1M context) * test(onboarding): add comprehensive tests for policy template processor Covers placeholder replacement, inline/multi-node/nested conditionals, mixed content nodes, edge cases, buildVariables, buildFlags, processTemplate. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): treat zero-item steps as complete in tracker When an org has no vendors or risks, `total > 0 && completed >= total` evaluates to false, causing those steps to appear stuck forever. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): prevent mitigation steps from flashing complete on load Revert zero-item guard (total === 0 ||) back to (total > 0 &&) — before totals metadata is set, the default of 0 caused steps to appear complete then flip back to in-progress once actual totals arrived. Also add missing risksTotal/risksInfo metadata alongside vendorsTotal so risk mitigation progress tracks correctly in the UI. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): show created/total format for vendor and risk creation steps Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.7 (1M context) --- .../app/(app)/[orgId]/components/OnboardingTracker.tsx | 9 ++++++--- .../src/trigger/tasks/onboarding/onboard-organization.ts | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx b/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx index 207b78a8ae..31b692d0b7 100644 --- a/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx +++ b/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx @@ -666,15 +666,18 @@ export const OnboardingTracker = ({ onboarding }: { onboarding: Onboarding }) => } // Simple step row (creation, linkage) - const count = step.key === 'vendors' ? uniqueVendorsCounts.total + const total = step.key === 'vendors' ? uniqueVendorsCounts.total : step.key === 'risk' ? stepStatus.risksTotal : null; + const created = step.key === 'vendors' && stepStatus.vendors ? uniqueVendorsCounts.total + : step.key === 'risk' && stepStatus.risk ? stepStatus.risksTotal + : 0; return (
{stepIcon} {step.label} - {count !== null && count > 0 && ( - {count} + {total !== null && total > 0 && ( + {created}/{total} )}
); diff --git a/apps/app/src/trigger/tasks/onboarding/onboard-organization.ts b/apps/app/src/trigger/tasks/onboarding/onboard-organization.ts index e9d6978964..690b26c543 100644 --- a/apps/app/src/trigger/tasks/onboarding/onboard-organization.ts +++ b/apps/app/src/trigger/tasks/onboarding/onboard-organization.ts @@ -151,6 +151,13 @@ export const onboardOrganization = task({ payload.organizationId, organization.name, ); + metadata.set('risksTotal', created.length); + metadata.set('risksCompleted', 0); + metadata.set('risksRemaining', created.length); + metadata.set( + 'risksInfo', + created.map((r) => ({ id: r.id, name: r.description?.slice(0, 80) ?? r.id })), + ); if (created.length > 0) { created.forEach((risk) => { metadata.set(`risk_${risk.id}_status`, 'assessing'); From a60e4c537a4a524dd3bc3810f4d657d1a3bd99b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 14:52:12 +0100 Subject: [PATCH 2/3] fix(onboarding): tracker N/N format + reranker timeout (#2788) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: address cubic review findings on onboarding PR P1: Add metadata.set('policies', true) after policy fan-out so the tracker boolean flag is set. P1: Log batchTriggerAndWait failures in vendor/risk mitigation fan-outs instead of silently ignoring them. P2: Strip {{#if}}/{{/if}} markers from mixed-content nodes so template syntax doesn't leak into rendered policies. P2: Fix stale onboardingTriggerJobId locking publish button in ToDoOverview. Co-Authored-By: Claude Opus 4.7 (1M context) * fix: strip only first marker occurrence to preserve nested conditionals The global regex flag in stripMarkerText would remove ALL matching {{#if}}/{{/if}} markers in a subtree, corrupting boundaries of nested conditional blocks. Removed the g flag so only the first occurrence (the one that triggered the match) is stripped. Co-Authored-By: Claude Opus 4.7 (1M context) * test(onboarding): add comprehensive tests for policy template processor Covers placeholder replacement, inline/multi-node/nested conditionals, mixed content nodes, edge cases, buildVariables, buildFlags, processTemplate. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): treat zero-item steps as complete in tracker When an org has no vendors or risks, `total > 0 && completed >= total` evaluates to false, causing those steps to appear stuck forever. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): prevent mitigation steps from flashing complete on load Revert zero-item guard (total === 0 ||) back to (total > 0 &&) — before totals metadata is set, the default of 0 caused steps to appear complete then flip back to in-progress once actual totals arrived. Also add missing risksTotal/risksInfo metadata alongside vendorsTotal so risk mitigation progress tracks correctly in the UI. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): show created/total format for vendor and risk creation steps Co-Authored-By: Claude Opus 4.6 (1M context) * fix(linkage): add 30s timeout to reranker LLM calls A hung AI Gateway request was blocking the entire linkage step indefinitely. The fallback in run-linkage.ts already handles rerank failures gracefully (falls back to cosine ordering). Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Mariano Co-authored-by: Claude Opus 4.7 (1M context) --- apps/app/src/lib/rerank-suggestions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/app/src/lib/rerank-suggestions.ts b/apps/app/src/lib/rerank-suggestions.ts index 1dad5df7c6..f9cd37692c 100644 --- a/apps/app/src/lib/rerank-suggestions.ts +++ b/apps/app/src/lib/rerank-suggestions.ts @@ -113,6 +113,7 @@ export async function rerankSuggestions({ system: SYSTEM_PROMPT, prompt: userPrompt, schema: rerankSchema, + abortSignal: AbortSignal.timeout(30_000), }); const scoreMap = new Map( From d9308beeb9326004dee94a40e3e8df3eb93e5e03 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 15:02:13 +0100 Subject: [PATCH 3/3] [dev] [Marfuen] mariano/cubic-fixes (#2789) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: address cubic review findings on onboarding PR P1: Add metadata.set('policies', true) after policy fan-out so the tracker boolean flag is set. P1: Log batchTriggerAndWait failures in vendor/risk mitigation fan-outs instead of silently ignoring them. P2: Strip {{#if}}/{{/if}} markers from mixed-content nodes so template syntax doesn't leak into rendered policies. P2: Fix stale onboardingTriggerJobId locking publish button in ToDoOverview. Co-Authored-By: Claude Opus 4.7 (1M context) * fix: strip only first marker occurrence to preserve nested conditionals The global regex flag in stripMarkerText would remove ALL matching {{#if}}/{{/if}} markers in a subtree, corrupting boundaries of nested conditional blocks. Removed the g flag so only the first occurrence (the one that triggered the match) is stripped. Co-Authored-By: Claude Opus 4.7 (1M context) * test(onboarding): add comprehensive tests for policy template processor Covers placeholder replacement, inline/multi-node/nested conditionals, mixed content nodes, edge cases, buildVariables, buildFlags, processTemplate. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): treat zero-item steps as complete in tracker When an org has no vendors or risks, `total > 0 && completed >= total` evaluates to false, causing those steps to appear stuck forever. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): prevent mitigation steps from flashing complete on load Revert zero-item guard (total === 0 ||) back to (total > 0 &&) — before totals metadata is set, the default of 0 caused steps to appear complete then flip back to in-progress once actual totals arrived. Also add missing risksTotal/risksInfo metadata alongside vendorsTotal so risk mitigation progress tracks correctly in the UI. Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): show created/total format for vendor and risk creation steps Co-Authored-By: Claude Opus 4.6 (1M context) * fix(linkage): add 30s timeout to reranker LLM calls A hung AI Gateway request was blocking the entire linkage step indefinitely. The fallback in run-linkage.ts already handles rerank failures gracefully (falls back to cosine ordering). Co-Authored-By: Claude Opus 4.6 (1M context) * fix(onboarding): hide mitigation steps until creation is done Don't render "Assessing Vendors"/"Assessing Risks" steps until their prerequisite creation step completes. Prevents the step from flashing as complete before totals metadata arrives. Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Mariano Co-authored-by: Claude Opus 4.7 (1M context) --- .../app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx b/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx index 31b692d0b7..ba9b358f70 100644 --- a/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx +++ b/apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx @@ -525,6 +525,9 @@ export const OnboardingTracker = ({ onboarding }: { onboarding: Onboarding }) => {/* Step progress - scrollable */}
{ONBOARDING_STEPS.map((step) => { + if (step.key === 'vendorMitigations' && !stepStatus.vendors) return null; + if (step.key === 'riskMitigations' && !stepStatus.risk) return null; + const isCurrent = currentStep?.key === step.key; const isCompleted = stepStatus[step.key as keyof typeof stepStatus] === true;