Skip to content
Merged
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
64 changes: 63 additions & 1 deletion build/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1453,12 +1453,15 @@ function neutralizeGithubControls(value) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PUBLICATION_REPLY_MARKER_PREFIX = exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = exports.PUBLICATION_MARKER_PREFIX = exports.PUBLICATION_SCHEMA = void 0;
exports.TRANSITION_FINGERPRINT_ACTIONS = exports.PUBLICATION_TRANSITION_MARKER_PREFIX = exports.PUBLICATION_REPLY_MARKER_PREFIX = exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = exports.PUBLICATION_MARKER_PREFIX = exports.PUBLICATION_SCHEMA = void 0;
exports.createSemanticDigest = createSemanticDigest;
exports.createTransitionFingerprint = createTransitionFingerprint;
exports.buildPublicationMarker = buildPublicationMarker;
exports.parsePublicationMarker = parsePublicationMarker;
exports.buildPublicationReplyMarker = buildPublicationReplyMarker;
exports.parsePublicationReplyMarker = parsePublicationReplyMarker;
exports.buildPublicationTransitionMarker = buildPublicationTransitionMarker;
exports.parsePublicationTransitionMarker = parsePublicationTransitionMarker;
exports.readablePublicationReplyCorrelationIds = readablePublicationReplyCorrelationIds;
exports.buildDuplicateMarker = buildDuplicateMarker;
const node_crypto_1 = __nccwpck_require__(6005);
Expand All @@ -1467,11 +1470,31 @@ exports.PUBLICATION_SCHEMA = '1';
exports.PUBLICATION_MARKER_PREFIX = 'copilot:publication';
exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = 'copilot:publication-duplicate';
exports.PUBLICATION_REPLY_MARKER_PREFIX = 'copilot:reply';
exports.PUBLICATION_TRANSITION_MARKER_PREFIX = 'copilot:transition';
exports.TRANSITION_FINGERPRINT_ACTIONS = Object.freeze([
'branch-sync-required',
]);
const SAFE_VALUE = /^[A-Za-z0-9._:-]{1,128}$/u;
const DIGEST = /^[a-f0-9]{8,64}$/u;
function createSemanticDigest(value) {
return (0, node_crypto_1.createHash)('sha256').update(stableSerialize(value), 'utf8').digest('hex').slice(0, 16);
}
/** Derives a notification identity exclusively from trusted, bounded transition facts. */
function createTransitionFingerprint(identity, action, sourceVersion) {
const target = (0, github_publication_1.publicationTargetToken)(identity.target);
for (const value of [identity.topic, target, identity.key, action, sourceVersion]) {
if (!SAFE_VALUE.test(value))
throw new Error('Transition fingerprint contains an unsafe identity value.');
}
if (!exports.TRANSITION_FINGERPRINT_ACTIONS.includes(action)) {
throw new Error('Transition fingerprint contains an unknown action.');
}
return createSemanticDigest({
action,
identity: { key: identity.key, target, topic: identity.topic },
sourceVersion,
});
}
function buildPublicationMarker(marker) {
const target = (0, github_publication_1.publicationTargetToken)(marker.identity.target);
for (const value of [marker.identity.topic, target, marker.identity.key, marker.sourceVersion]) {
Expand Down Expand Up @@ -1521,6 +1544,39 @@ function parsePublicationReplyMarker(body) {
return undefined;
return Object.freeze({ target: match[1], correlationId: match[2], messageKey: match[3], digest: match[4] });
}
function buildPublicationTransitionMarker(intent) {
const target = (0, github_publication_1.publicationTargetToken)(intent.identity.target);
for (const value of [intent.identity.topic, target, intent.identity.key, intent.messageKey]) {
if (!SAFE_VALUE.test(value))
throw new Error('Publication transition marker contains an unsafe identity value.');
}
if (!DIGEST.test(intent.fingerprint)) {
throw new Error('Publication transition marker contains an invalid fingerprint.');
}
return `<!-- ${exports.PUBLICATION_TRANSITION_MARKER_PREFIX} schema="${exports.PUBLICATION_SCHEMA}" topic="${intent.identity.topic}" target="${target}" key="${intent.identity.key}" fingerprint="${intent.fingerprint}" message="${intent.messageKey}" -->`;
}
function parsePublicationTransitionMarker(body) {
if (typeof body !== 'string')
return undefined;
const match = body.match(/<!-- copilot:transition schema="1" topic="([A-Za-z0-9._:-]{1,128})" target="(issue|pr):(\d+)" key="([A-Za-z0-9._:-]{1,128})" fingerprint="([a-f0-9]{8,64})" message="([A-Za-z0-9._:-]{1,128})" -->/u);
if (!match)
return undefined;
const topic = match[1];
if (!github_publication_1.PUBLICATION_TOPICS.includes(topic))
return undefined;
const number = Number(match[3]);
if (!Number.isSafeInteger(number) || number < 1)
return undefined;
return Object.freeze({
identity: Object.freeze({
topic,
target: Object.freeze({ kind: match[2] === 'pr' ? 'pull-request' : 'issue', number }),
key: match[4],
}),
fingerprint: match[5],
messageKey: match[6],
});
}
/**
* Reads the stable issue-comment identity plus the short-lived namespaced form
* emitted during migration. Review-comment identities remain transport-scoped.
Expand Down Expand Up @@ -5239,6 +5295,12 @@ function publicationIdentityEquals(left, right) {
&& left.key === right.key;
}
function publicationTargetToken(target) {
if (target.kind !== 'issue' && target.kind !== 'pull-request') {
throw new Error('Publication target kind must be issue or pull-request.');
}
if (!Number.isSafeInteger(target.number) || target.number < 1) {
throw new Error('Publication target number must be a positive safe integer.');
}
return `${target.kind === 'pull-request' ? 'pr' : 'issue'}:${target.number}`;
}

Expand Down
110 changes: 109 additions & 1 deletion build/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43983,12 +43983,15 @@ function progressPercentToColor(percent) {
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PUBLICATION_REPLY_MARKER_PREFIX = exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = exports.PUBLICATION_MARKER_PREFIX = exports.PUBLICATION_SCHEMA = void 0;
exports.TRANSITION_FINGERPRINT_ACTIONS = exports.PUBLICATION_TRANSITION_MARKER_PREFIX = exports.PUBLICATION_REPLY_MARKER_PREFIX = exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = exports.PUBLICATION_MARKER_PREFIX = exports.PUBLICATION_SCHEMA = void 0;
exports.createSemanticDigest = createSemanticDigest;
exports.createTransitionFingerprint = createTransitionFingerprint;
exports.buildPublicationMarker = buildPublicationMarker;
exports.parsePublicationMarker = parsePublicationMarker;
exports.buildPublicationReplyMarker = buildPublicationReplyMarker;
exports.parsePublicationReplyMarker = parsePublicationReplyMarker;
exports.buildPublicationTransitionMarker = buildPublicationTransitionMarker;
exports.parsePublicationTransitionMarker = parsePublicationTransitionMarker;
exports.readablePublicationReplyCorrelationIds = readablePublicationReplyCorrelationIds;
exports.buildDuplicateMarker = buildDuplicateMarker;
const node_crypto_1 = __nccwpck_require__(6005);
Expand All @@ -43997,11 +44000,31 @@ exports.PUBLICATION_SCHEMA = '1';
exports.PUBLICATION_MARKER_PREFIX = 'copilot:publication';
exports.PUBLICATION_DUPLICATE_MARKER_PREFIX = 'copilot:publication-duplicate';
exports.PUBLICATION_REPLY_MARKER_PREFIX = 'copilot:reply';
exports.PUBLICATION_TRANSITION_MARKER_PREFIX = 'copilot:transition';
exports.TRANSITION_FINGERPRINT_ACTIONS = Object.freeze([
'branch-sync-required',
]);
const SAFE_VALUE = /^[A-Za-z0-9._:-]{1,128}$/u;
const DIGEST = /^[a-f0-9]{8,64}$/u;
function createSemanticDigest(value) {
return (0, node_crypto_1.createHash)('sha256').update(stableSerialize(value), 'utf8').digest('hex').slice(0, 16);
}
/** Derives a notification identity exclusively from trusted, bounded transition facts. */
function createTransitionFingerprint(identity, action, sourceVersion) {
const target = (0, github_publication_1.publicationTargetToken)(identity.target);
for (const value of [identity.topic, target, identity.key, action, sourceVersion]) {
if (!SAFE_VALUE.test(value))
throw new Error('Transition fingerprint contains an unsafe identity value.');
}
if (!exports.TRANSITION_FINGERPRINT_ACTIONS.includes(action)) {
throw new Error('Transition fingerprint contains an unknown action.');
}
return createSemanticDigest({
action,
identity: { key: identity.key, target, topic: identity.topic },
sourceVersion,
});
}
function buildPublicationMarker(marker) {
const target = (0, github_publication_1.publicationTargetToken)(marker.identity.target);
for (const value of [marker.identity.topic, target, marker.identity.key, marker.sourceVersion]) {
Expand Down Expand Up @@ -44051,6 +44074,39 @@ function parsePublicationReplyMarker(body) {
return undefined;
return Object.freeze({ target: match[1], correlationId: match[2], messageKey: match[3], digest: match[4] });
}
function buildPublicationTransitionMarker(intent) {
const target = (0, github_publication_1.publicationTargetToken)(intent.identity.target);
for (const value of [intent.identity.topic, target, intent.identity.key, intent.messageKey]) {
if (!SAFE_VALUE.test(value))
throw new Error('Publication transition marker contains an unsafe identity value.');
}
if (!DIGEST.test(intent.fingerprint)) {
throw new Error('Publication transition marker contains an invalid fingerprint.');
}
return `<!-- ${exports.PUBLICATION_TRANSITION_MARKER_PREFIX} schema="${exports.PUBLICATION_SCHEMA}" topic="${intent.identity.topic}" target="${target}" key="${intent.identity.key}" fingerprint="${intent.fingerprint}" message="${intent.messageKey}" -->`;
}
function parsePublicationTransitionMarker(body) {
if (typeof body !== 'string')
return undefined;
const match = body.match(/<!-- copilot:transition schema="1" topic="([A-Za-z0-9._:-]{1,128})" target="(issue|pr):(\d+)" key="([A-Za-z0-9._:-]{1,128})" fingerprint="([a-f0-9]{8,64})" message="([A-Za-z0-9._:-]{1,128})" -->/u);
if (!match)
return undefined;
const topic = match[1];
if (!github_publication_1.PUBLICATION_TOPICS.includes(topic))
return undefined;
const number = Number(match[3]);
if (!Number.isSafeInteger(number) || number < 1)
return undefined;
return Object.freeze({
identity: Object.freeze({
topic,
target: Object.freeze({ kind: match[2] === 'pr' ? 'pull-request' : 'issue', number }),
key: match[4],
}),
fingerprint: match[5],
messageKey: match[6],
});
}
/**
* Reads the stable issue-comment identity plus the short-lived namespaced form
* emitted during migration. Review-comment identities remain transport-scoped.
Expand Down Expand Up @@ -44460,8 +44516,12 @@ exports.buildStaleSourcePublicationPayload = buildStaleSourcePublicationPayload;
exports.hasStaleSourcePublicationOutcome = hasStaleSourcePublicationOutcome;
exports.buildDuplicateCompactionPublicationPayload = buildDuplicateCompactionPublicationPayload;
exports.duplicateCompactionPublicationOutcomes = duplicateCompactionPublicationOutcomes;
exports.buildTransitionPublicationPayload = buildTransitionPublicationPayload;
exports.transitionPublicationOutcomes = transitionPublicationOutcomes;
const result_1 = __nccwpck_require__(73817);
const github_publication_1 = __nccwpck_require__(35793);
const MAX_REPORTED_COMMENT_IDS = 20;
const MAX_REPORTED_TRANSITIONS = 20;
/** Builds bounded evidence for a commit-derived result that was intentionally suppressed. */
function buildStaleSourcePublicationPayload(branch, sourceHeadSha) {
return Object.freeze({
Expand Down Expand Up @@ -44511,6 +44571,48 @@ function duplicateCompactionPublicationOutcomes(results) {
})];
}));
}
/** Builds content-free, bounded evidence for one action-notification decision. */
function buildTransitionPublicationPayload(intent, effect) {
return Object.freeze({
publicationTransition: Object.freeze({
topic: intent.identity.topic,
target: (0, github_publication_1.publicationTargetToken)(intent.identity.target),
effect,
fingerprint: intent.fingerprint,
}),
});
}
function transitionPublicationOutcomes(results) {
return Object.freeze(results.flatMap(result => {
if (!result.success || !result.executed)
return [];
const payload = (0, result_1.getResultPayload)(result.payload);
const transition = (0, result_1.getResultPayload)(payload?.publicationTransition);
if (!transition
|| typeof transition.topic !== 'string'
|| !github_publication_1.PUBLICATION_TOPICS.includes(transition.topic)
|| typeof transition.target !== 'string'
|| !isPublicationTargetToken(transition.target)
|| transition.effect !== 'created' && transition.effect !== 'unchanged'
|| typeof transition.fingerprint !== 'string'
|| !/^[a-f0-9]{8,64}$/u.test(transition.fingerprint)) {
return [];
}
return [Object.freeze({
topic: transition.topic,
target: transition.target,
effect: transition.effect,
fingerprint: transition.fingerprint,
})];
}).slice(0, MAX_REPORTED_TRANSITIONS));
}
function isPublicationTargetToken(value) {
const match = value.match(/^(?:issue|pr):([1-9]\d*)$/u);
if (!match)
return false;
const number = Number(match[1]);
return Number.isSafeInteger(number) && number > 0;
}
function isPositiveInteger(value) {
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0;
}
Expand Down Expand Up @@ -73816,6 +73918,12 @@ function publicationIdentityEquals(left, right) {
&& left.key === right.key;
}
function publicationTargetToken(target) {
if (target.kind !== 'issue' && target.kind !== 'pull-request') {
throw new Error('Publication target kind must be issue or pull-request.');
}
if (!Number.isSafeInteger(target.number) || target.number < 1) {
throw new Error('Publication target number must be a positive safe integer.');
}
return `${target.kind === 'pull-request' ? 'pr' : 'issue'}:${target.number}`;
}

Expand Down
Loading