ROOT FIX (não paliativo) das 3 lacunas que travavam o Construtor: 1. get_assistant_pricing_tool: lia de Captain::Mcp::PricingTables::TABLES (hash Ruby) que NÃO EXISTE MAIS desde a migração pra DB. Caía no fallback de scenario raw. Refactor: lê de Captain::PricingCategory + Captain::PricingAmount, formata grid markdown agrupado por day_bucket. 2. save_agent_spec_tool: Construtor salvava REFERÊNCIAS (pricing_source.copied_from_assistant_id) mas hermes-provision script espera DADOS EXPANDIDOS (categories[] com amounts, soul_md+skill_md). Refactor: tool agora EXPANDE server-side — busca PricingCategory do parent, monta categories array, gera SOUL.md (template + identity + disclosure_policy) e SKILL.md (template + pricing + rules + identity). Output já é spec consumível pelo script. 3. Captain::PricingAmount::PERIODS: adicionado '1h' (Prime tem 1h). 4. Seed pras 3 units faltando: Hotel Recanto (1) + PrimeAL (2) + Qnn01 (3). Agora os 6 units existentes têm pricing em DB. Hot-patched ambos tools + USR1 no Puma. Construtor pronto pra criar Bianca/Juliana etc end-to-end sem intervenção manual. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.6 KiB
Ruby
41 lines
1.6 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: captain_pricing_amounts
|
|
#
|
|
# id :bigint not null, primary key
|
|
# amount :decimal(10, 2) not null
|
|
# day_bucket :string
|
|
# period :string not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# captain_pricing_category_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# idx_captain_pricing_amount_uniq (captain_pricing_category_id,period,day_bucket) UNIQUE
|
|
# index_captain_pricing_amounts_on_captain_pricing_category_id (captain_pricing_category_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (captain_pricing_category_id => captain_pricing_categories.id)
|
|
#
|
|
# Valor por (categoria, período, dia da semana). day_bucket NULL = preço
|
|
# único todos os dias. day_bucket='mon_wed' = seg-qua. 'thu_sun' = qui-dom.
|
|
class Captain::PricingAmount < ApplicationRecord
|
|
self.table_name = 'captain_pricing_amounts'
|
|
|
|
PERIODS = %w[1h 2h 3h 4h 5h pernoite_promo pernoite_integral diaria].freeze
|
|
DAY_BUCKETS = %w[mon_wed thu_sun].freeze
|
|
|
|
belongs_to :pricing_category,
|
|
class_name: 'Captain::PricingCategory',
|
|
foreign_key: :captain_pricing_category_id,
|
|
inverse_of: :amounts
|
|
|
|
validates :period, inclusion: { in: PERIODS }
|
|
validates :day_bucket, inclusion: { in: DAY_BUCKETS, allow_nil: true }
|
|
validates :amount, numericality: { greater_than: 0 }
|
|
validates :captain_pricing_category_id,
|
|
uniqueness: { scope: %i[period day_bucket] }
|
|
end
|