Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

26.1 KB
Raw Blame
'use strict';
// Descriptions on every artifact that accepts one.
//
// A description is the maker-facing "what is this for", and it is also the only grounding an agent
// has when it later inspects a deployed app it did not build. An app whose tables and columns are
// named `new_col3` and described nowhere is guessable by a human and opaque to a model, so the build
// engine writes descriptions at CREATE time rather than leaving them to a backfill nobody runs.
//
// Two invariants this file exists to protect, both discovered by MEASURING the vendored bundle
// rather than reading its types:
//
//   1. OMISSION IS NOT BLANKING. Every write site omits `description` when the spec has none. If a
//      site ever sends `description: ''` instead, a rebuild silently erases a description a maker
//      typed in the UI — a data-loss bug that no error message would ever surface.
//
//   2. SECURITY ROLES ARE EXCLUDED ON PURPOSE. The SDK hardcodes its own ownership marker into a
//      role's description and then uses an EXACT match on that string to decide whether it may touch
//      the role. Honouring an author-supplied role description would make the SDK disown its own
//      role and refuse to update it. See the guard test at the bottom.
const test = require('node:test');
const assert = require('node:assert');
const os = require('node:os');
const path = require('node:path');
const fs = require('node:fs');

const { validateAppSpec } = require('../lib/app-spec.js');
const { viewDef, chartDef, businessRuleDef, compileFormIntent, personaRoleSpecFor } = require('../lib/sdk-build.js');
const { provisionDataModel, provisionSolution } = require('../lib/entity-provision.js');

const BUNDLE = path.resolve(__dirname, '..', 'vendor', 'cds-maker-sdk.cjs');
const DESC = 'Tracks a customer support ticket from intake to resolution.';

// ------------------------------------------------------------------ spec fixtures

function baseSpec(over = {}) {
  return Object.assign({
    solution: { uniqueName: 'DESC', displayName: 'Desc', publisherPrefix: 'new' },
    app: { name: 'Desc App', description: '' },
    entities: [{
      schemaName: 'new_ticket', displayName: 'Ticket', pluralName: 'Tickets',
      primaryAttribute: { schemaName: 'new_subject', displayName: 'Subject' },
      columns: [{ schemaName: 'new_score', displayName: 'Score', type: 'Integer' }],
    }],
    appShell: { areas: [{ label: 'Main', groups: [{ label: 'Records', subAreas: [{ entity: 'new_ticket', title: 'Tickets' }] }] }] },
  }, over);
}

// ------------------------------------------------------------------ 1. validation

test('a description is accepted on every artifact that supports one', () => {
  const spec = baseSpec({
    entities: [{
      schemaName: 'new_ticket', displayName: 'Ticket', pluralName: 'Tickets', description: DESC,
      primaryAttribute: { schemaName: 'new_subject', displayName: 'Subject' },
      columns: [{ schemaName: 'new_score', displayName: 'Score', type: 'Integer', description: 'Severity 1-5.' }],
    }],
    views: [{ name: 'Open', entity: 'new_ticket', columns: [{ name: 'new_subject' }], description: 'Unresolved tickets.' }],
    charts: [{ name: 'By Score', entity: 'new_ticket', chartType: 'Column', groupBy: 'new_score', description: 'Volume by severity.' }],
    forms: [{ name: 'Ticket', entity: 'new_ticket', description: 'Primary intake form.' }],
  });
  const res = validateAppSpec(spec);
  assert.deepStrictEqual(res.errors.filter((e) => /description/i.test(e)), [], 'no description should be rejected');
});

test('a non-string description is rejected rather than stringified into Dataverse', () => {
  // `description: 42` or an accidental object would otherwise be written as "42"/"[object Object]".
  for (const bad of [42, { text: 'x' }, ['x']]) {
    const spec = baseSpec();
    spec.entities[0].description = bad;
    const res = validateAppSpec(spec);
    assert.ok(res.errors.some((e) => /description must be a string/.test(e)), `${JSON.stringify(bad)} must be rejected`);
  }
});

test('a blank description is rejected — omit the field instead', () => {
  // An empty string is the one value that would BLANK an existing description on rebuild, so it is
  // refused at author time rather than silently dropped.
  const spec = baseSpec();
  spec.entities[0].description = '   ';
  assert.ok(validateAppSpec(spec).errors.some((e) => /must not be blank/.test(e)));
});

