From cff79b816cb7e137be2929c68c03f08751458713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Weberru=C3=9F?= Date: Tue, 17 Nov 2026 11:04:55 +0000 Subject: [PATCH] fix(assistant): retain concrete prefixed folder naming proposals --- .../assistant/knowledge-topics.generated.ts | 4 +- .../apps/api/src/assistant/model-serving.ts | 141 ++++++++++++- .../app/scripts/assistant-scenarios.ts | 129 +++++++++++- .../app/tests/assistant.test.ts | 191 +++++++++++++++++- .../docs/assistant-knowledge/README.de.md | 15 ++ .../docs/assistant-knowledge/README.md | 14 ++ .../docs/assistant-test-catalogue.json | 52 ++++- 7 files changed, 528 insertions(+), 18 deletions(-) diff --git a/landing-zone-configurator/app/apps/api/src/assistant/knowledge-topics.generated.ts b/landing-zone-configurator/app/apps/api/src/assistant/knowledge-topics.generated.ts index 6c22392..df8660e 100644 --- a/landing-zone-configurator/app/apps/api/src/assistant/knowledge-topics.generated.ts +++ b/landing-zone-configurator/app/apps/api/src/assistant/knowledge-topics.generated.ts @@ -455,7 +455,7 @@ export const assistantKnowledgeTopics = { { path: "landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts", sha256: - "a9f0b1ed2aa59abe43e3286866f9c88ae06670bb8e6c79ca0357affb08b592f1", + "6d04daccbbbe8e65c649ce891cbe1adf4c5e6f1d8ec54a945b11569cf0735aca", }, { path: "landing-zone-configurator/app/apps/api/src/assistant/editor.ts", @@ -1735,7 +1735,7 @@ export const assistantKnowledgeTopics = { { path: "landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts", sha256: - "a9f0b1ed2aa59abe43e3286866f9c88ae06670bb8e6c79ca0357affb08b592f1", + "6d04daccbbbe8e65c649ce891cbe1adf4c5e6f1d8ec54a945b11569cf0735aca", }, { path: "landing-zone-configurator/docs/application-execution-lifecycle.md", diff --git a/landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts b/landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts index 90a7896..f4151f5 100644 --- a/landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts +++ b/landing-zone-configurator/app/apps/api/src/assistant/model-serving.ts @@ -1603,7 +1603,7 @@ export class AssistantModelServing { { role: "system", content: - "Foundation namingDelegation paths only cover USER delegation for company names/codes or folder names. Choose the source reference from supplied namingSources (current/history/template), never rewrite or normalize a quote. No FOUNDATION delegation means paths=[] and source=none; it does NOT deny separate template naming. 'Nimm schlaue Namen für Grundsettings und Ordner' delegates company_name, company_code and rm_folders. Mentioning a company or asking how naming works is NOT delegation. Application template setup uses independent templateSetup: reference the actual USER task through source; the server supplies that original message, do not generate a quote. Central-network and separate Internet-only variants mean kinds=[corporate,public]; 'Benenne das Template entsprechend' means delegateNaming=true; 'Richte dort jeweils ein lokales Netz ein' means localNetworks=true. Do not negate these resolved template decisions because foundation namingDelegation is empty. Excluded/deferred Sandbox variants are not requested kinds. Never delegate region, Cloud IDs, IAM, parent selection or access metadata. Broad setup requests spanning identity and folder naming use configuration-contract, mode=draft. Restoring previously discussed foundations with an explicitly supplied existing organization UUID uses identity-foundations or configuration-contract, mode=draft, NOT the preceding DNS topic. This only proposes draft inputs, never verifies or binds organization access. Existing internal keys remain unchanged; new template keys are not Cloud resource IDs, which arise only from separate native deployment.", + "Foundation namingDelegation paths only cover USER delegation for company names/codes or folder names. Choose the source reference from supplied namingSources (current/history/template), never rewrite or normalize a quote. No FOUNDATION delegation means paths=[] and source=none; it does NOT deny separate template naming. 'Nimm schlaue Namen für Grundsettings und Ordner' delegates company_name, company_code and rm_folders. Mentioning a company or asking how naming works is NOT delegation. Application template setup uses independent templateSetup: reference the actual USER task through source; the server supplies that original message, do not generate a quote. Central-network and separate Internet-only variants mean kinds=[corporate,public]; 'Benenne das Template entsprechend' means delegateNaming=true; 'Richte dort jeweils ein lokales Netz ein' means localNetworks=true. Do not negate these resolved template decisions because foundation namingDelegation is empty. Excluded/deferred Sandbox variants are not requested kinds. Never delegate region, Cloud IDs, IAM, parent selection or access metadata. Broad setup requests spanning identity and folder naming use configuration-contract, mode=draft. A request for a good company prefix AND folder names must include BOTH company_code and rm_folders in namingDelegation.paths. A follow-up such as \"Please change the folder names reflecting the selected prefix\" delegates rm_folders and uses governance-folders, mode=draft; the existing-folder names-only foundation contract handles this even if editorContract=true. Keep the selected prefix from the draft or preceding conversation. Do not silently drop the folder part of a combined request. Restoring previously discussed foundations with an explicitly supplied existing organization UUID uses identity-foundations or configuration-contract, mode=draft, NOT the preceding DNS topic. This only proposes draft inputs, never verifies or binds organization access. Existing internal keys remain unchanged; new template keys are not Cloud resource IDs, which arise only from separate native deployment.", }, { role: "system", @@ -1839,7 +1839,13 @@ export class AssistantModelServing { ) return policyBoundary(); const delegation = { - paths: classifiedIntent.namingDelegation.paths, + paths: classifiedIntent.namingDelegation.paths.filter( + (path) => + path !== "rm_folders" || + [...namingSources.values()].some((source) => + /\b(?:folders?|foldernamen|ordner(?:namen|n|s)?)\b/i.test(source), + ), + ), quote: namingSources.get(classifiedIntent.namingDelegation.source) ?? "", }; if ( @@ -2643,7 +2649,26 @@ export class AssistantModelServing { ]) editorRoots.delete(root); } + const foundationNamingDraft = + intent.mode === "draft" && + delegation.paths.includes("rm_folders") && + [ + "identity-foundations", + "configuration-contract", + "governance-folders", + ].includes(intent.topic) && + [...editorRoots].every((root) => + [ + "company_name", + "company_code", + "owner_email", + "organization_id", + "region", + "rm_folders", + ].includes(root), + ); const editorDraft = + !foundationNamingDraft && intent.mode === "draft" && !accessAssignment && intent.topic !== "firewall-policy" && @@ -3206,6 +3231,36 @@ Reviewed knowledge: ${JSON.stringify({ fields: draftFields, ...topicKnowledge }) "configuration-contract", "governance-folders", ].includes(intent.topic); + const requestedFolderNames = + foundationDraft && delegation.paths.includes("rm_folders") + ? assistantFolderNames(publicValues) + : {}; + const folderNamesContract = Object.keys(requestedFolderNames).length + ? z.strictObject( + Object.fromEntries( + Object.keys(requestedFolderNames).map((key) => [ + key, + z.strictObject({ + name: z.string().min(1).max(40), + prefix: z + .string() + .min(1) + .max(20) + .regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/) + .nullable() + .default(null) + .describe( + "Requested company prefix to apply to this folder. For an explicit prefix-renaming request, return the prefix chosen in this answer or previously proposed/saved, even when name retains its original display name. Null only for an unrequested folder or a custom name without prefix delegation. This is naming metadata, not a resource ID.", + ), + }), + ]), + ), + ) + : undefined; + const folderNamingOnly = + !!folderNamesContract && + intent.topic === "governance-folders" && + delegation.paths.every((path) => path === "rm_folders"); const decisionPaths = { traffic: "connectivity.firewall.lan_network_range", capacity: "connectivity.firewall.flavor", @@ -3875,14 +3930,30 @@ Reviewed knowledge: ${JSON.stringify({ fields: draftFields, ...topicKnowledge }) ? [ { role: "system" as const, - content: - "CURRENT STEP: Restore or propose ONLY supported foundation scalars and existing folder names from actual prior user requirements and the supplied organization UUID. Keep the existing DNS/network configuration unchanged. Never resume earlier DNS questions or ask about future components. Use owner_email from user requirements or the verified human email when known, explaining its source. If a supported foundation value is still unknown, ask only that missing foundation question. Return identity-foundations/governance-folders/configuration-contract references, not network sources. These are proposals: begin with 'Ich schlage vor' or the equivalent in the user's language. Never say information was already entered, changed, restored or saved. Field-selection controls perform the later explicit save.", + content: `CURRENT STEP: Reply in the language of the CURRENT USER message (English request: replyLanguage=en; German request: replyLanguage=de), not the language of the curated knowledge or earlier Assistant text. ${folderNamesContract ? "The USER explicitly requested folder renaming. Return a concrete folderNames object: CHANGE the display names to reflect the requested prefix, do not merely repeat unchanged template defaults. For a combined company-prefix/folder request, choose a concise company_code and use that SAME prefix in every requested folder name by combining the chosen prefix with each folder purpose. For a follow-up, reuse the prefix already proposed in conversation or saved in the draft. Return that prefix in each requested folder's prefix property; the server applies it if name still contains the original display name. Use prefix=null for folders outside the requested scope. This naming request is unrelated to selecting IAM subjects or granting access. Keep unrequested names unchanged. " : ""}Restore or propose ONLY supported foundation scalars and existing folder names from actual prior user requirements and the supplied organization UUID. Keep the existing DNS/network configuration unchanged. Never resume earlier DNS questions or ask about future components. Use owner_email from user requirements or the verified human email when known, explaining its source. If a supported foundation value is still unknown, ask only that missing foundation question. Return identity-foundations/governance-folders/configuration-contract references, not network sources. These are proposals: begin with 'Ich schlage vor' or the equivalent in the user's language. Never say information was already entered, changed, restored or saved. Field-selection controls perform the later explicit save.`, }, ] : []), ], z.toJSONSchema( dialogueSchema.extend({ + ...(foundationDraft + ? { + replyLanguage: z + .enum(["de", "en"]) + .default("de") + .describe( + "Language of the current user request; English requests use en, German requests use de.", + ), + } + : {}), + ...(folderNamesContract + ? { + folderNames: folderNamesContract.describe( + "Required folder display-name proposal for the existing keys. Apply the requested company prefix consistently; use company_code from this proposal, the current draft or the previous USER-approved/proposed naming context. Keep unrequested folder names unchanged. Never omit the folder proposal when identity values are also requested. Internal keys, parents and IAM metadata remain unchanged.", + ), + } + : {}), explanation: z .string() .min(1) @@ -4032,7 +4103,11 @@ Reviewed knowledge: ${JSON.stringify({ fields: draftFields, ...topicKnowledge }) ) .min(dnsSettingsDraft && singleDnsZone ? 1 : 0) .max( - !draftAllowed || (networkFirst && !addressEvidence) ? 0 : 8, + !draftAllowed || + folderNamingOnly || + (networkFirst && !addressEvidence) + ? 0 + : 8, ), references: z .array( @@ -4064,10 +4139,51 @@ Reviewed knowledge: ${JSON.stringify({ fields: draftFields, ...topicKnowledge }) : stream, stream?.signal, ); + const { + replyLanguage: proposedReplyLanguage = "de", + folderNames: providedFolderNames, + ...providedDialogue + } = z + .object({ + replyLanguage: z.enum(["de", "en"]).optional(), + folderNames: folderNamesContract?.optional() ?? z.never().optional(), + }) + .passthrough() + .parse(result); + const foundationReplyLanguage = + intent.applicationAccessLanguage === "en" || + proposedReplyLanguage === "en" + ? "en" + : "de"; const dialogue = validateDialogue( - result, + providedDialogue, dnsAdvice ? ["dns-zones"] : context.rules.map((rule) => rule.id), ); + if (folderNamingOnly && dialogue.changes.length) + throw new Error("assistant_invalid_scope"); + if (folderNamesContract) { + const names = folderNamesContract.parse(providedFolderNames); + dialogue.changes = dialogue.changes.filter( + (change) => change.path !== "rm_folders", + ); + dialogue.changes.push({ + path: "rm_folders", + value: Object.fromEntries( + Object.entries(names).map(([key, folder]) => [ + key, + { + name: + folder.prefix && + !folder.name + .toLowerCase() + .startsWith(`${folder.prefix.toLowerCase()}-`) + ? `${folder.prefix}-${folder.name}`.slice(0, 40) + : folder.name, + }, + ]), + ), + }); + } if ( dialogue.references.some( (reference) => @@ -4493,16 +4609,21 @@ Reviewed knowledge: ${JSON.stringify({ fields: draftFields, ...topicKnowledge }) ); const details = dialogue.changes.map((change) => change.path === "rm_folders" - ? `Ordnernamen: ${Object.entries( + ? `${foundationReplyLanguage === "en" ? "Folder names" : "Ordnernamen"}: ${Object.entries( assistantFolderNamesSchema.parse(change.value), ) .map(([key, folder]) => `${key}: ${folder.name}`) .join(", ")}` : `${change.path}: ${change.value}`, ); - dialogue.explanation = details.length - ? `Ich schlage folgende Grundlagenwerte zur Prüfung vor:\n${details.join("\n")}\n\nNoch nichts gespeichert. Erst die ausdrückliche Übernahme der ausgewählten Felder speichert die Konfiguration. Bestehende DNS- und Netzwerkeinstellungen bleiben erhalten. Eine Organisations-ID im Entwurf bestätigt keinen Zugriff und ändert keine Tenant-Bindung; keine Cloud-Ausführung.` - : "Es gibt keinen neuen Grundlagenvorschlag. Bereits gespeicherte Werte bleiben erhalten; fehlende unterstützte Grundlagenwerte können im Chat geklärt werden. Keine Organisationsbindung oder Cloud-Ausführung."; + dialogue.explanation = + foundationReplyLanguage === "en" + ? details.length + ? `I propose the following settings for review:\n${details.join("\n")}\n\nReview and accept the fields you want to use, then save the configuration. No cloud changes have been made.` + : "The requested settings already match the current draft. No changes have been saved or deployed." + : details.length + ? `Ich schlage folgende Grundlagenwerte zur Prüfung vor:\n${details.join("\n")}\n\nNoch nichts gespeichert. Erst die ausdrückliche Übernahme der ausgewählten Felder speichert die Konfiguration. Bestehende DNS- und Netzwerkeinstellungen bleiben erhalten. Eine Organisations-ID im Entwurf bestätigt keinen Zugriff und ändert keine Tenant-Bindung; keine Cloud-Ausführung.` + : "Es gibt keinen neuen Grundlagenvorschlag. Bereits gespeicherte Werte bleiben erhalten; fehlende unterstützte Grundlagenwerte können im Chat geklärt werden. Keine Organisationsbindung oder Cloud-Ausführung."; } if (networkDraft && dialogue.changes.length) { const details = dialogue.changes.flatMap((change) => { diff --git a/landing-zone-configurator/app/scripts/assistant-scenarios.ts b/landing-zone-configurator/app/scripts/assistant-scenarios.ts index 1f2a29f..77ee77e 100644 --- a/landing-zone-configurator/app/scripts/assistant-scenarios.ts +++ b/landing-zone-configurator/app/scripts/assistant-scenarios.ts @@ -153,6 +153,7 @@ export type AssistantScenario = { fixture: | "baseline" | "foundations" + | "folder-naming" | "dns-owner" | "dns-login" | "dns-placeholder" @@ -1042,6 +1043,40 @@ export const assistantScenarios: readonly AssistantScenario[] = [ : {}), }), ), + { + id: "foundations-prefixed-folders", + topic: "identity-foundations", + fixture: "folder-naming", + acceptableReferences: [ + "identity-foundations", + "governance-folders", + "configuration-contract", + ], + message: `Here are some details about my company. Company name: "Synthetic Corp". Org ID: ${syntheticOrganizationId}. I am the technical contact with my logged in email. Region: south Germany. Please prepare the config including a good prefix and folder names reflecting this prefix.`, + }, + { + id: "governance-prefixed-folders-followup", + topic: "governance-folders", + fixture: "folder-naming", + acceptableReferences: [ + "identity-foundations", + "governance-folders", + "configuration-contract", + ], + message: "Please change the folder names reflecting the selected prefix.", + history: [ + { + role: "user", + content: + "The company is Synthetic Corp. Please propose a short company prefix.", + }, + { + role: "assistant", + content: + "I propose company_name: Synthetic Corp and company_code: syn. Nothing has been saved.", + }, + ], + }, { id: "foundations-restoration", topic: "identity-foundations", @@ -1202,6 +1237,27 @@ export function assistantScenarioFixture(scenario: AssistantScenario) { "Die Grundlagen sind schon gespeichert. Zuletzt wurden Folder-Namen besprochen.", }); } + if (scenario.fixture === "folder-naming") { + draft = setCommonInput(draft, "company_name", null); + draft = setCommonInput(draft, "company_code", null); + const folders = objectValue( + effectiveInput(compileCommonConfiguration(draft), "rm_folders"), + ); + draft = setCommonInput( + draft, + "rm_folders", + Object.fromEntries( + Object.entries(folders).map(([key, value]) => [ + key, + { + ...objectValue(value), + owner_emails: ["folder-owner@example.test"], + reader_emails: ["folder-reader@example.test"], + }, + ]), + ), + ); + } if (scenario.fixture === "foundations") { for (const path of [ "company_name", @@ -1490,6 +1546,8 @@ export function assistantScenarioFixture(scenario: AssistantScenario) { }, ); } + if (scenario.fixture === "folder-naming") + values["assistant.user_email"] = "login@example.test"; return { draft, values, history, catalogues }; } @@ -2366,6 +2424,71 @@ export function validateAssistantScenario( !/synchron|sync/i.test(dialogue.explanation)) ) failures.push("incomplete_policy_contract"); + if (scenario.fixture === "folder-naming") { + const before = compileCommonConfiguration(fixture.draft); + const folderChange = dialogue.changes.find( + ({ path }) => path === "rm_folders", + ); + const names = objectValue( + folderChange?.value as Parameters[0], + ); + const prefix = + scenario.id === "governance-prefixed-folders-followup" + ? "syn" + : dialogue.changes.find(({ path }) => path === "company_code")?.value; + const keys = Object.keys(objectValue(before.rm_folders)); + if ( + typeof prefix !== "string" || + !prefix || + !isDeepStrictEqual(Object.keys(names).sort(), keys.sort()) || + keys.some( + (key) => + typeof objectValue(names[key]).name !== "string" || + !String(objectValue(names[key]).name) + .toLowerCase() + .startsWith(prefix.toLowerCase()), + ) + ) + failures.push("prefixed_folder_names_missing"); + if ( + keys.some( + (key) => + !dialogue.explanation.includes(String(objectValue(names[key]).name)), + ) + ) + failures.push("folder_names_not_visible_in_explanation"); + if (!dialogue.explanation.includes("Folder names:")) + failures.push("folder_proposal_not_in_english"); + const candidate = compileCommonConfiguration( + applyAssistantChanges(fixture.draft, dialogue.changes), + ); + if ( + keys.some( + (key) => + !isDeepStrictEqual( + objectValue(objectValue(candidate.rm_folders)[key]), + { + ...objectValue(objectValue(before.rm_folders)[key]), + ...objectValue(names[key]), + }, + ), + ) + ) + failures.push("folder_metadata_changed"); + if ( + scenario.id === "governance-prefixed-folders-followup" && + dialogue.changes.some(({ path }) => path !== "rm_folders") + ) + failures.push("folder_followup_changed_unrequested_foundations"); + if ( + scenario.id === "foundations-prefixed-folders" && + !dialogue.changes.some( + ({ path, value }) => + path === "company_name" && value === "Synthetic Corp", + ) + ) + failures.push("combined_company_proposal_missing"); + } if (scenario.fixture === "foundations") { const expected = { company_name: "Example GmbH", @@ -2477,7 +2600,11 @@ export function validateAssistantScenario( failures.push("sna_scope_or_repeated_question"); } if (scenario.fixture !== "baseline") { - if (!/noch (?:nichts|nicht) gespeichert/i.test(dialogue.explanation)) + if ( + !/noch (?:nichts|nicht) gespeichert|no(?:thing| changes?) (?:has|have) been saved|then save the configuration/i.test( + dialogue.explanation, + ) + ) failures.push("missing_unsaved_notice"); if ( scenario.id !== "firewall-ha-already-saved" && diff --git a/landing-zone-configurator/app/tests/assistant.test.ts b/landing-zone-configurator/app/tests/assistant.test.ts index 66c9958..66ae52f 100644 --- a/landing-zone-configurator/app/tests/assistant.test.ts +++ b/landing-zone-configurator/app/tests/assistant.test.ts @@ -1530,7 +1530,15 @@ it("supports explicitly delegated naming without inventing IDs, new folders or I requirements: [], namingDelegation: { paths, source: evidence }, } - : result, + : paths.includes("rm_folders") + ? { + ...result, + folderNames: { + ...values.rm_folders, + platform: { name: "Example Platform" }, + }, + } + : result, ); }; const result = await new AssistantModelServing( @@ -2287,7 +2295,7 @@ it("uses bounded public dialogue history and validates the actual chat proposal" const request = vi.fn( withIntent("identity-foundations", "draft", async (_url, init) => { const body = JSON.parse(String(init?.body)); - expect(body.messages[0].content).toContain("CURRENT STEP: Restore"); + expect(body.messages[0].content).toContain("CURRENT STEP:"); expect(body.messages.at(-1).content).toBe("Firma Example"); expect(body.messages.length).toBe(4); expect(body.messages.at(-2)).toEqual({ @@ -3774,3 +3782,182 @@ it.each(["platform-impact-review", "audit-observability"] as const)( expect(request).toHaveBeenCalledTimes(2); }, ); + +it.each([false, true])( + "shows concrete prefixed folder names for English foundation requests (editorContract=%s), preserving metadata", + async (editorContract) => { + let draft = createCommonConfiguration("standalone", randomUUID()); + draft = setCommonInput(draft, "company_code", "syn"); + const folders = objectValue( + effectiveInput(compileCommonConfiguration(draft), "rm_folders"), + ); + draft = setCommonInput(draft, "rm_folders", { + ...folders, + platform: { + ...objectValue(folders.platform), + owner_emails: ["owner@example.test"], + reader_emails: ["reader@example.test"], + }, + }); + const before = compileCommonConfiguration(draft); + const names = Object.fromEntries( + Object.entries(objectValue(before.rm_folders)).map(([key]) => [ + key, + { name: `syn-${key}` }, + ]), + ); + const request = vi.fn(async (_url, options) => { + const payload = JSON.parse(String(options?.body)); + if (payload.response_format.json_schema.name === "conversation_intent") + return answer({ + topic: editorContract + ? "governance-folders" + : "configuration-contract", + applicationAccessLanguage: editorContract ? "en" : "de", + mode: "draft", + requirements: [], + editorContract, + editorInputs: editorContract ? ["rm_folders"] : [], + namingDelegation: { paths: ["rm_folders"], source: "current" }, + }); + expect(payload.response_format.json_schema.name).toBe( + "configuration_dialogue", + ); + expect(payload.response_format.json_schema.schema.required).toContain( + "folderNames", + ); + return answer({ + replyLanguage: editorContract ? "de" : "en", + explanation: "Proposal.", + questions: [], + changes: [], + folderNames: editorContract + ? Object.fromEntries( + Object.entries(names).map(([key]) => [ + key, + { name: key, prefix: "syn" }, + ]), + ) + : names, + references: ["governance-folders"], + }); + }); + const result = await new AssistantModelServing( + configuration, + request, + ).converse( + selection(), + { + ...before, + "assistant.platform_draft": true, + }, + [], + "Please change the folder names reflecting the selected prefix.", + ); + expect(result.changes).toEqual([{ path: "rm_folders", value: names }]); + expect(result.explanation).toContain("Folder names:"); + expect(result.explanation).toContain("syn-platform"); + expect(result.explanation).not.toContain("Ordnernamen"); + const after = compileCommonConfiguration( + applyAssistantChanges(draft, result.changes), + ); + expect(after).toEqual({ + ...before, + rm_folders: Object.fromEntries( + Object.entries(objectValue(before.rm_folders)).map(([key, value]) => [ + key, + { ...objectValue(value), ...names[key] }, + ]), + ), + }); + expect(compileCommonConfiguration(draft)).toEqual(before); + }, +); + +it.each(["missing", "unknown-key", "iam-change", "unrequested-company"])( + "rejects incomplete or out-of-scope folder naming answers: %s", + async (kind) => { + const request = vi.fn(async (_url, options) => { + const payload = JSON.parse(String(options?.body)); + if (payload.response_format.json_schema.name === "conversation_intent") + return answer({ + topic: "governance-folders", + mode: "draft", + requirements: [], + namingDelegation: { paths: ["rm_folders"], source: "current" }, + }); + return answer({ + explanation: "Names proposed.", + questions: [], + changes: + kind === "unrequested-company" + ? [{ path: "company_code", value: "other" }] + : [], + references: ["governance-folders"], + ...(kind === "missing" + ? {} + : { + folderNames: + kind === "unknown-key" + ? { invented: { name: "syn-invented" } } + : { + platform: { + name: "syn-platform", + ...(kind === "iam-change" + ? { owner_emails: ["other@example.test"] } + : {}), + }, + }, + }), + }); + }); + await expect( + new AssistantModelServing(configuration, request).converse( + selection(), + { company_code: "syn", rm_folders: { platform: { name: "Platform" } } }, + [], + "Please change the folder names reflecting the selected prefix.", + ), + ).rejects.toBeInstanceOf(AssistantInferenceError); + }, +); + +it("does not delegate folder naming from an Assistant-only folder mention when restoring foundations", async () => { + const request = vi.fn(async (_url, options) => { + const payload = JSON.parse(String(options?.body)); + if (payload.response_format.json_schema.name === "conversation_intent") + return answer({ + topic: "identity-foundations", + mode: "draft", + requirements: [], + namingDelegation: { paths: ["rm_folders"], source: "current" }, + }); + expect( + payload.response_format.json_schema.schema.properties, + ).not.toHaveProperty("folderNames"); + return answer({ + explanation: "Proposal.", + questions: [], + changes: [{ path: "company_name", value: "Example GmbH" }], + references: ["identity-foundations"], + }); + }); + const result = await new AssistantModelServing( + configuration, + request, + ).converse( + selection(), + { + company_name: null, + rm_folders: { platform: { name: "Platform" } }, + }, + [ + { role: "user", content: "Die Firma heißt Example GmbH." }, + { role: "assistant", content: "Zuletzt wurden Ordnernamen besprochen." }, + ], + "Bitte die Grundlagen wiederherstellen.", + ); + expect(result.changes).toEqual([ + { path: "company_name", value: "Example GmbH" }, + ]); +}); diff --git a/landing-zone-configurator/docs/assistant-knowledge/README.de.md b/landing-zone-configurator/docs/assistant-knowledge/README.de.md index 9986beb..ecf32be 100644 --- a/landing-zone-configurator/docs/assistant-knowledge/README.de.md +++ b/landing-zone-configurator/docs/assistant-knowledge/README.de.md @@ -51,6 +51,21 @@ Provenienz bleibt getrennt. Kundeneingaben/-historie und PIM-Labels bleiben nicht vertrauenswuerdige Daten, keine Anweisungen. +### Vorschläge für Ordnernamen + +Kombinierte Anfragen zu Firmenpräfix und Ordnernamen sowie reine Namens-Folgefragen +verwenden den begrenzten Grundlagenvertrag, auch wenn die Themenzuordnung den +allgemeinen Editor-Pfad auswählt. Eine ausdrückliche Namensanfrage verlangt +konkrete Anzeigenamen für die vorhandenen Schlüssel. Der Server wendet ein ausdrücklich vorgeschlagenes Präfix an, wenn das Modell +noch den bisherigen Anzeigenamen liefert. Die Antwort nennt die resultierenden +Namen in der Sprache des Benutzers statt nur `rm_folders` zu bestätigen. +Eine Folgefrage kann das im Gespräch vorgeschlagene Präfix bereits vor der +Übernahme wiederverwenden. Unveränderte Namen werden ausgefiltert; native +Ordnerschlüssel, Elternbindungen und Owner-/Reader-Metadaten bleiben erhalten. +Die Feldübernahme ändert den Entwurf; Speichern und Cloud-Ausführung bleiben +separate Schritte. Die synthetische Qualifikation prüft die kombinierte englische +Anfrage und ihre Präfix-Folgefrage unabhängig voneinander. + ### Vertrag zur Themenauslieferung diff --git a/landing-zone-configurator/docs/assistant-knowledge/README.md b/landing-zone-configurator/docs/assistant-knowledge/README.md index 5afa6d9..246b27a 100644 --- a/landing-zone-configurator/docs/assistant-knowledge/README.md +++ b/landing-zone-configurator/docs/assistant-knowledge/README.md @@ -36,6 +36,20 @@ access to docs. The compiled API artifact contains the generated snapshot. Topic text is supplied once as trusted curated rules; provenance is separate. Customer input/history and PIM labels remain untrusted data, not instructions. +### Folder naming proposals + +Combined company-prefix and folder-name requests and naming-only follow-ups use +the bounded foundation contract, including when intent classification selects +the generic Editor path. Explicit folder naming requires a concrete display-name +proposal for the existing keys. The server applies an explicitly proposed prefix +when the model still returns the previous display name. The response lists the resulting names in the user's +language; it does not substitute a root-only `rm_folders` acknowledgement. +A follow-up may reuse the prefix proposed in the conversation before acceptance. +Unchanged names are filtered out, and native folder keys, parent bindings and +owner/reader metadata remain intact. Field acceptance changes the draft; saving +and cloud execution remain separate. Synthetic qualification covers the combined +English request and its prefix follow-up independently. + ### Topic delivery contract The generic Editor proposal path previously passed topic/field metadata without diff --git a/landing-zone-configurator/docs/assistant-test-catalogue.json b/landing-zone-configurator/docs/assistant-test-catalogue.json index ab82019..9deb121 100644 --- a/landing-zone-configurator/docs/assistant-test-catalogue.json +++ b/landing-zone-configurator/docs/assistant-test-catalogue.json @@ -2,12 +2,12 @@ "schemaVersion": 1, "status": "field-inventory-and-smoke-corpus-not-ai-qualification", "engineRevision": "a256f6896d11134fdc351786f1be5eba4e56b2e2", - "knowledgeSha256": "1d697d8391ca8c3d765ae8ecae41a18ce3d8758536074fde4422098b04200706", + "knowledgeSha256": "48967d9f510be61be627a559970720c6f8985afa9de6ef686dc7db635edb7819", "sourceDigests": { - "scripts/assistant-scenarios.ts": "b1c09da0d5bc47f8260807aed1c4ed4e9af8090b375fc3c9b0093be584f2dc8f", + "scripts/assistant-scenarios.ts": "c9b2a1e618e3831b24543513be44ed7563bfd51a12540e97bda4c489eb405d03", "scripts/assistant-tests.ts": "5e19b1c74da1ffa996f2d76876cc8dc639da698d0b6f9b7e1fc6637863833a8d" }, - "suiteSha256": "9d0aaa5777345b4b6db11723b7ac7d0242604c2cdff515b52101bc6d1508a130", + "suiteSha256": "b30a7161e52133f2a875758d4b20ef652ed50177a05e53009f71bad0bb930f9f", "topics": [ { "id": "credential-foundations", @@ -601,6 +601,24 @@ "no_changes" ] }, + { + "id": "foundations-prefixed-folders", + "topic": "identity-foundations", + "fixture": "folder-naming", + "acceptableReferences": [ + "identity-foundations", + "governance-folders", + "configuration-contract" + ], + "message": "Here are some details about my company. Company name: \"Synthetic Corp\". Org ID: 00000000-0000-4000-8000-000000000001. I am the technical contact with my logged in email. Region: south Germany. Please prepare the config including a good prefix and folder names reflecting this prefix.", + "assertions": [ + "valid_dialogue", + "reviewed_topic_reference", + "compiler_accepts_proposal", + "explicit_unsaved_notice", + "no_premature_saved_claim" + ] + }, { "id": "foundations-restoration", "topic": "identity-foundations", @@ -854,6 +872,34 @@ "unsupported_description_rejected", "no_changes" ] + }, + { + "id": "governance-prefixed-folders-followup", + "topic": "governance-folders", + "fixture": "folder-naming", + "acceptableReferences": [ + "identity-foundations", + "governance-folders", + "configuration-contract" + ], + "message": "Please change the folder names reflecting the selected prefix.", + "history": [ + { + "role": "user", + "content": "The company is Synthetic Corp. Please propose a short company prefix." + }, + { + "role": "assistant", + "content": "I propose company_name: Synthetic Corp and company_code: syn. Nothing has been saved." + } + ], + "assertions": [ + "valid_dialogue", + "reviewed_topic_reference", + "compiler_accepts_proposal", + "explicit_unsaved_notice", + "no_premature_saved_claim" + ] } ] },