mirror of
https://github.com/penpot/penpot.git
synced 2026-11-29 06:30:33 +00:00
* ✨ Extend backend histogram buckets beyond 7.5s Give every backend timing histogram a tail past the shared 7500ms cap so slow RPC calls, CLIMIT waits and background tasks report real quantiles instead of clipping at the top bucket. Request and wait metrics grow to 60s, background tasks to 300s and Redis eval to 10s; the sub-7.5s buckets stay untouched to keep the history comparable. Closes #12408 AI-assisted-by: muse-spark-1.3-contributor * 🐛 Fix flaky assertion in climit republish test Read the last published waiting value instead of the exact publication list. The sampler thread started with the component runs its first tick asynchronously, and when it lands inside the recording window it publishes the same count twice, which made the full-suite CI run fail while focused runs stayed green. AI-assisted-by: muse-spark-1.3-contributor * ✨ Add file_data blob to JSON decode helper Allow decoding file_data blobs (app.util.blob) to JSON for investigations with jq, offline from a blob file or from nREPL with the backend running. AI-assisted-by: muse-spark-1.3-contributor * ✨ Add validation step timings to update-file logs and metrics Measure the six phases inside process-changes-and-validate (resolve-libs, process-changes, soft and hard affected and schema validations) with tpoint and try/finally, so timings are recorded even when a hard validation throws. Publish each phase to a new histogram penpot_rpc_update_file_validation_timing with a fixed step label using the request buckets (up to 60000 ms), and extend the update-file debug log with the same *-ms fields plus file, project and team ids. The deferred log only runs on success, so failures get an inline error log with partial timings. AI-assisted-by: muse-spark-1.3-contributor * 💄 Translate decode-file-data comments to English Translate the Spanish docstrings, section headers and test messages of the file_data decode helper to English, keeping code untouched. The repo convention is English in code and comments; the helper was first written in Spanish. AI-assisted-by: muse-spark-1.3-contributor
2.8 KiB
2.8 KiB
Clojure Design Rules
How to shape a function in this codebase. Each rule came from a review round; do not re-derive from taste.
- Preconditions belong to the boundary, not to the core. A function documents what it needs (hints, docstring) and assumes it. Absence checks live where the value enters the system: the caller that resolves optional objects,
ig/init-key, the request handler — includingnilthat is optional-by-design (when-let [cs (some-> server ...)]at the entry point, as withConnectorStatisticswhen the server option is off). A(when (and (some? a) (some? b)) ...)inside a leaf function means the guard is in the wrong place — if you cannot getaorb, you should not be calling it. - A static set of operations is written statically. With a fixed, small set (four metrics) write the four calls. Do not build a collection and iterate it (
doseqover a literal vector): it allocates, adds indirection and hides each operation. Use a collection when the set is dynamic (config, registry, input). - Default to no
!; existing!is legacy being removed gradually. Do not introduce new!names except the allowed cases documented inmem:clojure/idioms(add and justify the special case there first). Allowed: mutating public fns inapp.db(insert!,update!,delete!,run!,tx-run!, ...) and fns whose contract is to work over transients (stdlibconj!/assoc!/dissoc!/persistent!and custom helpers over them). Existing!elsewhere (e.g.emit!,send!,submit!,validate-file!) stays until its refactor; keep a family consistent in the meantime. Reporting helpers (log, sample-and-publish) never take!: the mutation happens in the!API they call. - Functions that obtain data start with
get-orfetch-. A reader must see at a glance that the function reads (get-file,get-snapshot,get-file-json); a bare noun hides it (file-jsonsays nothing about reading). New helpers that fetch by id follow this, never acurrent-prefix: the id parameter already says which one it is. ?marks a predicate, not a data prop. A var or function that answers a question takes?(export-error?,(defn editable? …)); a map key that names a property does not (:export-error, never:export-error?), even when its value is a boolean. Existing?keys are legacy to remove gradually; do not add a new one.- Do not shape production code for tests. No return values added just to assert them; assert on the observable effect. When preconditions move, move the tests with them.
Reference implementation: the http metrics samplers in app.http (sample-worker-metrics / sample-connector-metrics are guard-free; sample-http-metrics guards at the boundary).
See also: mem:clojure/idioms (language behaviors), mem:testing (TDD and test conventions).