Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
12 changes: 11 additions & 1 deletion .github/workflows/integration-candidate-prepare.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Prepare integration candidates
run-name: Prepare integration ${{ inputs.request_key || github.event.client_payload.request_key || 'manual' }}

on:
repository_dispatch:
Expand All @@ -9,6 +10,10 @@ on:
description: Bounded versioned request from an explicitly enrolled integration controller.
required: true
type: string
request_key:
description: Optional canonical request digest for explicit controller reconciliation.
required: false
type: string

permissions:
contents: read
Expand Down Expand Up @@ -39,12 +44,17 @@ jobs:
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
INTEGRATION_REQUEST: ${{ inputs.request || github.event.client_payload.request }}
INTEGRATION_REQUEST_KEY: ${{ inputs.request_key || github.event.client_payload.request_key }}
GH_TOKEN: ${{ github.token }}
with:
retries: 0
script: |
const fs = require('node:fs');
const {canonical, gitRunner, prepare} = require('./.github/scripts/integration-materialize.cjs');
const {canonical, digest, gitRunner, prepare} = require('./.github/scripts/integration-materialize.cjs');
if (process.env.INTEGRATION_REQUEST_KEY &&
digest(canonical(JSON.parse(process.env.INTEGRATION_REQUEST))) !== process.env.INTEGRATION_REQUEST_KEY) {
throw new Error('Controller request key differs from the exact bounded request');
}
const receipt = await prepare({
github, context,
requestText: process.env.INTEGRATION_REQUEST,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/added-integration-candidate-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add independent default-OFF integration execution enrollment, versioned private candidate provenance and actual runner accounting, designated-executor authority, bounded preparation admission, and exact protected-prefix promotion guards without replacing normal review, trust, CI, hold, or native-queue authority.
16 changes: 15 additions & 1 deletion dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,30 @@
}
}
},
"/api/integration-orchestration/execution-identity": {
"post": {
"tags": ["System"],
"summary": "Prepare create-only local execution identity (owner only)",
"description": "Creates or reads the private local installation identity and durable execution journal. Returns a designated executor ID and explicit disabled status. This does not enroll an executor, grant permissions, change configuration, dispatch CI or enable promotion. Cloned identity and automatic failover are unsupported.",
"responses": {
"200": {"description": "Local executor identity and explicit no-activation limits"},
"403": {"description": "Owner role required"},
"503": {"description": "Private durable identity or journal unavailable"}
}
}
},
"/api/config/integration-orchestration": {
"put": {
"tags": ["System"],
"summary": "Replace bounded integration orchestration configuration (owner only)",
"description": "Full off|advisory|enforce configuration with exact repository/base scopes, static execution/admission budgets, bounded lease/window/age/retries and optional pinned workflow contracts. JSON durations use nanoseconds. Disabling is independent of evidence-store availability and never releases authoritative claims/native entries.",
"description": "Full off|advisory|enforce configuration with independent execution opt-in, exact repository/base scopes, static budgets, bounded lease/window/age/retries and pinned producer/actor/authority profiles. JSON durations use nanoseconds. Execution changes require expected_execution compare-and-swap. Enforced Hive authority must be verifiably revoked at its shared forge epoch before OFF/advisory or authority handover. Execution-only updates never release authoring reservations; rollback retains evidence and unknown mutation outcomes and never releases authoritative claims/native entries.",
"requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object"}}}},
"responses": {
"200": {"description": "Validated effective configuration"},
"400": {"description": "Invalid mode, scope, contract or bounds"},
"403": {"description": "Owner role required"},
"409": {"description": "Old Hive authority epoch not verifiably revoked"},
"412": {"description": "Execution profile changed or expected_execution missing/stale"},
"500": {"description": "Configuration could not be persisted"},
"503": {"description": "Enforcement ledger unavailable; disable remains permitted"}
}
Expand Down
8 changes: 5 additions & 3 deletions src/cmd/hive/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ type boot struct {
// rebuilt client after that; forgeStateOnce guards the build. Held in
// an atomic because the dashboard's count wiring reads it late, from
// the metrics collector goroutine (#13376).
forgeState atomic.Pointer[forgestate.Store]
forgeStateOnce sync.Once
requestRelays *requestRelaySupervisor
forgeState atomic.Pointer[forgestate.Store]
forgeStateOnce sync.Once
requestRelays *requestRelaySupervisor
integrationEligibility automerge.IntegrationEligibilityGate
integrationPreparationEligibility automerge.IntegrationEligibilityGate

// bootConfig
startTime time.Time
Expand Down
46 changes: 46 additions & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,37 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) {
// Resolved lazily: bootDashboard has not run yet, so b.dashSrv is nil
// here (see lateContributorNudgeSink).
autoMergeOpts.ContributorNudge = lateContributorNudgeSink{hub: func() *dashboard.ContributeWSHub { return b.dashSrv.ContributeHub() }}
autoMergeOpts.IntegrationExecution = func(ctx context.Context, repo string, pr *gh.PullRequest, gate automerge.IntegrationEligibilityGate) (automerge.IntegrationExecutionDecision, error) {
if b.dashSrv != nil {
return b.dashSrv.IntegrationExecutionRoute(ctx, repo, pr, gate)
}
execution := b.cfg.IntegrationOrchestration.Execution.Effective()
if execution.Mode == config.IntegrationEnforce {
if _, enrolled := execution.Scope(repo, pr.GetBase().GetRef()); enrolled {
return automerge.IntegrationExecutionDecision{Authority: "hold", Reason: "integration execution initializes before any selected-destination writer"}, nil
}
}
return automerge.IntegrationExecutionDecision{}, nil
}
autoMergeOpts.IntegrationAdmission = func(ctx context.Context, repo string, pr *gh.PullRequest) (string, error) {
if b.dashSrv != nil {
return b.dashSrv.IntegrationNativeAdmission(ctx, repo, pr)
}
return "", nil
}
autoMergeOpts.IntegrationFilesObserved = func(repo, head string, files []string) {
if b.dashSrv != nil {
b.dashSrv.IntegrationObserveFiles(repo, head, files)
}
}
autoMergeOpts.NativeMergeQueue = func() automerge.NativeMergeQueuePolicy {
q := b.cfg.AutoMerge.NativeMergeQueue
return automerge.NativeMergeQueuePolicy{Enabled: q.Enabled, Repos: q.RepoSet(), Bases: q.BaseSet(),
SkipCurrentBaseGate: q.SkipCurrentBaseGate, ProbeTTL: q.EffectiveProbeTTL()}
}
autoMergeOpts.IntegrationSelfAllowed = func() bool {
return b.cfg.AutoMerge.SelfAuthoredAutoMergeAllowed(b.cfg.ACMMLevel)
}

// commitGreen's required-checks gate (self-merge sweep, see
// automerge_sweep.go): install the operator-declared
Expand Down Expand Up @@ -2231,6 +2262,20 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) {
return joinDone(relaysDone, sweepDone)
}, b.logger)
b.armRequestRelays(b.ghClient)
b.integrationEligibility = func(ctx context.Context, repo, base string, number int, head string) (*gh.PullRequest, string, error) {
client := b.currentGitHubClient()
if client == nil {
return nil, "live normal-policy GitHub client unavailable", github.ErrNoGitHubClient
}
return automerge.New(client, autoMergeOpts).IntegrationEligibility(ctx, repo, base, number, head)
}
b.integrationPreparationEligibility = func(ctx context.Context, repo, base string, number int, head string) (*gh.PullRequest, string, error) {
client := b.currentGitHubClient()
if client == nil {
return nil, "live normal-policy GitHub client unavailable", github.ErrNoGitHubClient
}
return automerge.New(client, autoMergeOpts).IntegrationPreparationEligibility(ctx, repo, base, number, head)
}

