Архитектура: протянуть shared organization authority в data-scope history recovery и session bootstrap
This commit is contained in:
parent
cf17404925
commit
59656a44a0
|
|
@ -351,6 +351,12 @@ Still open after the accepted phase12 replay:
|
||||||
- this matters because follow-up carryover is now closer to the same continuity interpretation layer that already owns item / organization / scoped-date facts, rather than keeping a separate transition-local parser for the same runtime evidence;
|
- this matters because follow-up carryover is now closer to the same continuity interpretation layer that already owns item / organization / scoped-date facts, rather than keeping a separate transition-local parser for the same runtime evidence;
|
||||||
- targeted continuity and transition regressions now protect inferred anchor carryover when explicit `anchor_type` is absent, plus root-frame temporal fallback at the helper layer;
|
- targeted continuity and transition regressions now protect inferred anchor carryover when explicit `anchor_type` is absent, plus root-frame temporal fallback at the helper layer;
|
||||||
- wide saved-session replay `address_truth_harness_phase12_wider_saved_session_pool_live_20260418_rerun7` remains accepted `20/20`, which is the critical proof that this transition-layer convergence did not reopen the broader saved-session path.
|
- wide saved-session replay `address_truth_harness_phase12_wider_saved_session_pool_live_20260418_rerun7` remains accepted `20/20`, which is the critical proof that this transition-layer convergence did not reopen the broader saved-session path.
|
||||||
|
- the next organization-authority pass now removes one more local history parser from the data-scope / session-bootstrap contour:
|
||||||
|
- `assistantDataScopePolicy.extractKnownOrganizationsFromHistory` no longer rebuilds `known organizations` from raw `assistant_* / organization_candidates / extracted_filters / root_frame_context` fields on its own;
|
||||||
|
- it now reads the shared `resolveAssistantOrganizationAuthority(...)` result first and only keeps assistant-text parsing as a compatibility fallback for older free-text scope replies;
|
||||||
|
- this matters because data-scope probing, organization selection bootstrap, and the broader continuity layer are now closer to one canonical organization merge order instead of keeping a separate debug-field collector inside the scope policy;
|
||||||
|
- targeted data-scope and organization-scope tests now protect that known organizations still include assistant-side authority, grounded address context, and free-text fallback organizations;
|
||||||
|
- wide saved-session replay `address_truth_harness_phase12_wider_saved_session_pool_live_20260418_rerun8` remains accepted `20/20`, which is the critical proof that this data-scope convergence did not reopen the flagship saved-session path.
|
||||||
|
|
||||||
## Next Execution Slice (2026-04-18)
|
## Next Execution Slice (2026-04-18)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,34 +180,18 @@ function createAssistantDataScopePolicy(deps) {
|
||||||
return Array.from(new Set(extracted));
|
return Array.from(new Set(extracted));
|
||||||
}
|
}
|
||||||
function extractKnownOrganizationsFromHistory(items) {
|
function extractKnownOrganizationsFromHistory(items) {
|
||||||
const collected = [];
|
const authority = (0, assistantContinuityPolicy_1.resolveAssistantOrganizationAuthority)({
|
||||||
|
sessionItems: items,
|
||||||
|
toNonEmptyString: assistantOrganizationMatcher_1.normalizeOrganizationScopeValue,
|
||||||
|
normalizeOrganizationScopeValue: assistantOrganizationMatcher_1.normalizeOrganizationScopeValue,
|
||||||
|
mergeKnownOrganizations: assistantOrganizationMatcher_1.mergeKnownOrganizations
|
||||||
|
});
|
||||||
|
const collected = [...authority.knownOrganizations];
|
||||||
for (let index = (Array.isArray(items) ? items.length : 0) - 1; index >= 0; index -= 1) {
|
for (let index = (Array.isArray(items) ? items.length : 0) - 1; index >= 0; index -= 1) {
|
||||||
const item = Array.isArray(items) ? items[index] : null;
|
const item = Array.isArray(items) ? items[index] : null;
|
||||||
if (!item || typeof item !== "object" || item.role !== "assistant") {
|
if (!item || typeof item !== "object" || item.role !== "assistant") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const debug = item.debug;
|
|
||||||
if (debug && typeof debug === "object") {
|
|
||||||
const directFromProbe = Array.isArray(debug.living_chat_data_scope_probe_organizations)
|
|
||||||
? debug.living_chat_data_scope_probe_organizations
|
|
||||||
: [];
|
|
||||||
const knownFromDebug = Array.isArray(debug.assistant_known_organizations)
|
|
||||||
? debug.assistant_known_organizations
|
|
||||||
: [];
|
|
||||||
const directFromCandidates = Array.isArray(debug.organization_candidates) ? debug.organization_candidates : [];
|
|
||||||
const directFromResolved = [
|
|
||||||
(0, assistantOrganizationMatcher_1.normalizeOrganizationScopeValue)(debug.assistant_active_organization),
|
|
||||||
(0, assistantOrganizationMatcher_1.normalizeOrganizationScopeValue)(debug.living_chat_selected_organization),
|
|
||||||
(0, assistantOrganizationMatcher_1.normalizeOrganizationScopeValue)(debug.extracted_filters?.organization),
|
|
||||||
(0, assistantOrganizationMatcher_1.normalizeOrganizationScopeValue)(debug.address_root_frame_context?.organization)
|
|
||||||
].filter((value) => Boolean(value));
|
|
||||||
if (directFromProbe.length > 0 ||
|
|
||||||
knownFromDebug.length > 0 ||
|
|
||||||
directFromCandidates.length > 0 ||
|
|
||||||
directFromResolved.length > 0) {
|
|
||||||
collected.push(...directFromProbe, ...knownFromDebug, ...directFromCandidates, ...directFromResolved);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const parsedFromText = parseOrganizationsFromDataScopeAssistantText(item.text);
|
const parsedFromText = parseOrganizationsFromDataScopeAssistantText(item.text);
|
||||||
if (parsedFromText.length > 0) {
|
if (parsedFromText.length > 0) {
|
||||||
collected.push(...parsedFromText);
|
collected.push(...parsedFromText);
|
||||||
|
|
|
||||||
|
|
@ -249,39 +249,18 @@ export function createAssistantDataScopePolicy(deps: AssistantDataScopePolicyDep
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractKnownOrganizationsFromHistory(items: unknown[]): string[] {
|
function extractKnownOrganizationsFromHistory(items: unknown[]): string[] {
|
||||||
const collected: unknown[] = [];
|
const authority = resolveAssistantOrganizationAuthority({
|
||||||
|
sessionItems: items,
|
||||||
|
toNonEmptyString: normalizeOrganizationScopeValue,
|
||||||
|
normalizeOrganizationScopeValue,
|
||||||
|
mergeKnownOrganizations
|
||||||
|
});
|
||||||
|
const collected: unknown[] = [...authority.knownOrganizations];
|
||||||
for (let index = (Array.isArray(items) ? items.length : 0) - 1; index >= 0; index -= 1) {
|
for (let index = (Array.isArray(items) ? items.length : 0) - 1; index >= 0; index -= 1) {
|
||||||
const item = Array.isArray(items) ? items[index] : null;
|
const item = Array.isArray(items) ? items[index] : null;
|
||||||
if (!item || typeof item !== "object" || (item as { role?: string }).role !== "assistant") {
|
if (!item || typeof item !== "object" || (item as { role?: string }).role !== "assistant") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debug = (item as { debug?: Record<string, unknown> }).debug;
|
|
||||||
if (debug && typeof debug === "object") {
|
|
||||||
const directFromProbe = Array.isArray(debug.living_chat_data_scope_probe_organizations)
|
|
||||||
? debug.living_chat_data_scope_probe_organizations
|
|
||||||
: [];
|
|
||||||
const knownFromDebug = Array.isArray(debug.assistant_known_organizations)
|
|
||||||
? debug.assistant_known_organizations
|
|
||||||
: [];
|
|
||||||
const directFromCandidates = Array.isArray(debug.organization_candidates) ? debug.organization_candidates : [];
|
|
||||||
const directFromResolved = [
|
|
||||||
normalizeOrganizationScopeValue(debug.assistant_active_organization),
|
|
||||||
normalizeOrganizationScopeValue(debug.living_chat_selected_organization),
|
|
||||||
normalizeOrganizationScopeValue(debug.extracted_filters?.organization),
|
|
||||||
normalizeOrganizationScopeValue(debug.address_root_frame_context?.organization)
|
|
||||||
].filter((value): value is string => Boolean(value));
|
|
||||||
|
|
||||||
if (
|
|
||||||
directFromProbe.length > 0 ||
|
|
||||||
knownFromDebug.length > 0 ||
|
|
||||||
directFromCandidates.length > 0 ||
|
|
||||||
directFromResolved.length > 0
|
|
||||||
) {
|
|
||||||
collected.push(...directFromProbe, ...knownFromDebug, ...directFromCandidates, ...directFromResolved);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const parsedFromText = parseOrganizationsFromDataScopeAssistantText((item as { text?: unknown }).text);
|
const parsedFromText = parseOrganizationsFromDataScopeAssistantText((item as { text?: unknown }).text);
|
||||||
if (parsedFromText.length > 0) {
|
if (parsedFromText.length > 0) {
|
||||||
collected.push(...parsedFromText);
|
collected.push(...parsedFromText);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,43 @@ function createPolicy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("assistantDataScopePolicy", () => {
|
describe("assistantDataScopePolicy", () => {
|
||||||
|
it("extracts known organizations from shared assistant organization authority and assistant text fallback", () => {
|
||||||
|
const policy = createPolicy();
|
||||||
|
|
||||||
|
const organizations = policy.extractKnownOrganizationsFromHistory([
|
||||||
|
{
|
||||||
|
role: "assistant",
|
||||||
|
text: "Доступны организации: Org Text, Org Extra.",
|
||||||
|
debug: {
|
||||||
|
execution_lane: "living_chat",
|
||||||
|
living_chat_selected_organization: "Org Selected",
|
||||||
|
assistant_active_organization: "Org Selected",
|
||||||
|
assistant_known_organizations: ["Org Selected", "Org Backup"],
|
||||||
|
organization_candidates: ["Org Candidate"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: "assistant",
|
||||||
|
debug: {
|
||||||
|
execution_lane: "address_query",
|
||||||
|
answer_grounding_check: { status: "grounded" },
|
||||||
|
extracted_filters: {
|
||||||
|
organization: "Org Grounded"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(organizations).toEqual([
|
||||||
|
"Org Grounded",
|
||||||
|
"Org Selected",
|
||||||
|
"Org Backup",
|
||||||
|
"Org Candidate",
|
||||||
|
"Org Text",
|
||||||
|
"Org Extra"
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("recovers active organization from assistant-side living chat authority when grounded answer is absent", () => {
|
it("recovers active organization from assistant-side living chat authority when grounded answer is absent", () => {
|
||||||
const policy = createPolicy();
|
const policy = createPolicy();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue