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

ENV NODE_ENV=development

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=d141eb14a40b79c04d1b1db5c20c6afa3844c0d9
RUN git clone https://github.com/meriyah/meriyah . \
 && 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 npm install --ignore-scripts

# v1.1 node-id scoring (CTRF route): vitest's built-in JUnit reporter is used at
# verify time (`--reporter=junit --outputFile=...`) and converted to CTRF JSON by
# the OFFICIAL ctrf-io converter junit-to-ctrf, pinned. npm -g installs to
# /usr/lib/node_modules (mars-base system node v24, npm prefix /usr), so /app's
# package.json + pnpm/npm manifests stay untouched. The `--version` smoke check
# fails the build loudly if the node engine requirement (>=20) is not met.
RUN npm install -g junit-to-ctrf@0.0.14 && junit-to-ctrf --version

# 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"]
