Add the mandatory block kind and upgrade the SDK - #40
Merged
Conversation
`structure refresh` output plus the kind/ workspace member it needs to discover: block-tools 2.12.7 -> 2.14.3, model 1.80.2 -> 1.82.0, ui-vue 1.80.4 -> 1.82.1, tengo-builder 4.0.18 -> 4.0.23, workflow-tengo 6.7.2 -> 6.8.2, plus ts-builder, ts-configs, package-builder, test and helpers. Drops the pnpm.overrides block that pinned ten SDK packages to local monorepo tarballs: @platforma-sdk/block-kind is published now, and those file: paths do not exist in CI. Keeps --unstable on the facade's prepublishOnly. The structurer strips that flag on refresh, so it is re-added deliberately and will show up as drift in `structure check`.
Eight optional fields: the dataset reference, the three analysis knobs, the per-process resource limits, and the two labels. tableState and graphState stay out — a template carrying them would restore one user's scroll position and plot config onto another user's block. The CONTRACT table is checked against BlockParams by a satisfies clause, so a field added to the contract without a runtime check fails to compile. Every field being optional is what makes that guard necessary: a parser that simply forgot one would otherwise return a valid BlockParams and say nothing.
The data model is built with the kind, so its BlockParams type flows into init, and the model records which kind it implements. templateParams projects the same eight fields back out, so export and apply are inverses.
Comment on lines
+75
to
+76
| mem: check(isInteger, "an integer"), | ||
| cpu: check(isInteger, "an integer"), |
There was a problem hiding this comment.
Non-positive resource limits pass validation
When a project template supplies zero or a negative integer for mem or cpu, the parser accepts it and the model forwards it unchanged into workflow resource configuration, causing invalid requests such as -1GiB to fail during scheduling instead of rejecting the template during initialization.
Prompt To Fix With AI
This is a comment left during a code review.
Path: kind/src/params.ts
Line: 75-76
Comment:
**Non-positive resource limits pass validation**
When a project template supplies zero or a negative integer for `mem` or `cpu`, the parser accepts it and the model forwards it unchanged into workflow resource configuration, causing invalid requests such as `-1GiB` to fail during scheduling instead of rejecting the template during initialization.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Drops the hand-written isInteger / isNumber / isFiniteNumber wrappers in favour of isNumber and isArray from es-toolkit/compat, which is where the narrowing versions live: the root entry ships neither. Two checks get looser, both deliberately. A fractional value now passes where isInteger refused it — whether 2.5 CPUs means anything is the block's own args to settle, not the kind's, which checks the envelope. And NaN passes, which JSON.parse cannot produce, so it is unreachable by the only route params travel. What stays local is what es-toolkit has no equivalent for: the Guard and Check types, the check factory, and the oneOf / arrayOf / optional combinators. All of it sits below the Internals divider.
Publishing goes to the normal channel. The flag was carried while the batch was in flight; the structurer strips it on every refresh, so keeping it also meant `structure check` reporting this one field as drift forever.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the now-mandatory kind to the Rarefaction block and takes it through the SDK upgrade that comes with it. Part of the batch bringing every block onto project templates.
The init-params contract
The kind carries the block's identity and its init-params contract — what a project template supplies to seed a new instance. Eight optional fields:
datasetRef(PlRef, guarded byisPlRef)numPoints,numIterations,extrapolationmem,cpudatasetLabel,customBlockLabelnumPoints/numIterationsare checked as strings because that is what the block stores — the UI binds them to text inputs, so a half-typed value is an ordinary state, and the model'sargsis what holds them to integers. A parser stricter than the states the editor can reach would make export and apply stop being inverses.Left out:
tableStateandgraphState— pure view state. A template carrying them would restore one user's scroll position and plot config onto another user's block.initandtemplateParamsname the same eight fields, so the round trip is lossless.The drift guard
params.tschecks itsCONTRACTtable againstBlockParamswith asatisfiesclause. Every contract field is optional, so a parser that simply forgot one would otherwise return a validBlockParamsand say nothing; with the guard, adding a field without a runtime check fails to compile.Also in here
pnpm.overrides— ten SDK packages had been pinned to local monorepo tarballs.@platforma-sdk/block-kindis published now, and thosefile:paths do not exist in CI.--unstablekept on the facade'sprepublishOnly. The structurer strips that flag on refresh, so it is re-added deliberately —structure checkreports it as drift, which is expected here.Verification
turbo run build— 12/12 green;pnpm install --frozen-lockfileclean.block-tools structure check— fixpoint apart from the intended--unstabledrift.kind/dist: a full eight-field params object comes back deep-equal,{}is accepted, a half-typed editor state is accepted, unknown keys are dropped rather than refused, and malformed envelopes (null, a number, an array) plus every per-field type error are rejected.CONTRACTentry fails the type-check with TS1360.model/dist/model.jsonrecordskind: "@platforma-open/milaboratories.rarefaction.kind@1.0.0".Not run: block tests (need a live backend) and the kind publish loop (needs registry credentials). Template export→apply is proven at the parser and by
init/templateParamsnaming the same fields, not by a running project cycle.Greptile Summary
The PR introduces the mandatory Rarefaction block kind and upgrades the Platforma SDK/toolchain, wiring template initialization and export through a shared eight-field contract.
kind/workspace package and connected to the model and facade.PlRef: a Platforma reference to another block’s output;datasetRefis now accepted through the kind contract and validated withisPlRef.prepublishOnlycommand.Confidence Score: 4/5
The PR should not merge until template-supplied CPU and memory values are constrained to valid positive resource limits.
The new template path accepts zero and negative resource values, bypasses the editor’s minimum constraint, and forwards those values unchanged into workflow execution resource requests.
Files Needing Attention: kind/src/params.ts
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR T[Project template] --> P[Kind parameter parser] P --> I[Model init] I --> S[Live block state] S --> A[Model args] A --> W[Workflow resource configuration] S --> E[templateParams export] E --> T2[Exported project template]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "chore: add changeset for the block kind" | Re-trigger Greptile