cabal-version:      3.0
name:               siza-client
version:            0.1.0.0
synopsis:           Compiled Haskell client for the Sabela AI tool surface.
description:        Typed CLI + library that drives a running Sabela notebook
                    over /api/ai/*, with a client-side pre-flight (parse +
                    security) pipeline. Replaces siza-discover.sh/siza-tool.sh.
build-type:         Simple
license:            MIT
license-file:       LICENSE
author:             DataHaskell
maintainer:         mschavinda@gmail.com
category:           Development

source-repository head
    type:     git
    location: https://github.com/DataHaskell/sabela
    subdir:   siza-client

common warnings
    ghc-options: -Wall

library
    import:           warnings
    hs-source-dirs:   src
    default-language: Haskell2010
    default-extensions: OverloadedStrings, LambdaCase
    exposed-modules:  Siza.Discover
                      Siza.Transport
                      Siza.Transport.Failure
                      Siza.HubToken
                      Siza.Login
                      Siza.Cli
                      Siza.Mcp
                      Siza.Mcp.Surface
                      Siza.Mcp.Rpc
                      Siza.Language
                      Siza.Lang.Haskell
                      Siza.Preflight
                      Siza.Security
                      Siza.Annotate
                      Siza.Cli.Annotate
                      Siza.Cli.Chat
                      Siza.Cli.Await
                      Siza.Cli.Options
                      Siza.Cli.Provenance
                      Siza.Cli.Retro
                      Siza.Provenance
                      Siza.Provenance.Event
                      Siza.Provenance.Log
                      Siza.Retro
                      Siza.Retro.Episode
                      Siza.Retro.Result
                      Siza.Retro.Metrics
                      Siza.Retro.Distribution
                      Siza.Retro.Report
                      Siza.Agent.Loop
                      Siza.Agent.Loop.Episode
                      Siza.Agent.Loop.Sampling
                      Siza.Agent.Loop.Step
                      Siza.Agent.Loop.Types
                      Siza.Agent.Loop.Support
                      Siza.Agent.Loop.WrapUp
                      Siza.Agent.Loop.Verdict
                      Siza.Agent.Loop.Prompt
                      Siza.Agent.Loop.Route
                      Siza.Agent.EmitLedger
                      Siza.Agent.Chat
                      Siza.Agent.Chat.Export
                      Siza.Agent.Chat.Verify
                      Siza.Agent.Compact
                      Siza.Agent.Recall
                      Siza.Agent.Check
                      Siza.Agent.Check.Gate
                      Siza.Agent.Check.Vet
                      Siza.Agent.Check.Marker
                      Siza.Agent.CheckExtract
                      Siza.Agent.Tools
                      Siza.Agent.Tools.Catalogue
                      Siza.Agent.OutcomeDistill
                      Siza.Agent.Render
                      Siza.Agent.ToolRoute
                      Siza.Agent.Ack
                      Siza.Agent.Discover
                      Siza.Agent.Discover.Types
                      Siza.Agent.Discover.CabalFacts
                      Siza.Agent.Discover.Absent
                      Siza.Agent.Discover.Interpret
                      Siza.Agent.Discover.UnitName
                      Siza.Agent.Discover.Classify
                      Siza.Agent.Discover.CardRows
                      Siza.Agent.Discover.CardAuthority
                      Siza.Agent.Discover.HitJson
                      Siza.Agent.Discover.SessionAnswer
                      Siza.Agent.Discover.Affordance
                      Siza.Agent.Discover.Installed
                      Siza.Agent.Discover.Mode
                      Siza.Agent.Discover.Merge
                      Siza.Agent.Discover.Rank
                      Siza.Agent.Discover.Render
                      Siza.Agent.Discover.Resolved
                      Siza.Agent.Discover.ScopeFilter
                      Siza.Agent.Discover.ModuleList
                      Siza.Agent.Discover.Inventory
                      Siza.Agent.Discover.Fetch
                      Siza.Agent.Discover.Guidance
                      Siza.Agent.Discover.Envelope
                      Siza.Agent.Discover.Evict
                      Siza.Agent.Discover.FactSelect
                      Siza.Agent.Discover.Exact
                      Siza.Agent.Discover.Construct
                      Siza.Agent.Discover.Goal
                      Siza.Agent.Discover.GoalEscalate
                      Siza.Agent.Discover.Literal
                      Siza.Agent.Discover.ProducerCard
                      Siza.Agent.Discover.Ledger
                      Siza.Agent.Discover.Request
                      Siza.Agent.Discover.Advice
                      Siza.Agent.Discover.Beside
                      Siza.Agent.Discover.Candidate
                      Siza.Agent.Discover.Facts
                      Siza.Agent.Discover.HoleProbe
                      Siza.Agent.Discover.MissLadder
                      Siza.Agent.Discover.Closure
                      Siza.Agent.Discover.Steer
                      Siza.Agent.Discover.History
                      Siza.Agent.Discover.Dedup
                      Siza.Agent.Discover.HistoryGuard
                      Siza.Agent.Discover.Hackage
                      Siza.Agent.DiscoverTool
                      Siza.Agent.Futility
                      Siza.Agent.Streak
                      Siza.Agent.Deliverable
                      Siza.Agent.NoteLedger
                      Siza.Agent.Owned
                      Siza.Agent.Stack
                      Siza.Agent.Stack.Call
                      Siza.Agent.VerifyTool
                      Siza.Agent.Repair
                      Siza.Agent.Repair.Blocking
                      Siza.Agent.RepairGuard
                      Siza.Agent.RepairLocate
                      Siza.Agent.RepairTiers
                      Siza.Agent.RenderContract
                      Siza.Agent.Messages
                      Siza.Agent.Transcript
                      Siza.Agent.Sample
                      Siza.Agent.Exemplars
                      Siza.Agent.Preflight
                      Siza.Agent.Scaffold
    build-depends:    base >= 4 && < 5
                      -- the contract sub-library: typed wire DTOs + AST parser
                      -- reuse, without the server's warp/servant/process drag
                    , sabela:sabela-contract >= 0.1 && < 0.2
                      -- transport (already in-project; server uses the same)
                    , http-client >= 0.7 && < 0.10
                    , http-client-tls >= 0.3 && < 0.4
                    , http-types >= 0.12 && < 0.13
                    , aeson >= 2.0 && < 3
                    , bytestring >= 0.10 && < 0.13
                    , text >= 1.2 && < 3
                    , containers >= 0.6.7 && < 0.9
                    , directory >= 1.3 && < 1.4
                    , filepath >= 1.4 && < 1.6
                      -- siza login: open the authorize URL in the browser
                    , process >= 1.6 && < 1.8
                      -- provenance log timestamps (UTCTime)
                    , time >= 1.9 && < 2
                      -- opt-in hash-chain over the provenance log (SHA-256);
                      -- already in the build plan via http-client-tls/tls
                    , crypton >= 0.30 && < 2
                      -- typed CLI surface
                    , optparse-applicative >= 0.17 && < 0.20
                      -- parse-with-location: the SAME parser Sabela.Parse
                      -- uses, pinned to the SAME bounds so they stay lockstep
                    , ghc-lib-parser >= 9.6 && < 9.20
                    , ghc-lib-parser-ex >= 9.6 && < 9.20
    -- POSIX file modes for the 0600 hub-token file; Windows uses ACLs (CPP no-op)
    if !os(windows)
        build-depends: unix >= 2.7 && < 2.9

executable siza
    import:           warnings
    hs-source-dirs:   app
    main-is:          Main.hs
    default-language: Haskell2010
    ghc-options:      -threaded -rtsopts "-with-rtsopts=-N"
    build-depends:    base >= 4 && < 5
                    , siza-client

-- The payload-truth gate. Run by scripts/payload-probe.sh against a throwaway
-- server; deliberately NOT a test-suite, since it needs a live backend.
executable siza-probe
    import:           warnings
    hs-source-dirs:   probe
    main-is:          Main.hs
    other-modules:    Probe.Check
                      Probe.Claim
                      Probe.Oracle
                      Probe.Record
    default-language: Haskell2010
    default-extensions: OverloadedStrings, LambdaCase
    ghc-options:      -threaded -rtsopts "-with-rtsopts=-N"
    build-depends:    base >= 4 && < 5
                    , siza-client
                    , sabela >= 0.1 && < 0.2
                    , sabela:sabela-contract >= 0.1 && < 0.2
                    , aeson >= 2.0 && < 3
                    , containers >= 0.6.7 && < 0.9
                    , directory >= 1.3 && < 1.4
                    , filepath >= 1.4 && < 1.6
                    , process >= 1.6 && < 1.8
                    , text >= 1.2 && < 3

-- Builds the local Hackage facts cache from the cabal index tar. Run by
-- tools/update-search-cache.sh, never at query time.
executable siza-hackage-facts
    import:           warnings
    hs-source-dirs:   hackage-facts
    main-is:          Main.hs
    default-language: Haskell2010
    default-extensions: OverloadedStrings, LambdaCase
    ghc-options:      -rtsopts
    build-depends:    base >= 4 && < 5
                    , siza-client
                    , bytestring >= 0.11 && < 0.13
                    , containers >= 0.6.7 && < 0.9
                    , directory >= 1.3 && < 1.4
                    , filepath >= 1.4 && < 1.6
                    , tar >= 0.5 && < 0.7
                    , text >= 1.2 && < 3

-- Run EXPLICITLY by target
-- (cabal test siza-client:test:siza-client-test), never `cabal test all`.
test-suite siza-client-test
    import:           warnings
    type:             exitcode-stdio-1.0
    hs-source-dirs:   test
    main-is:          Main.hs
    other-modules:    Test.Fixtures
                      Test.ConsultedStatusSpec
                      Test.FitsBlobSpec
                      Test.AgentCheckSpec
                      Test.ChatExportSpec
                      Test.KernelVocabClientSpec
                      Test.WriteAckClientSpec
                      Test.DiscoverToolClientSpec
                      Test.DiscoverQueryShapeSpec
                      Test.DiscoverFixtures
                      Test.CatalogueSim
                      Test.DiscoverCatalogueSpec
                      Test.CabalFactsSpec
                      Test.DeclaredModulesSpec
                      Test.DiscoverAbsentFactsSpec
                      Test.DiscoverAdviceLegalSpec
                      Test.DiscoverRepoSlugSpec
                      Test.DiscoverInstalledScopeSpec
                      Test.DiscoverScopeReachSpec
                      Test.DiscoverUniverse
                      Test.DiscoverScopeLedgerSpec
                      Test.DiscoverWorldChangeSpec
                      Test.DiscoverConstructSpec
                      Test.RepairTierGenSpec
                      Test.DiscoverTruthSpec
                      Test.DiscoverUnitScrubSpec
                      Test.DiscoverLedgerSpec
                      Test.DiscoverSeedSpec
                      Test.DiscoverEmissionSpec
                      Test.DiscoverEnvelopeSpec
                      Test.DiscoverNextSpec
                      Test.DiscoverHiddenDbSpec
                      Test.ArtifactSpec
                      Test.CompactProtectSpec
                      Test.CompactSpec
                      Test.DiscoverHackageSpec
                      Test.DiscoverHistorySpec
                      Test.DiscoverClosureSpec
                      Test.DiscoverInvariantSpec
                      Test.DiscoverHomonymSpec
                      Test.DiscoverCardMatchSpec
                      Test.DiscoverVariantDedupSpec
                      Test.NormalizeFindabilitySpec
                      Test.ReenterContrastSpec
                      Test.DiscoverMissSpec
                      Test.DiscoverModeGridSpec
                      Test.DiscoverRankPlainSpec
                      Test.DiscoverContextBandSpec
                      Test.DiscoverRecordBudgetSpec
                      Test.DiscoverRequestSpec
                      Test.DiscoverResolvedSpec
                      Test.DiscoverScopeConserveSpec
                      Test.DiscoverAbsentBoundSpec
                      Test.SteerFeedSpec
                      Test.DiscoverGoalSpec
                      Test.DiscoverGoalRankSpec
                      Test.DiscoverGoalRankSpec.Worlds
                      Test.DiscoverEscalateSpec
                      Test.DiscoverProducerHintSpec
                      Test.DiscoverInventorySpec
                      Test.DiscoverDemotionSpec
                      Test.RepairDispatchSpec
                      Test.RepairGuardSpec
                      Test.RepairGridSpec
                      Test.GoalHonestySpec
                      Test.WorldCardSpec
                      Test.RepairCascadeSpec
                      Test.StackFixtures
                      Test.StackSessionSpec
                      Test.McpCallSpec
                      Test.StackNoteDeliverySpec
                      Test.StackParitySpec
                      Test.GoalPlumbingSpec
                      Test.VerifyToolSpec
                      Test.CatalogueHonestySpec
                      Test.RecallSpec
                      Test.RecallSurfaceSpec
                      Test.McpSurfaceSpec
                      Test.VetSilenceSpec
                      Test.HoleDirectedInvariantSpec
                      Test.WorldChangeGateSpec
                      Test.RedStreakSpec
                      Test.CounterexampleSpec
                      Test.VerifyDiagSpec
                      Test.ContextCharsSpec
                      Test.RetroBeat
                      Test.RetroEpisodeGen
                      Test.RetroTranscriptSpec
                      Test.LanguageSpec
                      Test.ProvenanceSpec
                      Test.CrossSeamSpec
                      Test.FutilitySpec
                      Test.TransportFailureSpec
                      Test.TransportSpec
                      Test.HubTokenSpec
                      Test.LoginSpec
                      Test.McpSpec
                      Test.NoteLedgerSpec
                      Test.OutcomeDistillSpec
                      Test.OutcomeShapeSpec
                      Test.PostNudgeGateSpec
                      Test.CardGateSpec
                      Test.FactSelectSpec
                      Test.VerifierSurfaceSpec
                      Test.SteerSpec
                      Test.WrapUpSpec
                      Test.WrapUpLoopSpec
                      Test.WrapUpIntegritySpec
                      Test.ScaffoldChatSpec
                      Test.ToolRouteSpec
                      Test.TrySurfaceSpec
                      Test.SchemaRecoverySpec
                      Test.InstallAffordanceSpec
                      Test.GrammarCardSpec
                      Test.RenderOutcomeSpec
                      Test.RecordFieldUseSpec
                      Test.SystemPromptSpec
                      Test.LeverSurfaceSpec
                      Test.VerdictSurfaceSpec
                      Test.EmitLedgerSpec
                      Test.StateQuerySpec
                      Test.EmitLedgerFixtures
                      Test.EmitLedgerProtectSpec
                      Test.EmitLedgerSummarySpec
                      Test.AdviceSpec
                      Test.CandidateSpec
                      Test.CheckGateSpec
                      Test.DeadlineStartSpec
                      Test.HoleProbeSpec
                      Test.ProbeFixtures
                      Test.CandidateRankSpec
                      Test.RoutedUnblockSpec
                      Test.RenderContractSpec
                      Test.DoneSignalSpec
                      Test.ReEchoFixture
                      Test.ReEchoFixtureSpec
                      Test.TruthGen
                      Test.MarkerEchoSpec
                      Test.CheckScopeSpec
                      Test.VerdictEpisode
                      Test.VerifyToolFixtures
                      Test.VerdictEvidenceSpec
                      Test.VerdictStopSpec
                      Test.VerdictProtectSpec
                      Test.HarnessTruthSpec
                      Test.DiscoverGen
                      Test.LadderFixtures
                      Test.EnvelopeBudgetSpec
                      Test.DiscoverDuplicatePayloadSpec
                      Test.DiscoverUseSpec
                      Test.DiscoverHitFieldSpec
                      Test.DiscoverWorldTruthSpec
                      Test.RefutedReplaySpec
                      Test.RepairBudgetFlagSpec
                      Test.UnconfirmedWriteSpec
    default-language: Haskell2010
    default-extensions: OverloadedStrings
    build-depends:    base >= 4 && < 5
                    , siza-client
                    , sabela:sabela-contract >= 0.1 && < 0.2
                    , hspec >= 2 && < 3
                    , QuickCheck >= 2.14 && < 3
                    , optparse-applicative >= 0.17 && < 0.20
                    , http-client >= 0.7 && < 0.10
                    , aeson >= 2.0 && < 3
                    , bytestring >= 0.10 && < 0.13
                    , text >= 1.2 && < 3
                    , containers >= 0.6.7 && < 0.9
                    , directory >= 1.3 && < 1.4
                    , filepath >= 1.4 && < 1.6
                    , time >= 1.9 && < 2
    -- assert the hub-token file is mode 0600 (POSIX); Windows test is a no-op
    if !os(windows)
        build-depends: unix >= 2.7 && < 2.9
