feat(block1): inventory walking skeleton + first quick-add slice

Stand up the Tanemaki monorepo and the first end-to-end vertical slice of
Block 1 (offline, encrypted inventory): add a seed → see it in a categorized,
searchable list → it persists → reopen and it's still there.

Architecture (state management like G1nkgo, adapted to Tane's reality):
- flutter_bloc (Cubit-first), but the encrypted Drift DB is the single source
  of truth; cubits stream from repositories (no hydrated_bloc/Hive, which would
  write plaintext at rest).
- get_it composition root; go_router; slang i18n (ES/EN, Weblate-friendly JSON).

Workspace & core:
- pub workspace: packages/commons_core (pure Dart) + apps/app_seeds (Flutter).
- commons_core primitives: UUIDv7 IdGen, Hybrid Logical Clock, Quantity value
  type (+ plant-aware QuantityKind), IdentityService root-seed stub.

Data & security:
- Drift schemaVersion=1 with all 10 Block-1 tables + common CRDT columns
  (HLC updated_at, last_author, tombstones); Movement append-only.
- SQLCipher via an injectable executor that refuses to open a plaintext DB;
  DB key + root seed in the OS keystore (separate secrets).
- Exported drift_schema_v1.json + migration scaffold.

Tests (near-TDD; nothing merges without tests):
- commons_core units (24), Drift migration test, "no plaintext at rest"
  security guard (runs where SQLCipher is present, skips otherwise),
  repository, widget, full quick-add flow, file-reopen persistence, and a
  no-hardcoded-strings i18n guard. GitLab CI: format + analyze + test + coverage.

Follow-on Block-1 stories (item detail/edit, species catalog, germination UI)
and all of Block 2 remain out of scope.
This commit is contained in:
vjrj 2026-07-07 15:16:14 +02:00
parent 57c0eeadaf
commit 040f15a898
131 changed files with 19855 additions and 20 deletions

View file

@ -0,0 +1,47 @@
import 'package:commons_core/commons_core.dart';
import 'package:test/test.dart';
void main() {
group('Quantity', () {
test('value equality ignores object identity', () {
const a = Quantity(kind: QuantityKind.pod, precise: 12, label: 'a bag');
const b = Quantity(kind: QuantityKind.pod, precise: 12, label: 'a bag');
expect(a, b);
expect(a.hashCode, b.hashCode);
});
test('isPrecise reflects the presence of a precise amount', () {
expect(
const Quantity(kind: QuantityKind.grams, precise: 5).isPrecise,
isTrue,
);
expect(const Quantity(kind: QuantityKind.aFew).isPrecise, isFalse);
});
test('copyWith overrides only the given fields', () {
const q = Quantity(kind: QuantityKind.cob, precise: 2);
final q2 = q.copyWith(kind: QuantityKind.ear);
expect(q2.kind, QuantityKind.ear);
expect(q2.precise, 2);
});
});
group('QuantityKind', () {
test('enum names are stable storage keys', () {
// Guards against accidental renames these strings live in the DB.
expect(QuantityKind.pod.name, 'pod');
expect(QuantityKind.cob.name, 'cob');
expect(QuantityKind.head.name, 'head');
expect(QuantityKind.packet.name, 'packet');
expect(QuantityKind.handful.name, 'handful');
expect(QuantityKind.grams.name, 'grams');
expect(QuantityKind.count.name, 'count');
});
test('every kind belongs to a group', () {
for (final kind in QuantityKind.values) {
expect(QuantityGroup.values, contains(kind.group));
}
});
});
}