<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>dev.tnsai</groupId>
        <artifactId>tnsai-parent</artifactId>
        <version>0.18.6</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>tnsai-core</artifactId>
    <packaging>jar</packaging>

    <name>TnsAI Core</name>
    <description>Core framework — agent lifecycle, action routing, tool registry, capabilities, streaming.</description>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!-- JSON -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jdk8</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
        </dependency>

        <!-- HTTP -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp-jvm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
        </dependency>

        <!-- Resilience -->
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-circuitbreaker</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-bulkhead</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-ratelimiter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-jexl3</artifactId>
        </dependency>

        <!--
          Logging — slf4j-api on the public classpath; the binding is the
          consumer's choice (logback / log4j2 / nothing). Tests use logback
          via test scope (see below).
        -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <!-- Utilities -->
        <dependency>
            <groupId>io.github.cdimascio</groupId>
            <artifactId>dotenv-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.samskivert</groupId>
            <artifactId>jmustache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
        </dependency>

        <!-- Jedis (optional, for RedisIdempotencyStore) -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- SQLite JDBC (optional, for SqliteCheckpointStore) -->
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- AWS S3 SDK (optional, for S3CheckpointStore) -->
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver3</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.tngtech.archunit</groupId>
            <artifactId>archunit-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Test-scope logging binding so the test suite logs nicely; not on the consumer's compile classpath. -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
              Issue #9 coverage gate.

              Pins the five classes brought from 0% to >=95% coverage by
              issue #9 (phases 1-5, PRs #226/#227/#229/#230/#231) at a
              minimum of 80% line coverage. The gate fires during the
              standard `mvn verify` (jacoco's prepare-agent + report run
              in the parent's default build, see ../pom.xml).

              Threshold is set well below the actual ~95-100% so trivial
              refactors don't trip it, but a deleted test class would
              drop coverage past the floor and fail CI — which is the
              acceptance criterion for #9.

              Adding to the protected set: append the FQCN (with `$`
              for nested types) to the includes list below. Removing:
              don't — the whole point is that these classes stay covered.
            -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>issue-9-coverage-gate</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>CLASS</element>
                                    <includes>
                                        <include>com.tnsai.parser.FormatAwareOutputParser</include>
                                        <include>com.tnsai.parser.FormatAwareOutputParser$Builder</include>
                                        <include>com.tnsai.spi.CompositeResilienceStrategy</include>
                                        <include>com.tnsai.spi.ComposedResilienceStrategy</include>
                                        <include>com.tnsai.spi.InMemoryMessageBroker</include>
                                        <include>com.tnsai.spi.MessageBroker$Message</include>
                                        <include>com.tnsai.context.snapshot.ContextSnapshot</include>
                                        <include>com.tnsai.context.snapshot.ContextSnapshot$Builder</include>
                                        <include>com.tnsai.coordination.groups.GroupTask</include>
                                        <include>com.tnsai.coordination.groups.GroupTask$Builder</include>
                                        <include>com.tnsai.coordination.groups.GroupTask$Status</include>
                                        <include>com.tnsai.coordination.groups.GroupTask$Priority</include>
                                    </includes>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!--
            Mutation-testing pilot (issue #3).

            Activate explicitly with `-Pmutation-testing` — too slow for the
            normal verify cycle. Targets two recently-shipped self-contained
            packages whose tests are fresh enough to be representative of
            current standards (ToolPolicy + CancellationToken). Expand the
            targetClasses list as confidence grows.

            Run:
              mvn -pl tnsai-core -Pmutation-testing test \
                  org.pitest:pitest-maven:mutationCoverage

            Report opens at tnsai-core/target/pit-reports/index.html.
            See agent_docs/mutation-testing.md for the workflow.
        -->
        <profile>
            <id>mutation-testing</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-maven</artifactId>
                        <version>1.30.1</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.pitest</groupId>
                                <artifactId>pitest-junit5-plugin</artifactId>
                                <version>1.2.3</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <targetClasses>
                                <param>com.tnsai.tools.policy.*</param>
                                <param>com.tnsai.cancellation.*</param>
                            </targetClasses>
                            <targetTests>
                                <param>com.tnsai.tools.policy.*Test</param>
                                <param>com.tnsai.cancellation.*Test</param>
                                <param>com.tnsai.hooks.policy.*Test</param>
                            </targetTests>
                            <outputFormats>
                                <param>HTML</param>
                                <param>XML</param>
                            </outputFormats>
                            <timestampedReports>false</timestampedReports>
                            <!-- Mutators: DEFAULTS gives a balanced set without
                                 noise from STRONGER. Re-evaluate when graduating
                                 from pilot to nightly CI. -->
                            <mutators>
                                <mutator>DEFAULTS</mutator>
                            </mutators>
                            <!-- Pilot threshold; tighten as tests improve. -->
                            <mutationThreshold>50</mutationThreshold>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