test('a description past the Dataverse ceiling is rejected, not silently truncated', () => {
  const spec = baseSpec();
  spec.entities[0].description = 'x'.repeat(2001);
  assert.ok(validateAppSpec(spec).errors.some((e) => /2001 characters \(max 2000\)/.test(e)));
  spec.entities[0].description = 'x'.repeat(2000);
  assert.deepStrictEqual(validateAppSpec(spec).errors.filter((e) => /description/.test(e)), [], '2000 is inclusive');
});

test('descriptions stay OPTIONAL — a spec without any still validates', () => {
  // Making them mandatory would fail every spec authored before they existed.
  assert.deepStrictEqual(validateAppSpec(baseSpec()).errors.filter((e) => /description/i.test(e)), []);
});

// ------------------------------------------------------------------ 2. def builders

test('viewDef and chartDef carry the authored description', () => {
  const spec = baseSpec();
  const v = viewDef(spec, { name: 'Open', entity: 'new_ticket', description: DESC, columns: ['new_subject'] });
  assert.strictEqual(v.description, DESC);
  const c = chartDef(spec, { name: 'By Score', entity: 'new_ticket', chartType: 'Column', groupBy: 'new_score', description: DESC });
  assert.strictEqual(c.description, DESC);
});

test('viewDef and chartDef fall back to empty when none is authored', () => {
  // These two send `description` unconditionally (the SDK requires the key), so the fallback must be
  // '' rather than undefined — but the spec can never REACH that path with a blank, because a blank
  // is a validation error above.
  const spec = baseSpec();
  assert.strictEqual(viewDef(spec, { name: 'V', entity: 'new_ticket', columns: ['new_subject'] }).description, '');
  assert.strictEqual(chartDef(spec, { name: 'C', entity: 'new_ticket', chartType: 'Column', groupBy: 'new_score' }).description, '');
});

test('businessRuleDef carries a description and OMITS the key when absent', () => {
  const rule = { name: 'Escalate', entity: 'new_ticket', conditions: [], actions: [] };
  const withDesc = businessRuleDef(Object.assign({ description: DESC }, rule));
  assert.strictEqual(withDesc.description, DESC);
  assert.ok(!('description' in businessRuleDef(rule)), 'absent description must not appear as a key');
});

test('compileFormIntent carries the form description through to the SDK def', () => {
  const spec = baseSpec();
  const intent = compileFormIntent(spec, { name: 'Ticket', entity: 'new_ticket', description: DESC }, {});
  assert.strictEqual(intent.description, DESC);
  const bare = compileFormIntent(spec, { name: 'Ticket', entity: 'new_ticket' }, {});
  assert.strictEqual(bare.description, undefined, 'absent stays undefined so createArtifact omits it');
});

// ------------------------------------------------------------------ 3. table + column write path

function provisionHarness() {
  const calls = [];
  const sdk = {
    createTable: async (o) => { calls.push(['createTable', o]); return { logicalName: o.schemaName.toLowerCase(), entitySetName: `${o.schemaName.toLowerCase()}s` }; },
    createColumn: async (e, o) => { calls.push(['createColumn', o]); return { logicalName: o.schemaName.toLowerCase() }; },
    createCustomerColumn: async (e, o) => ({ logicalName: o.schemaName.toLowerCase() }),
    createGlobalOptionSet: async (o) => { calls.push(['createGlobalOptionSet', o]); return { name: o.name, metadataId: 'gc-1' }; },
    createRelationship: async (o) => ({ schemaName: o.schemaName }),
    createAlternateKey: async (e, o) => ({ logicalName: o.schemaName.toLowerCase() }),
    insertStatusValue: async () => 100000001,
    updateTable: async () => undefined,
    setColumnVisualization: async () => undefined,
  };
  const provision = {
    findTables: async () => [],
    findColumns: async () => [],
    fetchEntityMetadata: async (l) => ({ logicalName: l, entitySetName: `${l}s`, relationships: [] }),
    // Nothing pre-exists, so provisionSolution takes the create path (an existing solution returns
    // early and would never reach createSolution).
    queryRecords: async (entity) => (entity === 'solution' || entity === 'publisher' ? [] : [{ solutionid: 's' }]),
    createPublisher: async () => ({ id: '33333333-3333-3333-3333-333333333333' }),
    createSolution: async (o) => { calls.push(['createSolution', o]); return { id: 'sol-1' }; },
  };
  return { sdk, provision, calls };
}

