Skip to content

SOF-7926: generic InMemoryEntity - #280

Open
k0stik wants to merge 35 commits into
mainfrom
chore/SOF-7926
Open

SOF-7926: generic InMemoryEntity#280
k0stik wants to merge 35 commits into
mainfrom
chore/SOF-7926

Conversation

@k0stik

@k0stik k0stik commented Jun 22, 2026

Copy link
Copy Markdown
Member

No description provided.

k0stik and others added 18 commits June 23, 2026 00:44
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>
Comment thread dist/js/Material.js
this.unsetFileProps();
}
get Lattice() {
getLattice() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/js/Material.ts Outdated
defaultableEntityMixin(BaseMaterial);
hasMetadataMixin(BaseMaterial.prototype);

class Material<S extends Schema = Schema> extends BaseMaterial<S> implements Schema {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the corresponding conversion functions

k0stik added 3 commits August 4, 2026 16:48
Split unconstrained Material from MaterialConstrained / MaterialConstrainedHashed, put constraints on basis JSON, rename Material files to PascalCase, and update serializers and tests.
Comment thread src/js/Material.ts
if (!this.isNonPeriodic || bypassNonPeriodicCheck) {
message =
this.Basis.hashString + "#" + this.Lattice.getHashString(isScaled) + "#" + salt;
this.getBasis().hashString +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move all hash-related items to MaterialHashed then, including Inchi above

Comment thread src/js/MaterialConstrained.ts Outdated
},
};

function parseConstrainedBasis(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to reuse parseBasis from the above and add constraint

Comment thread src/js/MaterialConstrained.ts Outdated
setBasis(
textOrObject: string | BasisConfig | ConstrainedBasisConfig,
format?: "xyz",
unitz?: BasisSchema["units"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be units, not unitZ

Comment thread src/js/MaterialConstrained.ts Outdated
super.basis = basis;
}

setBasis(basis: BasisConfig): void;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add ConstrainedBasisConfig?

Comment thread tests/fixtures/si-standata.json Outdated
oid sha256:62175309558d4a75da4fd723ccb47dc558cdbb89fa224e61921c4ee2d5b48094
size 1133
oid sha256:ef37920119b9ae2ca66f73b24765bdfc8cb31786ffa07c54739359a4ad92be8e
size 1447

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixtures should not change

k0stik and others added 8 commits August 6, 2026 17:27
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>
Comment thread src/js/Material.ts Outdated
) as Schemas["pure"];
}

toJSONEnriched(): Schemas["enriched"] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe Enhanced instead of Enriched

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VsevolodX Pls confirm this is OK from the Py side

k0stik and others added 6 commits August 7, 2026 22:53
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>
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.

2 participants