Skip to content

fix(profiles): the last 11 envelope mismatches, and one live bug among them - #750

Merged
thinkclay merged 1 commit into
mainfrom
claude/744-fix-11
Sep 11, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/744-fix-11

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #744. BASELINE_MISMATCHES goes to empty.

Nine were real and are fixed in Scaffald/sdk#30 (merged); two were the guard's own false positives.

Seven declared the payload against a route that wraps

apiKeys.update, apiKeys.getUsage, connections.accept, connections.send, engagement.track, follows.followJob, follows.followUser.

They unwrap now — as 39 other methods in the SDK already do — rather than widening the signature. That is the fix that makes callers work rather than merely type-check:

export function useUpdateApiKeyMutation(
  options?: UseMutationOptions<ApiKey, Error, …>   // already expects the payload
)

The hook, the screens and the declared type were all right. Only the runtime value was wrong.

Two declared an envelope their route does not send — and this one was live

personalityAssessments.getStatus and getIPIPStatus declared { data: … }. Probed against the running api, both answer bare. So every consumer reading status?.data has been reading undefined:

file code
PersonalityAssessmentWidget.tsx const assessment = assessmentData?.data
usePersonalityAssessment.ts const assessment = assessmentData?.data
useAssessmentStatus.ts cast through { data?: … } purely to compile

All three corrected here.

A fourth, LuscherTestWizard.tsx, already carried the workaround and the diagnosis:

// SDK type declares { data: AssessmentStatus } but API returns AssessmentStatus directly
const assessment = assessmentData
  ? (assessmentData.data ?? (assessmentData as unknown as …))
  : undefined

That ?? fallback is why one screen worked while the other three silently did not. Someone hit this, diagnosed it correctly, and patched it locally. Now that the type is right, the fallback goes too.

Typecheck found that fourth site on its own once the declaration stopped lying — which is the whole argument for fixing the type rather than the call sites.

Two were the guard's false positives

auth.getUserRoles and jobs.officeDuplicateJob do unwrap, through spellings the detector did not recognise:

return { roles: response.data.roles }            // reshapes while unwrapping
.then((res) => res.data)
const response = (await this.get<…>(p)) as {…}   // parenthesised cast

Detection is now precise about the thing that matters: find the name the response is bound to, then ask whether the body reads .data off it.

Widening it that way first hid four real unwraps in background-checks and feedback, because the binding regex did not allow the parenthesised form. The baseline's own stale check caught that — which is exactly what that half of the guard is for, and a good argument for enforcing baselines in both directions.

Re-attacked after the change

A too-permissive unwrap detector would mask the class the guard exists to catch, so I re-ran the probes:

probe result
revert engagement.track to its pre-fix form caught — "sdk says bare, route says wrapped"
legitimate unwrapping not flagged

Verified

scf-core typecheck and its 1151 tests pass; deno fmt --check and deno lint clean; contract directory 9/9.

Closes #744

@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


…g them

Clears BASELINE_MISMATCHES to empty. Nine were real and are fixed in
Scaffald/sdk#30; two were this test's own false positives.

**Seven declared the payload against a route that wraps** — apiKeys.update,
apiKeys.getUsage, connections.accept, connections.send, engagement.track,
follows.followJob, follows.followUser. They now unwrap, as 39 other methods in
the SDK already do, rather than widening the signature. That is the fix that
makes callers work rather than merely type-check: useUpdateApiKeyMutation
already declares `UseMutationOptions<ApiKey, …>`, so the hook, the screens and
the type were all right and only the runtime value was wrong.

**Two declared an envelope their route does not send,** and this one was live.
personalityAssessments.getStatus and getIPIPStatus declared `{ data: … }`;
probed against the running api, both routes answer bare. So every consumer
reading `status?.data` was reading undefined:

  PersonalityAssessmentWidget.tsx           const assessment = assessmentData?.data
  usePersonalityAssessment.ts               const assessment = assessmentData?.data
  useAssessmentStatus.ts                    cast through `{ data?: … }` to compile

All three corrected here. A fourth, LuscherTestWizard.tsx, already carried the
workaround *and the diagnosis* — "SDK type declares { data: AssessmentStatus }
but API returns AssessmentStatus directly", with a `??` fallback that made that
one screen work while the other three silently did not. Now that the type is
right, the fallback goes too.

Typecheck found that fourth site on its own once the declaration stopped lying,
which is the argument for fixing the type rather than the call sites.

**Two were the guard's false positives.** auth.getUserRoles and
jobs.officeDuplicateJob do unwrap, through spellings the detector did not
recognise:

    return { roles: response.data.roles }              // reshapes while unwrapping
    .then((res) => res.data)
    const response = (await this.get<…>(p)) as {…}     // parenthesised cast

Detection is now precise about the thing that matters: find the name the
response is bound to, then ask whether the body reads `.data` off it. Widening
it that way first hid four real unwraps in background-checks and feedback,
because the binding regex did not allow the parenthesised form — caught by the
baseline's own stale check, which is what that half of the guard is for.

Re-attacked after the change, since a too-permissive detector would mask the
class it exists to catch: reverting engagement.track to its pre-fix form is
still reported as "sdk says bare, route says wrapped", and legitimate unwrapping
is still not flagged.

Also runs deno fmt over three files this branch does not otherwise touch —
__tests__/lib/profile-visibility.test.ts,
__tests__/routes/public-profile-sections.test.ts and routes/profile-widgets.ts,
all from #748. They fail `Lint REST API Code` on main, and formatting them makes
that check pass rather than fail less.

scf-core typecheck and its 1151 tests pass; deno fmt and lint clean; the
contract directory is 9/9.

Closes #744

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit a1813d5 into main Sep 11, 2026
14 checks passed
@thinkclay
thinkclay deleted the claude/744-fix-11 branch September 11, 2026 21:35
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.

The public /v1/profiles surface is inconsistent about the {data} envelope, and the SDK declares all of it bare

1 participant