// Opt-in mint credential: when mint.enabled, build a Minter from the config
// (signing key + issuer + TTL) and attach it so each per-agent token refresh
Expand Down Expand Up @@ -2391,6 +2436,7 @@ func (b *boot) bootDashboard() { b.bootDashboardWith(defaultBootDashboardDeps())
// persistence enables injected; see bootDashboardDeps.
func (b *boot) bootDashboardWith(deps bootDashboardDeps) {
b.dashSrv = deps.newServer(b.cfg.Dashboard.Port, b.cfg.Dashboard.AuthToken, b.logger)
b.dashSrv.SetIntegrationExecutionEvaluators(b.integrationPreparationEligibility, b.integrationEligibility)
worksource.SetRunStageAccessor(b.dashSrv.RunStageAccessor())
b.dashSrv.SetWritebackGate(b.writebackGate())
b.dashSrv.SetHotspotSource(hotspotDashSource{store: hotspotStore()})
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/hive/main_eval_cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,13 @@ func runEvalCycle(
if err := dashSrv.ReconcileIntegration(ctx); err != nil {
logger.Warn("integration observations incomplete", "error", err)
}
if cfg.IntegrationOrchestration.Execution.Effective().Mode != config.IntegrationOff {
go func() {
if err := dashSrv.ReconcileIntegrationExecution(ctx); err != nil {
logger.Warn("integration execution bounded reconciliation incomplete", "error", err)
}
}()
}
kickActionable = dashSrv.IntegrationKickAdmission(kickActionable)

sched.SetLastActionable(kickActionable)
Expand Down
1 change: 1 addition & 0 deletions src/cmd/hive/main_sweeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c
defer sweepSpan.End()
opts := automerge.Options{
IntegrationAdmission: dashSrv.IntegrationNativeAdmission,
IntegrationExecution: dashSrv.IntegrationExecutionRoute,
IntegrationFilesObserved: dashSrv.IntegrationObserveFiles,
Logger: logger,
MergerAuthorizer: trustedMergerFunc(cfg),
Expand Down
Loading
Loading