async function runProvision(spec, h) {
  const runner = {
    run: async (phase, label, fn, o = {}) => {
      try { return await fn(); } catch (err) { if (o.skipIf && o.skipIf(err)) return undefined; throw err; }
    },
    skip: () => {},
    mapLimit: async (items, _n, fn) => { const out = []; for (const it of items) out.push(await fn(it)); return out; },
  };
  await provisionSolution({ sdk: h.sdk, provision: h.provision, runner, solution: spec.solution });
  await provisionDataModel({ spec, sdk: h.sdk, provision: h.provision, runner, preResolvedLanguageCode: 1033 });
}

test('a table and a column are CREATED with their descriptions', async () => {
  const spec = baseSpec();
  spec.entities[0].description = DESC;
  spec.entities[0].columns[0].description = 'Severity 1-5.';
  const h = provisionHarness();
  await runProvision(spec, h);
  assert.strictEqual(h.calls.find((c) => c[0] === 'createTable')[1].description, DESC);
  assert.strictEqual(h.calls.find((c) => c[0] === 'createColumn')[1].description, 'Severity 1-5.');
});

test('a table and a column with NO description omit the key entirely', async () => {
  // The blanking guard: sending `description: ''` here would wipe whatever a maker had typed.
  const h = provisionHarness();
  await runProvision(baseSpec(), h);
  assert.ok(!('description' in h.calls.find((c) => c[0] === 'createTable')[1]));
  assert.ok(!('description' in h.calls.find((c) => c[0] === 'createColumn')[1]));
});

// ------------------------------------------------------------------ 3b. solution + global choice

test('a solution and a global choice are CREATED with their descriptions', async () => {
  const spec = baseSpec();
  spec.solution.description = 'Everything the support desk needs.';
  spec.globalChoices = [{ name: 'new_severity', displayName: 'Severity', options: ['Low', 'High'], description: 'Shared severity scale.' }];
  const h = provisionHarness();
  await runProvision(spec, h);
  assert.strictEqual(h.calls.find((c) => c[0] === 'createSolution')[1].description, 'Everything the support desk needs.');
  assert.strictEqual(h.calls.find((c) => c[0] === 'createGlobalOptionSet')[1].description, 'Shared severity scale.');
});

test('a solution and a global choice with NO description omit the key', async () => {
  const spec = baseSpec();
  spec.globalChoices = [{ name: 'new_severity', displayName: 'Severity', options: ['Low', 'High'] }];
  const h = provisionHarness();
  await runProvision(spec, h);
  assert.ok(!('description' in h.calls.find((c) => c[0] === 'createSolution')[1]));
  assert.ok(!('description' in h.calls.find((c) => c[0] === 'createGlobalOptionSet')[1]));
});

// ------------------------------------------------------------------ 3c. accepted-but-inert warnings

test('a description the SDK cannot write is WARNED about, not silently dropped', async () => {
  // Both of these validate fine and build fine — the value just never reaches Dataverse. Silence
  // here is the worst outcome: the author believes the description exists.
  const spec = baseSpec();
  spec.entities[0].columns.push({ schemaName: 'new_client', displayName: 'Client', type: 'Customer', description: 'Who reported it.' });
  spec.webResources = [{ name: 'new_lib.js', type: 'script', content: 'dmFy' }];
  spec.commands = [{ entity: 'new_ticket', label: 'Escalate', library: 'new_lib.js', function: 'esc', description: 'Escalates the ticket.' }];
  const res = validateAppSpec(spec);
  assert.deepStrictEqual(res.errors.filter((e) => /description/i.test(e)), [], 'neither is an error');
  assert.ok(res.warnings.some((w) => /Customer column/.test(w) && /NOT be written/.test(w)), 'Customer column warned');
  assert.ok(res.warnings.some((w) => /command/.test(w) && /NOT be written/.test(w)), 'command warned');
});

test('app.description may be empty (legacy shape) but a new surface may not', () => {
  // download-model-app emits `app.description: ""`; rejecting it would fail specs that already work.
  const spec = baseSpec();
  spec.app.description = '';
  assert.deepStrictEqual(validateAppSpec(spec).errors.filter((e) => /description/.test(e)), []);
  // The same emptiness on a surface introduced WITH this contract is still refused.
  spec.solution.description = '';
  assert.ok(validateAppSpec(spec).errors.some((e) => /solution: description must not be blank/.test(e)));
});

// ------------------------------------------------------------------ 4. real bundle: does it reach the wire?

const dirs = [];
test.after(() => { for (const d of dirs) fs.rmSync(d, { recursive: true, force: true }); });

async function sdkWithCapture() {
  const { createMakerSdk, createNodeWorkspaceStorage } = require(BUNDLE);
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'desc-'));
  dirs.push(dir);
  const writes = [];
  const httpClient = {
    get: async () => ({ status: 200, headers: {}, body: { value: [] } }),
    post: async (url, body) => {
      writes.push({ url: String(url), body });
      return { status: 200, headers: { 'odata-entityid': '/x(22222222-2222-2222-2222-222222222222)' }, body: {} };
    },
    postRaw: async (url, body) => { writes.push({ url: String(url), body }); return { status: 200, headers: {}, body: {} }; },
    patch: async (url, body) => { writes.push({ url: String(url), body }); return { status: 204, headers: {}, body: {} }; },
    put: async () => ({ status: 204, headers: {}, body: {} }),
    delete: async () => ({ status: 204, headers: {}, body: {} }),
  };
  const sdk = createMakerSdk({ workspaceStorage: createNodeWorkspaceStorage(dir), instanceUrl: 'https://contoso.crm.dynamics.com', httpClient });
  await sdk.initWorkspace();
  return { sdk, writes };
}

test('REAL BUNDLE: description survives to the wire for every artifact we set it on', async () => {
  // The typed surface ACCEPTING a field proves nothing about the payload — a serializer that drops
  // it would leave every assertion above green while Dataverse received nothing. So push for real
  // against a recording client and look for the value in the request body.
  const MARK = 'WIRE_MARKER_UNIQUE';
  const cases = {
    view: { name: 'V', description: MARK, entityLogicalName: 'account', queryType: 0, isDefault: false, columns: [{ name: 'name', width: 100 }] },
    chart: { name: 'C', description: MARK, entityLogicalName: 'account', chartType: 'Column', isDefault: false, series: [{ field: 'name', aggregate: 'count' }], categories: [{ field: 'name' }] },
    form: { name: 'F', description: MARK, entityLogicalName: 'account', formType: 'main', status: 'draft' },
    dashboard: { name: 'D', description: MARK },
    // ⚠ This rule must be COMPLETE — one condition and one action. It used to be a bare
    // `{ name, description, entityLogicalName, scope, status }`, which worked only because the SDK
    // would happily push a rule with no clauses and no actions. It no longer will: the designer's
    // completeness validator runs on every save, so a skeleton rule is refused and NOTHING reaches
    // the wire — making this test fail for a reason that has nothing to do with descriptions.
    //
    // The distinction matters: that was FIXTURE damage, not product damage. A rule the designer
    // itself would refuse to save is not a case this test ever meant to cover.
    businessRule: businessRuleDef({
      name: 'BR', description: MARK, entity: 'account',
      conditions: [{ field: 'name', operator: 'Equals', value: 'x', dataType: 'String' }],
      actions: [{ type: 'SetVisibility', field: 'name', visible: false }],
    }),
    app: { name: 'A', uniqueName: 'cr_descapp', description: MARK, iconWebResourceId: '11111111-1111-1111-1111-111111111111' },
  };
  for (const [type, def] of Object.entries(cases)) {
    const { sdk, writes } = await sdkWithCapture();
    const art = await sdk.createArtifact(type, def);
    assert.strictEqual(art.description, MARK, `${type}: the typed surface keeps description`);
    // A business rule carries its condition tree through the generic element surface, not the
    // create payload — mirroring how the build authors one.
    if (type === 'businessRule') {
      await sdk.updateElement('businessRule', art.id, '/rootCondition', def.rootCondition);
    }
    // The push may fail late (the fake client returns no usable id); the write we care about has
    // already been recorded by then, so the outcome of the push is deliberately not asserted.
    try { await sdk.pushArtifact(type, art.id); } catch { /* payload already captured */ }
    assert.ok(writes.some((w) => JSON.stringify(w.body || '').includes(MARK)), `${type}: description must reach the wire`);
  }
});

// ------------------------------------------------------------------ 5. the two deliberate exclusions

