Add staging simulation guide and refine hose integration sync

- Add comprehensive reference guide for staging simulation and production rule evolution
- Require latest CLI, skill, and plugin versions with self-update instructions in SKILL.md
- Deduplicate prod hosecloud integrations by corporationId during corps sync-test
- Support key and password fallback in enterprise source config for hose credentials
- Add unit and integration tests covering deduplication and source credential compatibility
This commit is contained in:
gitea committed 2026-09-11 15:04:49 +08:00
1 parent 0794f319b0
commit bdeca88354
4 files changed
+296 -21

No files matched your search

+42 -17
View File
@@ -452,23 +452,34 @@ export async function handleCorpsCommand(action: string | undefined, maybeName:
publishVersionName: versionName,
publishTarget: "test"
},
hosecloudSyncPlan: prodCorp.source.type === "hose" ? {
sourceType: "hose",
outboundName: buildTestHosecloudOutboundName(prodCorp.name),
targetMode: "assisted",
integrationsCount: (prodPref.integrations ?? []).filter((i: any) => i.type === "hosecloud").length,
integrations: (prodPref.integrations ?? [])
.filter((i: any) => i.type === "hosecloud")
.map((i: any) => ({
hosecloudSyncPlan: (() => {
if (prodCorp.source.type !== "hose") {
return {
sourceType: prodCorp.source.type,
skipped: true,
reason: "prod source is not hose; no hosecloud credentials available"
};
}
const rawHose = (prodPref.integrations ?? []).filter((i: any) => i.type === "hosecloud");
const seen = new Set<string>();
const distinct = rawHose.filter((i: any) => {
const cid = i.corporationId ?? prodCorp.id;
if (seen.has(cid)) return false;
seen.add(cid);
return true;
});
return {
sourceType: "hose",
outboundName: buildTestHosecloudOutboundName(prodCorp.name),
targetMode: "assisted",
integrationsCount: distinct.length,
integrations: distinct.map((i: any) => ({
corporationId: i.corporationId,
apiOrigin: i.apiOrigin,
customApiUrl: i.customApiUrl
}))
} : {
sourceType: prodCorp.source.type,
skipped: true,
reason: "prod source is not hose; no hosecloud credentials available"
},
};
})(),
productionGuarantees: {
prodRulesStayDraft: true,
prodVersionPublished: false
@@ -743,10 +754,10 @@ async function syncHosecloudIntegrationsToTest(
return { skipped: true, reason: "prod source is not hose; no hosecloud credentials available" }
}
const appKey = (prodCorp.source as any).appKey as string | undefined
const appSecurity = (prodCorp.source as any).appSecurity as string | undefined
const appKey = (((prodCorp.source as any).appKey ?? (prodCorp.source as any).key) as string | undefined)?.trim()
const appSecurity = (((prodCorp.source as any).appSecurity ?? (prodCorp.source as any).password) as string | undefined)?.trim()
if (!appKey || !appSecurity) {
return { skipped: true, reason: "prod hose source missing appKey/appSecurity" }
return { skipped: true, reason: "prod hose source missing appKey/appSecurity (or key/password)" }
}
const [prodPref, testPref] = await Promise.all([
@@ -759,6 +770,20 @@ async function syncHosecloudIntegrationsToTest(
return { skipped: true, reason: "prod Seal enterprise has no hosecloud integrations configured" }
}
// Deduplicate prod integrations by corporationId:
// Production enterprises may have multiple integrations (e.g. "assisted" + "fully_automatic")
// with the same corporationId. For the test environment, exactly one assisted integration per
// corporationId is needed.
const seenCorpIds = new Set<string>()
const distinctProdIntegrations: any[] = []
for (const item of prodIntegrations) {
const cid = item.corporationId ?? prodCorp.id
if (!seenCorpIds.has(cid)) {
seenCorpIds.add(cid)
distinctProdIntegrations.push(item)
}
}
const testIntegrations: any[] = (testPref.integrations ?? [])
const testByCorpId = new Map<string, any>(
testIntegrations.filter((i: any) => i.type === "hosecloud").map((i: any) => [i.corporationId, i])
@@ -767,7 +792,7 @@ async function syncHosecloudIntegrationsToTest(
const outboundName = buildTestHosecloudOutboundName(prodCorp.name)
const synced: HosecloudSyncResult["synced"] = []
const nextHosecloudIntegrations: any[] = prodIntegrations.map((prodInt: any) => {
const nextHosecloudIntegrations: any[] = distinctProdIntegrations.map((prodInt: any) => {
const existing = testByCorpId.get(prodInt.corporationId)
const signKey = existing?.signKey ?? randomBytes(6).toString("hex")
synced!.push({