@tiangong-lca/cli 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -2
- package/dist/src/cli.js +1327 -40
- package/dist/src/cli.js.map +1 -1
- package/dist/src/lib/dataset-author.js +100 -0
- package/dist/src/lib/dataset-author.js.map +1 -0
- package/dist/src/lib/dataset-bilingual.js +545 -0
- package/dist/src/lib/dataset-bilingual.js.map +1 -0
- package/dist/src/lib/dataset-contract.js +350 -0
- package/dist/src/lib/dataset-contract.js.map +1 -0
- package/dist/src/lib/dataset-evidence-search.js +636 -0
- package/dist/src/lib/dataset-evidence-search.js.map +1 -0
- package/dist/src/lib/dataset-import-lca.js +171 -0
- package/dist/src/lib/dataset-import-lca.js.map +1 -0
- package/dist/src/lib/dataset-remote-refresh.js +166 -0
- package/dist/src/lib/dataset-remote-refresh.js.map +1 -0
- package/dist/src/lib/dataset-remote-verify.js +543 -0
- package/dist/src/lib/dataset-remote-verify.js.map +1 -0
- package/dist/src/lib/dataset-validate.js +63 -7
- package/dist/src/lib/dataset-validate.js.map +1 -1
- package/dist/src/lib/flow-payload-validation.js +51 -0
- package/dist/src/lib/flow-payload-validation.js.map +1 -0
- package/dist/src/lib/flow-publish-reviewed-data.js +16 -0
- package/dist/src/lib/flow-publish-reviewed-data.js.map +1 -1
- package/dist/src/lib/flow-publish-version.js +182 -12
- package/dist/src/lib/flow-publish-version.js.map +1 -1
- package/dist/src/lib/identity-preflight.js +1021 -0
- package/dist/src/lib/identity-preflight.js.map +1 -0
- package/dist/src/lib/process-auto-build.js +147 -0
- package/dist/src/lib/process-auto-build.js.map +1 -1
- package/dist/src/lib/process-dedup-review.js +51 -0
- package/dist/src/lib/process-dedup-review.js.map +1 -1
- package/dist/src/lib/process-flow-build-plan.js +1071 -0
- package/dist/src/lib/process-flow-build-plan.js.map +1 -0
- package/dist/src/lib/process-payload-validation.js +14 -7
- package/dist/src/lib/process-payload-validation.js.map +1 -1
- package/dist/src/lib/process-publish-build.js +122 -4
- package/dist/src/lib/process-publish-build.js.map +1 -1
- package/dist/src/lib/process-refresh-references.js +19 -10
- package/dist/src/lib/process-refresh-references.js.map +1 -1
- package/dist/src/lib/process-required-fields.js +810 -0
- package/dist/src/lib/process-required-fields.js.map +1 -0
- package/dist/src/lib/process-save-draft-run.js +4 -1
- package/dist/src/lib/process-save-draft-run.js.map +1 -1
- package/dist/src/lib/publish.js +100 -0
- package/dist/src/lib/publish.js.map +1 -1
- package/dist/src/lib/review-flow.js +58 -0
- package/dist/src/lib/review-flow.js.map +1 -1
- package/dist/src/lib/review-process.js +150 -2
- package/dist/src/lib/review-process.js.map +1 -1
- package/dist/src/lib/runtime-rulesets.js +283 -0
- package/dist/src/lib/runtime-rulesets.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-preflight.js","sourceRoot":"","sources":["../../../src/lib/identity-preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAA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xB;KACF,CAAC;IAEF,MAAM,KAAK,GAAG,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO;QACL,GAAG,UAAU;QACb,KAAK;KACN,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAA2C;IAE3C,OAAO,CAAC,MAAM,oBAAoB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAmC,CAAC;AAC5F,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAwC;IAExC,OAAO,CAAC,MAAM,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAgC,CAAC;AACtF,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,uBAAuB;IACvB,aAAa;IACb,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc;IACd,WAAW;IACX,mBAAmB;IACnB,cAAc;IACd,8BAA8B;IAC9B,mBAAmB;IACnB,kBAAkB;IAClB,8BAA8B;IAC9B,kBAAkB;IAClB,4BAA4B;CAC7B,CAAC","sourcesContent":["import { existsSync, readdirSync, statSync } from 'node:fs';\nimport path from 'node:path';\nimport * as tidasSdk from '@tiangong-lca/tidas-sdk';\nimport { writeJsonArtifact, writeJsonLinesArtifact } from './artifacts.js';\nimport { readRuntimeEnv } from './env.js';\nimport { CliError } from './errors.js';\nimport type { FetchLike } from './http.js';\nimport { postJson } from './http.js';\nimport {\n datasetIdentity,\n detectDatasetKind,\n isRecord,\n readDatasetRowsInput,\n unwrapDatasetPayload,\n type DatasetKind,\n type JsonObject,\n} from './dataset-local.js';\nimport { readJsonInput } from './io.js';\nimport { deriveSupabaseFunctionsBaseUrl, requireSupabaseRestRuntime } from './supabase-client.js';\nimport { resolveSupabaseUserSession } from './supabase-session.js';\nimport {\n normalizeIssuePath,\n type SafeParseSchema,\n type SdkValidationFactory,\n validateSchemaWithDeepFallback,\n} from './tidas-sdk-validation.js';\n\ntype IdentityPreflightKind = 'process' | 'flow';\n\nexport type IdentityPreflightDecision =\n | 'reuse'\n | 'update_same_row'\n | 'version_bump'\n | 'create_new'\n | 'block_duplicate'\n | 'manual_review';\n\nexport type IdentityPreflightStatus = 'passed' | 'blocked' | 'needs_review';\n\nexport type IdentityPreflightFinding = {\n code: string;\n severity: 'info' | 'warning' | 'blocker';\n message: string;\n candidate_index?: number;\n};\n\ntype ValidationSummary = {\n status: 'passed' | 'failed' | 'not_applicable';\n validator: string | null;\n issue_count: number;\n issues: Array<{\n path: string;\n message: string;\n code: string;\n }>;\n};\n\ntype IdentityProfile = {\n id: string | null;\n version: string | null;\n state_code: number | null;\n names: string[];\n normalized_names: string[];\n identity_key: string;\n exchange_signature: string[];\n fields: Record<string, string | null | string[]>;\n};\n\nexport type IdentityPreflightCandidateReport = {\n index: number;\n id: string | null;\n version: string | null;\n state_code: number | null;\n identity_key: string;\n match_score: number;\n match_reasons: string[];\n decision_hint: IdentityPreflightDecision | null;\n};\n\nexport type IdentityPreflightCandidateSourceReport = {\n path: string;\n kind: 'embedded_request' | 'file' | 'directory' | 'remote_search';\n row_count: number;\n scanned_files: string[];\n endpoint?: string;\n query?: string;\n filter?: JsonObject | null;\n};\n\nexport type IdentityPreflightReport = {\n schema_version: 1;\n generated_at_utc: string;\n kind: IdentityPreflightKind;\n status: IdentityPreflightStatus;\n decision: IdentityPreflightDecision;\n confidence: 'high' | 'medium' | 'low';\n input_path: string;\n out_dir: string | null;\n target: {\n id: string | null;\n version: string | null;\n identity_key: string;\n exchange_signature: string[];\n schema_validation: ValidationSummary;\n };\n candidates: IdentityPreflightCandidateReport[];\n candidate_sources: IdentityPreflightCandidateSourceReport[];\n findings: IdentityPreflightFinding[];\n blockers: IdentityPreflightFinding[];\n next_action:\n | 'reuse_existing'\n | 'repair_existing_draft'\n | 'prepare_version_update'\n | 'materialize_new_payload'\n | 'stop_duplicate'\n | 'queue_manual_review';\n files: {\n identity_decision: string | null;\n candidates: string | null;\n candidate_sources: string | null;\n };\n};\n\nexport type RunIdentityPreflightOptions = {\n inputPath: string;\n outDir?: string | null;\n rawInput?: unknown;\n candidateInputPaths?: string[];\n remoteCandidateSearch?: boolean;\n remoteQuery?: string | null;\n remoteFilter?: JsonObject | null;\n remoteLimit?: number | null;\n env?: NodeJS.ProcessEnv;\n fetchImpl?: FetchLike;\n timeoutMs?: number;\n now?: Date;\n schemas?: Partial<Record<IdentityPreflightKind, SafeParseSchema>>;\n};\n\nexport type RunProcessIdentityPreflightOptions = RunIdentityPreflightOptions;\nexport type RunFlowIdentityPreflightOptions = RunIdentityPreflightOptions;\nexport type ProcessIdentityPreflightReport = IdentityPreflightReport & { kind: 'process' };\nexport type FlowIdentityPreflightReport = IdentityPreflightReport & { kind: 'flow' };\n\ntype NormalizedInput = {\n target: JsonObject;\n candidates: JsonObject[];\n candidateInputPaths: string[];\n remoteCandidateSearch: RemoteCandidateSearchConfig;\n};\n\ntype CandidateEvaluation = {\n report: IdentityPreflightCandidateReport;\n findings: IdentityPreflightFinding[];\n};\n\ntype RemoteCandidateSearchConfig = {\n enabled: boolean;\n query: string | null;\n filter: JsonObject | null;\n limit: number | null;\n};\n\ntype RemoteCandidateRead = {\n rows: JsonObject[];\n source: IdentityPreflightCandidateSourceReport;\n};\n\nconst SCHEMA_EXPORTS: Record<IdentityPreflightKind, keyof typeof tidasSdk> = {\n flow: 'FlowSchema' as keyof typeof tidasSdk,\n process: 'ProcessSchema' as keyof typeof tidasSdk,\n};\n\nconst ENTITY_FACTORY_EXPORTS: Record<IdentityPreflightKind, keyof typeof tidasSdk> = {\n flow: 'createFlow' as keyof typeof tidasSdk,\n process: 'createProcess' as keyof typeof tidasSdk,\n};\n\nfunction requiredInputPath(inputPath: string): string {\n const normalized = inputPath.trim();\n if (!normalized) {\n throw new CliError('Missing required --input value.', {\n code: 'IDENTITY_PREFLIGHT_INPUT_REQUIRED',\n exitCode: 2,\n });\n }\n return normalized;\n}\n\nfunction normalizeToRecord(value: unknown, label: string): JsonObject {\n if (!isRecord(value)) {\n throw new CliError(`${label} must be a JSON object.`, {\n code: 'IDENTITY_PREFLIGHT_INVALID_INPUT',\n exitCode: 2,\n });\n }\n return value;\n}\n\nfunction normalizeRows(value: unknown, label: string): JsonObject[] {\n if (value === undefined || value === null) {\n return [];\n }\n const rows = isRecord(value) && Array.isArray(value.rows) ? value.rows : value;\n const normalizedRows = Array.isArray(rows) ? rows : [rows];\n return normalizedRows.map((row, index) => normalizeToRecord(row, `${label}[${index}]`));\n}\n\nfunction normalizePathList(value: unknown, label: string): string[] {\n if (value === undefined || value === null) {\n return [];\n }\n const values = Array.isArray(value) ? value : [value];\n return values.flatMap((entry, index) => {\n if (typeof entry !== 'string') {\n throw new CliError(`${label}[${index}] must be a string path.`, {\n code: 'IDENTITY_PREFLIGHT_INVALID_CANDIDATE_INPUT',\n exitCode: 2,\n });\n }\n return entry\n .split(',')\n .map((pathValue) => pathValue.trim())\n .filter(Boolean);\n });\n}\n\nfunction normalizePositiveInteger(value: unknown, label: string): number | null {\n if (value === undefined || value === null || value === '') {\n return null;\n }\n const parsed = typeof value === 'number' ? value : Number.parseInt(String(value), 10);\n if (!Number.isInteger(parsed) || parsed <= 0) {\n throw new CliError(`Expected ${label} to be a positive integer.`, {\n code: 'IDENTITY_PREFLIGHT_INVALID_REMOTE_LIMIT',\n exitCode: 2,\n });\n }\n return parsed;\n}\n\nfunction normalizeRemoteCandidateSearch(value: unknown): RemoteCandidateSearchConfig {\n if (value === undefined || value === null) {\n return { enabled: false, query: null, filter: null, limit: null };\n }\n if (typeof value === 'boolean') {\n return { enabled: value, query: null, filter: null, limit: null };\n }\n if (!isRecord(value)) {\n throw new CliError('remote_candidate_search must be a boolean or object.', {\n code: 'IDENTITY_PREFLIGHT_INVALID_REMOTE_SEARCH',\n exitCode: 2,\n });\n }\n\n const enabled = value.enabled === undefined ? true : Boolean(value.enabled);\n const query = textValue(value.query) ?? textValue(value.search_query);\n const filter =\n value.filter === undefined || value.filter === null\n ? null\n : normalizeToRecord(value.filter, 'remote_candidate_search.filter');\n return {\n enabled,\n query,\n filter,\n limit: normalizePositiveInteger(value.limit, 'remote_candidate_search.limit'),\n };\n}\n\nfunction pickKindTarget(input: JsonObject, kind: IdentityPreflightKind): unknown {\n if (input.target !== undefined) {\n return input.target;\n }\n if (input.candidate !== undefined) {\n return input.candidate;\n }\n if (kind === 'process' && input.process !== undefined) {\n return input.process;\n }\n if (kind === 'flow' && input.flow !== undefined) {\n return input.flow;\n }\n return input;\n}\n\nfunction normalizePreflightInput(rawInput: unknown, kind: IdentityPreflightKind): NormalizedInput {\n const input = normalizeToRecord(rawInput, 'identity preflight input');\n const target = normalizeToRecord(pickKindTarget(input, kind), 'identity preflight target');\n const candidateGroups = [\n ...normalizeRows(input.candidates, 'candidates'),\n ...normalizeRows(input.existing, 'existing'),\n ...normalizeRows(input.existing_rows, 'existing_rows'),\n ...normalizeRows(input.rows, 'rows'),\n ];\n\n return {\n target,\n candidates: candidateGroups,\n candidateInputPaths: [\n ...normalizePathList(input.candidate_input, 'candidate_input'),\n ...normalizePathList(input.candidate_inputs, 'candidate_inputs'),\n ...normalizePathList(input.candidateInputPaths, 'candidateInputPaths'),\n ...normalizePathList(input.candidate_files, 'candidate_files'),\n ...normalizePathList(input.candidateFiles, 'candidateFiles'),\n ],\n remoteCandidateSearch: normalizeRemoteCandidateSearch(\n input.remote_candidate_search ?? input.remoteCandidateSearch ?? input.remote_candidates,\n ),\n };\n}\n\ninterface CandidateInputStats {\n isFile(): boolean;\n isDirectory(): boolean;\n}\n\nfunction isCandidateDatasetFile(filePath: string): boolean {\n return /\\.(?:json|jsonl)$/iu.test(path.basename(filePath));\n}\n\nfunction throwUnsupportedCandidateInput(resolved: string): never {\n throw new CliError(`Candidate input must be a JSON/JSONL file or directory: ${resolved}`, {\n code: 'IDENTITY_PREFLIGHT_CANDIDATE_INPUT_UNSUPPORTED',\n exitCode: 2,\n });\n}\n\nfunction collectCandidateFilesFromStats(resolved: string, stats: CandidateInputStats): string[] {\n if (stats.isFile()) {\n if (!isCandidateDatasetFile(resolved)) {\n throwUnsupportedCandidateInput(resolved);\n }\n return [resolved];\n }\n if (!stats.isDirectory()) {\n throwUnsupportedCandidateInput(resolved);\n }\n\n const files: string[] = [];\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n if (entry.name.startsWith('.')) {\n continue;\n }\n const entryPath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n visit(entryPath);\n } else if (entry.isFile() && isCandidateDatasetFile(entry.name)) {\n files.push(entryPath);\n }\n }\n };\n visit(resolved);\n return files.sort((left, right) => left.localeCompare(right));\n}\n\nfunction collectCandidateFiles(candidatePath: string): string[] {\n const resolved = path.resolve(candidatePath);\n if (!existsSync(resolved)) {\n throw new CliError(`Candidate input not found: ${resolved}`, {\n code: 'IDENTITY_PREFLIGHT_CANDIDATE_INPUT_NOT_FOUND',\n exitCode: 2,\n });\n }\n\n const stats = statSync(resolved);\n return collectCandidateFilesFromStats(resolved, stats);\n}\n\nfunction readCandidateSource(candidatePath: string): {\n rows: JsonObject[];\n source: IdentityPreflightCandidateSourceReport;\n} {\n const resolved = path.resolve(candidatePath);\n const files = collectCandidateFiles(resolved);\n const rows = files.flatMap((file) => readDatasetRowsInput(file));\n const kind = statSync(resolved).isDirectory() ? 'directory' : 'file';\n return {\n rows,\n source: {\n path: resolved,\n kind,\n row_count: rows.length,\n scanned_files: files,\n },\n };\n}\n\nfunction mergeRemoteCandidateSearchConfig(\n inputConfig: RemoteCandidateSearchConfig,\n options: RunIdentityPreflightOptions,\n): RemoteCandidateSearchConfig {\n return {\n enabled: options.remoteCandidateSearch ?? inputConfig.enabled,\n query: options.remoteQuery?.trim() || inputConfig.query,\n filter: options.remoteFilter ?? inputConfig.filter,\n limit: options.remoteLimit ?? inputConfig.limit,\n };\n}\n\nfunction remoteSearchEndpoint(kind: IdentityPreflightKind): string {\n return kind === 'process' ? 'process_hybrid_search' : 'flow_hybrid_search';\n}\n\nfunction defaultRemoteQuery(profile: IdentityProfile): string | null {\n return (\n profile.names[0] ??\n Object.values(profile.fields)\n .flat()\n .find((value): value is string => typeof value === 'string' && value.trim().length > 0) ??\n (profile.identity_key ? profile.identity_key : null)\n );\n}\n\nfunction remoteSearchFilter(\n kind: IdentityPreflightKind,\n profile: IdentityProfile,\n explicitFilter: JsonObject | null,\n): JsonObject | null {\n const filter: JsonObject = explicitFilter ? { ...explicitFilter } : {};\n if (kind === 'flow' && filter.flowType === undefined) {\n const flowType = Array.isArray(profile.fields.type_of_dataset)\n ? profile.fields.type_of_dataset[0]\n : profile.fields.type_of_dataset;\n if (flowType) {\n filter.flowType = flowType;\n }\n }\n return Object.keys(filter).length > 0 ? filter : null;\n}\n\nfunction rowsFromRemoteSearchResponse(value: unknown): JsonObject[] {\n const rows = isRecord(value)\n ? (value.data ?? value.rows ?? value.results ?? value.candidates ?? [])\n : value;\n if (rows === undefined || rows === null) {\n return [];\n }\n return normalizeRows(rows, 'remote search candidates');\n}\n\nasync function readRemoteCandidateSource(\n kind: IdentityPreflightKind,\n targetProfile: IdentityProfile,\n config: RemoteCandidateSearchConfig,\n options: RunIdentityPreflightOptions,\n): Promise<RemoteCandidateRead | null> {\n if (!config.enabled) {\n return null;\n }\n\n const query = config.query ?? defaultRemoteQuery(targetProfile);\n if (!query) {\n throw new CliError('Remote identity candidate search requires a query.', {\n code: 'IDENTITY_PREFLIGHT_REMOTE_QUERY_REQUIRED',\n exitCode: 2,\n });\n }\n\n const runtimeEnv = readRuntimeEnv(options.env ?? process.env);\n const runtime = requireSupabaseRestRuntime(options.env ?? process.env);\n const fetchImpl = options.fetchImpl ?? (fetch as FetchLike);\n const timeoutMs = options.timeoutMs ?? 10_000;\n const endpoint = remoteSearchEndpoint(kind);\n const url = `${deriveSupabaseFunctionsBaseUrl(runtime.apiBaseUrl)}/${endpoint}`;\n const session = await resolveSupabaseUserSession({\n runtime,\n fetchImpl,\n timeoutMs,\n now: options.now,\n });\n const filter = remoteSearchFilter(kind, targetProfile, config.filter);\n const body: JsonObject = {\n query,\n ...(filter ? { filter } : {}),\n ...(config.limit ? { limit: config.limit } : {}),\n };\n const headers: Record<string, string> = {\n Authorization: `Bearer ${session.accessToken}`,\n 'Content-Type': 'application/json',\n };\n if (runtimeEnv.region) {\n headers['x-region'] = runtimeEnv.region;\n }\n\n const response = await postJson({\n url,\n headers,\n body,\n timeoutMs,\n fetchImpl,\n });\n const rows = rowsFromRemoteSearchResponse(response);\n const limitedRows = config.limit ? rows.slice(0, config.limit) : rows;\n return {\n rows: limitedRows,\n source: {\n path: url,\n kind: 'remote_search',\n row_count: limitedRows.length,\n scanned_files: [],\n endpoint,\n query,\n filter,\n },\n };\n}\n\nfunction schemaForKind(\n kind: IdentityPreflightKind,\n schemas: Partial<Record<IdentityPreflightKind, SafeParseSchema>> | undefined,\n): { validator: string; schema: SafeParseSchema; createEntity: SdkValidationFactory | null } {\n if (schemas?.[kind]) {\n return {\n validator: 'injected',\n schema: schemas[kind],\n createEntity: null,\n };\n }\n\n const exportName = SCHEMA_EXPORTS[kind];\n const candidate = (tidasSdk as Record<string, unknown>)[exportName];\n if (\n !candidate ||\n typeof candidate !== 'object' ||\n typeof (candidate as SafeParseSchema).safeParse !== 'function'\n ) {\n throw new CliError(`${String(exportName)} is unavailable in @tiangong-lca/tidas-sdk.`, {\n code: 'IDENTITY_PREFLIGHT_SCHEMA_UNAVAILABLE',\n exitCode: 2,\n details: { kind },\n });\n }\n\n const factoryName = ENTITY_FACTORY_EXPORTS[kind];\n const createEntity = (tidasSdk as Record<string, unknown>)[factoryName];\n return {\n validator: `@tiangong-lca/tidas-sdk/${String(exportName)}`,\n schema: candidate as SafeParseSchema,\n createEntity:\n typeof createEntity === 'function' ? (createEntity as SdkValidationFactory) : null,\n };\n}\n\nfunction validateTargetSchema(\n target: JsonObject,\n kind: IdentityPreflightKind,\n schemas: Partial<Record<IdentityPreflightKind, SafeParseSchema>> | undefined,\n): ValidationSummary {\n const detectedKind = detectDatasetKind(target);\n if (detectedKind && detectedKind !== kind) {\n return {\n status: 'failed',\n validator: null,\n issue_count: 1,\n issues: [\n {\n path: '<root>',\n message: `Expected ${kind} target but detected ${detectedKind}.`,\n code: 'dataset_kind_mismatch',\n },\n ],\n };\n }\n\n if (!detectedKind) {\n return {\n status: 'not_applicable',\n validator: null,\n issue_count: 0,\n issues: [],\n };\n }\n\n const { validator, schema, createEntity } = schemaForKind(kind, schemas);\n const payload = unwrapDatasetPayload(target);\n const outcome = validateSchemaWithDeepFallback(schema, payload, createEntity);\n if (outcome.success) {\n return {\n status: 'passed',\n validator,\n issue_count: 0,\n issues: [],\n };\n }\n\n return {\n status: 'failed',\n validator,\n issue_count: outcome.issues.length,\n issues: outcome.issues.map((issue) => ({\n path: normalizeIssuePath(issue.path),\n message: issue.message ?? 'Validation failed',\n code: issue.code ?? 'custom',\n })),\n };\n}\n\nfunction normalizeText(value: string): string {\n return value\n .normalize('NFKC')\n .trim()\n .toLowerCase()\n .replace(/[^\\p{Letter}\\p{Number}]+/gu, ' ')\n .replace(/\\s+/gu, ' ')\n .trim();\n}\n\nfunction normalizeKey(key: string): string {\n return key\n .split(':')\n .pop()!\n .replace(/[^a-zA-Z0-9]+/gu, '')\n .toLowerCase();\n}\n\nfunction textValue(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim();\n return trimmed || null;\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n return String(value);\n }\n return null;\n}\n\nfunction collectText(value: unknown, output: string[] = []): string[] {\n const direct = textValue(value);\n if (direct) {\n output.push(direct);\n return output;\n }\n if (Array.isArray(value)) {\n for (const entry of value) {\n collectText(entry, output);\n }\n return output;\n }\n if (isRecord(value)) {\n if (textValue(value['#text'])) {\n output.push(textValue(value['#text']) as string);\n }\n for (const [key, entry] of Object.entries(value)) {\n if (key === '#text') {\n continue;\n }\n collectText(entry, output);\n }\n }\n return output;\n}\n\nfunction collectValuesByKey(\n value: unknown,\n wantedKeys: Set<string>,\n output: unknown[] = [],\n): unknown[] {\n if (Array.isArray(value)) {\n for (const entry of value) {\n collectValuesByKey(entry, wantedKeys, output);\n }\n return output;\n }\n if (!isRecord(value)) {\n return output;\n }\n for (const [key, entry] of Object.entries(value)) {\n if (wantedKeys.has(normalizeKey(key))) {\n output.push(entry);\n }\n collectValuesByKey(entry, wantedKeys, output);\n }\n return output;\n}\n\nfunction uniqueTexts(values: unknown[]): string[] {\n const normalized = new Map<string, string>();\n for (const value of values) {\n for (const text of collectText(value)) {\n const key = normalizeText(text);\n if (key && !normalized.has(key)) {\n normalized.set(key, text.trim());\n }\n }\n }\n return [...normalized.values()].sort((a, b) => normalizeText(a).localeCompare(normalizeText(b)));\n}\n\nfunction firstUniqueText(...values: unknown[]): string | null {\n return uniqueTexts(values)[0] ?? null;\n}\n\nfunction fieldFromKeys(row: JsonObject, payload: JsonObject, keys: string[]): string | null {\n const wanted = new Set(keys.map(normalizeKey));\n return firstUniqueText(\n ...collectValuesByKey(row, wanted),\n ...collectValuesByKey(payload, wanted),\n );\n}\n\nfunction textListFromKeys(row: JsonObject, payload: JsonObject, keys: string[]): string[] {\n const wanted = new Set(keys.map(normalizeKey));\n return uniqueTexts([...collectValuesByKey(row, wanted), ...collectValuesByKey(payload, wanted)]);\n}\n\nfunction normalizedList(values: string[]): string[] {\n return [...new Set(values.map(normalizeText).filter(Boolean))].sort();\n}\n\nfunction numberOrNull(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === 'string' && value.trim()) {\n const parsed = Number.parseInt(value.trim(), 10);\n return Number.isInteger(parsed) ? parsed : null;\n }\n return null;\n}\n\nfunction collectExchangeLikeRecords(value: unknown, output: JsonObject[] = []): JsonObject[] {\n if (Array.isArray(value)) {\n for (const entry of value) {\n collectExchangeLikeRecords(entry, output);\n }\n return output;\n }\n if (!isRecord(value)) {\n return output;\n }\n\n const keys = new Set(Object.keys(value).map(normalizeKey));\n if (\n keys.has('referencetoflowdataset') ||\n keys.has('flowid') ||\n keys.has('flowuuid') ||\n keys.has('flow') ||\n keys.has('exchangedirection')\n ) {\n output.push(value);\n }\n\n for (const entry of Object.values(value)) {\n collectExchangeLikeRecords(entry, output);\n }\n return output;\n}\n\nfunction exchangeRecordSignature(record: JsonObject): string | null {\n const flowId = fieldFromKeys(record, record, [\n '@refObjectId',\n 'refObjectId',\n 'flow_id',\n 'flowId',\n 'flow_uuid',\n 'flowUuid',\n 'referenceToFlowDataSet',\n ]);\n const direction = fieldFromKeys(record, record, [\n 'exchangeDirection',\n 'direction',\n 'inputGroup',\n 'outputGroup',\n ]);\n const amount = fieldFromKeys(record, record, [\n 'meanAmount',\n 'mean_amount',\n 'resultingAmount',\n 'resulting_amount',\n 'amount',\n 'meanValue',\n ]);\n\n const normalizedFlowId = flowId ? normalizeText(flowId) : '';\n if (!normalizedFlowId) {\n return null;\n }\n return [normalizedFlowId, normalizeText(direction ?? ''), normalizeText(amount ?? '')].join(':');\n}\n\nfunction processExchangeSignature(row: JsonObject, payload: JsonObject): string[] {\n return [\n ...new Set(\n [...collectExchangeLikeRecords(row), ...collectExchangeLikeRecords(payload)]\n .map(exchangeRecordSignature)\n .filter((entry): entry is string => Boolean(entry)),\n ),\n ].sort();\n}\n\nfunction profileDatasetIdentity(\n row: JsonObject,\n payload: JsonObject,\n kind: IdentityPreflightKind,\n): { id: string | null; version: string | null } {\n const detectedKind = detectDatasetKind(row);\n const identity = datasetIdentity(\n row,\n payload,\n detectedKind === kind ? (kind as DatasetKind) : null,\n );\n return {\n id: firstUniqueText(row.id, row.process_id, row.flow_id, row.uuid, identity.id) ?? identity.id,\n version:\n firstUniqueText(row.version, row.dataset_version, identity.version) ?? identity.version,\n };\n}\n\nfunction processProfile(row: JsonObject): IdentityProfile {\n const payload = unwrapDatasetPayload(row);\n const identity = profileDatasetIdentity(row, payload, 'process');\n const names = textListFromKeys(row, payload, [\n 'name',\n 'baseName',\n 'shortDescription',\n 'name_en',\n 'name_zh',\n ]);\n const referenceFlowIds = textListFromKeys(row, payload, [\n 'reference_flow_id',\n 'referenceFlowId',\n 'reference_product_flow',\n 'referenceProductFlow',\n 'referenceToReferenceFlow',\n 'referenceToFlowDataSet',\n '@refObjectId',\n 'refObjectId',\n ]);\n const operation = fieldFromKeys(row, payload, ['operation', 'process_operation']);\n const quantitativeReference = fieldFromKeys(row, payload, [\n 'quantitative_reference',\n 'quantitativeReference',\n 'qref',\n 'referenceToReferenceFlow',\n ]);\n const geography = fieldFromKeys(row, payload, [\n 'geography',\n 'location',\n 'locationOfOperationSupplyOrProduction',\n ]);\n const time = fieldFromKeys(row, payload, [\n 'time',\n 'reference_year',\n 'referenceYear',\n 'timePeriod',\n ]);\n const technologyRoute = fieldFromKeys(row, payload, [\n 'technology_route',\n 'technologyRoute',\n 'technology',\n 'treatmentStandardsRoutes',\n ]);\n const systemBoundary = fieldFromKeys(row, payload, [\n 'system_boundary',\n 'systemBoundary',\n 'boundary',\n ]);\n const providerRole = fieldFromKeys(row, payload, ['provider_role', 'providerRole']);\n const exchangeSignature = processExchangeSignature(row, payload);\n const keyParts = [\n ...normalizedList(names).slice(0, 4),\n ...normalizedList(referenceFlowIds).slice(0, 4),\n normalizeText(operation ?? ''),\n normalizeText(quantitativeReference ?? ''),\n normalizeText(geography ?? ''),\n normalizeText(time ?? ''),\n normalizeText(technologyRoute ?? ''),\n normalizeText(systemBoundary ?? ''),\n normalizeText(providerRole ?? ''),\n exchangeSignature.join(','),\n ].filter(Boolean);\n\n return {\n id: identity.id,\n version: identity.version,\n state_code: numberOrNull(row.state_code ?? row.stateCode),\n names,\n normalized_names: normalizedList(names),\n identity_key: keyParts.join('|'),\n exchange_signature: exchangeSignature,\n fields: {\n reference_flow_ids: referenceFlowIds,\n operation,\n quantitative_reference: quantitativeReference,\n geography,\n time,\n technology_route: technologyRoute,\n system_boundary: systemBoundary,\n provider_role: providerRole,\n },\n };\n}\n\nfunction flowProfile(row: JsonObject): IdentityProfile {\n const payload = unwrapDatasetPayload(row);\n const identity = profileDatasetIdentity(row, payload, 'flow');\n const names = textListFromKeys(row, payload, [\n 'name',\n 'baseName',\n 'shortDescription',\n 'name_en',\n 'name_zh',\n 'synonyms',\n ]);\n const typeOfDataset = fieldFromKeys(row, payload, [\n 'type_of_dataset',\n 'typeOfDataSet',\n 'flow_type',\n 'flowType',\n ]);\n const cas = fieldFromKeys(row, payload, ['CASNumber', 'cas_number', 'cas']);\n const flowProperty = fieldFromKeys(row, payload, [\n 'flow_property',\n 'flowProperty',\n 'referenceToFlowPropertyDataSet',\n 'reference_property',\n 'referenceProperty',\n ]);\n const referenceUnit = fieldFromKeys(row, payload, ['reference_unit', 'referenceUnit', 'unit']);\n const categories = textListFromKeys(row, payload, ['category', 'compartment']);\n const geography = fieldFromKeys(row, payload, [\n 'geography',\n 'location',\n 'market',\n 'mixAndLocationTypes',\n ]);\n const keyParts = [\n normalizeText(typeOfDataset ?? ''),\n ...normalizedList(names).slice(0, 4),\n normalizeText(cas ?? ''),\n normalizeText(flowProperty ?? ''),\n normalizeText(referenceUnit ?? ''),\n ...normalizedList(categories).slice(0, 4),\n normalizeText(geography ?? ''),\n ].filter(Boolean);\n\n return {\n id: identity.id,\n version: identity.version,\n state_code: numberOrNull(row.state_code ?? row.stateCode),\n names,\n normalized_names: normalizedList(names),\n identity_key: keyParts.join('|'),\n exchange_signature: [],\n fields: {\n type_of_dataset: typeOfDataset,\n cas,\n flow_property: flowProperty,\n reference_unit: referenceUnit,\n categories,\n geography,\n },\n };\n}\n\nfunction profileForKind(row: JsonObject, kind: IdentityPreflightKind): IdentityProfile {\n return kind === 'process' ? processProfile(row) : flowProfile(row);\n}\n\nfunction intersects(left: string[], right: string[]): boolean {\n const rightSet = new Set(right);\n return left.some((entry) => rightSet.has(entry));\n}\n\nfunction normalizedFieldValues(value: string | null | string[]): string[] {\n return (Array.isArray(value) ? value : [value])\n .filter((entry): entry is string => typeof entry === 'string')\n .map(normalizeText)\n .filter(Boolean);\n}\n\nfunction sameNonEmptyField(\n left: string | null | string[],\n right: string | null | string[],\n): boolean {\n const leftValues = normalizedFieldValues(left);\n const rightValues = normalizedFieldValues(right);\n return leftValues.length > 0 && rightValues.length > 0 && intersects(leftValues, rightValues);\n}\n\nfunction sameExchangeSignature(left: string[], right: string[]): boolean {\n return left.length > 0 && right.length > 0 && left.join('|') === right.join('|');\n}\n\nfunction hasEquivalentFlowCore(target: IdentityProfile, candidate: IdentityProfile): boolean {\n const hasSameType = sameNonEmptyField(\n target.fields.type_of_dataset,\n candidate.fields.type_of_dataset,\n );\n const hasSameProperty = sameNonEmptyField(\n target.fields.flow_property,\n candidate.fields.flow_property,\n );\n const hasSameUnit = sameNonEmptyField(\n target.fields.reference_unit,\n candidate.fields.reference_unit,\n );\n const hasSameCas = sameNonEmptyField(target.fields.cas, candidate.fields.cas);\n const hasSameCategory = sameNonEmptyField(target.fields.categories, candidate.fields.categories);\n\n return (\n hasSameType &&\n hasSameProperty &&\n hasSameUnit &&\n intersects(target.normalized_names, candidate.normalized_names) &&\n (hasSameCas || hasSameCategory)\n );\n}\n\nfunction candidateEvaluation(\n target: IdentityProfile,\n candidate: IdentityProfile,\n kind: IdentityPreflightKind,\n index: number,\n): CandidateEvaluation {\n const matchReasons: string[] = [];\n let matchScore = 0;\n let decisionHint: IdentityPreflightDecision | null = null;\n\n if (target.id && candidate.id && target.id === candidate.id) {\n matchScore += 100;\n matchReasons.push('same_dataset_id');\n if (candidate.state_code === 0) {\n decisionHint = 'update_same_row';\n } else if (target.version && candidate.version && target.version !== candidate.version) {\n decisionHint = 'version_bump';\n } else {\n decisionHint = 'reuse';\n }\n }\n\n if (\n target.identity_key &&\n candidate.identity_key &&\n target.identity_key === candidate.identity_key\n ) {\n matchScore += 90;\n matchReasons.push('same_identity_key');\n if (!decisionHint) {\n decisionHint = 'block_duplicate';\n }\n }\n\n if (\n kind === 'process' &&\n sameExchangeSignature(target.exchange_signature, candidate.exchange_signature)\n ) {\n matchScore += 40;\n matchReasons.push('same_exchange_signature');\n if (!decisionHint) {\n decisionHint = 'manual_review';\n }\n }\n\n const hasOverlappingName = intersects(target.normalized_names, candidate.normalized_names);\n if (hasOverlappingName) {\n matchScore += 20;\n matchReasons.push('overlapping_name');\n if (!decisionHint) {\n decisionHint = 'manual_review';\n }\n }\n\n const targetReferenceFields = Object.values(target.fields)\n .flat()\n .filter((value): value is string => typeof value === 'string')\n .map(normalizeText)\n .filter(Boolean);\n const candidateReferenceFields = Object.values(candidate.fields)\n .flat()\n .filter((value): value is string => typeof value === 'string')\n .map(normalizeText)\n .filter(Boolean);\n const hasOverlappingIdentityField = intersects(targetReferenceFields, candidateReferenceFields);\n if (hasOverlappingIdentityField) {\n matchScore += 10;\n matchReasons.push('overlapping_identity_field');\n }\n\n if (\n kind === 'process' &&\n decisionHint === 'manual_review' &&\n matchReasons.includes('same_exchange_signature') &&\n hasOverlappingIdentityField\n ) {\n matchScore += 20;\n matchReasons.push('same_exchange_fingerprint');\n decisionHint = 'block_duplicate';\n }\n\n if (\n kind === 'flow' &&\n (decisionHint === null || decisionHint === 'manual_review') &&\n hasEquivalentFlowCore(target, candidate)\n ) {\n matchScore += 70;\n matchReasons.push('equivalent_flow_core_fields');\n decisionHint = 'block_duplicate';\n }\n\n const findings: IdentityPreflightFinding[] = [];\n if (decisionHint === 'block_duplicate') {\n findings.push({\n code: `${kind}_duplicate_candidate`,\n severity: 'blocker',\n message: `Candidate ${index} matches the target identity and should block new ${kind} creation.`,\n candidate_index: index,\n });\n } else if (decisionHint === 'manual_review') {\n findings.push({\n code: `${kind}_manual_review_candidate`,\n severity: 'warning',\n message: `Candidate ${index} is similar enough to require manual review before new ${kind} creation.`,\n candidate_index: index,\n });\n } else if (decisionHint) {\n findings.push({\n code: `${kind}_${decisionHint}`,\n severity: 'info',\n message: `Candidate ${index} supports decision ${decisionHint}.`,\n candidate_index: index,\n });\n }\n\n return {\n report: {\n index,\n id: candidate.id,\n version: candidate.version,\n state_code: candidate.state_code,\n identity_key: candidate.identity_key,\n match_score: matchScore,\n match_reasons: matchReasons,\n decision_hint: decisionHint,\n },\n findings,\n };\n}\n\nfunction chooseDecision(\n evaluations: CandidateEvaluation[],\n validation: ValidationSummary,\n kind: IdentityPreflightKind,\n): {\n decision: IdentityPreflightDecision;\n confidence: 'high' | 'medium' | 'low';\n findings: IdentityPreflightFinding[];\n} {\n const findings = evaluations.flatMap((evaluation) => evaluation.findings);\n if (validation.status === 'failed') {\n return {\n decision: 'manual_review',\n confidence: 'high',\n findings: [\n {\n code: `${kind}_schema_invalid`,\n severity: 'blocker',\n message: `Target ${kind} payload failed schema validation.`,\n },\n ...findings,\n ],\n };\n }\n\n const sorted = [...evaluations].sort(\n (left, right) => right.report.match_score - left.report.match_score,\n );\n const top = sorted[0]?.report;\n if (!top || top.match_score === 0) {\n return {\n decision: 'create_new',\n confidence: 'medium',\n findings: [\n {\n code: `${kind}_no_duplicate_candidate`,\n severity: 'info',\n message: `No duplicate ${kind} candidate matched the target identity.`,\n },\n ...findings,\n ],\n };\n }\n\n if (top.decision_hint === 'block_duplicate') {\n return {\n decision: 'block_duplicate',\n confidence: top.match_score >= 90 ? 'high' : 'medium',\n findings,\n };\n }\n if (\n top.decision_hint === 'reuse' ||\n top.decision_hint === 'update_same_row' ||\n top.decision_hint === 'version_bump'\n ) {\n return {\n decision: top.decision_hint,\n confidence: top.match_score >= 90 ? 'high' : 'medium',\n findings,\n };\n }\n\n return {\n decision: 'manual_review',\n confidence: top.match_score >= 60 ? 'medium' : 'low',\n findings,\n };\n}\n\nfunction statusForDecision(\n decision: IdentityPreflightDecision,\n blockers: IdentityPreflightFinding[],\n): IdentityPreflightStatus {\n if (blockers.length > 0 || decision === 'block_duplicate') {\n return 'blocked';\n }\n if (decision === 'manual_review') {\n return 'needs_review';\n }\n return 'passed';\n}\n\nfunction nextActionForDecision(\n decision: IdentityPreflightDecision,\n): IdentityPreflightReport['next_action'] {\n if (decision === 'reuse') {\n return 'reuse_existing';\n }\n if (decision === 'update_same_row') {\n return 'repair_existing_draft';\n }\n if (decision === 'version_bump') {\n return 'prepare_version_update';\n }\n if (decision === 'block_duplicate') {\n return 'stop_duplicate';\n }\n if (decision === 'manual_review') {\n return 'queue_manual_review';\n }\n return 'materialize_new_payload';\n}\n\nfunction writeArtifacts(\n report: IdentityPreflightReport,\n outDir: string | null | undefined,\n): IdentityPreflightReport['files'] {\n if (!outDir) {\n return {\n identity_decision: null,\n candidates: null,\n candidate_sources: null,\n };\n }\n\n const resolved = path.resolve(outDir);\n const files = {\n identity_decision: path.join(resolved, 'outputs', 'identity-decision.json'),\n candidates: path.join(resolved, 'outputs', 'identity-candidates.jsonl'),\n candidate_sources: path.join(resolved, 'outputs', 'identity-candidate-sources.json'),\n };\n\n writeJsonArtifact(files.identity_decision, { ...report, files });\n writeJsonLinesArtifact(files.candidates, report.candidates);\n writeJsonArtifact(files.candidate_sources, report.candidate_sources);\n return files;\n}\n\nexport async function runIdentityPreflight(\n kind: IdentityPreflightKind,\n options: RunIdentityPreflightOptions,\n): Promise<IdentityPreflightReport> {\n const inputPath = requiredInputPath(options.inputPath);\n const normalizedInput = normalizePreflightInput(\n options.rawInput ?? readJsonInput(inputPath),\n kind,\n );\n const targetProfile = profileForKind(normalizedInput.target, kind);\n const remoteCandidateSearch = mergeRemoteCandidateSearchConfig(\n normalizedInput.remoteCandidateSearch,\n options,\n );\n const candidateSourceReads = [\n ...normalizedInput.candidateInputPaths,\n ...(options.candidateInputPaths ?? []),\n ].map(readCandidateSource);\n const remoteCandidateRead = await readRemoteCandidateSource(\n kind,\n targetProfile,\n remoteCandidateSearch,\n options,\n );\n const candidateSources: IdentityPreflightCandidateSourceReport[] = [\n ...(normalizedInput.candidates.length > 0\n ? [\n {\n path: path.resolve(inputPath),\n kind: 'embedded_request' as const,\n row_count: normalizedInput.candidates.length,\n scanned_files: [],\n },\n ]\n : []),\n ...candidateSourceReads.map((entry) => entry.source),\n ...(remoteCandidateRead ? [remoteCandidateRead.source] : []),\n ];\n const candidates = [\n ...normalizedInput.candidates,\n ...candidateSourceReads.flatMap((entry) => entry.rows),\n ...(remoteCandidateRead?.rows ?? []),\n ];\n const validation = validateTargetSchema(normalizedInput.target, kind, options.schemas);\n const evaluations = candidates.map((candidate, index) =>\n candidateEvaluation(targetProfile, profileForKind(candidate, kind), kind, index),\n );\n const decision = chooseDecision(evaluations, validation, kind);\n const blockers = decision.findings.filter((finding) => finding.severity === 'blocker');\n\n const baseReport: IdentityPreflightReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n kind,\n status: statusForDecision(decision.decision, blockers),\n decision: decision.decision,\n confidence: decision.confidence,\n input_path: path.resolve(inputPath),\n out_dir: options.outDir ? path.resolve(options.outDir) : null,\n target: {\n id: targetProfile.id,\n version: targetProfile.version,\n identity_key: targetProfile.identity_key,\n exchange_signature: targetProfile.exchange_signature,\n schema_validation: validation,\n },\n candidates: evaluations.map((evaluation) => evaluation.report),\n candidate_sources: candidateSources,\n findings: decision.findings,\n blockers,\n next_action: nextActionForDecision(decision.decision),\n files: {\n identity_decision: null,\n candidates: null,\n candidate_sources: null,\n },\n };\n\n const files = writeArtifacts(baseReport, options.outDir);\n return {\n ...baseReport,\n files,\n };\n}\n\nexport async function runProcessIdentityPreflight(\n options: RunProcessIdentityPreflightOptions,\n): Promise<ProcessIdentityPreflightReport> {\n return (await runIdentityPreflight('process', options)) as ProcessIdentityPreflightReport;\n}\n\nexport async function runFlowIdentityPreflight(\n options: RunFlowIdentityPreflightOptions,\n): Promise<FlowIdentityPreflightReport> {\n return (await runIdentityPreflight('flow', options)) as FlowIdentityPreflightReport;\n}\n\nexport const __testInternals = {\n normalizePreflightInput,\n schemaForKind,\n entityFactoryExports: ENTITY_FACTORY_EXPORTS,\n processProfile,\n flowProfile,\n candidateEvaluation,\n chooseDecision,\n collectCandidateFilesFromStats,\n readCandidateSource,\n defaultRemoteQuery,\n normalizeRemoteCandidateSearch,\n remoteSearchFilter,\n rowsFromRemoteSearchResponse,\n};\n"]}
|
|
@@ -379,6 +379,7 @@ function buildLayout(runRoot, runId) {
|
|
|
379
379
|
sourcePolicyPath: path.join(runRoot, 'request', 'source-policy.json'),
|
|
380
380
|
flowSummaryPath: path.join(runRoot, 'manifests', 'flow-summary.json'),
|
|
381
381
|
inputManifestPath: path.join(runRoot, 'input', 'input_manifest.json'),
|
|
382
|
+
buildPlanPath: path.join(runRoot, 'manifests', 'process-build-plan.json'),
|
|
382
383
|
assemblyPlanPath: path.join(runRoot, 'manifests', 'assembly-plan.json'),
|
|
383
384
|
lineageManifestPath: path.join(runRoot, 'manifests', 'lineage-manifest.json'),
|
|
384
385
|
invocationIndexPath: path.join(runRoot, 'manifests', 'invocation-index.json'),
|
|
@@ -455,6 +456,147 @@ function buildAssemblyPlan(runRoot) {
|
|
|
455
456
|
})),
|
|
456
457
|
};
|
|
457
458
|
}
|
|
459
|
+
function flowReferencePropertySummary(flowDataset) {
|
|
460
|
+
const flowInformation = isRecord(flowDataset.flowInformation) ? flowDataset.flowInformation : {};
|
|
461
|
+
const quantitativeReference = isRecord(flowInformation.quantitativeReference)
|
|
462
|
+
? flowInformation.quantitativeReference
|
|
463
|
+
: {};
|
|
464
|
+
const referenceId = nonEmptyString(quantitativeReference.referenceToReferenceFlowProperty);
|
|
465
|
+
const flowProperties = isRecord(flowDataset.flowProperties) ? flowDataset.flowProperties : {};
|
|
466
|
+
const propertyRows = Array.isArray(flowProperties.flowProperty)
|
|
467
|
+
? flowProperties.flowProperty
|
|
468
|
+
: flowProperties.flowProperty
|
|
469
|
+
? [flowProperties.flowProperty]
|
|
470
|
+
: [];
|
|
471
|
+
const referenceProperty = propertyRows.find((entry) => isRecord(entry) && nonEmptyString(entry['@dataSetInternalID']) === (referenceId ?? '0'));
|
|
472
|
+
const propertyRef = isRecord(referenceProperty) && isRecord(referenceProperty.referenceToFlowPropertyDataSet)
|
|
473
|
+
? referenceProperty.referenceToFlowPropertyDataSet
|
|
474
|
+
: {};
|
|
475
|
+
const shortDescription = isRecord(propertyRef['common:shortDescription'])
|
|
476
|
+
? propertyRef['common:shortDescription']
|
|
477
|
+
: {};
|
|
478
|
+
const propertyText = extractText(shortDescription) ?? extractText(propertyRef['common:shortDescription']);
|
|
479
|
+
return {
|
|
480
|
+
reference_property: propertyText ?? 'Reference flow property',
|
|
481
|
+
reference_property_id: nonEmptyString(propertyRef['@refObjectId']),
|
|
482
|
+
reference_unit: null,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function buildInitialProcessBuildPlan(normalized, flowArtifactPath) {
|
|
486
|
+
const flowProperty = flowReferencePropertySummary(normalized.flow_dataset);
|
|
487
|
+
const referenceFlowId = normalized.flow_summary.uuid ??
|
|
488
|
+
nonEmptyString(normalized.flow_dataset['@id']) ??
|
|
489
|
+
sanitizeRunToken(normalized.flow_summary.base_name ?? normalized.run_id, 'reference-flow');
|
|
490
|
+
const referenceFlowVersion = normalized.flow_summary.version ?? '00.00.000';
|
|
491
|
+
const baseName = normalized.flow_summary.base_name
|
|
492
|
+
? `${normalized.operation === 'treat' ? 'Treatment of' : 'Production of'} ${normalized.flow_summary.base_name}`
|
|
493
|
+
: `${normalized.operation === 'treat' ? 'Treatment' : 'Production'} process from reference flow`;
|
|
494
|
+
return {
|
|
495
|
+
schema_version: 1,
|
|
496
|
+
kind: 'process',
|
|
497
|
+
ruleset: {
|
|
498
|
+
id: 'process-authoring/strict',
|
|
499
|
+
version: '1',
|
|
500
|
+
},
|
|
501
|
+
target: {
|
|
502
|
+
geography: 'GLO',
|
|
503
|
+
technology_route: normalized.operation === 'treat'
|
|
504
|
+
? 'Treatment route to be evidenced during process auto-build'
|
|
505
|
+
: 'Production route to be evidenced during process auto-build',
|
|
506
|
+
classification_path: [
|
|
507
|
+
'Technosphere',
|
|
508
|
+
normalized.operation === 'treat' ? 'Treatment' : 'Production',
|
|
509
|
+
flowProperty.reference_property,
|
|
510
|
+
normalized.flow_summary.base_name ?? 'Reference flow',
|
|
511
|
+
],
|
|
512
|
+
},
|
|
513
|
+
identity_decision: {
|
|
514
|
+
decision: 'create_new',
|
|
515
|
+
rationale: 'Initial process auto-build scaffold; identity preflight must be rerun with remote/local candidates before write.',
|
|
516
|
+
},
|
|
517
|
+
evidence_manifest: {
|
|
518
|
+
sources: [
|
|
519
|
+
{
|
|
520
|
+
id: `flow:${referenceFlowId}`,
|
|
521
|
+
type: 'input_flow_dataset',
|
|
522
|
+
path: flowArtifactPath,
|
|
523
|
+
title: normalized.flow_summary.base_name ?? referenceFlowId,
|
|
524
|
+
version: referenceFlowVersion,
|
|
525
|
+
},
|
|
526
|
+
...normalized.source_inputs.map((source) => ({
|
|
527
|
+
id: source.source_id,
|
|
528
|
+
type: source.type,
|
|
529
|
+
path: source.artifact_path,
|
|
530
|
+
title: source.artifact_file_name,
|
|
531
|
+
intended_roles: source.intended_roles,
|
|
532
|
+
})),
|
|
533
|
+
],
|
|
534
|
+
field_bindings: [
|
|
535
|
+
{ field_path: 'target', source_id: `flow:${referenceFlowId}` },
|
|
536
|
+
{ field_path: 'identity_decision.decision', source_id: `flow:${referenceFlowId}` },
|
|
537
|
+
{ field_path: 'unit_of_analysis', source_id: `flow:${referenceFlowId}` },
|
|
538
|
+
{ field_path: 'name_plan.base_name', source_id: `flow:${referenceFlowId}` },
|
|
539
|
+
{ field_path: 'target.geography', source_id: `flow:${referenceFlowId}` },
|
|
540
|
+
{ field_path: 'target.technology_route', source_id: `flow:${referenceFlowId}` },
|
|
541
|
+
{
|
|
542
|
+
field_path: 'quantitative_reference_plan.reference_flow_id',
|
|
543
|
+
source_id: `flow:${referenceFlowId}`,
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
},
|
|
547
|
+
unit_of_analysis: {
|
|
548
|
+
target_kind: normalized.operation === 'treat' ? 'treatment' : 'process_from_flow_scaffold',
|
|
549
|
+
decision: 'manual_review',
|
|
550
|
+
functional_unit: {
|
|
551
|
+
what: normalized.operation === 'treat'
|
|
552
|
+
? `treat ${normalized.flow_summary.base_name ?? 'the reference flow'}`
|
|
553
|
+
: `produce ${normalized.flow_summary.base_name ?? 'the reference flow'}`,
|
|
554
|
+
how_much: `1 ${flowProperty.reference_unit ?? flowProperty.reference_property}`,
|
|
555
|
+
how_well: 'to be determined from source evidence before materialization',
|
|
556
|
+
how_long: 'not determined in the initial scaffold',
|
|
557
|
+
},
|
|
558
|
+
reference_flow: {
|
|
559
|
+
flow_identity: normalized.flow_summary.base_name ?? referenceFlowId,
|
|
560
|
+
reference_unit: flowProperty.reference_unit ?? flowProperty.reference_property,
|
|
561
|
+
reference_amount: 1,
|
|
562
|
+
flow_property: flowProperty.reference_property,
|
|
563
|
+
},
|
|
564
|
+
declared_unit_allowed: false,
|
|
565
|
+
scaling_evidence_status: 'source_required',
|
|
566
|
+
notes: [
|
|
567
|
+
'Initial scaffold only. A skill/Codex workflow must revise unit_of_analysis before build-plan materialize.',
|
|
568
|
+
],
|
|
569
|
+
},
|
|
570
|
+
name_plan: {
|
|
571
|
+
base_name: baseName,
|
|
572
|
+
treatment_standards_routes: normalized.operation === 'treat' ? 'treatment route' : 'production route',
|
|
573
|
+
mix_and_location_types: 'global average',
|
|
574
|
+
functional_unit_flow_properties: flowProperty.reference_unit ?? flowProperty.reference_property,
|
|
575
|
+
},
|
|
576
|
+
quantitative_reference_plan: {
|
|
577
|
+
reference_flow_id: referenceFlowId,
|
|
578
|
+
reference_flow_version: referenceFlowVersion,
|
|
579
|
+
reference_flow_name: normalized.flow_summary.base_name ?? referenceFlowId,
|
|
580
|
+
reference_flow_internal_id: '1',
|
|
581
|
+
mean_amount: '1.0',
|
|
582
|
+
resulting_amount: '1.0',
|
|
583
|
+
reference_unit: flowProperty.reference_unit ?? flowProperty.reference_property,
|
|
584
|
+
},
|
|
585
|
+
flow_property_plan: flowProperty,
|
|
586
|
+
exchange_plan: {
|
|
587
|
+
exchanges: [],
|
|
588
|
+
},
|
|
589
|
+
materialization_readiness: {
|
|
590
|
+
status: 'scaffold_only',
|
|
591
|
+
next_required_steps: [
|
|
592
|
+
'replace scaffold unit_of_analysis with a skill-authored decision artifact',
|
|
593
|
+
'run process identity-preflight with local and remote candidates',
|
|
594
|
+
'replace scaffold geography, technology, classification, exchange values, and annual volume with evidence-backed values',
|
|
595
|
+
'run process build-plan validate/materialize before save-draft or publish-build',
|
|
596
|
+
],
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
}
|
|
458
600
|
function buildLineageManifest(normalized) {
|
|
459
601
|
return {
|
|
460
602
|
schema_version: 1,
|
|
@@ -575,6 +717,7 @@ function buildAgentHandoffSummary(normalized, layout, flowArtifactPath, now) {
|
|
|
575
717
|
request_snapshot: layout.requestSnapshotPath,
|
|
576
718
|
normalized_request: layout.normalizedRequestPath,
|
|
577
719
|
assembly_plan: layout.assemblyPlanPath,
|
|
720
|
+
build_plan: layout.buildPlanPath,
|
|
578
721
|
flow_copy: flowArtifactPath,
|
|
579
722
|
},
|
|
580
723
|
next_actions: buildNextActions(layout),
|
|
@@ -611,6 +754,7 @@ function buildReport(normalized, layout, flowArtifactPath, now) {
|
|
|
611
754
|
source_policy: layout.sourcePolicyPath,
|
|
612
755
|
flow_summary: layout.flowSummaryPath,
|
|
613
756
|
input_manifest: layout.inputManifestPath,
|
|
757
|
+
build_plan: layout.buildPlanPath,
|
|
614
758
|
assembly_plan: layout.assemblyPlanPath,
|
|
615
759
|
lineage_manifest: layout.lineageManifestPath,
|
|
616
760
|
invocation_index: layout.invocationIndexPath,
|
|
@@ -679,7 +823,9 @@ export async function runProcessAutoBuild(options) {
|
|
|
679
823
|
flow_path: normalized.flow_file,
|
|
680
824
|
flow_artifact_path: flowArtifactPath,
|
|
681
825
|
operation: normalized.operation,
|
|
826
|
+
build_plan_path: layout.buildPlanPath,
|
|
682
827
|
});
|
|
828
|
+
writeJsonArtifact(layout.buildPlanPath, buildInitialProcessBuildPlan(normalized, flowArtifactPath));
|
|
683
829
|
writeJsonArtifact(layout.assemblyPlanPath, buildAssemblyPlan(layout.runRoot));
|
|
684
830
|
writeJsonArtifact(layout.lineageManifestPath, buildLineageManifest(normalized));
|
|
685
831
|
writeJsonArtifact(layout.invocationIndexPath, buildInvocationIndex(normalized, options, layout.reportPath, now));
|
|
@@ -711,6 +857,7 @@ export const __testInternals = {
|
|
|
711
857
|
buildProcessAutoBuildRunId,
|
|
712
858
|
buildLayout,
|
|
713
859
|
buildAssemblyPlan,
|
|
860
|
+
buildInitialProcessBuildPlan,
|
|
714
861
|
buildLineageManifest,
|
|
715
862
|
buildInvocationIndex,
|
|
716
863
|
buildInitialState,
|