feat(bambubuddy): sync the spool shelf into filament inventory - #11
Conversation
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>
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
|



POST /filament-inventory/syncmirrors 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
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_usedis 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+UpdateFilamentLevelalready compose into the upsert this needs.🤖 Generated with Claude Code