Skip to content

feat(config): frictionLambda .wind field + slipLimit machine profile, live (#327) - #352

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/vk-friction-schema
Aug 8, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/vk-friction-schema

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Part of #327 (Stage 3b Phase 2). PR 3a — the .wind/config surface, live end-to-end.

Makes non-geodesic Von Kármán winding a real, validated capability by adding the schema/config fields the planner (PR1 math + PR2 wiring) already knows how to consume — replacing PR2's hardcoded placeholders.

Fields

  • HelicalLayer.frictionLambda (schemaVersion 1.3, ge=0, default 0.0) — helical-only (not on the shared LayerModel), so hoop/skip layers can't carry it. This closes the PR2 review's skip/hoop-bypass watch-item.
  • MachineProfile.slipLimit (profileVersion 1.1, 0 < μ ≤ 0.5, default 0.2) — the machine's slip limit that bounds λ. Bundled marlin_xab.json → profileVersion 1.1 + explicit slipLimit. Not in any wire artifact (internal config).

Wiring

plan_wind now sources friction_lambda = layer.frictionLambda (helical-only) and μ = options.profile.slipLimit, replacing the placeholders. λ=0 stays byte-identical to the geodesic path.

The slipLimit ≤ 0.5 cap (from the adversarial review)

An unbounded μ let an operator profile push λ into a regime where the adaptive integrator is slow and eventually non-deterministic (measured: λ=1.5 → 15 s + a cross-platform floor-flip). Capping μ at the numerically-validated range (λ∈[0,0.5], which already reaches within ~1 mm of the tip — physically a high dry limit) keeps planning fast and platform-stable. λ=0.5 already gives near-full tip coverage, so this doesn't limit the practical feature.

Also

  • Regenerated schema artifacts (wind-schema.json/.ts, openapi.json, api/schema.ts) carry frictionLambda; GUI Zod save-gate mirrors ge=0.
  • Conformance: valid vk_friction; invalid vk_friction_exceeds_slip_limit + negative_friction_lambda.
  • examples/vk_nosecone_friction (gated: plans deeper than the geodesic, round-trips) + docs (wind-format 1.3, machine-profile slipLimit, changelog).

Adversarial review — SHIP

Verified additive back-compat (existing files/goldens unchanged), the helical-only claim is airtight, bounds correct (incl. NaN/Inf rejection inherited by MachineProfile), conformance cases fail for the stated reason, and the new plan_wind-level tests would fail if the wiring were reverted to placeholders. Fixed the two findings it raised (stale embedded profile JSON in the doc; the slipLimit cap from its robustness observation).

Gate

Full backend 330 passed; ruff/format/mypy clean; GUI tsc + svelte-check + 332 vitest green; artifacts deterministic; λ=0 byte-frozen.

CLI --profile (operator-settable μ) and the org-pages hosted-schema sync follow in PR3b.

… live (#327)

Make non-geodesic VK winding a real, validated, end-to-end capability (PR3a of
the #327 finish): the .wind format and machine profile now carry the inputs the
planner already knows how to consume, replacing PR2's placeholders.

- schemas.py: HelicalLayer.frictionLambda (schemaVersion 1.3, ge=0.0, default 0.0)
  — helical-only, so hoop/skip layers can never carry it (closes the PR2 review's
  skip/hoop bypass).
- machine_profile.py: MachineProfile.slipLimit (profileVersion 1.1, gt=0.0, default
  0.2); bundled marlin_xab.json bumped to 1.1 with an explicit slipLimit. Not in any
  wire artifact, so no openapi/schema churn from it.
- planner.py: source lambda from layer.frictionLambda (helical-only) and mu from
  options.profile.slipLimit, replacing the hardcoded placeholders.
- Regenerated schema artifacts (wind-schema.json/.ts, openapi.json, api/schema.ts)
  carry frictionLambda; GUI Zod save-gate mirrors the ge=0 bound.
- Conformance: valid vk_friction.wind; invalid vk_friction_exceeds_slip_limit.wind
  ("exceeds the machine slip limit") and negative_friction_lambda.wind (ge=0 at parse).
- examples/vk_nosecone_friction + docs (wind-format 1.3 field/changelog + version
  fixes, machine-profile slipLimit row, CHANGELOG).

Tests: plan_wind-level end-to-end (layer-sourced lambda winds deeper; rejects
lambda>mu against the default AND a custom profile mu; rejects lambda on a cylinder);
frictionLambda field default/negative; slipLimit default/bounds; shipped friction
example plans deeper than the geodesic and round-trips. Full suite 330 passed; lambda=0
byte-frozen.

CLI --profile (operator-settable mu) and the org-pages hosted-schema sync follow in PR3b.
@CameronBrooks11
CameronBrooks11 merged commit 0e1df88 into main Aug 8, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/vk-friction-schema branch August 8, 2026 21:54
CameronBrooks11 added a commit that referenced this pull request Aug 9, 2026
The GUI plans/saves from a reserialized project model. That model never
carried the mandrel `profile` (Von Kármán nose, schemaVersion 1.2) or the
helical `frictionLambda` (non-geodesic friction ratio, 1.3), so a VK file
was blocked on open by a guard, and — once the guard was lifted — would
lose both fields on save (planned/exported as a plain cylinder). #352 added
frictionLambda to the Zod gate for validation parity but never threaded it
through the converters, a latent silent-strip masked only by that guard.

Thread both through the internal model and both converter directions, and
emit the highest schemaVersion the content requires (frictionLambda -> 1.3,
profile -> 1.2, endDiameter -> 1.1, else 1.0). Remove the load guard: a VK
file now opens, edits, saves, and plans losslessly, at parity with how cone
files already round-trip (#344). Fields are omitted when absent so plain
cylinder/geodesic files stay byte-identical.

Data-fidelity only, mirroring #344 — no new form controls (endDiameter has
no editor either). Authoring a profile/friction wind from scratch in the
GUI is deferred to a follow-up mandrel-authoring editor.

Regression tests: a VK-friction .wind survives open -> save with profile
and frictionLambda intact; a geodesic VK nose stays 1.2; a plain cylinder
gains no spurious fields. The open guard's test flips to assert a load.
CameronBrooks11 added a commit that referenced this pull request Sep 10, 2026
Closes #370.

## Why this isn't the change #370 originally asked for

#370 was opened about zod growing 15.6 KiB. Measuring properly reframed
it. I decoded the build's sourcemap mappings to attribute **real
minified bytes** per module (source sizes overstate large libraries):

| module | minified | share |
| --- | ---: | ---: |
| **ajv** | 101.0 KiB | 30.3% |
| **zod** | 80.8 KiB | 24.2% |
| app source | 75.6 KiB | 22.7% |
| svelte | 48.6 KiB | 14.6% |

The GUI carried **two validators for one contract**, together ~60% of
its JavaScript:

- `src/lib/validation.ts` (**ajv**) compiles `schemas/wind-schema.json`,
**generated** from the Pydantic models.
- `src/lib/schemas.ts` (**zod**) hand-mirrored the same `.wind` shapes.

That is a drift risk as well as weight, and it had already bitten — from
#345's commit message: *"#352 added frictionLambda to the Zod gate for
validation parity but never threaded it through the converters, a latent
silent-strip masked only by that guard."*

## What changed

Only **two** files consumed the zod schemas. The `WindDefinition` *type*
was already imported from the generated `src/types/wind-schema.ts`, so
zod's inferred type was already redundant.

- **File open gate** → `validateWindDefinition`. ajv's error shape
(`{field, message}[]`) already matches `ValidationError`'s second
parameter, so the errors surface unchanged.
- **Backend health** → a small hand-written type guard. It comes over
the Tauri bridge, not the OpenAPI surface, so it has no generated type;
three fields didn't warrant a schema library.
- `schemas.ts` keeps the error classes and helpers, which is most of it,
and gains a note saying validation deliberately lives elsewhere.
- **`ajv` moved to `dependencies`** — it's imported by runtime code and
was the only such package still in `devDependencies` (`zod` and
`openapi-fetch` were both already correct).

## The one constraint that had to be carried over

The engine bounds `windAngle` to **[1, 89]** in a Pydantic *validator*,
not a field constraint, so `generate_schema.py` can't emit it —
`wind-schema.json` has only `exclusiveMinimum: 0`. ajv alone would have
accepted a file the planner then rejects with a 422, so this would have
been a silent loosening of the gate.

`validateWindDefinition` now applies that bound explicitly, cited to
`fiberpath/planning/validators.py`. I checked every other constraint zod
enforced — mandrel, tow, layer bounds, and the `schemaVersion`
`^1\.\d+$` pattern — and all of them are already in the generated
schema. `windAngle` was the only gap. (The `profile`/`endDiameter`
mutual exclusion is a Pydantic `model_validator` that zod didn't enforce
either, so no change there.)

Confirmed against the engine, with the mutation asserted so a no-op edit
couldn't masquerade as a pass:

```
$ fiberpath plan <vk_nosecone with windAngle=120>
Planning failed: Layer 1: wind angle 120.0° must be between 1.0° and 89.0°
exit=1
```

## Verification

New tests cover the parity bound at 0.5 / 89.5 / 90 / 120 (reject) and 1
/ 45 / 89 (accept). **Mutation-tested**: disabling the parity check
fails exactly those 4 rejection cases and nothing else, so the tests are
genuinely exercising it rather than passing incidentally.

| | before | after |
| --- | ---: | ---: |
| JS bundle | 337.39 KiB | **255.10 KiB** |
| gzip | 102.83 KiB | 80.05 KiB |
| headroom vs 346.62 KiB budget | ~9 KiB | **91.5 KiB** |

`tsc --noEmit` clean · `svelte-check` 0 errors · **327 tests pass** ·
coverage 78.2 / 68.7 / 80.1 / 83.3 against thresholds of 60 / 50 / 65 /
60.

Test count moves 339 → 327: the 19 zod schema tests are removed (that
contract is now covered by `validation.test.ts` against the canonical
schema) and 7 parity tests added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant