Skip to content

refactor: concept folders — one ASCKit module, Internal/ implementations - #45

Merged
hanrw merged 18 commits into
mainfrom
refactor/concept-folders
Nov 19, 2026
Merged

hanrw merged 18 commits into
mainfrom
refactor/concept-folders

Conversation

@hanrw

@hanrw hanrw commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Lays asc-cli out by concept instead of by layer, following docs/features/concept-folders/design.md. Each step from that design lands on this branch; draft until all steps are in.

Done

  • Step 1: one module, concept folders. Sources/Domain + Sources/Infrastructure → Sources/ASCKit/<Concept>/ with each implementation in the concept's Internal/. DomainTests + InfrastructureTests → ASCKitTests, same layout. Pure move (git mv, history kept): 2,913 @Tests before and after, all green.

  • Step 2: docs and skills follow. CLAUDE.md, CONTRIBUTING.md, docs/design.md, the implement-feature / fix-bug / improvement skills and the feature designs' file maps describe the new tree.

  • Step 3: one composition root. Commands and RESTRoutes ask ClientProvider for a concept's public protocol instead of building implementations (22 uses of 12 types in 14 files). CompositionRootTests fails, naming file and type, if any other ASCCommand file names an Internal/ type.

  • The app-implement-feature skill describes the pattern (concept folders, role names, canonical model, domain-shape.md).

  • Step 4: the bare call in Internal/System/. The SDK adapters were already split (they depend on the narrow APIClient role; 472 tests drive them through StubAPIClient). The seven untested adapters that weren't now keep their decisions in tested Internal/ types or behind @Mockable roles, with only the call in Internal/System/ (16–82 lines each):

    • ShellCommand / SystemShellRunner
    • IrisRequest + IrisResponse / IrisClient, which plays the new @Mockable IrisAPI role
    • BrowserIrisCookieProvider via @Mockable BrowserCookieStores / SweetCookieKitStores
    • IrisAuthSDKRepository via @Mockable AppleIDSignIn + AppStoreConnectAccounts (both login paths now tested)
    • LocalImages / WebKitHTMLRenderer
    • PluginMarketRepository via @Mockable PluginsFolder + PluginDownloads / LocalPluginsFolder
    • IrisSDKAppBundleRepository tested on MockIrisAPI

    codecov.yml skips Sources/**/Internal/System/** by one rule instead of six per-file entries; the blanket Iris/Internal/Auth/** skip is gone (77% covered).

  • Step 5: names for roles. XxxRepository stays for the 68 CRUD protocols (a state change like submit is an update). The 7 that run something outside asc-cli take role nouns: IrisSignIn, Reports, AppWall, Simulators, Skills, Plugins, Themes. The one workflow hiding in a repository moved to the model: AppStoreVersion.submitForReview(to:) replaces SubmissionRepository.submitVersion.

Behaviour change

asc versions submit and POST /api/v1/versions/:id/submit now refuse a version that can't be edited (e.g. Ready for Sale) before calling Apple — REST answers 422 — saying which states can go to review. Previously the request went to Apple and failed there.

Breaking (library only)

ASCKit is now one module: replace import Domain / import Infrastructure with import ASCKit. Seven protocols take role names (IrisAuthRepository → IrisSignIn, …), and SubmissionRepository.submitVersion becomes AppStoreVersion.submitForReview(to:). CHANGELOG has the lines.

Test plan

  • swift test: 2,170 + 791 tests pass
  • make check-docs: 0 problems
  • examples/hello-plugin builds against ASCKit

🤖 Generated with Claude Code

hanrw and others added 4 commits November 19, 2026 20:14
…nal/

Concept folders instead of Domain/Infrastructure layers: public face at
the top, implementations in Internal/, the bare outside call in
Internal/System/. Roles named for what they are (no Service/Manager/
Repository suffixes), a canonical-model step and the five domain
questions (references/domain-shape.md), no approval gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Domain/ and Infrastructure/ (two modules mirroring each other) become
Sources/ASCKit/<Concept>/ with each implementation in the concept's
Internal/. DomainTests + InfrastructureTests become ASCKitTests, same
layout. Pure move: 2,913 tests unchanged and green.

Library users replace import Domain / import Infrastructure with
import ASCKit. Design: docs/features/concept-folders/design.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLAUDE.md, CONTRIBUTING.md, docs/design.md, the implement-feature,
fix-bug and improvement skills, and the feature designs' file maps now
point at Sources/ASCKit/<Concept>/ and its Internal/, and at
Tests/ASCKitTests/. Step 2 of docs/features/concept-folders/design.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commands and RESTRoutes ask ClientProvider for a concept's public
protocol instead of building FileAuthStorage, EnvironmentAuthProvider,
ProcessXcodeBuildRunner, FileProjectConfigStorage, the screenshot
repositories or their own ClientFactory. CompositionRootTests holds the
fence: it fails, naming file and type, when any other ASCCommand file
names an ASCKit Internal/ type. Step 3 of the concept-folders design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Walkthrough

Warning

Review details and warnings were omitted to fit the comment limit.

hanrw and others added 13 commits November 19, 2026 20:24
ShellCommand owns what SystemShellRunner used to decide inline: argv via
/usr/bin/env, the environment merge, exit status -> executionFailed and
output trimming, all now unit-tested. SystemShellRunner moves to
Skills/Internal/System/ and keeps only the Process and pipe calls.
codecov skips Sources/**/Internal/System/** by one rule instead of the
file. Step 4 of the concept-folders design, rescoped to the seven
untested adapters (the SDK adapters are already split via APIClient).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ession call

IrisRequest builds every iris request (the iris/v1 URL, JSON:API, cookie,
CSRF and user-agent headers; downloads with cookies only) and
IrisResponse decides what a reply means (2xx body, httpError with status
and body, invalidResponse), both unit-tested. IrisClient moves to
Iris/Internal/System/ and keeps only session.data(for:). IrisAPIError,
which REST controllers catch, moves to the Iris/ public face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t reads

BrowserIrisCookieProvider keeps its decisions — ASC_IRIS_COOKIES first
when not blank, only the nine iris cookies, the first browser holding
myacinfo, the cookie count — now tested through MockBrowserCookieStores.
SweetCookieKitStores in Iris/Internal/System/ only reads each browser's
stores. The cookie header is sorted by name instead of dictionary order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ystem/

With IrisClient's URLSession call in Iris/Internal/System/, nothing in
IrisSDKAppBundleRepository is untestable: its query, decoding, mapping
(fallback name, en-US default) and refusals are now pinned through a
stubbed URLProtocol, and codecov no longer skips AppBundles/Internal/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LocalImages owns which src values are local images, where to find them
(absolute, working directory, .asc/app-shots/, the web server's
/api/files/read URLs) and their MIME types, unit-tested with an
in-memory file reader; each file is now read once. WebKitHTMLRenderer
moves to Screenshots/Internal/System/ and keeps only the WKWebView load
and snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TTP clients

IrisAuthSDKRepository depends on AppleIDSignIn (idmsa) and
AppStoreConnectAccounts (olympus), played by IdmsaAPIClient and
OlympusClient, plus an injected clock. Its decisions — the pending
two-factor state, the session it builds (team, Apple ID as fallback
email, 30-day expiry) and both login paths — are now tested with
MockAppleIDSignIn / MockAppStoreConnectAccounts instead of a URLProtocol
stub. codecov no longer skips Iris/Internal/Auth/ (77% covered;
IdmsaAPIClient's own wire at 46% is the gap).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IrisAPI (get, post, download, delete) is what the iris repositories need
from iris; IrisClient in Internal/System/ plays it. The four iris
repositories take any IrisAPI (defaulting to IrisClient), and the
app-bundle tests stub MockIrisAPI by path, query and cookies instead of
a URLProtocol stub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… download roles

PluginMarketRepository keeps its decisions — installed matching by slug
or name-as-id, search, outdated versions, uninstall's match order,
update as reinstall — now tested with MockPluginsFolder and
MockPluginDownloads. LocalPluginsFolder and URLSessionPluginDownloads in
Plugins/Internal/System/ hold only the PluginLoader, file system, unzip
and URLSession calls. Completes step 4 of the concept-folders design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 repository protocols become collection nouns — the plural of the
aggregate they hold (Apps, Builds, AppStoreVersions, AppScreenshots) —
or role nouns where they aren't collections (IrisSignIn, TestFlight,
GameCenter, Reports, AppPrices, ReviewSubmissions, *ReviewAssets).
Implementations say how (SDKBuilds, SimctlSimulators,
MarketplacePlugins); generated mocks, make* factories and file names
follow. CLAUDE.md and the implement-feature skill state the rule.
No behaviour change: 2,958 tests before and after. Step 5 of the
concept-folders design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reverts the blanket rename of step 5 (258cf42, 83d7b0e): the 64
protocols that are CRUD over an aggregate keep XxxRepository. The 11
that run a workflow take role nouns — IrisSignIn, Reports,
ReviewSubmissions, InAppPurchaseSubmissions, SubscriptionSubmissions,
IrisInAppPurchaseSubmissions, AppWall, Simulators, Skills, Plugins,
Themes — with their implementations, mocks and make* factories.
CLAUDE.md and both implement-feature skills state the rule. No
behaviour change: 2,958 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SubmissionRepository, InAppPurchaseSubmissionRepository,
SubscriptionSubmissionRepository and IrisInAppPurchaseSubmissionRepository
are CRUD over a submission resource (submit is create or an isSubmitted
update), so they keep the Repository name they had on main; their
implementations, mocks and make* factories follow. The one workflow in
them, SubmissionRepository.submitVersion, moves to the domain next.
CLAUDE.md and the implement-feature skill say where a workflow over
aggregates lives: a method on the model, built from repository
primitives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ditable

AppStoreVersion.submitForReview(to:) runs the submit workflow from the
SubmissionRepository's primitives: its app's open draft for its
platform, the version added unless the draft holds it, the draft
submitted. It refuses a version that can't be edited (the same
isEditable that offers the submitForReview affordance) before anything
reaches Apple: versionNotEditable names the state and which states can
go. asc versions submit and POST /api/v1/versions/:id/submit both load
the version and call it; REST answers that refusal with 422.

SubmissionRepository.submitVersion, which re-fetched the version and
duplicated createSubmission's find-or-create inside the adapter, is
gone. createSubmission now explains Apple's refusal to open a draft,
as submitVersion did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hanrw
hanrw marked this pull request as ready for review November 19, 2026 13:12
DataProvider.fetch answers null when the command fails and only logs
the reason, so the Submissions page showed 'Submitted for App Store
Review!' even when versions submit was refused (a version that can't be
edited, or Apple's refusal). It now shows an error toast pointing to the
command log. Mock mode is unaffected: it never answers null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hanrw
hanrw merged commit c7f697e into main Nov 19, 2026
2 of 3 checks passed
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