csync-local 0.1.0__py3-none-any.whl

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 (98) hide show
  1. csync_local-0.1.0.dist-info/METADATA +251 -0
  2. csync_local-0.1.0.dist-info/RECORD +98 -0
  3. csync_local-0.1.0.dist-info/WHEEL +5 -0
  4. csync_local-0.1.0.dist-info/entry_points.txt +2 -0
  5. csync_local-0.1.0.dist-info/licenses/LICENSE +21 -0
  6. csync_local-0.1.0.dist-info/top_level.txt +1 -0
  7. localcsync/__init__.py +3 -0
  8. localcsync/__main__.py +6 -0
  9. localcsync/_vendor/VENDORED_FROM +1 -0
  10. localcsync/_vendor/__init__.py +1 -0
  11. localcsync/_vendor/csync/backend/app/__init__.py +2 -0
  12. localcsync/_vendor/csync/backend/app/log_redaction.py +66 -0
  13. localcsync/_vendor/csync/backend/app/runtime_assets/__init__.py +1 -0
  14. localcsync/_vendor/csync/backend/app/runtime_assets/contract.py +168 -0
  15. localcsync/_vendor/csync/backend/app/sentry.py +415 -0
  16. localcsync/_vendor/csync/backend/app/validation/__init__.py +0 -0
  17. localcsync/_vendor/csync/backend/app/validation/codebuild_entry.py +96 -0
  18. localcsync/_vendor/csync/backend/app/validation/codebuild_run.py +291 -0
  19. localcsync/_vendor/csync/backend/app/validation/config_yaml_check/__init__.py +14 -0
  20. localcsync/_vendor/csync/backend/app/validation/config_yaml_check/checker.py +170 -0
  21. localcsync/_vendor/csync/backend/app/validation/config_yaml_check/gather.py +72 -0
  22. localcsync/_vendor/csync/backend/app/validation/config_yaml_check/prompt.py +121 -0
  23. localcsync/_vendor/csync/backend/app/validation/config_yaml_check/rules.py +823 -0
  24. localcsync/_vendor/csync/backend/app/validation/datetime_utc/__init__.py +0 -0
  25. localcsync/_vendor/csync/backend/app/validation/datetime_utc/checker.py +145 -0
  26. localcsync/_vendor/csync/backend/app/validation/datetime_utc/gather.py +541 -0
  27. localcsync/_vendor/csync/backend/app/validation/docker_manager.py +726 -0
  28. localcsync/_vendor/csync/backend/app/validation/engine.py +2787 -0
  29. localcsync/_vendor/csync/backend/app/validation/env_validator/__init__.py +0 -0
  30. localcsync/_vendor/csync/backend/app/validation/env_validator/batch_validators.py +238 -0
  31. localcsync/_vendor/csync/backend/app/validation/env_validator/models.py +64 -0
  32. localcsync/_vendor/csync/backend/app/validation/env_validator/utils/__init__.py +0 -0
  33. localcsync/_vendor/csync/backend/app/validation/env_validator/utils/async_http.py +233 -0
  34. localcsync/_vendor/csync/backend/app/validation/env_validator/utils/docker_utils.py +334 -0
  35. localcsync/_vendor/csync/backend/app/validation/env_validator/utils/http_utils.py +338 -0
  36. localcsync/_vendor/csync/backend/app/validation/env_validator/utils/port_utils.py +113 -0
  37. localcsync/_vendor/csync/backend/app/validation/env_validator/validators.py +661 -0
  38. localcsync/_vendor/csync/backend/app/validation/eval_awareness/__init__.py +0 -0
  39. localcsync/_vendor/csync/backend/app/validation/eval_awareness/checker.py +565 -0
  40. localcsync/_vendor/csync/backend/app/validation/external_network.py +1691 -0
  41. localcsync/_vendor/csync/backend/app/validation/feature_coverage/__init__.py +0 -0
  42. localcsync/_vendor/csync/backend/app/validation/feature_coverage/checker.py +97 -0
  43. localcsync/_vendor/csync/backend/app/validation/feature_coverage/gather.py +385 -0
  44. localcsync/_vendor/csync/backend/app/validation/file_scope.py +293 -0
  45. localcsync/_vendor/csync/backend/app/validation/fingerprint.py +265 -0
  46. localcsync/_vendor/csync/backend/app/validation/github_reporter.py +493 -0
  47. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/__init__.py +0 -0
  48. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/checker.py +275 -0
  49. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/fetch.py +491 -0
  50. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/keys.py +106 -0
  51. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/manifest.py +164 -0
  52. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/models.py +50 -0
  53. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/reference.py +115 -0
  54. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/scanner.py +169 -0
  55. localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/search_provider.py +200 -0
  56. localcsync/_vendor/csync/backend/app/validation/live_log.py +135 -0
  57. localcsync/_vendor/csync/backend/app/validation/mcp_parity/__init__.py +9 -0
  58. localcsync/_vendor/csync/backend/app/validation/mcp_parity/detect.py +164 -0
  59. localcsync/_vendor/csync/backend/app/validation/mcp_parity/prompt.py +161 -0
  60. localcsync/_vendor/csync/backend/app/validation/mcp_parity/runner.py +115 -0
  61. localcsync/_vendor/csync/backend/app/validation/multi_rl/__init__.py +35 -0
  62. localcsync/_vendor/csync/backend/app/validation/multi_rl/app_contract.py +378 -0
  63. localcsync/_vendor/csync/backend/app/validation/multi_rl/ci_image.py +542 -0
  64. localcsync/_vendor/csync/backend/app/validation/multi_rl/em_dash.py +225 -0
  65. localcsync/_vendor/csync/backend/app/validation/multi_rl/findings.py +157 -0
  66. localcsync/_vendor/csync/backend/app/validation/multi_rl/image_checks.py +876 -0
  67. localcsync/_vendor/csync/backend/app/validation/multi_rl/pins.py +357 -0
  68. localcsync/_vendor/csync/backend/app/validation/multi_rl/profile_config.py +328 -0
  69. localcsync/_vendor/csync/backend/app/validation/multi_rl/runner.py +356 -0
  70. localcsync/_vendor/csync/backend/app/validation/multi_rl/secrets.py +241 -0
  71. localcsync/_vendor/csync/backend/app/validation/multi_rl/seed_cache.py +112 -0
  72. localcsync/_vendor/csync/backend/app/validation/multi_rl/suite_rules.py +424 -0
  73. localcsync/_vendor/csync/backend/app/validation/naming_audit/__init__.py +6 -0
  74. localcsync/_vendor/csync/backend/app/validation/naming_audit/candidates.py +159 -0
  75. localcsync/_vendor/csync/backend/app/validation/naming_audit/detectors.py +166 -0
  76. localcsync/_vendor/csync/backend/app/validation/naming_audit/prompt.py +181 -0
  77. localcsync/_vendor/csync/backend/app/validation/naming_audit/providers.py +137 -0
  78. localcsync/_vendor/csync/backend/app/validation/naming_audit/runner.py +206 -0
  79. localcsync/_vendor/csync/backend/app/validation/recovery.py +680 -0
  80. localcsync/_vendor/csync/backend/app/validation/registry.py +615 -0
  81. localcsync/_vendor/csync/backend/app/validation/restricted_terms/__init__.py +0 -0
  82. localcsync/_vendor/csync/backend/app/validation/restricted_terms/checker.py +321 -0
  83. localcsync/_vendor/csync/backend/app/validation/runtime_assets.py +121 -0
  84. localcsync/_vendor/csync/backend/app/validation/seed_paths.py +7 -0
  85. localcsync/_vendor/csync/backend/app/validation/single_rl_checks.py +326 -0
  86. localcsync/_vendor/csync/backend/app/validation/worker.py +210 -0
  87. localcsync/_vendor/csync/backend/tools/feature-mapping/action-facts.mjs +142 -0
  88. localcsync/_vendor/csync/backend/tools/feature-mapping/census.mjs +53 -0
  89. localcsync/_vendor/csync/backend/tools/feature-mapping/chain-facts.mjs +286 -0
  90. localcsync/_vendor/csync/backend/tools/feature-mapping/extract.mjs +806 -0
  91. localcsync/_vendor/csync/backend/tools/feature-mapping/keyboard-chords.mjs +211 -0
  92. localcsync/_vendor/csync/backend/tools/feature-mapping/package-lock.json +132 -0
  93. localcsync/_vendor/csync/backend/tools/feature-mapping/package.json +13 -0
  94. localcsync/cli.py +749 -0
  95. localcsync/docker_mode.py +351 -0
  96. localcsync/llm.py +138 -0
  97. localcsync/runtime.py +68 -0
  98. localcsync/verdicts.py +115 -0
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: csync-local
3
+ Version: 0.1.0
4
+ Summary: Run CSync validation checks locally before opening a pull request
5
+ Maintainer: thrishaldoma
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/thrishaldoma/csync-local
8
+ Project-URL: Issues, https://github.com/thrishaldoma/csync-local/issues
9
+ Classifier: Environment :: Console
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Software Development :: Quality Assurance
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: PyYAML>=6.0
16
+ Requires-Dist: jsonschema>=4.18
17
+ Requires-Dist: ijson>=3.2
18
+ Dynamic: license-file
19
+
20
+ # csync-local
21
+
22
+ Licensed under the [MIT License](LICENSE).
23
+
24
+ Run CSync's validation checks on your own machine **before** you open a PR, instead of
25
+ waiting for Foundry. It runs bundled CSync check code to catch issues early; see
26
+ "Where it can still differ from CSync" below for the limits of local results.
27
+
28
+ The workflow is: edit your local checkout, run `csync-local`, fix the findings, then
29
+ push and open a PR. CSync still runs its normal PR validation. This package supplies
30
+ an earlier local check using the bundled validator version.
31
+
32
+ ```bash
33
+ ./csync-local ~/rl_lseg # source checks + CSync data (seconds)
34
+ ./csync-local ~/rl_lseg --llm # + the 3 LLM checks, answered by Claude Code
35
+ ./csync-local ~/rl_lseg --docker # + build and start the app, run the 11 app checks
36
+ ./csync-local ~/rl_lseg --docker --llm # everything
37
+ ```
38
+
39
+ Exit code is `1` if any check fails, so it can run in a git pre-push hook.
40
+
41
+ ---
42
+
43
+ ## Install with pip
44
+
45
+ Requires **Python 3.12+** and **git**. From this project directory:
46
+
47
+ ```bash
48
+ python3 -m venv .venv
49
+ source .venv/bin/activate
50
+ python -m pip install .
51
+ csync-local --help
52
+ csync-local /path/to/your-rl-repo
53
+ ```
54
+
55
+ The installed command works from any directory. Python dependencies and the vendored
56
+ CSync validators are included automatically; `uv` is not required. You can also run
57
+ `python -m localcsync` or use `pip install -e .` for development.
58
+
59
+ The keyboard-shortcut scanner additionally needs **Node.js 20+ and npm**. Set it up once:
60
+
61
+ ```bash
62
+ csync-local --setup-scanner
63
+ ```
64
+
65
+ This downloads the scanner's locked Node dependencies to a user cache, without
66
+ modifying the Python installation. The cache defaults to
67
+ `$XDG_CACHE_HOME/csync-local` or `~/.cache/csync-local`; set `CSYNC_LOCAL_CACHE_DIR`
68
+ to override it. A change to the bundled scanner selects a new cache, so rerun setup
69
+ after upgrading. Without setup, checks that need the scanner report a warning.
70
+ An existing `QC_FEATURE_MAPPING_TOOL_DIR` override takes precedence over the cache.
71
+
72
+ **Docker** is still needed for `--docker`, and **Claude Code** for `--llm`.
73
+
74
+ To build a wheel and source distribution for sharing:
75
+
76
+ ```bash
77
+ python -m pip install build
78
+ python -m build
79
+ # On the receiving machine:
80
+ python -m pip install dist/csync_local-0.1.0-py3-none-any.whl
81
+ ```
82
+
83
+ The package is installable locally or from its wheel; it has not been published to PyPI.
84
+
85
+ To verify a release, install its wheel into a fresh virtual environment, run
86
+ `csync-local --setup-scanner`, then run `python tests/test_installed_package.py -v`
87
+ with that environment's Python. The tests exercise the installed command from outside
88
+ the checkout, including real source findings and the bundled keyboard parser.
89
+
90
+ ## Run directly from a checkout
91
+
92
+ You need **git**, **uv** (`brew install uv`) and **node** (`brew install node`).
93
+ For `--docker`: **Docker Desktop**. For `--llm`: **Claude Code** (`claude`).
94
+
95
+ ```bash
96
+ unzip local-csync.zip && cd local-csync
97
+ ./setup.sh
98
+ ```
99
+
100
+ **CSync API key (recommended).** Three checks need data that lives in CSync: the
101
+ restricted-terms list, whether your runtime assets are published, and the
102
+ eval-awareness wording. Create a key while signed in to Foundry: open the browser
103
+ console (Cmd+Option+J) and run
104
+
105
+ ```js
106
+ fetch("https://api.foundry.peaktalent.ai/api/auth/api-keys", {method: "POST", credentials: "include",
107
+ headers: {"Content-Type": "application/json"}, body: JSON.stringify({name: "csync-local", expires_in_days: 90})})
108
+ .then(r => r.json()).then(r => console.log(r.key)) // shown once: copy it
109
+ ```
110
+
111
+ then add it to your shell profile (never to a repo, never in chat):
112
+
113
+ ```bash
114
+ echo 'export CSYNC_API_KEY=<the key>' >> ~/.zshrc && source ~/.zshrc
115
+ ```
116
+
117
+ ---
118
+
119
+ ## What it checks
120
+
121
+ CSync reports 34 rows for a typical repo. They need different things:
122
+
123
+ The package includes all 34 check implementations listed below, plus per-server MCP
124
+ checks. Installing it does not supply Docker, Claude Code, Node.js, or access to CSync.
125
+ To enable the full suite, set up the scanner, configure `CSYNC_API_KEY`, and run
126
+ `csync-local /path/to/repo --docker --llm`. Missing prerequisites and inapplicable checks
127
+ can still produce warnings or skips. A zero exit code means no check reported a failure;
128
+ it does not mean all 34 checks ran and passed.
129
+
130
+ | Group | Rows | Needs | Here |
131
+ |---|---|---|---|
132
+ | **Source files** | `readme_auth_keys`, `config_yaml_check`, `datetime_utc`, `feature_coverage`, `keyboard_shortcuts`, `app_config_current_date`, 8 × `external_network_*`, `localhost_references`, `localstorage_usage`, `external_websocket_urls`, `browser_dialogs_debugger` (18) | Node.js + scanner setup for keyboard shortcuts | always |
133
+ | **CSync data** | `runtime_assets`, `restricted_terms` (2) | `CSYNC_API_KEY` | always |
134
+ | **LLM** | `hardcoded_names`, `mcp_user_parity`, `config_yaml_advisory` (3) | Claude Code | `--llm` |
135
+ | **Built image** | `dockerfile_build_run`, `app_config_baked` (2) | Docker | `--docker` |
136
+ | **Running app** | `health_check`, `eval_awareness`, `state_endpoint`, `state_endpoint_v2`, `state_streaming`, `state_restore`, `sql_endpoint`, `schema_endpoint`, `dbchangelog` (9) | Docker; CSync API key for eval-awareness | `--docker` |
137
+
138
+ `mcp_user_parity` usually needs no LLM: when the MCP code does not work out the
139
+ logged-in user itself, it passes without asking a model (as on CSync).
140
+
141
+ ---
142
+
143
+ ## Why it is faster than Foundry
144
+
145
+ - **No queue, no fresh clone.** It reads your checkout directly.
146
+ - **One build, cached.** CSync builds the image twice and throws both away. Here the image
147
+ is tagged by a fingerprint of what CSync would build: run again with nothing changed and
148
+ it is reused; change some code and Docker rebuilds only the layers that change.
149
+ - **Everything at once.** Source checks, the LLM checks and the image build run side by
150
+ side; the LLM batches go to Claude Code 4 at a time (CSync sends them one by one).
151
+ - **`--keep`** leaves the app running between runs, so fixing and re-checking the app is quick.
152
+
153
+ Measured on `rl_lseg` (Apple Silicon): see "Timings" at the end.
154
+
155
+ ---
156
+
157
+ ## Options
158
+
159
+ | Option | What it does |
160
+ |---|---|
161
+ | `--llm` | Run the 3 LLM checks with Claude Code |
162
+ | `--llm-model sonnet` | Model for `--llm` (default: your Claude Code default). Sonnet is much cheaper than Opus |
163
+ | `--llm-parallel N` | Claude Code calls at once (default 4) |
164
+ | `--docker` | Build + start the app and run the 11 checks that need it |
165
+ | `--keep` | With `--docker`: leave the app running (reused next time) |
166
+ | `--rebuild` | With `--docker`: build even if nothing changed |
167
+ | `--amd64` | With `--docker`: build for linux/amd64 like CSync's servers (slow on Apple chips) |
168
+ | `--clean` | Remove every container and image csync-local made |
169
+ | `--only a,b` | Run only these checks |
170
+ | `--branch X` | The branch CSync will validate (default: your current branch) |
171
+ | `--terms a,b` | Restricted terms to use instead of CSync's list |
172
+ | `--as-is` | Read the folder as it is, ignored files included (normally: only what git would push) |
173
+ | `-v` | Show every finding |
174
+
175
+ ---
176
+
177
+ ## Where it can still differ from CSync
178
+
179
+ It is honest about these in its output:
180
+
181
+ 1. **What it reads.** CSync checks a fresh clone. csync-local reads exactly what git would
182
+ push (tracked files + new, not-ignored files) plus the runtime assets your `app.config`
183
+ declares — not ignored folders like `reference/` or `.claude/`.
184
+ 2. **Your runtime assets vs the published ones.** `--docker` builds with your local
185
+ `data.db`; CSync builds with the published release. `runtime_assets` tells you which
186
+ release CSync will use.
187
+ 3. **Unpushed work.** CSync reads `app.config` and asset releases from GitHub/S3: push your
188
+ branch for `runtime_assets` to judge it.
189
+ 4. **LLM model.** CSync's LLM checks use `codex/gpt-5.5`; here Claude Code answers. Same
190
+ prompts and rules, but a different model can judge a borderline line differently.
191
+ Cost depends on the model: on large repos `hardcoded_names` is ~24 batches
192
+ (~360k input tokens) — use `--llm-model sonnet`.
193
+ 5. **`keyboard_shortcuts`** is checked against your code and `keyboards.json`, not CSync's
194
+ stored product reference ("documented but undeclared" shows up only on CSync).
195
+ 6. **Chip.** `--docker` builds for your Mac's chip; CSync builds linux/amd64 (`--amd64`).
196
+ 7. **New files must be `git add`ed** to be checked: untracked files never reach CSync, so
197
+ they are left out here too (edits to tracked files count without committing).
198
+
199
+ If your local dev server is running against `data.db`, it writes to it, so each
200
+ `--docker` run sees a changed database and rebuilds (about a minute, from cache).
201
+
202
+ ---
203
+
204
+ ## Keeping it up to date
205
+
206
+ `vendor/` is a copy of CSync's check code (see `vendor/VENDORED_FROM`). When CSync's checks
207
+ change, refresh it from a csync checkout:
208
+
209
+ ```bash
210
+ git -C ~/csync pull && scripts/sync-vendor.sh ~/csync
211
+ ```
212
+
213
+ `localcsync/verdicts.py` holds four small verdicts CSync writes inside its engine (which
214
+ cannot be imported without CSync's servers); after a sync, compare them with the engine
215
+ methods named at the top of that file.
216
+
217
+ ---
218
+
219
+ ## Troubleshooting
220
+
221
+ - **`keyboard_shortcuts` warns about `keyboard-chords.mjs` or `ts-morph`** → run `csync-local --setup-scanner` (or `./setup.sh` when using the checkout launcher).
222
+ - **`runtime_assets` says the branch is not on GitHub** → push it; until then it shows what
223
+ `main` has, which your branch will inherit.
224
+ - **`--docker` says a runtime asset is missing** → your checkout lacks a file `app.config`
225
+ declares (e.g. `backend/data/data.db`); get it the way you normally do for local runs.
226
+ - **Disk space** → `./csync-local --clean` removes this tool's containers and images.
227
+
228
+ ---
229
+
230
+ ## Timings
231
+
232
+ Measured on `rl_lseg` (3,462 tracked files, 863 MB `data.db`), Apple Silicon:
233
+
234
+ | What | Time |
235
+ |---|---|
236
+ | Source checks (no flags) | 15–26 s |
237
+ | `config_yaml_advisory` (3 votes, in parallel) | 16 s |
238
+ | `hardcoded_names`, small repo (2 calls, Sonnet) | 10 s |
239
+ | `--docker` image, first build | 109 s |
240
+ | `--docker` image, rebuild from Docker's cache | 52–60 s |
241
+ | `--docker` image, nothing changed | reused (0.4 s on a test repo) |
242
+ | App start → healthy | 20 s |
243
+ | State checks (`rl_lseg` exports a 966 MB state, read twice, posted back once) | ~150 s |
244
+ | **Full `--docker` run** | **234–257 s** |
245
+
246
+ For comparison, on CSync the same repo spent 196 s on `dockerfile_build_run` alone, and
247
+ 410 s on each LLM audit, before any queue time.
248
+
249
+ Cost of `--llm`: the advisory's 3 calls cost $2.07 on Opus (Claude Code's default here);
250
+ a large repo's `hardcoded_names` is ~24 batches (~360k input tokens), so prefer
251
+ `--llm-model sonnet` for routine runs.
@@ -0,0 +1,98 @@
1
+ csync_local-0.1.0.dist-info/licenses/LICENSE,sha256=hJA6rzg663f1UH6gou-zSJBzEBQOGSG5370rctec8qI,1069
2
+ localcsync/__init__.py,sha256=9TRjzI3Jl6FwT_XIMELZDlo-0Q6lKXL5enFvfRCHo3A,80
3
+ localcsync/__main__.py,sha256=4JMK66Wj4uLZTKbF-sT3LAxOsr6buig77PmOkJCRRxw,83
4
+ localcsync/cli.py,sha256=SH70FKo_X3bAipwuvdfeDRKc2HlGkL5ayZfDZ26b7TU,38505
5
+ localcsync/docker_mode.py,sha256=mUxH7IKZtaeCvA9vyHKxUJK6oejCaYYvzxiyU21jLu8,15998
6
+ localcsync/llm.py,sha256=40qNWnH3eEcIPjCu-yi5jqctuP2dZdIFXHeAugFZ1Iw,6066
7
+ localcsync/runtime.py,sha256=utbSfk75TcSbLt3fqyLuMcG2aHdbnxcPr8lbKt2q9Nw,2758
8
+ localcsync/verdicts.py,sha256=5If3jcAB-A5_hDAxUPtnTnzAAFB5zLTzdFojJ9xLzBA,6001
9
+ localcsync/_vendor/VENDORED_FROM,sha256=VihWxZ8nXDm13zc0SUYbbgaUS3DJO7UqkiSGeRiNkg4,65
10
+ localcsync/_vendor/__init__.py,sha256=ZLAm7KbYjIwBONW_jlAVMcgbvTVPMl0IIO-0Fa-kvFU,72
11
+ localcsync/_vendor/csync/backend/app/__init__.py,sha256=E4x2jU7s3zOg4ktwrro7Vqf91PBOE1kV6oNyxKku9X8,35
12
+ localcsync/_vendor/csync/backend/app/log_redaction.py,sha256=9yyR_p8PVr5zk6b95nesyrAFO-bbLIMV6EItIJLNlpM,3324
13
+ localcsync/_vendor/csync/backend/app/sentry.py,sha256=LxWu99PQcoI9PBjJ_T0h8msNWxtV4etIgbOq85OadiE,18159
14
+ localcsync/_vendor/csync/backend/app/runtime_assets/__init__.py,sha256=WBMTlrJr1zjZ48iCnxoQyZaxn6xgRaMFkeu8bl20xBk,55
15
+ localcsync/_vendor/csync/backend/app/runtime_assets/contract.py,sha256=f9El1i_Uv8F-UmuxcQKond3ovb9wXelTrKQ8E74uX9M,7276
16
+ localcsync/_vendor/csync/backend/app/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ localcsync/_vendor/csync/backend/app/validation/codebuild_entry.py,sha256=wCXEleA1qYDiktZX7B75GdiDpLDlT-ZUjh_vn5y7HFA,4040
18
+ localcsync/_vendor/csync/backend/app/validation/codebuild_run.py,sha256=7Z2Eo9K35MUJud2daI-nWqHyxe_mJ_JRsJcW9Hm1tbM,14133
19
+ localcsync/_vendor/csync/backend/app/validation/docker_manager.py,sha256=vy8RxdfkEXpILPerQqH3pdfsKTLdAzLMNN5av28hA2s,32953
20
+ localcsync/_vendor/csync/backend/app/validation/engine.py,sha256=j36WtM3cJpDQ6GlIk_VRLZjXSwwfvBaWVB-liX9BbyU,142595
21
+ localcsync/_vendor/csync/backend/app/validation/external_network.py,sha256=INsMp7LWK-q9cgtkCm-rVWL4MLljcS7CBMmKAsYaOBw,72762
22
+ localcsync/_vendor/csync/backend/app/validation/file_scope.py,sha256=OFj4K1xBhWNObROLDSb87XMwBKbi4O9Si6xi93OcAO4,14398
23
+ localcsync/_vendor/csync/backend/app/validation/fingerprint.py,sha256=Kzm07ZeJPElCdpeCVguKQbTt8fJj9NY9a1u0N4Q6s6Q,9081
24
+ localcsync/_vendor/csync/backend/app/validation/github_reporter.py,sha256=9t2aoTfs8ViAFIfTTNQzz-MFJF0QdRaIfwavrs05YRk,20975
25
+ localcsync/_vendor/csync/backend/app/validation/live_log.py,sha256=ymKASnIqyYGa-U7_y8sBXMXkSwYJWBHBZPNcfC9LFiE,4739
26
+ localcsync/_vendor/csync/backend/app/validation/recovery.py,sha256=pw_jGGrcsl3s9iCDpQYrcxadhC76T94Pzi9vqskX7vs,30960
27
+ localcsync/_vendor/csync/backend/app/validation/registry.py,sha256=LaHCR1geF8ZYb5mnkJVw572HQpDZ7I-pSRoOKSHmH78,29422
28
+ localcsync/_vendor/csync/backend/app/validation/runtime_assets.py,sha256=CcY_DudBggo8RAinPtMxD6ioKYEwmUIc5wisG5Phuug,5625
29
+ localcsync/_vendor/csync/backend/app/validation/seed_paths.py,sha256=Cnbkuk3UGCHNbntX0obotdVvyxsqBgBJjNlPQp42iQQ,163
30
+ localcsync/_vendor/csync/backend/app/validation/single_rl_checks.py,sha256=xEXX7LKUtcK_GxfxYnbh1ozFiR42-stFl6eC3cbcXAQ,14009
31
+ localcsync/_vendor/csync/backend/app/validation/worker.py,sha256=SdKBJNTrhEpMM8ry13U7WIjF6sFJTycV_-cj1UMY9GM,9931
32
+ localcsync/_vendor/csync/backend/app/validation/config_yaml_check/__init__.py,sha256=CeJ9tocmuLy7yJ5O-wcveKvRph5VnKioJMitDJQYcRg,817
33
+ localcsync/_vendor/csync/backend/app/validation/config_yaml_check/checker.py,sha256=9E4hLknVqxetzIJaBMV__BMKhoDuP3YI5KjpqV3qJKE,7731
34
+ localcsync/_vendor/csync/backend/app/validation/config_yaml_check/gather.py,sha256=-Y4bej5SsHNydwd6mTXWxNCbfzP2y0jcKxqvQ8ODnaY,2628
35
+ localcsync/_vendor/csync/backend/app/validation/config_yaml_check/prompt.py,sha256=ZCiTfporgFS8KT7FVye4fv77HsO9Lmfm0dUXo7fhkEM,6746
36
+ localcsync/_vendor/csync/backend/app/validation/config_yaml_check/rules.py,sha256=0zGnW-hIQPPONVPQZF61i19juUNwG_EbwNsmgmBHIp4,35916
37
+ localcsync/_vendor/csync/backend/app/validation/datetime_utc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ localcsync/_vendor/csync/backend/app/validation/datetime_utc/checker.py,sha256=vQzPJDSiThRnbCGjjvv4NFizoGSt79fF7EYswNuqAks,6038
39
+ localcsync/_vendor/csync/backend/app/validation/datetime_utc/gather.py,sha256=dLIY6fyYghdu9sv_MZWSjoq9Sa6-4cRkGmHyykKxZoA,23641
40
+ localcsync/_vendor/csync/backend/app/validation/env_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ localcsync/_vendor/csync/backend/app/validation/env_validator/batch_validators.py,sha256=Opxk3iKvCvT5u60B35G6xpJyGTd4W-g_o5cwpKJ5TrM,7717
42
+ localcsync/_vendor/csync/backend/app/validation/env_validator/models.py,sha256=9WXpkGvq-GEU7vfQfYm8Yjq9kP-ZY5dSun7BFI_UjEw,1667
43
+ localcsync/_vendor/csync/backend/app/validation/env_validator/validators.py,sha256=6h0NgAs9M4rCJGAVaekMmJ0ynbIo9mC8pReu8JHvydQ,27177
44
+ localcsync/_vendor/csync/backend/app/validation/env_validator/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ localcsync/_vendor/csync/backend/app/validation/env_validator/utils/async_http.py,sha256=knrm4sjCVhN7N1sMPKD1Vdy5TSWDOZ59vjNztih33ZM,7245
46
+ localcsync/_vendor/csync/backend/app/validation/env_validator/utils/docker_utils.py,sha256=2PpKDZ1Df-dVM3-nkdiuvn7x15s6rUyx_fTVXOy_Tq8,10455
47
+ localcsync/_vendor/csync/backend/app/validation/env_validator/utils/http_utils.py,sha256=7542yXEKF4PCLdSjmWNF4NKSsbuB4IJvRzLF-hEGtmQ,14234
48
+ localcsync/_vendor/csync/backend/app/validation/env_validator/utils/port_utils.py,sha256=cj6OOH5dLLlEGFGH0Jk6Zg9kxz1GKDI_VrxjrrAFIY8,3599
49
+ localcsync/_vendor/csync/backend/app/validation/eval_awareness/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
+ localcsync/_vendor/csync/backend/app/validation/eval_awareness/checker.py,sha256=48daJoHS0RWzEOBaBbjjmsAEP-de54FShMK_9Q5p-Os,25966
51
+ localcsync/_vendor/csync/backend/app/validation/feature_coverage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
+ localcsync/_vendor/csync/backend/app/validation/feature_coverage/checker.py,sha256=MyQoNgEgZ4B3f-pbFdwyKD1r-zzrUkxtaw6FbQMXrWw,3748
53
+ localcsync/_vendor/csync/backend/app/validation/feature_coverage/gather.py,sha256=uuZ5HhGQlaZYhZxcigCs4nZTdHwFjgjXbiU6PULqjD0,14572
54
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/checker.py,sha256=7nNwzn3y-T6Vekil7jIGTapEmEYRZ7BkfSf7NZdvVuM,14005
56
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/fetch.py,sha256=IN_iFdBZzRNqMefCaPju5b8NsCm-Bey4EJIrT3tlqGI,21314
57
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/keys.py,sha256=xGH60O-hcIh5fSMwRDBdYGaM08FIMG08r7C5XTRvl7k,4914
58
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/manifest.py,sha256=7umAbqsOjdV7JLOY747B39Be6LOH-p5bl0Q3vF12nOs,6114
59
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/models.py,sha256=9yeVTtZn-agefSHncAFcKWovpVik69hkDHT3SuSV_fY,2079
60
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/reference.py,sha256=I2jZphgSkJSxYYCpqbU9hRia4McVX-Kt75rhSe-sqyk,4278
61
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/scanner.py,sha256=7eZGVA2nW6ooOuap3Hv-6vggQqw3rL1ahntIU5mOP14,6727
62
+ localcsync/_vendor/csync/backend/app/validation/keyboard_shortcuts/search_provider.py,sha256=tlPyMiqG5_kYXsLatnw5vsRahuIDJnsPMxBVjkZre8E,8942
63
+ localcsync/_vendor/csync/backend/app/validation/mcp_parity/__init__.py,sha256=Mvvbi_0KYG6--QJXm0XoOAZcS4zmJfU4r2VkPRKQiJs,462
64
+ localcsync/_vendor/csync/backend/app/validation/mcp_parity/detect.py,sha256=_2B7wyYQ4K91gtn-eve-OuR_lmJYutey4tcFeGt7Sfg,6858
65
+ localcsync/_vendor/csync/backend/app/validation/mcp_parity/prompt.py,sha256=PkzEMxZ-PV483UAkti-iI9Vh-pBDuicuHWmCTgMqzqU,7531
66
+ localcsync/_vendor/csync/backend/app/validation/mcp_parity/runner.py,sha256=V5F739iC1Jq4NLCSBcn6I54NPsEZ_dOA9pGJAQslc5s,4469
67
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/__init__.py,sha256=i9JZuA5WLVtYv-ohs4HD4axcQgQqA1tokXAFdvOk7HQ,1379
68
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/app_contract.py,sha256=IqkuF1qSmSyN2QiIyWU0dToOK5_my5ZFse245rJRI9g,18708
69
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/ci_image.py,sha256=k_nmcdx7-rc8XSJra7NIwWOLuMPfSceTqjBVXAMvaF4,27244
70
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/em_dash.py,sha256=rTK3oUFss9GLmcf-W8AUZohjA8RwKIfMOFUWAcS0SaM,9312
71
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/findings.py,sha256=SfxygPy8DdCXlKVTywUCYT0iPqkJCH-OUxqjZHDZ-Q8,9428
72
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/image_checks.py,sha256=k07D18S8-tf7US7j_grvuB8uvyRz-DKPznyKC7KeLIw,44454
73
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/pins.py,sha256=u2DgX_nzdI2pRDPpTrxxYN_A7VZBq7ZInoUnIsckDAU,16851
74
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/profile_config.py,sha256=mKeK7WE2WxyRmPaeFad4TkB7sQfEqWsHByiGJxjyyt8,14172
75
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/runner.py,sha256=ChCjS-Zp9m-CqVaHynE6HZnTr7ZvxttuqE-ZIUwvZkY,16423
76
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/secrets.py,sha256=pagT022elYFjQVnkbarC2EfIVD6S-h4lL9vhtOxY1tY,10160
77
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/seed_cache.py,sha256=C7wlgqsOCqZBoczNJECFLd9IrP2O76HLEsqbnz60WeU,3948
78
+ localcsync/_vendor/csync/backend/app/validation/multi_rl/suite_rules.py,sha256=VUf2173JIe1_9QLkwsmpl7SY5uDkWMoIPrdm0G2QXCM,21423
79
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/__init__.py,sha256=8ajI147xojfgdsEoLl-ECs2tUM0LCeGeITZUC5J3Pe8,336
80
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/candidates.py,sha256=KfKWK2ODbTeIPNQzjcS1OPxkEg3zRrhvTuV8JflsNCQ,7503
81
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/detectors.py,sha256=U_csdybTUVzQvhsEtn7CMUCtHlgI_8pAljhJPTsCYUE,7220
82
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/prompt.py,sha256=K2ebz1cTAyhefgtPUrqLgPEqyMhgYrQhmQusxMtmDOg,8146
83
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/providers.py,sha256=l5EivEgRUZZ4CgG8a6xBXbXLgkbgHLFYAwC9kRS5qsE,5654
84
+ localcsync/_vendor/csync/backend/app/validation/naming_audit/runner.py,sha256=DNAtm_YjTOrlzdDkMJaxRdC0b28OMxy32QBzH9WQSSE,9106
85
+ localcsync/_vendor/csync/backend/app/validation/restricted_terms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
+ localcsync/_vendor/csync/backend/app/validation/restricted_terms/checker.py,sha256=rLpHagkJNK94CG3u1TpRUsG7jSnIqiIp6mT0AS7dqBY,15048
87
+ localcsync/_vendor/csync/backend/tools/feature-mapping/action-facts.mjs,sha256=PnB_YlDycnQXV176xJLX2oKSJv0Lbb-rjYO1GRpwSV8,8454
88
+ localcsync/_vendor/csync/backend/tools/feature-mapping/census.mjs,sha256=Tur0aAXXQDeYAKGAGQqogcebOSNKNxB_C1FWvT3jM-o,3448
89
+ localcsync/_vendor/csync/backend/tools/feature-mapping/chain-facts.mjs,sha256=bC1lfV2ynQu-c7-1AYpVUJiPHKhHI-_cTFoLFiF-eKQ,18096
90
+ localcsync/_vendor/csync/backend/tools/feature-mapping/extract.mjs,sha256=k-crcWXNTIg7kTSietJh9quc9XWuRtyMqhtQS6gUSkA,47841
91
+ localcsync/_vendor/csync/backend/tools/feature-mapping/keyboard-chords.mjs,sha256=EG0fC14YFjkrv_xBja7YiGBWhZKZzESq5hougLTPD44,8903
92
+ localcsync/_vendor/csync/backend/tools/feature-mapping/package-lock.json,sha256=tEK67s4K9CL7pS41sLWqKFbTkkJueORXlkYvln_cv1Y,4532
93
+ localcsync/_vendor/csync/backend/tools/feature-mapping/package.json,sha256=4zUmkI8LXJiiTPwYmU4b0ZgrzKnxgKeDyGYJXxGumo8,285
94
+ csync_local-0.1.0.dist-info/METADATA,sha256=QakwvXWmur_n12yPzBlXkrAYrgpVBIYM7CidEjVWG8s,11281
95
+ csync_local-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
96
+ csync_local-0.1.0.dist-info/entry_points.txt,sha256=oGBUtpBx8qPiwy8gtHzuu9jxAWAhzL1YTNerBdF37cI,52
97
+ csync_local-0.1.0.dist-info/top_level.txt,sha256=0cZCW9vKEvw-kGQXzH1brKw2eOJch80d63WVtFG7hiw,11
98
+ csync_local-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ csync-local = localcsync.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 thrishaldoma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ localcsync
localcsync/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """csync-local: CSync validation checks, run locally."""
2
+
3
+ __version__ = "0.1.0"
localcsync/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
@@ -0,0 +1 @@
1
+ csync main 6016eb545a64b43554c0e6ed5cef879593fd1cc4 (2026-11-13)
@@ -0,0 +1 @@
1
+ """Bundled CSync sources, installed privately as localcsync._vendor."""
@@ -0,0 +1,2 @@
1
+ # Marks backend app as a package.
2
+
@@ -0,0 +1,66 @@
1
+ """Take Foundry's own credentials back out of text on its way to a log.
2
+
3
+ Validation and sandbox launches both put a script's or a container's output in front of
4
+ a person: the run's log, its live stream, the worker's log, the failure message. Those
5
+ scripts run with credentials in their environment -- prepare.sh and build.sh need them
6
+ for the seed-database pull -- and a script run with `set -x`, or one that prints its
7
+ environment while failing, would carry them along.
8
+
9
+ Matched by value, not by shape: only what this process was given counts as a secret, so
10
+ nothing in an RL's own output is guessed at.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import os
15
+ import re
16
+
17
+ #: Environment variables whose values must never appear in a log a person can read.
18
+ #: CRED rather than CREDENTIAL, because the packed ones are named _CREDS --
19
+ #: ARTIFACTS_AWS_CREDS, PERSONA_SEED_AWS_CREDS, RL_DEPLOY_AWS_CREDS and
20
+ #: RL_ECR_PULL_CREDS each hold an AWS key and secret that nothing here matched.
21
+ SECRET_NAME = re.compile(r"KEY|TOKEN|SECRET|PASSWORD|CRED", re.IGNORECASE)
22
+
23
+ #: A packed credential is "<access_key_id>:<secret_access_key>:<region>" (config.py), so
24
+ #: the whole value is only found in output that prints it whole. Each part is taken as
25
+ #: well, from a length an AWS key id (20) or secret (40) clears and a region name
26
+ #: ("ap-southeast-1", 14) does not -- blanking a region would make a log harder to read
27
+ #: while protecting nothing.
28
+ PACKED_PART_CHARS = 16
29
+
30
+ #: The password in a connection URL -- postgresql://user:pw@host, redis://:pw@host.
31
+ #: DATABASE_URL and REDIS_URL are named after what they connect to, not after what they
32
+ #: carry, so no name pattern finds them. Only the password is taken: the rest of the URL
33
+ #: says which host a script could not reach, which is worth reading.
34
+ #: Greedy up to the last @ of the authority: a password may contain one (pw@more), and
35
+ #: stopping at the first would take "pw", drop it for being short, and leave the rest.
36
+ URL_PASSWORD = re.compile(r"://[^/\s:@?#]*:([^/\s?#]+)@")
37
+
38
+ #: Below this, a value is too short to be a credential and too likely to be a word that
39
+ #: appears in ordinary output (a one-character key would blank out most of a build log).
40
+ MIN_SECRET_CHARS = 8
41
+
42
+
43
+ def secret_values() -> list[str]:
44
+ # Read each time rather than cached: the environment is small, and a credential set
45
+ # after import would otherwise be missed. Longest first, so a value that contains
46
+ # another is replaced whole.
47
+ found: set[str] = set()
48
+ for name, value in os.environ.items():
49
+ if not value:
50
+ continue
51
+ if SECRET_NAME.search(name):
52
+ found.add(value)
53
+ found.update(part for part in value.split(":") if len(part) >= PACKED_PART_CHARS)
54
+ found.update(match.group(1) for match in URL_PASSWORD.finditer(value))
55
+ return sorted({value for value in found if len(value) >= MIN_SECRET_CHARS},
56
+ key=len, reverse=True)
57
+
58
+
59
+ def redact(text: str) -> str:
60
+ # NULs first: a credential printed with one inside it matches no value below, and
61
+ # whatever drops the NUL later (Postgres refuses them, a viewer hides them) would show
62
+ # it whole. Nothing a log reader needs is in a NUL.
63
+ text = text.replace("\x00", "")
64
+ for value in secret_values():
65
+ text = text.replace(value, "***")
66
+ return text
@@ -0,0 +1 @@
1
+ """Branch-scoped, immutable runtime asset releases."""
@@ -0,0 +1,168 @@
1
+ """The app.config runtime_assets contract. No repository-specific path rules."""
2
+ import re
3
+ from urllib.parse import quote
4
+
5
+
6
+ class AssetError(ValueError):
7
+ pass
8
+
9
+
10
+ GAMMA_BUCKET = 'gamma-rle-artifacts'
11
+
12
+
13
+ def is_gamma_bucket(bucket):
14
+ return bucket == GAMMA_BUCKET
15
+
16
+
17
+ def safe_path(value: str, *, directory=False) -> str:
18
+ if not isinstance(value, str) or not value or len(value) > 900:
19
+ raise AssetError('Asset paths must be nonempty strings of at most 900 characters')
20
+ path = value[:-1] if directory and value.endswith('/') else value
21
+ if (not path or path.startswith('/') or '\\' in path or ':' in path
22
+ or any(ord(c) < 32 for c in path) or any(p in ('', '.', '..') for p in path.split('/'))
23
+ or any(p.lower() == '.git' for p in path.split('/'))):
24
+ raise AssetError(f'Unsafe asset path: {value!r}')
25
+ return path + ('/' if directory else '')
26
+
27
+
28
+ def asset_contract(config: dict):
29
+ if not isinstance(config, dict):
30
+ raise AssetError('app.config must be a JSON object')
31
+ if 'runtime_assets' not in config:
32
+ return None # explicit legacy boundary
33
+ values = config['runtime_assets']
34
+ if not isinstance(values, list) or len(values) > 1000:
35
+ raise AssetError('runtime_assets must be a list of at most 1000 repo-relative paths')
36
+ result = []
37
+ for value in values:
38
+ directory = isinstance(value, str) and value.endswith('/')
39
+ path = safe_path(value, directory=directory)
40
+ if path.rstrip('/').casefold() in ('app.config', 'dockerfile', '.dockerignore', 'prepare.sh'):
41
+ raise AssetError(f'Asset cannot replace build configuration: {path}')
42
+ key = path.rstrip('/') + ('.zip' if directory else '')
43
+ for other in result:
44
+ a, b = path.rstrip('/').casefold(), other['path'].rstrip('/').casefold()
45
+ if a == b or a.startswith(b + '/') or b.startswith(a + '/') or key.casefold() == other['object_path'].casefold():
46
+ raise AssetError(f'Overlapping or duplicate runtime assets: {path} and {other["path"]}')
47
+ result.append({'path': path, 'kind': 'directory' if directory else 'file', 'object_path': key})
48
+ return result
49
+
50
+
51
+ def namespace(repository):
52
+ parts = [repository.repo_organization, repository.repo_name]
53
+ if any(not re.fullmatch(r'[A-Za-z0-9_.-]+', p or '') or p in ('.', '..') for p in parts):
54
+ raise AssetError('Invalid repository organization/name')
55
+ return 'srl/' + '/'.join(p.lower() for p in parts)
56
+
57
+
58
+ def branch_segment(branch):
59
+ if not isinstance(branch, str) or not branch or len(branch) > 250 or any(ord(c) < 32 for c in branch):
60
+ raise AssetError('Invalid branch')
61
+ if branch in ('.', '..'):
62
+ raise AssetError('Invalid branch')
63
+ # A slash-containing branch must never collide with a dashed branch.
64
+ return quote(branch, safe='-_.')
65
+
66
+
67
+ def prefix(repository, branch):
68
+ return f'{namespace(repository)}/{branch_segment(branch)}'
69
+
70
+
71
+ _RL_NAME = re.compile(r'[a-z][a-z0-9_-]{0,63}')
72
+ _RELEASE_NAME = re.compile(r'[A-Za-z0-9][A-Za-z0-9._-]{0,127}')
73
+
74
+
75
+ def gamma_layout(config: dict):
76
+ """Extract the gamma S3 key layout from app.config.
77
+
78
+ Returns ``(rl_name, release_name)`` when both are present and valid, else ``None``.
79
+ """
80
+ if not isinstance(config, dict):
81
+ return None
82
+ rl_name = config.get('rl_name')
83
+ release_name = config.get('release_name')
84
+ if not isinstance(rl_name, str) or not isinstance(release_name, str):
85
+ return None
86
+ if not _RL_NAME.fullmatch(rl_name):
87
+ raise AssetError(f'Invalid rl_name in app.config: {rl_name!r}')
88
+ if not _RELEASE_NAME.fullmatch(release_name):
89
+ raise AssetError(f'Invalid release_name in app.config: {release_name!r}')
90
+ if release_name == 'latest':
91
+ raise AssetError("release_name 'latest' is reserved")
92
+ return rl_name, release_name
93
+
94
+
95
+ class GammaLayout:
96
+ """S3 key builder for the gamma bucket: ``{rl_name}/{release_name}/{asset_path}``.
97
+
98
+ Replaces the Foundry layout (``srl/{org}/{repo}/{branch}/{version}/artifacts/{object_path}``)
99
+ when the bucket is ``gamma-rle-artifacts`` and app.config carries ``rl_name``
100
+ and ``release_name``.
101
+ """
102
+
103
+ def __init__(self, rl_name, release_name):
104
+ self.rl_name = rl_name
105
+ self.release_name = release_name
106
+
107
+ @property
108
+ def base(self):
109
+ """Branch-level prefix (the ``rl_name``). Equivalent to ``prefix(repo, branch)``."""
110
+ return self.rl_name
111
+
112
+ def version_prefix(self):
113
+ """Version-level prefix. Equivalent to ``{prefix}/{version}``."""
114
+ return f'{self.rl_name}/{self.release_name}'
115
+
116
+ def artifact_key(self, asset):
117
+ """Full key for an asset object: ``{rl_name}/{release_name}/{path}``."""
118
+ return f'{self.rl_name}/{self.release_name}/{asset["path"]}'
119
+
120
+ def manifest_key(self):
121
+ return f'{self.rl_name}/{self.release_name}/manifest.json'
122
+
123
+ def latest_key(self):
124
+ return f'{self.rl_name}/latest/manifest.json'
125
+
126
+
127
+ _BUCKET = re.compile(r'[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]')
128
+
129
+
130
+ def asset_bucket(config: dict):
131
+ """The S3 bucket app.config names for this branch's runtime assets, or None.
132
+
133
+ `runtime_assets_s3_path` is how an RL says its artifacts do not live in Foundry's
134
+ default bucket -- `"s3://gamma-rle-artifacts"` on the gamma branches. Absent means
135
+ the default, which is a decision the caller surfaces rather than one made here.
136
+
137
+ Only the bucket is configurable. The key layout underneath it is Foundry's
138
+ (`srl/<org>/<rl>/<branch>/...`), and a URL carrying a key prefix is rejected rather
139
+ than silently ignored -- being quietly written somewhere other than where it says
140
+ is the failure this field exists to prevent.
141
+ """
142
+ if not isinstance(config, dict):
143
+ raise AssetError('app.config must be a JSON object')
144
+ value = config.get('runtime_assets_s3_path')
145
+ if value is None or (isinstance(value, str) and not value.strip()):
146
+ return None
147
+ if not isinstance(value, str) or len(value) > 1024:
148
+ raise AssetError('runtime_assets_s3_path must be an s3:// URL')
149
+ rest = value.strip()
150
+ if not rest.lower().startswith('s3://'):
151
+ raise AssetError(f'runtime_assets_s3_path must start with s3:// : {value!r}')
152
+ name, _, key = rest[5:].partition('/')
153
+ if key.strip('/'):
154
+ raise AssetError(f'runtime_assets_s3_path must name a bucket with no key prefix: {value!r}')
155
+ if not _BUCKET.fullmatch(name) or '..' in name:
156
+ raise AssetError(f'Invalid S3 bucket in runtime_assets_s3_path: {value!r}')
157
+ # app.config is committed in the RL's own repository. Without this, whoever can commit
158
+ # there could point Foundry's artifact credentials at any bucket those keys reach, so
159
+ # the check lives here, in the one function every caller goes through, rather than in
160
+ # a wrapper one of them could be written without.
161
+ from ..config import get_settings
162
+ allowed = get_settings().runtime_assets_s3_buckets
163
+ if name not in allowed:
164
+ raise AssetError(
165
+ f'runtime_assets_s3_path names a bucket Foundry is not configured to use: {name}. '
166
+ 'Allowed: ' + ', '.join(sorted(allowed)) + '. Ask an admin to add it to '
167
+ 'RUNTIME_ASSETS_S3_BUCKETS if it is intended.')
168
+ return name