Tests ADN / test (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GEMMA <noreply@gemma.dtic>
39 lines
1.5 KiB
Ruby
39 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# lib_usos.rb — Registro de uso por individuo (P201/Fase3, D045 §11, ME-605 punto 5)
|
|
# ==============================================================================
|
|
# Trazabilidad de quién recibió qué key y cuándo — separado del dato de origen
|
|
# (cuenta_origen, en lib_registro.rb) y separado de registro.json (estado actual)
|
|
# para no mezclar "foto del ahora" con "historial acumulado". Append-only,
|
|
# JSONL — mismo espíritu que un log de bitácora: se escribe, no se reescribe.
|
|
# ==============================================================================
|
|
|
|
require 'json'
|
|
require 'time'
|
|
require_relative 'lib_estado'
|
|
|
|
module Nexxa
|
|
module Usos
|
|
LOG_FILE = Estado::USOS_LOG # fuente única de la ruta (P335/Fase 17)
|
|
|
|
# evento (P204/Fase3): 'dispensada' (reserva al entregar la key) o 'agotada'
|
|
# (el consumidor reportó agotamiento real) — default compat con llamadas
|
|
# previas a Fase3 (todas eran dispensas).
|
|
def self.registrar(provider:, identificador:, individuo:, en: Time.now, evento: 'dispensada')
|
|
linea = {
|
|
'provider' => provider,
|
|
'identificador' => identificador,
|
|
'individuo' => individuo,
|
|
'evento' => evento,
|
|
'en' => en.iso8601
|
|
}
|
|
Estado.usos_registrar(linea)
|
|
end
|
|
|
|
# Historial más reciente primero, opcionalmente filtrado por key (Nexxa::Estado, P335/Fase 17)
|
|
def self.historial(provider: nil, identificador: nil, limit: 50)
|
|
Estado.usos_historial(provider: provider, identificador: identificador, limit: limit)
|
|
end
|
|
end
|
|
end
|