Skip to content

Store the target's password verdict as one TargetSecurity value - #418

Merged
alexkroman merged 1 commit into
mainfrom
claude/target-security-enum
Nov 25, 2026
Merged

alexkroman merged 1 commit into
mainfrom
claude/target-security-enum

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

What & why

FocusedFieldContext had two separate Bools for the press target's password-field verdict (isSecure, securityUnknown), and so did TranscriptionContext (targetIsSecure, targetSecurityUnknown). The verdict really has three states. Two Bools let a value be "secure and unknown" at once, so PressContext.targetSecurity had to turn them back into .secure/.unknown/.ordinary with a precedence rule of its own.

Both types now hold one TargetSecurity:

  • FocusedFieldContext.security and TranscriptionContext.targetSecurity both default to .ordinary, where the Bools defaulted to false.
  • FocusCapture reports .secure or .ordinary, and FocusedFieldContext.unreachable is .unknown.
  • The iPhone maps the keyboard's KeyboardCommand.isSecure to .secure/.ordinary. That field's wire shape is unchanged.
  • DictationSession+Press passes the verdict through unchanged.
  • PressContext.targetSecurity keeps only its own rule: a read that hasn't settled is .unknown; a settled read gives the stored context's verdict, or .ordinary if the stored context is nil.
  • TranscriptionContext.isEmpty counts any verdict other than .ordinary, so a secure or unknown snapshot still isn't collapsed to nil.
  • The developer-mode log still withholds only a .secure transcript (== .secure).

Neither type is Codable or sent to the App Group, so nothing encoded changes. The doc comments and the cleanup-reviewer agent's guardrail text are updated: it now names targetSecurity and says it is a three-way verdict that must not be deleted as unused. The information the guardrail protects (never remember a password) is unchanged; only its representation is.

Trade-off: the type can no longer state "secure and unknown". The old code let .secure win in that case, and nothing ever produced it. Call sites now write .secure/.ordinary instead of true/false, and the iPhone's wire Bool is mapped at the edge instead of being passed straight through.

Behaviour change: none.

How it was tested

  • Written in a Linux sandbox with no Swift toolchain: scripts/check.sh --portable passes, plus check-swift-size.sh and check-test-clock.sh on the changed files. CI on macOS verifies the build, swift test, the iPhone build and tests, swiftlint, swift-format and periphery.

  • Updated the engine tests that built or read the old fields (DictationSessionContextTests, DictationSessionUnknownSecurityTests, DictationLogEntryTests, CancelledPasteLogTests), and added an assertion that an .ordinary context with no other content is empty.

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)

  • I read AGENTS.md and this doesn't reintroduce anything
    deliberately removed

  • Docs updated if behavior changed


Generated by Claude Code

FocusedFieldContext carried isSecure and securityUnknown, and
TranscriptionContext carried targetIsSecure and targetSecurityUnknown:
two independent Bools for what is really a three-way verdict, so
"secure and unknown" was representable and PressContext.targetSecurity
had to re-derive .secure/.unknown/.ordinary from them with a precedence
rule of its own.

Both types now hold a single TargetSecurity (FocusedFieldContext.security,
TranscriptionContext.targetSecurity), defaulting to .ordinary where the
flags defaulted to false. FocusCapture reports .secure/.ordinary and
.unreachable is .unknown; the iPhone maps the keyboard's isSecure flag
(its wire shape unchanged) to .secure/.ordinary; the press path passes
the verdict through. PressContext keeps only its own rule: a read that
has not settled is .unknown, a settled one is its context's verdict,
and a settled empty snapshot is .ordinary. isEmpty keeps any verdict
other than .ordinary, and the developer-mode log still withholds only
a .secure transcript. Neither type is Codable, so nothing encoded
changes. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC

Copy link
Copy Markdown
Collaborator Author

The ios-audits (b) failure here isn't from this PR. Its only iPhone change is in the dictation command path, not the setup screen. XCTest's accessibility audit of testSetupWithKey threw Code=-56 "Audit failed to complete in time". That is a timeout, not a finding.

Every other job passed. The same error hit testConsent on a merge-queue run on main (45688579022) and testTryItBox on #417. I've re-run the failed job once. A likely fix for the audit itself is described on #417.


Generated by Claude Code

@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit b705522 Nov 25, 2026
36 of 38 checks passed
@alexkroman
alexkroman deleted the claude/target-security-enum branch November 25, 2026 21:32
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
One conflict, in DictationSession+Pipeline.swift: #418 renamed the
password verdict to one targetSecurity value in two comments this PR
had rewritten around the press it now threads through. Kept this PR's
change with #418's names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
No content conflicts: #398 moved AssemblyAIAccount.swift into
BlurtAssemblyAI, and git carried this PR's comment at the early return
along with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
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.

2 participants