Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(products): items count by the one membership rule [S12]

Corey Olsonb3a08ab01b04
diff --git a/src/products.js b/src/products.js
index 137c39f7..2515ea36 100644
--- a/src/products.js
+++ b/src/products.js
@@ -80,7 +80,9 @@ export function productsOfLane(config, spec, lane) {
/**
* Each product's standing: its rows in force, how many are approved, how many an accepted item
- * cites, and its items by state. Withdrawn items are left out.
+ * cites, and its items by state. Only the row counts leave out rows decided against or retired; an
+ * item belongs to a product exactly as productsOfItem says, whatever became of its rows. Withdrawn
+ * items are left out of the item counts.
*
* @param {any} config
* @param {{ rows: { id: string, status: string }[] }} spec
@@ -90,8 +92,7 @@ export function productsOfLane(config, spec, lane) {
export function productSummaries(config, spec, items) {
return Object.entries(config.products ?? {}).map(([name, entries]) => {
const rows = spec.rows.filter((row) => !OUT_OF_FORCE.includes(row.status) && entries.some((entry) => names(entry, row.id)));
- const ids = new Set(rows.map((row) => row.id));
- const mine = items.filter((item) => citedBy(item).some((id) => ids.has(id)));
+ const mine = items.filter((item) => productsOfItem(config, item).includes(name));
const accepted = items.filter((item) => item.item_status === 'verified');
const count = (state) => mine.filter((item) => item.item_status === state).length;
return {
diff --git a/test/products.test.js b/test/products.test.js
index 96dba528..8a837a8f 100644
--- a/test/products.test.js
+++ b/test/products.test.js
@@ -145,18 +145,29 @@ test('in a real repo, status prints each product, and spec check fails on an ent
assert.equal(typo.status, 1);
assert.match(typo.stdout, /error: product "View": "Q9" names no row in the spec/);
+ writeConfig(PRODUCTS);
+ writeFileSync(join(repo, 'SPEC.md'), SPEC.replace('- B1 [approved, must] Claims are leases. | gate: test', '- B1 [retired] Claims are leases.'));
+ const retired = run('status');
+ assert.match(retired.stdout, /^product Core: 2 rows, 1 approved, 0 cited by accepted items; items 1 open, 1 building, 0 awaiting verification, 1 verified$/m, 'a retired row leaves the row counts, but its accepted item stays Core\'s');
+
writeConfig({});
assert.doesNotMatch(run('status').stdout, /^product /m, 'no products, no product lines');
});
-test('a product counts rows in force only, and items by the state the board reads [S12]', () => {
+test('a product counts only rows in force, but its items by the one membership rule [S12]', () => {
const spec = parseSpec(SPEC);
const items = [
{ item_spec_ids: 'B1', item_status: 'verified' },
{ item_spec_ids: 'B3', item_status: 'open' },
{ item_spec_ids: 'N26', item_status: 'withdrawn' },
+ { item_spec_ids: 'N26.1,B2', item_status: 'claimed' },
];
const [core, view] = productSummaries(CONFIG, spec, items);
- assert.deepEqual(core, { name: 'Core', rows: 3, approved: 2, proven: 1, items: { open: 0, claimed: 0, submitted: 0, verified: 1 } }, 'B3 is wont: out of the rows, and the item citing only it is out too');
- assert.deepEqual(view.items, { open: 0, claimed: 0, submitted: 0, verified: 0 }, 'withdrawn items are left out');
+ assert.deepEqual(core, { name: 'Core', rows: 3, approved: 2, proven: 1, items: { open: 1, claimed: 1, submitted: 0, verified: 1 } }, 'B3 is wont, so it is out of the rows, but the item citing it is still Core\'s');
+ assert.deepEqual(view.items, { open: 0, claimed: 1, submitted: 0, verified: 0 }, 'withdrawn items are left out');
+ for (const product of [core, view]) {
+ const counted = Object.values(product.items).reduce((sum, count) => sum + count, 0);
+ const members = items.filter((item) => item.item_status !== 'withdrawn' && productsOfItem(CONFIG, item).includes(product.name)).length;
+ assert.equal(counted, members, `${product.name} counts exactly the items productsOfItem gives it`);
+ }
});