amalgm 0.1.186 → 0.1.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amalgm",
3
- "version": "0.1.186",
3
+ "version": "0.1.187",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -116,6 +116,34 @@ test('wall reduction chooses one rail winner and orders checkpoint transitions b
116
116
  assert.deepEqual(plan.transitions.map((item) => item.version), [8]);
117
117
  });
118
118
 
119
+ test('a ready parked bundle never regresses to pending', () => {
120
+ const oid = 'c'.repeat(40);
121
+ const ready = card('/ready', 'a'.repeat(40), 1);
122
+ const readyCheckpoint = transition('machine-ready', 2, ready.head.oid, '', '');
123
+ readyCheckpoint.parked = [{
124
+ oid,
125
+ ref: `refs/amalgm/parked/${oid}`,
126
+ objects: { kind: 'bundle', checksum: 'd'.repeat(64) },
127
+ }];
128
+ ready.checkpoints = [readyCheckpoint];
129
+
130
+ const pending = card('/pending', ready.head.oid, 3);
131
+ const pendingCheckpoint = transition('machine-pending', 4, pending.head.oid, '', '');
132
+ pendingCheckpoint.parked = [{
133
+ oid,
134
+ ref: `refs/amalgm/parked/${oid}`,
135
+ objects: { kind: 'pending' },
136
+ }];
137
+ pending.checkpoints = [pendingCheckpoint];
138
+
139
+ const plan = reduceWall([
140
+ { machine: 'machine-ready', cards: [ready] },
141
+ { machine: 'machine-pending', cards: [pending] },
142
+ ]).get('root:test');
143
+ assert.equal(plan.parked.length, 1);
144
+ assert.equal(plan.parked[0].objects.kind, 'bundle');
145
+ });
146
+
119
147
  test('a stale lower rail card cannot roll back a newer branch and commit', () => {
120
148
  const newer = card('/newer', 'b'.repeat(40), 12);
121
149
  newer.head.branch = 'feature';
@@ -124,6 +124,7 @@ function reduceWall(entries) {
124
124
  && entry.branch === repo.card.head?.branch
125
125
  ))
126
126
  .sort((left, right) => left.version - right.version);
127
+ repo.parked = uniqueParked(repo.parked);
127
128
  if (repo.card.head?.branch) {
128
129
  const held = repo.branchMap.get(repo.card.head.branch);
129
130
  if (!held || repo.card.positionVersion > held.version) {
@@ -146,7 +147,10 @@ function uniqueParked(entries) {
146
147
  const byOid = new Map();
147
148
  for (const entry of entries || []) {
148
149
  if (typeof entry?.oid === 'string' && /^[0-9a-f]{40,64}$/.test(entry.oid)) {
149
- byOid.set(entry.oid, entry);
150
+ const held = byOid.get(entry.oid);
151
+ if (!held || held.objects?.kind !== 'bundle' || entry.objects?.kind === 'bundle') {
152
+ byOid.set(entry.oid, entry);
153
+ }
150
154
  }
151
155
  }
152
156
  return [...byOid.values()].sort((left, right) => left.oid.localeCompare(right.oid));