appstore-precheck 1.18.0 → 1.20.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +256 -0
  2. package/README.md +108 -39
  3. package/bin/cli.js +8 -0
  4. package/package.json +2 -2
  5. package/skills/appstore-precheck/SKILL.md +99 -157
  6. package/skills/appstore-precheck/guidelines-baseline.json +285 -36
  7. package/skills/appstore-precheck/guidelines-fingerprints.json +319 -93
  8. package/skills/appstore-precheck/references/finding-commentary.md +93 -0
  9. package/skills/appstore-precheck/references/methodology.md +81 -26
  10. package/skills/appstore-precheck/references/optional-review.md +56 -0
  11. package/skills/appstore-precheck/references/pierre-deep-review.md +323 -44
  12. package/skills/appstore-precheck/references/review-catalog.json +740 -0
  13. package/skills/appstore-precheck/references/screenshot-vision-review.md +8 -8
  14. package/skills/appstore-precheck/references/simulator-dynamic-review.md +398 -54
  15. package/skills/appstore-precheck/references/typesafe-example.json +239 -0
  16. package/skills/appstore-precheck/references/typesafe.md +216 -0
  17. package/skills/appstore-precheck/scripts/app-discover.sh +138 -0
  18. package/skills/appstore-precheck/scripts/artifact-review.sh +10 -0
  19. package/skills/appstore-precheck/scripts/augment-json.py +29 -0
  20. package/skills/appstore-precheck/scripts/build-run.sh +5 -0
  21. package/skills/appstore-precheck/scripts/coverage-sections.sh +6 -0
  22. package/skills/appstore-precheck/scripts/dynamic-run.sh +400 -0
  23. package/skills/appstore-precheck/scripts/dynamic.sh +329 -0
  24. package/skills/appstore-precheck/scripts/evidence.sh +49 -15
  25. package/skills/appstore-precheck/scripts/findings.sh +76 -26
  26. package/skills/appstore-precheck/scripts/framework-detect.sh +101 -0
  27. package/skills/appstore-precheck/scripts/guideline-cite.sh +4 -1
  28. package/skills/appstore-precheck/scripts/lib/artifact-review.py +518 -0
  29. package/skills/appstore-precheck/scripts/lib/asc-client.py +293 -0
  30. package/skills/appstore-precheck/scripts/lib/build-evidence.py +50 -0
  31. package/skills/appstore-precheck/scripts/lib/build-exec.py +50 -0
  32. package/skills/appstore-precheck/scripts/lib/build-plan.py +106 -0
  33. package/skills/appstore-precheck/scripts/lib/build-plan.sh +15 -0
  34. package/skills/appstore-precheck/scripts/lib/build-run.py +177 -0
  35. package/skills/appstore-precheck/scripts/lib/coverage-run.sh +23 -0
  36. package/skills/appstore-precheck/scripts/lib/coverage-sections.py +244 -0
  37. package/skills/appstore-precheck/scripts/lib/dyn-bundle.sh +185 -0
  38. package/skills/appstore-precheck/scripts/lib/dyn-demo-login.py +111 -0
  39. package/skills/appstore-precheck/scripts/lib/dyn-device.sh +123 -0
  40. package/skills/appstore-precheck/scripts/lib/dyn-explore.py +312 -0
  41. package/skills/appstore-precheck/scripts/lib/dyn-geometry.sh +75 -0
  42. package/skills/appstore-precheck/scripts/lib/dyn-guideline-capture.py +301 -0
  43. package/skills/appstore-precheck/scripts/lib/dyn-guidelines.py +112 -0
  44. package/skills/appstore-precheck/scripts/lib/dyn-guidelines.sh +23 -0
  45. package/skills/appstore-precheck/scripts/lib/dyn-hosts.sh +134 -0
  46. package/skills/appstore-precheck/scripts/lib/dyn-process.py +75 -0
  47. package/skills/appstore-precheck/scripts/lib/dyn-quorum.sh +90 -0
  48. package/skills/appstore-precheck/scripts/lib/dyn-scrub.py +79 -0
  49. package/skills/appstore-precheck/scripts/lib/dyn-signals.sh +120 -0
  50. package/skills/appstore-precheck/scripts/lib/guideline-text.sh +23 -5
  51. package/skills/appstore-precheck/scripts/lib/metadata-review.py +369 -0
  52. package/skills/appstore-precheck/scripts/lib/optin-scan.sh +73 -0
  53. package/skills/appstore-precheck/scripts/lib/optional-records.py +60 -0
  54. package/skills/appstore-precheck/scripts/lib/png-uniform.py +115 -0
  55. package/skills/appstore-precheck/scripts/lib/runtime-blocking.py +26 -0
  56. package/skills/appstore-precheck/scripts/lib/safe_write.py +61 -0
  57. package/skills/appstore-precheck/scripts/lib/scan-guidelines.sh +199 -0
  58. package/skills/appstore-precheck/scripts/lib/static-guidelines.py +341 -0
  59. package/skills/appstore-precheck/scripts/lib/static-reader.py +39 -0
  60. package/skills/appstore-precheck/scripts/metadata-review.sh +4 -0
  61. package/skills/appstore-precheck/scripts/opt-in-review.py +160 -0
  62. package/skills/appstore-precheck/scripts/runtime-review.sh +5 -0
  63. package/skills/appstore-precheck/scripts/scan.sh +132 -21
  64. package/skills/appstore-precheck/scripts/semantic/__init__.py +1 -0
  65. package/skills/appstore-precheck/scripts/semantic/client.py +95 -0
  66. package/skills/appstore-precheck/scripts/semantic/collect.py +165 -0
  67. package/skills/appstore-precheck/scripts/semantic/engine.py +320 -0
  68. package/skills/appstore-precheck/scripts/semantic/questions.py +167 -0
  69. package/skills/appstore-precheck/scripts/semantic/review_v4.py +81 -0
  70. package/skills/appstore-precheck/scripts/semantic-review.py +61 -0
