Skip to content

feat(bambubuddy): sync the spool shelf into filament inventory - #11

Merged
tech5-opti merged 2 commits into
mainfrom
tushar
Aug 22, 2026
Merged

feat(bambubuddy): sync the spool shelf into filament inventory#11
tech5-opti merged 2 commits into
mainfrom
tushar

Conversation

@tech5-opti

Copy link
Copy Markdown
Collaborator

POST /filament-inventory/sync mirrors BambuBuddy's spools into Tensor's stock rows.

Verified against the real shelf: 129 spools aggregate to 9 material/colour buckets totalling 129.0kg — matching BambuBuddy's own "TOTAL INVENTORY 129.0kg" exactly.

Why a sync and not a shared table

The two systems count at different granularities. BambuBuddy tracks individual spools (129 rows, each with label weight, used weight, cost). Tensor tracks availability per material and colour, because that is the only question the batch planner asks: is there enough black PLA for this bed?

So this aggregates — and reports both counts, because an operator comparing the two pages needs to know which number they are looking at.

Three things easy to get wrong, each tested

  • Core weight is the empty spool, not filament — counting it would inflate every material by 250 g per spool
  • A spool consumed past its label weight clamps at zero rather than subtracting from the material total
  • Colour is trimmed, so a stray space cannot split one colour into two buckets that never merge

Archived spools are excluded: BambuBuddy archives a spool when it is used up, and counting those reports filament that isn't there.

The trade-off, stated plainly

BambuBuddy's figures win — it's where spools are physically scanned and weighed. The cost is real and documented in the code: a Tensor-side debit not yet reflected in a spool's weight_used is overwritten on the next sync. That's why this is an operator action, not a background job.

Known follow-up

Material names are taken as-is ("PLA"). Designs ask for "PLA Basics" (the slicing-profile vocabulary), so imported stock does not yet satisfy them — the planner will still report shortages. A mapping layer is the fix, and it's a deliberate separate decision.

No schema change: GetFilamentByMaterialColour + InsertFilament + UpdateFilamentLevel already compose into the upsert this needs.

🤖 Generated with Claude Code

tech5-opti and others added 2 commits August 22, 2026 12:38
POST /filament-inventory/sync mirrors BambuBuddy's spools into Tensor's
stock rows. Verified against the real shelf: 129 spools aggregate to 9
material/colour buckets totalling 129.0kg, matching BambuBuddy's own
"TOTAL INVENTORY 129.0kg" exactly.

The two systems count filament at different granularities, which is the
whole reason this is a sync rather than a shared table. BambuBuddy tracks
INDIVIDUAL SPOOLS - 129 rows, each with a label weight, a used weight and
a cost. Tensor tracks AVAILABILITY PER MATERIAL AND COLOUR, because that
is the only question the batch planner asks: is there enough black PLA
for this bed? So this aggregates, and reports both counts, because an
operator comparing the two pages needs to know which number they are
looking at.

Three things the aggregation gets right that are easy to get wrong, each
with a test:

  - The core weight is the empty spool, not filament. Counting it would
    inflate every material by 250g per spool.
  - A spool consumed past its label weight clamps at zero rather than
    subtracting from the material's total.
  - Colour is trimmed, so a stray space cannot split one colour into two
    buckets that never merge.

Archived spools are excluded: BambuBuddy archives a spool when it is used
up or retired, and counting those reports filament that is not there.

BambuBuddy's figures win. It is where spools are physically scanned and
weighed, so it is the honest source of truth for the shelf - but the cost
is real and stated in the code: a Tensor-side debit not yet reflected in
a spool's weight_used is overwritten on the next sync. That is why this
is an operator action rather than something that happens quietly.

Material names are taken as-is ("PLA", not "PLA PRO+" and not remapped to
the slicing-profile vocabulary). Worth knowing: designs ask for "PLA
Basics", so imported stock does not yet satisfy them - see the follow-up.

No schema change: GetFilamentByMaterialColour + InsertFilament +
UpdateFilamentLevel already compose into the upsert this needs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tech5-opti
tech5-opti merged commit c308203 into main Aug 22, 2026
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e811fa9-a09d-4a66-b3f6-f6c995344ffd


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

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