Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions devnet/_bootstrap/bootstrap.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,20 @@ async function main() {
},
];
const createRes = await fetch(
`http://127.0.0.1:${core.apiPort}/api/assertion/create`,
`http://127.0.0.1:${core.apiPort}/api/knowledge-assets`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${agent.authToken}`,
},
// KA create auto-finalizes when `quads` are supplied; `alsoShareSwm`
// is the WM→SWM transition that the legacy `promote: true` flag did.
body: JSON.stringify({
name,
contextGraphId: CONTEXT_GRAPH,
quads,
finalize: true,
promote: true,
alsoShareSwm: true,
}),
},
);
Expand Down
25 changes: 14 additions & 11 deletions devnet/rich-scenario/automated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,16 @@ async function assertionCreate(
ts: number,
): Promise<string> {
const { quads, rootSubject } = buildQuads(cgId, name, ts);
const res = await apiFetch(node, '/api/assertion/create', {
// KA create auto-finalizes when `quads` are supplied; `alsoShareSwm` is the
// WM→SWM transition that the legacy `promote: true` flag performed.
const res = await apiFetch(node, '/api/knowledge-assets', {
method: 'POST',
bearer: agentToken,
body: JSON.stringify({
name,
contextGraphId: cgId,
quads,
finalize: true,
...(promote ? { promote: true } : {}),
...(promote ? { alsoShareSwm: true } : {}),
}),
});
if (!res.ok) {
Expand Down Expand Up @@ -701,14 +702,14 @@ describe('Devnet rich scenario (~10 min)', () => {
for (let i = 0; i < WM_COUNT; i++) {
const name = `bulk-wm-${run.stamp}-${i}`;
const { quads } = buildBulkQuads(name, batchTs + i);
const res = await apiFetch(core1, '/api/assertion/create', {
// KA create auto-finalizes (seals to WM) when `quads` are supplied.
const res = await apiFetch(core1, '/api/knowledge-assets', {
method: 'POST',
bearer: token,
body: JSON.stringify({
name,
contextGraphId: BULK_CG,
quads,
finalize: true,
}),
});
if (!res.ok) {
Expand All @@ -721,15 +722,16 @@ describe('Devnet rich scenario (~10 min)', () => {
for (let i = 0; i < SWM_COUNT; i++) {
const name = `bulk-swm-${run.stamp}-${i}`;
const { quads } = buildBulkQuads(name, batchTs + 100 + i);
const res = await apiFetch(core1, '/api/assertion/create', {
// KA create auto-finalizes when `quads` are supplied; `alsoShareSwm`
// performs the WM→SWM transition (legacy `promote: true`).
const res = await apiFetch(core1, '/api/knowledge-assets', {
method: 'POST',
bearer: token,
body: JSON.stringify({
name,
contextGraphId: BULK_CG,
quads,
finalize: true,
promote: true,
alsoShareSwm: true,
}),
});
if (!res.ok) {
Expand All @@ -742,15 +744,16 @@ describe('Devnet rich scenario (~10 min)', () => {
for (let i = 0; i < VM_COUNT; i++) {
const name = `bulk-vm-${run.stamp}-${i}`;
const { quads, rootSubject } = buildBulkQuads(name, batchTs + 200 + i);
const createRes = await apiFetch(core1, '/api/assertion/create', {
// KA create auto-finalizes + `alsoShareSwm` promotes to SWM; the
// separate /api/shared-memory/publish below lifts SWM→VM.
const createRes = await apiFetch(core1, '/api/knowledge-assets', {
method: 'POST',
bearer: token,
body: JSON.stringify({
name,
contextGraphId: BULK_CG,
quads,
finalize: true,
promote: true,
alsoShareSwm: true,
}),
});
if (!createRes.ok) {
Expand Down
35 changes: 20 additions & 15 deletions devnet/v10-core-flows/automated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@ async function fullPublish(api: string, token: string, name: string): Promise<{
{ subject, predicate: 'http://schema.org/name', object: `"${name}"`, graph: '' },
{ subject, predicate: 'http://schema.org/value', object: '"epoch-pool fuel"', graph: '' },
];
let r = await postJson(api, '/api/assertion/create', { contextGraphId: cgId, name }, token);
expect(r.status, `create failed: ${JSON.stringify(r.body)}`).toBe(200);
r = await postJson(api, `/api/assertion/${name}/write`, { contextGraphId: cgId, quads }, token);
let r = await postJson(api, '/api/knowledge-assets', { contextGraphId: cgId, name }, token);
// KA create returns 201 (resource created) vs the legacy route's 200.
expect(r.status, `create failed: ${JSON.stringify(r.body)}`).toBe(201);
r = await postJson(api, `/api/knowledge-assets/${name}/wm/write`, { contextGraphId: cgId, quads }, token);
expect(r.status, `write failed: ${JSON.stringify(r.body)}`).toBe(200);
r = await postJson(api, `/api/assertion/${name}/finalize`, { contextGraphId: cgId }, token);
r = await postJson(api, `/api/knowledge-assets/${name}/wm/finalize`, { contextGraphId: cgId }, token);
expect(r.status, `finalize failed: ${JSON.stringify(r.body)}`).toBe(200);
r = await postJson(api, `/api/assertion/${name}/promote`, { contextGraphId: cgId }, token);
r = await postJson(api, `/api/knowledge-assets/${name}/swm/share`, { contextGraphId: cgId }, token);
expect(r.status, `promote failed: ${JSON.stringify(r.body)}`).toBe(200);
r = await postJson(api, '/api/shared-memory/publish', { contextGraphId: cgId, assertionName: name }, token);
expect(r.status, `publish failed: ${JSON.stringify(r.body)}`).toBe(200);
Expand Down Expand Up @@ -357,26 +358,29 @@ describe('1. chained sign-at-creation assertion lifecycle', () => {
);
await sleep(500); // SSE warm-up

let r = await postJson(NODE1_API, '/api/assertion/create', { contextGraphId: CONTEXT_GRAPH, name: assertionName }, state.node1Token);
expect(r.status, `create: ${JSON.stringify(r.body)}`).toBe(200);
let r = await postJson(NODE1_API, '/api/knowledge-assets', { contextGraphId: CONTEXT_GRAPH, name: assertionName }, state.node1Token);
// KA create returns 201 (resource created) vs the legacy route's 200.
expect(r.status, `create: ${JSON.stringify(r.body)}`).toBe(201);
expect(r.body.assertionUri).toContain(assertionName);

const quads = [
{ subject: 'urn:test:lifecycle:s1', predicate: 'http://schema.org/name', object: '"Sign-at-creation lifecycle test"', graph: '' },
{ subject: 'urn:test:lifecycle:s2', predicate: 'http://schema.org/sameAs', object: 'urn:test:lifecycle:s1', graph: '' },
];
r = await postJson(NODE1_API, `/api/assertion/${assertionName}/write`, { contextGraphId: CONTEXT_GRAPH, quads }, state.node1Token);
r = await postJson(NODE1_API, `/api/knowledge-assets/${assertionName}/wm/write`, { contextGraphId: CONTEXT_GRAPH, quads }, state.node1Token);
expect(r.status, `write: ${JSON.stringify(r.body)}`).toBe(200);
expect(r.body.written).toBe(2);

r = await postJson(NODE1_API, `/api/assertion/${assertionName}/finalize`, { contextGraphId: CONTEXT_GRAPH }, state.node1Token);
r = await postJson(NODE1_API, `/api/knowledge-assets/${assertionName}/wm/finalize`, { contextGraphId: CONTEXT_GRAPH }, state.node1Token);
expect(r.status, `finalize: ${JSON.stringify(r.body)}`).toBe(200);
// wm/finalize returns the full seal payload (PR #971): merkleRoot, eip712Digest, schemeVersion, etc.
expect(r.body.merkleRoot).toMatch(/^0x[0-9a-f]{64}$/);
expect(r.body.eip712Digest).toMatch(/^0x[0-9a-f]{64}$/);
expect(r.body.schemeVersion).toBe(1);

r = await postJson(NODE1_API, `/api/assertion/${assertionName}/promote`, { contextGraphId: CONTEXT_GRAPH }, state.node1Token);
r = await postJson(NODE1_API, `/api/knowledge-assets/${assertionName}/swm/share`, { contextGraphId: CONTEXT_GRAPH }, state.node1Token);
expect(r.status, `promote: ${JSON.stringify(r.body)}`).toBe(200);
// swm/share returns { swmShared, promotedCount }.
expect(r.body.promotedCount).toBe(2);

await sleep(1500); // let trailing events arrive
Expand All @@ -397,8 +401,9 @@ describe('2. failed publish does not leak triples into verified-memory (RC11 / P
const subject = `urn:test:edge:rc11:${Date.now().toString(36)}`;
const witnessLiteral = `"PR2 failed-publish witness ${Date.now().toString(36)}"`;

let r = await postJson(NODE5_API, '/api/assertion/create', { contextGraphId: CONTEXT_GRAPH, name: assertionName }, state.node5Token);
expect(r.status, `edge create: ${JSON.stringify(r.body)}`).toBe(200);
let r = await postJson(NODE5_API, '/api/knowledge-assets', { contextGraphId: CONTEXT_GRAPH, name: assertionName }, state.node5Token);
// KA create returns 201 (resource created) vs the legacy route's 200.
expect(r.status, `edge create: ${JSON.stringify(r.body)}`).toBe(201);

// The witness literal is unique per run so the verified-memory query
// below can isolate THIS publish's quads from any bootstrap data
Expand All @@ -407,11 +412,11 @@ describe('2. failed publish does not leak triples into verified-memory (RC11 / P
{ subject, predicate: 'http://schema.org/name', object: witnessLiteral, graph: '' },
{ subject, predicate: 'http://schema.org/author', object: '"edge-node-5"', graph: '' },
];
r = await postJson(NODE5_API, `/api/assertion/${assertionName}/write`, { contextGraphId: CONTEXT_GRAPH, quads }, state.node5Token);
r = await postJson(NODE5_API, `/api/knowledge-assets/${assertionName}/wm/write`, { contextGraphId: CONTEXT_GRAPH, quads }, state.node5Token);
expect(r.status).toBe(200);
r = await postJson(NODE5_API, `/api/assertion/${assertionName}/finalize`, { contextGraphId: CONTEXT_GRAPH }, state.node5Token);
r = await postJson(NODE5_API, `/api/knowledge-assets/${assertionName}/wm/finalize`, { contextGraphId: CONTEXT_GRAPH }, state.node5Token);
expect(r.status).toBe(200);
r = await postJson(NODE5_API, `/api/assertion/${assertionName}/promote`, { contextGraphId: CONTEXT_GRAPH }, state.node5Token);
r = await postJson(NODE5_API, `/api/knowledge-assets/${assertionName}/swm/share`, { contextGraphId: CONTEXT_GRAPH }, state.node5Token);
expect(r.status).toBe(200);

// Post-RFC-38 an edge node (identityId=0) may still reach `confirmed`
Expand Down
20 changes: 11 additions & 9 deletions devnet/v10-stress/automated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,9 @@ describe('V10 chain — stress + scenario validation', () => {
console.log(`phase 2: WM-only batch (${wmOnly} assertions on core1)...`);
for (let i = 0; i < wmOnly; i++) {
const name = `wm-only-${runTag}-${i}`;
// KA create auto-finalizes (seals to WM) when `quads` are supplied.
const r = await fetch(
`http://127.0.0.1:${core1.apiPort}/api/assertion/create`,
`http://127.0.0.1:${core1.apiPort}/api/knowledge-assets`,
{
method: 'POST',
headers: {
Expand All @@ -1005,7 +1006,6 @@ describe('V10 chain — stress + scenario validation', () => {
name,
contextGraphId: CONTEXT_GRAPH,
quads: buildQuads(name),
finalize: true,
}),
},
);
Expand Down Expand Up @@ -1045,8 +1045,10 @@ describe('V10 chain — stress + scenario validation', () => {
console.log(`phase 2: VM custodial (mode B) batch (${vmCustodial} assertions via core2)...`);
for (let i = 0; i < vmCustodial; i++) {
const name = `vm-custodial-${runTag}-${i}`;
// KA create auto-finalizes when `quads` are supplied; `alsoShareSwm`
// performs the WM→SWM transition (legacy `promote: true`).
const createRes = await fetch(
`http://127.0.0.1:${core2.apiPort}/api/assertion/create`,
`http://127.0.0.1:${core2.apiPort}/api/knowledge-assets`,
{
method: 'POST',
headers: {
Expand All @@ -1057,8 +1059,7 @@ describe('V10 chain — stress + scenario validation', () => {
name,
contextGraphId: CONTEXT_GRAPH,
quads: buildQuads(name),
finalize: true,
promote: true,
alsoShareSwm: true,
}),
},
);
Expand Down Expand Up @@ -1211,8 +1212,10 @@ describe('V10 chain — stress + scenario validation', () => {
console.log(`phase 2: WM→SWM batch (${wmSwm} assertions on core1)...`);
for (let i = 0; i < wmSwm; i++) {
const name = `wm-swm-${runTag}-${i}`;
// KA create auto-finalizes when `quads` are supplied; `alsoShareSwm`
// performs the WM→SWM transition (legacy `promote: true`).
const r = await fetch(
`http://127.0.0.1:${core1.apiPort}/api/assertion/create`,
`http://127.0.0.1:${core1.apiPort}/api/knowledge-assets`,
{
method: 'POST',
headers: {
Expand All @@ -1223,8 +1226,7 @@ describe('V10 chain — stress + scenario validation', () => {
name,
contextGraphId: CONTEXT_GRAPH,
quads: buildQuads(name),
finalize: true,
promote: true,
alsoShareSwm: true,
}),
},
);
Expand Down Expand Up @@ -1293,7 +1295,7 @@ describe('V10 chain — stress + scenario validation', () => {
`\`publishFromFinalizedAssertion\` (\`packages/agent/src/dkg-agent.ts:4383\`) calls ` +
`\`publishFromSharedMemory(contextGraphId, 'all', ...)\` with the literal selection \`'all'\`. ` +
`It does NOT filter SWM content to the named assertion's quads. ` +
`Reproduction: promote N assertions (\`POST /api/assertion/create { ..., finalize: true, promote: true }\` × N) ` +
`Reproduction: promote N assertions (\`POST /api/knowledge-assets { ..., quads, alsoShareSwm: true }\` × N) ` +
`then publish ONE of them by name (\`POST /api/shared-memory/publish { assertionName }\`). ` +
`The publish bundles all N assertions' quads into one KC and the response status is \`tentative\` ` +
`with \`kaId: "0"\` (sentinel), because the merkle root the publisher derives over the actual ` +
Expand Down
Loading
Loading