refactor(multitenant): collapse planTenantApply allowedResources duplication
Drop the allowedResources field from TenantApplyPlan — it was derived field-for-field from resourceChecklist already, which was exactly the "triplicate representation" flagged in the handoff's consolidation list. Update scripts/tenant-lifecycle.ts to compute the same lists from the checklist when it prints, and drop the tautological equality assertions from the test (resourceChecklist is now the single source). --- Build: pass | Tests: pass — 33 passed (1 file) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
1d3bf570de
commit
9605c7ad81
3 changed files with 12 additions and 24 deletions
|
|
@ -168,9 +168,12 @@ function printApplyPlan(
|
|||
for (const entry of plan.contractChecklist) {
|
||||
console.log(`- [${entry.status}] ${entry.field} ${entry.value}: ${entry.detail}`);
|
||||
}
|
||||
console.log(`Allowed databases: ${plan.allowedResources.databases.join(', ')}`);
|
||||
console.log(`Allowed worker jails: ${plan.allowedResources.workerJails.join(', ')}`);
|
||||
console.log(`Allowed datasets: ${plan.allowedResources.datasets.join(', ') || '(none)'}`);
|
||||
const allowedDatabases = plan.resourceChecklist.databases.map((e) => e.name);
|
||||
const allowedWorkerJails = plan.resourceChecklist.workerJails.map((e) => e.name);
|
||||
const allowedDatasets = plan.resourceChecklist.datasets.map((e) => e.name);
|
||||
console.log(`Allowed databases: ${allowedDatabases.join(', ')}`);
|
||||
console.log(`Allowed worker jails: ${allowedWorkerJails.join(', ')}`);
|
||||
console.log(`Allowed datasets: ${allowedDatasets.join(', ') || '(none)'}`);
|
||||
console.log('Normalization hints:');
|
||||
for (const hint of plan.normalizationHints) {
|
||||
console.log(`- ${hint}`);
|
||||
|
|
|
|||
|
|
@ -109,8 +109,12 @@ describe('tenant-registry', () => {
|
|||
}),
|
||||
]),
|
||||
);
|
||||
expect(plan.allowedResources.databases).toContain('mevy_brain');
|
||||
expect(plan.allowedResources.workerJails).toContain('mevy_ctrl_worker');
|
||||
expect(plan.resourceChecklist.databases.map((e) => e.name)).toContain(
|
||||
'mevy_brain',
|
||||
);
|
||||
expect(plan.resourceChecklist.workerJails.map((e) => e.name)).toContain(
|
||||
'mevy_ctrl_worker',
|
||||
);
|
||||
expect(plan.preflightChecks).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
|
|
@ -167,15 +171,6 @@ describe('tenant-registry', () => {
|
|||
}),
|
||||
]),
|
||||
);
|
||||
expect(plan.allowedResources.databases).toEqual(
|
||||
plan.resourceChecklist.databases.map((entry) => entry.name),
|
||||
);
|
||||
expect(plan.allowedResources.workerJails).toEqual(
|
||||
plan.resourceChecklist.workerJails.map((entry) => entry.name),
|
||||
);
|
||||
expect(plan.allowedResources.datasets).toEqual(
|
||||
plan.resourceChecklist.datasets.map((entry) => entry.name),
|
||||
);
|
||||
expect(plan.blockers).toEqual(
|
||||
plan.preflightChecks
|
||||
.filter((check) => check.status === 'blocked')
|
||||
|
|
|
|||
|
|
@ -187,11 +187,6 @@ export interface TenantApplyPlan {
|
|||
detail: string;
|
||||
}>;
|
||||
};
|
||||
allowedResources: {
|
||||
databases: string[];
|
||||
workerJails: string[];
|
||||
datasets: string[];
|
||||
};
|
||||
preflightChecks: Array<{
|
||||
name: string;
|
||||
status: 'pass' | 'manual' | 'blocked';
|
||||
|
|
@ -1042,11 +1037,6 @@ export function planTenantApply(
|
|||
},
|
||||
],
|
||||
},
|
||||
allowedResources: {
|
||||
databases: resourceChecklist.databases.map((entry) => entry.name),
|
||||
workerJails: resourceChecklist.workerJails.map((entry) => entry.name),
|
||||
datasets: resourceChecklist.datasets.map((entry) => entry.name),
|
||||
},
|
||||
preflightChecks,
|
||||
prerequisites: [
|
||||
'Tenant must already exist in the registry.',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue