SOF-7926: generic InMemoryEntity - #280
Conversation
Compose system/hashed via esse c6c4d84b1, wire hashedEntityMixin on Material, and keep persisted hash in sync after basis/lattice mutations. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Material structure-only; persist and refresh hash on MaterialHashed via basis/lattice setters.
Allow web-app Core* subclasses to widen schema via MaterialHashed<S> without redeclaring _json. Pin @mat3ra/code for NoInfer on InMemoryEntity. Co-authored-by: Cursor <cursoragent@cursor.com>
Rely on InMemoryEntity.toJSON for hash; type defaultMaterialConfig as Schema. Co-authored-by: Cursor <cursoragent@cursor.com>
Materials often omit basis.constraints (stored as a proto property); restoring optional constraints and ?? [] avoids fromObjects(undefined). Co-authored-by: Cursor <cursoragent@cursor.com>
Pass constraints via Material ctor/parsers separately, split non-empty fixture constraints into sidecar files, and type ConstrainedBasis as Basis<ConstrainedBasisConfig>. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| this.unsetFileProps(); | ||
| } | ||
| get Lattice() { | ||
| getLattice() { |
There was a problem hiding this comment.
We should add this as a rule to https://github.com/mat3ra/agent-code-review-tb/blob/main/
| defaultableEntityMixin(BaseMaterial); | ||
| hasMetadataMixin(BaseMaterial.prototype); | ||
|
|
||
| class Material<S extends Schema = Schema> extends BaseMaterial<S> implements Schema { |
There was a problem hiding this comment.
We should have all cases spelled out:
Material (as Base, with no hash, no constraints)
MaterialWithHash or HashedMaterial (with hash)
MaterialWIthConstraints (with ConstrainedBasis)
MaterialWithHashAndConstraints (with both)
There was a problem hiding this comment.
And the corresponding conversion functions
Split unconstrained Material from MaterialConstrained / MaterialConstrainedHashed, put constraints on basis JSON, rename Material files to PascalCase, and update serializers and tests.
| if (!this.isNonPeriodic || bypassNonPeriodicCheck) { | ||
| message = | ||
| this.Basis.hashString + "#" + this.Lattice.getHashString(isScaled) + "#" + salt; | ||
| this.getBasis().hashString + |
There was a problem hiding this comment.
We should move all hash-related items to MaterialHashed then, including Inchi above
| }, | ||
| }; | ||
|
|
||
| function parseConstrainedBasis( |
There was a problem hiding this comment.
Probably better to reuse parseBasis from the above and add constraint
| setBasis( | ||
| textOrObject: string | BasisConfig | ConstrainedBasisConfig, | ||
| format?: "xyz", | ||
| unitz?: BasisSchema["units"], |
There was a problem hiding this comment.
should be units, not unitZ
| super.basis = basis; | ||
| } | ||
|
|
||
| setBasis(basis: BasisConfig): void; |
There was a problem hiding this comment.
Should we add ConstrainedBasisConfig?
| oid sha256:62175309558d4a75da4fd723ccb47dc558cdbb89fa224e61921c4ee2d5b48094 | ||
| size 1133 | ||
| oid sha256:ef37920119b9ae2ca66f73b24765bdfc8cb31786ffa07c54739359a4ad92be8e | ||
| size 1447 |
There was a problem hiding this comment.
Fixtures should not change
Move hash-updating basis/lattice accessors into materialHashedMixin, re-type accessors via S, and align tests with Material/MaterialHashed/MaterialConstrained while putting constraints back on material fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
Collapse MaterialConstrained/Hashed variants into one Material with toJSON* cleaners driven by an overridable MaterialSchemaMap, register ESSE schemas in tests only, and keep hash sync on the class itself. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the unused fromMaterial helper, type defaults/parsers against MaterialConstrainedSchema or MaterialConfig, and normalize basis/hash before calling super. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Align schema-map keys and toJSON*/jsonSchema* APIs with esse material-enriched ids, and pin @mat3ra/esse to 05c55da65. Co-authored-by: Cursor <cursoragent@cursor.com>
validateData only throws the error code; surface AJV errors, json, and schema in the console like InMemoryEntity.clean. Co-authored-by: Cursor <cursoragent@cursor.com>
Document the constructor normalization and add a regression test; fixtures no longer need an empty metadata object. Co-authored-by: Cursor <cursoragent@cursor.com>
| ) as Schemas["pure"]; | ||
| } | ||
|
|
||
| toJSONEnriched(): Schemas["enriched"] { |
There was a problem hiding this comment.
maybe Enhanced instead of Enriched
There was a problem hiding this comment.
Or Extended (may clash with "extend" elsewhere) We need to explain what Enhanced means in the README, either here or inside the schema
| oid sha256:62175309558d4a75da4fd723ccb47dc558cdbb89fa224e61921c4ee2d5b48094 | ||
| size 1133 | ||
| oid sha256:d81edc05f74463da35845fd348716de48459b8b3b5acfa5076fb621a8e23a74e | ||
| size 1454 |
Follow the esse material-enriched -> material-enhanced schema rename (address review feedback preferring "enhanced" terminology): pin @mat3ra/esse to the renamed commit and update MaterialEnrichedSchema/MaterialEnrichedHashedSchema, MATERIAL_SCHEMA_IDS, jsonSchemaEnriched*/toJSONEnriched* accordingly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Pin @mat3ra/code and @mat3ra/esse to SOF-7926 commits that strip nulls in entity clean and keep empty-string placeholders intact. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Passing isNonPeriodic as bypassNonPeriodicCheck forced geometric hashes on construct and basis/lattice setters. Use calculateHash() defaults instead. Co-authored-by: Cursor <cursoragent@cursor.com>
Designer toggle sets isNonPeriodic before butler derives InChI. Keep calculateHash strict (throw without InChI); updateHash falls back to bypass geometric hashing so lattice/basis setters match main UX. Co-authored-by: Cursor <cursoragent@cursor.com>
toJSONPure strips basis.constraints, so the material viewer XYZ omitted selective-dynamics flags. Match main's toJSON behavior using enhanced. Co-authored-by: Cursor <cursoragent@cursor.com>
No description provided.