csync-local 0.1.0__tar.gz

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 (108) hide show
  1. csync_local-0.1.0/LICENSE +21 -0
  2. csync_local-0.1.0/MANIFEST.in +5 -0
  3. csync_local-0.1.0/PKG-INFO +251 -0
  4. csync_local-0.1.0/README.md +232 -0
  5. csync_local-0.1.0/csync-local +11 -0
  6. csync_local-0.1.0/csync_local.egg-info/PKG-INFO +251 -0
  7. csync_local-0.1.0/csync_local.egg-info/SOURCES.txt +106 -0
  8. csync_local-0.1.0/csync_local.egg-info/dependency_links.txt +1 -0
  9. csync_local-0.1.0/csync_local.egg-info/entry_points.txt +2 -0
  10. csync_local-0.1.0/csync_local.egg-info/requires.txt +3 -0
  11. csync_local-0.1.0/csync_local.egg-info/top_level.txt +1 -0
  12. csync_local-0.1.0/localcsync/__init__.py +3 -0
  13. csync_local-0.1.0/localcsync/__main__.py +6 -0
  14. csync_local-0.1.0/localcsync/cli.py +749 -0
  15. csync_local-0.1.0/localcsync/docker_mode.py +351 -0
  16. csync_local-0.1.0/localcsync/llm.py +138 -0
  17. csync_local-0.1.0/localcsync/runtime.py +68 -0
  18. csync_local-0.1.0/localcsync/verdicts.py +115 -0
  19. csync_local-0.1.0/pyproject.toml +42 -0
  20. csync_local-0.1.0/scripts/sync-vendor.sh +36 -0
  21. csync_local-0.1.0/setup.cfg +4 -0
  22. csync_local-0.1.0/setup.sh +36 -0
  23. csync_local-0.1.0/tests/test_installed_package.py +139 -0
  24. csync_local-0.1.0/vendor/VENDORED_FROM +1 -0
  25. csync_local-0.1.0/vendor/__init__.py +1 -0
  26. csync_local-0.1.0/vendor/csync/backend/app/__init__.py +2 -0
  27. csync_local-0.1.0/vendor/csync/backend/app/log_redaction.py +66 -0
  28. csync_local-0.1.0/vendor/csync/backend/app/runtime_assets/__init__.py +1 -0
  29. csync_local-0.1.0/vendor/csync/backend/app/runtime_assets/contract.py +168 -0
  30. csync_local-0.1.0/vendor/csync/backend/app/sentry.py +415 -0
  31. csync_local-0.1.0/vendor/csync/backend/app/validation/__init__.py +0 -0
  32. csync_local-0.1.0/vendor/csync/backend/app/validation/codebuild_entry.py +96 -0
  33. csync_local-0.1.0/vendor/csync/backend/app/validation/codebuild_run.py +291 -0
  34. csync_local-0.1.0/vendor/csync/backend/app/validation/config_yaml_check/__init__.py +14 -0
  35. csync_local-0.1.0/vendor/csync/backend/app/validation/config_yaml_check/checker.py +170 -0
  36. csync_local-0.1.0/vendor/csync/backend/app/validation/config_yaml_check/gather.py +72 -0
  37. csync_local-0.1.0/vendor/csync/backend/app/validation/config_yaml_check/prompt.py +121 -0
  38. csync_local-0.1.0/vendor/csync/backend/app/validation/config_yaml_check/rules.py +823 -0
  39. csync_local-0.1.0/vendor/csync/backend/app/validation/datetime_utc/__init__.py +0 -0
  40. csync_local-0.1.0/vendor/csync/backend/app/validation/datetime_utc/checker.py +145 -0
  41. csync_local-0.1.0/vendor/csync/backend/app/validation/datetime_utc/gather.py +541 -0
  42. csync_local-0.1.0/vendor/csync/backend/app/validation/docker_manager.py +726 -0
  43. csync_local-0.1.0/vendor/csync/backend/app/validation/engine.py +2787 -0
  44. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/__init__.py +0 -0
  45. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/batch_validators.py +238 -0
  46. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/models.py +64 -0
  47. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/utils/__init__.py +0 -0
  48. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/utils/async_http.py +233 -0
  49. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/utils/docker_utils.py +334 -0
  50. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/utils/http_utils.py +338 -0
  51. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/utils/port_utils.py +113 -0
  52. csync_local-0.1.0/vendor/csync/backend/app/validation/env_validator/validators.py +661 -0
  53. csync_local-0.1.0/vendor/csync/backend/app/validation/eval_awareness/__init__.py +0 -0
  54. csync_local-0.1.0/vendor/csync/backend/app/validation/eval_awareness/checker.py +565 -0
  55. csync_local-0.1.0/vendor/csync/backend/app/validation/external_network.py +1691 -0
  56. csync_local-0.1.0/vendor/csync/backend/app/validation/feature_coverage/__init__.py +0 -0
  57. csync_local-0.1.0/vendor/csync/backend/app/validation/feature_coverage/checker.py +97 -0
  58. csync_local-0.1.0/vendor/csync/backend/app/validation/feature_coverage/gather.py +385 -0
  59. csync_local-0.1.0/vendor/csync/backend/app/validation/file_scope.py +293 -0
  60. csync_local-0.1.0/vendor/csync/backend/app/validation/fingerprint.py +265 -0
  61. csync_local-0.1.0/vendor/csync/backend/app/validation/github_reporter.py +493 -0
  62. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/__init__.py +0 -0
  63. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/checker.py +275 -0
  64. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/fetch.py +491 -0
  65. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/keys.py +106 -0
  66. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/manifest.py +164 -0
  67. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/models.py +50 -0
  68. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/reference.py +115 -0
  69. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/scanner.py +169 -0
  70. csync_local-0.1.0/vendor/csync/backend/app/validation/keyboard_shortcuts/search_provider.py +200 -0
  71. csync_local-0.1.0/vendor/csync/backend/app/validation/live_log.py +135 -0
  72. csync_local-0.1.0/vendor/csync/backend/app/validation/mcp_parity/__init__.py +9 -0
  73. csync_local-0.1.0/vendor/csync/backend/app/validation/mcp_parity/detect.py +164 -0
  74. csync_local-0.1.0/vendor/csync/backend/app/validation/mcp_parity/prompt.py +161 -0
  75. csync_local-0.1.0/vendor/csync/backend/app/validation/mcp_parity/runner.py +115 -0
  76. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/__init__.py +35 -0
  77. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/app_contract.py +378 -0
  78. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/ci_image.py +542 -0
  79. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/em_dash.py +225 -0
  80. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/findings.py +157 -0
  81. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/image_checks.py +876 -0
  82. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/pins.py +357 -0
  83. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/profile_config.py +328 -0
  84. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/runner.py +356 -0
  85. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/secrets.py +241 -0
  86. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/seed_cache.py +112 -0
  87. csync_local-0.1.0/vendor/csync/backend/app/validation/multi_rl/suite_rules.py +424 -0
  88. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/__init__.py +6 -0
  89. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/candidates.py +159 -0
  90. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/detectors.py +166 -0
  91. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/prompt.py +181 -0
  92. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/providers.py +137 -0
  93. csync_local-0.1.0/vendor/csync/backend/app/validation/naming_audit/runner.py +206 -0
  94. csync_local-0.1.0/vendor/csync/backend/app/validation/recovery.py +680 -0
  95. csync_local-0.1.0/vendor/csync/backend/app/validation/registry.py +615 -0
  96. csync_local-0.1.0/vendor/csync/backend/app/validation/restricted_terms/__init__.py +0 -0
  97. csync_local-0.1.0/vendor/csync/backend/app/validation/restricted_terms/checker.py +321 -0
  98. csync_local-0.1.0/vendor/csync/backend/app/validation/runtime_assets.py +121 -0
  99. csync_local-0.1.0/vendor/csync/backend/app/validation/seed_paths.py +7 -0
  100. csync_local-0.1.0/vendor/csync/backend/app/validation/single_rl_checks.py +326 -0
  101. csync_local-0.1.0/vendor/csync/backend/app/validation/worker.py +210 -0
  102. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/action-facts.mjs +142 -0
  103. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/census.mjs +53 -0
  104. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/chain-facts.mjs +286 -0
  105. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/extract.mjs +806 -0
  106. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/keyboard-chords.mjs +211 -0
  107. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/package-lock.json +132 -0
  108. csync_local-0.1.0/vendor/csync/backend/tools/feature-mapping/package.json +13 -0
