Skip to content

Add sourced mechanical properties to the filament schema - #893

Merged
coffandro merged 2 commits into
OpenFilamentCollective:mainfrom
percosys:feat/mechanical-schema
Nov 11, 2026
Merged

coffandro merged 2 commits into
OpenFilamentCollective:mainfrom
percosys:feat/mechanical-schema

Conversation

@percosys

@percosys percosys commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Schema part of #892. The data follows in a separate PR on top of this one.

What

An optional mechanical array on filament.json (schemas/mechanical_schema.json). One entry per published value: property, print direction, value, ± spread, unit, standard, dry or conditioned, test-bar details (specimen), and the same source fields as sustainability (source_type, source_url, source_quote, retrieved, notes).

It follows #768:

  • Schema: linked from the filament schema with a cross-file $ref. ofd-validator resolves it as is (tested).
  • Validation (data_quality.py): reuses the sustainability source checks. Errors: missing source fields, value or ± not in the quote, retrieved in the future, a unit that doesn't fit the property. Warnings: a print direction on moulded bars, a repeated entry (same property, direction, condition, standard, unit and specimen).
  • Review and merge: the Sustainability sources gate also checks mechanical entries against their source (the quote on the page, the value in the quote), and a PR that touches them never auto-merges. The AI review never suggests mechanical values, and its mechanical findings are never dropped. The gate fails closed on this PR because it changes rule files (data_quality.py, sustainability.py), so a maintainer must review it.
  • Number in quote: in MPa, psi, ksi and J/m it also matches grouped thousands (7250 ↔ 7,250), as sheets in psi write them. In other units a comma stays a decimal comma. A value no longer matches part of a longer number (5 in 5.85, 7 in 7,250). Sustainability quotes never group.
  • Exports: a mechanical JSON column in SQLite and CSV. The API carries the field as is.
  • style_data: key order from the schema; tracking parameters stripped from source_url; specimen cleaned like the other fields.
  • WebUI: a table on the filament page (XY / XZ / Z side by side, each value linked to its source), an editor in the filament form (reuses SourcedEntryFields), the schema endpoint, the same checks client-side, and tests. A new entry left empty is dropped on save.
  • Docs: a "🔩 Mechanical data" section in the manual.

Notes

  • Filament only. A data sheet covers a product line, so variants don't override it.
  • Units stay as published (psi stays psi): copy, never compute.
  • Changes from the issue: direction gains XZ (some sheets test on-edge bars) and uses unknown instead of "".
  • Two small WebUI fixes this needed, which also touch sustainability:
    • checkSourcedEntry checked every value field except value_kg_co2e as a percentage. It now checks only pct, recycled_pct and reduction_pct, like the Python side.
    • A required dropdown used to pick its first option silently (a new carbon footprint got method: "epd"). It now starts on "Choose…" and shows an inline "… is required" error until a value is picked.

Testing

  • pytest: 547 passed. The 2 failures in test_search_index_exporter.py also fail on main.
  • ruff check, ruff format --check: clean.
  • ofd validate: passes with no errors. style_data --dry-run: 0 files changed.
  • WebUI: vitest 1071 passed, npm run check 0 errors, npm run build OK.

🤖 Generated with Claude Code

An optional `mechanical` array on filament.json (schemas/mechanical_schema.json):
one entry per published value (tensile, flexural, impact, heat deflection) with
its print direction, unit as published, standard, condition, test-bar details
and the sustainability-style source fields. Follows OpenFilamentCollective#768: data-quality checks
(sources, value in quote, unit fits the property), CSV/SQLite columns, key
order and tracker stripping in style_data, WebUI display and editor, manual
section and tests. The number-in-quote check also accepts thousands
separators (7,250 psi).

Refs OpenFilamentCollective#892

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@coffandro coffandro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this. The mechanical schema and the editor look solid. Below are the issues I found. Inline comments cover the changed lines. Two concerns are about code this PR doesn't touch, so they're here:

