@semacode/cli 2.2.0 → 2.3.0
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 +91 -4
- 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 +70 -19
- 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/exemplosOficiais.js +29 -8
- package/dist/iaPrompts.d.ts +1 -1
- package/dist/iaPrompts.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -5
- package/dist/index.part01.d.ts +1 -1
- package/dist/index.part01.js +39 -4
- package/dist/index.part06.js +3 -0
- package/dist/initTemplatesBase.js +3 -2
- 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/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/docs/README.md +6 -0
- package/docs/ai-integration.md +7 -1
- package/docs/ai-workflow.md +5 -4
- package/docs/commands.md +43 -1
- package/docs/descoberta-capacidades.md +106 -0
- package/docs/documentation.md +11 -2
- package/docs/profiles.md +11 -2
- package/docs/sistemas-interativos.md +381 -0
- package/docs/testing.md +11 -2
- package/exemplos/profile_simulation.sema +211 -0
- 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/node_modules/@sema/gerador-lua/dist/index.js +31 -2
- package/node_modules/@sema/gerador-lua/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { compilarCodigo } from "@sema/nucleo";
|
|
2
2
|
export type PerfilSemantico = "software" | "workflow" | "ops" | "game" | "legal" | "research" | "redacao" | "propostas" | "conversas";
|
|
3
|
-
export type
|
|
3
|
+
export type PerfilSemanticoValidavel = PerfilSemantico | "simulation";
|
|
4
|
+
export type ProfileGovernanca = PerfilSemanticoValidavel | "author";
|
|
4
5
|
export type SeveridadeProfile = "info" | "warning" | "blocking" | "critical";
|
|
5
6
|
export type MaturidadeProfile = "draft" | "prototype" | "production" | "critical";
|
|
6
7
|
export type DecisaoAgenteProfile = "continuar" | "continuar_com_ressalva" | "parar" | "chamar_humano";
|
|
7
8
|
export type FonteAchadoProfile = "contrato" | "artefato" | "preset";
|
|
8
9
|
export type ConfiancaValidacaoProfile = "alta" | "media" | "parcial" | "baixa";
|
|
9
|
-
export type PresetProfile = "api" | "modulo" | "refactor" | "persistencia" | "security" | "webhook" | "fila" | "n8n" | "cron" | "integracao" | "deploy" | "migration" | "incidente" | "rollback" | "critical" | "lgpd" | "contrato" | "dpa" | "termos_uso" | "privacidade" | "due_diligence" | "compliance" | "rapida" | "tecnica" | "decisoria" | "critica" | "editorial" | "materia" | "blog" | "seo" | "reescrita" | "marketplace" | "freela" | "consultiva" | "diagnostico" | "score90" | "casual" | "arcade" | "rpg" | "economia" | "playtest" | "atendimento" | "vendas" | "suporte" | "qualificacao" | "retencao" | "cobranca";
|
|
10
|
+
export type PresetProfile = "api" | "modulo" | "refactor" | "persistencia" | "security" | "webhook" | "fila" | "n8n" | "cron" | "integracao" | "deploy" | "migration" | "incidente" | "rollback" | "critical" | "lgpd" | "contrato" | "dpa" | "termos_uso" | "privacidade" | "due_diligence" | "compliance" | "rapida" | "tecnica" | "decisoria" | "critica" | "editorial" | "materia" | "blog" | "seo" | "reescrita" | "marketplace" | "freela" | "consultiva" | "diagnostico" | "score90" | "casual" | "arcade" | "rpg" | "economia" | "playtest" | "model" | "scenario" | "calibration" | "deterministic" | "batch" | "safety" | "atendimento" | "vendas" | "suporte" | "qualificacao" | "retencao" | "cobranca";
|
|
10
11
|
export interface RequisitoProfile {
|
|
11
12
|
id: string;
|
|
12
13
|
descricao: string;
|
|
@@ -81,7 +82,7 @@ export interface OpcoesProfileValidar {
|
|
|
81
82
|
export interface ResultadoProfileValidar {
|
|
82
83
|
comando: "profile validar";
|
|
83
84
|
sucesso: boolean;
|
|
84
|
-
profile:
|
|
85
|
+
profile: PerfilSemanticoValidavel;
|
|
85
86
|
arquivo: string;
|
|
86
87
|
modulo: string | null;
|
|
87
88
|
maturidade: MaturidadeProfile;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CapabilityProfile, MaturidadeProfile,
|
|
2
|
-
export declare const REQUISITOS_PROFILE: Record<
|
|
1
|
+
import type { CapabilityProfile, MaturidadeProfile, PerfilSemanticoValidavel, PresetProfile, ProfileGovernanca, RequisitoProfile } from "./profileAuthorTipos.js";
|
|
2
|
+
export declare const REQUISITOS_PROFILE: Record<PerfilSemanticoValidavel, RequisitoProfile[]>;
|
|
3
3
|
export declare const REQUISITOS_PROFILE_COMUNS: RequisitoProfile[];
|
|
4
|
-
export declare const ALIASES_PROFILE: Record<string,
|
|
5
|
-
export declare function normalizarProfileSemantico(valor: string | undefined):
|
|
4
|
+
export declare const ALIASES_PROFILE: Record<string, PerfilSemanticoValidavel>;
|
|
5
|
+
export declare function normalizarProfileSemantico(valor: string | undefined): PerfilSemanticoValidavel | null;
|
|
6
6
|
export declare function normalizarMaturidadeProfile(valor: string | undefined): MaturidadeProfile;
|
|
7
|
-
export declare const PRESETS_PROFILE: Record<
|
|
7
|
+
export declare const PRESETS_PROFILE: Record<PerfilSemanticoValidavel, PresetProfile[]>;
|
|
8
8
|
export declare const CAPABILITY_MATRIX_GOVERNANCA: Record<ProfileGovernanca, CapabilityProfile>;
|
package/dist/profileCatalogo.js
CHANGED
|
@@ -27,6 +27,14 @@ export const REQUISITOS_PROFILE = {
|
|
|
27
27
|
{ id: "falha_balanceamento", descricao: "modela falha, balanceamento e abuso", termos: [/falha|derrota|erro/i, /balanceamento|abuso|exploit/i], obrigatorio: true },
|
|
28
28
|
{ id: "telemetria_jogo", descricao: "define telemetria ou replay de decisao", termos: [/telemetria|replay|metricas/i], obrigatorio: false },
|
|
29
29
|
],
|
|
30
|
+
simulation: [
|
|
31
|
+
{ id: "modelo_e_assumptions", descricao: "declara modelo testavel e assumptions explicitas", termos: [/modelo|model/i, /assumptions?|premissas?|hipoteses?/i], obrigatorio: true },
|
|
32
|
+
{ id: "condicoes_outputs_unidades", descricao: "declara condicoes iniciais, contorno, outputs e unidades", termos: [/condicoes?_iniciais|initial[_ -]?conditions?/i, /condicoes?_contorno|boundary[_ -]?conditions?/i, /outputs?|saidas?|resultados?/i, /unidades?|units?/i], obrigatorio: true },
|
|
33
|
+
{ id: "spatial_render_visual_separados", descricao: "separa modelo espacial, modo de renderizacao e visual profile", termos: [/spatial[_ -]?model|modelo[_ -]?espacial/i, /render[_ -]?mode|modo[_ -]?(?:de[_ -]?)?render/i, /visual[_ -]?profile|perfil[_ -]?visual/i], obrigatorio: true },
|
|
34
|
+
{ id: "controle_e_tempo", descricao: "declara modo de controle e modelo de tempo", termos: [/controle|control(?:[_ -]?modes?)?/i, /tempo|time[_ -]?model|fixed[_ -]?step|real[_ -]?time|event[_ -]?driven/i], obrigatorio: true },
|
|
35
|
+
{ id: "fidelidade_calibracao_incerteza", descricao: "declara fidelidade, referencia, calibracao, tolerancia e incerteza", termos: [/fidelity|fidelidade/i, /referencia|reference|dataset/i, /calibracao|calibration/i, /tolerancias?|tolerances?/i, /incerteza|uncertainty/i], obrigatorio: true },
|
|
36
|
+
{ id: "telemetria_e_replay_simulacao", descricao: "define telemetria, seed, snapshot ou replay reproduzivel", termos: [/telemetria|telemetry|metricas?/i, /seed|snapshot|replay|event[_ -]?log/i], obrigatorio: false },
|
|
37
|
+
],
|
|
30
38
|
legal: [
|
|
31
39
|
{ id: "jurisdicao_e_escopo", descricao: "declara jurisdicao, escopo e limite de uso", termos: [/jurisdicao/i, /escopo|limite/i], obrigatorio: true },
|
|
32
40
|
{ id: "fontes_normativas", descricao: "exige fontes normativas ou base documental", termos: [/fonte|norma|lei|regulamento/i, /citacao|evidencia|documento/i], obrigatorio: true },
|
|
@@ -89,6 +97,12 @@ export const ALIASES_PROFILE = {
|
|
|
89
97
|
game: "game",
|
|
90
98
|
jogo: "game",
|
|
91
99
|
games: "game",
|
|
100
|
+
simulation: "simulation",
|
|
101
|
+
simulations: "simulation",
|
|
102
|
+
simulacao: "simulation",
|
|
103
|
+
simulacoes: "simulation",
|
|
104
|
+
simulador: "simulation",
|
|
105
|
+
simuladores: "simulation",
|
|
92
106
|
legal: "legal",
|
|
93
107
|
juridico: "legal",
|
|
94
108
|
research: "research",
|
|
@@ -140,6 +154,7 @@ export const PRESETS_PROFILE = {
|
|
|
140
154
|
redacao: ["editorial", "materia", "blog", "seo", "reescrita"],
|
|
141
155
|
propostas: ["marketplace", "freela", "consultiva", "diagnostico", "score90"],
|
|
142
156
|
game: ["casual", "arcade", "rpg", "economia", "playtest"],
|
|
157
|
+
simulation: ["model", "scenario", "calibration", "deterministic", "batch", "safety"],
|
|
143
158
|
conversas: ["atendimento", "vendas", "suporte", "qualificacao", "retencao", "cobranca"],
|
|
144
159
|
};
|
|
145
160
|
export const CAPABILITY_MATRIX_GOVERNANCA = {
|
|
@@ -278,6 +293,21 @@ export const CAPABILITY_MATRIX_GOVERNANCA = {
|
|
|
278
293
|
],
|
|
279
294
|
rulePacksSugeridos: ["playtest", "economy-balance", "progression"],
|
|
280
295
|
},
|
|
296
|
+
simulation: {
|
|
297
|
+
profile: "simulation",
|
|
298
|
+
detectaLiteral: true,
|
|
299
|
+
detectaSemantico: "parcial",
|
|
300
|
+
detectaOrdemExecucao: "parcial",
|
|
301
|
+
detectaDriftReal: "parcial",
|
|
302
|
+
validaArtefatoReal: "parcial",
|
|
303
|
+
interpretaNegacao: true,
|
|
304
|
+
confianca: "media",
|
|
305
|
+
limites: [
|
|
306
|
+
"validacao textual nao executa engine, solver ou runtime externo",
|
|
307
|
+
"aparencia visual nao prova fidelidade sem referencia, calibracao, tolerancia e evidencia observada",
|
|
308
|
+
],
|
|
309
|
+
rulePacksSugeridos: ["simulation-model", "simulation-calibration", "simulation-determinism", "simulation-batch", "simulation-safety"],
|
|
310
|
+
},
|
|
281
311
|
conversas: {
|
|
282
312
|
profile: "conversas",
|
|
283
313
|
detectaLiteral: true,
|
package/dist/profileCommand.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type { CapabilityProfile, OpcoesProfileValidar,
|
|
1
|
+
import type { CapabilityProfile, OpcoesProfileValidar, PerfilSemanticoValidavel, ProfileGovernanca, ResultadoProfileValidar, RulePackSema } from "./profileAuthorTipos.js";
|
|
2
2
|
export declare function carregarArtefatoProfile(args: string[]): Promise<{
|
|
3
3
|
texto: string | null;
|
|
4
4
|
arquivo: string | null;
|
|
5
5
|
}>;
|
|
6
|
-
export declare function validarProfileSemantico(entrada: string | undefined, profile:
|
|
6
|
+
export declare function validarProfileSemantico(entrada: string | undefined, profile: PerfilSemanticoValidavel, opcoes: OpcoesProfileValidar): Promise<ResultadoProfileValidar>;
|
|
7
7
|
export declare function renderizarProfileValidarTexto(resultado: ResultadoProfileValidar): string;
|
|
8
8
|
export declare function criarPayloadCapabilityMatrix(): {
|
|
9
9
|
comando: string;
|
|
10
10
|
sucesso: boolean;
|
|
11
11
|
profiles: CapabilityProfile[];
|
|
12
|
+
workflowsEspecializados: readonly [{
|
|
13
|
+
readonly id: "workflow.author";
|
|
14
|
+
readonly comando: "sema author <subcomando>";
|
|
15
|
+
readonly resumo: "Workflow narrativo especializado; não é um profile validável.";
|
|
16
|
+
}];
|
|
12
17
|
resumo: {
|
|
13
18
|
profiles: number;
|
|
19
|
+
workflowsEspecializados: 1;
|
|
14
20
|
validaArtefatoReal: ProfileGovernanca[];
|
|
15
21
|
interpretaNegacao: ProfileGovernanca[];
|
|
16
22
|
};
|
package/dist/profileCommand.js
CHANGED
|
@@ -24,7 +24,7 @@ export async function carregarArtefatoProfile(args) {
|
|
|
24
24
|
}
|
|
25
25
|
export async function validarProfileSemantico(entrada, profile, opcoes) {
|
|
26
26
|
if (!entrada) {
|
|
27
|
-
throw new Error("Uso: sema profile validar <software|workflow|ops|game|legal|research|redacao|propostas|conversas> <arquivo-ou-pasta> [--maturidade draft|prototype|production|critical] [--preset <preset>] [--artefato <texto>|--artefato-arquivo <arquivo>] [--json]");
|
|
27
|
+
throw new Error("Uso: sema profile validar <software|workflow|ops|game|simulation|legal|research|redacao|propostas|conversas> <arquivo-ou-pasta> [--maturidade draft|prototype|production|critical] [--preset <preset>] [--artefato <texto>|--artefato-arquivo <arquivo>] [--json]");
|
|
28
28
|
}
|
|
29
29
|
const modulos = await carregarModulos(entrada);
|
|
30
30
|
const escolhido = modulos.find((item) => moduloCombinaComProfile(item.resultado.modulo?.nome, item.caminho, profile)) ?? modulos[0];
|
|
@@ -139,13 +139,21 @@ export function renderizarProfileValidarTexto(resultado) {
|
|
|
139
139
|
return linhas.join("\n");
|
|
140
140
|
}
|
|
141
141
|
export function criarPayloadCapabilityMatrix() {
|
|
142
|
-
const profiles = Object.values(CAPABILITY_MATRIX_GOVERNANCA)
|
|
142
|
+
const profiles = Object.values(CAPABILITY_MATRIX_GOVERNANCA)
|
|
143
|
+
.filter((profile) => profile.profile !== "author");
|
|
144
|
+
const workflowsEspecializados = [{
|
|
145
|
+
id: "workflow.author",
|
|
146
|
+
comando: "sema author <subcomando>",
|
|
147
|
+
resumo: "Workflow narrativo especializado; não é um profile validável.",
|
|
148
|
+
}];
|
|
143
149
|
return {
|
|
144
150
|
comando: "profile capabilities",
|
|
145
151
|
sucesso: true,
|
|
146
152
|
profiles,
|
|
153
|
+
workflowsEspecializados,
|
|
147
154
|
resumo: {
|
|
148
155
|
profiles: profiles.length,
|
|
156
|
+
workflowsEspecializados: workflowsEspecializados.length,
|
|
149
157
|
validaArtefatoReal: profiles.filter((profile) => profile.validaArtefatoReal).map((profile) => profile.profile),
|
|
150
158
|
interpretaNegacao: profiles.filter((profile) => profile.interpretaNegacao).map((profile) => profile.profile),
|
|
151
159
|
},
|
|
@@ -160,6 +168,8 @@ export function renderizarCapabilityMatrixTexto(payload) {
|
|
|
160
168
|
` packs=${profile.rulePacksSugeridos.join(", ")}`,
|
|
161
169
|
` limites=${profile.limites.join(" | ")}`,
|
|
162
170
|
].join("\n")).join("\n"),
|
|
171
|
+
"SPECIALIZED_WORKFLOWS",
|
|
172
|
+
...payload.workflowsEspecializados.map((workflow) => (`- ${workflow.id}: ${workflow.resumo}\n comando=${workflow.comando}`)),
|
|
163
173
|
].join("\n");
|
|
164
174
|
}
|
|
165
175
|
export function criarPayloadRulePacks(profileFiltro = null) {
|
|
@@ -204,9 +214,9 @@ export async function comandoProfile(posicionais, args, emJson) {
|
|
|
204
214
|
"Uso: sema profile <validar|capabilities|rule-packs>",
|
|
205
215
|
"",
|
|
206
216
|
"Comandos:",
|
|
207
|
-
" sema profile validar <software|workflow|ops|game|legal|research|redacao|propostas|conversas> <arquivo-ou-pasta> [--maturidade draft|prototype|production|critical] [--preset <preset>] [--artefato <texto>|--artefato-arquivo <arquivo>] [--json]",
|
|
217
|
+
" sema profile validar <software|workflow|ops|game|simulation|legal|research|redacao|propostas|conversas> <arquivo-ou-pasta> [--maturidade draft|prototype|production|critical] [--preset <preset>] [--artefato <texto>|--artefato-arquivo <arquivo>] [--json]",
|
|
208
218
|
" sema profile capabilities [--json]",
|
|
209
|
-
" sema profile rule-packs [--profile <author|software|workflow|ops|game|legal|research|redacao|propostas|conversas>] [--json]",
|
|
219
|
+
" sema profile rule-packs [--profile <author|software|workflow|ops|game|simulation|legal|research|redacao|propostas|conversas>] [--json]",
|
|
210
220
|
"",
|
|
211
221
|
"O profile e um gate semantico: se requisito obrigatorio faltar, a saida bloqueia.",
|
|
212
222
|
].join("\n"));
|
|
@@ -230,7 +240,7 @@ export async function comandoProfile(posicionais, args, emJson) {
|
|
|
230
240
|
const profile = normalizarProfileSemantico(posicionais[1] ?? obterOpcao(args, "--profile"));
|
|
231
241
|
const entrada = posicionais[2] ?? obterOpcao(args, "--arquivo");
|
|
232
242
|
if (!profile) {
|
|
233
|
-
console.error("Profile invalido. Use software, workflow, ops, game, legal, research, redacao, propostas ou conversas.");
|
|
243
|
+
console.error("Profile invalido. Use software, workflow, ops, game, simulation, legal, research, redacao, propostas ou conversas.");
|
|
234
244
|
return 1;
|
|
235
245
|
}
|
|
236
246
|
const preset = normalizarPresetProfile(profile, obterOpcao(args, "--preset"));
|
package/dist/profileRegras.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AchadoProfile, ConfiancaValidacaoProfile, DecisaoAgenteProfile, FonteAchadoProfile, MaturidadeProfile,
|
|
2
|
-
export declare function normalizarPresetProfile(profile:
|
|
3
|
-
export declare function moduloCombinaComProfile(modulo: string | null | undefined, caminho: string, profile:
|
|
4
|
-
export declare function severidadeRequisitoProfile(requisito: RequisitoProfile, profile:
|
|
1
|
+
import type { AchadoProfile, ConfiancaValidacaoProfile, DecisaoAgenteProfile, FonteAchadoProfile, MaturidadeProfile, PerfilSemanticoValidavel, PresetProfile, ProfileGovernanca, RequisitoProfile, RulePackSema, RuntimeGateProfile, SeveridadeProfile } from "./profileAuthorTipos.js";
|
|
2
|
+
export declare function normalizarPresetProfile(profile: PerfilSemanticoValidavel, valor: string | undefined): PresetProfile | null;
|
|
3
|
+
export declare function moduloCombinaComProfile(modulo: string | null | undefined, caminho: string, profile: PerfilSemanticoValidavel): boolean;
|
|
4
|
+
export declare function severidadeRequisitoProfile(requisito: RequisitoProfile, profile: PerfilSemanticoValidavel, maturidade: MaturidadeProfile): SeveridadeProfile;
|
|
5
5
|
export declare function riscoAchadoProfile(severidade: SeveridadeProfile, fonte: FonteAchadoProfile): string;
|
|
6
|
-
export declare function avaliarRequisitosProfile(conteudo: string, requisitos: RequisitoProfile[], profile:
|
|
6
|
+
export declare function avaliarRequisitosProfile(conteudo: string, requisitos: RequisitoProfile[], profile: PerfilSemanticoValidavel, maturidade: MaturidadeProfile, fonte?: FonteAchadoProfile): AchadoProfile[];
|
|
7
7
|
export declare function decidirAcaoAgenteProfile(contratoValido: boolean, achados: AchadoProfile[]): DecisaoAgenteProfile;
|
|
8
8
|
export declare function calcularScoreProfile(contratoValido: boolean, achados: AchadoProfile[]): number;
|
|
9
9
|
export declare function penalidadeAchadoProfile(achado: AchadoProfile): number;
|
package/dist/profileRegras.js
CHANGED
|
@@ -46,7 +46,16 @@ export function normalizarPresetProfile(profile, valor) {
|
|
|
46
46
|
retencao_cliente: "retencao",
|
|
47
47
|
cobrar: "cobranca",
|
|
48
48
|
};
|
|
49
|
-
const
|
|
49
|
+
const aliasSimulation = {
|
|
50
|
+
modelo: "model",
|
|
51
|
+
cenario: "scenario",
|
|
52
|
+
calibracao: "calibration",
|
|
53
|
+
deterministico: "deterministic",
|
|
54
|
+
deterministica: "deterministic",
|
|
55
|
+
lote: "batch",
|
|
56
|
+
seguranca: "safety",
|
|
57
|
+
};
|
|
58
|
+
const preset = (profile === "simulation" ? aliasSimulation[chave] : undefined) ?? alias[chave] ?? chave;
|
|
50
59
|
return PRESETS_PROFILE[profile].includes(preset) ? preset : null;
|
|
51
60
|
}
|
|
52
61
|
export function moduloCombinaComProfile(modulo, caminho, profile) {
|
|
@@ -57,6 +66,9 @@ export function moduloCombinaComProfile(modulo, caminho, profile) {
|
|
|
57
66
|
if (profile === "conversas") {
|
|
58
67
|
return /conversas|conversa|atendimento|chatbot|bot/.test(alvo);
|
|
59
68
|
}
|
|
69
|
+
if (profile === "simulation") {
|
|
70
|
+
return /simulation|simulacao|simulador/.test(alvo);
|
|
71
|
+
}
|
|
60
72
|
if (profile === "redacao") {
|
|
61
73
|
return /redacao|redator|materia|editorial|seo/.test(alvo);
|
|
62
74
|
}
|
package/dist/profileRulePacks.js
CHANGED
|
@@ -293,6 +293,56 @@ export const RULE_PACKS_SEMA = [
|
|
|
293
293
|
monetizacao: "cloud",
|
|
294
294
|
status: "planejado",
|
|
295
295
|
},
|
|
296
|
+
{
|
|
297
|
+
id: "simulation-model",
|
|
298
|
+
nome: "Simulation Model Contract",
|
|
299
|
+
categoria: "oss",
|
|
300
|
+
profiles: ["simulation"],
|
|
301
|
+
maturidadeMinima: "draft",
|
|
302
|
+
controles: ["model", "assumptions", "initial_conditions", "boundary_conditions", "outputs", "units"],
|
|
303
|
+
monetizacao: "aberto",
|
|
304
|
+
status: "base",
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: "simulation-calibration",
|
|
308
|
+
nome: "Simulation Calibration Evidence",
|
|
309
|
+
categoria: "oss",
|
|
310
|
+
profiles: ["simulation"],
|
|
311
|
+
maturidadeMinima: "prototype",
|
|
312
|
+
controles: ["reference", "calibration", "tolerance", "uncertainty", "telemetry"],
|
|
313
|
+
monetizacao: "aberto",
|
|
314
|
+
status: "base",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "simulation-determinism",
|
|
318
|
+
nome: "Simulation Determinism And Replay",
|
|
319
|
+
categoria: "oss",
|
|
320
|
+
profiles: ["simulation"],
|
|
321
|
+
maturidadeMinima: "prototype",
|
|
322
|
+
controles: ["seed", "fixed_step", "snapshot", "event_log", "replay", "result_digest"],
|
|
323
|
+
monetizacao: "aberto",
|
|
324
|
+
status: "base",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
id: "simulation-batch",
|
|
328
|
+
nome: "Simulation Batch Runs",
|
|
329
|
+
categoria: "oss",
|
|
330
|
+
profiles: ["simulation"],
|
|
331
|
+
maturidadeMinima: "prototype",
|
|
332
|
+
controles: ["replications", "seed_strategy", "aggregation", "resource_budget", "stop_condition"],
|
|
333
|
+
monetizacao: "aberto",
|
|
334
|
+
status: "base",
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
id: "simulation-safety",
|
|
338
|
+
nome: "Autonomous Simulation Safety",
|
|
339
|
+
categoria: "oss",
|
|
340
|
+
profiles: ["simulation"],
|
|
341
|
+
maturidadeMinima: "prototype",
|
|
342
|
+
controles: ["authority_boundary", "resource_budget", "stop_condition", "fail_safe", "human_takeover", "isolation"],
|
|
343
|
+
monetizacao: "aberto",
|
|
344
|
+
status: "base",
|
|
345
|
+
},
|
|
296
346
|
];
|
|
297
347
|
export const REQUISITOS_PRESET_PROFILE = {
|
|
298
348
|
security: [
|
|
@@ -382,6 +432,24 @@ export const REQUISITOS_PRESET_PROFILE = {
|
|
|
382
432
|
economia: [
|
|
383
433
|
{ id: "game_economia_balanceada", descricao: "economia declara moeda, fonte, gasto e exploit", termos: [/moeda|economia/i, /fonte/i, /gasto|sink/i, /exploit/i], obrigatorio: true, severidade: "blocking" },
|
|
384
434
|
],
|
|
435
|
+
model: [
|
|
436
|
+
{ id: "simulation_model_core", descricao: "modelo declara assumptions, condicoes, outputs e unidades", termos: [/modelo|model/i, /assumptions?|premissas?/i, /condicoes?_iniciais|initial[_ -]?conditions?/i, /condicoes?_contorno|boundary[_ -]?conditions?/i, /outputs?|saidas?/i, /unidades?|units?/i], obrigatorio: true, severidade: "blocking" },
|
|
437
|
+
],
|
|
438
|
+
scenario: [
|
|
439
|
+
{ id: "simulation_scenario_acceptance", descricao: "cenario declara identidade, condicoes e criterios de aceitacao", termos: [/scenario|cenario/i, /condicoes?_iniciais|initial[_ -]?conditions?/i, /condicoes?_contorno|boundary[_ -]?conditions?/i, /acceptance|aceitacao|resultado_esperado/i], obrigatorio: true, severidade: "blocking" },
|
|
440
|
+
],
|
|
441
|
+
calibration: [
|
|
442
|
+
{ id: "simulation_calibration_evidence", descricao: "calibracao declara referencia, metodo, tolerancia, incerteza e telemetria", termos: [/referencia|reference|dataset/i, /calibracao|calibration/i, /tolerancias?|tolerances?/i, /incerteza|uncertainty/i, /telemetria|telemetry/i], obrigatorio: true, severidade: "critical" },
|
|
443
|
+
],
|
|
444
|
+
deterministic: [
|
|
445
|
+
{ id: "simulation_deterministic_replay", descricao: "determinismo declara seed, passo, snapshot e replay", termos: [/determinism|determinismo|deterministic/i, /seed/i, /fixed[_ -]?step|passo_reprodutivel/i, /snapshot|state[_ -]?digest/i, /replay|event[_ -]?log/i], obrigatorio: true, severidade: "blocking" },
|
|
446
|
+
],
|
|
447
|
+
batch: [
|
|
448
|
+
{ id: "simulation_batch_budget", descricao: "batch declara repeticoes, estrategia de seeds, agregacao, budget e parada", termos: [/batch|lote|ensemble/i, /replications?|repeticoes?|scenarios?/i, /seed[_ -]?strategy|estrategia[_ -]?seed/i, /aggregation|agregacao|metricas?/i, /budget|orcamento|limite/i, /stop[_ -]?condition|criterio[_ -]?parada/i], obrigatorio: true, severidade: "blocking" },
|
|
449
|
+
],
|
|
450
|
+
safety: [
|
|
451
|
+
{ id: "simulation_autonomous_safety", descricao: "autonomia declara fronteira, budget, parada, fail-safe e tomada humana", termos: [/autonomous|uncontrolled|autonom/i, /authority[_ -]?boundary|fronteira[_ -]?autoridade/i, /resource[_ -]?budget|orcamento[_ -]?recursos|limite/i, /stop[_ -]?condition|criterio[_ -]?parada|kill[_ -]?switch/i, /fail[_ -]?safe|human[_ -]?takeover|isolamento/i], obrigatorio: true, severidade: "critical" },
|
|
452
|
+
],
|
|
385
453
|
atendimento: [
|
|
386
454
|
{ id: "conversas_atendimento_estado", descricao: "atendimento declara estado do cliente e proxima acao", termos: [/estado|etapa|sentimento/i, /proxima_acao|proxima acao|encaminhar|resolver/i], obrigatorio: true, severidade: "blocking" },
|
|
387
455
|
],
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AdaptadorSistemaInterativo, RegistroProtocoloAdapter, ResultadoValidacaoAdaptadorSistemaInterativo, ResultadoValidacaoProtocoloAdapter } from "./types.js";
|
|
2
|
+
export declare function validarAdaptadorSistemaInterativo(adapter: AdaptadorSistemaInterativo): ResultadoValidacaoAdaptadorSistemaInterativo;
|
|
3
|
+
export declare function validarProtocoloAdapterSistemaInterativo(registro: RegistroProtocoloAdapter): ResultadoValidacaoProtocoloAdapter;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.sistemas_interativos.adaptadores
|
|
2
|
+
// Descricao: valida descriptors e registros detect-probe-snapshot-plan sem executar qualquer fase.
|
|
3
|
+
import { digestSha256Valido } from "./canonical.js";
|
|
4
|
+
import { MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS, obterAdaptadorSistemaInterativo } from "./catalog.js";
|
|
5
|
+
const ORDEM_FASES = [
|
|
6
|
+
"DETECT", "PROBE", "SNAPSHOT", "PLAN", "APPLY", "VALIDATE", "EVIDENCE", "ROLLBACK",
|
|
7
|
+
];
|
|
8
|
+
const BASE_FASES = [
|
|
9
|
+
"DETECT", "PROBE", "SNAPSHOT", "PLAN", "VALIDATE", "EVIDENCE",
|
|
10
|
+
];
|
|
11
|
+
const VERSOES_FLUTUANTES = new Set(["latest", "next", "dev", "main", "master", "*"]);
|
|
12
|
+
const MARCADOR_CHAVE_SENSIVEL = /password|passwd|senha|secret|token|privatekey|apikey|credential|credencial|chaveprivada|chavesecreta/;
|
|
13
|
+
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;
|
|
14
|
+
function adicionar(bloqueios, valor) {
|
|
15
|
+
if (!bloqueios.includes(valor))
|
|
16
|
+
bloqueios.push(valor);
|
|
17
|
+
}
|
|
18
|
+
function textoOpaco(valor) {
|
|
19
|
+
return typeof valor === "string" && valor.trim().length > 0 && !/[\u0000-\u001f\u007f]/.test(valor);
|
|
20
|
+
}
|
|
21
|
+
function registroObjeto(valor) {
|
|
22
|
+
return typeof valor === "object" && valor !== null && !Array.isArray(valor);
|
|
23
|
+
}
|
|
24
|
+
function listaUnicaNaoVazia(valor) {
|
|
25
|
+
return Array.isArray(valor)
|
|
26
|
+
&& valor.length > 0
|
|
27
|
+
&& valor.every(textoOpaco)
|
|
28
|
+
&& new Set(valor).size === valor.length;
|
|
29
|
+
}
|
|
30
|
+
function chaveSensivel(chave) {
|
|
31
|
+
const normalizada = chave
|
|
32
|
+
.normalize("NFKD")
|
|
33
|
+
.replace(/[\u0300-\u036f]/gu, "")
|
|
34
|
+
.replace(/[^a-z0-9]/giu, "")
|
|
35
|
+
.toLowerCase();
|
|
36
|
+
return MARCADOR_CHAVE_SENSIVEL.test(normalizada);
|
|
37
|
+
}
|
|
38
|
+
function contemDadoSensivel(valor, visitados = new Set()) {
|
|
39
|
+
if (typeof valor === "string")
|
|
40
|
+
return VALOR_SENSIVEL.test(valor);
|
|
41
|
+
if (valor === null || typeof valor !== "object")
|
|
42
|
+
return false;
|
|
43
|
+
if (visitados.has(valor))
|
|
44
|
+
return true;
|
|
45
|
+
visitados.add(valor);
|
|
46
|
+
try {
|
|
47
|
+
if (Array.isArray(valor))
|
|
48
|
+
return valor.some((item) => contemDadoSensivel(item, visitados));
|
|
49
|
+
return Object.entries(valor).some(([chave, item]) => chaveSensivel(chave) || contemDadoSensivel(item, visitados));
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
visitados.delete(valor);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function fasesEmOrdem(protocol) {
|
|
56
|
+
let ultima = -1;
|
|
57
|
+
for (const fase of protocol) {
|
|
58
|
+
const indice = ORDEM_FASES.indexOf(fase);
|
|
59
|
+
if (indice < 0 || indice <= ultima)
|
|
60
|
+
return false;
|
|
61
|
+
ultima = indice;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
export function validarAdaptadorSistemaInterativo(adapter) {
|
|
66
|
+
const bloqueios = [];
|
|
67
|
+
const entrada = registroObjeto(adapter) ? adapter : {};
|
|
68
|
+
if (entrada !== adapter)
|
|
69
|
+
adicionar(bloqueios, "adapter_invalido");
|
|
70
|
+
if (!textoOpaco(entrada.adapterId))
|
|
71
|
+
adicionar(bloqueios, "adapter_id_invalido");
|
|
72
|
+
if (!textoOpaco(entrada.version) || VERSOES_FLUTUANTES.has(entrada.version.toLowerCase()))
|
|
73
|
+
adicionar(bloqueios, "adapter_version_nao_fixada");
|
|
74
|
+
if (!textoOpaco(entrada.engine))
|
|
75
|
+
adicionar(bloqueios, "adapter_engine_invalida");
|
|
76
|
+
if (!MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.adapterRoles.includes(entrada.role))
|
|
77
|
+
adicionar(bloqueios, "adapter_role_invalido");
|
|
78
|
+
if (entrada.readOnlyProbe !== true)
|
|
79
|
+
adicionar(bloqueios, "adapter_probe_deve_ser_read_only");
|
|
80
|
+
if (typeof entrada.mutatesWorkspace !== "boolean")
|
|
81
|
+
adicionar(bloqueios, "adapter_mutates_workspace_deve_ser_booleano");
|
|
82
|
+
if (typeof entrada.supportsRollback !== "boolean")
|
|
83
|
+
adicionar(bloqueios, "adapter_supports_rollback_deve_ser_booleano");
|
|
84
|
+
if (entrada.executionBoundary !== "EXTERNAL")
|
|
85
|
+
adicionar(bloqueios, "adapter_execution_boundary_deve_ser_external");
|
|
86
|
+
for (const [campo, lista] of [
|
|
87
|
+
["kinds", entrada.kinds],
|
|
88
|
+
["spatial_models", entrada.spatialModels],
|
|
89
|
+
["render_modes", entrada.renderModes],
|
|
90
|
+
["visual_profiles", entrada.visualProfiles],
|
|
91
|
+
["control_modes", entrada.controlModes],
|
|
92
|
+
["time_models", entrada.timeModels],
|
|
93
|
+
["fidelities", entrada.fidelities],
|
|
94
|
+
["capabilities", entrada.capabilities],
|
|
95
|
+
["protocol", entrada.protocol],
|
|
96
|
+
]) {
|
|
97
|
+
if (!listaUnicaNaoVazia(lista))
|
|
98
|
+
adicionar(bloqueios, `adapter_${campo}_invalidos`);
|
|
99
|
+
}
|
|
100
|
+
const vocabularios = [
|
|
101
|
+
[entrada.kinds, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.kinds, "adapter_kind_fora_do_vocabulario"],
|
|
102
|
+
[entrada.spatialModels, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.spatialModels, "adapter_spatial_model_fora_do_vocabulario"],
|
|
103
|
+
[entrada.renderModes, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.renderModes, "adapter_render_mode_fora_do_vocabulario"],
|
|
104
|
+
[entrada.visualProfiles, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.visualProfiles, "adapter_visual_profile_fora_do_vocabulario"],
|
|
105
|
+
[entrada.controlModes, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.controlModes, "adapter_control_mode_fora_do_vocabulario"],
|
|
106
|
+
[entrada.timeModels, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.timeModels, "adapter_time_model_fora_do_vocabulario"],
|
|
107
|
+
[entrada.fidelities, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.fidelities, "adapter_fidelity_fora_do_vocabulario"],
|
|
108
|
+
];
|
|
109
|
+
for (const [valores, permitidos, codigo] of vocabularios) {
|
|
110
|
+
if (Array.isArray(valores) && !valores.every((valor) => typeof valor === "string" && permitidos.includes(valor))) {
|
|
111
|
+
adicionar(bloqueios, codigo);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(entrada.protocol)) {
|
|
115
|
+
if (!fasesEmOrdem(entrada.protocol))
|
|
116
|
+
adicionar(bloqueios, "adapter_protocol_ordem_invalida");
|
|
117
|
+
for (const fase of BASE_FASES) {
|
|
118
|
+
if (!entrada.protocol.includes(fase))
|
|
119
|
+
adicionar(bloqueios, `adapter_protocol_fase_ausente:${fase}`);
|
|
120
|
+
}
|
|
121
|
+
if (entrada.mutatesWorkspace === true) {
|
|
122
|
+
if (!entrada.protocol.includes("APPLY"))
|
|
123
|
+
adicionar(bloqueios, "adapter_mutante_sem_apply");
|
|
124
|
+
if (!entrada.protocol.includes("ROLLBACK"))
|
|
125
|
+
adicionar(bloqueios, "adapter_mutante_sem_rollback");
|
|
126
|
+
if (!entrada.supportsRollback)
|
|
127
|
+
adicionar(bloqueios, "adapter_mutante_sem_suporte_rollback");
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (entrada.protocol.includes("APPLY"))
|
|
131
|
+
adicionar(bloqueios, "adapter_read_only_nao_pode_declarar_apply");
|
|
132
|
+
if (entrada.protocol.includes("ROLLBACK"))
|
|
133
|
+
adicionar(bloqueios, "adapter_read_only_nao_pode_declarar_rollback");
|
|
134
|
+
if (entrada.supportsRollback)
|
|
135
|
+
adicionar(bloqueios, "adapter_read_only_nao_deve_declarar_rollback");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (contemDadoSensivel(entrada))
|
|
139
|
+
adicionar(bloqueios, "adapter_contem_dado_sensivel");
|
|
140
|
+
return { valido: bloqueios.length === 0, bloqueios: bloqueios.sort() };
|
|
141
|
+
}
|
|
142
|
+
export function validarProtocoloAdapterSistemaInterativo(registro) {
|
|
143
|
+
const bloqueios = [];
|
|
144
|
+
const entrada = registroObjeto(registro) ? registro : {};
|
|
145
|
+
if (entrada !== registro)
|
|
146
|
+
adicionar(bloqueios, "registro_protocolo_invalido");
|
|
147
|
+
if (!textoOpaco(entrada.runId))
|
|
148
|
+
adicionar(bloqueios, "run_id_invalido");
|
|
149
|
+
if (!textoOpaco(entrada.adapterId))
|
|
150
|
+
adicionar(bloqueios, "adapter_id_invalido");
|
|
151
|
+
if (!textoOpaco(entrada.adapterVersion) || VERSOES_FLUTUANTES.has(entrada.adapterVersion.toLowerCase()))
|
|
152
|
+
adicionar(bloqueios, "adapter_version_invalida");
|
|
153
|
+
if (!textoOpaco(entrada.semanticTargetId))
|
|
154
|
+
adicionar(bloqueios, "semantic_target_id_invalido");
|
|
155
|
+
if (typeof entrada.mutated !== "boolean")
|
|
156
|
+
adicionar(bloqueios, "mutated_deve_ser_booleano");
|
|
157
|
+
if (typeof entrada.success !== "boolean")
|
|
158
|
+
adicionar(bloqueios, "success_deve_ser_booleano");
|
|
159
|
+
const phases = Array.isArray(entrada.phases) ? entrada.phases : [];
|
|
160
|
+
if (phases.length === 0)
|
|
161
|
+
adicionar(bloqueios, "phases_ausentes_ou_malformadas");
|
|
162
|
+
const descriptor = textoOpaco(entrada.adapterId) ? obterAdaptadorSistemaInterativo(entrada.adapterId) : undefined;
|
|
163
|
+
if (!descriptor)
|
|
164
|
+
adicionar(bloqueios, "registro_adapter_desconhecido");
|
|
165
|
+
else if (entrada.adapterVersion !== descriptor.version)
|
|
166
|
+
adicionar(bloqueios, "registro_adapter_version_divergente");
|
|
167
|
+
const ids = new Set();
|
|
168
|
+
const fases = [];
|
|
169
|
+
for (const [indice, itemBruto] of phases.entries()) {
|
|
170
|
+
if (!registroObjeto(itemBruto)) {
|
|
171
|
+
adicionar(bloqueios, `phase_malformada_indice:${indice}`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const item = itemBruto;
|
|
175
|
+
if (!textoOpaco(item.phaseId))
|
|
176
|
+
adicionar(bloqueios, "phase_id_invalido");
|
|
177
|
+
else if (ids.has(item.phaseId))
|
|
178
|
+
adicionar(bloqueios, `phase_id_duplicado_indice:${indice}`);
|
|
179
|
+
else
|
|
180
|
+
ids.add(item.phaseId);
|
|
181
|
+
if (!ORDEM_FASES.includes(item.phase))
|
|
182
|
+
adicionar(bloqueios, `phase_invalida_indice:${indice}`);
|
|
183
|
+
else {
|
|
184
|
+
fases.push(item.phase);
|
|
185
|
+
if (descriptor && !descriptor.protocol.includes(item.phase)) {
|
|
186
|
+
adicionar(bloqueios, `phase_nao_permitida_pelo_adapter_indice:${indice}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (item.semanticTargetId !== entrada.semanticTargetId)
|
|
190
|
+
adicionar(bloqueios, `semantic_target_divergente_indice:${indice}`);
|
|
191
|
+
if (!digestSha256Valido(item.inputDigest))
|
|
192
|
+
adicionar(bloqueios, `phase_input_digest_invalido_indice:${indice}`);
|
|
193
|
+
if (!digestSha256Valido(item.outputDigest))
|
|
194
|
+
adicionar(bloqueios, `phase_output_digest_invalido_indice:${indice}`);
|
|
195
|
+
if (typeof item.success !== "boolean")
|
|
196
|
+
adicionar(bloqueios, `phase_success_deve_ser_booleano_indice:${indice}`);
|
|
197
|
+
}
|
|
198
|
+
if (fases[0] !== "DETECT")
|
|
199
|
+
adicionar(bloqueios, "protocolo_deve_iniciar_em_detect");
|
|
200
|
+
if (new Set(fases).size !== fases.length)
|
|
201
|
+
adicionar(bloqueios, "phase_tipo_duplicado");
|
|
202
|
+
if (!fasesEmOrdem(fases))
|
|
203
|
+
adicionar(bloqueios, "phases_fora_da_ordem_canonica");
|
|
204
|
+
for (const fase of BASE_FASES) {
|
|
205
|
+
if (!fases.includes(fase))
|
|
206
|
+
adicionar(bloqueios, `protocolo_fase_base_ausente:${fase}`);
|
|
207
|
+
}
|
|
208
|
+
if (descriptor && !descriptor.mutatesWorkspace && entrada.mutated === true) {
|
|
209
|
+
adicionar(bloqueios, "adapter_read_only_nao_pode_mutar");
|
|
210
|
+
}
|
|
211
|
+
if (entrada.mutated === false && (fases.includes("APPLY") || fases.includes("ROLLBACK"))) {
|
|
212
|
+
adicionar(bloqueios, "registro_nao_mutante_com_fase_mutante");
|
|
213
|
+
}
|
|
214
|
+
const faseSucesso = (fase) => phases.some((item) => (registroObjeto(item) && item.phase === fase && item.success === true));
|
|
215
|
+
const exigeRollback = entrada.mutated === true && entrada.success === false && !faseSucesso("ROLLBACK");
|
|
216
|
+
if (entrada.mutated === true && !faseSucesso("APPLY"))
|
|
217
|
+
adicionar(bloqueios, "mutated_sem_apply_bem_sucedido");
|
|
218
|
+
if (entrada.success === true) {
|
|
219
|
+
if (!faseSucesso("VALIDATE"))
|
|
220
|
+
adicionar(bloqueios, "sucesso_sem_validate");
|
|
221
|
+
if (!faseSucesso("EVIDENCE"))
|
|
222
|
+
adicionar(bloqueios, "sucesso_sem_evidence");
|
|
223
|
+
if (phases.some((item) => !registroObjeto(item) || item.success !== true))
|
|
224
|
+
adicionar(bloqueios, "sucesso_global_com_fase_falha");
|
|
225
|
+
}
|
|
226
|
+
if (exigeRollback)
|
|
227
|
+
adicionar(bloqueios, "falha_mutante_exige_rollback");
|
|
228
|
+
if (entrada.mutated === true && entrada.success === false && faseSucesso("ROLLBACK") && !textoOpaco(entrada.rollbackEvidenceId)) {
|
|
229
|
+
adicionar(bloqueios, "rollback_sem_evidence_id");
|
|
230
|
+
}
|
|
231
|
+
if (contemDadoSensivel(entrada))
|
|
232
|
+
adicionar(bloqueios, "registro_contem_dado_sensivel");
|
|
233
|
+
return {
|
|
234
|
+
valido: bloqueios.length === 0,
|
|
235
|
+
faseAtual: fases.at(-1) ?? "NOT_STARTED",
|
|
236
|
+
bloqueios: bloqueios.sort(),
|
|
237
|
+
exigeRollback,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=adapterProtocol.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AdaptadorSistemaInterativo, PipelineSistemaInterativo } from "./types.js";
|
|
2
|
+
export declare const CATALOGO_PIPELINES_INTERATIVOS_AVANCADOS: readonly PipelineSistemaInterativo[];
|
|
3
|
+
export declare const CATALOGO_ADAPTADORES_INTERATIVOS_AVANCADOS: readonly AdaptadorSistemaInterativo[];
|
|
4
|
+
export declare function listarPipelinesInterativosAvancados(): readonly PipelineSistemaInterativo[];
|
|
5
|
+
export declare function listarAdaptadoresInterativosAvancados(): readonly AdaptadorSistemaInterativo[];
|