@@ -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,5 @@
1
+ include csync-local setup.sh
2
+ include scripts/sync-vendor.sh
3
+ recursive-include tests *.py
4
+ global-exclude __pycache__ *.py[cod] .DS_Store
5
+ prune vendor/csync/backend/tools/feature-mapping/node_modules
@@ -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,232 @@
1
+ # csync-local
2
+
3
+ Licensed under the [MIT License](LICENSE).
4
+
5
+ Run CSync's validation checks on your own machine **before** you open a PR, instead of
6
+ waiting for Foundry. It runs bundled CSync check code to catch issues early; see
7
+ "Where it can still differ from CSync" below for the limits of local results.
8
+
9
+ The workflow is: edit your local checkout, run `csync-local`, fix the findings, then
10
+ push and open a PR. CSync still runs its normal PR validation. This package supplies
11
+ an earlier local check using the bundled validator version.
12
+
13
+ ```bash
14
+ ./csync-local ~/rl_lseg # source checks + CSync data (seconds)
15
+ ./csync-local ~/rl_lseg --llm # + the 3 LLM checks, answered by Claude Code
16
+ ./csync-local ~/rl_lseg --docker # + build and start the app, run the 11 app checks
17
+ ./csync-local ~/rl_lseg --docker --llm # everything
18
+ ```
19
+
20
+ Exit code is `1` if any check fails, so it can run in a git pre-push hook.
21
+
22
+ ---
23
+
24
+ ## Install with pip
25
+
26
+ Requires **Python 3.12+** and **git**. From this project directory:
27
+
28
+ ```bash
29
+ python3 -m venv .venv
30
+ source .venv/bin/activate
31
+ python -m pip install .
32
+ csync-local --help
33
+ csync-local /path/to/your-rl-repo
34
+ ```
35
+
36
+ The installed command works from any directory. Python dependencies and the vendored
37
+ CSync validators are included automatically; `uv` is not required. You can also run
38
+ `python -m localcsync` or use `pip install -e .` for development.
39
+
40
+ The keyboard-shortcut scanner additionally needs **Node.js 20+ and npm**. Set it up once:
41
+
42
+ ```bash
43
+ csync-local --setup-scanner
44
+ ```
45
+
46
+ This downloads the scanner's locked Node dependencies to a user cache, without
47
+ modifying the Python installation. The cache defaults to
48
+ `$XDG_CACHE_HOME/csync-local` or `~/.cache/csync-local`; set `CSYNC_LOCAL_CACHE_DIR`
49
+ to override it. A change to the bundled scanner selects a new cache, so rerun setup
50
+ after upgrading. Without setup, checks that need the scanner report a warning.
51
+ An existing `QC_FEATURE_MAPPING_TOOL_DIR` override takes precedence over the cache.
52
+
53
+ **Docker** is still needed for `--docker`, and **Claude Code** for `--llm`.
54
+
55
+ To build a wheel and source distribution for sharing:
56
+
57
+ ```bash
58
+ python -m pip install build
59
+ python -m build
60
+ # On the receiving machine:
61
+ python -m pip install dist/csync_local-0.1.0-py3-none-any.whl
62
+ ```
63
+
64
+ The package is installable locally or from its wheel; it has not been published to PyPI.
65
+
66
+ To verify a release, install its wheel into a fresh virtual environment, run
67
+ `csync-local --setup-scanner`, then run `python tests/test_installed_package.py -v`
68
+ with that environment's Python. The tests exercise the installed command from outside
69
+ the checkout, including real source findings and the bundled keyboard parser.
70
+
71
+ ## Run directly from a checkout
72
+
73
+ You need **git**, **uv** (`brew install uv`) and **node** (`brew install node`).
74
+ For `--docker`: **Docker Desktop**. For `--llm`: **Claude Code** (`claude`).
75
+
76
+ ```bash
77
+ unzip local-csync.zip && cd local-csync
78
+ ./setup.sh
79
+ ```
80
+
81
+ **CSync API key (recommended).** Three checks need data that lives in CSync: the
82
+ restricted-terms list, whether your runtime assets are published, and the
83
+ eval-awareness wording. Create a key while signed in to Foundry: open the browser
84
+ console (Cmd+Option+J) and run
85
+
86
+ ```js
87
+ fetch("https://api.foundry.peaktalent.ai/api/auth/api-keys", {method: "POST", credentials: "include",
88
+ headers: {"Content-Type": "application/json"}, body: JSON.stringify({name: "csync-local", expires_in_days: 90})})
89
+ .then(r => r.json()).then(r => console.log(r.key)) // shown once: copy it
90
+ ```
91
+
92
+ then add it to your shell profile (never to a repo, never in chat):
93
+
94
+ ```bash
95
+ echo 'export CSYNC_API_KEY=<the key>' >> ~/.zshrc && source ~/.zshrc
96
+ ```
97
+
98
+ ---
99
+
100
+ ## What it checks
101
+
102
+ CSync reports 34 rows for a typical repo. They need different things:
103
+
104
+ The package includes all 34 check implementations listed below, plus per-server MCP
105
+ checks. Installing it does not supply Docker, Claude Code, Node.js, or access to CSync.
106
+ To enable the full suite, set up the scanner, configure `CSYNC_API_KEY`, and run
107
+ `csync-local /path/to/repo --docker --llm`. Missing prerequisites and inapplicable checks
108
+ can still produce warnings or skips. A zero exit code means no check reported a failure;
109
+ it does not mean all 34 checks ran and passed.
110
+
111
+ | Group | Rows | Needs | Here |
112
+ |---|---|---|---|
113
+ | **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 |
114
+ | **CSync data** | `runtime_assets`, `restricted_terms` (2) | `CSYNC_API_KEY` | always |
115
+ | **LLM** | `hardcoded_names`, `mcp_user_parity`, `config_yaml_advisory` (3) | Claude Code | `--llm` |
116
+ | **Built image** | `dockerfile_build_run`, `app_config_baked` (2) | Docker | `--docker` |
117
+ | **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` |
118
+
119
+ `mcp_user_parity` usually needs no LLM: when the MCP code does not work out the
120
+ logged-in user itself, it passes without asking a model (as on CSync).
121
+
122
+ ---
123
+
124
+ ## Why it is faster than Foundry
125
+
126
+ - **No queue, no fresh clone.** It reads your checkout directly.
127
+ - **One build, cached.** CSync builds the image twice and throws both away. Here the image
128
+ is tagged by a fingerprint of what CSync would build: run again with nothing changed and
129
+ it is reused; change some code and Docker rebuilds only the layers that change.
130
+ - **Everything at once.** Source checks, the LLM checks and the image build run side by
131
+ side; the LLM batches go to Claude Code 4 at a time (CSync sends them one by one).
132
+ - **`--keep`** leaves the app running between runs, so fixing and re-checking the app is quick.
133
+
134
+ Measured on `rl_lseg` (Apple Silicon): see "Timings" at the end.
135
+
136
+ ---
137
+
138
+ ## Options
139
+
140
+ | Option | What it does |
141
+ |---|---|
142
+ | `--llm` | Run the 3 LLM checks with Claude Code |
143
+ | `--llm-model sonnet` | Model for `--llm` (default: your Claude Code default). Sonnet is much cheaper than Opus |
144
+ | `--llm-parallel N` | Claude Code calls at once (default 4) |
145
+ | `--docker` | Build + start the app and run the 11 checks that need it |
146
+ | `--keep` | With `--docker`: leave the app running (reused next time) |
147
+ | `--rebuild` | With `--docker`: build even if nothing changed |
148
+ | `--amd64` | With `--docker`: build for linux/amd64 like CSync's servers (slow on Apple chips) |
149
+ | `--clean` | Remove every container and image csync-local made |
150
+ | `--only a,b` | Run only these checks |
151
+ | `--branch X` | The branch CSync will validate (default: your current branch) |
152
+ | `--terms a,b` | Restricted terms to use instead of CSync's list |
153
+ | `--as-is` | Read the folder as it is, ignored files included (normally: only what git would push) |
154
+ | `-v` | Show every finding |
155
+
156
+ ---
157
+
158
+ ## Where it can still differ from CSync
159
+
160
+ It is honest about these in its output:
161
+
162
+ 1. **What it reads.** CSync checks a fresh clone. csync-local reads exactly what git would
163
+ push (tracked files + new, not-ignored files) plus the runtime assets your `app.config`
164
+ declares — not ignored folders like `reference/` or `.claude/`.
165
+ 2. **Your runtime assets vs the published ones.** `--docker` builds with your local
166
+ `data.db`; CSync builds with the published release. `runtime_assets` tells you which
167
+ release CSync will use.
168
+ 3. **Unpushed work.** CSync reads `app.config` and asset releases from GitHub/S3: push your
169
+ branch for `runtime_assets` to judge it.
170
+ 4. **LLM model.** CSync's LLM checks use `codex/gpt-5.5`; here Claude Code answers. Same
171
+ prompts and rules, but a different model can judge a borderline line differently.
172
+ Cost depends on the model: on large repos `hardcoded_names` is ~24 batches
173
+ (~360k input tokens) — use `--llm-model sonnet`.
174
+ 5. **`keyboard_shortcuts`** is checked against your code and `keyboards.json`, not CSync's
175
+ stored product reference ("documented but undeclared" shows up only on CSync).
176
+ 6. **Chip.** `--docker` builds for your Mac's chip; CSync builds linux/amd64 (`--amd64`).
177
+ 7. **New files must be `git add`ed** to be checked: untracked files never reach CSync, so
178
+ they are left out here too (edits to tracked files count without committing).
179
+
180
+ If your local dev server is running against `data.db`, it writes to it, so each
181
+ `--docker` run sees a changed database and rebuilds (about a minute, from cache).
182
+
183
+ ---
184
+
185
+ ## Keeping it up to date
186
+
187
+ `vendor/` is a copy of CSync's check code (see `vendor/VENDORED_FROM`). When CSync's checks
188
+ change, refresh it from a csync checkout:
189
+
190
+ ```bash
191
+ git -C ~/csync pull && scripts/sync-vendor.sh ~/csync
192
+ ```
193
+
194
+ `localcsync/verdicts.py` holds four small verdicts CSync writes inside its engine (which
195
+ cannot be imported without CSync's servers); after a sync, compare them with the engine
196
+ methods named at the top of that file.
197
+
198
+ ---
199
+
200
+ ## Troubleshooting
201
+
202
+ - **`keyboard_shortcuts` warns about `keyboard-chords.mjs` or `ts-morph`** → run `csync-local --setup-scanner` (or `./setup.sh` when using the checkout launcher).
203
+ - **`runtime_assets` says the branch is not on GitHub** → push it; until then it shows what
204
+ `main` has, which your branch will inherit.
205
+ - **`--docker` says a runtime asset is missing** → your checkout lacks a file `app.config`
206
+ declares (e.g. `backend/data/data.db`); get it the way you normally do for local runs.
207
+ - **Disk space** → `./csync-local --clean` removes this tool's containers and images.
208
+
209
+ ---
210
+
211
+ ## Timings
212
+
213
+ Measured on `rl_lseg` (3,462 tracked files, 863 MB `data.db`), Apple Silicon:
214
+
215
+ | What | Time |
216
+ |---|---|
217
+ | Source checks (no flags) | 15–26 s |
218
+ | `config_yaml_advisory` (3 votes, in parallel) | 16 s |
219
+ | `hardcoded_names`, small repo (2 calls, Sonnet) | 10 s |
220
+ | `--docker` image, first build | 109 s |
221
+ | `--docker` image, rebuild from Docker's cache | 52–60 s |
222
+ | `--docker` image, nothing changed | reused (0.4 s on a test repo) |
223
+ | App start → healthy | 20 s |
224
+ | State checks (`rl_lseg` exports a 966 MB state, read twice, posted back once) | ~150 s |
225
+ | **Full `--docker` run** | **234–257 s** |
226
+
227
+ For comparison, on CSync the same repo spent 196 s on `dockerfile_build_run` alone, and
228
+ 410 s on each LLM audit, before any queue time.
229
+
230
+ Cost of `--llm`: the advisory's 3 calls cost $2.07 on Opus (Claude Code's default here);
231
+ a large repo's `hardcoded_names` is ~24 batches (~360k input tokens), so prefer
232
+ `--llm-model sonnet` for routine runs.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # csync-local: CSync's validation checks on your machine. See README.md.
3
+ set -euo pipefail
4
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ if ! command -v uv >/dev/null 2>&1; then
6
+ echo "csync-local needs uv (https://docs.astral.sh/uv/): brew install uv" >&2
7
+ exit 2
8
+ fi
9
+ export PYTHONWARNINGS="ignore::SyntaxWarning"
10
+ export PYTHONPATH="$HERE:$HERE/vendor/csync/backend${PYTHONPATH:+:$PYTHONPATH}"
11
+ exec uv run --quiet --no-project --python 3.12 --with pyyaml --with jsonschema --with ijson python -m localcsync "$@"