@mmerterden/multi-agent-pipeline 20.37.0 → 20.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +123 -49
- package/README.md +12 -10
- package/README.tr.md +12 -10
- package/docs/adr/0006-skills-core-external-split.md +5 -5
- package/docs/adr/0010-own-code-graph.md +6 -7
- package/docs/adr/0013-lsp-code-intelligence.md +6 -8
- package/docs/adr/0017-change-impact-from-the-graph.md +4 -5
- package/docs/adr/0018-cross-repo-links-not-a-global-graph.md +1 -1
- package/docs/adr/README.md +1 -1
- package/docs/ecosystem.md +53 -41
- package/docs/facts.json +15 -13
- package/docs/features.md +2 -2
- package/docs/recovery-guide.md +1 -1
- package/install/_dev-only-files.mjs +3 -0
- package/install/_platform-filter.mjs +1 -23
- package/install/catalog-history.json +1 -1
- package/install/claude.mjs +8 -1
- package/install/codex.mjs +0 -2
- package/install/copilot.mjs +0 -2
- package/install/templates/claude-hooks.json +47 -1
- package/manifest.json +455 -332
- package/package.json +5 -2
- package/pipeline/agents/security-auditor.md +58 -6
- package/pipeline/commands/multi-agent/build-optimize/SKILL.md +1 -2
- package/pipeline/commands/multi-agent/complaint-analysis/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/graph/SKILL.md +12 -3
- package/pipeline/commands/multi-agent/manual-test/SKILL.md +12 -7
- package/pipeline/commands/multi-agent/research/SKILL.md +2 -2
- package/pipeline/commands/multi-agent/search/SKILL.md +10 -1
- package/pipeline/commands/multi-agent/security-review/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/setup/SKILL.md +1 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +8 -0
- package/pipeline/commands/multi-agent/store-ready/SKILL.md +1 -1
- package/pipeline/commands/sim-test.md +34 -1
- package/pipeline/lib/context-budget.mjs +103 -0
- package/pipeline/lib/credential-inventory.sh +2 -3
- package/pipeline/lib/identifier-scan.mjs +145 -0
- package/pipeline/lib/outbound-gate.mjs +28 -1
- package/pipeline/lib/unattended-profile-check.mjs +13 -4
- package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
- package/pipeline/multi-agent-refs/analysis/redesign.md +17 -3
- package/pipeline/multi-agent-refs/analysis-template-corporate.md +8 -4
- package/pipeline/multi-agent-refs/analysis-template.md +7 -5
- package/pipeline/multi-agent-refs/audit-guide.md +20 -0
- package/pipeline/multi-agent-refs/complaint-analysis/phases.md +1 -0
- package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +1 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +25 -0
- package/pipeline/multi-agent-refs/features/commit-multi-repo.md +63 -0
- package/pipeline/multi-agent-refs/features/design-conformance.md +20 -4
- package/pipeline/multi-agent-refs/features/dev-multi-repo.md +51 -0
- package/pipeline/multi-agent-refs/features/free-models.md +10 -3
- package/pipeline/multi-agent-refs/features/research.md +4 -3
- package/pipeline/multi-agent-refs/features/security-audit.md +25 -3
- package/pipeline/multi-agent-refs/features/test-gap.md +40 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +20 -0
- package/pipeline/multi-agent-refs/features/worktree-finalize.md +1 -1
- package/pipeline/multi-agent-refs/help/en.md +15 -9
- package/pipeline/multi-agent-refs/help/tr.md +15 -9
- package/pipeline/multi-agent-refs/knowledge.md +17 -0
- package/pipeline/multi-agent-refs/orchestrator/phase-3-user-test.md +12 -9
- package/pipeline/multi-agent-refs/outside-the-pipeline.md +9 -0
- package/pipeline/multi-agent-refs/phases/log-format.md +5 -0
- package/pipeline/multi-agent-refs/phases/operations.md +3 -5
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +8 -47
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +21 -65
- package/pipeline/multi-agent-refs/phases/phase-4-commit.md +9 -59
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +0 -31
- package/pipeline/multi-agent-refs/picker-contract.md +1 -1
- package/pipeline/multi-agent-refs/research/engine.md +2 -1
- package/pipeline/multi-agent-refs/rules.md +1 -1
- package/pipeline/multi-agent-refs/setup/free-models.md +10 -0
- package/pipeline/multi-agent-refs/store-ready/gate-3-policy.md +15 -0
- package/pipeline/multi-agent-refs/web-guide.md +2 -1
- package/pipeline/office/index.html +8 -9
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/figma-pipeline.md +6 -3
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/learnings-ledger.schema.json +7 -2
- package/pipeline/schemas/prefs.schema.json +17 -4
- package/pipeline/schemas/reviewer-output.schema.json +113 -5
- package/pipeline/schemas/secret-patterns.json +49 -0
- package/pipeline/schemas/security-finding.schema.json +49 -5
- package/pipeline/scripts/_code-graph.mjs +3 -3
- package/pipeline/scripts/_graph-analysis.mjs +51 -0
- package/pipeline/scripts/_memory-policy.mjs +37 -7
- package/pipeline/scripts/_secret-scan.mjs +1 -1
- package/pipeline/scripts/_skill-practices.mjs +178 -0
- package/pipeline/scripts/_stack-routing.mjs +1 -0
- package/pipeline/scripts/autopilot-runner.mjs +8 -3
- package/pipeline/scripts/build-stack-plugins.mjs +8 -44
- package/pipeline/scripts/capture-resume.sh +19 -0
- package/pipeline/scripts/checkpoint-fold.sh +59 -0
- package/pipeline/scripts/file-context.mjs +306 -70
- package/pipeline/scripts/gate-ledger.mjs +1 -1
- package/pipeline/scripts/gen-skills-index.mjs +1 -1
- package/pipeline/scripts/graph-hint.mjs +197 -0
- package/pipeline/scripts/graph-hint.sh +20 -0
- package/pipeline/scripts/graph-query.mjs +306 -11
- package/pipeline/scripts/graph-report.mjs +29 -1
- package/pipeline/scripts/learnings-ledger.mjs +71 -15
- package/pipeline/scripts/note-agent-event.mjs +160 -0
- package/pipeline/scripts/note-agent-event.sh +19 -0
- package/pipeline/scripts/office-control.mjs +41 -15
- package/pipeline/scripts/offload-ref.sh +1 -1
- package/pipeline/scripts/parity-score.mjs +139 -0
- package/pipeline/scripts/pre-commit-check.sh +25 -4
- package/pipeline/scripts/pre-push-check.sh +3 -0
- package/pipeline/scripts/repo-recommend.mjs +321 -0
- package/pipeline/scripts/rework-rulings.mjs +5 -3
- package/pipeline/scripts/scan-agent-config.sh +1 -2
- package/pipeline/scripts/scope-check-gate.mjs +15 -2
- package/pipeline/scripts/security-evidence-gate.mjs +282 -0
- package/pipeline/scripts/unattended_policy.py +3 -2
- package/pipeline/scripts/user-test-handoff.sh +203 -0
- package/pipeline/scripts/validate-analysis-doc.mjs +17 -1
- package/pipeline/scripts/validate-planning.mjs +5 -3
- package/pipeline/scripts/validate-triage.mjs +2 -1
- package/pipeline/scripts/write-state.mjs +13 -4
- package/pipeline/skills/.skill-manifest.json +73 -69
- package/pipeline/skills/shared/README.md +41 -40
- package/pipeline/skills/shared/core/apple-archive-compliance/SKILL.md +6 -6
- package/pipeline/skills/shared/core/apple-archive-compliance/references/examples.md +1 -1
- package/pipeline/skills/shared/core/apple-archive-compliance/references/version-history.md +1 -1
- package/pipeline/skills/shared/core/google-play-compliance/SKILL.md +1 -1
- package/pipeline/skills/shared/core/google-play-compliance/references/notes.md +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-build-optimize/SKILL.md +0 -1
- package/pipeline/skills/shared/core/multi-agent-complaint-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +5 -5
- package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +10 -0
- package/pipeline/skills/shared/core/multi-agent-manual-test/SKILL.md +12 -7
- package/pipeline/skills/shared/core/multi-agent-research/SKILL.md +2 -2
- package/pipeline/skills/shared/core/multi-agent-search/SKILL.md +9 -0
- package/pipeline/skills/shared/core/multi-agent-security-review/SKILL.md +3 -2
- package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +1 -0
- package/pipeline/skills/shared/core/multi-agent-stack/SKILL.md +8 -0
- package/pipeline/skills/shared/core/multi-agent-store-ready/SKILL.md +4 -3
- package/pipeline/skills/shared/core/multi-agent-test/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-accessibility/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-dark-mode/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-dynamic-type/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-gen/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-screenshots/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-testflight-validation/SKILL.md +2 -2
- package/pipeline/skills/shared/external/accessibility-compliance-accessibility-audit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/agent-introspection-debugging/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/android-architecture/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-architecture/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-build-quality-gates/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-datastore/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-design-tokens-codegen/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/android-jetpack-compose-expert/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/android-mvi-viewmodel/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-performance/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/android-security/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-security/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/api-patterns/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/api-security-best-practices/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/app-store-changelog/SKILL.md +65 -49
- package/pipeline/skills/shared/external/app-store-changelog/evals/evals.json +40 -0
- package/pipeline/skills/shared/external/app-store-changelog/references/release-notes-guidelines.md +64 -34
- package/pipeline/skills/shared/external/app-store-changelog/scripts/collect_release_changes.sh +21 -23
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +4 -1
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +6 -0
- package/pipeline/skills/shared/external/architecture/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/backlog/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/ci-cd-pipelines/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/clean-code/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/compose-components/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-components/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/compose-navigation/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-navigation/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/compose-testing/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-testing/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/context-compression/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/core-data/SKILL.md +1 -1
- package/pipeline/skills/shared/external/council/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/css-modern/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/css-modern/references/code-examples.md +5 -0
- package/pipeline/skills/shared/external/database-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/database-patterns/references/orm-examples.md +5 -0
- package/pipeline/skills/shared/external/debugging-strategies/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/docker-expert/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/e2e-testing/SKILL.md +21 -21
- package/pipeline/skills/shared/external/e2e-testing/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/e2e-testing/references/document-fixtures.md +5 -5
- package/pipeline/skills/shared/external/evidence-github/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/evidence-registry/SKILL.md +1 -1
- package/pipeline/skills/shared/external/evidence-registry/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/fastapi-pro/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/firebase/SKILL.md +132 -54
- package/pipeline/skills/shared/external/firebase/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/firebase/references/functions-and-products.md +51 -0
- package/pipeline/skills/shared/external/firebase/references/security-rules.md +59 -0
- package/pipeline/skills/shared/external/fix-review-verdicts/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/free-llm-apis/SKILL.md +70 -0
- package/pipeline/skills/shared/external/free-llm-apis/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +33 -0
- package/pipeline/skills/shared/external/github-actions-templates/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/gradle-kotlin-dsl/SKILL.md +1 -1
- package/pipeline/skills/shared/external/gradle-kotlin-dsl/evals/evals.json +58 -0
- package/pipeline/skills/shared/external/handle-request/SKILL.md +2 -2
- package/pipeline/skills/shared/external/handle-request/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/hig-app-icons/SKILL.md +2 -2
- package/pipeline/skills/shared/external/hig-app-icons/references/icon-workflow.md +1 -1
- package/pipeline/skills/shared/external/hig-components-content/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-components-status/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-components-system/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-inputs/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/hig-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/hig-platforms/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/hig-technologies/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/html-semantic/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/humanizer/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/ios-coding-standard/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/ios-debugger-agent/SKILL.md +91 -52
- package/pipeline/skills/shared/external/ios-debugger-agent/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/ios-design-review/SKILL.md +12 -12
- package/pipeline/skills/shared/external/ios-design-review/references/appearance-matrix.md +16 -16
- package/pipeline/skills/shared/external/ios-design-review/references/checklist.md +1 -1
- package/pipeline/skills/shared/external/ios-iphone-duo/SKILL.md +0 -1
- package/pipeline/skills/shared/external/ios-module-structure/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/ios-security/SKILL.md +1 -1
- package/pipeline/skills/shared/external/ios-security/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/kotlin-coroutines-expert/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/localization-reuse-map/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/macos-menubar-tuist-app/SKILL.md +170 -74
- package/pipeline/skills/shared/external/macos-menubar-tuist-app/evals/evals.json +52 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/SKILL.md +119 -77
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Package.swift +5 -5
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/MyApp.swift +24 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/version.env +2 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/build_icon.sh +46 -39
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/compile_and_run.sh +70 -49
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/launch.sh +24 -17
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/make_appcast.sh +74 -59
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/package_app.sh +201 -170
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/setup_dev_signing.sh +50 -42
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/sign-and-notarize.sh +65 -35
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/version.env +2 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/packaging.md +49 -17
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/release.md +48 -23
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/scaffold.md +74 -44
- package/pipeline/skills/shared/external/monorepo-architect/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/nextjs-app-router/SKILL.md +14 -3
- package/pipeline/skills/shared/external/nextjs-app-router/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/nextjs-app-router/references/app-router-examples.md +3 -0
- package/pipeline/skills/shared/external/nodejs-backend-patterns/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/observability-engineer/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +10 -0
- package/pipeline/skills/shared/external/photos-camera-media/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/play-store-review/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/python-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/react-best-practices/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/rest-api-design/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/retrofit-networking/SKILL.md +1 -1
- package/pipeline/skills/shared/external/retrofit-networking/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/room-database/SKILL.md +1 -1
- package/pipeline/skills/shared/external/room-database/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/scenario-gap-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/external/scenario-gap-analysis/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/search-first/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/security-review/SKILL.md +14 -3
- package/pipeline/skills/shared/external/security-review/evals/evals.json +48 -0
- package/pipeline/skills/shared/external/security-review/references/agentic-systems.md +93 -0
- package/pipeline/skills/shared/external/security-review/references/firebase-rules.md +100 -0
- package/pipeline/skills/shared/external/security-review/references/graphql.md +82 -0
- package/pipeline/skills/shared/external/security-review/references/llm-prompt-injection.md +93 -0
- package/pipeline/skills/shared/external/security-review/references/oauth-oidc.md +100 -0
- package/pipeline/skills/shared/external/security-review/references/owasp-mobile-top10-2024.md +1 -1
- package/pipeline/skills/shared/external/security-review/references/owasp-web-api-top10-2021.md +1 -1
- package/pipeline/skills/shared/external/security-review/references/supabase.md +73 -0
- package/pipeline/skills/shared/external/signal-community/SKILL.md +29 -10
- package/pipeline/skills/shared/external/signal-community/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/skill-creator/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/skill-creator/template.md +1 -3
- package/pipeline/skills/shared/external/spm-build-analysis/SKILL.md +80 -61
- package/pipeline/skills/shared/external/spm-build-analysis/evals/evals.json +56 -0
- package/pipeline/skills/shared/external/spm-build-analysis/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/spm-build-analysis/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/spm-build-analysis/references/spm-analysis-checks.md +89 -87
- package/pipeline/skills/shared/external/spm-build-analysis/scripts/check_spm_pins.py +90 -85
- package/pipeline/skills/shared/external/swift-concurrency-expert/SKILL.md +78 -69
- package/pipeline/skills/shared/external/swift-concurrency-expert/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/approachable-concurrency.md +52 -48
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/swift-6-2-concurrency.md +118 -184
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +68 -22
- package/pipeline/skills/shared/external/swift-concurrency-pro/SKILL.md +117 -94
- package/pipeline/skills/shared/external/swift-concurrency-pro/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/actors.md +102 -97
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/async-streams.md +36 -37
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/bridging.md +82 -34
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/bug-patterns.md +90 -52
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/cancellation.md +55 -55
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/diagnostics.md +66 -43
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/hotspots.md +39 -23
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/interop.md +66 -68
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/new-features.md +152 -131
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/structured.md +60 -57
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/testing.md +131 -118
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/unstructured.md +37 -29
- package/pipeline/skills/shared/external/swift-formatstyle/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swift-testing-pro/SKILL.md +77 -58
- package/pipeline/skills/shared/external/swift-testing-pro/evals/evals.json +59 -0
- package/pipeline/skills/shared/external/swift-testing-pro/references/async-tests.md +139 -144
- package/pipeline/skills/shared/external/swift-testing-pro/references/core-rules.md +90 -28
- package/pipeline/skills/shared/external/swift-testing-pro/references/migrating-from-xctest.md +38 -21
- package/pipeline/skills/shared/external/swift-testing-pro/references/new-features.md +139 -156
- package/pipeline/skills/shared/external/swift-testing-pro/references/writing-better-tests.md +173 -147
- package/pipeline/skills/shared/external/swiftdata-pro/SKILL.md +75 -59
- package/pipeline/skills/shared/external/swiftdata-pro/evals/evals.json +50 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/cloudkit.md +34 -7
- package/pipeline/skills/shared/external/swiftdata-pro/references/indexing.md +20 -14
- package/pipeline/skills/shared/external/swiftdata-pro/references/inheritance.md +127 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/model-rules.md +141 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/predicates.md +37 -44
- package/pipeline/skills/shared/external/swiftlint/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-expert-skill/SKILL.md +89 -88
- package/pipeline/skills/shared/external/swiftui-expert-skill/evals/evals.json +55 -0
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/accessibility-patterns.md +104 -122
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-advanced.md +73 -93
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-basics.md +144 -169
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-transitions.md +122 -133
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts-accessibility.md +141 -99
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts.md +273 -333
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/image-optimization.md +105 -128
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/latest-apis.md +199 -312
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/layout-best-practices.md +129 -169
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/liquid-glass.md +17 -30
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/list-patterns.md +198 -258
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-scenes.md +145 -218
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-views.md +150 -249
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-window-styling.md +109 -208
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/performance-patterns.md +225 -271
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/scroll-patterns.md +117 -210
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/sheet-navigation-patterns.md +171 -237
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/state-management.md +196 -260
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/view-structure.md +167 -230
- package/pipeline/skills/shared/external/swiftui-gestures/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-layout-components/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-navigation/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +1 -2
- package/pipeline/skills/shared/external/swiftui-patterns/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/SKILL.md +71 -79
- package/pipeline/skills/shared/external/swiftui-performance-audit/evals/evals.json +55 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/audit-layout.md +50 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/capture-checklist.md +51 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/hangs.md +34 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/instruments-guide.md +68 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/smell-catalog.md +191 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/update-model.md +69 -0
- package/pipeline/skills/shared/external/swiftui-pro/SKILL.md +65 -63
- package/pipeline/skills/shared/external/swiftui-pro/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/swiftui-pro/references/accessibility.md +40 -13
- package/pipeline/skills/shared/external/swiftui-pro/references/api.md +74 -29
- package/pipeline/skills/shared/external/swiftui-pro/references/data.md +44 -24
- package/pipeline/skills/shared/external/swiftui-pro/references/design.md +45 -31
- package/pipeline/skills/shared/external/swiftui-pro/references/hygiene.md +17 -8
- package/pipeline/skills/shared/external/swiftui-pro/references/navigation.md +19 -9
- package/pipeline/skills/shared/external/swiftui-pro/references/performance.md +50 -34
- package/pipeline/skills/shared/external/swiftui-pro/references/swift.md +73 -45
- package/pipeline/skills/shared/external/swiftui-pro/references/views.md +48 -23
- package/pipeline/skills/shared/external/swiftui-ui-patterns/SKILL.md +89 -83
- package/pipeline/skills/shared/external/swiftui-ui-patterns/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/app-wiring.md +119 -114
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/async-state.md +76 -61
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/components-index.md +63 -46
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/controls.md +32 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/deeplinks.md +49 -38
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/focus.md +77 -49
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/form.md +61 -44
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/grids.md +40 -42
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/input-toolbar.md +44 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/lightweight-clients.md +90 -64
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/list.md +48 -49
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/loading-placeholders.md +36 -25
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/macos-settings.md +30 -30
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/matched-transitions.md +49 -32
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/media.md +49 -41
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/menu-bar.md +52 -48
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/navigationstack.md +119 -104
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/overlay.md +30 -27
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/performance.md +33 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/previews.md +27 -27
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scroll-reveal.md +79 -86
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scrollview.md +47 -40
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/searchable.md +55 -40
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/sheets.md +113 -84
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/split-views.md +37 -34
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/tabview.md +75 -75
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/theming.md +37 -32
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/title-menus.md +41 -51
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/top-bar.md +46 -30
- package/pipeline/skills/shared/external/swiftui-uikit-interop/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-view-refactor/SKILL.md +152 -121
- package/pipeline/skills/shared/external/swiftui-view-refactor/evals/evals.json +56 -0
- package/pipeline/skills/shared/external/swiftui-view-refactor/references/mv-patterns.md +107 -98
- package/pipeline/skills/shared/external/swiftui-webkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/tailwind-css/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/test-result-triage/SKILL.md +2 -2
- package/pipeline/skills/shared/external/test-result-triage/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/testing-backend/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/tipkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/typescript-patterns/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/valven-rules/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/vision-framework/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/vue-composition/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/weatherkit/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/web-accessibility/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/web-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/web-testing/SKILL.md +2 -2
- package/pipeline/skills/shared/external/web-testing/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/web-testing/references/testing-examples.md +2 -2
- package/pipeline/skills/shared/external/widgetkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/xcode-build-benchmark/SKILL.md +61 -55
- package/pipeline/skills/shared/external/xcode-build-benchmark/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmark-artifacts.md +69 -67
- package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmarking-workflow.md +39 -47
- package/pipeline/skills/shared/external/xcode-build-benchmark/schemas/build-benchmark.schema.json +72 -154
- package/pipeline/skills/shared/external/xcode-build-benchmark/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-fixer/SKILL.md +145 -139
- package/pipeline/skills/shared/external/xcode-build-fixer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-build-fixer/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-build-fixer/references/fix-patterns.md +188 -143
- package/pipeline/skills/shared/external/xcode-build-fixer/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-build-fixer/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-orchestrator/SKILL.md +107 -98
- package/pipeline/skills/shared/external/xcode-build-orchestrator/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/benchmark-artifacts.md +69 -67
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/orchestration-report-template.md +81 -69
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/diagnose_compilation.py +155 -210
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/generate_optimization_report.py +355 -480
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/SKILL.md +70 -69
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/code-compilation-checks.md +85 -73
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/scripts/diagnose_compilation.py +155 -210
- package/pipeline/skills/shared/external/xcode-project-analyzer/SKILL.md +54 -52
- package/pipeline/skills/shared/external/xcode-project-analyzer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/project-audit-checks.md +115 -83
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/recommendation-format.md +41 -40
- package/pipeline/scripts/_notices.mjs +0 -171
- package/pipeline/skills/shared/external/NOTICE-avdlee-swiftui-agent-skill.md +0 -48
- package/pipeline/skills/shared/external/NOTICE-dimillian-skills.md +0 -63
- package/pipeline/skills/shared/external/NOTICE-paul-hudson-skills.md +0 -54
- package/pipeline/skills/shared/external/NOTICE-vibeship-spawner-skills.md +0 -203
- package/pipeline/skills/shared/external/NOTICE-xcode-build-skills.md +0 -60
- package/pipeline/skills/shared/external/ios-iphone-duo/NOTICE.md +0 -53
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/main.swift +0 -11
- package/pipeline/skills/shared/external/swiftdata-pro/references/class-inheritance.md +0 -104
- package/pipeline/skills/shared/external/swiftdata-pro/references/core-rules.md +0 -20
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/code-smells.md +0 -158
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +0 -46
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +0 -29
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/profiling-intake.md +0 -44
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/report-template.md +0 -47
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +0 -33
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +0 -52
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
# Async streams
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Create streams with `makeStream(of:)`
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The static factory hands back the stream and its continuation together as a
|
|
6
|
+
tuple, so there is no need to smuggle the continuation out of a closure.
|
|
6
7
|
|
|
7
8
|
```swift
|
|
8
|
-
//
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
continuation = cont
|
|
12
|
-
}
|
|
9
|
+
// Older shape: the continuation has to escape the build closure.
|
|
10
|
+
var sink: AsyncStream<Reading>.Continuation?
|
|
11
|
+
let readings = AsyncStream<Reading> { sink = $0 }
|
|
13
12
|
|
|
14
|
-
//
|
|
15
|
-
let (
|
|
13
|
+
// Current shape: both halves arrive at once.
|
|
14
|
+
let (readings, sink) = AsyncStream.makeStream(of: Reading.self)
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
The throwing variant is `AsyncThrowingStream.makeStream(of:throwing:)`.
|
|
20
18
|
|
|
21
|
-
##
|
|
19
|
+
## Finishing the continuation
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Finish a stream's continuation exactly once. Without a `finish()`, the
|
|
22
|
+
consumer's `for await` loop waits forever. Finishing twice is a programming
|
|
23
|
+
mistake, even though `AsyncStream.Continuation` tolerates it (a
|
|
24
|
+
`CheckedContinuation` does not).
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
Make every exit path finish it, and stop the producer when the consumer goes
|
|
27
|
+
away:
|
|
26
28
|
|
|
27
29
|
```swift
|
|
28
|
-
let (
|
|
30
|
+
let (readings, sink) = AsyncStream.makeStream(of: Reading.self)
|
|
31
|
+
let scale = BluetoothScale()
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
monitor.onEvent = { event in
|
|
33
|
-
continuation.yield(event)
|
|
33
|
+
scale.onReading = { reading in
|
|
34
|
+
sink.yield(reading)
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
continuation.finish()
|
|
36
|
+
scale.onDisconnect = {
|
|
37
|
+
sink.finish()
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
continuation.onTermination = { _ in
|
|
42
|
-
monitor.stop()
|
|
39
|
+
sink.onTermination = { _ in
|
|
40
|
+
scale.disconnect()
|
|
43
41
|
}
|
|
44
42
|
```
|
|
45
43
|
|
|
46
|
-
|
|
47
44
|
## Buffering and back pressure
|
|
48
45
|
|
|
49
|
-
`AsyncStream`
|
|
46
|
+
By default an `AsyncStream` buffers without limit. A fast producer can make
|
|
47
|
+
memory grow without bound, so give a policy:
|
|
50
48
|
|
|
51
49
|
```swift
|
|
52
|
-
let (
|
|
53
|
-
of:
|
|
54
|
-
bufferingPolicy: .bufferingNewest(
|
|
50
|
+
let (samples, sink) = AsyncStream.makeStream(
|
|
51
|
+
of: AccelerometerSample.self,
|
|
52
|
+
bufferingPolicy: .bufferingNewest(50)
|
|
55
53
|
)
|
|
56
54
|
```
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- `.bufferingNewest(n)` keeps the most recent `n` elements, dropping older ones.
|
|
61
|
-
- `.bufferingOldest(n)` keeps the first `n` elements, dropping newer ones.
|
|
62
|
-
- `.unbounded` is the default; use only when the consumer keeps up.
|
|
56
|
+
The options:
|
|
63
57
|
|
|
58
|
+
- `.bufferingNewest(n)`: retain the most recent `n`, discard older ones.
|
|
59
|
+
- `.bufferingOldest(n)`: retain the earliest `n`, discard later arrivals.
|
|
60
|
+
- `.unbounded`, the default, is fine only when the consumer keeps pace.
|
|
64
61
|
|
|
65
62
|
## `for await` and cancellation
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
Cancelling the consuming task, or finishing the stream, ends a `for await`
|
|
65
|
+
loop automatically, so the loop body does not need its own cancellation check. Code
|
|
66
|
+
placed *after* the loop still runs, which makes it the place for any cleanup.
|
|
@@ -2,51 +2,99 @@
|
|
|
2
2
|
|
|
3
3
|
## Checked continuations
|
|
4
4
|
|
|
5
|
-
`withCheckedContinuation` and `withCheckedThrowingContinuation`
|
|
5
|
+
`withCheckedContinuation` and `withCheckedThrowingContinuation` turn a
|
|
6
|
+
callback API into an async function. The rule that matters above all others:
|
|
7
|
+
**on every path, resume the continuation exactly once.**
|
|
6
8
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
+
- Zero resumes leave the caller suspended forever.
|
|
10
|
+
- Two resumes crash at runtime.
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Default to `withCheckedContinuation` / `withCheckedThrowingContinuation` everywhere, including production builds. The runtime checks catch double-resume and missing-resume bugs that are otherwise extremely hard to diagnose.
|
|
13
|
-
|
|
14
|
-
Only consider switching to the `withUnsafe` continuation variants after profiling proves the checked version is a bottleneck in a hot path, but this is rare in practice.
|
|
12
|
+
Audit each path. When the callback might never fire, for example because its
|
|
13
|
+
owner was deallocated, still make sure something resumes the continuation.
|
|
15
14
|
|
|
15
|
+
Use the checked variants by default, in release builds too. Their runtime
|
|
16
|
+
checks catch double and missing resumes, which are otherwise very hard to
|
|
17
|
+
track down. Consider the `withUnsafe` variants only when profiling shows the
|
|
18
|
+
checked version is a bottleneck on a hot path, which is uncommon.
|
|
16
19
|
|
|
17
20
|
## Wrapping delegate-based APIs
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
A delegate that reports many values over time maps onto `AsyncStream`. Get
|
|
23
|
+
both halves from `makeStream(of:)`, and release resources in
|
|
24
|
+
`onTermination` once nobody is listening.
|
|
25
|
+
|
|
26
|
+
Two things to get right:
|
|
27
|
+
|
|
28
|
+
- Keep the continuation in a stored property so the delegate callbacks can
|
|
29
|
+
yield into it.
|
|
30
|
+
- The underlying service should be stopped in `onTermination`, which runs
|
|
31
|
+
when the listening loop exits or its task gets cancelled.
|
|
32
|
+
|
|
33
|
+
```swift
|
|
34
|
+
@MainActor
|
|
35
|
+
final class HeadingFeed: NSObject, CLLocationManagerDelegate {
|
|
36
|
+
private let manager = CLLocationManager()
|
|
37
|
+
private var sink: AsyncStream<CLLocationDirection>.Continuation?
|
|
38
|
+
|
|
39
|
+
func headings() -> AsyncStream<CLLocationDirection> {
|
|
40
|
+
let (stream, sink) = AsyncStream.makeStream(of: CLLocationDirection.self)
|
|
41
|
+
self.sink = sink
|
|
42
|
+
sink.onTermination = { [weak self] _ in
|
|
43
|
+
Task { @MainActor in self?.manager.stopUpdatingHeading() }
|
|
44
|
+
}
|
|
45
|
+
manager.delegate = self
|
|
46
|
+
manager.startUpdatingHeading()
|
|
47
|
+
return stream
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
nonisolated func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
|
|
51
|
+
let degrees = newHeading.trueHeading
|
|
52
|
+
MainActor.assumeIsolated {
|
|
53
|
+
_ = sink?.yield(degrees)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The manager is created on the main actor, so Core Location delivers its
|
|
60
|
+
callbacks there; that is the guarantee `MainActor.assumeIsolated` states. The
|
|
61
|
+
stream carries the `Sendable` heading value, not the non-Sendable `CLHeading`
|
|
62
|
+
object.
|
|
63
|
+
|
|
64
|
+
This serves one consumer. For several consumers, broadcast through an
|
|
65
|
+
`@Observable` class instead.
|
|
66
|
+
|
|
67
|
+
## Runtime isolation checks in callbacks
|
|
68
|
+
|
|
69
|
+
Callback APIs are where actor assumptions most often break at runtime.
|
|
70
|
+
|
|
71
|
+
- When callback code touches main-actor state while the compiler has no
|
|
72
|
+
proof it is on the main actor, Swift 6's runtime checks can trap rather than let the
|
|
73
|
+
race happen silently.
|
|
74
|
+
- `MainActor.assumeIsolated()` is for the case where the callback really is
|
|
75
|
+
delivered on the main actor and the code is stating a guarantee the compiler
|
|
76
|
+
cannot see. Nowhere else.
|
|
36
77
|
|
|
37
78
|
## `@unchecked Sendable`
|
|
38
79
|
|
|
39
|
-
This
|
|
80
|
+
This turns Sendable checking off for the type. It is a promise that thread
|
|
81
|
+
safety has been verified by hand, a high bar, so read such code very
|
|
82
|
+
carefully.
|
|
40
83
|
|
|
41
|
-
|
|
84
|
+
Acceptable uses:
|
|
42
85
|
|
|
43
|
-
- Types that
|
|
44
|
-
|
|
86
|
+
- Types that are truly thread safe through internal locking such as
|
|
87
|
+
`os_unfair_lock` or `NSLock`.
|
|
88
|
+
- Classes that an actor protects in practice, through an arrangement the
|
|
89
|
+
compiler has no way to model.
|
|
45
90
|
|
|
46
|
-
|
|
91
|
+
Warning signs:
|
|
47
92
|
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
-
|
|
93
|
+
- It was added to silence an error without understanding the error. Xcode
|
|
94
|
+
used to offer it as a Fix-It, so this is common.
|
|
95
|
+
- The class has unsynchronised mutable `var` storage.
|
|
96
|
+
- It was used as a shortcut instead of restructuring around value types or
|
|
97
|
+
actors.
|
|
51
98
|
|
|
52
|
-
|
|
99
|
+
First try removing it: Swift 6 region-based isolation often makes it
|
|
100
|
+
unnecessary, and many cases that once needed it now compile as they are.
|
|
@@ -1,100 +1,138 @@
|
|
|
1
1
|
# Bug patterns
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
<!-- toc -->
|
|
4
|
+
- [Check-then-act across a suspension inside an actor](#check-then-act-across-a-suspension-inside-an-actor)
|
|
5
|
+
- [A continuation that never resumes](#a-continuation-that-never-resumes)
|
|
6
|
+
- [A continuation that resumes twice](#a-continuation-that-resumes-twice)
|
|
7
|
+
- [Unstructured tasks spawned per item](#unstructured-tasks-spawned-per-item)
|
|
8
|
+
- [Errors lost inside a `Task` closure](#errors-lost-inside-a-task-closure)
|
|
9
|
+
- [Heavy synchronous work on the main actor](#heavy-synchronous-work-on-the-main-actor)
|
|
10
|
+
- [An `AsyncStream` buffer with no limit](#an-asyncstream-buffer-with-no-limit)
|
|
11
|
+
- [Treating `CancellationError` as a failure](#treating-cancellationerror-as-a-failure)
|
|
12
|
+
- [`@unchecked Sendable` covering an actual race](#unchecked-sendable-covering-an-actual-race)
|
|
13
|
+
<!-- /toc -->
|
|
14
|
+
|
|
15
|
+
Concurrency mistakes that generated code makes again and again, each with the
|
|
16
|
+
fix to recommend.
|
|
17
|
+
|
|
18
|
+
## Check-then-act across a suspension inside an actor
|
|
19
|
+
|
|
20
|
+
**What goes wrong:** the method tests some state, awaits, and then acts on a
|
|
21
|
+
test result that is no longer true. Any number of other calls can run on the
|
|
22
|
+
actor while it is suspended.
|
|
8
23
|
|
|
9
24
|
```swift
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
actor
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
func
|
|
16
|
-
if
|
|
17
|
-
|
|
25
|
+
// Defect: two concurrent callers both find no entry and both fetch.
|
|
26
|
+
// If a third caller evicts the entry mid-flight, the `!` crashes.
|
|
27
|
+
actor QuoteCache {
|
|
28
|
+
private var quotes: [String: Quote] = [:]
|
|
29
|
+
|
|
30
|
+
func quote(for symbol: String) async throws -> Quote {
|
|
31
|
+
if quotes[symbol] == nil {
|
|
32
|
+
quotes[symbol] = try await fetchQuote(symbol)
|
|
18
33
|
}
|
|
19
|
-
return
|
|
34
|
+
return quotes[symbol]!
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
```
|
|
23
38
|
|
|
24
|
-
**Fix:**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Continuation resumed zero times
|
|
28
|
-
|
|
29
|
-
**Failure:** A `withCheckedThrowingContinuation` callback never fires (object deallocated, network timeout with no callback, early return before registering the handler, etc). The caller hangs forever.
|
|
39
|
+
**Fix:** keep the awaited value in a local and write it afterwards. When
|
|
40
|
+
duplicate work must be avoided, cache the in-flight `Task` handle instead. The
|
|
41
|
+
complete pattern is in [actors.md](actors.md).
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
## A continuation that never resumes
|
|
32
44
|
|
|
45
|
+
**What goes wrong:** the callback wrapped by `withCheckedThrowingContinuation`
|
|
46
|
+
never runs. The owning object was freed, a timeout produced no callback, or the
|
|
47
|
+
code returned before it installed the handler. The awaiting caller is stuck
|
|
48
|
+
for good.
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
**Fix:** trace every path and prove the continuation resumes. If the wrapped
|
|
51
|
+
API is able to drop its callback silently, add a timeout or reshape the code
|
|
52
|
+
so nothing waits on it indefinitely. Stick with the checked variant rather
|
|
53
|
+
than the unsafe one, because a missed resume is far easier to diagnose there.
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
## A continuation that resumes twice
|
|
37
56
|
|
|
38
|
-
**
|
|
57
|
+
**What goes wrong:** two callbacks, say a completion handler and a cancel
|
|
58
|
+
handler, both resume one continuation. `CheckedContinuation` traps at runtime;
|
|
59
|
+
`UnsafeContinuation` gives undefined behaviour.
|
|
39
60
|
|
|
61
|
+
**Fix:** rewire the callbacks so a single path reaches the continuation. When
|
|
62
|
+
that cannot be done, guard it with a `Bool` flag or serialise access through an
|
|
63
|
+
actor. Keep `CheckedContinuation` as the default so a double resume shows up
|
|
64
|
+
during development and testing.
|
|
40
65
|
|
|
41
|
-
## Unstructured tasks
|
|
66
|
+
## Unstructured tasks spawned per item
|
|
42
67
|
|
|
43
|
-
**
|
|
68
|
+
**What goes wrong:** `for order in orders { Task { await ship(order) } }`
|
|
69
|
+
launches tasks nobody owns. Cancellation does not reach them, their errors go
|
|
70
|
+
nowhere, and the caller cannot wait for them to finish.
|
|
44
71
|
|
|
45
|
-
**Fix:**
|
|
72
|
+
**Fix:** a `withTaskGroup` or `withThrowingTaskGroup`. See
|
|
73
|
+
[structured.md](structured.md).
|
|
46
74
|
|
|
75
|
+
## Errors lost inside a `Task` closure
|
|
47
76
|
|
|
48
|
-
|
|
77
|
+
**What goes wrong:** with `Task { try await syncInbox() }`, a thrown error
|
|
78
|
+
disappears. Nothing is shown to the user; the work silently does not happen.
|
|
49
79
|
|
|
50
|
-
**
|
|
51
|
-
|
|
52
|
-
**Fix:** Handle the error inside the closure - show an alert, log to a visible surface, or propagate via a `@State` error property.
|
|
80
|
+
**Fix:** handle the error in the closure: present it, log it somewhere
|
|
81
|
+
visible, or store it in an error property the UI observes.
|
|
53
82
|
|
|
54
83
|
```swift
|
|
55
84
|
Task {
|
|
56
85
|
do {
|
|
57
|
-
try await
|
|
86
|
+
try await syncInbox()
|
|
58
87
|
} catch {
|
|
59
|
-
|
|
88
|
+
syncFailure = error.localizedDescription
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
91
|
```
|
|
63
92
|
|
|
93
|
+
## Heavy synchronous work on the main actor
|
|
64
94
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
95
|
+
**What goes wrong:** expensive computation executes on the main actor
|
|
96
|
+
(directly, or in a `Task {}` spawned there) and frames drop. Approachable
|
|
97
|
+
Concurrency makes this easier to hit, because with
|
|
98
|
+
`NonisolatedNonsendingByDefault` on, a `nonisolated` async function runs on the
|
|
99
|
+
caller's executor unless told otherwise.
|
|
70
100
|
|
|
101
|
+
**Fix:** give the computation its own `@concurrent` function;
|
|
102
|
+
`Task.detached` is the last resort.
|
|
71
103
|
|
|
72
|
-
##
|
|
104
|
+
## An `AsyncStream` buffer with no limit
|
|
73
105
|
|
|
74
|
-
**
|
|
106
|
+
**What goes wrong:** the producer yields faster than the consumer drains. With
|
|
107
|
+
the default `.unbounded` policy, memory climbs without bound.
|
|
75
108
|
|
|
76
|
-
**Fix:**
|
|
109
|
+
**Fix:** choose a bounded policy, `.bufferingNewest(n)` or
|
|
110
|
+
`.bufferingOldest(n)`. See
|
|
111
|
+
[async-streams.md](async-streams.md).
|
|
77
112
|
|
|
113
|
+
## Treating `CancellationError` as a failure
|
|
78
114
|
|
|
79
|
-
|
|
115
|
+
**What goes wrong:** the error handler alerts the user about, or retries
|
|
116
|
+
after, a `CancellationError`. Cancellation is an ordinary lifecycle event, for example
|
|
117
|
+
the user leaving the screen.
|
|
80
118
|
|
|
81
|
-
**
|
|
82
|
-
|
|
83
|
-
**Fix:** Check for cancellation before handling other errors:
|
|
119
|
+
**Fix:** match cancellation first and let it pass quietly:
|
|
84
120
|
|
|
85
121
|
```swift
|
|
86
122
|
do {
|
|
87
|
-
try await
|
|
123
|
+
try await refreshFeed()
|
|
88
124
|
} catch is CancellationError {
|
|
89
|
-
//
|
|
125
|
+
// Expected when the screen goes away; nothing to report.
|
|
90
126
|
} catch {
|
|
91
|
-
|
|
127
|
+
feedError = error.localizedDescription
|
|
92
128
|
}
|
|
93
129
|
```
|
|
94
130
|
|
|
131
|
+
## `@unchecked Sendable` covering an actual race
|
|
95
132
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
**What goes wrong:** a class gets `@unchecked Sendable` to make the compiler
|
|
134
|
+
stop complaining, yet its `var` properties have no synchronisation at all. The
|
|
135
|
+
race is still there at runtime.
|
|
99
136
|
|
|
100
|
-
**Fix:**
|
|
137
|
+
**Fix:** value types, an actor, or a lock around the state; details in
|
|
138
|
+
[bridging.md](bridging.md).
|
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
# Cancellation
|
|
2
2
|
|
|
3
3
|
<!-- toc -->
|
|
4
|
-
- [How cancellation
|
|
4
|
+
- [How cancellation spreads](#how-cancellation-spreads)
|
|
5
5
|
- [Checking for cancellation](#checking-for-cancellation)
|
|
6
6
|
- [`withTaskCancellationHandler`](#withtaskcancellationhandler)
|
|
7
7
|
- [Broken cancellation patterns](#broken-cancellation-patterns)
|
|
8
8
|
<!-- /toc -->
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Swift concurrency cancels cooperatively. Raising the cancelled flag has no
|
|
11
|
+
effect until the running code looks at it.
|
|
11
12
|
|
|
12
|
-
## How cancellation
|
|
13
|
-
|
|
14
|
-
- Cancelling a parent task cancels all its children (structured concurrency).
|
|
15
|
-
- Cancelling a task group cancels all child tasks in that group.
|
|
16
|
-
- `Task {}` and `Task.detached {}` are unstructured - they must be cancelled explicitly by storing and calling `.cancel()` on the task handle.
|
|
17
|
-
- SwiftUI's `.task()` modifier cancels its task automatically when the view disappears. This is the primary reason to prefer `.task()` over `onAppear()` or loose `Task {}` in views.
|
|
13
|
+
## How cancellation spreads
|
|
18
14
|
|
|
15
|
+
- A cancelled parent task cancels each of its children (structured
|
|
16
|
+
concurrency).
|
|
17
|
+
- A cancelled task group cancels every child in it.
|
|
18
|
+
- Unstructured tasks (`Task {}`, `Task.detached {}`) are never cancelled
|
|
19
|
+
automatically; keep the handle and call `.cancel()` on it.
|
|
20
|
+
- The SwiftUI `.task()` modifier ends its work once the view goes away.
|
|
21
|
+
That is the main argument for `.task()` over `onAppear()` or a stray
|
|
22
|
+
`Task {}` in a view.
|
|
19
23
|
|
|
20
24
|
## Checking for cancellation
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
Check inside long-running or looping work, and only at points where leaving
|
|
27
|
+
early is safe:
|
|
23
28
|
|
|
24
|
-
- `try Task.checkCancellation()`
|
|
25
|
-
|
|
29
|
+
- `try Task.checkCancellation()` throws `CancellationError`. The preferred
|
|
30
|
+
form wherever throwing is allowed.
|
|
31
|
+
- `Task.isCancelled` returns a `Bool`. Use it where the code cannot throw, or
|
|
32
|
+
where cleanup must run before returning.
|
|
26
33
|
|
|
27
34
|
```swift
|
|
28
|
-
func
|
|
29
|
-
for
|
|
35
|
+
func transcode(_ clips: [Clip]) async throws {
|
|
36
|
+
for clip in clips {
|
|
30
37
|
try Task.checkCancellation()
|
|
31
|
-
try await
|
|
38
|
+
try await encode(clip)
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
```
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
Each `await` is a chance to notice cancellation, but only if the callee
|
|
44
|
+
itself checks. A CPU-bound loop with no `await` in it never notices unless it
|
|
45
|
+
checks explicitly.
|
|
38
46
|
|
|
39
47
|
## `withTaskCancellationHandler`
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
This connects Swift cancellation to an older API that has its own way of
|
|
50
|
+
cancelling. The `onCancel` closure runs as soon as cancellation is requested,
|
|
51
|
+
even while the body is suspended, and it can run on any thread.
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return try await withTaskCancellationHandler {
|
|
47
|
-
let (data, _) = try await URLSession.shared.data(for: request)
|
|
48
|
-
return data
|
|
49
|
-
} onCancel: {
|
|
50
|
-
// No direct handle to cancel here - URLSession.data(for:) already
|
|
51
|
-
// checks for task cancellation internally. This pattern is most
|
|
52
|
-
// useful when wrapping APIs that return a cancellable handle.
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
A more realistic use is wrapping something that gives you a cancel handle:
|
|
53
|
+
`URLSession.data(for:)` already watches for task cancellation, so wrapping it
|
|
54
|
+
gains nothing; there is no handle to cancel. The handler earns its place when
|
|
55
|
+
the wrapped API gives back a cancellable object:
|
|
58
56
|
|
|
59
57
|
```swift
|
|
60
|
-
func
|
|
61
|
-
let
|
|
62
|
-
let operation = CKQueryOperation(query: query)
|
|
63
|
-
|
|
58
|
+
func runExport(_ job: ExportJob) async throws -> URL {
|
|
59
|
+
let operation = ExportOperation(job: job)
|
|
64
60
|
return try await withTaskCancellationHandler {
|
|
65
|
-
try await
|
|
61
|
+
try await operation.start()
|
|
66
62
|
} onCancel: {
|
|
67
63
|
operation.cancel()
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
```
|
|
71
67
|
|
|
68
|
+
The same shape applies to things like `CKQueryOperation`, whose `cancel()` can
|
|
69
|
+
be called from `onCancel`.
|
|
72
70
|
|
|
73
71
|
## Broken cancellation patterns
|
|
74
72
|
|
|
75
|
-
**
|
|
73
|
+
**Handling `CancellationError` like any other error:**
|
|
76
74
|
|
|
77
75
|
```swift
|
|
78
|
-
//
|
|
76
|
+
// Broken: reacts to a normal lifecycle event with an alert or a retry.
|
|
79
77
|
catch {
|
|
80
|
-
|
|
78
|
+
presentAlert(error.localizedDescription)
|
|
81
79
|
}
|
|
82
80
|
```
|
|
83
81
|
|
|
84
|
-
|
|
82
|
+
Filter out `CancellationError` before handling the rest. See
|
|
83
|
+
[bug-patterns.md](bug-patterns.md).
|
|
85
84
|
|
|
86
|
-
**
|
|
85
|
+
**Never cancelling a stored task:**
|
|
87
86
|
|
|
88
87
|
```swift
|
|
89
|
-
//
|
|
90
|
-
class
|
|
91
|
-
var
|
|
88
|
+
// Broken: the task keeps going after its owner is finished with it.
|
|
89
|
+
final class SearchModel {
|
|
90
|
+
var searchTask: Task<Void, Never>?
|
|
92
91
|
|
|
93
|
-
func
|
|
94
|
-
|
|
92
|
+
func search(_ text: String) {
|
|
93
|
+
searchTask = Task { await runQuery(text) }
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
Cancel the previous task before
|
|
98
|
+
Cancel the previous task before replacing it, and cancel again on teardown:
|
|
100
99
|
|
|
101
100
|
```swift
|
|
102
|
-
func
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
func search(_ text: String) {
|
|
102
|
+
searchTask?.cancel()
|
|
103
|
+
searchTask = Task { await runQuery(text) }
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
deinit {
|
|
108
|
-
|
|
107
|
+
searchTask?.cancel()
|
|
109
108
|
}
|
|
110
109
|
```
|
|
111
110
|
|
|
112
|
-
**
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
**CPU-bound work without checks:** a tight computation loop with no `await`
|
|
112
|
+
runs to the end even after cancellation, because cancellation has no
|
|
113
|
+
suspension point to act on. Add `try Task.checkCancellation()` at regular,
|
|
114
|
+
safe intervals.
|