% \iffalse meta-comment
%
% clawxiv.dtx
% Copyright 2026 Andras Kornai and Claude Sonnet 4.6 (Anthropic)
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, version 1.3c of this license.
% The license text is available at
%   https://www.latex-project.org/lppl/lppl-1-3c/
% and is part of current LaTeX distributions.
%
% This work has the LPPL maintenance status `maintained'.
% The Current Maintainer of this work is Andras Kornai.
%
% This work consists of the files clawxiv.dtx, clawxiv.ins,
% README.md, clawxiv-sty-doc.tex, and the derived file clawxiv.sty.
% The distributed documentation file is clawxiv-sty-doc.pdf.
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{microtype}
\PassOptionsToPackage{hyperindex=false}{hyperref}
\usepackage{clawxiv}
\usepackage{enumitem}
%% \env{name} typesets an environment name in code font.
%% Defined here because it is absent from some ltxdoc versions.
\providecommand{\env}[1]{\texttt{#1}}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{clawxiv.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{60}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v0.4}{2026/03/29}{First CTAN release}
% \changes{v0.4.1}{2026/04/18}{Fix documentation build; remove redundant dependencies; clarify snip marker semantics}
% \changes{v0.4.2}{2026/04/18}{Record release provenance and bounded endorsement for the v0.4.1 repair line; no functional code changes}
% \changes{v0.4.3}{2026/04/19}{CTAN follow-up release: fix duplicated v in the documentation date line; rename distributed documentation to clawxiv-sty-doc; state the LPPL 1.3c license explicitly and consistently across the bundle}
%
% \GetFileInfo{clawxiv.sty}
%
% \DoNotIndex{\newcommand,\renewcommand,\RequirePackage,\NeedsTeXFormat}
% \DoNotIndex{\begin,\end,\def,\gdef,\let,\relax,\noindent,\par}
% \DoNotIndex{\footnotesize,\color,\smallskip,\href,\ifx}
%
%^^A ===================================================================
% \title{The \textsf{clawxiv} package\\
%   \large Provenance typesetting for human--AI collaborative writing}
% \author{Andr\'as Kornai\thanks{%
%     Budapest University of Technology and Economics (BME);
%     ELKH Institute for Computer Science and Control (SZTAKI).
%     ORCID: 0000-0001-6078-6840.
%     \texttt{kornai@math.bme.hu}}
%   \and
%   Claude Sonnet~4.6 (Anthropic)\thanks{%
%     AI co-author.  The package design, color palette, environment
%     signatures, and alias conventions were developed collaboratively
%     between the human and AI authors in early 2026.  The framing of
%     the provenance problem is the human author's; the specific
%     \textsf{mdframed} style parameters and the internal
%     \cs{cxw@attrib} helper are the AI author's.}}
% \date{2026-04-19\quad(\fileversion)}
% \maketitle
%
% \begin{abstract}
% The \textsf{clawxiv} package provides \LaTeX{} environments for
% typesetting text according to its authorial provenance in documents
% that mix human and AI contributions.  Three principal environments
% are provided: \env{seniorquote} for the corresponding human author,
% \env{aiquote} for an AI co-author, and \env{coauthorquote} for
% other human contributors.  Convenient aliases \env{humanprompt} and
% \env{airesp} support prompt/response interaction transcripts.
% The package is part of the ClawXiv framework for archiving
% human--AI co-authored papers with full provenance tracking.
% \end{abstract}
% 
% This \textsf{v0.4.3} source bundle preserves the release provenance for the
% documentation-build repair introduced on 2026-04-18 and incorporates
% the minor CTAN follow-up adjustments requested after acceptance. The package's
% original design authorship remains Andr\'as Kornai and Claude
% Sonnet~4.6 (Anthropic).  The diagnosis and source-level repair of the
% \texttt{clawxiv.dtx} documentation build failure, together with the
% explicit release-provenance metadata added in this bundle and the
% v0.4.3 CTAN follow-up corrections were carried out with AI assistance
% by \emph{ChatGPT GPT-5.4 Thinking}.  Human maintainer and releasing author:
% Andr\'as Kornai.  See
% Section~\ref{sec:release-provenance}.
%
% \tableofcontents
%
%^^A ===================================================================
% \section{Introduction}
%
% Collaborative writing between humans and AI systems raises a
% question that \LaTeX{} has not previously needed to answer: whose
% words are these?  Citation and quotation mechanisms handle text
% from external sources, but they presuppose a clean boundary between
% the document's authors and everyone else.  When an AI system is a
% genuine co-author---contributing analysis, drafting arguments,
% proposing structure---that boundary dissolves.
%
% The \textsf{clawxiv} package takes a simple, typographic approach.
% Each passage of text is attributed to its author at paragraph
% level, using visually distinct left-ruled boxes.  The senior human
% author's voice appears in a steel-blue box; AI contributions in
% amber/ochre; other human co-authors in grey.  Attribution lines
% carry a name, a timestamp, and an optional hyperlink to the
% original session, making provenance claims verifiable rather than
% merely asserted.
%
% This documentation is itself an example.  The following passage
% was contributed by the AI co-author of this package:
%
% \begin{aiquote}{Claude Sonnet~4.6}{2026-03-29}[https://claude.ai]
% The design goal was to make provenance \emph{visible without being
% obtrusive}.  The left-rule style was chosen over a full box because
% it signals a shift in voice without visually interrupting the flow
% of reading.  The color palette is intentionally muted: steel blue,
% ochre, and grey rather than primary colors.  A reader scanning the
% page should notice that something changed; they should not feel
% assaulted by it.
% \end{aiquote}
%
% And this framing is the human author's:
%
% \begin{seniorquote}{Andr\'as Kornai}{2026-03-29}
% The deeper motivation is archival.  A document that records not
% only \emph{what} was written but \emph{who} wrote each part, and
% \emph{when}, and from \emph{which session}, is a more honest
% artifact than one that launders AI contributions into the
% undifferentiated authorial voice.  The ClawXiv framework exists
% because honesty about provenance should have better tooling.
% \end{seniorquote}
%
%^^A ===================================================================
% \section{Usage}
%
% \subsection{Loading the package}
%
% \begin{verbatim}
% \usepackage{clawxiv}
% \end{verbatim}
%
% The package loads \textsf{mdframed}, \textsf{xcolor},
% \textsf{hyperref}, and \textsf{xparse}. If \textsf{hyperref}
% is loaded before \textsf{clawxiv}, the previously set options are
% respected.
%
% \subsection{Principal environments}
%
% \DescribeEnv{seniorquote}
% \begin{quote}
% \verb|\begin{seniorquote}|\marg{author}\marg{timestamp}\oarg{url}\\
% \meta{text}\\
% \verb|\end{seniorquote}|
% \end{quote}
% Typesets \meta{text} in a pale-blue left-ruled box attributed to
% the senior (corresponding) human author.  \meta{author} is a name
% string; \meta{timestamp} is a date string (no special format is
% enforced); \meta{url} is an optional hyperlink for the attribution
% line.
%
% \DescribeEnv{aiquote}
% \begin{quote}
% \verb|\begin{aiquote}|\marg{author}\marg{timestamp}\oarg{url}\\
% \meta{text}\\
% \verb|\end{aiquote}|
% \end{quote}
% Typesets \meta{text} in a pale-amber left-ruled box attributed to
% an AI co-author.  The \meta{url} argument, when supplied, should
% point to the original AI session transcript so that provenance is
% independently verifiable.
%
% \DescribeEnv{coauthorquote}
% \begin{quote}
% \verb|\begin{coauthorquote}|\marg{author}\marg{timestamp}\oarg{url}\\
% \meta{text}\\
% \verb|\end{coauthorquote}|
% \end{quote}
% Typesets \meta{text} in a grey left-ruled box for contributions
% from human co-authors other than the senior author.
%
% \subsection{Interaction-style aliases}
%
% \DescribeEnv{humanprompt}
% \begin{quote}
% \verb|\begin{humanprompt}|\oarg{author}\oarg{timestamp}\\
% \meta{text}\\
% \verb|\end{humanprompt}|
% \end{quote}
% An alias for \env{seniorquote} intended for prompt/response
% transcripts.  Both arguments are optional; \meta{author} defaults
% to \texttt{Senior Author} (a placeholder---supply your own name)
% and \meta{timestamp} defaults to \cs{today}.
%
% \DescribeEnv{airesp}
% \begin{quote}
% \verb|\begin{airesp}|\marg{author}\oarg{timestamp}\oarg{url}\\
% \meta{text}\\
% \verb|\end{airesp}|
% \end{quote}
% An alias for \env{aiquote}.  \meta{author} is mandatory;
% \meta{timestamp} defaults to \cs{today}; \meta{url} is optional.
%
% \subsection{Snip markers}
%
% \DescribeMacro{\snipinsert}
% \cs{snipinsert} is a no-op at typeset time. Its literal occurrence
% in the source serves as a marker for the \texttt{clawxiv-snip}
% command-line tool; the macro itself intentionally expands to nothing.
%
% \DescribeMacro{\inputsnip}
% \cs{inputsnip}\marg{filename} expands to
% \cs{input}\texttt{\{snips/}\meta{filename}\texttt{\}},
% assuming snip files are staged in a \texttt{snips/} subdirectory.
%
% \subsection{License}
% The package is distributed under the \emph{LaTeX Project Public License}
% \texttt{lppl1.3c}. In LPPL terminology, this work is \emph{maintained};
% the Current Maintainer is Andr\'as Kornai. The license is stated
% explicitly in the README, in this documented source, in the installer,
% and in the generated package file so that the CTAN metadata and the
% shipped files agree.
%
%^^A ===================================================================
% \section{Color palette}
%
% All colors are defined internally with \texttt{@}-guarded names
% and are not intended for direct use in documents.
%
% \begin{center}
% \begin{tabular}{lll}
% \hline
% Internal name & RGB & Role \\
% \hline
% \texttt{cxw@SeniorBg}     & 245,\,248,\,252 & senior box fill \\
% \texttt{cxw@SeniorRule}   & 100,\,140,\,190 & senior left rule \\
% \texttt{cxw@AIBg}         & 250,\,248,\,240 & AI box fill \\
% \texttt{cxw@AIRule}       & 190,\,150,\,80  & AI left rule (ochre) \\
% \texttt{cxw@CoAuthorBg}   & 248,\,248,\,248 & co-author fill \\
% \texttt{cxw@CoAuthorRule} & 160,\,160,\,160 & co-author left rule \\
% \texttt{cxw@LinkColor}    & 40,\,80,\,160   & attribution links \\
% \hline
% \end{tabular}
% \end{center}
%
% Future versions may expose a user-facing configuration interface.
%
%^^A ===================================================================
% \section{The ClawXiv framework}
%
% This package is the \LaTeX{} component of the ClawXiv framework,
% a workflow for archiving human--AI co-authored papers with
% cryptographic provenance tracking.  The full framework includes:
%
% \begin{itemize}[leftmargin=2em]
% \item A command-line tool (\texttt{clawxiv}) with subcommands for
%   initializing bundles (\texttt{init}), capturing text snippets
%   with provenance metadata (\texttt{snip}), integrating captures
%   into source (\texttt{integrate-snips}), and adding figures with
%   attribution (\texttt{fig-add}, \texttt{fig-capture}).
% \item A \texttt{project.yaml} schema recording bundle-level
%   metadata: author identifiers (ORCID, VIAF, ISNI), timestamps,
%   version history, and co-author AI model identifiers.
% \item A \texttt{Makefile} and \texttt{configure} script for
%   reproducible builds.
% \end{itemize}
%
% The \LaTeX{} package documented here can be used independently
% of the command-line tooling.  Load \textsf{clawxiv} and use the
% environments manually; no other part of the framework is required.
%
% The ClawXiv v4 white paper is available on arXiv.
%
%^^A ===================================================================
% \section{Release provenance}\label{sec:release-provenance}
%
% Release \textsf{v0.4.3} is intentionally conservative.  It does not
% change the package interface or runtime behavior relative to the
% repaired \textsf{v0.4.1} line.  Instead, it makes the provenance of
% that repair explicit inside the distributed bundle.
%
% The package's durable authorship and maintenance roles remain human-led:
% Andr\'as Kornai is the Current Maintainer and releasing author, and the
% package's original design authorship remains shared between Andr\'as
% Kornai and Claude Sonnet~4.6 (Anthropic).  The specific 2026-04-18
% repair sequence---reproducing the \texttt{pdflatex clawxiv.dtx} failure,
% diagnosing the malformed \texttt{macrocode} terminators in the
% \texttt{.dtx} source, patching the source, verifying the successful
% rebuild, and adding the present release metadata---was carried out with
% AI assistance by \emph{ChatGPT GPT-5.4 Thinking}.
%
% The endorsement conveyed by this bundle is textual rather than
% cryptographic.  It should be interpreted narrowly: the AI contributor
% endorses the repaired source bundle to the extent actually tested in its
% build environment, while the human maintainer stands behind the package
% release over the longer archival horizon.
%
% Machine-readable release metadata are supplied in
% \texttt{release\_provenance.json} and \texttt{manifest.v0.4.3.json}.
%
%^^A ===================================================================
% \StopEventually{}
%
%^^A ===================================================================
% \section{Implementation}
%
% \subsection{Identification and dependencies}
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{clawxiv}[2026/04/19 v0.4.3 ClawXiv provenance macros (LPPL 1.3c)]
% Released under the LaTeX Project Public License \texttt{lppl1.3c}.
% Current Maintainer: Andr\'as Kornai.

\RequirePackage{mdframed}
\RequirePackage{xcolor}
\RequirePackage{hyperref}
\RequirePackage{xparse}
%    \end{macrocode}
%
% \subsection{Color palette}
%
%    \begin{macrocode}
\definecolor{cxw@SeniorBg}    {RGB}{245,248,252}
\definecolor{cxw@SeniorRule}  {RGB}{100,140,190}
\definecolor{cxw@AIBg}        {RGB}{250,248,240}
\definecolor{cxw@AIRule}      {RGB}{190,150,80}
\definecolor{cxw@CoAuthorBg}  {RGB}{248,248,248}
\definecolor{cxw@CoAuthorRule}{RGB}{160,160,160}
\definecolor{cxw@LinkColor}   {RGB}{40,80,160}
%    \end{macrocode}
%
% \subsection{Frame styles}
%
%    \begin{macrocode}
\mdfdefinestyle{cxw@senior}{
  backgroundcolor   = cxw@SeniorBg,
  linecolor         = cxw@SeniorRule,
  linewidth         = 1.2pt,
  leftline          = true,
  rightline         = false,
  topline           = false,
  bottomline        = false,
  innerleftmargin   = 6pt,
  innerrightmargin  = 4pt,
  innertopmargin    = 3pt,
  innerbottommargin = 3pt,
  skipabove         = 4pt,
  skipbelow         = 4pt,
}
\mdfdefinestyle{cxw@ai}{
  backgroundcolor   = cxw@AIBg,
  linecolor         = cxw@AIRule,
  linewidth         = 0.8pt,
  leftline          = true,
  rightline         = false,
  topline           = false,
  bottomline        = false,
  innerleftmargin   = 6pt,
  innerrightmargin  = 4pt,
  innertopmargin    = 3pt,
  innerbottommargin = 3pt,
  skipabove         = 4pt,
  skipbelow         = 4pt,
}
\mdfdefinestyle{cxw@coauthor}{
  backgroundcolor   = cxw@CoAuthorBg,
  linecolor         = cxw@CoAuthorRule,
  linewidth         = 0.6pt,
  leftline          = true,
  rightline         = false,
  topline           = false,
  bottomline        = false,
  innerleftmargin   = 6pt,
  innerrightmargin  = 4pt,
  innertopmargin    = 3pt,
  innerbottommargin = 3pt,
  skipabove         = 4pt,
  skipbelow         = 4pt,
}
%    \end{macrocode}
%
% \subsection{Internal attribution helper}
%
% \begin{macro}{\cxw@attrib}
% Prints the attribution line at the top of every provenance box.
% |#1|~author name, |#2|~timestamp, |#3|~URL (empty disables link).
%    \begin{macrocode}
\newcommand{\cxw@attrib}[3]{%
  \noindent
  {\footnotesize\color{cxw@LinkColor}%
    \ifx\relax#3\relax
      [\textit{#1},\ #2]%
    \else
      \href{#3}{[\textit{#1},\ #2]}%
    \fi
  }\par\smallskip
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Principal environments}
%
% \begin{environment}{seniorquote}
%    \begin{macrocode}
\NewDocumentEnvironment{seniorquote}{m m O{}}{%
  \begin{mdframed}[style=cxw@senior]%
  \cxw@attrib{#1}{#2}{#3}%
}{%
  \end{mdframed}%
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{aiquote}
%    \begin{macrocode}
\NewDocumentEnvironment{aiquote}{m m O{}}{%
  \begin{mdframed}[style=cxw@ai]%
  \cxw@attrib{#1}{#2}{#3}%
}{%
  \end{mdframed}%
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{coauthorquote}
%    \begin{macrocode}
\NewDocumentEnvironment{coauthorquote}{m m O{}}{%
  \begin{mdframed}[style=cxw@coauthor]%
  \cxw@attrib{#1}{#2}{#3}%
}{%
  \end{mdframed}%
}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Interaction-style aliases}
%
% \begin{environment}{humanprompt}
% The default author \texttt{Senior Author} is a placeholder;
% users should supply their own name as the optional argument.
%    \begin{macrocode}
\NewDocumentEnvironment{humanprompt}{O{Senior Author} O{\today}}{%
  \begin{seniorquote}{#1}{#2}%
}{%
  \end{seniorquote}%
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{airesp}
%    \begin{macrocode}
\NewDocumentEnvironment{airesp}{m O{\today} O{}}{%
  \begin{aiquote}{#1}{#2}[#3]%
}{%
  \end{aiquote}%
}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Snip markers}
%
% \begin{macro}{\snipinsert}
%    \begin{macrocode}
\newcommand{\snipinsert}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\inputsnip}
%    \begin{macrocode}
\newcommand{\inputsnip}[1]{%
  \input{snips/#1}%
}
%    \end{macrocode}
% \end{macro}
%
%</package>
%
% \Finale
\endinput
