@@ -46,6 +46,13 @@ type ProvisionStatusReader interface {
4646 Ready (ctx context.Context , orgID , projectID , depName string ) (bool , error )
4747}
4848
49+ // OrgCatalogReader reports whether a logical name already holds values on the
50+ // org catalog plane (Registered External — non-empty env cells). Nil means
51+ // fail-open: treat the name as Project External and still emit external-config.
52+ type OrgCatalogReader interface {
53+ HasOrgEnvCells (orgID , name string ) bool
54+ }
55+
4956// --- wire shapes (names drive the generated schema names — keep them exactly
5057// --- BuildPreflight / PreflightItem / ConfigKeyView) ------------------------
5158
@@ -86,20 +93,22 @@ type BuildPreflight struct {
8693
8794// PreflightDeps carries the preflight service's ports.
8895type PreflightDeps struct {
89- Design PreflightDesignReader
90- Status ProvisionStatusReader
96+ Design PreflightDesignReader
97+ Status ProvisionStatusReader
98+ Catalog OrgCatalogReader
9199}
92100
93101// PreflightService computes the build dependency-drawer preflight from the
94102// design at HEAD, filtering out anything already provisioned or in-flight.
95103type PreflightService struct {
96- design PreflightDesignReader
97- status ProvisionStatusReader
104+ design PreflightDesignReader
105+ status ProvisionStatusReader
106+ catalog OrgCatalogReader
98107}
99108
100109// NewPreflightService wires the preflight service.
101110func NewPreflightService (d PreflightDeps ) * PreflightService {
102- return & PreflightService {design : d .Design , status : d .Status }
111+ return & PreflightService {design : d .Design , status : d .Status , catalog : d . Catalog }
103112}
104113
105114// Preflight walks every component's dependencies at HEAD — service AND
@@ -116,7 +125,9 @@ func NewPreflightService(d PreflightDeps) *PreflightService {
116125// computed Status/Reason (spec.ComputeDependencyStatus, via
117126// dependencyBlocker) says so; this is the dependency-management proceed
118127// gate Task 1 orphaned, reborn here. Otherwise, an "external-config" item
119- // (key/secret views only) when the dependency is not yet Ready.
128+ // (key/secret views only) when the dependency is not yet Ready and is not
129+ // a Registered External (org catalog already holds env cells — the drawer
130+ // must not collect secrets that live on the org record).
120131// - platform-resource: a "platform-resource" item when not yet Ready.
121132// - org-service: an "org-service" item when Status is one of the three
122133// non-resolved resolution states (unresolved | blocked | ambiguous);
@@ -172,9 +183,10 @@ func (s *PreflightService) itemsFor(ctx context.Context, orgID, projectID, compo
172183// still-ambiguous/unresolved dependency has no derived config keys yet). Once
173184// resolved (or when no resolver was ever wired — the fail-open empty Status),
174185// the pre-existing external-config item (key/secret views only) is emitted
175- // when the dependency is not yet Ready — unchanged: config collection stays a
176- // provisioning-readiness concern local to this preflight, not part of
177- // ComputeDependencyStatus.
186+ // when the dependency is not yet Ready and is not Registered (org catalog
187+ // env cells). Config collection stays a provisioning-readiness concern local
188+ // to this preflight, not part of ComputeDependencyStatus. Registered names
189+ // still author from org cells at POST /build; they just do not collect here.
178190func (s * PreflightService ) externalItems (ctx context.Context , orgID , projectID , componentName string , d spec.Dependency ) ([]PreflightItem , error ) {
179191 if kind , desc , blocked := dependencyBlocker (d ); blocked {
180192 return []PreflightItem {{
@@ -184,6 +196,11 @@ func (s *PreflightService) externalItems(ctx context.Context, orgID, projectID,
184196 Description : desc ,
185197 }}, nil
186198 }
199+ if s .catalog != nil && s .catalog .HasOrgEnvCells (orgID , d .Name ) {
200+ // Org cells already hold values; project Ready is irrelevant until
201+ // POST /build authors the instance from those cells.
202+ return nil , nil
203+ }
187204 ready , err := s .status .Ready (ctx , orgID , projectID , d .Name )
188205 if err != nil {
189206 return nil , err
0 commit comments