@semacode/cli 2.2.0 → 2.3.1
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/LICENSE +39 -39
- package/README.md +251 -141
- package/dist/agentContext.d.ts +1 -1
- package/dist/agentContextPack.js +6 -1
- package/dist/agentContextTipos.d.ts +4 -2
- package/dist/agentContextTipos.js +7 -0
- package/dist/agentEntryPoints.js +551 -499
- package/dist/angular-consumer-standalone.d.ts +3 -1
- package/dist/angular-consumer-standalone.js +12 -8
- package/dist/comandos.js +4 -0
- package/dist/discovery/catalog.d.ts +11 -0
- package/dist/discovery/catalog.js +521 -0
- package/dist/discovery/command.d.ts +11 -0
- package/dist/discovery/command.js +226 -0
- package/dist/discovery/index.d.ts +5 -0
- package/dist/discovery/index.js +8 -0
- package/dist/discovery/ranker.d.ts +3 -0
- package/dist/discovery/ranker.js +310 -0
- package/dist/discovery/redaction.d.ts +2 -0
- package/dist/discovery/redaction.js +21 -0
- package/dist/discovery/render.d.ts +2 -0
- package/dist/discovery/render.js +100 -0
- package/dist/discovery/types.d.ts +119 -0
- package/dist/discovery/types.js +13 -0
- package/dist/drift.part01.d.ts +32 -2
- package/dist/drift.part01.js +2 -0
- package/dist/drift.part04.d.ts +3 -2
- package/dist/drift.part04.js +6 -3
- package/dist/drift.part05.d.ts +2 -1
- package/dist/drift.part05.js +4 -3
- package/dist/drift.part06.d.ts +2 -1
- package/dist/drift.part06.js +9 -5
- package/dist/drift.part07.d.ts +11 -10
- package/dist/drift.part07.js +40 -30
- package/dist/drift.part08.d.ts +2 -1
- package/dist/drift.part08.js +4 -3
- package/dist/drift.part11.js +71 -6
- package/dist/drift.part12.js +14 -1
- package/dist/drift.part13.d.ts +42 -7
- package/dist/drift.part13.js +660 -36
- package/dist/driftCache.d.ts +49 -0
- package/dist/driftCache.js +311 -0
- package/dist/driftCacheIncremental.d.ts +98 -0
- package/dist/driftCacheIncremental.js +596 -0
- package/dist/driftCatalogo.d.ts +91 -0
- package/dist/driftCatalogo.js +657 -0
- package/dist/driftCatalogoPersistente.d.ts +8 -0
- package/dist/driftCatalogoPersistente.js +77 -0
- package/dist/driftEscopo.d.ts +23 -0
- package/dist/driftEscopo.js +563 -0
- package/dist/driftEscopoReferencias.d.ts +4 -0
- package/dist/driftEscopoReferencias.js +265 -0
- package/dist/driftOrcamento.d.ts +12 -0
- package/dist/driftOrcamento.js +19 -3
- package/dist/execucoesExternas.js +5 -19
- package/dist/exemplosOficiais.js +29 -8
- package/dist/iaPrompts.d.ts +1 -1
- package/dist/iaPrompts.js +310 -307
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -5
- package/dist/index.part01.d.ts +17 -2
- package/dist/index.part01.js +119 -8
- package/dist/index.part02.js +21 -21
- package/dist/index.part03.d.ts +2 -2
- package/dist/index.part03.js +14 -3
- package/dist/index.part04.d.ts +2 -2
- package/dist/index.part04.js +113 -101
- package/dist/index.part05.d.ts +1 -1
- package/dist/index.part05.js +99 -22
- package/dist/index.part06.js +6 -2
- package/dist/index.part07.js +24 -24
- package/dist/index.part08.js +1 -1
- package/dist/init/templates.part01.js +393 -393
- package/dist/init/templates.part02.js +189 -189
- package/dist/initTemplatesBackend.js +73 -73
- package/dist/initTemplatesBase.js +81 -80
- package/dist/initTemplatesFlutter.js +137 -137
- package/dist/initTemplatesRuntime.js +350 -350
- package/dist/initTemplatesWeb.js +309 -309
- package/dist/pipelineConteudo/command.js +1 -36
- package/dist/profileArtefatoValidadores.d.ts +3 -2
- package/dist/profileArtefatoValidadores.js +81 -0
- package/dist/profileAuthorTipos.d.ts +4 -3
- package/dist/profileCatalogo.d.ts +5 -5
- package/dist/profileCatalogo.js +30 -0
- package/dist/profileCommand.d.ts +8 -2
- package/dist/profileCommand.js +15 -5
- package/dist/profileRegras.d.ts +5 -5
- package/dist/profileRegras.js +13 -1
- package/dist/profileRulePacks.js +68 -0
- package/dist/projeto.d.ts +1 -1
- package/dist/projetoCarregar.d.ts +2 -2
- package/dist/projetoCarregar.js +47 -24
- package/dist/projetoCatalogo.d.ts +7 -0
- package/dist/projetoCatalogo.js +125 -0
- package/dist/projetoTipos.d.ts +14 -5
- package/dist/sistemasInterativos/adapterProtocol.d.ts +3 -0
- package/dist/sistemasInterativos/adapterProtocol.js +240 -0
- package/dist/sistemasInterativos/advancedCatalog.d.ts +5 -0
- package/dist/sistemasInterativos/advancedCatalog.js +442 -0
- package/dist/sistemasInterativos/autonomy.d.ts +230 -0
- package/dist/sistemasInterativos/autonomy.js +753 -0
- package/dist/sistemasInterativos/canonical.d.ts +3 -0
- package/dist/sistemasInterativos/canonical.js +43 -0
- package/dist/sistemasInterativos/catalog.d.ts +116 -0
- package/dist/sistemasInterativos/catalog.js +543 -0
- package/dist/sistemasInterativos/command.d.ts +7 -0
- package/dist/sistemasInterativos/command.js +311 -0
- package/dist/sistemasInterativos/controlRun.d.ts +56 -0
- package/dist/sistemasInterativos/controlRun.js +391 -0
- package/dist/sistemasInterativos/evidence.d.ts +5 -0
- package/dist/sistemasInterativos/evidence.js +306 -0
- package/dist/sistemasInterativos/experienceIr.d.ts +12 -0
- package/dist/sistemasInterativos/experienceIr.js +895 -0
- package/dist/sistemasInterativos/experienceIrSemantics.d.ts +30 -0
- package/dist/sistemasInterativos/experienceIrSemantics.js +368 -0
- package/dist/sistemasInterativos/experienceIrTypes.d.ts +370 -0
- package/dist/sistemasInterativos/experienceIrTypes.js +5 -0
- package/dist/sistemasInterativos/extensionCommand.d.ts +391 -0
- package/dist/sistemasInterativos/extensionCommand.js +383 -0
- package/dist/sistemasInterativos/index.d.ts +19 -0
- package/dist/sistemasInterativos/index.js +22 -0
- package/dist/sistemasInterativos/operations.d.ts +40 -0
- package/dist/sistemasInterativos/operations.js +1167 -0
- package/dist/sistemasInterativos/operationsTypes.d.ts +297 -0
- package/dist/sistemasInterativos/operationsTypes.js +11 -0
- package/dist/sistemasInterativos/planner.d.ts +2 -0
- package/dist/sistemasInterativos/planner.js +159 -0
- package/dist/sistemasInterativos/portability.d.ts +164 -0
- package/dist/sistemasInterativos/portability.js +539 -0
- package/dist/sistemasInterativos/render.d.ts +3 -0
- package/dist/sistemasInterativos/render.js +179 -0
- package/dist/sistemasInterativos/temporal.d.ts +183 -0
- package/dist/sistemasInterativos/temporal.js +543 -0
- package/dist/sistemasInterativos/types.d.ts +215 -0
- package/dist/sistemasInterativos/types.js +4 -0
- package/dist/sistemasInterativos/validator.d.ts +2 -0
- package/dist/sistemasInterativos/validator.js +305 -0
- package/dist/sync/index.js +35 -35
- package/docs/README.md +34 -28
- package/docs/ai-onboarding.md +62 -62
- package/docs/ai-workflow.md +9 -4
- package/docs/auth.md +26 -26
- package/docs/cli.md +79 -79
- package/docs/commands.md +47 -2
- package/docs/database.md +15 -15
- package/docs/deploy.md +41 -41
- package/docs/descoberta-capacidades.md +106 -0
- package/docs/documentation.md +39 -39
- package/docs/env.md +16 -16
- package/docs/frontend.md +41 -41
- package/docs/getting-started.md +57 -57
- package/docs/i18n.md +15 -15
- package/docs/pipeline-conteudo.md +246 -246
- package/docs/profiles.md +54 -45
- package/docs/repositories.md +43 -43
- package/docs/rollback.md +31 -31
- package/docs/security.md +32 -32
- package/docs/sistemas-interativos.md +376 -0
- package/docs/support.md +8 -8
- package/docs/testing.md +51 -35
- package/docs/vocabulary.md +29 -29
- package/exemplos/agendamento.sema +1 -1
- package/exemplos/assinatura.sema +1 -1
- package/exemplos/auditoria.sema +1 -1
- package/exemplos/autenticacao.sema +1 -1
- package/exemplos/author_obra_comum.sema +1 -1
- package/exemplos/author_tema_sensivel.sema +1 -1
- package/exemplos/automacao.sema +1 -1
- package/exemplos/cadastro_usuario.sema +1 -1
- package/exemplos/calculadora.sema +1 -1
- package/exemplos/crud_simples.sema +1 -1
- package/exemplos/estoque.sema +1 -1
- package/exemplos/exportacao.sema +1 -1
- package/exemplos/fila.sema +1 -1
- package/exemplos/integracao_externa.sema +1 -1
- package/exemplos/multi_tenant.sema +1 -1
- package/exemplos/notificacao.sema +1 -1
- package/exemplos/operacao_estrategia.sema +132 -132
- package/exemplos/operacao_estrategia_discovery.sema +220 -220
- package/exemplos/operacao_estrategia_fluxo.sema +114 -114
- package/exemplos/operacao_estrategia_gates.sema +106 -106
- package/exemplos/operacao_estrategia_quarentena.sema +133 -133
- package/exemplos/operacao_estrategia_rollout.sema +124 -124
- package/exemplos/pagamento.sema +1 -1
- package/exemplos/pagamento_dominio.sema +1 -1
- package/exemplos/pedido.sema +1 -1
- package/exemplos/permissao.sema +1 -1
- package/exemplos/persistencia_vendor_first.sema +1 -1
- package/exemplos/pipeline-conteudo/README.md +44 -44
- package/exemplos/pipeline-conteudo/alvos.json +23 -23
- package/exemplos/pipeline-conteudo/definicao.json +136 -136
- package/exemplos/profile_conversas.sema +165 -165
- package/exemplos/profile_game.sema +1 -1
- package/exemplos/profile_legal.sema +1 -1
- package/exemplos/profile_ops.sema +1 -1
- package/exemplos/profile_research.sema +1 -1
- package/exemplos/profile_simulation.sema +211 -0
- package/exemplos/profile_software.sema +1 -1
- package/exemplos/profile_workflow_n8n.sema +1 -1
- package/exemplos/relatorio.sema +1 -1
- package/exemplos/replica_analitica_erp.sema +1 -1
- package/exemplos/sistemas-interativos/README.md +100 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -0
- package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -0
- package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -0
- package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -0
- package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -0
- package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -0
- package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -0
- package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -0
- package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -0
- package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -0
- package/exemplos/sistemas-interativos/game-2d.json +83 -0
- package/exemplos/sistemas-interativos/game-3d-human.json +81 -0
- package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -0
- package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -0
- package/exemplos/sistemas-interativos/game-xr-human.json +80 -0
- package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -0
- package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -0
- package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -0
- package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -0
- package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -0
- package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -0
- package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -0
- package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -0
- package/exemplos/testes_embutidos.sema +1 -1
- package/exemplos/tratamento_erro.sema +1 -1
- package/exemplos/upload_arquivo.sema +1 -1
- package/exemplos/webhook.sema +1 -1
- package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
- package/node_modules/@sema/gerador-cpp/package.json +1 -1
- package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
- package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
- package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
- package/node_modules/@sema/gerador-dotnet/package.json +1 -1
- package/node_modules/@sema/gerador-html/dist/index.js +17 -17
- package/node_modules/@sema/gerador-lua/dist/index.js +76 -47
- package/node_modules/@sema/gerador-lua/dist/index.js.map +1 -1
- package/node_modules/@sema/gerador-php/dist/index.js +113 -113
- package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
- package/package.json +3 -3
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.sistemas_interativos.evidencias
|
|
2
|
+
// Descricao: valida bundles locais e deriva estado regeneravel, sempre non-authoritative.
|
|
3
|
+
import { digestJsonSistemaInterativo, digestSha256Valido } from "./canonical.js";
|
|
4
|
+
import { obterAdaptadorSistemaInterativo } from "./catalog.js";
|
|
5
|
+
import { planejarSistemaInterativo } from "./planner.js";
|
|
6
|
+
const MARCADOR_CHAVE_SENSIVEL = /password|passwd|senha|secret|token|privatekey|apikey|credential|credencial|chaveprivada|chavesecreta/;
|
|
7
|
+
const VALOR_SENSIVEL = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\bBearer\s+[A-Za-z0-9._~+/=-]+|\b(?:sk|ghp|github_pat)_[A-Za-z0-9_-]{12,}/i;
|
|
8
|
+
const FONTES_CLAIM = new Set(["PRODUCER_CLAIM", "RUNNER_CLAIM", "SELF_DECLARED", "CLAIM"]);
|
|
9
|
+
function adicionar(lista, valor) {
|
|
10
|
+
if (!lista.includes(valor))
|
|
11
|
+
lista.push(valor);
|
|
12
|
+
}
|
|
13
|
+
function texto(valor) {
|
|
14
|
+
return typeof valor === "string" && valor.trim().length > 0 && !/[\u0000-\u001f\u007f]/.test(valor);
|
|
15
|
+
}
|
|
16
|
+
function identificadorSeguro(valor) {
|
|
17
|
+
return texto(valor)
|
|
18
|
+
&& valor.length <= 128
|
|
19
|
+
&& /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(valor)
|
|
20
|
+
&& !VALOR_SENSIVEL.test(valor);
|
|
21
|
+
}
|
|
22
|
+
function registroObjeto(valor) {
|
|
23
|
+
return typeof valor === "object" && valor !== null && !Array.isArray(valor);
|
|
24
|
+
}
|
|
25
|
+
function chaveSensivel(chave) {
|
|
26
|
+
const normalizada = chave
|
|
27
|
+
.normalize("NFKD")
|
|
28
|
+
.replace(/[\u0300-\u036f]/gu, "")
|
|
29
|
+
.replace(/[^a-z0-9]/giu, "")
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
return MARCADOR_CHAVE_SENSIVEL.test(normalizada);
|
|
32
|
+
}
|
|
33
|
+
function contemDadoSensivel(valor, visitados = new Set()) {
|
|
34
|
+
if (typeof valor === "string")
|
|
35
|
+
return VALOR_SENSIVEL.test(valor);
|
|
36
|
+
if (valor === null || typeof valor !== "object")
|
|
37
|
+
return false;
|
|
38
|
+
if (visitados.has(valor))
|
|
39
|
+
return true;
|
|
40
|
+
visitados.add(valor);
|
|
41
|
+
try {
|
|
42
|
+
if (Array.isArray(valor))
|
|
43
|
+
return valor.some((item) => contemDadoSensivel(item, visitados));
|
|
44
|
+
return Object.entries(valor).some(([chave, item]) => chaveSensivel(chave) || contemDadoSensivel(item, visitados));
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
visitados.delete(valor);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function bloqueioOperacionalPlanejamento(codigo) {
|
|
51
|
+
return codigo === "capability_controle_ausente"
|
|
52
|
+
|| codigo === "capabilities_obrigatorias_ausentes"
|
|
53
|
+
|| codigo === "adapter_compativel_ausente"
|
|
54
|
+
|| codigo === "adapter_selecao_explicita_ausente"
|
|
55
|
+
|| codigo === "adapter_provedor_candidato_ausente"
|
|
56
|
+
|| codigo === "adapter_capability_coverage_incompleta"
|
|
57
|
+
|| codigo.startsWith("adapter_target_incompativel_indice:");
|
|
58
|
+
}
|
|
59
|
+
function resolverPlanoCanonico(definicao) {
|
|
60
|
+
try {
|
|
61
|
+
const planejamento = planejarSistemaInterativo(definicao);
|
|
62
|
+
return {
|
|
63
|
+
plano: planejamento.plano,
|
|
64
|
+
bloqueios: planejamento.bloqueios.map((item) => (`${bloqueioOperacionalPlanejamento(item) ? "planejamento_canonico_bloqueado" : "planejamento_canonico_invalido"}:${item}`)),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return { bloqueios: ["definicao_ou_planejamento_canonico_invalido"] };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function digestConteudoPlano(plano) {
|
|
72
|
+
try {
|
|
73
|
+
if (plano === null || typeof plano !== "object" || Array.isArray(plano))
|
|
74
|
+
return undefined;
|
|
75
|
+
const { planDigest: _planDigest, ...conteudo } = plano;
|
|
76
|
+
return digestJsonSistemaInterativo(conteudo);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function exigenciasDoPlano(definicao, plano) {
|
|
83
|
+
const exigencias = [];
|
|
84
|
+
for (const stage of plano?.stages ?? []) {
|
|
85
|
+
for (const evidenceType of stage.requiredEvidence) {
|
|
86
|
+
exigencias.push({ stageId: stage.stageInstanceId, evidenceType });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const exigirGlobalSeAusente = (evidenceType) => {
|
|
90
|
+
if (!exigencias.some((item) => item.evidenceType === evidenceType))
|
|
91
|
+
exigencias.push({ evidenceType });
|
|
92
|
+
};
|
|
93
|
+
if (definicao.determinism === "SEEDED" || definicao.determinism === "STRICT") {
|
|
94
|
+
for (const evidenceType of ["determinism.seed", "state.snapshot", "event.log", "result.digest"]) {
|
|
95
|
+
exigirGlobalSeAusente(evidenceType);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (definicao.fidelity === "REALISTIC" || definicao.fidelity === "CALIBRATED") {
|
|
99
|
+
for (const evidenceType of [
|
|
100
|
+
"simulation.reference.dataset",
|
|
101
|
+
"simulation.calibration",
|
|
102
|
+
"simulation.tolerance",
|
|
103
|
+
"simulation.uncertainty",
|
|
104
|
+
"simulation.telemetry",
|
|
105
|
+
]) {
|
|
106
|
+
exigirGlobalSeAusente(evidenceType);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(definicao.controlModes)
|
|
110
|
+
&& definicao.controlModes.some((modo) => modo === "AUTONOMOUS" || modo === "UNCONTROLLED")) {
|
|
111
|
+
for (const evidenceType of ["simulation.hazards", "simulation.stop.criteria", "simulation.recovery.plan"]) {
|
|
112
|
+
exigirGlobalSeAusente(evidenceType);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const chaves = new Set();
|
|
116
|
+
return exigencias.filter((item) => {
|
|
117
|
+
const chave = `${item.stageId ?? "global"}\u0000${item.evidenceType}`;
|
|
118
|
+
if (chaves.has(chave))
|
|
119
|
+
return false;
|
|
120
|
+
chaves.add(chave);
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function observacaoSatisfaz(observacao, exigencia) {
|
|
125
|
+
return observacao.evidenceType === exigencia.evidenceType
|
|
126
|
+
&& (exigencia.stageId === undefined || observacao.stageId === exigencia.stageId);
|
|
127
|
+
}
|
|
128
|
+
function rotuloExigencia(exigencia) {
|
|
129
|
+
return `${exigencia.stageId ?? "global"}:${exigencia.evidenceType}`;
|
|
130
|
+
}
|
|
131
|
+
export function validarBundleEvidenciasSistemaInterativo(definicao, plano, bundle) {
|
|
132
|
+
const bloqueios = [];
|
|
133
|
+
const evidenciasAceitas = [];
|
|
134
|
+
const planoResolvido = resolverPlanoCanonico(definicao);
|
|
135
|
+
const planoCanonico = planoResolvido.plano;
|
|
136
|
+
const planoFornecido = registroObjeto(plano) ? plano : undefined;
|
|
137
|
+
const bundleFornecido = registroObjeto(bundle) ? bundle : undefined;
|
|
138
|
+
if (!planoFornecido)
|
|
139
|
+
adicionar(bloqueios, "plano_fornecido_invalido");
|
|
140
|
+
if (!bundleFornecido)
|
|
141
|
+
adicionar(bloqueios, "bundle_invalido");
|
|
142
|
+
for (const bloqueio of planoResolvido.bloqueios)
|
|
143
|
+
adicionar(bloqueios, bloqueio);
|
|
144
|
+
if (!planoCanonico) {
|
|
145
|
+
adicionar(bloqueios, "plano_canonico_indisponivel");
|
|
146
|
+
}
|
|
147
|
+
else if (planoFornecido) {
|
|
148
|
+
if (planoFornecido.definitionDigest !== planoCanonico.definitionDigest) {
|
|
149
|
+
adicionar(bloqueios, "plano_definition_digest_divergente");
|
|
150
|
+
}
|
|
151
|
+
if (planoFornecido.planDigest !== planoCanonico.planDigest) {
|
|
152
|
+
adicionar(bloqueios, "plano_plan_digest_divergente");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const digestFornecido = planoFornecido ? digestConteudoPlano(planoFornecido) : undefined;
|
|
156
|
+
if (digestFornecido === undefined || digestFornecido !== planoFornecido?.planDigest) {
|
|
157
|
+
adicionar(bloqueios, "plano_conteudo_digest_divergente");
|
|
158
|
+
}
|
|
159
|
+
const observationsBrutas = Array.isArray(bundleFornecido?.observations) ? bundleFornecido.observations : [];
|
|
160
|
+
const observations = observationsBrutas
|
|
161
|
+
.filter((item) => registroObjeto(item));
|
|
162
|
+
if (observations.length !== observationsBrutas.length)
|
|
163
|
+
adicionar(bloqueios, "bundle_observation_malformada");
|
|
164
|
+
if (bundleFornecido?.schemaVersion !== "1.0")
|
|
165
|
+
adicionar(bloqueios, "bundle_schema_version_nao_suportada");
|
|
166
|
+
if (!identificadorSeguro(bundleFornecido?.runId))
|
|
167
|
+
adicionar(bloqueios, "bundle_run_id_invalido");
|
|
168
|
+
if (bundleFornecido?.systemId !== definicao.systemId || bundleFornecido?.systemId !== planoCanonico?.systemId)
|
|
169
|
+
adicionar(bloqueios, "bundle_system_id_divergente");
|
|
170
|
+
if (bundleFornecido?.definitionDigest !== planoCanonico?.definitionDigest)
|
|
171
|
+
adicionar(bloqueios, "bundle_definition_digest_divergente");
|
|
172
|
+
if (bundleFornecido?.planDigest !== planoCanonico?.planDigest)
|
|
173
|
+
adicionar(bloqueios, "bundle_plan_digest_divergente");
|
|
174
|
+
if (!Array.isArray(bundleFornecido?.observations))
|
|
175
|
+
adicionar(bloqueios, "bundle_observations_invalidas");
|
|
176
|
+
const stages = new Map((planoCanonico?.stages ?? []).map((stage) => [stage.stageInstanceId, stage]));
|
|
177
|
+
const providers = new Map((planoCanonico?.stageProviderMap ?? []).map((item) => [item.stageInstanceId, item]));
|
|
178
|
+
const ids = new Set();
|
|
179
|
+
let semanticTargetId;
|
|
180
|
+
for (const [indice, observacao] of observations.entries()) {
|
|
181
|
+
const problemasAntes = bloqueios.length;
|
|
182
|
+
if (!identificadorSeguro(observacao.evidenceId))
|
|
183
|
+
adicionar(bloqueios, "evidence_id_invalido");
|
|
184
|
+
else if (ids.has(observacao.evidenceId))
|
|
185
|
+
adicionar(bloqueios, `evidence_id_duplicado_indice:${indice}`);
|
|
186
|
+
else
|
|
187
|
+
ids.add(observacao.evidenceId);
|
|
188
|
+
if (!texto(observacao.evidenceType))
|
|
189
|
+
adicionar(bloqueios, `evidence_type_invalido_indice:${indice}`);
|
|
190
|
+
const stage = stages.get(observacao.stageId);
|
|
191
|
+
if (!stage)
|
|
192
|
+
adicionar(bloqueios, `evidence_stage_desconhecido_indice:${indice}`);
|
|
193
|
+
else if (!stage.requiredEvidence.includes(observacao.evidenceType)
|
|
194
|
+
&& !exigenciasDoPlano(definicao, planoCanonico).some((item) => item.stageId === undefined && item.evidenceType === observacao.evidenceType)) {
|
|
195
|
+
adicionar(bloqueios, `evidence_type_nao_exigido_no_stage_indice:${indice}`);
|
|
196
|
+
}
|
|
197
|
+
if (!identificadorSeguro(observacao.semanticTargetId))
|
|
198
|
+
adicionar(bloqueios, `semantic_target_id_invalido_indice:${indice}`);
|
|
199
|
+
else if (semanticTargetId === undefined)
|
|
200
|
+
semanticTargetId = observacao.semanticTargetId;
|
|
201
|
+
else if (semanticTargetId !== observacao.semanticTargetId)
|
|
202
|
+
adicionar(bloqueios, `semantic_target_id_divergente_indice:${indice}`);
|
|
203
|
+
const provider = providers.get(observacao.stageId);
|
|
204
|
+
if (!identificadorSeguro(observacao.producerAdapterId))
|
|
205
|
+
adicionar(bloqueios, `producer_adapter_id_invalido_indice:${indice}`);
|
|
206
|
+
else if (!provider?.selectedAdapterIds.includes(observacao.producerAdapterId)) {
|
|
207
|
+
adicionar(bloqueios, `producer_adapter_nao_selecionado_para_stage_indice:${indice}`);
|
|
208
|
+
}
|
|
209
|
+
const producer = identificadorSeguro(observacao.producerAdapterId)
|
|
210
|
+
? obterAdaptadorSistemaInterativo(observacao.producerAdapterId)
|
|
211
|
+
: undefined;
|
|
212
|
+
if (!producer || observacao.producerAdapterVersion !== producer.version) {
|
|
213
|
+
adicionar(bloqueios, `producer_adapter_version_divergente_indice:${indice}`);
|
|
214
|
+
}
|
|
215
|
+
if (!digestSha256Valido(observacao.artifactDigest))
|
|
216
|
+
adicionar(bloqueios, `artifact_digest_invalido_indice:${indice}`);
|
|
217
|
+
if (!texto(observacao.observedAt) || !Number.isFinite(Date.parse(observacao.observedAt)))
|
|
218
|
+
adicionar(bloqueios, `observed_at_invalido_indice:${indice}`);
|
|
219
|
+
if (!texto(observacao.source) || FONTES_CLAIM.has(observacao.source.toUpperCase()))
|
|
220
|
+
adicionar(bloqueios, `evidence_source_nao_observacional_indice:${indice}`);
|
|
221
|
+
if (!registroObjeto(observacao.data) || Object.keys(observacao.data).length === 0) {
|
|
222
|
+
adicionar(bloqueios, `evidence_data_invalida_ou_vazia_indice:${indice}`);
|
|
223
|
+
}
|
|
224
|
+
if (contemDadoSensivel(observacao))
|
|
225
|
+
adicionar(bloqueios, `evidence_contem_dado_sensivel_indice:${indice}`);
|
|
226
|
+
if (bloqueios.length === problemasAntes)
|
|
227
|
+
evidenciasAceitas.push(observacao.evidenceId);
|
|
228
|
+
}
|
|
229
|
+
const aceitas = observations.filter((item) => evidenciasAceitas.includes(item.evidenceId));
|
|
230
|
+
const evidenciasAusentes = exigenciasDoPlano(definicao, planoCanonico)
|
|
231
|
+
.filter((exigencia) => !aceitas.some((observacao) => observacaoSatisfaz(observacao, exigencia)))
|
|
232
|
+
.map(rotuloExigencia)
|
|
233
|
+
.sort();
|
|
234
|
+
return {
|
|
235
|
+
valido: bloqueios.length === 0 && evidenciasAusentes.length === 0,
|
|
236
|
+
evidenciasAceitas: evidenciasAceitas.sort(),
|
|
237
|
+
evidenciasAusentes,
|
|
238
|
+
bloqueios: bloqueios.sort(),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function estadoStages(plano, observations, aceitas) {
|
|
242
|
+
return (plano?.stages ?? []).map((stage) => {
|
|
243
|
+
const observacoes = observations.filter((item) => item.stageId === stage.stageInstanceId && aceitas.has(item.evidenceId));
|
|
244
|
+
const evidenciasAusentes = stage.requiredEvidence
|
|
245
|
+
.filter((tipo) => !observacoes.some((item) => item.evidenceType === tipo))
|
|
246
|
+
.sort();
|
|
247
|
+
return {
|
|
248
|
+
stageId: stage.stageInstanceId,
|
|
249
|
+
status: evidenciasAusentes.length === 0 ? "STRUCTURALLY_COMPLETE" : "WAITING_EVIDENCE",
|
|
250
|
+
evidenciasAusentes,
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
export function derivarEstadoSistemaInterativo(definicao, plano, bundle) {
|
|
255
|
+
const validacao = validarBundleEvidenciasSistemaInterativo(definicao, plano, bundle);
|
|
256
|
+
const aceitas = new Set(validacao.evidenciasAceitas);
|
|
257
|
+
const observations = registroObjeto(bundle) && Array.isArray(bundle.observations)
|
|
258
|
+
? bundle.observations.filter((item) => registroObjeto(item))
|
|
259
|
+
: [];
|
|
260
|
+
const planoCanonico = resolverPlanoCanonico(definicao).plano;
|
|
261
|
+
const stages = estadoStages(planoCanonico, observations, aceitas);
|
|
262
|
+
const temGapPlanejamento = validacao.bloqueios.some((item) => item.startsWith("planejamento_canonico_bloqueado:"));
|
|
263
|
+
const temBloqueioInvalido = validacao.bloqueios.some((item) => !item.startsWith("planejamento_canonico_bloqueado:"));
|
|
264
|
+
const planoPronto = planoCanonico?.adapterSelectionExplicit === true
|
|
265
|
+
&& planoCanonico.adapterCoverageComplete === true
|
|
266
|
+
&& planoCanonico.capabilitiesAusentes.length === 0
|
|
267
|
+
&& planoCanonico.capabilitiesSemAdapter.length === 0;
|
|
268
|
+
const localCoverageComplete = planoPronto && validacao.valido && validacao.evidenciasAusentes.length === 0;
|
|
269
|
+
const status = temBloqueioInvalido
|
|
270
|
+
? "INVALID"
|
|
271
|
+
: temGapPlanejamento || !planoPronto
|
|
272
|
+
? "BLOCKED"
|
|
273
|
+
: localCoverageComplete
|
|
274
|
+
? "STRUCTURALLY_COMPLETE"
|
|
275
|
+
: observations.length === 0
|
|
276
|
+
? "PLANNED"
|
|
277
|
+
: "WAITING_EVIDENCE";
|
|
278
|
+
const nextActions = [
|
|
279
|
+
...validacao.bloqueios.map((item) => `corrigir:${item}`),
|
|
280
|
+
...validacao.evidenciasAusentes.map((item) => `coletar_evidencia_externa:${item}`),
|
|
281
|
+
];
|
|
282
|
+
return {
|
|
283
|
+
status,
|
|
284
|
+
stages,
|
|
285
|
+
evidenciasAceitas: validacao.evidenciasAceitas,
|
|
286
|
+
evidenciasAusentes: validacao.evidenciasAusentes,
|
|
287
|
+
bloqueios: validacao.bloqueios,
|
|
288
|
+
nextActions,
|
|
289
|
+
completed: false,
|
|
290
|
+
localCoverageComplete,
|
|
291
|
+
awaitingExternalAttestation: true,
|
|
292
|
+
completionScope: "STRUCTURAL_LOCAL",
|
|
293
|
+
authoritative: false,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
export function bundleVazioSistemaInterativo(definicao, plano, runId) {
|
|
297
|
+
return {
|
|
298
|
+
schemaVersion: "1.0",
|
|
299
|
+
runId,
|
|
300
|
+
systemId: definicao.systemId,
|
|
301
|
+
definitionDigest: plano.definitionDigest,
|
|
302
|
+
planDigest: plano.planDigest,
|
|
303
|
+
observations: [],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=evidence.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExperienceIrChunkResult, ExperienceIrIndex, ExperienceIrIndexQueryResult, ExperienceIrIndexResult, ExperienceIrSerializationDescriptorResult, ExperienceIrValidationResult } from "./experienceIrTypes.js";
|
|
2
|
+
export * from "./experienceIrTypes.js";
|
|
3
|
+
export { EXPERIENCE_IR_SEMANTIC_ROLE_SCHEMA, EXPERIENCE_IR_SEMANTIC_ROLES_SCHEMA_VERSION, validarSemanticaExperienceIr, } from "./experienceIrSemantics.js";
|
|
4
|
+
export declare const EXPERIENCE_IR_SCHEMA_VERSION: "sema.experience-ir/v1";
|
|
5
|
+
export declare const EXPERIENCE_IR_INDEX_SCHEMA_VERSION: "sema.experience-ir.index/v1";
|
|
6
|
+
export declare const EXPERIENCE_IR_CHUNK_SCHEMA_VERSION: "sema.experience-ir.chunk/v1";
|
|
7
|
+
export declare const EXPERIENCE_IR_SERIALIZATION_SCHEMA_VERSION: "sema.experience-ir.serialization/v1";
|
|
8
|
+
export declare function validarExperienceIr(input: unknown): ExperienceIrValidationResult;
|
|
9
|
+
export declare function indexarExperienceIr(input: unknown): ExperienceIrIndexResult;
|
|
10
|
+
export declare function consultarIndiceExperienceIr(index: ExperienceIrIndex, semanticId: unknown): ExperienceIrIndexQueryResult;
|
|
11
|
+
export declare function criarChunkExperienceIr(input: unknown, semanticIds: unknown, incluirDependencias?: boolean): ExperienceIrChunkResult;
|
|
12
|
+
export declare function descreverSerializacaoExperienceIr(schemaVersion?: unknown): ExperienceIrSerializationDescriptorResult;
|