feat(plantare): schema v12 — bilateral signed columns + repo

Adds the deferred bilateral columns to Plantares (plantare-bilateral.md
§"Schema delta"), all nullable/defaulted so v1 local rows coexist
untouched:

- pledgeId (the shared id both parties key their row by), debtorKey /
  creditorKey, debtorSignature / creditorSignature, movementId (the
  shared hand-over Movement for the provenance DAG), remoteState
  (proposed/accepted/declined — the handshake, distinct from status),
  returnKind (similar/workHours/other, default similar) + workHours.

Repo: createPlantare grows optional bilateral params; plantareByPledgeId
looks a row up by the shared id; applyPlantareSignatures counter-stamps
an incoming accept; setPlantareRemoteState records a decline. The
JSON codec carries every new field so they ride backups.

Versioned migration is guarded/idempotent like the others; schema v12
dumped, test helper regenerated, migration test covers v1..v11 → v12.
db + data + services 295/295 green.
This commit is contained in:
vjrj 2026-07-14 10:59:35 +02:00
parent 3f622f7bf7
commit 01fba40ec2
11 changed files with 5322 additions and 17 deletions

View file

@ -230,6 +230,16 @@ class InventoryJsonCodec {
'status': p.status.name,
'settledOn': p.settledOn,
'note': p.note,
// Bilateral signed form (plantare-bilateral.md).
'pledgeId': p.pledgeId,
'debtorKey': p.debtorKey,
'creditorKey': p.creditorKey,
'debtorSignature': p.debtorSignature,
'creditorSignature': p.creditorSignature,
'movementId': p.movementId,
'remoteState': p.remoteState?.name,
'returnKind': p.returnKind.name,
'workHours': p.workHours,
},
],
'sales': [
@ -484,6 +494,17 @@ class InventoryJsonCodec {
_enumOr(PlantareStatus.values, m['status'], PlantareStatus.open),
settledOn: m['settledOn'] as int?,
note: m['note'] as String?,
pledgeId: m['pledgeId'] as String?,
debtorKey: m['debtorKey'] as String?,
creditorKey: m['creditorKey'] as String?,
debtorSignature: m['debtorSignature'] as String?,
creditorSignature: m['creditorSignature'] as String?,
movementId: m['movementId'] as String?,
remoteState:
_enumOrNull(PlantareRemoteState.values, m['remoteState']),
returnKind: _enumOr(PlantareReturnKind.values, m['returnKind'],
PlantareReturnKind.similar),
workHours: (m['workHours'] as num?)?.toDouble(),
);
}),
sales: _rows(root, 'sales', (m) {