test('REAL BUNDLE: a command does NOT accept a description — so the build never sends one', async () => {
  // Pins why `commands[]` is absent from everything above. If a future bundle adds it, this fails
  // and the omission gets revisited on purpose instead of staying an unexplained gap.
  const { sdk } = await sdkWithCapture();
  const art = await sdk.createArtifact('command', { name: 'CMD', description: 'ignored', entityLogicalName: 'account', buttons: [] });
  assert.ok(!('description' in art), 'the command surface drops description; wiring one would be inert');
});

test('REAL BUNDLE: a view accepts /description as an updateElement pointer, and the push carries it (#496)', async () => {
  // The whole view mechanic in reconcileView rests on two bundle contracts that no mock can vouch
  // for, because the sdk-build mock's jpSet creates a missing key while the REAL updateElement
  // throws PathNotFoundError when its pointer resolves to undefined:
  //   1. `/description` is a resolvable pointer on a fetched view;
  //   2. the view push includes `description` in its PATCH body — which is WHY the description must
  //      ride the push rather than be written as a separate record PATCH (that would be clobbered).
  // A re-vendor that changed either would otherwise go green. AGENTS.md treats re-vendoring as a
  // normal operation, so this is pinned here rather than assumed.
  const ID = '33333333-3333-3333-3333-333333333333';
  const { createMakerSdk, createNodeWorkspaceStorage } = require(BUNDLE);
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'view496-'));
  dirs.push(dir);
  const writes = [];
  // A deployed view as Dataverse returns it — note `description: null`, the shape a view that never
  // had one comes back as.
  const deployed = {
    savedqueryid: ID, name: 'Active Work Items', description: null,
    returnedtypecode: 'new_item', querytype: 0, isdefault: true,
    fetchxml: '<fetch><entity name="new_item"><attribute name="new_name"/></entity></fetch>',
    layoutxml: '<grid name="resultset" object="1" jump="new_name" select="1" icon="1" preview="1">'
      + '<row name="result" id="new_itemid"><cell name="new_name" width="150"/></row></grid>',
  };
  const sdk = createMakerSdk({
    workspaceStorage: createNodeWorkspaceStorage(dir),
    instanceUrl: 'https://contoso.crm.dynamics.com',
    httpClient: {
      get: async (url) => (/savedqueries\(/.test(String(url))
        ? { status: 200, headers: { etag: 'W/"1"' }, body: deployed }
        : { status: 200, headers: {}, body: { value: [] } }),
      post: async (url, body) => { writes.push({ verb: 'POST', url: String(url), body }); return { status: 200, headers: {}, body: {} }; },
      patch: async (url, body) => { writes.push({ verb: 'PATCH', url: String(url), body }); return { status: 204, headers: {}, body: {} }; },
      put: async () => ({ status: 204, headers: {}, body: {} }),
      delete: async () => ({ status: 204, headers: {}, body: {} }),
    },
  });
  await sdk.initWorkspace();

  await sdk.fetchArtifact('view', ID);
  const fetched = await sdk.getArtifact('view', ID);
  assert.strictEqual(fetched.description, '', 'the adapter must normalise a null description to "" — a missing key would make updateElement throw');

  await sdk.updateElement('view', ID, '/description', 'Authored text.');
  await sdk.pushArtifact('view', ID);

  const patch = writes.find((w) => w.verb === 'PATCH');
  assert.ok(patch, 'the view push must PATCH');
  assert.ok('description' in patch.body, `the push body must carry description; keys: ${Object.keys(patch.body).join(', ')}`);
  assert.strictEqual(patch.body.description, 'Authored text.');
});

const AUTHOR_PROSE = 'Handles field work orders end to end.';

// A real-bundle SDK wired just far enough for `createPersonaRole` to reach its `/roles` write.
// Two stubs are load-bearing and were both found by measuring:
//   * the root business unit is resolved with `_parentbusinessunitid_value eq null`;
//   * each entity's privilege must have a DISTINCT PrivilegeId, or the SDK refuses the role with
//     "share the Dataverse privilege ... but request different scopes" (the persona's own table is
//     user-scoped while the injected `appmodule` read is organization-scoped).
async function roleSdk() {
  const { createMakerSdk, createNodeWorkspaceStorage } = require(BUNDLE);
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'role-'));
  dirs.push(dir);
  const calls = [];
  const sdk = createMakerSdk({
    workspaceStorage: createNodeWorkspaceStorage(dir),
    instanceUrl: 'https://contoso.crm.dynamics.com',
    httpClient: {
      get: async (url) => {
        calls.push({ verb: 'GET', url: String(url) });
        if (/businessunits/i.test(url)) return { status: 200, headers: {}, body: { value: [{ businessunitid: '00000000-0000-0000-0000-0000000000b1' }] } };
        // e.g. EntityDefinitions(LogicalName='new_ticket')?$select=LogicalName,Privileges
        const ed = /EntityDefinitions\(LogicalName='([^']+)'\)/.exec(String(url));
        if (ed) {
          const logical = ed[1];
          const pid = logical === 'appmodule' ? '33333333-3333-3333-3333-333333333333' : '11111111-1111-1111-1111-111111111111';
          return { status: 200, headers: {}, body: { LogicalName: logical, Privileges: [{ PrivilegeId: pid, Name: `prvRead${logical}`, PrivilegeType: 'Read', CanBeBasic: true, CanBeLocal: true, CanBeDeep: true, CanBeGlobal: true }] } };
        }
        return { status: 200, headers: {}, body: { value: [] } };  // no existing role -> create path
      },
      post: async (url, body) => { calls.push({ verb: 'POST', url: String(url), body }); return { status: 204, headers: { 'odata-entityid': 'https://x/roles(22222222-2222-2222-2222-222222222222)' }, body: {} }; },
      patch: async (url, body) => { calls.push({ verb: 'PATCH', url: String(url), body }); return { status: 204, headers: {}, body: {} }; },
      put: async () => ({ status: 204, headers: {}, body: {} }),
      delete: async () => ({ status: 204, headers: {}, body: {} }),
    },
  });
  await sdk.initWorkspace();
  return { sdk, calls };
}

test('a persona NEVER sends a description — it would break the SDK ownership guard', async () => {
  // The bundle builds its role payload with its OWN marker as the description, and gates reuse on
  // an exact match of that marker, so a role carrying an author's prose is treated as somebody
  // else's role and the SDK THROWS ("already exists ... and was not created by the SDK; refusing to
  // modify or assign it"). Teardown and verify re-implement the same marker check, so all three
  // would disagree at once.
  const spec = personaRoleSpecFor({
    persona: 'Field Agent', description: AUTHOR_PROSE,
    jobs: [{ name: 'Job', privileges: [{ entity: 'new_ticket', access: ['read'], scope: 'user' }] }],
  });
  assert.ok(!('description' in spec), 'persona description must not be forwarded to createPersonaRole');

  // Proven against the REAL bundle by observing the wire, not by grepping it. The previous version
  // of this guard asserted the literal `description:It.SDK_ROLE_MARKER`, where `It` is a namespace
  // alias the MINIFIER assigns — it became `Pt` on the next re-vendor and the test failed for a
  // reason that had nothing to do with the behaviour it was protecting. Drive the call instead.
  const { sdk, calls } = await roleSdk();
  await sdk.createPersonaRole(spec);

  const create = calls.find((c) => c.verb === 'POST' && /\/roles$/.test(String(c.url)));
  assert.ok(create, `the role create must POST /roles; got ${JSON.stringify(calls.map((c) => `${c.verb} ${c.url}`))}`);
  assert.strictEqual(typeof create.body.description, 'string');
  assert.ok(create.body.description.length > 0,
    'the SDK still stamps a description of its own — if it stops, the exclusion below has no purpose and must be revisited');
  assert.match(create.body.description, /cds-maker-sdk/,
    `the description must be the SDK's ownership marker; got ${JSON.stringify(create.body.description)}`);

  // The decisive half: the author's prose reaches NOTHING on the wire.
  assert.strictEqual(JSON.stringify(calls).includes(AUTHOR_PROSE), false,
    'an author-supplied persona description must never reach the role write');

  // And the ownership gate really does read `description` back, which is why sending prose would
  // make the SDK disown its own role.
  const reuseQuery = calls.find((c) => c.verb === 'GET' && /\/roles\?/.test(String(c.url)));
  assert.ok(reuseQuery, 'the SDK must look for an existing role before creating one');
  assert.match(decodeURIComponent(String(reuseQuery.url)), /\$select=[^&]*description/,
    'the reuse gate selects description — that is the field the marker defends');
});