@defrex/autobuild 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SPEC.md +25 -3
- package/docs/architecture.md +4 -0
- package/docs/integration-tree.md +4 -2
- package/docs/remote-store-protocol.md +5 -0
- package/docs/remote-ticket-protocol.md +5 -0
- package/docs/setup.md +4 -0
- package/docs/spec-standard.md +71 -0
- package/docs/ticket-migration.md +50 -4
- package/package.json +3 -3
- package/packages/core/src/cli/build-control.ts +3 -3
- package/packages/core/src/cli/dashboard/integration-detail.ts +8 -6
- package/packages/core/src/cli/dashboard/integration-row.ts +15 -8
- package/packages/core/src/cli/dashboard/model.ts +7 -0
- package/packages/core/src/cli/dispatch-frontend.ts +5 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +2 -1
- package/packages/core/src/cli/dispatch.ts +5 -0
- package/packages/core/src/cli/help.ts +1 -0
- package/packages/core/src/cli/main.ts +11 -8
- package/packages/core/src/cli/repository-status.ts +7 -1
- package/packages/core/src/cli/ticket.ts +35 -11
- package/packages/core/src/events/payloads.ts +2 -0
- package/packages/core/src/events/policy.ts +1 -0
- package/packages/core/src/events/repository.ts +21 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +4025 -3978
- package/packages/core/src/kernel/change-presence.ts +7 -1
- package/packages/core/src/kernel/dispatch-capacity.ts +12 -4
- package/packages/core/src/kernel/integration-completeness.ts +54 -16
- package/packages/core/src/kernel/node-parent.ts +35 -10
- package/packages/core/src/kernel/read-facts.ts +7 -0
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +1 -1
- package/packages/core/src/kernel/ticket-migrations.ts +139 -0
- package/packages/core/src/operator/query.ts +7 -1
- package/packages/core/src/operator/tickets.ts +30 -26
- package/packages/core/src/ports/tickets/linear.ts +180 -12
- package/packages/core/src/ports/tickets/migration.ts +92 -9
- package/packages/core/src/ports/types.ts +7 -0
- package/packages/core/src/processes/dispatcher.ts +164 -36
- package/packages/core/src/store/contract.ts +30 -0
- package/packages/core/src/store/reducer-value-shapes.json +5735 -5642
- package/packages/core/src/store/repo-state-events.ts +3 -2
- package/packages/core/src/testing/dispatch-read-budget.ts +3 -2
- package/skills/guide/SKILL.md +3 -1
- package/skills/guide/references/integration-tree.md +4 -2
- package/skills/guide/references/remote-store-protocol.md +5 -0
- package/skills/guide/references/remote-ticket-protocol.md +5 -0
- package/skills/guide/references/setup.md +4 -0
- package/skills/guide/references/spec-standard.md +71 -0
- package/skills/guide/references/ticket-migration.md +50 -4
- package/skills/spec/SKILL.md +16 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { recordTicketMigration, readTicketMigrations } from '../kernel/ticket-migrations'
|
|
1
2
|
import { readTicketTree } from '../operator/tickets'
|
|
2
3
|
import { updateTicketTarget } from '../kernel/node-parent'
|
|
3
4
|
import { createForge } from '../ports/forge/create'
|
|
4
5
|
import { compatibleTicketSource, type TicketTreeEntry } from '../ports/tickets/tree'
|
|
5
6
|
import { readBuildFacts } from '../store/reduced-reads'
|
|
6
|
-
import { exportTickets, importTickets } from '../ports/tickets/migration'
|
|
7
|
+
import { exportTickets, importTickets, directMigration } from '../ports/tickets/migration'
|
|
7
8
|
import { composeTicketAssets } from '../store/ticket-assets'
|
|
8
9
|
import { editTicket, type TicketEditorRunner } from './ticket-editor'
|
|
9
10
|
/**
|
|
@@ -174,6 +175,7 @@ type TicketCommandName =
|
|
|
174
175
|
| 'tree'
|
|
175
176
|
| 'export'
|
|
176
177
|
| 'import'
|
|
178
|
+
| 'migration'
|
|
177
179
|
| 'states'
|
|
178
180
|
| 'state create'
|
|
179
181
|
| 'create'
|
|
@@ -787,6 +789,7 @@ const STATE_CREATE_USAGE = 'usage: ab ticket state create <name> [--about <text>
|
|
|
787
789
|
export const TICKET_USAGE = [
|
|
788
790
|
'usage: ab ticket export <dir> [--store <ref>]',
|
|
789
791
|
'usage: ab ticket import <dir> [--store <ref>]',
|
|
792
|
+
'usage: ab ticket migration record <dir> [--store <ref>]',
|
|
790
793
|
'usage: ab ticket tree [--json]',
|
|
791
794
|
CREATE_USAGE,
|
|
792
795
|
'usage: ab ticket edit <id> (§8.8)',
|
|
@@ -811,6 +814,7 @@ function commaList(value: string): string[] {
|
|
|
811
814
|
}
|
|
812
815
|
|
|
813
816
|
interface TicketCliOpts extends TicketCommandOpts {
|
|
817
|
+
signal?: AbortSignal
|
|
814
818
|
/** Required because the `list` subcommand can produce record diagnostics. */
|
|
815
819
|
stderr: (line: string) => void
|
|
816
820
|
}
|
|
@@ -820,22 +824,42 @@ interface TicketCliOpts extends TicketCommandOpts {
|
|
|
820
824
|
export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<void> {
|
|
821
825
|
const [command, ...args] = argv
|
|
822
826
|
switch (command) {
|
|
827
|
+
case 'migration':
|
|
823
828
|
case 'export':
|
|
824
829
|
case 'import': {
|
|
825
|
-
const
|
|
830
|
+
const tail = command === 'migration' ? args.slice(1) : args
|
|
831
|
+
if (command === 'migration' && args[0] !== 'record') throw new Error(TICKET_USAGE)
|
|
832
|
+
const parsed = parseArgs(tail, { store: 'value' }, TICKET_USAGE)
|
|
826
833
|
const [dir, ...extra] = parsed.positionals
|
|
827
834
|
if (!dir?.trim() || extra.length) throw new Error(TICKET_USAGE)
|
|
828
835
|
const migrationOpts = { ...opts, storeRef: stringFlag(parsed, 'store') ?? opts.storeRef }
|
|
829
836
|
const { source } = await resolveTicketCommand(migrationOpts, command)
|
|
830
|
-
await withTicketAssets(migrationOpts, source, ({ store, repo }) =>
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
837
|
+
await withTicketAssets(migrationOpts, source, async ({ store, buildStore, repo }) => {
|
|
838
|
+
const input = { source, assets: store, repo, dir, print: opts.stdout, signal: opts.signal }
|
|
839
|
+
if (command === 'export') return exportTickets(input)
|
|
840
|
+
await buildStore.ensureRepo(repo)
|
|
841
|
+
await readTicketMigrations(buildStore, repo)
|
|
842
|
+
const result =
|
|
843
|
+
command === 'import' ? await importTickets(input) : await directMigration(input)
|
|
844
|
+
try {
|
|
845
|
+
await recordTicketMigration(
|
|
846
|
+
buildStore,
|
|
847
|
+
repo,
|
|
848
|
+
{
|
|
849
|
+
kind: 'human',
|
|
850
|
+
user: opts.env.USER?.trim() || opts.env.USERNAME?.trim() || 'operator',
|
|
851
|
+
},
|
|
852
|
+
result,
|
|
853
|
+
)
|
|
854
|
+
} catch (error) {
|
|
855
|
+
throw new Error(
|
|
856
|
+
`Tickets imported/validated but continuity was not recorded: ${error instanceof Error ? error.message : error}. Rerun the same command to retry safely.`,
|
|
857
|
+
)
|
|
858
|
+
}
|
|
859
|
+
opts.stdout(
|
|
860
|
+
`recorded ticket migration ${result.from} → ${result.to}: ${Object.keys(result.mapping).length} tickets`,
|
|
861
|
+
)
|
|
862
|
+
})
|
|
839
863
|
return
|
|
840
864
|
}
|
|
841
865
|
|
|
@@ -438,6 +438,7 @@ export const eventPayloadSchemas = {
|
|
|
438
438
|
}),
|
|
439
439
|
'integration.abandoned': z.strictObject({ id: z.string().min(1), reason: z.string().min(1) }),
|
|
440
440
|
'integration.observed': z.strictObject({
|
|
441
|
+
membershipSource: z.string().optional(),
|
|
441
442
|
openChildren: z.array(z.string()),
|
|
442
443
|
diagnostics: z.array(z.string()),
|
|
443
444
|
contributions: z.array(z.string()),
|
|
@@ -448,6 +449,7 @@ export const eventPayloadSchemas = {
|
|
|
448
449
|
id: z.string(),
|
|
449
450
|
title: z.string().optional(),
|
|
450
451
|
builds: z.array(z.string()).optional(),
|
|
452
|
+
claims: z.array(z.string()).optional(),
|
|
451
453
|
}),
|
|
452
454
|
)
|
|
453
455
|
.optional(),
|
|
@@ -140,6 +140,7 @@ export const buildEventPolicy = {
|
|
|
140
140
|
'phase.deferral-escalated': 'decisive',
|
|
141
141
|
} satisfies Record<EventType, FactClassification>
|
|
142
142
|
export const repositoryEventPolicy = {
|
|
143
|
+
'tickets.migration-recorded': 'decisive',
|
|
143
144
|
'change-presence.observed': 'decisive',
|
|
144
145
|
'harvest.pause-requested': 'decisive',
|
|
145
146
|
'harvest.resume-requested': 'decisive',
|
|
@@ -546,7 +546,27 @@ export const forgeHealthEventPayloadSchemas = {
|
|
|
546
546
|
'dispatcher.forge-recovered': z.strictObject({ forge: z.string().min(1) }),
|
|
547
547
|
} as const
|
|
548
548
|
|
|
549
|
+
export const ticketMigrationEventPayloadSchemas = {
|
|
550
|
+
'tickets.migration-recorded': z
|
|
551
|
+
.strictObject({
|
|
552
|
+
identity: z.string().min(1),
|
|
553
|
+
from: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
554
|
+
to: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
555
|
+
mapping: z.record(z.string().min(1), z.string().min(1)),
|
|
556
|
+
})
|
|
557
|
+
.superRefine((value, ctx) => {
|
|
558
|
+
if (
|
|
559
|
+
value.from === value.to &&
|
|
560
|
+
Object.entries(value.mapping).some(([id, next]) => id !== next)
|
|
561
|
+
)
|
|
562
|
+
ctx.addIssue({ code: 'custom', message: 'migration sources must differ' })
|
|
563
|
+
if (new Set(Object.values(value.mapping)).size !== Object.keys(value.mapping).length)
|
|
564
|
+
ctx.addIssue({ code: 'custom', message: 'duplicate destination ticket id' })
|
|
565
|
+
}),
|
|
566
|
+
} as const
|
|
567
|
+
|
|
549
568
|
export const repositoryEventPayloadSchemas = {
|
|
569
|
+
...ticketMigrationEventPayloadSchemas,
|
|
550
570
|
...forgeHealthEventPayloadSchemas,
|
|
551
571
|
...changePresenceEventPayloadSchemas,
|
|
552
572
|
...ticketSourceHealthEventPayloadSchemas,
|
|
@@ -613,6 +633,7 @@ export type HarvestEventWrite<T extends HarvestEventType = HarvestEventType> =
|
|
|
613
633
|
export const HARVEST_EVENT_TYPES = Object.keys(harvestEventPayloadSchemas) as HarvestEventType[]
|
|
614
634
|
|
|
615
635
|
const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
|
|
636
|
+
'tickets.migration-recorded': ['human'],
|
|
616
637
|
'change-presence.observed': ['dispatcher', 'kernel'],
|
|
617
638
|
'harvest.pause-requested': ['human'],
|
|
618
639
|
'harvest.resume-requested': ['human'],
|