/** * @module pr.respec * * Respec test suite for Pull Request ingestion, cryptographic Sync Delegate Keystone * verification, admission policy gating, and AOT targets index synchronization. */ import { respecfully, ifWe, iReckon, } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs'; import { getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs'; import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs'; import { createInMemoryTempMetaspaceAndSpace } from '../../witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs'; import { getIbGibFromSpace, getTjpAddr } from '../../common/other/ibgib-helper.mjs'; import { KeystoneService_V1 } from '../../keystone/keystone-service-v1.mjs'; import { createStandardPoolConfig } from '../../keystone/keystone-config-builder.mjs'; import { KEYSTONE_VERB_AUTHOR, KEYSTONE_VERB_SYNC, POOL_ID_DEFAULT, POOL_ID_MANAGE, } from '../../keystone/keystone-constants.mjs'; import { KEYSTONE_ROLE_AUTHOR_DELEGATE } from '../../keystone/delegate/delegate-constants.mjs'; import { createCosmosIbGib, setPermissionPolicy } from '../cosmos/cosmos-helpers.mjs'; import { executeVcsInit } from '../branching/commands/core-init-cmd.mjs'; import { getFileItemFromPath } from '../branching/item/item-helpers.mjs'; import { getTargetAnchorsForFile } from '../metatext/metatext-helpers.mjs'; import { TARGETS_INDEX_FILE_PATH } from '../metatext/metatext-constants.mjs'; import { approvePullRequest, createPullRequestIbGib, getStagedPullRequests, ingestPullRequestCommit, rejectPullRequest, validateSyncDelegateKeystone, } from './pr-helpers.mjs'; import { PullRequestSubmission } from './pr-types.mjs'; import { PR_STATUS_AUTO_MERGED, PR_STATUS_MERGED, PR_STATUS_PENDING, PR_STATUS_REJECTED } from './pr-constants.mjs'; const lc = `[core-gib/src/cosmology/pr/pr.respec.mts]`; await respecfully(lc, `Pull Request & Admission Gate Specs`, async () => { await respecfully(lc, `Cryptographic Sync Delegate Keystone Verification`, async () => { // Server space: simulates ibgib.space authority space const { metaspace, space } = await createInMemoryTempMetaspaceAndSpace(); // Client space: simulates Alice's / Bob's device space const { metaspace: clientMetaspace, space: clientSpace } = await createInMemoryTempMetaspaceAndSpace(); const keystoneService = new KeystoneService_V1(); const parentSecret = "ParentSecret_Alice_12345"; const salt = (await getUUID()).substring(0, 16); const parentDefaultConfig = createStandardPoolConfig({ id: POOL_ID_DEFAULT, salt }); const parentManageConfig = createStandardPoolConfig({ id: POOL_ID_MANAGE, salt: salt + "_manage" }); // 1. Create Parent Identity (Alice) in server space const parentKeystone = await keystoneService.genesis({ masterSecret: parentSecret, configs: [parentDefaultConfig, parentManageConfig], metaspace, space, }); const parentTjp = getTjpAddr({ ibGib: parentKeystone })!; // 2. Create Delegate Keystone (Session / Device) on client const delegateSecret = "DelegateSecret_Device_67890"; const delegateConfig = createStandardPoolConfig({ id: POOL_ID_DEFAULT, salt: salt + "_delegate" }); const delegateKeystone = await keystoneService.genesis({ masterSecret: delegateSecret, configs: [delegateConfig], metaspace: clientMetaspace, space: clientSpace, }); const delegateTjp = getTjpAddr({ ibGib: delegateKeystone })!; // Register delegate in server space at n=0 await metaspace.put({ ibGibs: [delegateKeystone], space }); await metaspace.registerNewIbGib({ ibGib: delegateKeystone, space }); // 3. Register Delegate under Parent Identity on server await keystoneService.registerDelegate({ parentKeystone, delegateKeystone, masterSecret: parentSecret, signingPoolId: POOL_ID_MANAGE, metaspace, space, allowedVerbs: [KEYSTONE_VERB_SYNC], }); const targetCommitAddr = "b2tfs_branch metatext-1 main^abc123def4567890"; await ifWe(lc, `validates a legitimate evolved sync delegate keystone (n -> n+1)`, async () => { // Client evolves delegate n=0 -> n=1 in client space const evolvedDelegate = await keystoneService.sign({ latestKeystone: delegateKeystone, masterSecret: delegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: targetCommitAddr, }, metaspace: clientMetaspace, space: clientSpace, }); // Server validates incoming n=1 against its space (which has n=0) const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: evolvedDelegate, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: targetCommitAddr, metaspace, space, }); iReckon(lc, result.isValid).asTo('valid keystone').isGonnaBeTrue(); iReckon(lc, result.delegateTjpAddr).asTo('delegate TJP').willEqual(delegateTjp); }); await ifWe(lc, `rejects replay attack with identical keystone frame`, async () => { // Replay the exact same frame that the server already persisted and burned at n=1 const serverLatest = await keystoneService.getLatestKeystone({ addr: delegateTjp, metaspace, space, }); const replayResult = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: serverLatest, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: targetCommitAddr, metaspace, space, }); iReckon(lc, replayResult.isValid).asTo('replay rejected').isGonnaBeFalse(); iReckon(lc, replayResult.error?.toLowerCase().includes('transition validation failed')).asTo('transition error').isGonnaBeTrue(); }); await ifWe(lc, `rejects keystone with forged or tampered intrinsic hash`, async () => { const clientLatest = await keystoneService.getLatestKeystone({ addr: delegateTjp, metaspace: clientMetaspace, space: clientSpace, }); // Client evolves to n=2 in client space const evolved = await keystoneService.sign({ latestKeystone: clientLatest, masterSecret: delegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: targetCommitAddr, }, metaspace: clientMetaspace, space: clientSpace, }); // Tamper with data without recalculating gib const tampered = JSON.parse(JSON.stringify(evolved)); tampered.data.proofs[0].claim.target = "tampered_target_addr"; const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: tampered, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: targetCommitAddr, metaspace, space, }); iReckon(lc, result.isValid).asTo('tampered rejected').isGonnaBeFalse(); iReckon(lc, result.error?.toLowerCase().includes('intrinsic validation failed')).asTo('intrinsic error').isGonnaBeTrue(); }); await ifWe(lc, `rejects keystone with unauthorized verb`, async () => { const clientLatest = await keystoneService.getLatestKeystone({ addr: delegateTjp, metaspace: clientMetaspace, space: clientSpace, }); const evolvedWithWrongVerb = await keystoneService.sign({ latestKeystone: clientLatest, masterSecret: delegateSecret, claim: { verb: "unauthorized_verb", target: targetCommitAddr, }, metaspace: clientMetaspace, space: clientSpace, }); const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: evolvedWithWrongVerb, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: targetCommitAddr, metaspace, space, }); iReckon(lc, result.isValid).asTo('wrong verb rejected').isGonnaBeFalse(); iReckon(lc, result.error?.includes('Claim verb must be one of')).asTo('verb error').isGonnaBeTrue(); }); await ifWe(lc, `rejects keystone when target candidate does not match expected target`, async () => { const clientLatest = await keystoneService.getLatestKeystone({ addr: delegateTjp, metaspace: clientMetaspace, space: clientSpace, }); const evolved = await keystoneService.sign({ latestKeystone: clientLatest, masterSecret: delegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: "b2tfs_branch metatext-1 main^different_commit", }, metaspace: clientMetaspace, space: clientSpace, }); const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: evolved, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: targetCommitAddr, metaspace, space, }); iReckon(lc, result.isValid).asTo('target mismatch rejected').isGonnaBeFalse(); iReckon(lc, result.error?.includes('does not match expected target')).asTo('target error').isGonnaBeTrue(); }); await ifWe(lc, `rejects keystone from unregistered parent identity`, async () => { const fakeParentTjp = "keystone fake_alice^fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210"; const clientLatest = await keystoneService.getLatestKeystone({ addr: delegateTjp, metaspace: clientMetaspace, space: clientSpace, }); const evolved = await keystoneService.sign({ latestKeystone: clientLatest, masterSecret: delegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: targetCommitAddr, }, metaspace: clientMetaspace, space: clientSpace, }); const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: evolved, authorPrimaryTjpAddr: fakeParentTjp, metaspace, space, }); iReckon(lc, result.isValid).asTo('unregistered rejected').isGonnaBeFalse(); iReckon(lc, result.error?.includes('not registered under author identity')).asTo('lineage error').isGonnaBeTrue(); }); await ifWe(lc, `validates a legitimate evolved author delegate keystone (role: author-delegate, verb: author)`, async () => { // Create Author Delegate Keystone const authorDelegateSecret = "AuthorDelegateSecret_Device_11111"; const authorDelegateConfig = createStandardPoolConfig({ id: 'author', salt: salt + "_author_delegate", verbs: [KEYSTONE_VERB_AUTHOR], }); const authorDelegateKeystone = await keystoneService.genesis({ masterSecret: authorDelegateSecret, configs: [authorDelegateConfig], metaspace: clientMetaspace, space: clientSpace, frameDetails: { role: KEYSTONE_ROLE_AUTHOR_DELEGATE, }, }); const authorDelegateTjp = getTjpAddr({ ibGib: authorDelegateKeystone })!; // Register in server space await metaspace.put({ ibGibs: [authorDelegateKeystone], space }); await metaspace.registerNewIbGib({ ibGib: authorDelegateKeystone, space }); // Register Author Delegate under Parent Identity on server const latestParent = await keystoneService.getLatestKeystone({ addr: parentTjp, metaspace, space, }); await keystoneService.registerDelegate({ parentKeystone: latestParent, delegateKeystone: authorDelegateKeystone, masterSecret: parentSecret, signingPoolId: POOL_ID_MANAGE, metaspace, space, allowedVerbs: [KEYSTONE_VERB_AUTHOR], }); // Author signs comment file item with author delegate const commentFileAddr = "b2t_item 2026-10-02_alice_comment.md^abc123456"; const evolvedAuthor = await keystoneService.sign({ latestKeystone: authorDelegateKeystone, masterSecret: authorDelegateSecret, poolId: 'author', claim: { verb: KEYSTONE_VERB_AUTHOR, target: commentFileAddr, }, metaspace: clientMetaspace, space: clientSpace, }); const result = await validateSyncDelegateKeystone({ evolvedSyncDelegateKeystone: evolvedAuthor, authorPrimaryTjpAddr: parentTjp, expectedTargetAddr: commentFileAddr, allowedVerbs: [KEYSTONE_VERB_AUTHOR, 'author'], metaspace, space, }); iReckon(lc, result.isValid).asTo('author delegate valid').isGonnaBeTrue(); iReckon(lc, result.statusCode).asTo('author status 200').willEqual(200); }); }); await respecfully(lc, `Ingestion Gate with Admission Policies & AOT Targets Index`, async () => { // Server space const { metaspace, space } = await createInMemoryTempMetaspaceAndSpace(); // Bob's client device space const { metaspace: bobMetaspace, space: bobSpace } = await createInMemoryTempMetaspaceAndSpace(); const keystoneService = new KeystoneService_V1(); // 1. Create Owner Identity (Alice) const ownerSecret = "AliceOwnerSecret_99999"; const salt = (await getUUID()).substring(0, 16); const ownerKeystone = await keystoneService.genesis({ masterSecret: ownerSecret, configs: [createStandardPoolConfig({ id: POOL_ID_DEFAULT, salt })], metaspace, space, }); const ownerTjp = getTjpAddr({ ibGib: ownerKeystone })!; // 2. Create Contributor Identity (Bob) on server const bobSecret = "BobContributorSecret_88888"; const bobParent = await keystoneService.genesis({ masterSecret: bobSecret, configs: [ createStandardPoolConfig({ id: POOL_ID_DEFAULT, salt: salt + "_bob" }), createStandardPoolConfig({ id: POOL_ID_MANAGE, salt: salt + "_bob_manage" }), ], metaspace, space, }); const bobTjp = getTjpAddr({ ibGib: bobParent })!; // Create Bob's delegate on Bob's client space const bobDelegateSecret = "BobDelegateSecret_77777"; const bobDelegate = await keystoneService.genesis({ masterSecret: bobDelegateSecret, configs: [createStandardPoolConfig({ id: POOL_ID_DEFAULT, salt: salt + "_bob_del" })], metaspace: bobMetaspace, space: bobSpace, }); const bobDelegateTjp = getTjpAddr({ ibGib: bobDelegate })!; // Register Bob's delegate on server at n=0 await metaspace.put({ ibGibs: [bobDelegate], space }); await metaspace.registerNewIbGib({ ibGib: bobDelegate, space }); await keystoneService.registerDelegate({ parentKeystone: bobParent, delegateKeystone: bobDelegate, masterSecret: bobSecret, signingPoolId: POOL_ID_MANAGE, metaspace, space, allowedVerbs: [KEYSTONE_VERB_SYNC], }); // 3. Initialize Cosmos and Metatext Galaxy const cosmos = await createCosmosIbGib({ cosmosName: 'demo-cosmos', ownerKeystoneTjp: ownerTjp, space, metaspace, }); const initResult = await executeVcsInit({ metaspace, localSpace: space, galaxyName: 'metatext-1', branchName: 'main', }); const { branchSpace, branchIbGib, galaxyIbGib } = initResult; await ifWe(lc, `auto-merges comment commit and updates index/targets.json on public-open policy`, async () => { // Set policy to public-open const currentCosmos = await setPermissionPolicy({ cosmosIbGib: cosmos, policy: { galaxyName: 'metatext-1', branchName: 'main', access: 'public-open', }, space, metaspace, }); // Bob signs submission in Bob's client space (n=0 -> n=1) const evolvedBobDelegate = await keystoneService.sign({ latestKeystone: bobDelegate, masterSecret: bobDelegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: 'b2tfs_item file 2026-10-01T18-05-00Z_bob.md^target111', }, metaspace: bobMetaspace, space: bobSpace, }); const commentPath = 'topics/general/2026-10-01T18-05-00Z_bob.md'; const commentContent = `# Discussion on Utils I agree with the implementation in [utils.mts](https://ibgib.space/@alice/demo-cosmos/code-1/main/src/utils.mts#L12-L24). It is very concise. `; const submission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file 2026-10-01T18-05-00Z_bob.md^target111', candidateChanges: [{ path: commentPath, content: commentContent, status: 'untracked', }], summary: 'Bob comments on utils.mts', authorPrimaryTjpAddr: bobTjp, authorHandle: '@bob', evolvedSyncDelegateKeystone: evolvedBobDelegate, }; const result = await ingestPullRequestCommit({ cosmosIbGib: currentCosmos, submission, galaxyIbGib, branchSpace, space, metaspace, }); iReckon(lc, result.isAuthorized).asTo('authorized').isGonnaBeTrue(); iReckon(lc, result.status).asTo('status').willEqual(PR_STATUS_AUTO_MERGED); iReckon(lc, result.mergedCommitAddr).asTo('new tip addr').isGonnaBeTruthy(); // Also check AOT index was created and contains the anchor iReckon(lc, result.updatedTargetsIndex).asTo('updated targets index').isGonnaBeTruthy(); const anchors = getTargetAnchorsForFile({ indexData: result.updatedTargetsIndex!, filePath: 'src/utils.mts', galaxyName: 'code-1', }); iReckon(lc, anchors.length).asTo('target anchor records found').willEqual(1); iReckon(lc, anchors[0].filePath).willEqual(commentPath); iReckon(lc, anchors[0].lineRange).asTo('line range [12, 24]').willEqual([12, 24]); iReckon(lc, anchors[0].author).willEqual('@bob'); // Verify index file was committed to branch const rootAddr = result.updatedBranch?.rel8ns?.b2tfs_item?.at(-1); const rootItem = rootAddr ? await getIbGibFromSpace({ addr: rootAddr, space: branchSpace }) : undefined; const indexFileItem = rootItem ? await getFileItemFromPath({ branchSpace, rootItem: rootItem as any, filePath: TARGETS_INDEX_FILE_PATH, }) : undefined; iReckon(lc, indexFileItem).asTo('index/targets.json committed').isGonnaBeTruthy(); }); await ifWe(lc, `stages PR in pending queue when policy is moderated, without modifying branch`, async () => { // Set policy to moderated const moderatedCosmos = await setPermissionPolicy({ cosmosIbGib: cosmos, policy: { galaxyName: 'metatext-1', branchName: 'main', access: 'moderated', }, space, metaspace, }); // Bob signs new submission in Bob's client space (n=1 -> n=2) const latestBobDelegate = await keystoneService.getLatestKeystone({ addr: bobDelegateTjp, metaspace: bobMetaspace, space: bobSpace, }); const evolvedBobDelegate = await keystoneService.sign({ latestKeystone: latestBobDelegate, masterSecret: bobDelegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: 'b2tfs_item file 2026-10-01T19-00-00Z_bob.md^target222', }, metaspace: bobMetaspace, space: bobSpace, }); const moderatedCommentPath = 'topics/general/2026-10-01T19-00-00Z_bob.md'; const submission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file 2026-10-01T19-00-00Z_bob.md^target222', candidateChanges: [{ path: moderatedCommentPath, content: 'This needs maintainer approval before landing.', status: 'untracked', }], summary: 'Bob moderated suggestion', authorPrimaryTjpAddr: bobTjp, authorHandle: '@bob', evolvedSyncDelegateKeystone: evolvedBobDelegate, }; const result = await ingestPullRequestCommit({ cosmosIbGib: moderatedCosmos, submission, galaxyIbGib, branchSpace, space, metaspace, }); iReckon(lc, result.isAuthorized).asTo('not auto-authorized').isGonnaBeFalse(); iReckon(lc, result.status).asTo('status').willEqual('staged-pr'); iReckon(lc, result.pullRequest).asTo('staged PR stone created').isGonnaBeTruthy(); iReckon(lc, result.pullRequest?.data.status).willEqual(PR_STATUS_PENDING); // Verify PR is in cosmos staging rel8n const stagedPrs = await getStagedPullRequests({ cosmosIbGib: result.updatedCosmos!, space, metaspace, }); iReckon(lc, stagedPrs.length > 0).asTo('staged PR in cosmos').isGonnaBeTrue(); // Now maintainer (Alice/owner) approves the PR const approveResult = await approvePullRequest({ cosmosIbGib: result.updatedCosmos!, pullRequestIbGib: result.pullRequest!, reviewerKeystoneTjp: ownerTjp, galaxyIbGib, branchSpace, metaspace, localSpace: space, }); iReckon(lc, approveResult.isAuthorized).asTo('approval successful').isGonnaBeTrue(); iReckon(lc, approveResult.status).asTo('status auto-merged').willEqual(PR_STATUS_AUTO_MERGED); iReckon(lc, approveResult.pullRequest?.data.status).willEqual(PR_STATUS_MERGED); }); await ifWe(lc, `enforces allowlist policy: authorizes allowed contributors, rejects unlisted`, async () => { // Set allowlist with only Bob const allowlistCosmos = await setPermissionPolicy({ cosmosIbGib: cosmos, policy: { galaxyName: 'metatext-1', branchName: 'main', access: 'allowlist', allowedKeystones: [bobTjp], }, space, metaspace, }); // Bob signs on client (n=2 -> n=3) const latestBobDelegate = await keystoneService.getLatestKeystone({ addr: bobDelegateTjp, metaspace: bobMetaspace, space: bobSpace, }); const bobEvolved = await keystoneService.sign({ latestKeystone: latestBobDelegate, masterSecret: bobDelegateSecret, claim: { verb: KEYSTONE_VERB_SYNC, target: 'b2tfs_item file allowlist_bob.md^target333', }, metaspace: bobMetaspace, space: bobSpace, }); const bobSubmission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file allowlist_bob.md^target333', candidateChanges: [{ path: 'topics/general/allowlist_bob.md', content: 'Bob is on allowlist!', status: 'untracked', }], summary: 'Bob allowlist post', authorPrimaryTjpAddr: bobTjp, evolvedSyncDelegateKeystone: bobEvolved, }; const bobResult = await ingestPullRequestCommit({ cosmosIbGib: allowlistCosmos, submission: bobSubmission, galaxyIbGib, branchSpace, space, metaspace, }); iReckon(lc, bobResult.isAuthorized).asTo('bob allowed').isGonnaBeTrue(); iReckon(lc, bobResult.status).willEqual(PR_STATUS_AUTO_MERGED); // Stranger (Mallory) is NOT on allowlist -> rejected const malloryTjp = "keystone mallory^0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff"; const mallorySubmission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file mallory.md^target444', candidateChanges: [{ path: 'topics/general/mallory.md', content: 'Stranger post', status: 'untracked', }], summary: 'Mallory uninvited post', authorPrimaryTjpAddr: malloryTjp, }; const malloryResult = await ingestPullRequestCommit({ cosmosIbGib: allowlistCosmos, submission: mallorySubmission, galaxyIbGib, branchSpace, space, metaspace, skipKeystoneVerification: true, // test policy gate directly }); iReckon(lc, malloryResult.isAuthorized).asTo('mallory rejected').isGonnaBeFalse(); iReckon(lc, malloryResult.status).willEqual('rejected'); iReckon(lc, malloryResult.reason?.includes('not on the allowed contributors list')).isGonnaBeTrue(); }); await ifWe(lc, `enforces admin-only policy: allows owner, rejects non-owner`, async () => { const adminCosmos = await setPermissionPolicy({ cosmosIbGib: cosmos, policy: { galaxyName: 'metatext-1', branchName: 'main', access: 'admin-only', }, space, metaspace, }); // Owner (Alice) is authorized const aliceSubmission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file announcement.md^target555', candidateChanges: [{ path: 'topics/general/announcement.md', content: 'Admin announcement', status: 'untracked', }], summary: 'Admin announcement', authorPrimaryTjpAddr: ownerTjp, }; const ownerResult = await ingestPullRequestCommit({ cosmosIbGib: adminCosmos, submission: aliceSubmission, galaxyIbGib, branchSpace, space, metaspace, skipKeystoneVerification: true, }); iReckon(lc, ownerResult.isAuthorized).asTo('owner authorized').isGonnaBeTrue(); iReckon(lc, ownerResult.status).willEqual(PR_STATUS_AUTO_MERGED); // Non-owner (Bob) is rejected const bobSubmission: PullRequestSubmission = { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', candidateCommitAddr: 'b2tfs_item file bob_try.md^target666', candidateChanges: [{ path: 'topics/general/bob_try.md', content: 'Trying to post to admin topic', status: 'untracked', }], summary: 'Bob unauthorized post', authorPrimaryTjpAddr: bobTjp, }; const nonOwnerResult = await ingestPullRequestCommit({ cosmosIbGib: adminCosmos, submission: bobSubmission, galaxyIbGib, branchSpace, space, metaspace, skipKeystoneVerification: true, }); iReckon(lc, nonOwnerResult.isAuthorized).asTo('non-owner rejected').isGonnaBeFalse(); iReckon(lc, nonOwnerResult.status).willEqual('rejected'); iReckon(lc, nonOwnerResult.reason?.includes('restricted to the cosmos owner')).isGonnaBeTrue(); }); await ifWe(lc, `rejects a staged pull request with maintainer reason`, async () => { const stagedPr = await createPullRequestIbGib({ submission: { targetCosmosName: 'demo-cosmos', targetGalaxyName: 'metatext-1', targetBranchName: 'main', summary: 'Spam comment', authorPrimaryTjpAddr: bobTjp, }, status: PR_STATUS_PENDING, space, metaspace, }); const rejectedPr = await rejectPullRequest({ pullRequestIbGib: stagedPr, reviewerKeystoneTjp: ownerTjp, reason: 'Violates community guidelines / off-topic.', space, metaspace, }); iReckon(lc, rejectedPr.data.status).willEqual(PR_STATUS_REJECTED); iReckon(lc, rejectedPr.data.rejectionReason).willEqual('Violates community guidelines / off-topic.'); iReckon(lc, rejectedPr.data.reviewerKeystoneTjp).willEqual(ownerTjp); iReckon(lc, rejectedPr.data.reviewedAt).isGonnaBeTruthy(); }); }); });