AI review guard skips mechanical. In ofd/review/suggest.py (~L138), the "never suggested" filter blocks pointers containing sustainability or container_details, but not mechanical. A review model could emit an enrichment like /mechanical/0/value with a guessed number, and it would become a PR suggestion. That breaks the "copy, never compute" rule this schema enforces. ofd/review/triage.py (~L73) and ofd/review/sustainability.py (~L448) have the same sustainability-only checks.

No source gate or auto-merge exclusion for mechanical-only PRs. The "Sustainability sources" gate (ofd/review/sustainability.py ~L60) and auto-merge eligibility (eligibility.py ~L285) only look at sustainability paths. A PR that only adds mechanical entries with a wrong source_url, where the quote check still passes, gets no human source review and can be auto-merged. The PR description mentions this gap. I'd close it here or in a follow-up before contributors start using the field.

I think the two above and the two number-matching comments on _number_pattern should be fixed before merge. The rest are smaller.

🤖 Generated with Claude Code

Comment thread ofd/validation/data_quality.py Resolved
Comment thread ofd/validation/data_quality.py Resolved
Comment thread webui/src/lib/utils/dataQuality.ts Resolved
Comment thread ofd/scripts/style_data.py Resolved
Comment thread ofd/validation/data_quality.py Resolved
Comment thread webui/src/lib/utils/mechanical.ts Resolved
- Number in quote: a value no longer matches part of a longer number
  (5 in 5.85, 7 in 7,250). Grouped thousands only in MPa, psi, ksi
  and J/m; elsewhere a comma is a decimal comma. Sustainability quotes
  never group. Same rules in the WebUI.
- AI review: mechanical values are never suggested, mechanical findings
  are never dropped, and the "Sustainability sources" gate checks
  mechanical entries against their source, so E15 blocks auto-merge.
- style_data also cleans the specimen object.
- A repeated entry now also compares the specimen.
- WebUI: inline "... is required" hint, untouched new entries are
  dropped on save, one editable-copy helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Automated review of 1511610 · how this works

  • 🌱 Sustainability: 2 problem(s) overridden by @coffandro.

Maintainers: ✅ LGTM & merge · workflow run

@percosys

Copy link
Copy Markdown
Contributor Author

Thanks for the review. All points are fixed in 1511610.

  • AI review guard: suggest.py now rejects any /mechanical pointer ("mechanical data is never suggested"). triage.py and model_problems in sustainability.py now use one is_sourced_pointer() that covers sustainability, container_details and mechanical, so mechanical findings are never dropped.
  • Source gate and auto-merge: the "Sustainability sources" gate now also checks each mechanical entry against its source (the quote on the page, the value in the quote). A PR that adds, changes or removes mechanical data counts as touched, so E15 keeps it from auto-merging. schemas/mechanical_schema.json is now a rule file. The "not covered" note is gone from the description.
  • Number matching: see the two threads on _number_pattern.

The bot's "Sustainability blocked" on this PR is expected: the gate fails closed when data_quality.py or sustainability.py change, until a maintainer reviews them.

Tests: pytest 547 passed (the 2 failures in test_search_index_exporter.py also fail on main). ruff is clean. ofd validate passes with no errors, and style_data --dry-run changes 0 files. WebUI: vitest 1071 passed, npm run check 0 errors, npm run build OK.

🤖 Addressed by Claude Code

@coffandro coffandro added the sustainability-verified A maintainer checked the sustainability sources by hand; overrides the Sustainability sources gate label Nov 11, 2026
@coffandro
coffandro merged commit edc8d70 into OpenFilamentCollective:main Nov 11, 2026
27 of 28 checks passed
@coffandro

Copy link
Copy Markdown
Collaborator

LGTM! Thanks for the contribution, it'll be up on SP and the dataset at about 00:00 Danish time.
You can make a PR for the data additions aswell if you'd like :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sustainability-verified A maintainer checked the sustainability sources by hand; overrides the Sustainability sources gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants