{"openapi":"3.1.0","info":{"title":"Yzidro Knowledge API","version":"0.2.0","description":"MVP local: projetos, importação versionada e biblioteca oficial. Firebase Auth fornece identidade; PostgreSQL controla permissões."},"servers":[{"url":"/","description":"Servidor atual"}],"security":[{"bearerAuth":[]}],"paths":{"/api/v1/blocked-knowledge":{"get":{"operationId":"listBlockedKnowledge","summary":"Listar memórias publicadas bloqueadas","description":"Exige permissão de revisão e publicação e todos os escopos. Retorna memórias, limitações e fontes para decisão; itens bloqueados não são disponibilizados pelo MCP.","parameters":[{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"maximum":999999,"default":0}}],"responses":{"200":{"description":"Até 100 memórias com nextOffset"},"403":{"description":"Permissões ou escopos insuficientes"}}}},"/api/v1/blocked-knowledge/{id}/decision":{"post":{"operationId":"decideBlockedKnowledge","summary":"Manter bloqueio ou desbloquear memória","description":"Registra a decisão de revisão. Desbloquear ativa a memória e cria uma nova versão auditável. Exige revisão, publicação e todos os escopos; o requestId torna a ação idempotente.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","action","expectedVersion","notes"],"properties":{"requestId":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["unblock","keep_blocked"]},"expectedVersion":{"type":"integer","minimum":1},"notes":{"type":"string","maxLength":2000}}}}}},"responses":{"200":{"description":"Decisão registrada"},"400":{"description":"Decisão inválida"},"403":{"description":"Permissões ou escopos insuficientes"},"404":{"description":"Memória não encontrada"},"409":{"description":"Versão alterada ou solicitação conflitante"}}}},"/api/v1/batches/{id}/items/{itemId}/prioritize":{"post":{"operationId":"prioritizeBatchItem","summary":"Priorizar ou reprocessar um projeto do lote","description":"Prioriza um item pendente ou enfileirado; se já concluído, falho ou bloqueado, solicita nova coleta e análise preservando histórico e contabilizando até duas novas chamadas de IA. Aguarda a próxima vaga sem interromper trabalhos ativos. Repetir requestId não duplica a solicitação. Lotes pausados, cancelados ou rascunhos precisam ser iniciados ou retomados.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"itemId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId"],"properties":{"requestId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Projeto priorizado ou solicitação já registrada"},"400":{"description":"Identificador ou solicitação inválida"},"403":{"description":"Permissões ou escopos insuficientes"},"404":{"description":"Lote ou projeto não encontrado"},"409":{"description":"Lote indisponível ou projeto recriado"}}}},"/api/v1/batches/groups":{"post":{"operationId":"createBatchGroupDrafts","summary":"Salvar projetos em lotes de até 100","description":"Divide até 10.000 PJs em rascunhos numa única transação. Repetir com a mesma chave e lista retorna os mesmos lotes. Não inicia coleta ou análise. A política padrão é confidence: confiança média/alta segue revisão e publicação automáticas, com permissões e validações vigentes. manual mantém revisão humana.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["projects","idempotencyKey"],"properties":{"projects":{"type":"array","minItems":1,"maxItems":10000,"items":{"type":"string"}},"idempotencyKey":{"type":"string","minLength":16,"maxLength":100},"publicationPolicy":{"type":"string","enum":["confidence","manual"],"default":"confidence"}}}}}},"responses":{"200":{"description":"Lotes salvos como rascunhos"},"400":{"description":"Lista inválida"},"403":{"description":"Permissão insuficiente"},"409":{"description":"Chave já utilizada com outra lista"}}}},"/api/v1/batches/{id}/resume":{"post":{"operationId":"resumeBatch","summary":"Retomar lote cancelado, pausado ou com pendencias","description":"Inicia ou retoma o lote. Reabre itens incompletos, preserva publicados e historico de consumo. Cada retomada autoriza ate duas novas chamadas por item reaberto; o teto retornado inclui o consumo anterior. Requer coletor e IA disponiveis.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},"responses":{"200":{"description":"Lote em andamento"},"400":{"description":"Entrada inválida"},"403":{"description":"Permissão insuficiente"},"409":{"description":"Lote não pode ser iniciado"},"503":{"description":"Coletor ou IA indisponível"}}}},"/api/v1/batches/{id}/start":{"post":{"operationId":"startBatch","summary":"Iniciar lote","description":"Inicia ou retoma o lote. Reabre itens incompletos, preserva publicados e historico de consumo. Cada retomada autoriza ate duas novas chamadas por item reaberto; o teto retornado inclui o consumo anterior. Requer coletor e IA disponiveis.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},"responses":{"200":{"description":"Lote em andamento"},"400":{"description":"Entrada inválida"},"403":{"description":"Permissão insuficiente"},"409":{"description":"Lote não pode ser iniciado"},"503":{"description":"Coletor ou IA indisponível"}}}},"/api/v1/batches/{id}/cancel":{"post":{"operationId":"cancelBatch","summary":"Cancelar lote em andamento","description":"Impede novas etapas, marca itens pendentes como cancelados e interrompe coletas e análises ativas do lote.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},"responses":{"200":{"description":"Lote cancelado"},"400":{"description":"Entrada inválida"},"403":{"description":"Permissão insuficiente"},"409":{"description":"Lote não está em andamento"}}}},"/api/v1/batches/wiki-versions/search":{"post":{"operationId":"findWikiVersionsProjects","summary":"Buscar PJs de várias versões na Wiki","description":"Consulta o índice da Wiki uma vez; reúne projetos repetidos e informa as versões e os caminhos de origem. Exige escrita de projetos e importações e todos os escopos. O resultado não garante cobertura de referências fora dos caminhos de versão.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["versions"],"properties":{"versions":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"string","pattern":"^[vV]?[0-9]{3,4}$"}}}}}}},"responses":{"200":{"description":"Versões normalizadas, projetos únicos, fontes e indicação de limite"},"400":{"description":"Lista de versões inválida"},"403":{"description":"Permissão insuficiente"},"503":{"description":"Wiki indisponível ou não configurada"}}}},"/api/v1/batches/wiki-versions/{version}":{"get":{"operationId":"findWikiVersionProjects","summary":"Buscar PJs nos caminhos de uma versão na Wiki","description":"Exige escrita de projetos e importações e todos os escopos. A busca consulta o índice da Wiki configurada, não comprova que todas as referências a projetos estão em caminhos de versão e não inicia tarefas.","parameters":[{"name":"version","in":"path","required":true,"schema":{"type":"string","pattern":"^[vV]?[0-9]{3,4}$"}}],"responses":{"200":{"description":"Lista de PJs, caminhos de origem e indicador de limite da consulta"},"400":{"description":"Versão inválida"},"403":{"description":"Permissão insuficiente"},"503":{"description":"Wiki indisponível ou não configurada"}}}},"/api/v1/batches/preview":{"post":{"operationId":"previewBatchDraft","summary":"Conferir lista de projetos para um rascunho","description":"Requer knowledge:projects:write, knowledge:imports:write e todos os escopos de projeto. Não inicia coleta ou análise.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchDraftInput"}}}},"responses":{"200":{"description":"Projetos válidos, duplicados e inválidos; o lote pode ser iniciado manualmente após ser salvo."},"400":{"description":"Entrada inválida"},"403":{"description":"Permissão insuficiente"}}}},"/api/v1/batches":{"get":{"operationId":"listBatchDrafts","summary":"Listar até 50 rascunhos do usuário","responses":{"200":{"description":"Lista pessoal de rascunhos"}}},"post":{"operationId":"createBatchDraft","summary":"Salvar lista de projetos como rascunho","description":"Não executa os projetos. A chave é idempotente por usuário e projeto Firebase.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BatchDraftInput"},{"type":"object","required":["idempotencyKey"],"properties":{"idempotencyKey":{"type":"string","minLength":16,"maxLength":120}}}]}}}},"responses":{"200":{"description":"Rascunho já criado"},"201":{"description":"Rascunho criado"},"400":{"description":"Entrada inválida"},"403":{"description":"Permissão insuficiente"},"409":{"description":"Chave usada com outra lista"}}}},"/api/v1/batches/{id}":{"get":{"operationId":"getBatchDraft","summary":"Consultar lote do usuário","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Lote, seus projetos e estados de processamento"},"404":{"description":"Lote não encontrado"}}}},"/health":{"get":{"operationId":"health","security":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/health/ready":{"get":{"operationId":"ready","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ready"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Falha interna","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/knowledge":{"get":{"operationId":"searchKnowledge","parameters":[{"name":"query","in":"query","required":false,"schema":{"type":"string","maxLength":200}},{"name":"kind","in":"query","required":false,"schema":{"type":"string","enum":["all","business_rule","parameter","code_mapping","process","invariant","decision","project"],"default":"all"}},{"name":"domain","in":"query","required":false,"schema":{"type":"string","maxLength":120,"default":"all"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"maximum":100000,"default":0}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Falha interna","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/knowledge/{id}":{"get":{"operationId":"getKnowledge","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Detail"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Falha interna","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/auth/me":{"get":{"operationId":"getCurrentIdentity","description":"Retorna somente a identidade do próprio usuário. Não exige concessão de leitura.","responses":{"200":{"description":"Identidade autenticada","content":{"application/json":{"schema":{"type":"object","properties":{"identity":{"type":"object","properties":{"sub":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"}}}}}}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/import-schema":{"get":{"operationId":"getImportSchema","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects":{"get":{"operationId":"listProjects","parameters":[{"name":"query","in":"query","schema":{"type":"string","maxLength":200}},{"name":"attention","in":"query","schema":{"enum":["all","collection","extraction","review"],"default":"all"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"maximum":100000,"default":0}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object"}},"total":{"type":"integer"},"stats":{"type":"object"},"pagination":{"type":"object"}}}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createProject","description":"Exige knowledge:read e knowledge:projects:write. Recebe somente id; metadados são obtidos pela coleta.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectCreate"}}}},"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{id}":{"get":{"operationId":"getProject","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteProject","summary":"Excluir projeto ainda não publicado","description":"Exige knowledge:projects:write e acesso completo. Remove registros candidatos e tarefas; bloqueia qualquer publicação ou origem oficial. Site e ERP são preservados.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"responses":{"200":{"description":"Projeto excluído","content":{"application/json":{"schema":{"type":"object","required":["id","deleted"],"properties":{"id":{"type":"string","pattern":"^PJ-[0-9]{6}$"},"deleted":{"const":true}}}}}},"400":{"description":"Rota ou argumentos inválidos"},"401":{"description":"Autenticação necessária"},"403":{"description":"Sem permissão de escrita ou acesso completo"},"404":{"description":"Projeto não encontrado"},"409":{"description":"Projeto publicado ou alteração concorrente; exclusão recusada"}}}},"/api/v1/projects/{id}/imports":{"post":{"operationId":"importPackage","description":"Exige knowledge:read e knowledge:imports:write. Importação atômica; 200 para reenvio idêntico, 201 para novo pacote.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportPackage"}}}},"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object"}}}},"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/ingestion/status":{"get":{"operationId":"getCollectorStatus","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"boolean"},"reason":{"type":["string","null"]}}}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{id}/ingestions":{"post":{"operationId":"startIngestion","description":"Exige knowledge:read e knowledge:projects:write. Cria tarefa em segundo plano ou reutiliza a tarefa ativa do PJ.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false}}}},"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object"}}}},"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{id}/ingestions/{jobId}":{"get":{"operationId":"getIngestion","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ingestion"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{id}/ingestions/{jobId}/package":{"get":{"operationId":"downloadEvidence","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"ZIP da coleta autenticada","content":{"application/zip":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Requisição inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token ausente ou inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origem ou permissão não autorizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflito","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Corpo maior que 1 MiB","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Banco ou estrutura indisponível","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/extraction/status":{"get":{"summary":"Disponibilidade da geração com IA; não expõe chave","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"boolean"},"reason":{"type":["string","null"]},"model":{"type":["string","null"]}}}}}}}}},"/api/v1/projects/{id}/extractions":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"get":{"summary":"Últimas 20 análises do PJ","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Extraction"}}}}}}}}},"post":{"summary":"Solicitar análise inicial ou aprofundamento; exige knowledge:imports:write","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalysisRequest"}}}},"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/Extraction"},"alreadyQueued":{"const":true}}}}}},"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/Extraction"},"alreadyQueued":{"type":"boolean"}}}}}},"409":{"description":"Coleta necessária"},"503":{"description":"Geração indisponível"}},"description":"Não publica conhecimento. Orientação não importa candidatos. Aprofundamento pode importar candidatos válidos para revisão humana. Até duas chamadas de IA por execução; fila sequencial existente."}},"/api/v1/projects/{id}/extractions/{jobId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"get":{"summary":"Progresso e relatório de uma análise","responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Extraction"}}}},"404":{"description":"Análise não encontrada neste PJ"}}}},"/api/v1/projects/{id}/proposals/{proposalId}/reviews":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"proposalId","in":"path","required":true,"schema":{"type":"string"}}],"post":{"summary":"Registrar revisão humana; exige knowledge:reviews:write e não publica conhecimento","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewRequest"}}}},"responses":{"200":{"description":"Decisão já registrada (idempotência)"},"201":{"description":"Decisão registrada; projeto atualizado"},"403":{"description":"Permissão de revisão ausente"},"409":{"description":"Proposta, revisão ou alvo mudou; atualizar e comparar novamente"}}}},"/api/v1/projects/{id}/proposals/{proposalId}/comparison":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"proposalId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Comparar proposta com entidade oficial ativa","parameters":[{"name":"targetId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Proposta e alvo com fingerprint, versão e compatibilidade"},"404":{"description":"Proposta ou alvo ativo não encontrado"}}}},"/api/v1/projects/{id}/publication-preview":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"get":{"summary":"Preparar lote aprovado, sem gravar dados; exige knowledge:read","responses":{"200":{"description":"Itens com snapshots antes/depois, bloqueios, excluídos, publicações anteriores e previewDigest"},"404":{"description":"PJ ausente"}}}},"/api/v1/projects/{id}/publications":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}],"post":{"summary":"Publicar lote atomicamente; exige knowledge:publish:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicationRequest"}}}},"responses":{"200":{"description":"Solicitação já publicada; resultado e projeto"},"201":{"description":"Lote publicado; resultado e projeto"},"403":{"description":"Permissão de publicação ausente"},"409":{"description":"Prévia mudou ou lote bloqueado; atualizar antes de confirmar"}}}},"/api/v1/gateway/heartbeat":{"post":{"description":"Registra presença e retorna ok, leaseSeconds e concurrency (inteiro de 1 a 16, configurado por PROJECT_CONCURRENCY). O sincronizador usa essa capacidade para executar coletas simultâneas, com leases independentes.","security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":[],"properties":{}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}}}},"/api/v1/gateway/jobs/claim":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":[],"properties":{}}}}},"responses":{"200":{"description":"Operação aceita","content":{"application/json":{"schema":{"type":"object","properties":{"job":{"oneOf":[{"$ref":"#/components/schemas/GatewayJob"},{"type":"null"}]}}}}}},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}}}},"/api/v1/gateway/jobs/{id}/renew":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId"],"properties":{"leaseId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/jobs/{id}/progress":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId","stage","status"],"properties":{"leaseId":{"type":"string","format":"uuid"},"stage":{"enum":["erp","wiki","git","bitbucket","package"]},"status":{"enum":["running","complete","partial","skipped"]}}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/jobs/{id}/manifest":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId","result"],"properties":{"leaseId":{"type":"string","format":"uuid"},"result":{"type":"object","description":"Resultado sanitizado do coletor; arquivos fixos com nome, bytes e sha256. Consulte GATEWAY.md."}}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/jobs/{id}/complete":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId"],"properties":{"leaseId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/jobs/{id}/fail":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId","errorCode"],"properties":{"leaseId":{"type":"string","format":"uuid"},"errorCode":{"enum":["PROJECT_NOT_FOUND","CONFIGURATION_MISSING","DEPENDENCIES_MISSING","COLLECTOR_TIMEOUT","COLLECTOR_FAILED","INVALID_ARTIFACT","PACKAGE_TOO_LARGE","INVALID_PROTOCOL","GATEWAY_STOPPED"]}}}}}},"responses":{"200":{"description":"Operação aceita"},"400":{"description":"Contrato inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Execução vencida, incompleta ou divergente"},"503":{"description":"Gateway desabilitado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/jobs/{id}/artifacts/{name}":{"post":{"security":[{"gatewayAuth":[]}],"tags":["Gateway"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"name","in":"path","required":true,"schema":{"enum":["project.json","requirements.json","checklist-develop.json","checklist-feature.json","wiki-pages.json","evidence-manifest.yaml","git-evidence.json","git-diff.patch"]}},{"name":"X-Gateway-Lease","in":"header","required":true,"schema":{"type":"string","format":"uuid"}}],"description":"Content-Length deve corresponder ao manifesto. Não aceita Content-Encoding.","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"responses":{"200":{"description":"Arquivo conferido e registrado"},"400":{"description":"Nome, tamanho ou tipo inválido"},"401":{"description":"Credencial inválida"},"409":{"description":"Lease inválida ou SHA-256 divergente"}}}},"/api/v1/gateway/code/jobs/claim":{"post":{"tags":["Gateway"],"security":[{"gatewayAuth":[]}],"description":"Requer GATEWAY_CODE_ENABLED=true e migration 009. Credencial exclusiva de máquina.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":[],"properties":{}}}}},"responses":{"200":{"description":"Resultado aceito ou tarefa disponível"},"400":{"description":"Contrato ou resultado inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Lease vencida ou análise encerrada"},"503":{"description":"Leitura remota desabilitada"}}}},"/api/v1/gateway/code/jobs/{id}/renew":{"post":{"tags":["Gateway"],"security":[{"gatewayAuth":[]}],"description":"Requer GATEWAY_CODE_ENABLED=true e migration 009. Credencial exclusiva de máquina.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId"],"properties":{"leaseId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Resultado aceito ou tarefa disponível"},"400":{"description":"Contrato ou resultado inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Lease vencida ou análise encerrada"},"503":{"description":"Leitura remota desabilitada"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/code/jobs/{id}/complete":{"post":{"tags":["Gateway"],"security":[{"gatewayAuth":[]}],"description":"Requer GATEWAY_CODE_ENABLED=true e migration 009. Credencial exclusiva de máquina.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId","result"],"properties":{"leaseId":{"type":"string","format":"uuid"},"result":{"type":"object","description":"Catálogo ou resultados de símbolos conforme GATEWAY-CODE.md; até 400.000 bytes."}}}}}},"responses":{"200":{"description":"Resultado aceito ou tarefa disponível"},"400":{"description":"Contrato ou resultado inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Lease vencida ou análise encerrada"},"503":{"description":"Leitura remota desabilitada"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/gateway/code/jobs/{id}/fail":{"post":{"tags":["Gateway"],"security":[{"gatewayAuth":[]}],"description":"Requer GATEWAY_CODE_ENABLED=true e migration 009. Credencial exclusiva de máquina.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["leaseId"],"properties":{"leaseId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Resultado aceito ou tarefa disponível"},"400":{"description":"Contrato ou resultado inválido"},"401":{"description":"Credencial de máquina inválida"},"409":{"description":"Lease vencida ou análise encerrada"},"503":{"description":"Leitura remota desabilitada"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}]}},"/api/v1/tasks":{"get":{"operationId":"taskCenter","summary":"Tarefas e avisos pessoais do Knowledge","description":"Requer knowledge:read e escopos completos de projetos. Sem filtros de usuário; não inclui fontes, relatórios ou checkpoints. Posição FIFO somente para análises aguardando.","responses":{"200":{"description":"Resumo pessoal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCenter"}}}},"401":{"description":"Autenticação necessária","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Acesso insuficiente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/tasks/notifications/read":{"post":{"operationId":"readTaskNotifications","summary":"Marcar avisos pessoais como lidos","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"oneOf":[{"type":"string","pattern":"^[1-9][0-9]{0,17}$"},{"type":"null"}],"description":"ID do aviso; null marca todos os avisos pessoais."}}}}}},"responses":{"200":{"description":"Leitura persistida, inclusive em chamadas repetidas","content":{"application/json":{"schema":{"type":"object","required":["ok"],"properties":{"ok":{"const":true}}}}}},"400":{"description":"Entrada inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Autenticação necessária","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Acesso insuficiente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{id}/ingestions/{jobId}/normalized":{"get":{"operationId":"normalizedEvidence","summary":"Inspecionar e pesquisar evidências normalizadas","description":"Exige knowledge:read e escopos completos de projetos. Consulta explícita, sem chamadas de IA.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"maximum":100000000}},{"name":"query","in":"query","schema":{"type":"string","maxLength":200}}],"responses":{"200":{"description":"Consulta concluída","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NormalizedEvidence"}}}},"400":{"description":"Consulta inválida"},"401":{"description":"Autenticação necessária"},"403":{"description":"Acesso insuficiente"},"404":{"description":"Coleta ou fonte ausente"},"409":{"description":"Coleta ou código indisponível"},"503":{"description":"Estrutura ou executor indisponível"}}}},"/api/v1/projects/{id}/ingestions/{jobId}/normalized/sources/{sourceId}":{"get":{"operationId":"normalizedSource","summary":"Consultar página de uma fonte normalizada","description":"Exige knowledge:read e escopos completos de projetos. Consulta explícita, sem chamadas de IA.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"sourceId","in":"path","required":true,"schema":{"type":"string","maxLength":120,"pattern":"^[A-Za-z0-9_-]+$"}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}},{"name":"maxBytes","in":"query","schema":{"type":"integer","minimum":256,"maximum":16000}}],"responses":{"200":{"description":"Consulta concluída","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/NormalizedSource"},{"type":"object","properties":{"text":{"type":"string"},"start":{"type":"integer"},"end":{"type":"integer"},"total":{"type":"integer"},"nextOffset":{"type":["integer","null"]}}}]}}}},"400":{"description":"Consulta inválida"},"401":{"description":"Autenticação necessária"},"403":{"description":"Acesso insuficiente"},"404":{"description":"Coleta ou fonte ausente"},"409":{"description":"Coleta ou código indisponível"},"503":{"description":"Estrutura ou executor indisponível"}}}},"/api/v1/projects/{id}/ingestions/{jobId}/normalized/code":{"get":{"operationId":"evidenceCode","summary":"Consultar catálogo ou símbolo de código no snapshot","description":"Exige knowledge:read e escopos completos de projetos. Consulta explícita, sem chamadas de IA.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"file","in":"query","schema":{"type":"string","maxLength":500}},{"name":"symbol","in":"query","schema":{"type":"string","maxLength":200}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}},{"name":"maxBytes","in":"query","schema":{"type":"integer","minimum":256,"maximum":16000}}],"responses":{"200":{"description":"Consulta concluída","content":{"application/json":{"schema":{"type":"object","description":"Sem symbol: file, indexed, symbols, total e nextOffset (até 50 símbolos). Com symbol: página de texto, classificação e proveniência do snapshot."}}}},"400":{"description":"Consulta inválida"},"401":{"description":"Autenticação necessária"},"403":{"description":"Acesso insuficiente"},"404":{"description":"Coleta ou fonte ausente"},"409":{"description":"Coleta ou código indisponível"},"503":{"description":"Estrutura ou executor indisponível"}}}},"/api/v1/projects/{id}/ingestions/{jobId}/normalized/sources/{sourceId}/current":{"get":{"summary":"Read current Wiki page from a captured source index (explicit, no AI)","description":"Exige knowledge:read e escopos completos de projetos. Consulta explícita, sem chamadas de IA.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"sourceId","in":"path","required":true,"schema":{"type":"string","maxLength":120,"pattern":"^[A-Za-z0-9_-]+$"}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}},{"name":"maxBytes","in":"query","schema":{"type":"integer","minimum":256,"maximum":16000}}],"responses":{"200":{"description":"Current version, separate from captured evidence. Includes mode=current, capturedIndex, retrievedAt, currentUpdatedAt and paginated text."},"400":{"description":"Consulta inválida"},"401":{"description":"Autenticação necessária"},"403":{"description":"Acesso insuficiente"},"404":{"description":"Coleta ou fonte ausente"},"409":{"description":"Coleta ou código indisponível"},"503":{"description":"Estrutura ou executor indisponível"}}}},"/api/v1/projects/{id}/ingestions/{jobId}/normalized/sources/{sourceId}/original":{"get":{"summary":"Read original captured source record, paginated UTF-8","description":"Exige knowledge:read e escopos completos de projetos. Consulta explícita, sem chamadas de IA.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^PJ-[0-9]{6}$"}},{"name":"jobId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"sourceId","in":"path","required":true,"schema":{"type":"string","maxLength":120,"pattern":"^[A-Za-z0-9_-]+$"}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0}},{"name":"maxBytes","in":"query","schema":{"type":"integer","minimum":256,"maximum":16000}}],"responses":{"200":{"description":"Original captured record (or grouped original patch), with sourceIndex, mode=captured_original, representation, hashes and byte pagination. Does not return the whole artifact."},"400":{"description":"Consulta inválida"},"401":{"description":"Autenticação necessária"},"403":{"description":"Acesso insuficiente"},"404":{"description":"Coleta ou fonte ausente"},"409":{"description":"Coleta ou código indisponível"},"503":{"description":"Estrutura ou executor indisponível"}}}},"/.well-known/oauth-protected-resource":{"get":{"tags":["OAuth MCP"],"summary":"Metadados públicos para descoberta da autorização MCP","security":[],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}}}},"/.well-known/oauth-protected-resource/mcp":{"get":{"tags":["OAuth MCP"],"summary":"Metadados públicos para descoberta da autorização MCP","security":[],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}}}},"/.well-known/oauth-authorization-server":{"get":{"tags":["OAuth MCP"],"summary":"Metadados públicos para descoberta da autorização MCP","security":[],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}}}},"/oauth/register":{"post":{"tags":["OAuth MCP"],"summary":"Registrar cliente público com PKCE (DCR)","security":[],"responses":{"201":{"description":"Cliente registrado"},"400":{"description":"Metadados inválidos"},"429":{"description":"Limite de registros atingido"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["redirect_uris"],"properties":{"client_name":{"type":"string","maxLength":160},"redirect_uris":{"type":"array","minItems":1,"maxItems":10,"items":{"type":"string","format":"uri"}},"token_endpoint_auth_method":{"const":"none"},"grant_types":{"type":"array","items":{"enum":["authorization_code","refresh_token"]}},"response_types":{"type":"array","items":{"const":"code"}}}}}}}}},"/oauth/authorize":{"get":{"tags":["OAuth MCP"],"summary":"Iniciar autorização no frontend principal","security":[],"responses":{"302":{"description":"Abrir consentimento no frontend"},"400":{"description":"Solicitação inválida"}},"description":"Redireciona para a tela /mcp/authorize do gestao-projeto-discord. A documentação do backend não hospeda consentimento.","parameters":[{"name":"client_id","in":"query","required":true,"schema":{"type":"string"}},{"name":"response_type","in":"query","required":true,"schema":{"type":"string"}},{"name":"redirect_uri","in":"query","required":true,"schema":{"type":"string"}},{"name":"resource","in":"query","required":true,"schema":{"type":"string"}},{"name":"code_challenge","in":"query","required":true,"schema":{"type":"string"}},{"name":"code_challenge_method","in":"query","required":true,"schema":{"type":"string"}},{"name":"scope","in":"query","required":false,"schema":{"type":"string"}},{"name":"state","in":"query","required":false,"schema":{"type":"string"}}]}},"/oauth/token":{"post":{"tags":["OAuth MCP"],"summary":"Trocar código PKCE ou renovar token OAuth","security":[],"responses":{"200":{"description":"Token emitido; scope pode ser menor que o solicitado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpOAuthTokenResponse"}}}},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpOAuthTokenRequest"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/McpOAuthTokenRequest"}}}}}},"/oauth/revoke":{"post":{"tags":["OAuth MCP"],"summary":"Revogar conexão pelo token de acesso ou renovação","security":[],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["client_id","token"],"properties":{"client_id":{"type":"string"},"token":{"type":"string"}}}},"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["client_id","token"],"properties":{"client_id":{"type":"string"},"token":{"type":"string"}}}}}}}},"/api/v1/mcp/oauth/consent/{request}":{"get":{"tags":["OAuth MCP"],"summary":"Consultar consentimento e vincular solicitação à conta autenticada","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"request","in":"path","required":true,"schema":{"type":"string"}}]},"post":{"tags":["OAuth MCP"],"summary":"Autorizar ou recusar os scopes selecionados","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"request","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpOAuthConsentDecision"}}}}}},"/api/v1/mcp/oauth/connections":{"get":{"tags":["OAuth MCP"],"summary":"Listar conexões OAuth próprias","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[]}},"/api/v1/mcp/oauth/connections/{id}":{"delete":{"tags":["OAuth MCP"],"summary":"Revogar conexão OAuth própria","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}]}},"/api/v1/mcp/oauth/admin/users/{uid}/connections":{"get":{"tags":["OAuth MCP"],"summary":"Listar conexões OAuth do usuário (knowledge:access:write)","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"uid","in":"path","required":true,"schema":{"type":"string"}}]}},"/api/v1/mcp/oauth/admin/users/{uid}/connections/{id}":{"delete":{"tags":["OAuth MCP"],"summary":"Revogar conexão OAuth do usuário (knowledge:access:write)","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"uid","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}]}},"/api/v1/mcp/account":{"get":{"tags":["OAuth MCP"],"summary":"Consultar endpoint, catálogo, acesso e disponibilidade de OAuth","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}}}},"/api/v1/mcp/admin/users/{uid}":{"get":{"tags":["OAuth MCP"],"summary":"Consultar acesso MCP do usuário (knowledge:access:write)","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"uid","in":"path","required":true,"schema":{"type":"string"}}]},"put":{"tags":["OAuth MCP"],"summary":"Administrar limites e capacidades de Bearer e OAuth (knowledge:access:write)","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sucesso"},"400":{"description":"Solicitação inválida"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"}},"parameters":[{"name":"uid","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpAccessUpdate"}}}}}},"/api/v1/mcp/account/profile":{"put":{"tags":["OAuth MCP"],"summary":"Definir o próprio perfil de uso do MCP (Suporte N1, Suporte N2, Desenvolvimento ou QA)","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpProfileUpdate"}}}},"responses":{"200":{"description":"Perfil salvo"},"400":{"description":"Perfil inválido"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"},"404":{"description":"Usuário sem acesso ativo"}}}},"/api/v1/mcp/admin/users/{uid}/profile":{"put":{"tags":["OAuth MCP"],"summary":"Definir o perfil de uso do MCP de um usuário (knowledge:access:write)","security":[{"bearerAuth":[]}],"parameters":[{"name":"uid","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpProfileUpdate"}}}},"responses":{"200":{"description":"Perfil salvo"},"400":{"description":"Perfil inválido"},"401":{"description":"Credencial inválida"},"403":{"description":"Acesso não autorizado"},"404":{"description":"Usuário sem acesso ativo"}}}},"/api/v1/mcp/admin/settings":{"get":{"summary":"Lê a configuração do MCP (guard rail de perfil). Exige knowledge:access:write.","tags":["OAuth MCP"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Configuração atual","content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpSettings"}}}},"403":{"description":"Sem permissão de administração"}}},"put":{"summary":"Liga ou desliga o guard rail de perfil: ligado, só o perfil desenvolvimento recebe código-fonte pelo MCP e esse perfil só é atribuído por administrador. Auditado como settings_updated.","tags":["OAuth MCP"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["profileGuard"],"properties":{"profileGuard":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Configuração salva","content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpSettings"}}}},"400":{"description":"Corpo inválido"},"403":{"description":"Sem permissão de administração"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"ID token Firebase. Permissão knowledge:read concedida no PostgreSQL no modo firebase."},"gatewayAuth":{"type":"http","scheme":"bearer","description":"Token próprio do gateway interno; não é um ID token Firebase."}},"schemas":{"BatchDraftInput":{"type":"object","required":["projects","publicationPolicy","maxAiCalls"],"properties":{"projects":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"string","maxLength":120}},"publicationPolicy":{"type":"string","enum":["manual","confidence"]},"maxAiCalls":{"type":"integer","minimum":0,"maximum":200}}},"Item":{"type":"object","required":["id","kind","type","title","domain","status","version","content"],"properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["business_rule","parameter","code_mapping","process","invariant","decision","project"]},"type":{"type":"string"},"title":{"type":"string"},"domain":{"type":"string"},"status":{"type":"string","enum":["active","deprecated","superseded"]},"version":{"type":"integer"},"content":{"type":"object","additionalProperties":true},"sources":{"type":"array","items":{"type":"object","additionalProperties":true}},"relations":{"type":"array","items":{"type":"string"}},"details":{"type":["object","null"]},"evidence":{"type":["object","null"]}},"additionalProperties":true},"Health":{"type":"object","properties":{"status":{"const":"ok"},"service":{"const":"yzidro-knowledge-api"}}},"Ready":{"type":"object","properties":{"status":{"const":"ready"},"dataSource":{"enum":["demo","postgres"]}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","requestId"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"}}}}},"Search":{"type":"object","required":["items","total","filters","stats","pagination"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Item"}},"total":{"type":"integer","description":"Total ativo, antes dos filtros."},"filters":{"type":"object","properties":{"types":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}}}},"domains":{"type":"array","items":{"type":"string"}}}},"stats":{"type":"object","properties":{"active":{"type":"integer"},"types":{"type":"integer"},"fromProjects":{"type":"integer"}}},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"matched":{"type":"integer"}}}}},"Detail":{"type":"object","required":["item","related","origins"],"properties":{"item":{"$ref":"#/components/schemas/Item"},"related":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"direction":{"enum":["incoming","outgoing"]},"item":{"oneOf":[{"$ref":"#/components/schemas/Item"},{"type":"null"}]}}}},"origins":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"ProjectCreate":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","pattern":"^PJ-[0-9]{6}$"}}},"Project":{"type":"object","required":["id","title","domain","proposals","imports","history"],"properties":{"id":{"type":"string"},"title":{"type":"string"},"domain":{"type":"string"},"proposals":{"type":"array","items":{"type":"object"}},"imports":{"type":"array","items":{"type":"object"}},"history":{"type":"array","items":{"type":"object"}},"reviewStats":{"type":"object","properties":{"pending":{"type":"integer","minimum":0},"approved":{"type":"integer","minimum":0},"rejected":{"type":"integer","minimum":0},"needs_changes":{"type":"integer","minimum":0},"stale":{"type":"integer","minimum":0}}},"canDelete":{"type":"boolean","description":"Sem publicação ou origem oficial; a escrita também exige permissão."}},"additionalProperties":true},"ImportPackage":{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"urn:yzidro-knowledge:codex-import:1","title":"Contrato de importação — versões 1 e 2","description":"Limite HTTP: 1 MiB. IDs de propostas pertencem ao projectId; sourceIds devem existir no pacote e relations devem apontar para propostas deste PJ ou conhecimento oficial ativo. Novas propostas iniciam em 1; mudanças usam versão seguinte. A importação não publica conhecimento.","type":"object","additionalProperties":false,"required":["schemaVersion","projectId","packageId","generatedAt","sources","proposals"],"properties":{"schemaVersion":{"type":"integer","enum":[1,2]},"projectId":{"type":"string","pattern":"^PJ-[0-9]{6}$"},"packageId":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"generatedAt":{"type":"string","format":"date-time","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$"},"sources":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["id","type","name","artifact","locator","classification"],"properties":{"id":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"type":{"enum":["erp","git","code","document","knowledge"]},"name":{"type":"string","minLength":1,"maxLength":200},"artifact":{"type":"string","minLength":1,"maxLength":500},"locator":{"type":"string","minLength":1,"maxLength":500},"excerpt":{"type":"string","minLength":0,"maxLength":10000},"classification":{"enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","INFERRED","UNKNOWN","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE"]},"provenance":{"type":"object","additionalProperties":false,"properties":{"projectId":{"type":"string","maxLength":500},"requirementId":{"type":"integer","minimum":0},"wikiPageId":{"type":"integer","minimum":0},"role":{"type":"string","maxLength":500},"commit":{"type":"string","maxLength":500},"pullRequestId":{"type":"integer","minimum":0},"file":{"type":"string","maxLength":500},"symbol":{"type":"string","maxLength":500},"startLine":{"type":"integer","minimum":0},"endLine":{"type":"integer","minimum":0},"sha256":{"type":"string","maxLength":500},"readAt":{"type":"string","maxLength":500},"head":{"type":"string","maxLength":500},"workingTree":{"type":"string","maxLength":500},"excerptSha256":{"type":"string","pattern":"^[a-f0-9]{64}$"}}}}}},"proposals":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"object","additionalProperties":false,"required":["id","kind","title","version","content","sourceIds","relations"],"properties":{"id":{"type":"string","pattern":"^CAND-PJ-[0-9]{6}-[A-Z]+-[0-9]{3}$","maxLength":120},"kind":{"enum":["business_rule","parameter","code_mapping","process","invariant","decision","project"]},"title":{"type":"string","minLength":1,"maxLength":200},"domain":{"type":"string","minLength":0,"maxLength":120},"version":{"type":"integer","minimum":1,"maximum":100000},"content":{"type":"object","additionalProperties":false,"required":["summary","conditions","exceptions"],"properties":{"summary":{"type":"string","minLength":1,"maxLength":10000},"conditions":{"type":"array","minItems":0,"maxItems":50,"items":{"type":"string","minLength":1,"maxLength":2000}},"exceptions":{"type":"array","minItems":0,"maxItems":50,"items":{"type":"string","minLength":1,"maxLength":2000}}}},"sourceIds":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"uniqueItems":true},"relations":{"type":"array","minItems":0,"maxItems":100,"items":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"uniqueItems":true},"details":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["business_rule"]},"behavior":{"type":"object","additionalProperties":false,"properties":{"summary":{"type":"string","maxLength":10000}},"required":["summary"]},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"controlled_by":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","behavior","processes","controlled_by","related_invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["parameter"]},"technical_identifier":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"scope":{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["system","company","user","process","document","entity","entity_instance"]},"entity":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":2000}},"required":["type","entity","description"]},"storage":{"type":"object","additionalProperties":false,"properties":{"table":{"type":"string","maxLength":2000},"column":{"type":"string","maxLength":2000},"dataType":{"type":"string","maxLength":2000}},"required":["table","column","dataType"]},"functional_effect":{"type":"string","maxLength":10000},"values":{"type":"object","additionalProperties":false,"properties":{"presentation":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"technical":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["presentation","technical"]},"activation":{"type":"object","additionalProperties":false,"properties":{"defined_when":{"type":"string","maxLength":2000},"loaded_when":{"type":"string","maxLength":2000},"mutable_until":{"type":"string","maxLength":2000},"constraint":{"type":"string","maxLength":2000}},"required":["defined_when","loaded_when","mutable_until","constraint"]},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","technical_identifier","description","scope","storage","functional_effect","values","activation","related_processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["process"]},"description":{"type":"string","maxLength":10000},"steps":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["name","description","sourceIds"]}},"inputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"outputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"parameters":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","steps","inputs","outputs","related_rules","parameters"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["decision"]},"decision":{"type":"string","maxLength":10000},"rationale":{"type":"string","maxLength":10000},"alternatives":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_projects":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","decision","rationale","alternatives","related_projects","related_processes"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["invariant"]},"description":{"type":"string","maxLength":10000},"applies_to":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","applies_to","processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["code_mapping"]},"symbol":{"type":"object","additionalProperties":false,"properties":{"language":{"type":"string","maxLength":2000},"file":{"type":"string","maxLength":2000},"name":{"type":"string","maxLength":2000}},"required":["language","file","name"]},"description":{"type":"string","maxLength":10000},"rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","symbol","description","rules","processes","invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["project"]},"description":{"type":"string","maxLength":10000},"introduced":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"changed":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"legacy":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"unknowns":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","introduced","changed","legacy","unknowns","related_rules","related_processes"]}]},"evidence":{"type":"object","additionalProperties":false,"properties":{"classifications":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"string","enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE","INFERRED","UNKNOWN"]}},"confidence":{"type":"string","enum":["high","medium","low","unknown"]},"scope":{"type":"string","enum":["INTRODUZIDO_PELO_PJ","ALTERADO_PELO_PJ","LEGADO_JA_EXISTENTE","DESCOBERTO_DURANTE_ANALISE","NAO_CONFIRMADO"]}},"required":["classifications","confidence","scope"]},"disposition":{"enum":["NEW","ENRICH"]},"targetId":{"type":["string","null"]},"findingIds":{"type":"array","maxItems":100,"items":{"type":"string","maxLength":2000}}}}}},"$defs":{"source":{"type":"object","additionalProperties":false,"required":["id","type","name","artifact","locator","classification"],"properties":{"id":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"type":{"enum":["erp","git","code","document","knowledge"]},"name":{"type":"string","minLength":1,"maxLength":200},"artifact":{"type":"string","minLength":1,"maxLength":500},"locator":{"type":"string","minLength":1,"maxLength":500},"excerpt":{"type":"string","minLength":0,"maxLength":10000},"classification":{"enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","INFERRED","UNKNOWN","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE"]},"provenance":{"type":"object","additionalProperties":false,"properties":{"projectId":{"type":"string","maxLength":500},"requirementId":{"type":"integer","minimum":0},"wikiPageId":{"type":"integer","minimum":0},"role":{"type":"string","maxLength":500},"commit":{"type":"string","maxLength":500},"pullRequestId":{"type":"integer","minimum":0},"file":{"type":"string","maxLength":500},"symbol":{"type":"string","maxLength":500},"startLine":{"type":"integer","minimum":0},"endLine":{"type":"integer","minimum":0},"sha256":{"type":"string","maxLength":500},"readAt":{"type":"string","maxLength":500},"head":{"type":"string","maxLength":500},"workingTree":{"type":"string","maxLength":500},"excerptSha256":{"type":"string","pattern":"^[a-f0-9]{64}$"}}}}},"proposal":{"type":"object","additionalProperties":false,"required":["id","kind","title","version","content","sourceIds","relations"],"properties":{"id":{"type":"string","pattern":"^CAND-PJ-[0-9]{6}-[A-Z]+-[0-9]{3}$","maxLength":120},"kind":{"enum":["business_rule","parameter","code_mapping","process","invariant","decision","project"]},"title":{"type":"string","minLength":1,"maxLength":200},"domain":{"type":"string","minLength":0,"maxLength":120},"version":{"type":"integer","minimum":1,"maximum":100000},"content":{"type":"object","additionalProperties":false,"required":["summary","conditions","exceptions"],"properties":{"summary":{"type":"string","minLength":1,"maxLength":10000},"conditions":{"type":"array","minItems":0,"maxItems":50,"items":{"type":"string","minLength":1,"maxLength":2000}},"exceptions":{"type":"array","minItems":0,"maxItems":50,"items":{"type":"string","minLength":1,"maxLength":2000}}}},"sourceIds":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"uniqueItems":true},"relations":{"type":"array","minItems":0,"maxItems":100,"items":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$"},"uniqueItems":true},"details":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["business_rule"]},"behavior":{"type":"object","additionalProperties":false,"properties":{"summary":{"type":"string","maxLength":10000}},"required":["summary"]},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"controlled_by":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","behavior","processes","controlled_by","related_invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["parameter"]},"technical_identifier":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"scope":{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["system","company","user","process","document","entity","entity_instance"]},"entity":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":2000}},"required":["type","entity","description"]},"storage":{"type":"object","additionalProperties":false,"properties":{"table":{"type":"string","maxLength":2000},"column":{"type":"string","maxLength":2000},"dataType":{"type":"string","maxLength":2000}},"required":["table","column","dataType"]},"functional_effect":{"type":"string","maxLength":10000},"values":{"type":"object","additionalProperties":false,"properties":{"presentation":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"technical":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["presentation","technical"]},"activation":{"type":"object","additionalProperties":false,"properties":{"defined_when":{"type":"string","maxLength":2000},"loaded_when":{"type":"string","maxLength":2000},"mutable_until":{"type":"string","maxLength":2000},"constraint":{"type":"string","maxLength":2000}},"required":["defined_when","loaded_when","mutable_until","constraint"]},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","technical_identifier","description","scope","storage","functional_effect","values","activation","related_processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["process"]},"description":{"type":"string","maxLength":10000},"steps":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["name","description","sourceIds"]}},"inputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"outputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"parameters":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","steps","inputs","outputs","related_rules","parameters"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["decision"]},"decision":{"type":"string","maxLength":10000},"rationale":{"type":"string","maxLength":10000},"alternatives":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_projects":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","decision","rationale","alternatives","related_projects","related_processes"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["invariant"]},"description":{"type":"string","maxLength":10000},"applies_to":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","applies_to","processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["code_mapping"]},"symbol":{"type":"object","additionalProperties":false,"properties":{"language":{"type":"string","maxLength":2000},"file":{"type":"string","maxLength":2000},"name":{"type":"string","maxLength":2000}},"required":["language","file","name"]},"description":{"type":"string","maxLength":10000},"rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","symbol","description","rules","processes","invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["project"]},"description":{"type":"string","maxLength":10000},"introduced":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"changed":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"legacy":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"unknowns":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","introduced","changed","legacy","unknowns","related_rules","related_processes"]}]},"evidence":{"type":"object","additionalProperties":false,"properties":{"classifications":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"string","enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE","INFERRED","UNKNOWN"]}},"confidence":{"type":"string","enum":["high","medium","low","unknown"]},"scope":{"type":"string","enum":["INTRODUZIDO_PELO_PJ","ALTERADO_PELO_PJ","LEGADO_JA_EXISTENTE","DESCOBERTO_DURANTE_ANALISE","NAO_CONFIRMADO"]}},"required":["classifications","confidence","scope"]},"disposition":{"enum":["NEW","ENRICH"]},"targetId":{"type":["string","null"]},"findingIds":{"type":"array","maxItems":100,"items":{"type":"string","maxLength":2000}}}}},"allOf":[{"if":{"properties":{"schemaVersion":{"const":2}}},"then":{"properties":{"proposals":{"items":{"required":["details","evidence","disposition","targetId","findingIds"]}}}}}]},"Ingestion":{"type":"object","required":["id","projectId","status","stages"],"properties":{"id":{"type":"string","format":"uuid"},"projectId":{"type":"string"},"status":{"enum":["queued","running","complete","partial","failed","interrupted"]},"stages":{"type":"object"},"warnings":{"type":"array","items":{"type":"object"}},"artifacts":{"type":"array","items":{"type":"object"}}},"additionalProperties":true},"Extraction":{"type":"object","required":["id","projectId","evidenceJobId","status","stages","model"],"properties":{"id":{"type":"string","format":"uuid"},"projectId":{"type":"string","pattern":"^PJ-[0-9]{6}$"},"evidenceJobId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["queued","running","complete","failed","interrupted"]},"model":{"type":"string"},"promptVersion":{"type":"string"},"stages":{"type":"object","additionalProperties":{"type":"string"}},"report":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"reportVersion":{"type":"integer","minimum":2,"maximum":2},"summary":{"type":"string","maxLength":10000},"pjScope":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"functionalScope":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"gaps":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"scopeFindings":{"type":"array","maxItems":100,"items":{"type":"object","additionalProperties":false,"properties":{"finding":{"type":"string","maxLength":2000},"scope":{"type":"string","enum":["INTRODUZIDO_PELO_PJ","ALTERADO_PELO_PJ","LEGADO_JA_EXISTENTE","DESCOBERTO_DURANTE_ANALISE","NAO_CONFIRMADO"]},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["finding","scope","sourceIds"]}},"functionalAnalysis":{"type":"object","additionalProperties":false,"properties":{"before":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"after":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"conditions":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"exceptions":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"parameters":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"effects":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"limits":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"impacts":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["before","after","conditions","rules","exceptions","parameters","effects","limits","impacts"]},"findings":{"type":"array","maxItems":100,"items":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string","maxLength":2000},"title":{"type":"string","maxLength":2000},"decision":{"type":"string","enum":["REUSE","ENRICH","NEW","CONFLICT","UNMODELED","REJECT"]},"scope":{"type":"string","enum":["INTRODUZIDO_PELO_PJ","ALTERADO_PELO_PJ","LEGADO_JA_EXISTENTE","DESCOBERTO_DURANTE_ANALISE","NAO_CONFIRMADO"]},"explanation":{"type":"string","maxLength":10000},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"officialIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"confidence":{"type":"string","enum":["high","medium","low","unknown"]},"classifications":{"type":"array","maxItems":8,"items":{"type":"string","enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE","INFERRED","UNKNOWN"]}},"knowledgeMiss":{"type":"boolean"},"nextAction":{"type":"string","maxLength":2000}},"required":["id","title","decision","scope","explanation","sourceIds","officialIds","confidence","classifications","knowledgeMiss","nextAction"]}},"coverage":{"type":"array","maxItems":200,"items":{"type":"object","additionalProperties":false,"properties":{"topic":{"type":"string","maxLength":2000},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"proposalIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"outcome":{"type":"string","enum":["modeled","unmodeled","rejected","conflict","unknown"]},"explanation":{"type":"string","maxLength":10000}},"required":["topic","sourceIds","proposalIds","outcome","explanation"]}},"proposals":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"properties":{"id":{"type":"string","maxLength":2000},"kind":{"type":"string","enum":["business_rule","parameter","code_mapping","process","invariant","decision","project"]},"title":{"type":"string","maxLength":2000},"domain":{"type":"string","maxLength":2000},"content":{"type":"object","additionalProperties":false,"properties":{"summary":{"type":"string","maxLength":10000},"conditions":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"exceptions":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["summary","conditions","exceptions"]},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"relations":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"details":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["business_rule"]},"behavior":{"type":"object","additionalProperties":false,"properties":{"summary":{"type":"string","maxLength":10000}},"required":["summary"]},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"controlled_by":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","behavior","processes","controlled_by","related_invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["parameter"]},"technical_identifier":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"scope":{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["system","company","user","process","document","entity","entity_instance"]},"entity":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":2000}},"required":["type","entity","description"]},"storage":{"type":"object","additionalProperties":false,"properties":{"table":{"type":"string","maxLength":2000},"column":{"type":"string","maxLength":2000},"dataType":{"type":"string","maxLength":2000}},"required":["table","column","dataType"]},"functional_effect":{"type":"string","maxLength":10000},"values":{"type":"object","additionalProperties":false,"properties":{"presentation":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"technical":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["presentation","technical"]},"activation":{"type":"object","additionalProperties":false,"properties":{"defined_when":{"type":"string","maxLength":2000},"loaded_when":{"type":"string","maxLength":2000},"mutable_until":{"type":"string","maxLength":2000},"constraint":{"type":"string","maxLength":2000}},"required":["defined_when","loaded_when","mutable_until","constraint"]},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","technical_identifier","description","scope","storage","functional_effect","values","activation","related_processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["process"]},"description":{"type":"string","maxLength":10000},"steps":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":2000},"description":{"type":"string","maxLength":10000},"sourceIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["name","description","sourceIds"]}},"inputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"outputs":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"parameters":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","steps","inputs","outputs","related_rules","parameters"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["decision"]},"decision":{"type":"string","maxLength":10000},"rationale":{"type":"string","maxLength":10000},"alternatives":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_projects":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","decision","rationale","alternatives","related_projects","related_processes"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["invariant"]},"description":{"type":"string","maxLength":10000},"applies_to":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","applies_to","processes","related_rules"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["code_mapping"]},"symbol":{"type":"object","additionalProperties":false,"properties":{"language":{"type":"string","maxLength":2000},"file":{"type":"string","maxLength":2000},"name":{"type":"string","maxLength":2000}},"required":["language","file","name"]},"description":{"type":"string","maxLength":10000},"rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"invariants":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","symbol","description","rules","processes","invariants"]},{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["project"]},"description":{"type":"string","maxLength":10000},"introduced":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"changed":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"legacy":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"unknowns":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_rules":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}},"related_processes":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["type","description","introduced","changed","legacy","unknowns","related_rules","related_processes"]}]},"evidence":{"type":"object","additionalProperties":false,"properties":{"classifications":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"string","enum":["CODE_CONFIRMED","KNOWLEDGE_CONFIRMED","ERP_PROJECT_REQUIREMENT","ERP_CHECKLIST","WIKI_DOCUMENTATION","HISTORICAL_EVIDENCE","INFERRED","UNKNOWN"]}},"confidence":{"type":"string","enum":["high","medium","low","unknown"]},"scope":{"type":"string","enum":["INTRODUZIDO_PELO_PJ","ALTERADO_PELO_PJ","LEGADO_JA_EXISTENTE","DESCOBERTO_DURANTE_ANALISE","NAO_CONFIRMADO"]}},"required":["classifications","confidence","scope"]},"disposition":{"type":"string","enum":["NEW","ENRICH"]},"targetId":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}]},"findingIds":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":2000}}},"required":["id","kind","title","domain","content","sourceIds","relations","details","evidence","disposition","targetId","findingIds"]}}},"required":["reportVersion","summary","pjScope","functionalScope","gaps","scopeFindings","functionalAnalysis","findings","coverage","proposals"]},{"type":"null"},{"type":"object","description":"Relatório histórico v1 ou relatório v2 acrescido dos metadados controlados pelo servidor."}]},"usage":{"type":["object","null"]},"errorCode":{"type":["string","null"]},"importId":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"taskInput":{"type":"object","description":"Solicitação persistida, sem segredos ou checkpoint privado. Novas tarefas usam AnalysisRequest."}}},"ReviewRequest":{"type":"object","additionalProperties":false,"required":["requestId","proposalVersion","proposalDigest","expectedReviewVersion","status","disposition","targetId","targetVersion","targetDigest","notes","patch"],"properties":{"requestId":{"type":"string","format":"uuid"},"proposalVersion":{"type":"integer","minimum":1},"proposalDigest":{"type":"string","pattern":"^[a-f0-9]{64}$"},"expectedReviewVersion":{"type":"integer","minimum":0},"status":{"type":"string","enum":["approved","rejected","needs_changes"]},"disposition":{"type":["string","null"],"enum":["new","enrich","reuse",null]},"targetId":{"type":["string","null"]},"targetVersion":{"type":["integer","null"]},"targetDigest":{"type":["string","null"]},"notes":{"type":"string","minLength":1,"maxLength":4000},"patch":{"type":["object","null"],"description":"Explicit enrichment patch, or title/domain/content adjustment of a new project memory. Stored with the review; publication remains explicit."}}},"ProposalReview":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"reviewVersion":{"type":"integer"},"proposalVersion":{"type":"integer"},"proposalDigest":{"type":"string"},"status":{"enum":["approved","rejected","needs_changes"]},"disposition":{"enum":["new","enrich","reuse",null]},"targetId":{"type":["string","null"]},"targetSnapshot":{"type":["object","null"]},"patch":{"type":["object","null"]},"notes":{"type":"string"},"actor":{"type":"string"},"reviewedAt":{"type":"string","format":"date-time"}}},"PublicationRequest":{"type":"object","additionalProperties":false,"required":["requestId","previewDigest"],"properties":{"requestId":{"type":"string","format":"uuid"},"previewDigest":{"type":"string","pattern":"^[a-f0-9]{64}$"}}},"GatewayJob":{"type":"object","additionalProperties":false,"required":["id","projectId","leaseId","leaseExpiresAt","deadlineAt","maxBytes"],"properties":{"id":{"type":"string","format":"uuid"},"projectId":{"type":"string","pattern":"^PJ-[0-9]{6}$"},"leaseId":{"type":"string","format":"uuid"},"leaseExpiresAt":{"type":"string","format":"date-time"},"deadlineAt":{"type":"string","format":"date-time"},"maxBytes":{"type":"integer","minimum":1}}},"TaskSummary":{"type":"object","required":["id","projectId","projectTitle","type","status","createdAt","startedAt","finishedAt","updatedAt","stage","queuePosition"],"properties":{"id":{"type":"string"},"projectId":{"type":"string"},"projectTitle":{"type":"string"},"type":{"type":"string","enum":["ingestion","extraction"]},"status":{"type":"string","enum":["queued","running","complete","partial","failed","interrupted","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":["string","null"],"format":"date-time"},"finishedAt":{"type":["string","null"],"format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"stage":{"type":["string","null"]},"queuePosition":{"type":["integer","null"],"minimum":1},"taskKind":{"type":"string","enum":["collection","initial","focused","legacy"]}}},"TaskNotification":{"type":"object","required":["id","projectId","projectTitle","type","status","createdAt","taskId","readAt"],"properties":{"id":{"type":"string"},"projectId":{"type":"string"},"projectTitle":{"type":"string"},"type":{"type":"string","enum":["ingestion","extraction"]},"status":{"type":"string","enum":["queued","running","complete","partial","failed","interrupted","cancelled"]},"createdAt":{"type":"string","format":"date-time"},"taskId":{"type":"string","format":"uuid"},"readAt":{"type":["string","null"],"format":"date-time"},"taskKind":{"type":"string","enum":["collection","initial","focused","legacy"]}}},"TaskCenter":{"type":"object","required":["activeCount","unreadCount","tasks","recent","notifications"],"properties":{"activeCount":{"type":"integer","minimum":0},"unreadCount":{"type":"integer","minimum":0},"tasks":{"type":"array","items":{"$ref":"#/components/schemas/TaskSummary"}},"recent":{"type":"array","maxItems":30,"items":{"$ref":"#/components/schemas/TaskSummary"}},"notifications":{"type":"array","maxItems":50,"items":{"$ref":"#/components/schemas/TaskNotification"}}}},"AnalysisRequest":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"const":"initial"},"evidenceJobId":{"type":"string","format":"uuid"},"normalizedIdentity":{"type":"string","pattern":"^[a-f0-9]{64}$"}}},{"type":"object","additionalProperties":false,"required":["kind","evidenceJobId","question"],"properties":{"kind":{"const":"focused"},"evidenceJobId":{"type":"string","format":"uuid"},"normalizedIdentity":{"type":"string","pattern":"^[a-f0-9]{64}$"},"question":{"type":"string","minLength":10,"maxLength":2000},"sourceIds":{"type":"array","minItems":1,"maxItems":12,"uniqueItems":true,"items":{"type":"string","pattern":"^[A-Za-z0-9_-]+$","maxLength":120},"description":"Optional override. Without sourceIds, the server selects related normalized excerpts."},"codeRequests":{"type":"array","maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["file","symbol"],"properties":{"file":{"type":"string","maxLength":500},"symbol":{"type":"string","maxLength":200}}}},"officialQuery":{"type":"string","maxLength":200,"description":"Busca explícita de até dez termos; carrega até três entidades e relações."}}},{"type":"object","maxProperties":0}],"description":"Pre-analysis prepares a reviewable project memory. Focused questions select normalized sources automatically unless sourceIds is provided. Empty body uses latest completed collection."},"NormalizedSource":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"title":{"type":"string"},"artifact":{"type":"string"},"locator":{"type":"string"},"classification":{"type":"string"},"sha256":{"type":"string","pattern":"^[a-f0-9]{64}$"},"originalSha256":{"type":"string","pattern":"^[a-f0-9]{64}$"},"artifactSha256":{"type":["string","null"]},"bytes":{"type":"integer"},"contentId":{"type":"string"},"provenance":{"type":"object"},"references":{"type":"object"},"transformations":{"type":"array","items":{"type":"object"}},"warnings":{"type":"array","items":{"type":"object"}},"sourceIndex":{"type":"object","properties":{"id":{"type":"string"},"sourceKey":{"type":"string"},"evidenceJobId":{"type":"string","format":"uuid"},"sourceId":{"type":"string"},"origin":{"type":"object"},"capturedSha256":{"type":"string"},"links":{"type":"object","properties":{"normalized":{"type":["string","null"]},"captured":{"type":["string","null"]},"current":{"type":["string","null"]},"original":{"type":["string","null"]}}}}}}},"NormalizedEvidence":{"type":"object","properties":{"version":{"type":"string"},"identity":{"type":"string","pattern":"^[a-f0-9]{64}$"},"projectId":{"type":"string"},"evidenceJobId":{"type":"string","format":"uuid"},"total":{"type":"integer"},"offset":{"type":"integer"},"nextOffset":{"type":["integer","null"]},"collectionStatus":{"type":"string"},"capturedAt":{"type":"string","format":"date-time"},"warnings":{"type":"array","items":{"type":"object"}},"metrics":{"type":"object"},"sources":{"type":"array","maxItems":30,"items":{"$ref":"#/components/schemas/NormalizedSource"}},"codeFiles":{"type":"array","maxItems":100,"items":{"type":"string"}},"codeFileCount":{"type":"integer"},"codeFilesTruncated":{"type":"boolean"},"codeAvailable":{"type":"boolean"},"codeIndex":{"type":"object"},"currentWikiAvailable":{"type":"boolean"},"gitOrigin":{"type":"object"}}},"McpOAuthConsentDecision":{"type":"object","additionalProperties":false,"required":["approve"],"properties":{"approve":{"type":"boolean"},"scopes":{"type":"string","description":"Subconjunto permitido, separado por espaços; obrigatório ao aprovar."}}},"McpOAuthTokenRequest":{"type":"object","required":["client_id","grant_type","resource"],"properties":{"client_id":{"type":"string"},"grant_type":{"enum":["authorization_code","refresh_token"]},"resource":{"type":"string","format":"uri"},"code":{"type":"string"},"redirect_uri":{"type":"string","format":"uri"},"code_verifier":{"type":"string","minLength":43,"maxLength":128},"refresh_token":{"type":"string"},"scope":{"type":"string"}}},"McpOAuthTokenResponse":{"type":"object","required":["access_token","token_type","expires_in","scope"],"properties":{"access_token":{"type":"string"},"token_type":{"const":"Bearer"},"expires_in":{"type":"integer","maximum":3600},"scope":{"type":"string"},"refresh_token":{"type":"string"}}},"McpAccessUpdate":{"type":"object","additionalProperties":false,"required":["enabled","canIssueTokens","scopes"],"properties":{"enabled":{"type":"boolean"},"canIssueTokens":{"type":"boolean"},"canAuthorizeOAuth":{"type":"boolean","description":"Independente da emissão de tokens pessoais; omissão preserva o valor atual."},"scopes":{"type":"array","items":{"type":"string"}}}},"McpProfileUpdate":{"type":"object","additionalProperties":false,"required":["profile"],"properties":{"profile":{"type":["string","null"],"enum":["suporte","desenvolvimento",null],"description":"Perfil de uso do MCP: muda só o formato das respostas (não altera escopos). suporte = Suporte (N1 e N2) / Implantação; desenvolvimento = Desenvolvimento / N3. null remove o perfil e o MCP volta a perguntar e salvar pela conversa."}}},"McpSettings":{"type":"object","properties":{"profileGuard":{"type":"boolean","description":"Guard rail de perfil ligado."},"updatedBy":{"type":["string","null"]},"updatedAt":{"type":["string","null"],"format":"date-time"}}}}}}