FROM public.ecr.aws/x8v8d7g8/mars-base:latest

WORKDIR /app

# Git time-travel: clone, then make the repo's default branch point AT the base
# commit with no future history — a real branch checkout (not a detached HEAD),
# future commits/tags gc'd away so the reference solution can't leak from history.
ARG BASE_SHA=73f5b537c8cad998e8e6d6bc40ad60e2e23bf268
RUN git clone https://github.com/jkwill87/mnamer . \
 && DEFAULT="$(git remote show origin | sed -n 's/.*HEAD branch: //p')" \
 && git checkout -B "$DEFAULT" "$BASE_SHA" \
 && git remote remove origin \
 && for b in $(git for-each-ref --format='%(refname:short)' refs/heads | grep -vx "$DEFAULT"); do git branch -D "$b" || true; done \
 && for t in $(git tag); do git merge-base --is-ancestor "$t" HEAD 2>/dev/null || git tag -d "$t"; done \
 && git reflog expire --expire=now --all \
 && git gc --prune=now \
 && (git submodule update --init --recursive || true)

RUN python -m pip install \
      "appdirs>=1.4.4" \
      "babelfish>=0.6.0" \
      "guessit>=3.8.0" \
      "requests>=2.32.0" \
      "requests-cache~=0.9.8" \
      "setuptools-scm>=8.0.0" \
      "teletype>=1.3.4" \
      "typing-extensions>=4.7.0" \
      "pytest>=8.4.1" \
      "pytest-cov>=6.2.1" \
      "pytest-rerunfailures>=15.1" && \
    python -c "from pathlib import Path; Path('mnamer/__version__.py').write_text('__version__ = \"0.0.0\"\\n')"

# v1.1 node-id scoring: pytest emits JUnit XML natively via --junitxml; no extra
# reporter package needed.

# Disable git commit hooks (husky etc.): dev-workflow tooling, not task content.
# Broken hook environments otherwise block the agent's (and oracle's) commits.
RUN cd /app && git config core.hooksPath /dev/null

CMD ["/bin/bash"]
