Skip to content

DES-374: Token candidates + parallel pipeline + sub-agent fix proposals#5

Merged
OJBoon merged 1 commit into
mainfrom
feat/lotus-audit-ios-candidates-and-subagents
May 7, 2026
Merged

DES-374: Token candidates + parallel pipeline + sub-agent fix proposals#5
OJBoon merged 1 commit into
mainfrom
feat/lotus-audit-ios-candidates-and-subagents

Conversation

@OJBoon
Copy link
Copy Markdown
Collaborator

@OJBoon OJBoon commented May 7, 2026

Jira: DES-374 — Lotus Design System (Epic)
Stacked on: #4 (typography parity)

Summary

Three additions, all building on the same audit run.

1. Token candidates from iOS

New scripts/token-candidates.mjs finds hardcoded values used 3+ times in iOS code that aren't already Lotus tokens. Classifies each as:

  • 🔁 use-existing-token — value matches an existing token, just typed as a literal. Adoption gap.
  • 🎯 near-miss — value within 1pt of an existing token. Likely typo / off-by-one.
  • ➕ new-candidate — value isn't close to anything. Worth proposing as a new Figma token.

Real findings on the live iOS repo include 10pt spacing used 5× — iOS already has LotusSpacing.spacingSemiSmall = 10 but Figma doesn't. The script surfaces this as a "new-candidate" for Figma. Other findings: 20× literal 12pt (should use spacingSmall), 5pt near-miss of spacingXXSmall=4, etc.

Excludes the colour-system definition files (UIColor+JP.swift, UIColor+Design2.0.swift, UIColor+fromHEX.swift) so their internal hex literals don't surface as candidates.

2. Parallel pipeline

Stage 1 (four extract scripts: figma-fetch, parse-colours, parse-typography, scan-ios) and Stage 2 (three analysers: colour-parity, typography-parity, token-candidates) have no inter-script dependencies. Now invoked via simultaneous Bash tool calls in a single message. Roughly halves wall-clock time vs the old sequential run.

SKILL.md now leads with a four-stage mermaid diagram (Stage 1 / 2 / 3 / 4) and explicitly tells the orchestrator: "send these as four parallel Bash tool calls in one message".

3. Per-file fix-proposal sub-agents (new Stage 3)

New stage spawns one general-purpose Task agent per worst-offender file (top 10, gated to ≥5 violations). Each sub-agent reads its file with the full Lotus token namespace as context, then proposes concrete migrations as JSON: line, current snippet, proposed snippet, token used, confidence, optional caveat.

Orchestrator aggregates results to /tmp/fix-proposals.json. build-report.mjs renders a new "Suggested fixes — worst-offender files" section with one table per file.

Smoke-test on 4 real files produced 47 high-confidence migrations including:

  • .jpGreenLotusColours.Brand.justparkGreen
  • Font.heavy.font(forSize: 16)LotusTypography.bodyMediumBold
  • .padding(8).padding(LotusSpacing.spacingXSmall)
  • .cornerRadius(4).cornerRadius(LotusCorners.radiusXSmall)
  • Plus medium-confidence ones with caveats — e.g. legacy jpDarkGray6LotusColours.Text.secondary ("muted body/secondary text colour throughout this cell").

allowed-tools adds Task. Skill degrades gracefully if Task isn't available — Stage 3 just gets skipped.

Architectural notes

The skill now uses three different Claude Code primitives in concert:

  • Bash for the data pipeline (deterministic scripts)
  • Task / sub-agents for narrative reasoning (per-file migration proposals — something a script can't do)
  • Write for aggregation (orchestrator stitches sub-agent JSON together)

This is the right division of labour. Scripts handle volume; sub-agents handle judgement. The report builder consumes both.

Test plan

  • Full pipeline runs end-to-end against ~/code/ios with focused Lotus tab.
  • Stage 1 + 2 confirmed parallel via background Bash calls (4 then 3, all completing within seconds of each other).
  • Stage 3 spawned 4 sub-agents in parallel; each returned valid JSON; aggregated successfully.
  • build-report.mjs renders new sections; degrades gracefully when their inputs are absent.

Followups (not in this PR)

  • Drift comparison between consecutive audits — the only one of the four "advanced features" we discussed not shipped here.
  • Consider auto-excluding Lotus/-prefixed files from worstFiles[*] so a definition file like UIColor+Design2.0.swift never tops the list.

🤖 Generated with Claude Code

Three additions to lotus-audit-ios, all working together off a single
audit run:

1. **Token candidates** (new analyser script): finds hardcoded values used
   3+ times in iOS code that aren't already Lotus tokens. Classifies each
   as `use-existing-token` (adoption gap — value matches a token, just
   typed as a literal), `near-miss` (1pt off — likely typo), or
   `new-candidate` (worth proposing as a new Figma token). Excludes the
   colour-system definition files (UIColor+JP.swift, +Design2.0.swift,
   +fromHEX.swift) so their internal hex literals don't surface as
   candidates. Real findings on the live iOS repo include 5× literal
   `10pt` spacing — iOS has `spacingSemiSmall=10` but Figma doesn't, so
   this surfaces as a "new-candidate" for Figma.

2. **Parallel pipeline**: Stage 1 (4 data scripts) and Stage 2 (3
   analysers) have no inter-stage dependencies and now run in parallel
   via simultaneous `Bash` tool calls in a single message. Roughly halves
   wall-clock time from the old sequential run. Documented in SKILL.md
   with a 4-stage mermaid diagram replacing the old 5-phase flow.

3. **Per-file fix-proposal sub-agents**: new Stage 3 in the pipeline
   spawns one general-purpose `Task` agent per top worst-offender file
   (top 10, ≥5 violations). Each sub-agent reads the file with full Lotus
   token namespace context and proposes concrete migrations as JSON:
   line, current snippet, proposed snippet, token used, confidence,
   optional caveat. Orchestrator aggregates to /tmp/fix-proposals.json;
   build-report.mjs renders a "Suggested fixes — worst-offender files"
   section. Smoke-test on 4 real files produced 47 high-confidence
   migrations including .jpGreen → LotusColours.Brand.justparkGreen,
   Font.heavy.font(forSize: 16) → LotusTypography.bodyMediumBold, and
   `.padding(8)` → `.padding(LotusSpacing.spacingXSmall)`.

Files:
- scripts/token-candidates.mjs (new)
- scripts/build-report.mjs (consume both new inputs; degrade gracefully)
- SKILL.md
  - allowed-tools += Task
  - Pipeline mermaid diagram now shows Stage 1/2/3/4
  - Phases reorganised as parallel Stage 1 + parallel Stage 2 +
    sub-agent Stage 3 + Stage 4 (build-report)
  - Stage 3 includes the full sub-agent prompt template + aggregation
    contract, plus the "skip if Task tool unavailable" graceful-degrade
  - Report-structure list bumped to include the two new sections
  - Important rules note the parallel-execution expectation

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@gitstream-cm
Copy link
Copy Markdown

gitstream-cm Bot commented May 7, 2026

🚨 gitStream Monthly Automation Limit Reached 🚨

Your organization has exceeded the number of pull requests allowed for automation with gitStream.
Monthly PRs automated: 250/250

To continue automating your PR workflows and unlock additional features, please contact LinearB.

Base automatically changed from feat/lotus-audit-ios-typography to main May 7, 2026 16:35
@OJBoon OJBoon merged commit 06b9b2a into main May 7, 2026
8 checks passed
@OJBoon OJBoon deleted the feat/lotus-audit-ios-candidates-and-subagents branch May 7, 2026 16:36
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.

1 participant