@@ -0,0 +1,239 @@
1
+ {
2
+ "version": 1,
3
+ "jobs": [
4
+ {
5
+ "id": "review-example",
6
+ "workflow": "review",
7
+ "context": {
8
+ "check_definition": "Does this user-facing release note describe an unfinished app?"
9
+ },
10
+ "coverage": {
11
+ "complete": true,
12
+ "missing": []
13
+ },
14
+ "evidence": [
15
+ {
16
+ "id": "source",
17
+ "path": "synthetic/review.txt",
18
+ "line": 1,
19
+ "text": "Welcome to our unfinished public beta."
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ "id": "copy-example",
25
+ "workflow": "copy",
26
+ "context": {
27
+ "text": "Try the preview of your invoice before sending.",
28
+ "locale": "en",
29
+ "ui_role": "invoice toolbar",
30
+ "flow_stage": "document editing"
31
+ },
32
+ "coverage": {
33
+ "complete": true,
34
+ "missing": []
35
+ },
36
+ "evidence": [
37
+ {
38
+ "id": "source",
39
+ "path": "synthetic/copy.txt",
40
+ "line": 1,
41
+ "text": "Try the preview of your invoice before sending."
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ "id": "purpose-example",
47
+ "workflow": "purpose",
48
+ "context": {
49
+ "permission_key": "NSMicrophoneUsageDescription",
50
+ "text": "Sesli notlarınızı kaydetmek için mikrofon kullanılır.",
51
+ "locale": "tr",
52
+ "feature_description": "Users record voice notes."
53
+ },
54
+ "coverage": {
55
+ "complete": true,
56
+ "missing": []
57
+ },
58
+ "evidence": [
59
+ {
60
+ "id": "source",
61
+ "path": "synthetic/purpose.txt",
62
+ "line": 1,
63
+ "text": "Sesli notlarınızı kaydetmek için mikrofon kullanılır."
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "id": "disclosure-example",
69
+ "workflow": "disclosure",
70
+ "context": {
71
+ "copy": "After 7 days, $9.99/month. Renews automatically. Cancel in Settings before renewal.",
72
+ "product_terms": {
73
+ "trial": true,
74
+ "price": "9.99 USD/month"
75
+ },
76
+ "locale": "en",
77
+ "policy_excerpt": "Review whether the supplied disclosure explains trial billing, renewal and cancellation.",
78
+ "locale_pair": {
79
+ "en": "7 days free, then $9.99/month",
80
+ "fr": "7 jours gratuits, puis 9,99 USD/mois"
81
+ }
82
+ },
83
+ "coverage": {
84
+ "complete": true,
85
+ "missing": []
86
+ },
87
+ "evidence": [
88
+ {
89
+ "id": "source",
90
+ "path": "synthetic/disclosure.txt",
91
+ "line": 1,
92
+ "text": "After 7 days, $9.99/month. Renews automatically. Cancel in Settings before renewal."
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ "id": "consistency-example",
98
+ "workflow": "consistency",
99
+ "context": {
100
+ "claim": "We never collect location.",
101
+ "comparison_kind": "privacy policy versus observed implementation"
102
+ },
103
+ "coverage": {
104
+ "complete": true,
105
+ "missing": []
106
+ },
107
+ "evidence": [
108
+ {
109
+ "id": "source",
110
+ "path": "synthetic/consistency.txt",
111
+ "line": 1,
112
+ "text": "The observed runtime trace records GPS coordinates and transmits them to analytics.example."
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ "id": "routing-example",
118
+ "workflow": "routing",
119
+ "context": {
120
+ "offering": "Home-delivered groceries",
121
+ "flow": "Card payment for delivered physical goods",
122
+ "policy_excerpt": "For this synthetic example, physical goods use an external processor."
123
+ },
124
+ "coverage": {
125
+ "complete": true,
126
+ "missing": []
127
+ },
128
+ "evidence": [
129
+ {
130
+ "id": "source",
131
+ "path": "synthetic/routing.txt",
132
+ "line": 1,
133
+ "text": "Card payment for delivered physical goods"
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ "id": "rerank-example",
139
+ "workflow": "rerank",
140
+ "context": {
141
+ "query": "Purpose strings must describe why microphone access is needed",
142
+ "candidates": [
143
+ {
144
+ "id": "privacy",
145
+ "text": "Explain why microphone access benefits the user."
146
+ },
147
+ {
148
+ "id": "screenshots",
149
+ "text": "Screenshots must show the app."
150
+ }
151
+ ]
152
+ },
153
+ "coverage": {
154
+ "complete": true,
155
+ "missing": []
156
+ },
157
+ "evidence": []
158
+ },
159
+ {
160
+ "id": "verify-example",
161
+ "workflow": "verify",
162
+ "context": {
163
+ "claim": "The production binary transmits location.",
164
+ "source_id": "source",
165
+ "evidence_class": "source",
166
+ "build_config": "unknown",
167
+ "quote": "requestWhenInUseAuthorization()"
168
+ },
169
+ "coverage": {
170
+ "complete": true,
171
+ "missing": []
172
+ },
173
+ "evidence": [
174
+ {
175
+ "id": "source",
176
+ "path": "synthetic/verify.txt",
177
+ "line": 1,
178
+ "text": "requestWhenInUseAuthorization()"
179
+ }
180
+ ]
181
+ },
182
+ {
183
+ "id": "drift-example",
184
+ "workflow": "drift",
185
+ "context": {
186
+ "old_text": "Include a privacy policy.",
187
+ "new_text": "Include a privacy policy and disclose each AI provider.",
188
+ "publication_date": "2026-09-18",
189
+ "rule_catalog": [
190
+ {
191
+ "id": "privacy",
192
+ "description": "Privacy policy matches collection."
193
+ },
194
+ {
195
+ "id": "ai-consent",
196
+ "description": "AI provider disclosure."
197
+ }
198
+ ]
199
+ },
200
+ "coverage": {
201
+ "complete": true,
202
+ "missing": []
203
+ },
204
+ "evidence": [
205
+ {
206
+ "id": "source",
207
+ "path": "synthetic/drift.txt",
208
+ "line": 1,
209
+ "text": "Include a privacy policy and disclose each AI provider."
210
+ }
211
+ ]
212
+ },
213
+ {
214
+ "id": "functionality-example",
215
+ "workflow": "functionality",
216
+ "context": {
217
+ "app_purpose": "Voice notebook",
218
+ "reachable_flows": [
219
+ "create recording",
220
+ "play recording",
221
+ "delete recording"
222
+ ],
223
+ "coverage_notes": "Synthetic observed flows only"
224
+ },
225
+ "coverage": {
226
+ "complete": true,
227
+ "missing": []
228
+ },
229
+ "evidence": [
230
+ {
231
+ "id": "source",
232
+ "path": "synthetic/functionality.txt",
233
+ "line": 1,
234
+ "text": "Observed: create a recording, play it, then delete it."
235
+ }
236
+ ]
237
+ }
238
+ ]
239
+ }
@@ -0,0 +1,216 @@
1
+ # Optional TypeSafe / Jev semantic review
2
+
3
+ TypeSafe is an opt-in, text-only advisory layer. The default Bash scanner, JSON/SARIF
4
+ formats, FAIL/WARN counts, evidence labels, runtime reconciliation, and upload token
5
+ are unchanged. Every result has `advisory: true`; the report has `mode: shadow`.
6
+ Experimental probability thresholds are not a claim of measured App Store accuracy.
7
+
8
+ ## Run it
9
+
10
+ Python 3.8+ with the standard library is sufficient; no pip or npm dependency is added.
11
+ The `review` command is included in the npm package and the skill installation.
12
+
13
+ ```sh
14
+ # Collect locally; no network, build, or device access. Redirect to a private location.
15
+ npx appstore-precheck review --repo /path/to/app --prepare > /tmp/review-bundle.json
16
+
17
+ # Inspect and enrich the bundle, then inspect the exact API requests (still offline).
18
+ npx appstore-precheck review --bundle /tmp/review-bundle.json --dry-run
19
+
20
+ # TYPESAFE_API_KEY must already be set in your environment; never put it in the bundle.
21
+ # --live explicitly sends the bundle's source/copy/policy evidence to TypeSafe.
22
+ npx appstore-precheck review --bundle /tmp/review-bundle.json --live \
23
+ --cache-dir /tmp/app-typesafe-cache > /tmp/review-result.json
24
+
25
+ # Replay exact cached requests, without a key or network access.
26
+ npx appstore-precheck review --bundle /tmp/review-bundle.json \
27
+ --cache-dir /tmp/app-typesafe-cache --format text
28
+ ```
29
+
30
+ When installed as a skill, run `python3 -B <skill-dir>/scripts/semantic-review.py`
31
+ with the same arguments. `--workflows` prints every question and required context field.
32
+ Without `--live`, requests never reach the network. `--repo` defaults to preparation;
33
+ `--bundle` defaults to cache-only review. Missing credentials/cache, malformed answers,
34
+ timeouts, or unknown evidence become `insufficient_evidence`, never PASS.
35
+
36
+ The collector excludes dependency/build/test trees, hidden directories, credentials
37
+ files, and symlinks. It redacts recognizable secret assignments and private keys.
38
+ Redaction is best-effort: inspect collected source before sending it. App Review
39
+ password files are never collected. Represent credentials only as locally established
40
+ presence/placeholder facts; do not submit passwords or App Store Connect keys.
41
+
42
+ Collection is deliberately bounded: 48 evidence files, 5,000 characters per file,
43
+ 70,000 collected characters, and at most 128 jobs. Truncation/unreadable files set
44
+ coverage gaps; they are never silently treated as absence. Parsed plist/String Catalog
45
+ values use file-level line 1 pointers explicitly marked as representations. Host agents
46
+ should replace them with exact source spans when available. Source coverage never proves
47
+ shipping-binary behavior. URL contents and visual observations require host inspection.
48
+
49
+ ## Bundle contract
50
+
51
+ The complete executable example is [typesafe-example.json](typesafe-example.json).
52
+ It contains synthetic evidence for all ten workflows, not labeled accuracy results.
53
+
54
+ ```json
55
+ {
56
+ "version": 1,
57
+ "jobs": [{
58
+ "id": "camera-purpose",
59
+ "workflow": "purpose",
60
+ "context": {
61
+ "permission_key": "NSCameraUsageDescription",
62
+ "text": "Scan QR codes to open your saved tickets.",
63
+ "locale": "en",
64
+ "feature_description": "The ticket screen scans QR codes."
65
+ },
66
+ "coverage": {"complete": true, "missing": []},
67
+ "evidence": [{
68
+ "id": "purpose",
69
+ "path": "App/Info.plist",
70
+ "line": 24,
71
+ "text": "Scan QR codes to open your saved tickets."
72
+ }, {
73
+ "id": "feature",
74
+ "path": "App/TicketScanner.swift",
75
+ "line": 18,
76
+ "text": "metadataOutput.metadataObjectTypes = [.qr]"
77
+ }]
78
+ }]
79
+ }
80
+ ```
81
+
82
+ `context` holds facts, comparisons, and policy text. Questions live in the versioned
83
+ registry, not user data. `evidence` contains verbatim source spans, unique IDs and real
84
+ pointers (or explicitly marked parsed representations). `coverage.complete` is the
85
+ host's assertion that evidence is sufficient for this *bounded question*, not a model
86
+ prediction. Keep it false until missing inputs are actually supplied. Incomplete jobs
87
+ return a Pierre handoff without spending API tokens. Do not set it true just to run Jev.
88
+
89
+ ## Workflows and host integration
90
+
91
+ | Workflow | Primitive | Required context / use |
92
+ |---|---|---|
93
+ | `review` | Choice | `check_definition`; one catalog check, outcome plus evidence selection |
94
+ | `copy` | Noul | `text`, `locale`, `ui_role`, `flow_stage`; attach handler/flow evidence for consent or rating gates |
95
+ | `purpose` | Score + Noul | `permission_key`, `text`, `locale`, `feature_description`; specificity and feature agreement |
96
+ | `disclosure` | Noul + Choice | `copy`, `product_terms` (including boolean `trial`), `locale`, `policy_excerpt`; optional `locale_pair` |
97
+ | `consistency` | Choice | `claim`, `comparison_kind`; compare marketing, code, privacy, or locale evidence |
98
+ | `routing` | Choice + Noul | `offering`, `flow`, `policy_excerpt`; add storefront, exemption and account-dependency evidence |
99
+ | `rerank` | Score per candidate | `query`, `candidates` with unique `id` and `text`; original order is fallback |
100
+ | `verify` | Noul | `claim`, `source_id`, `evidence_class`, `build_config`; optional exact `quote` |
101
+ | `drift` | Choice + Noul | `old_text`, `new_text`, `publication_date`, `rule_catalog`; each rule evaluated independently |
102
+ | `functionality` | Score + Choice | `app_purpose`, `reachable_flows`, `coverage_notes`; observed task completion, not compliance |
103
+
104
+ All questions within a job share state and are independent. The runner processes jobs
105
+ sequentially to bound load. A later request is needed when routing discovers new evidence
106
+ requirements. Unknown/mixed offerings retain a broader review route. Exemption signals
107
+ never clear scanner warnings. Disclosures ignore trial answers when no trial exists and
108
+ ignore locale comparison answers when no locale pair was supplied.
109
+
110
+ For Phase 3, submit each explanation claim with its real cited source to `verify`.
111
+ An exact-quote mismatch is caught locally before inference. When verification fails,
112
+ retain the original scanner line and evidence pointer, revise the explanation or use
113
+ a factual template; never modify the scanner finding.
114
+
115
+ For Phase 4, prepare all 31 checks using `review-catalog.json` stable keys. Add narrow
116
+ copy, purpose, disclosure, comparison, and routing jobs as evidence becomes available.
117
+ Keep full Pierre review during the experimental rollout. Supplementary workflow jobs
118
+ are a separate shadow-results block, not extra checks in the "31 checks" denominator.
119
+ `action: pierre_review` means
120
+ the host agent continues the original checklist procedure; the standalone CLI does not
121
+ launch an agent or bill a second model. Emit the existing advisory `REVIEW-*` report.
122
+ Screenshots, previews, layout, and actual simulator actions remain with the host tools.
123
+ Do not present text-only Jev judgments as image inspection or runtime verification.
124
+
125
+ For Phase 0, provide the fetched old/new policy text and affected rule definitions to
126
+ `drift`. Filter announcement dates deterministically before creating jobs. Retain every
127
+ original drift warning regardless of the model's change classification. Reconciliation
128
+ remains a deliberate human action; this tool never updates fingerprints or baseline files.
129
+
130
+ For retrieval, the existing eval RAG helper supports:
131
+
132
+ ```sh
133
+ python3 eval/rag/retrieve.py --case eval/dataset/cases/check18-specific-purpose-strings.json \
134
+ --top-k 10 --rerank-typesafe
135
+ ```
136
+
137
+ This explicitly adds a paid Jev reranking call after Gemini retrieval. Uncertain ranks
138
+ and service failures preserve the original ordering. All candidates are retained;
139
+ exact section references must not be discarded because of semantic ranking.
140
+
141
+ ## Uncertainty, provenance, and fallback
142
+
143
+ - Choice: selected probability at least 0.90 and distribution confidence at least 0.50.
144
+ - Noul: concern at least 0.90; absence at most 0.10; verified support at least 0.95.
145
+ - Score: preserve levels and probabilities; purpose quality uses probability mass on
146
+ the two weakest levels. Functionality scores only prioritize review.
147
+ - One serious concern cannot be averaged away by unrelated positive signals.
148
+ - Findings need a confidently selected supplied evidence span. Unknown evidence IDs,
149
+ missing questions, invalid probabilities, NaN, model mismatch and invalid usage fail
150
+ validation. Noul has no invented confidence field.
151
+ - Existing `confidence` enforcement labels remain unchanged. Jev values use
152
+ `model_probability`, `model_confidence`, and the raw `judgments` object. Probability
153
+ is not the likelihood Apple rejects the submission.
154
+ - An incomplete review renders an advisory handoff, never a clean pass. Text output
155
+ has no `FAIL:`/`WARN:` lines that could enter verdict arithmetic.
156
+
157
+ ## Cost, caching, and evaluation
158
+
159
+ The default is pinned `jev-1.13.0`. Reviewed documentation on 2026-09-18 lists $0.042
160
+ per million input tokens and free output tokens. `estimated_cost_usd` uses actual
161
+ returned input usage; it is an estimate, not an invoice. Transport failures can have
162
+ unknown cost. Host/Pierre calls are not included. Replayed results report zero new
163
+ billed tokens; API latency and cache latency remain distinguishable through `cached`.
164
+
165
+ The documented ~100 ms typical query latency is not a measured repo guarantee. Reports
166
+ record measured request latency. HTTP requests time out after 15 seconds, with at most
167
+ two retries for retryable HTTP statuses and backoff capped at 5 seconds. Lost transport
168
+ responses are not automatically retried. Redirects cannot forward the API key.
169
+
170
+ Caches are opt-in. Files are written atomically with mode 0600 and include exact requests,
171
+ responses, model, evidence, question-version and threshold fingerprints. Keep caches
172
+ outside version control. Invalid or mismatched entries are never trusted. A changed
173
+ model, evidence bundle, question, or threshold requires a new result.
174
+
175
+ ```sh
176
+ bash eval/validate.sh
177
+ bash eval/run.sh --provider typesafe --cases 'check18-*' --dry-run
178
+ # Paid evaluation; requires TYPESAFE_API_KEY. Every repeat is a fresh request.
179
+ bash eval/run.sh --provider typesafe --repeat 3 --out eval/runs/jev-pilot
180
+ python3 eval/score.py --run eval/runs/jev-pilot
181
+ ```
182
+
183
+ Current cases have stable `check_key` values; display numbers are catalog-versioned.
184
+ New runs snapshot cases. Historical results retain their original labels and numbering
185
+ through `eval/baseline/cases-v1.json`; old response files are never relabeled or rewritten.
186
+ The scorer separates abstentions from true negatives, reports decision coverage,
187
+ latency percentiles, estimated cost, probability bands and binary Brier score when
188
+ TypeSafe data exists. A 95% decision-coverage floor on answerable cases accompanies
189
+ the existing Tier-A F1 gate; expected abstentions are measured separately.
190
+ New candidate fixtures remain `label_confirmed: false` until a human independently
191
+ reviews them. Offline mocked tests are protocol/behavior checks, not quality evidence.
192
+
193
+ Before promoting any workflow, evaluate false negatives and false positives by check
194
+ and language, measure handoff rate, calibrate thresholds on held-out human labels, and
195
+ compare *total* cost including host escalation. Preserve shadow mode until that evidence
196
+ supports a narrower deployment. No TypeSafe judgment issues or removes an upload token.
197
+
198
+ Sources: [API](https://docs.typesafe.ai/api), [models/pricing](https://docs.typesafe.ai/models),
199
+ [confidence](https://docs.typesafe.ai/confidence), [state](https://docs.typesafe.ai/concepts/state),
200
+ [reranking](https://docs.typesafe.ai/cookbooks/rerank_typesafe),
201
+ [citation verification](https://docs.typesafe.ai/cookbooks/citation_check).
202
+
203
+ ## Request-attempt telemetry
204
+
205
+ JSON results include `transport_attempts`, `retry_count` and
206
+ `retry_billing_unknown`. Cache hits, offline fallbacks and evidence guards use
207
+ zero attempts. The built-in client counts each HTTP attempt, including failed
208
+ ones. Injected test/custom clients count one invocation; their internal retries
209
+ are not observable.
210
+
211
+ When a retry occurs, usage and estimated cost from the final response do not
212
+ account for unknown billing of earlier attempts. Treat `retry_billing_unknown`
213
+ as an incomplete billing record, not a zero-cost retry. Failed requests without
214
+ usage keep billing unknown. These local fields do not alter the API contract or
215
+ authorize live calls. See the [TypeSafe API reference](https://docs.typesafe.ai/api)
216
+ for the current transport contract.
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env bash
2
+ # app-discover.sh — find simulator .app bundles the USER already built, describe them,
3
+ # recommend the newest, and stop. Never builds (no xcodebuild / flutter / gradle),
4
+ # never launches, never writes under the repo. Bash 3.2 compatible.
5
+ #
6
+ # WHY THIS EXISTS
7
+ # ---------------
8
+ # The Phase 6 dynamic tier needs a simulator .app. Building it ourselves is out of
9
+ # the question (principle 2: never run the user's build), so the tier either finds a
10
+ # build the user already made or asks for one. Two places hold such builds:
11
+ # ~/Library/Developer/Xcode/DerivedData/*/Build/Products/*-iphonesimulator/*.app
12
+ # <repo>/build/ios/iphonesimulator/*.app (flutter build ios --simulator)
13
+ # <repo>/ios/build/Build/Products/*-iphonesimulator/*.app (react-native run-ios)
14
+ # Each candidate is reported with its mtime, its configuration READ FROM THE DIRECTORY
15
+ # NAME (Debug-iphonesimulator → debug, Release-iphonesimulator → release, anything
16
+ # else → unknown; never inferred from the plist), and its bundle id from Info.plist.
17
+ # The newest is recommended. It is only a recommendation: the caller must obtain an
18
+ # explicit confirmation before installing or launching anything, because running the
19
+ # app has effects (network, credentials) the static scan never has.
20
+ #
21
+ # The configuration matters downstream: dynamic.sh --build-config <debug|release|unknown>
22
+ # is what decides whether a runtime observation may clear `needs build verification`.
23
+ # A Debug DerivedData build never does (evidence.sh).
24
+ #
25
+ # USAGE
26
+ # app-discover.sh [--repo DIR] [--derived-data DIR] [--framework rn|flutter|kmp|native] [--json]
27
+ # Exit 0 with candidates; 3 when none were found (the run then carries the
28
+ # runtime-not-audited gap record); 64 on a bad argument.
29
+
30
+ set -u
31
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
32
+ # shellcheck source=framework-detect.sh
33
+ . "$HERE/framework-detect.sh"
34
+ # shellcheck source=lib/dyn-bundle.sh
35
+ . "$HERE/lib/dyn-bundle.sh"
36
+
37
+ REPO="." DD="${HOME}/Library/Developer/Xcode/DerivedData" FRAMEWORK="" JSON=0
38
+ usage_err() { echo "app-discover.sh: $1" >&2; exit 64; }
39
+ while [[ $# -gt 0 ]]; do
40
+ case "$1" in
41
+ --repo) [[ $# -ge 2 ]] || usage_err "--repo needs a path"; REPO="$2"; shift 2 ;;
42
+ --derived-data) [[ $# -ge 2 ]] || usage_err "--derived-data needs a path"; DD="$2"; shift 2 ;;
43
+ --framework) [[ $# -ge 2 ]] || usage_err "--framework needs a value"; FRAMEWORK="$2"; shift 2 ;;
44
+ --json) JSON=1; shift ;;
45
+ *) usage_err "unknown option '$1'" ;;
46
+ esac
47
+ done
48
+ [[ -d "$REPO" ]] || usage_err "--repo is not a directory: $REPO"
49
+ case "$FRAMEWORK" in ""|rn|flutter|kmp|native) ;; *) usage_err "--framework must be rn|flutter|kmp|native" ;; esac
50
+ [[ -n "$FRAMEWORK" ]] || FRAMEWORK="$(detect_framework "$REPO")"
51
+
52
+ # --- Portable helpers (macOS + Linux) ----------------------------------------------
53
+ mtime_epoch() { stat -f %m "$1" 2>/dev/null || stat -c %Y "$1" 2>/dev/null || echo 0; }
54
+ epoch_iso() { date -u -r "$1" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d "@$1" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo ""; }
55
+
56
+ # plist_string <plist> <key> -> the string value, or "" (lib/dyn-bundle.sh: plutil on
57
+ # macOS for the binary plists of a real .app, a tag-per-line XML fallback elsewhere).
58
+ plist_string() { dyn_plist_string "$1" "$2"; }
59
+
60
+ # config_from_dir <app-path> -> debug | release | unknown, from the parent directory name only.
61
+ config_from_dir() {
62
+ case "$(basename "$(dirname "$1")")" in
63
+ Debug-iphonesimulator) echo debug ;;
64
+ Release-iphonesimulator) echo release ;;
65
+ *) echo unknown ;;
66
+ esac
67
+ }
68
+
69
+ # --- Collect candidates --------------------------------------------------------------
70
+ # One line per candidate: epoch<TAB>path. Globs that match nothing expand to nothing
71
+ # (checked with -d). Shell globs, no find -newer tricks: the order is decided by sort.
72
+ CANDS="$(mktemp)"; trap 'rm -f "$CANDS"' EXIT
73
+ add_candidate() {
74
+ local app="$1"
75
+ [[ -d "$app" && -f "$app/Info.plist" ]] || return 0
76
+ printf '%s\t%s\n' "$(mtime_epoch "$app")" "$app" >> "$CANDS"
77
+ }
78
+ for app in "$DD"/*/Build/Products/*-iphonesimulator/*.app; do add_candidate "$app"; done
79
+ for app in "$REPO"/build/ios/iphonesimulator/*.app; do add_candidate "$app"; done
80
+ for app in "$REPO"/ios/build/Build/Products/*-iphonesimulator/*.app; do add_candidate "$app"; done
81
+
82
+ # --- Build hint: the command WE WILL NOT RUN, for the user to paste ----------------
83
+ build_hint() {
84
+ case "$1" in
85
+ flutter) printf '%s' "flutter build ios --simulator # then re-run discovery; the .app lands in build/ios/iphonesimulator/" ;;
86
+ rn) printf '%s' "npx react-native run-ios --simulator \"iPhone 17\" # bare RN; managed Expo projects first need: npx expo prebuild -p ios. A Debug build also needs Metro running (port 8081) at launch, or supply a release bundle" ;;
87
+ kmp) printf '%s' "xcodebuild -sdk iphonesimulator -project iosApp/iosApp.xcodeproj -scheme iosApp -configuration Debug -derivedDataPath /tmp/precheck-dd build # the KMP iosApp Xcode project" ;;
88
+ *) printf '%s' "xcodebuild -sdk iphonesimulator -scheme <YourScheme> -configuration Debug -derivedDataPath /tmp/precheck-dd build # then pass --derived-data /tmp/precheck-dd" ;;
89
+ esac
90
+ }
91
+
92
+ # --- Render ---------------------------------------------------------------------------
93
+ CONFIRM="Recommendation only: obtain the user's explicit confirmation of ONE candidate before installing or launching anything (running the app has network and credential effects the static scan never has)."
94
+ n="$(grep -c . "$CANDS" 2>/dev/null)"; n="${n:-0}"
95
+
96
+ emit_json() {
97
+ local hint; hint="$(build_hint "$FRAMEWORK")"
98
+ if [[ "$n" -eq 0 ]]; then
99
+ jq -n --arg fw "$FRAMEWORK" --arg hint "$hint" --arg c "$CONFIRM" \
100
+ '{framework:$fw, candidates:[], recommended:null, launched:false, confirm:$c,
101
+ gap:"runtime-not-audited", build_hint:$hint}'
102
+ return
103
+ fi
104
+ sort -t "$(printf '\t')" -k1,1nr "$CANDS" | while IFS="$(printf '\t')" read -r ep path; do
105
+ jq -n --arg p "$path" --arg name "$(basename "$path" .app)" \
106
+ --arg bid "$(plist_string "$path/Info.plist" CFBundleIdentifier)" \
107
+ --arg cfg "$(config_from_dir "$path")" --argjson ep "$ep" --arg iso "$(epoch_iso "$ep")" \
108
+ --arg exe "$(plist_string "$path/Info.plist" CFBundleExecutable)" \
109
+ '{path:$p, name:$name, bundle_id:(if $bid=="" then null else $bid end), executable:(if $exe=="" then null else $exe end),
110
+ build_config:$cfg, mtime_epoch:$ep, mtime_iso:$iso}'
111
+ done | jq -s --arg fw "$FRAMEWORK" --arg hint "$hint" --arg c "$CONFIRM" \
112
+ '{framework:$fw, candidates:., recommended:.[0], launched:false, confirm:$c, build_hint:$hint}'
113
+ }
114
+
115
+ emit_text() {
116
+ if [[ "$n" -eq 0 ]]; then
117
+ echo "app-discover: no simulator .app found under $DD or $REPO/build/ios/iphonesimulator (framework: $FRAMEWORK)."
118
+ echo "The dynamic tier cannot run; the report will carry the runtime-not-audited gap record."
119
+ echo "To close it, build a simulator app yourself and re-run discovery. This tool will not run the build for you:"
120
+ echo " $(build_hint "$FRAMEWORK")"
121
+ return
122
+ fi
123
+ echo "app-discover: $n simulator .app candidate(s), newest first (framework: $FRAMEWORK)"
124
+ local i=0
125
+ sort -t "$(printf '\t')" -k1,1nr "$CANDS" | while IFS="$(printf '\t')" read -r ep path; do
126
+ i=$((i + 1))
127
+ local tag=""; [[ $i -eq 1 ]] && tag=" <- Recommended (newest)"
128
+ printf ' %d. %s\n bundle id: %s config: %s built: %s%s\n' \
129
+ "$i" "$path" "$(plist_string "$path/Info.plist" CFBundleIdentifier)" \
130
+ "$(config_from_dir "$path")" "$(epoch_iso "$ep")" "$tag"
131
+ done
132
+ echo "$CONFIRM"
133
+ echo "Pass the chosen path to dynamic-run.sh --app, and its config to dynamic.sh --build-config (a debug build never clears 'needs build verification')."
134
+ }
135
+
136
+ if (( JSON )); then emit_json; else emit_text; fi
137
+ [[ "$n" -eq 0 ]] && exit 3
138
+ exit 0
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # Inspect an existing iOS app bundle without installing or executing it.
3
+ # Python 3.8+ stdlib; optional Apple command-line tools are detected per check.
4
+ set -eu
5
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ if ! command -v python3 >/dev/null 2>&1; then
7
+ echo 'artifact-review: Python 3.8+ is required for plist/archive inspection' >&2
8
+ exit 69
9
+ fi
10
+ exec python3 "$HERE/lib/artifact-review.py" "$@"
@@ -0,0 +1,29 @@
1
+ """Add only opt-in tier/run summaries; full check details remain in --out."""
2
+ import argparse
3
+ import collections
4
+ import json
5
+ from pathlib import Path
6
+ import sys
7
+
8
+
9
+ def augment(envelope, summary):
10
+ result = dict(envelope)
11
+ checks = json.loads(Path(summary['run_results']).read_text()).get('checks', {})
12
+ counts = dict(collections.Counter(row.get('status', 'SKIP') for row in checks.values()))
13
+ result['optional_review'] = {key: summary[key] for key in ('tiers', 'output_dir', 'run_results', 'input_errors')}
14
+ result['coverage_run'] = {'check_status_counts': counts, 'scope': 'Only explicitly executed optional tiers; section inventory is separate.'}
15
+ return result
16
+
17
+
18
+ def main():
19
+ parser = argparse.ArgumentParser(description=__doc__)
20
+ parser.add_argument('--opt-summary', required=True, type=Path)
21
+ args = parser.parse_args()
22
+ envelope = json.load(sys.stdin)
23
+ if not isinstance(envelope, dict):
24
+ parser.error('scan envelope must be an object')
25
+ print(json.dumps(augment(envelope, json.loads(args.opt_summary.read_text()))))
26
+
27
+
28
+ if __name__ == '__main__':
29
+ main()
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ # Explicit opt-in build helper. Never invoked by the dynamic runner.
3
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4
+ command -v python3 >/dev/null 2>&1 || { echo 'SKIP: build-run — Python 3 required'; exit 3; }
5
+ exec python3 -B "$HERE/lib/build-run.py" "$@"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ # Maintainer inventory; never a claim of full guideline verification.
3
+ set -euo pipefail
4
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ command -v python3 >/dev/null 2>&1 || { echo 'coverage-sections: Python 3.8+ required' >&2; exit 69; }
6
+ exec python3 -B "$HERE/lib/coverage-sections.py" "$@"