Compare commits
192 Commits
python-fin
...
v2.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| ccdecaf182 | |||
| 50374de5b5 | |||
| 7a29f4a776 | |||
| 7b150eb9cc | |||
| 88470b7b97 | |||
| edbbf3d5ea | |||
| 9723102117 | |||
| f36cb58781 | |||
| 91d9be68a7 | |||
| 5150b5c636 | |||
| 422a688741 | |||
| 982b595cb0 | |||
| f9bf2c9c2c | |||
| 4cf1b6fbca | |||
| 07a4b65570 | |||
| 5feec1bf14 | |||
| 011b021d47 | |||
| 325c4ea7d3 | |||
| 3eb73e70fc | |||
| b8089f4a50 | |||
| 22f0932389 | |||
| d726ea8f6d | |||
| 7199cb565f | |||
| 60e2fe74b5 | |||
| d2a6fcfd41 | |||
| 5e2e863fbd | |||
| 24b899281c | |||
| 2a58db04c2 | |||
| 93f62c9095 | |||
| 640f663ace | |||
| 31979d4081 | |||
| f219309617 | |||
| a83a51848b | |||
| 0b6cd98262 | |||
| efaefdbf3d | |||
| ec78b5a5db | |||
| 9fc4de22b7 | |||
| 6523d7ac74 | |||
| a770c77a23 | |||
| 2f036b0356 | |||
| 87b8d9ad5c | |||
| a80eed4745 | |||
| 989b28e8c5 | |||
| 61af29ecb8 | |||
| 63fcfc487d | |||
| b98604e5ca | |||
| bb21a81805 | |||
| 0a19f163c6 | |||
| 42bde59827 | |||
| 51169ff9e9 | |||
| 7dc1be5a08 | |||
| 8ffbf41b89 | |||
| cb405f6fc7 | |||
| 053b714ce6 | |||
| aa2f486845 | |||
| 665ee85215 | |||
| c42bc01052 | |||
| 7cefb3fb04 | |||
| 80804a038f | |||
| 9561e80efb | |||
| 4bfc5f3456 | |||
| 4812032c9e | |||
| a4a72168d5 | |||
| f577847ca2 | |||
| c8a78bf024 | |||
| 96d3d03bee | |||
| f8c18247a0 | |||
| 51e370b4c8 | |||
| 9fb89057ce | |||
| 1ad2119283 | |||
| 116648fa78 | |||
| 5b7d2e6e81 | |||
| 590604bf38 | |||
| 7b809878d6 | |||
| 228ac4e26d | |||
| 2d8b441802 | |||
| 2c55bf5f1e | |||
| c97a6fa70a | |||
| 187dc4cb1c | |||
| 228087dec8 | |||
| f70bb27636 | |||
| a379cc915e | |||
| 837efc78a7 | |||
| 6b33254a82 | |||
| e8bc005040 | |||
| c5627460d0 | |||
| 3c68ec9d05 | |||
| e8b8fbd509 | |||
| 588ca36dfc | |||
| 018d08fd4c | |||
| 3a0a0b3940 | |||
| 99ab2f181b | |||
| 4e4801dc98 | |||
| 900ad74958 | |||
| 28d5201a69 | |||
| e5944f9875 | |||
| 6344fc91ba | |||
| 7f3a91cc9e | |||
| 72fb021453 | |||
| 40e8b54d3b | |||
| 76651333b1 | |||
| 0b01c3a83d | |||
| 0630d36734 | |||
| 52c2697040 | |||
| f790c1441c | |||
| 56f9b28f4b | |||
| 222222f449 | |||
| 99391cd18b | |||
| 84be774b34 | |||
| e053f7e124 | |||
| 13029dbb33 | |||
| 938bfe88c1 | |||
| fa1bd237d1 | |||
| 3d7057b437 | |||
| 32c8c8b446 | |||
| a3655f5540 | |||
| a84941d681 | |||
| 46b7356a3b | |||
| 39208cd119 | |||
| 6dae15656d | |||
| b103bb2e7d | |||
| 2b2a3fc024 | |||
| 52ffe42e73 | |||
| 3b160cf05b | |||
| 0687982822 | |||
| ff4ed82239 | |||
| 037121e9ce | |||
| d6126bf52b | |||
| 1bc5936681 | |||
| 9a77a0cd0b | |||
| ebbd2c8a63 | |||
| de99467ede | |||
| 20f612215f | |||
| 3d45571bb0 | |||
| 1afd753fad | |||
| a85a7e204e | |||
| 509436cc4a | |||
| a48f6da1f4 | |||
| df96f9fdf6 | |||
| 390daa8b84 | |||
| af84249da0 | |||
| cad172a758 | |||
| fb59cb21b9 | |||
| 68e2d9b549 | |||
| 185f7ca2b6 | |||
| 7ccadc6bd6 | |||
| a9f7fa27ff | |||
| dbf3605712 | |||
| 543a7ff8ef | |||
| fc3a7b7a67 | |||
| b360493cdc | |||
| 12202508bf | |||
| 6d9a4bd017 | |||
| 426864eedb | |||
| 0b17a6fbeb | |||
| aeb31f1c0d | |||
| 28fe899aa1 | |||
| 30606f5c49 | |||
| db880ed868 | |||
| 5217093be2 | |||
| 0e83991537 | |||
| 3e8d19cccd | |||
| c1193e3450 | |||
| 73249b63d8 | |||
| c3087aeda6 | |||
| 0452a605ad | |||
| b9b7384123 | |||
| 726acc47e1 | |||
| 5c78b1d5d9 | |||
| f461922b9b | |||
| c58d307ba7 | |||
| 1eb93481e0 | |||
| b997e7c97c | |||
| 12fd541669 | |||
| 10377876e4 | |||
| d847168ecd | |||
| 14e51698c2 | |||
| aeb9c4f062 | |||
| e2ae7f77d8 | |||
| 0b1b670baf | |||
| 3cfa4b6e8a | |||
| 950edc01f2 | |||
| ea8def423e | |||
| 95fe8c32fa | |||
| 08b7531149 | |||
| 2cf2d390da | |||
| 8f3c2ec5fd | |||
| 9427c4e6cc | |||
| 6424d7db4f | |||
| 87e560dd3d | |||
| 09fc6fd364 | |||
| 2e47c8a1b6 |
60
.gitignore
vendored
60
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
# --> Python
|
||||
.DS_Store
|
||||
.venv/
|
||||
__pycache__/
|
||||
@@ -9,3 +10,62 @@ dist/
|
||||
build/
|
||||
*.egg-info/
|
||||
|
||||
# ---> Codex
|
||||
.codex
|
||||
|
||||
# ---> Go
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# env file
|
||||
.env
|
||||
|
||||
# Compiled binaries and test configuration
|
||||
narratio
|
||||
local-test
|
||||
pipeline.yml
|
||||
bin/
|
||||
|
||||
# Local run artifacts
|
||||
.audita-runs/
|
||||
report.json
|
||||
corrected.json
|
||||
normalized.json
|
||||
|
||||
# Coverage artifacts
|
||||
coverage.out
|
||||
coverage.txt
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
26
.woodpecker/release.yml
Normal file
26
.woodpecker/release.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
when:
|
||||
- event: tag
|
||||
|
||||
steps:
|
||||
- name: build-release-assets
|
||||
image: golang:1.25.5
|
||||
commands:
|
||||
- bash scripts/build-release.sh "$CI_COMMIT_TAG" dist
|
||||
|
||||
- name: publish-release
|
||||
image: woodpeckerci/plugin-release
|
||||
depends_on:
|
||||
- build-release-assets
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: GITEA_RELEASE_TOKEN
|
||||
files:
|
||||
- dist/audita-*-linux-amd64
|
||||
- dist/audita-*-linux-arm64
|
||||
note: docs/releases/${CI_COMMIT_TAG}.md
|
||||
checksum: sha256
|
||||
checksum-file: SHA256SUMS
|
||||
checksum-flatten: true
|
||||
file-exists: skip
|
||||
overwrite: false
|
||||
prerelease: false
|
||||
6
AGENTS.md
Normal file
6
AGENTS.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Start with `docs/development.md` for orientation and use its policy reading guide
|
||||
to select the policies applicable to the task. Do not read the entire suite by
|
||||
default.
|
||||
|
||||
Read and follow `docs/policy/agents.md` before recommending, planning, or
|
||||
implementing repository changes.
|
||||
23
COPYRIGHT
Normal file
23
COPYRIGHT
Normal file
@@ -0,0 +1,23 @@
|
||||
Audita
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
Audita is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU General Public License version 3 is provided in LICENSE.
|
||||
|
||||
Audita is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
Third-party code and assets are subject to their respective license terms.
|
||||
|
||||
Policy documents and guidance adapted from Standard Repository Policies
|
||||
remain licensed under CC-BY-SA-4.0. See docs/oss/attribution.md for the
|
||||
affected material, upstream credit, and license links.
|
||||
675
LICENSE
675
LICENSE
@@ -1,11 +1,674 @@
|
||||
Copyright (c) 2026 eric.
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Preamble
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
168
README.md
168
README.md
@@ -1,148 +1,62 @@
|
||||
# Audita
|
||||
|
||||
Audita is a framework-first transcript correction application. The public `audita` package provides:
|
||||
Audita polishes transcript JSON using glossary-aware and LLM-backed correction
|
||||
modules. It validates proposed corrections and produces corrected text plus
|
||||
reports for review and subprocess integration.
|
||||
|
||||
- deterministic transcript normalization
|
||||
- token-batched module orchestration
|
||||
- concrete `glossary`, `homophones`, `spoken_word`, and `grammar` modules built on reusable proposal / validator contracts
|
||||
- structured run reporting and work-dir diagnostics
|
||||
## Quickstart
|
||||
|
||||
The previous working implementation has been preserved as `audita_prototype` inside this repository. Its full regression suite lives under `tests/audita_prototype`.
|
||||
|
||||
## Development
|
||||
|
||||
This project is set up for `uv`.
|
||||
From a checkout, build with Go 1.25.5 or newer:
|
||||
|
||||
```sh
|
||||
uv sync --extra dev
|
||||
uv run pytest
|
||||
go build -o ./bin/audita ./cmd/audita
|
||||
```
|
||||
|
||||
## Usage
|
||||
Processing requires a reachable [compatible LLM endpoint](docs/integrations/openai-compatible-llm.md)
|
||||
and access to a model you select. The [minimal config](examples/minimal-config.yml)
|
||||
targets an unauthenticated local endpoint; edit its endpoint and
|
||||
[local profiles](examples/profiles/) to match your service and models. The
|
||||
[service example](examples/production-config.yml) demonstrates a named credential
|
||||
reference and a shared backend. Set its referenced environment variable before
|
||||
validating it. The [testing overlay](examples/overlays/testing.yml) selects both
|
||||
role profiles, but model cost, speed, and quality depend on your provider choices.
|
||||
|
||||
Process a transcript with the current framework implementation:
|
||||
Check configuration and profile selection offline:
|
||||
|
||||
```sh
|
||||
uv run audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
./bin/audita config validate --config examples/minimal-config.yml
|
||||
./bin/audita config print-effective --config examples/minimal-config.yml --view profiles
|
||||
```
|
||||
|
||||
The framework currently runs this default module sequence:
|
||||
|
||||
1. `glossary`
|
||||
2. `homophones`
|
||||
3. `glossary`
|
||||
4. `spoken_word`
|
||||
5. `grammar`
|
||||
|
||||
Resolved run instance names are auto-numbered for repeats, so the default report pipeline is:
|
||||
|
||||
1. `glossary_1`
|
||||
2. `homophones`
|
||||
3. `glossary_2`
|
||||
4. `spoken_word`
|
||||
5. `grammar`
|
||||
|
||||
The default module sequence is fully implemented today:
|
||||
|
||||
- `glossary` proposes glossary-supported acoustic corrections
|
||||
- `homophones` proposes conservative homophone and mistranscription corrections
|
||||
- `spoken_word` proposes conservative dysfluency cleanup
|
||||
- `grammar` proposes punctuation, capitalization, and spacing cleanup only
|
||||
|
||||
To run a custom module sequence, pass `--modules`:
|
||||
Run the included small input with the minimal config:
|
||||
|
||||
```sh
|
||||
uv run audita process transcript.json --glossary glossary.yaml --modules grammar --output corrected.json
|
||||
./bin/audita process examples/tiny-transcript.json \
|
||||
--config examples/minimal-config.yml \
|
||||
--glossary examples/tiny-glossary.yaml \
|
||||
--output corrected.json
|
||||
```
|
||||
|
||||
To also write a structured JSON report:
|
||||
This makes LLM requests. Explicit setting flags override the selected file and
|
||||
optional overlay; general environment setting overrides are no longer read.
|
||||
By default the command writes `errors.yml`, `recoveries.yml`, and `report.md`
|
||||
beside `corrected.json`. Use `--reporting=false` to suppress those files, or
|
||||
`--debug` to retain detailed run artifacts under the configured debug work
|
||||
directory. Model failures affecting some operations can still yield a completed
|
||||
transcript with applied corrections; the summary and reports identify them.
|
||||
See the [v2 migration guide](docs/migrations/v2.md) for old configurations.
|
||||
|
||||
```sh
|
||||
uv run audita process transcript.json --glossary glossary.yaml --output corrected.json --report-json report.json
|
||||
```
|
||||
## Documentation
|
||||
|
||||
From a checked-out repository, you can also use the root launcher:
|
||||
- [CLI reference](docs/cli.md)
|
||||
- [Configuration and maintained examples](docs/config.md)
|
||||
- [Operations and artifact lifecycle](docs/operations.md)
|
||||
- [Transcript and glossary inputs](docs/integrations/transcript-glossary-files.md)
|
||||
- [Output files and report formats](docs/integrations/output-files.md)
|
||||
- [Subprocess integration](docs/integrations/subprocess.md)
|
||||
- [LLM endpoint contract](docs/integrations/openai-compatible-llm.md)
|
||||
- [Contributor guide](docs/development.md)
|
||||
|
||||
```sh
|
||||
./audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
```
|
||||
Audita is licensed under the [GPL v3.0 or later](COPYRIGHT).
|
||||
|
||||
For a system-wide command, install the source tree under `/usr/local/src/audita`, sync dependencies there, and symlink the root launcher into your `PATH`:
|
||||
|
||||
```sh
|
||||
cd /usr/local/src/audita
|
||||
uv sync --extra dev
|
||||
ln -s /usr/local/src/audita/audita /usr/local/bin/audita
|
||||
audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
```
|
||||
|
||||
Without `--output`, Audita writes the corrected transcript JSON to stdout and progress logs to stderr.
|
||||
`--report-json` writes a separate machine-readable run report and never mixes report data into stdout.
|
||||
|
||||
Useful configuration can be supplied by CLI flag or environment variable. CLI flags take precedence over environment variables. Default OpenRouter runs require LLM API credentials, because the `glossary`, `homophones`, `spoken_word`, and `grammar` modules make real LLM calls. Self-hosted or other non-default OpenAI-compatible endpoints may not require credentials. `AUDITA_LLM_API_KEY` and `--llm-api-key` are the preferred provider-neutral credential surfaces, while `OPENROUTER_API_KEY` remains supported as a backward-compatible fallback.
|
||||
|
||||
| Environment variable | CLI flag | Default | Purpose |
|
||||
| --- | --- | --- | --- |
|
||||
| `AUDITA_MODULES` | `--modules` | `glossary,homophones,glossary,spoken_word,grammar` | Comma-separated logical module keys to run; CLI overrides the environment value |
|
||||
| `AUDITA_LLM_API_KEY` | `--llm-api-key` | unset | Preferred provider-neutral LLM API credential; required for the default OpenRouter endpoint and optional for non-default endpoints; CLI overrides both environment-key variants |
|
||||
| `AUDITA_VALIDATION_LLM_API_KEY` | `--validation-llm-api-key` | unset | Validation-phase LLM API credential; defaults to the primary LLM API key and is optional for non-default validation endpoints |
|
||||
| `AUDITA_MODEL` | `--model` | `openrouter/google/gemma-4-31b-it` | LLM model name sent to the configured OpenAI-compatible endpoint |
|
||||
| `AUDITA_VALIDATION_MODEL` | `--validation-model` | unset | Validation-phase LLM model; defaults to `AUDITA_MODEL` |
|
||||
| `AUDITA_BASE_URL` | `--base-url` | `https://openrouter.ai/api/v1` | OpenAI-compatible API base URL |
|
||||
| `AUDITA_VALIDATION_BASE_URL` | `--validation-base-url` | unset | Validation-phase OpenAI-compatible API base URL; defaults to `AUDITA_BASE_URL` |
|
||||
| `AUDITA_LLM_TIMEOUT_SECONDS` | `--llm-timeout-seconds` | `600` | Per-request timeout in seconds for LLM calls to the configured OpenAI-compatible endpoint |
|
||||
| `AUDITA_VALIDATION_LLM_TIMEOUT_SECONDS` | `--validation-llm-timeout-seconds` | unset | Validation-phase per-request timeout in seconds; defaults to `AUDITA_LLM_TIMEOUT_SECONDS` |
|
||||
| `AUDITA_VALIDATION_MAX_PROMPT_TOKENS` | `--validation-max-prompt-tokens` | `2048` | Maximum estimated tokens per validation-phase LLM prompt batch |
|
||||
| `AUDITA_TARGET_SECTIONS` | `--target-sections` | unset | Exact number of contiguous proposal-stage transcript sections; errors if min/max token bounds cannot be satisfied |
|
||||
| `AUDITA_MAX_RETRIES` | `--max-retries` | `3` | Maximum Instructor retries for structured responses |
|
||||
| `AUDITA_VALIDATION_MAX_RETRIES` | `--validation-max-retries` | unset | Validation-phase structured-output retries; defaults to `AUDITA_MAX_RETRIES` |
|
||||
| `AUDITA_VALIDATION_LLM_CONCURRENCY` | `--validation-llm-concurrency` | unset | Validation-phase LLM concurrency; defaults to `AUDITA_LLM_CONCURRENCY` |
|
||||
| `AUDITA_MAX_SECTION_TOKENS` | `--max-section-tokens` | `8192` | Maximum estimated tokens per proposal-stage transcript section |
|
||||
| `AUDITA_MIN_SECTION_TOKENS` | `--min-section-tokens` | `2048` | Minimum estimated tokens per proposal-stage transcript section when balancing for concurrency |
|
||||
| `AUDITA_GLOSSARY_CONFIDENCE_THRESHOLD` | `--glossary-confidence-threshold` | `0.8` | Minimum confidence required for glossary proposals to survive validation |
|
||||
| `AUDITA_GRAMMAR_CONFIDENCE_THRESHOLD` | `--grammar-confidence-threshold` | `0.8` | Minimum confidence required for grammar proposals to survive validation |
|
||||
| `AUDITA_HOMOPHONES_CONFIDENCE_THRESHOLD` | `--homophones-confidence-threshold` | `0.8` | Minimum confidence required for homophone proposals to survive validation |
|
||||
| `AUDITA_SPOKEN_WORD_CONFIDENCE_THRESHOLD` | `--spoken-word-confidence-threshold` | `0.8` | Minimum confidence required for spoken-word proposals to survive validation |
|
||||
| `AUDITA_NORMALIZE_MAX_SEGMENT_GAP` | `--normalize-max-segment-gap` | `4.0` | Same-speaker gaps eligible for deterministic merging |
|
||||
| `AUDITA_NORMALIZE_ELLIPSIS_GAP` | `--normalize-ellipsis-gap` | `3.5` | Same-speaker gaps above this value are joined with ` ... ` |
|
||||
| `AUDITA_NORMALIZE_MAX_SEGMENT_DURATION` | `--normalize-max-segment-duration` | `60.0` | Maximum merged segment duration |
|
||||
| `AUDITA_NORMALIZE_MAX_SEGMENT_TOKENS` | `--normalize-max-segment-tokens` | `2048` | Maximum merged segment prompt payload size |
|
||||
| `AUDITA_WORK_DIR` | `--work-dir` | `/tmp/audita` | Per-run scratch diagnostics directory |
|
||||
| `AUDITA_WORK_DIR_RETENTION` | `--work-dir-retention` | `auto` | Whether to retain the per-run work directory: `auto`, `always`, or `never` |
|
||||
|
||||
Set `AUDITA_MODULES=grammar` to run only the grammar module by default, or override it per command with `--modules`.
|
||||
|
||||
Validation-phase LLM settings inherit from the primary `AUDITA_*` LLM settings by default. Set any of the `AUDITA_VALIDATION_*` values only when you want LLM-backed validators to use a different model, endpoint, credential, timeout, retry budget, or concurrency level.
|
||||
|
||||
OpenRouter remains the default out of the box:
|
||||
|
||||
```sh
|
||||
export AUDITA_LLM_API_KEY=your-openrouter-key
|
||||
audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
```
|
||||
|
||||
You can point Audita at any OpenAI-compatible endpoint by changing `AUDITA_BASE_URL` and, if needed, `AUDITA_MODEL`. For example, a local vLLM server:
|
||||
|
||||
```sh
|
||||
export AUDITA_BASE_URL=http://localhost:8000/v1
|
||||
export AUDITA_MODEL=meta-llama/Llama-3.1-8B-Instruct
|
||||
audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
```
|
||||
|
||||
If your self-hosted endpoint requires authentication, you can still set `AUDITA_LLM_API_KEY`; Audita simply no longer requires it for non-default endpoints.
|
||||
|
||||
Or the actual OpenAI API:
|
||||
|
||||
```sh
|
||||
export AUDITA_LLM_API_KEY=your-openai-key
|
||||
export AUDITA_BASE_URL=https://api.openai.com/v1
|
||||
export AUDITA_MODEL=gpt-4.1-mini
|
||||
audita process transcript.json --glossary glossary.yaml --output corrected.json
|
||||
```
|
||||
|
||||
`AUDITA_WORK_DIR` stores per-run diagnostics while processing. Under the default `AUDITA_WORK_DIR_RETENTION=auto`, clean successful runs are removed, while failed runs and successful runs with final skipped corrections are preserved. Use `always` to keep every run directory and `never` to remove successful run directories even when skips remain.
|
||||
Failed runs always preserve the run directory and include an authoritative `report.json` alongside normalization and prompt/response diagnostics.
|
||||
|
||||
## Prototype Archive
|
||||
|
||||
The archived prototype remains importable as `audita_prototype` and is still covered by its original regression suite. This is intentional: the new `audita` package is a framework-oriented rewrite, not a thin wrapper around the old code.
|
||||
[Open Source attribution notices](docs/oss/attribution.md) are available.
|
||||
|
||||
147
audita
147
audita
@@ -1,147 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
DEFAULT_WORK_DIR = "/tmp/audita"
|
||||
_SECRET_FLAGS = {"--llm-api-key", "--validation-llm-api-key"}
|
||||
|
||||
|
||||
def _redact_argv(argv: list[str]) -> list[str]:
|
||||
redacted: list[str] = []
|
||||
index = 0
|
||||
while index < len(argv):
|
||||
arg = argv[index]
|
||||
matched_flag = next((flag for flag in _SECRET_FLAGS if arg == flag or arg.startswith(flag + "=")), None)
|
||||
if matched_flag is None:
|
||||
redacted.append(arg)
|
||||
index += 1
|
||||
continue
|
||||
if arg == matched_flag:
|
||||
redacted.append(arg)
|
||||
if index + 1 < len(argv):
|
||||
redacted.append("[REDACTED]")
|
||||
index += 2
|
||||
else:
|
||||
index += 1
|
||||
continue
|
||||
redacted.append(f"{matched_flag}=[REDACTED]")
|
||||
index += 1
|
||||
return redacted
|
||||
|
||||
|
||||
def _resolve_work_root(argv: list[str]) -> Path:
|
||||
for index, arg in enumerate(argv):
|
||||
if arg == "--work-dir" and index + 1 < len(argv):
|
||||
return Path(argv[index + 1])
|
||||
if arg.startswith("--work-dir="):
|
||||
return Path(arg.split("=", 1)[1])
|
||||
return Path(os.environ.get("AUDITA_WORK_DIR") or DEFAULT_WORK_DIR)
|
||||
|
||||
|
||||
def _create_run_dir(root: Path) -> Path:
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
timestamp = datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
|
||||
run_dir = root / f"run-{timestamp}-{uuid4().hex[:8]}"
|
||||
run_dir.mkdir(parents=False, exist_ok=False)
|
||||
return run_dir
|
||||
|
||||
|
||||
def _capture_run_dirs(root: Path) -> set[str]:
|
||||
if not root.exists():
|
||||
return set()
|
||||
return {path.name for path in root.iterdir() if path.is_dir() and path.name.startswith("run-")}
|
||||
|
||||
|
||||
def _find_new_run_dir(root: Path, before: set[str]) -> Optional[Path]:
|
||||
if not root.exists():
|
||||
return None
|
||||
candidates = [
|
||||
path for path in root.iterdir() if path.is_dir() and path.name.startswith("run-") and path.name not in before
|
||||
]
|
||||
if not candidates:
|
||||
return None
|
||||
return max(candidates, key=lambda path: path.name)
|
||||
|
||||
|
||||
def _write_launcher_error_log(
|
||||
path: Path,
|
||||
*,
|
||||
message: str,
|
||||
exit_code: int,
|
||||
argv: list[str],
|
||||
command: Optional[list[str]],
|
||||
) -> None:
|
||||
payload = {
|
||||
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||
"message": message,
|
||||
"exit_code": exit_code,
|
||||
"argv": argv,
|
||||
"cwd": os.getcwd(),
|
||||
"command": command,
|
||||
}
|
||||
path.write_text(
|
||||
"Audita Launcher Diagnostics\n" + json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def _emit_console_line(message: str) -> None:
|
||||
for stream in (sys.stderr, sys.stdout):
|
||||
if stream is None:
|
||||
continue
|
||||
try:
|
||||
stream.write(f"{message}\n")
|
||||
stream.flush()
|
||||
return
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
|
||||
|
||||
def main() -> int:
|
||||
argv = list(sys.argv[1:])
|
||||
work_root = _resolve_work_root(argv)
|
||||
redacted_argv = _redact_argv(argv)
|
||||
uv = shutil.which("uv")
|
||||
if uv is None:
|
||||
run_dir = _create_run_dir(work_root)
|
||||
error_log = run_dir / "error.log"
|
||||
message = "uv is required to run this launcher. Install uv and run `uv sync` in the Audita project."
|
||||
_write_launcher_error_log(error_log, message=message, exit_code=1, argv=redacted_argv, command=None)
|
||||
_emit_console_line(f"audita: error: {message}")
|
||||
_emit_console_line("audita: exit code: 1")
|
||||
_emit_console_line(f"audita: run directory: {run_dir}")
|
||||
_emit_console_line(f"audita: error log: {error_log}")
|
||||
return 1
|
||||
|
||||
project_root = Path(__file__).resolve().parent
|
||||
command = [uv, "run", "--project", str(project_root), "python", "-m", "audita", *sys.argv[1:]]
|
||||
before = _capture_run_dirs(work_root)
|
||||
result = subprocess.run(command, cwd=project_root, check=False)
|
||||
if result.returncode == 0:
|
||||
return 0
|
||||
if _find_new_run_dir(work_root, before) is None:
|
||||
run_dir = _create_run_dir(work_root)
|
||||
error_log = run_dir / "error.log"
|
||||
_write_launcher_error_log(
|
||||
error_log,
|
||||
message=f"Audita subprocess exited with status {result.returncode}.",
|
||||
exit_code=result.returncode,
|
||||
argv=redacted_argv,
|
||||
command=_redact_argv(command),
|
||||
)
|
||||
_emit_console_line(f"audita: subprocess exited with status {result.returncode}")
|
||||
_emit_console_line(f"audita: run directory: {run_dir}")
|
||||
_emit_console_line(f"audita: error log: {error_log}")
|
||||
return result.returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
20
cmd/audita/main.go
Normal file
20
cmd/audita/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
}
|
||||
|
||||
func run() int {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
return cli.Run(ctx, os.Args[1:], os.Stdout, os.Stderr)
|
||||
}
|
||||
1246
cmd/audita/main_integration_test.go
Normal file
1246
cmd/audita/main_integration_test.go
Normal file
File diff suppressed because it is too large
Load Diff
7
docs/adr/README.md
Normal file
7
docs/adr/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Architectural Decision Records
|
||||
|
||||
No ADRs have been recorded here. Use the
|
||||
[documentation policy's ADR lifecycle](../policy/documentation.md#architecture-decision-records)
|
||||
for significant decisions. Current architecture belongs in the
|
||||
[architecture policy](../policy/architecture.md); implementation status belongs in
|
||||
[roadmap documents](../roadmap/).
|
||||
95
docs/cli.md
Normal file
95
docs/cli.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# Audita CLI Reference
|
||||
|
||||
The shared version-2 configuration parser and offline profile inspection serve
|
||||
`process`, `config validate`, and `config print-effective`.
|
||||
The [configuration reference](config.md) owns fields, defaults, and validation;
|
||||
the [migration guide](migrations/v2.md) maps retired inputs.
|
||||
|
||||
## Commands and help
|
||||
|
||||
```sh
|
||||
audita process <transcript.json> --glossary <glossary.yml> [flags]
|
||||
audita config validate --config <config.yml> [flags]
|
||||
audita config print-effective [flags]
|
||||
```
|
||||
|
||||
Root invocation, `--help`, `-h`, and command help succeed without loading a config
|
||||
file or resolving secrets. Unknown commands and flags return exit code `2`.
|
||||
`process` accepts exactly one transcript path, either before the flags or after
|
||||
them. With flags first, put the transcript last. Both config commands reject
|
||||
positional arguments and process-only flags.
|
||||
|
||||
All three commands accept `--config <path>` and `--overlay <name>`. `config validate`
|
||||
requires an explicit nonempty `--config`; the other commands select the explicit
|
||||
file, then `/usr/local/etc/audita/config.yml`, then `/etc/audita/config.yml`.
|
||||
Missing system candidates are skipped; inaccessible selected files are errors.
|
||||
No file means a configuration error. `AUDITA_CONFIG` is ignored. The selected
|
||||
overlay is loaded beside the main file, not used to locate profile files.
|
||||
|
||||
## Setting overrides
|
||||
|
||||
Only flags actually supplied override file or overlay settings. `--modules ''`
|
||||
clears the module pipeline, and an explicit numeric zero reaches configuration
|
||||
validation. The shared setting flags are:
|
||||
|
||||
| Setting | Flags |
|
||||
| --- | --- |
|
||||
| Profile selection | `--proposal-profile`, `--validation-profile` |
|
||||
| Pipeline and output | `--modules`, `--output-schema` |
|
||||
| Validation budget | `--validation-max-prompt-tokens` |
|
||||
| Chunking | `--target-sections`, `--max-section-tokens`, `--min-section-tokens` |
|
||||
| Normalization (numeric seconds) | `--normalize-max-segment-gap`, `--normalize-ellipsis-gap`, `--normalize-max-segment-duration`, `--normalize-max-segment-tokens` |
|
||||
| Confidence thresholds | `--glossary-confidence-threshold`, `--homophones-confidence-threshold`, `--spoken-word-confidence-threshold`, `--grammar-confidence-threshold` |
|
||||
| Context | `--transcript-description` |
|
||||
| Reporting | `--reporting[=true\|false]`, `--report-dir DIR` |
|
||||
| Debug | `--debug[=true\|false]`, `--work-dir DIR` |
|
||||
|
||||
`process` alone accepts `--glossary` (required) and `--output`.
|
||||
An omitted or empty output value selects stdout. Nonempty output filenames are
|
||||
used literally, including whitespace.
|
||||
Reporting defaults to enabled. `--reporting=false` disables all three ordinary
|
||||
reports; an explicit false overrides a true file or overlay setting. With file
|
||||
output, reports go beside the transcript and `--report-dir` has no effect. With
|
||||
stdout output, `--report-dir` selects the report directory, defaulting to the
|
||||
invocation working directory. `--debug` separately enables retained detailed
|
||||
artifacts under `--work-dir`. Configuration inspection does not create or probe
|
||||
these output directories.
|
||||
Per-role model, base URL, key, timeout, retry, and concurrency flags have been
|
||||
removed. Models and generation controls belong to PromptKit profiles, backend
|
||||
credentials and capacity to configuration, and retry/deadline settings to the
|
||||
shared LLM section. Legacy configuration environment overrides are ignored.
|
||||
|
||||
## Streams and exit status
|
||||
|
||||
`config validate` loads settings and both selected PromptKit profiles offline,
|
||||
then prints `config is valid` on success. `config print-effective` accepts
|
||||
`--view settings|profiles|explain` and defaults to `settings`. Settings writes
|
||||
ConfigKit's redacted effective-settings YAML. Profiles writes an Audita-owned
|
||||
YAML summary of selected ID, backend, model, sampling controls, per-attempt
|
||||
timeout, service tier, and reasoning effort for each role. It omits credentials,
|
||||
endpoints, and arbitrary extra provider parameters. Explain writes a YAML
|
||||
sequence of field paths, source origins, and recorded derivations without
|
||||
resolved setting values. These views share the same settings and profile
|
||||
validation path as `process`. Unknown views are usage errors. The effective
|
||||
settings YAML is for inspection and is not guaranteed reloadable.
|
||||
|
||||
For `process`, `--output` writes the corrected transcript to a file and leaves
|
||||
stdout empty on success. Without it, stdout carries transcript JSON only on
|
||||
success. Enabled reporting creates `errors.yml`, `recoveries.yml`, and
|
||||
`report.md` in the selected directory. Successful stderr begins with
|
||||
`Completed: N corrections applied; E work units with errors; R recoveries.`
|
||||
Report and debug locations follow only when created. Model-operation failures
|
||||
can coexist with a completed run and applied corrections; read the YAML reports
|
||||
for details. Debug artifacts are created only with `--debug`. See the
|
||||
[report contract](integrations/output-files.md).
|
||||
|
||||
Exit codes are `0` for success, `1` for runtime or output failure, and `2` for
|
||||
usage or configuration input errors. Invalid settings and profiles return `2`;
|
||||
broken embedded assets, caller cancellation, fatal processing, and required
|
||||
output failures return `1`. A late report-write failure can follow a published
|
||||
transcript; exit status and report status remain authoritative.
|
||||
Configuration commands inspect profiles without contacting a provider.
|
||||
|
||||
See the [input files](integrations/transcript-glossary-files.md),
|
||||
[subprocess contract](integrations/subprocess.md), and
|
||||
[artifact lifecycle](operations.md) for their respective details.
|
||||
88
docs/config.md
Normal file
88
docs/config.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# Audita Configuration
|
||||
|
||||
This reference describes the version-2 configuration loader in `internal/core/config`.
|
||||
Use the maintained [local](../examples/minimal-config.yml) and
|
||||
[service](../examples/production-config.yml) examples with their PromptKit
|
||||
[profiles](../examples/profiles/) and optional [testing overlay](../examples/overlays/testing.yml).
|
||||
Choose real models for your endpoint; a testing profile makes no cost or quality
|
||||
guarantee. See the [migration guide](migrations/v2.md) for retired inputs.
|
||||
|
||||
## Loading and precedence
|
||||
|
||||
The application selects one main YAML file: an explicit `--config`, then
|
||||
`/usr/local/etc/audita/config.yml` if present, then `/etc/audita/config.yml`
|
||||
if present. Missing system candidates are skipped; an explicit missing or empty
|
||||
path, inaccessible selected file, or absence of any selected file is an error.
|
||||
`config validate` requires an explicit file. ConfigKit loads built-in defaults,
|
||||
the selected file, an optional named overlay from `overlays/<name>.yml` beside the
|
||||
main file, and only explicitly supplied setting overrides, in that order. Imports
|
||||
and secret-directory bootstrap are disabled. Unknown fields and missing, null,
|
||||
or non-integer `version: 2` are errors. Version-1 files require migration; no
|
||||
compatibility loader or implicit environment configuration remains.
|
||||
|
||||
Validation runs after overlays, explicit overrides, and derived settings have
|
||||
resolved. An override can therefore repair an invalid lower-precedence setting
|
||||
when that setting can be decoded. ConfigKit retains field origins and derivations
|
||||
for effective-configuration inspection. Its effective YAML redacts resolved
|
||||
credentials.
|
||||
|
||||
Profile files are resolved against the selected main file's directory, or may
|
||||
use an absolute `profiles_dir`. Both selected profiles must exist and select a
|
||||
registered backend. Their effective endpoints must match that backend's endpoint
|
||||
after surrounding whitespace and trailing slashes are removed. Profiles cannot
|
||||
supply a competing `api_key_env` lookup. The backend credential supplies the
|
||||
runtime key when required; inspection makes no provider call. The
|
||||
[CLI inspection views](cli.md#streams-and-exit-status) show selected controls and
|
||||
field provenance separately from ConfigKit's redacted settings YAML.
|
||||
|
||||
## Settings
|
||||
|
||||
| Field | Default | Rule |
|
||||
| --- | --- | --- |
|
||||
| `profiles_dir` | `profiles` | Nonempty; profile files are resolved relative to the selected main file. |
|
||||
| `backends.<id>.endpoint` | None | Required nonempty endpoint for each backend. At least one backend is required. |
|
||||
| `backends.<id>.concurrency` | `1` | Positive finite capacity; shared by both roles using that backend. |
|
||||
| `backends.<id>.queue_capacity` | `1024` | Nonnegative; zero disables waiting admission. |
|
||||
| `backends.<id>.credential` | Unset | Optional environment-variable secret reference; omission or null means unauthenticated use. |
|
||||
| `llm.proposal_profile` | None | Required nonempty profile ID. |
|
||||
| `llm.validation_profile` | Final proposal profile | Omission inherits the final proposal selection; explicit empty or null fails. |
|
||||
| `llm.transient_retries` | `2` | Nonnegative additional attempts per generation. |
|
||||
| `llm.repair_attempts` | `2` | Additional structural repair generations, from zero through three. |
|
||||
| `llm.operation_timeout` | `15m` | Positive Go duration string per logical call. |
|
||||
| `pipeline.modules` | `[glossary, homophones, glossary, spoken_word, grammar]` | Ordered module keys; repeats are meaningful and an explicit empty list runs no correction modules. |
|
||||
| `output.schema` | `bare-segments` | `bare-segments` or `audita-v1`. See [output formats](integrations/output-files.md). |
|
||||
| `validation.max_prompt_tokens` | `2048` | Positive validation batching budget. |
|
||||
| `chunking.target_sections` | Unset | Optional positive target; omission or null selects automatic chunking. |
|
||||
| `chunking.max_section_tokens` | `8192` | Positive maximum estimate. |
|
||||
| `chunking.min_section_tokens` | `2048` | Positive and no greater than maximum. |
|
||||
| `normalization.max_segment_gap` | `4.0` | Nonnegative numeric seconds. |
|
||||
| `normalization.ellipsis_gap` | `3.5` | Nonnegative numeric seconds. |
|
||||
| `normalization.max_segment_duration` | `60.0` | Positive numeric seconds. |
|
||||
| `normalization.max_segment_tokens` | `2048` | Positive token estimate. |
|
||||
| `thresholds.glossary`, `.homophones`, `.spoken_word`, `.grammar` | `0.8` each | Confidence thresholds in `[0, 1]`. |
|
||||
| `context.description` | Empty | Trimmed prompt context, at most 500 bytes. |
|
||||
| `reporting.enabled` | `true` | Write the ordinary three-file report bundle when processing. |
|
||||
| `reporting.stdout_dir` | `.` | Report directory for stdout transcript output; ignored for file output or disabled reporting. |
|
||||
| `diagnostics.debug` | `false` | Persist detailed debug artifacts when processing. |
|
||||
| `diagnostics.work_dir` | `/tmp/audita` | Parent of the retained debug run directory; required only when debug is enabled. |
|
||||
|
||||
Module keys select correction modules; validator chains remain built into them.
|
||||
The loader preserves module order and repetitions. Normalization time settings
|
||||
accept numeric seconds only. The operation timeout uses a duration string.
|
||||
`reporting.stdout_dir` must be nonblank only for reporting-enabled stdout runs;
|
||||
`diagnostics.work_dir` must be nonblank only with debug enabled. These path
|
||||
requirements are checked when choosing process destinations, not during
|
||||
configuration inspection.
|
||||
|
||||
## Credentials
|
||||
|
||||
A backend credential is a ConfigKit secret reference containing an environment
|
||||
variable name, such as `credential: AUDITA_SERVICE_KEY`. Every reference that
|
||||
survives overlay and override resolution must name a set, nonempty variable,
|
||||
including credentials on backends unused by the selected roles. A replacement
|
||||
reference resolves only the replacement; null removes the reference. General
|
||||
`AUDITA_*` and `OPENROUTER_API_KEY` variables have no implicit setting effect.
|
||||
Secret values are available to the runtime through the resolved reference, while
|
||||
ConfigKit's effective output and provenance contain no resolved secret values.
|
||||
|
||||
Current invocation syntax belongs in [CLI](cli.md).
|
||||
70
docs/development.md
Normal file
70
docs/development.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Developing Audita
|
||||
|
||||
Audita is a Go CLI for transcript polishing. Start with the
|
||||
[README](../README.md) for product orientation and the
|
||||
[internal overview](internal/overview.md) for the implemented component map.
|
||||
|
||||
## Before Changing the Repository
|
||||
|
||||
Coding agents must read and follow the [agent policy](policy/agents.md) before
|
||||
recommending, planning, or implementing changes. Use the policy reading guide
|
||||
below to select the policies applicable to the task.
|
||||
|
||||
Confirm the requested scope and behavior contract, make focused changes in the
|
||||
owning component, and update the relevant tests and canonical documentation
|
||||
when behavior changes. The [testing policy](policy/testing.md) governs test
|
||||
sufficiency; the [documentation policy](policy/documentation.md) governs content
|
||||
ownership. Commit discipline and agent Git restrictions are in the
|
||||
[agent policy](policy/agents.md#git-commit-policy).
|
||||
|
||||
## Policy Reading Guide
|
||||
|
||||
| Policy | Read before… |
|
||||
| --- | --- |
|
||||
| [Policy set provenance](policy/meta.md) | Adopting policies, checking upstream revisions, or updating the adopted policy set. |
|
||||
| [Agents](policy/agents.md) | Recommending, planning, or implementing repository changes. |
|
||||
| [Architecture](policy/architecture.md) | Planning or changing application code or its structure. |
|
||||
| [Testing](policy/testing.md) | Selecting validation for code changes, or adding, changing, removing, or evaluating tests. |
|
||||
| [Documentation](policy/documentation.md) | Writing, revising, or reorganizing documentation. |
|
||||
| [OSS](policy/oss.md) | Adding or updating dependencies or incorporated third-party material, or changing licensing or attribution. |
|
||||
| [Release](policy/release.md) | Preparing or publishing a release, changing release procedures, or making versioning and compatibility decisions. |
|
||||
|
||||
- Read applicable policies before making decisions they govern; multiple policies
|
||||
may apply.
|
||||
- Select policies using the task triggers above. Follow cross-references to
|
||||
relevant sections when needed to resolve a concrete question.
|
||||
- Reuse policies already available in context; reread when changed or no longer
|
||||
available.
|
||||
- Expand reading when the task's scope expands.
|
||||
- When revising a policy itself, read that policy and any provisions elsewhere
|
||||
affected by the revision.
|
||||
|
||||
## Baseline Validation
|
||||
|
||||
Use Go 1.25.5 or newer. From the repository root:
|
||||
|
||||
```sh
|
||||
go build -o ./bin/audita ./cmd/audita
|
||||
go test ./...
|
||||
```
|
||||
|
||||
Run targeted package tests for touched behavior and the complete suite for
|
||||
substantial changes. Documentation-only work normally needs affected-link,
|
||||
example, and whitespace checks; use `git diff --check`. Detailed component
|
||||
validation belongs with the change recipes below.
|
||||
|
||||
## Task-Specific Reading Guide
|
||||
|
||||
| Task | Read |
|
||||
| --- | --- |
|
||||
| Locate components or change orchestration | [Internal overview](internal/overview.md), then [pipeline](internal/pipeline.md) |
|
||||
| Change configuration or CLI behavior | [Configuration contract](config.md), [CLI contract](cli.md), and [configuration/CLI change recipes](internal/cli-config.md) |
|
||||
| Change modules or validators | [Modules](internal/modules.md) or [validators](internal/validators.md); follow their prompt, registry, and test references |
|
||||
| Change LLM transport or concurrency | [LLM integration contract](integrations/openai-compatible-llm.md), [LLM runtime](internal/llm-runtime.md), and [pipeline](internal/pipeline.md) |
|
||||
| Change prompts | [Prompt registry](internal/prompts.md) and the consuming [module](internal/modules.md) or [validator](internal/validators.md) |
|
||||
| Change input/output formats | [Input file contracts](integrations/transcript-glossary-files.md), [output-file contract](integrations/output-files.md), [encoder internals](internal/output-schemas.md), and [configuration](config.md) |
|
||||
| Change reports or diagnostics | [Operations](operations.md), [output-file contract](integrations/output-files.md), [subprocess integration](integrations/subprocess.md), and [diagnostics/reporting internals](internal/diagnostics-reporting.md) |
|
||||
| Change tests | [Testing policy](policy/testing.md) and the affected component's internal documentation |
|
||||
| Change docs or examples | [Documentation policy](policy/documentation.md), the canonical topic owner, and [example validation](internal/cli-config.md#validating-examples) |
|
||||
| Prepare a release | [Release policy](policy/release.md) and [release procedure](release.md) |
|
||||
| Record a significant architectural decision | [ADR lifecycle](policy/documentation.md#architecture-decision-records) and [ADR index](adr/README.md) |
|
||||
34
docs/integrations/openai-compatible-llm.md
Normal file
34
docs/integrations/openai-compatible-llm.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# OpenAI-Compatible LLM Integration
|
||||
|
||||
Audita uses the pinned [PromptKit](https://gitea.maximumdirect.net/eric/promptkit)
|
||||
built-in OpenAI-compatible transport. PromptKit owns chat-completions wire framing,
|
||||
provider envelope parsing, transient retries, per-generation timeouts, and JSON
|
||||
Schema repair. A backend's configured base endpoint must support the selected
|
||||
profile's model and structured JSON-schema responses; local configuration
|
||||
inspection does not contact the provider.
|
||||
|
||||
Audita selects a role profile, supplies its registered backend credential, and
|
||||
passes the embedded response schema as a complete per-call output contract. It
|
||||
prepares each call once, checks that the prepared target still matches the
|
||||
inspected backend and endpoint, then executes that same prepared request. A
|
||||
profile cannot introduce a separate credential environment lookup. An absent
|
||||
backend credential permits an unauthenticated local service.
|
||||
|
||||
`llm.transient_retries` counts additional attempts for eligible transient
|
||||
failures; explicit zero makes one attempt. `llm.repair_attempts` counts
|
||||
additional generations for schema-invalid model output. The operation timeout
|
||||
covers preparation, capacity waiting, retries, generation, and repair. Caller
|
||||
cancellation or an earlier deadline also applies. See [configuration](../config.md#settings)
|
||||
for defaults and [PromptKit's consumer contract](https://gitea.maximumdirect.net/eric/promptkit/src/tag/v0.11.2/docs/consumers/pkg-promptkit.md)
|
||||
for the pinned protocol and retry details.
|
||||
|
||||
A model operation that exhausts structural repair, a live-parent local operation
|
||||
timeout, capacity rejection, transport failure, malformed provider response,
|
||||
or provider HTTP failure is recoverable for that operation. Proposal generation
|
||||
then contributes no candidates from that response; a failed validation batch
|
||||
marks its candidates unavailable while other batches and later modules can
|
||||
continue. Caller cancellation, broken assets or configuration, and unknown
|
||||
internal failures remain fatal and cancel peers. Audita decodes into domain
|
||||
types only after PromptKit validates the JSON. Ordinary reports use safe reason
|
||||
codes and counts rather than provider messages. Full request/response content
|
||||
is written only with `--debug`; see [operations](../operations.md#diagnostics-directory).
|
||||
112
docs/integrations/output-files.md
Normal file
112
docs/integrations/output-files.md
Normal file
@@ -0,0 +1,112 @@
|
||||
# Output Files and Reports
|
||||
|
||||
## Corrected Transcript
|
||||
|
||||
The corrected transcript uses the selected `output.schema`: `bare-segments`
|
||||
or `audita-v1`. Its schema and text rules are unchanged by resilience
|
||||
reporting. See [configuration](../config.md#settings) for selection and
|
||||
[operations](../operations.md#required-output-files) for placement and writes.
|
||||
|
||||
With reporting enabled, Audita produces three ordinary files:
|
||||
|
||||
- `errors.yml`: affected work units and run-level failures;
|
||||
- `recoveries.yml`: successful logical model operations with repair, service
|
||||
retry, or response filtering;
|
||||
- `report.md`: a concise overview and complete per-chunk matrices.
|
||||
|
||||
The YAML documents have Audita-owned schemas `audita-errors` and
|
||||
`audita-recoveries`, each with integer `version: 1`. Both contain, in order,
|
||||
`schema`, `version`, `run_id`, `status`, `started_at`, `completed_at`, `summary`,
|
||||
and an always-present `errors` or `recoveries` sequence. Status is
|
||||
`in_progress`, `completed`, or `failed`. Times are UTC RFC3339 strings;
|
||||
`completed_at` is null until finalization. A recoverable model error can appear
|
||||
with `status: completed`.
|
||||
|
||||
## Summary Counts
|
||||
|
||||
Both documents carry the same summary, in this order:
|
||||
|
||||
| Count | Meaning |
|
||||
| --- | --- |
|
||||
| `work_units_total` | Configured module instances × initial chunks. |
|
||||
| `work_units_started`, `work_units_completed`, `work_units_interrupted`, `work_units_not_started` | Explicit processing states. |
|
||||
| `work_units_with_errors` | Distinct units with recoverable operation failures. |
|
||||
| `run_errors` | Fatal processing or output failures outside that unit count. |
|
||||
| `corrections_applied` | Approved proposals applied, not replacement occurrences. |
|
||||
| `llm_operations` | Structured-client invocations, including pre-dispatch failures. |
|
||||
| `proposal_responses` | Structurally usable proposal responses. |
|
||||
| `recoveries` | Successful operations with one or more recovery reasons. |
|
||||
| `proposal_responses_with_filtering` | Proposal responses that filtered at least one defective proposal. |
|
||||
|
||||
Unknown counts before processing are `null`; completed empty counts are `0`.
|
||||
Retries and repair generations are details of one operation, not additional
|
||||
operations. Provider token usage, execution timing, and attempt-level evidence
|
||||
remain in opt-in debug files.
|
||||
|
||||
## Error and Recovery Records
|
||||
|
||||
An `errors` record with `scope: work_unit` identifies zero-based `stage_index`
|
||||
and `chunk_index`, module key/instance, initial segment range, applied-correction
|
||||
count, and a `failures` sequence. Each failure identifies the operation
|
||||
(`proposal`, `validation`, or `validation_input`), optional validator and
|
||||
zero-based batch index, safe reason/message, sorted proposal indices when
|
||||
known, and execution counts when available. Multiple failed batches in one
|
||||
work unit form one error record. `scope: run` instead records phase, safe reason
|
||||
and message, optional origin, and output path where relevant. It can describe
|
||||
a fatal error or secondary output-write failure without inventing a failed
|
||||
model work unit. Raw provider errors and transcript text are absent.
|
||||
For `validation_decisions_invalid`, proposal indices identify only candidates
|
||||
whose required decisions were unavailable. Other candidates in the same batch
|
||||
may still be approved or rejected normally.
|
||||
|
||||
Each recovery identifies its work unit and successful operation, with sorted
|
||||
`reasons`, a safe message, available execution counts, and sorted
|
||||
`filtered_proposals` details. One recovery can contain `output_repaired`,
|
||||
`service_recovered`, and `proposals_filtered` together. Filtering covers
|
||||
defective response proposals; low confidence, protected-term rejection,
|
||||
ordinary editorial rejection, and an apply-time conflict caused by an earlier
|
||||
accepted correction are not filtering recoveries. Failed operations are errors,
|
||||
not recoveries. The initial chunk identity remains stable even if earlier
|
||||
modules change its text.
|
||||
`validation_decisions_filtered` records unexpected validator decision indices
|
||||
ignored from a successful validation batch. It may accompany repair or service
|
||||
recovery reasons, but it does not add `filtered_proposals` or increment
|
||||
`proposal_responses_with_filtering`. A batch with unavailable requested decisions
|
||||
is an error even when unexpected indices were also ignored.
|
||||
|
||||
## Markdown Overview
|
||||
|
||||
`report.md` includes run ID, status, corrections, work coverage, error and
|
||||
recovery totals, input/output paths, and full work-unit error and recovery
|
||||
matrices. Rows show every initial chunk with 1-based chunk number and initial
|
||||
segment range; columns follow configured module-instance order, including
|
||||
repeats. Completed error cells are `0` or `1`; recovery cells are operation
|
||||
counts. `—` means not started and `n*` means interrupted with n facts recorded.
|
||||
An empty stage or chunk set is identified as having no work units. Short reason breakdowns count
|
||||
records containing each reason; a recovery can have several reasons, so those
|
||||
counts need not sum to the recovery total. The report refers to both YAML
|
||||
files. It does not include transcript excerpts or correction lists.
|
||||
|
||||
## Debug-Only Files
|
||||
|
||||
With `--debug`, `correction-ledger.json` contains proposed candidates and
|
||||
their application, rejection, or interruption details. `llm-execution.json`
|
||||
holds logical calls and PromptKit execution events; `utilization-diagnostics.json`
|
||||
groups backend capacity and timing observations while preserving known and
|
||||
complete usage semantics. Interaction request/response artifacts, selected
|
||||
profiles, configuration provenance, and input snapshots are also debug-only.
|
||||
These files are diagnostic evidence, not an alternate ordinary report schema.
|
||||
Each candidate-backed ledger entry includes `proposed_corrected_text`, the
|
||||
literal replacement span, even when it is `""` for a deletion. Applied entries
|
||||
also include `applied_corrected_text`, likewise `""` for an applied deletion.
|
||||
Rejected, unavailable, skipped, and interrupted entries omit the applied field; a module
|
||||
failure without a candidate omits both. These fields are replacement spans,
|
||||
not full resulting-segment text. Deterministic decision records now identify
|
||||
the blank-result guard as `non_empty_resulting_segment` (formerly
|
||||
`non_empty_corrected_text`); its `empty_resulting_segment` reason is unchanged.
|
||||
Validator decision records carry `disposition`: `approved`, `rejected`, or
|
||||
`unavailable`. A missing or duplicate required decision is `unavailable`, not
|
||||
an editorial rejection. The candidate ledger uses the same distinction in its
|
||||
top-level disposition. Interaction response artifacts retain supplied model
|
||||
decisions and the reconciliation result, including unavailable and ignored
|
||||
indices; unexpected indices never create candidate ledger entries.
|
||||
48
docs/integrations/subprocess.md
Normal file
48
docs/integrations/subprocess.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Subprocess Integration
|
||||
|
||||
This guide explains how a parent process can invoke Audita and consume its results.
|
||||
The [CLI reference](../cli.md) owns command syntax, streams, and exit semantics;
|
||||
[configuration](../config.md) owns discovery and precedence.
|
||||
|
||||
## Invocation
|
||||
|
||||
Use an argument array with the transcript path and required glossary argument,
|
||||
following the [process examples](../cli.md#commands-and-help). For machine workflows,
|
||||
select an explicit transcript file destination and a configuration path. Reports
|
||||
then go beside the transcript. For stdout output, select `--report-dir` or use
|
||||
the invocation working directory. Debug is independent and off by default.
|
||||
Supplying a configuration path also
|
||||
makes file selection predictable; only explicitly referenced credential variables
|
||||
are read from the environment.
|
||||
|
||||
Resolve the executable deliberately and set the child's working directory so
|
||||
relative input/output paths and reported artifact paths have a known base.
|
||||
Read stdout and stderr concurrently to avoid pipe blocking, and impose timeout
|
||||
or cancellation in the parent process when needed.
|
||||
|
||||
## Result Handling
|
||||
|
||||
Interpret the exit result according to the
|
||||
[CLI output and exit contract](../cli.md#streams-and-exit-status).
|
||||
Consume transcript/report data through the
|
||||
[output-file contract](output-files.md), and treat stderr as human-readable detail.
|
||||
The three reports may be absent after early configuration or destination
|
||||
failures. After initialization, failed reports can describe invalid input or
|
||||
partial processing. Exit `0` can include recoverable model errors and applied
|
||||
corrections; inspect `errors.yml` and `recoveries.yml` for those outcomes. A
|
||||
transcript may have been written before a later required report failure, so
|
||||
the file alone does not prove completion.
|
||||
|
||||
If processing fails, preserve available evidence and follow
|
||||
[operations recovery](../operations.md#failure-inspection-and-recovery).
|
||||
Ordinary reports are independent of optional retained debug evidence. Parent
|
||||
cancellation reaches the child through its context; Audita joins workers and
|
||||
attempts failed-status report finalization before exiting. Uncatchable
|
||||
termination can leave `in_progress` reports. Neither the existence of an output
|
||||
file nor a debug directory alone establishes successful completion.
|
||||
|
||||
## Related Contracts
|
||||
|
||||
- [Transcript and glossary inputs](transcript-glossary-files.md)
|
||||
- [LLM endpoint compatibility](openai-compatible-llm.md)
|
||||
- [Configuration inspection commands](../cli.md#commands-and-help)
|
||||
50
docs/integrations/transcript-glossary-files.md
Normal file
50
docs/integrations/transcript-glossary-files.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Transcript and Glossary Input Files
|
||||
|
||||
This document owns accepted input formats. Use the [CLI reference](../cli.md) for
|
||||
invocation and error exit semantics, [operations](../operations.md) for artifact
|
||||
handling, and [output files](output-files.md) for corrected-transcript serialization.
|
||||
|
||||
## Transcript JSON Contract
|
||||
|
||||
Accepted top-level shapes are an array of segments or an object containing a
|
||||
`segments` array. The array must contain at least one segment. Unknown object
|
||||
fields are ignored by the current parser; an input envelope does not require a
|
||||
schema/version marker.
|
||||
|
||||
| Segment field | Type and validation |
|
||||
| --- | --- |
|
||||
| `id` | Optional integer (or null). Supplied IDs must be unique; missing IDs are accepted. |
|
||||
| `speaker` | Non-empty string |
|
||||
| `start`, `end` | Numeric seconds, finite and non-negative; end must be at least start |
|
||||
| `text` | Non-empty string |
|
||||
| `categories` | Optional array of non-empty strings |
|
||||
|
||||
Supply explicit start and end times for meaningful timing. The current decoder
|
||||
uses zero for missing or null timestamps rather than enforcing their presence.
|
||||
String validation checks empty values, not whitespace trimming. Normalization can
|
||||
merge segments and reassign IDs, so source IDs need not match output IDs.
|
||||
|
||||
The [tiny transcript](../../examples/tiny-transcript.json) is a complete copyable
|
||||
input. Invalid JSON, unsupported top-level shapes, empty transcripts, invalid field
|
||||
types, duplicate supplied IDs, and the validation failures above are rejected.
|
||||
|
||||
## Glossary YAML Contract
|
||||
|
||||
The top-level object contains a `glossary` list with at least one entry.
|
||||
|
||||
| Entry field | Type and validation |
|
||||
| --- | --- |
|
||||
| `name` | Non-empty string |
|
||||
| `category` | Non-empty string |
|
||||
| `summary` | Non-empty string |
|
||||
| `aliases` | Optional list of non-empty strings |
|
||||
| `plural` | Optional string |
|
||||
|
||||
The parser checks empty strings without trimming them. Unknown YAML fields are
|
||||
ignored by the glossary parser, unlike the stricter
|
||||
[configuration-file schema](../config.md#loading-and-precedence).
|
||||
|
||||
The [tiny glossary](../../examples/tiny-glossary.yaml) is a complete copyable input.
|
||||
Malformed YAML, an empty/missing glossary, invalid shapes, missing required text,
|
||||
and empty aliases are rejected. These formats describe input acceptance, not
|
||||
additional vocabulary restrictions.
|
||||
66
docs/internal/cli-config.md
Normal file
66
docs/internal/cli-config.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Configuration and CLI Change Recipes
|
||||
|
||||
This document owns contributor editing and validation steps for configuration,
|
||||
CLI wiring, and maintained examples. Definitions of behavior belong to the
|
||||
[configuration](../config.md) and [CLI](../cli.md) contracts.
|
||||
|
||||
## Changing Configuration
|
||||
|
||||
1. Update fields, defaults, loading, and validation in `internal/core/config`.
|
||||
2. Update file, selected overlay, credential reference, and CLI mapping as
|
||||
applicable. Preserve the precedence defined in the
|
||||
[configuration contract](../config.md#loading-and-precedence), including the
|
||||
distinct validation and effective-config commands.
|
||||
3. Update redaction when secrets are involved.
|
||||
4. Review configuration tests and related CLI tests for precedence, validation,
|
||||
and source-specific behavior. Add or adjust tests for the changed contract
|
||||
according to the [testing policy](../policy/testing.md).
|
||||
5. Update the configuration reference and affected [examples](../../examples/).
|
||||
|
||||
## Changing CLI Behavior
|
||||
|
||||
1. Implement parsing and wiring in `internal/cli`.
|
||||
2. Preserve [stream and exit contracts](../cli.md) unless a change is intentional
|
||||
and documented. Review [subprocess integration](../integrations/subprocess.md)
|
||||
when changing output, error, or report handling.
|
||||
3. Review `internal/cli` tests and `cmd/audita` subprocess tests; update coverage
|
||||
for the changed behavior.
|
||||
4. Update the CLI reference and affected integration guidance.
|
||||
|
||||
## Validating Examples
|
||||
|
||||
Keep complete copyable files in [examples](../../examples/) and link to them from
|
||||
their canonical contract documentation. Keep them valid and secret-free.
|
||||
From the repository root, validate the maintained configuration examples:
|
||||
|
||||
```sh
|
||||
go run ./cmd/audita config validate --config examples/minimal-config.yml
|
||||
AUDITA_SERVICE_KEY=synthetic-example go run ./cmd/audita config validate --config examples/production-config.yml
|
||||
AUDITA_SERVICE_KEY=synthetic-example go run ./cmd/audita config validate --config examples/production-config.yml --overlay testing
|
||||
go run ./cmd/audita config print-effective --config examples/minimal-config.yml --view profiles
|
||||
```
|
||||
|
||||
Only referenced credentials read environment values; use a controlled synthetic
|
||||
value when validating the service example. Check affected CLI examples against the
|
||||
parser and use schema tests for maintained transcript/glossary inputs. Example
|
||||
validation should not invoke a live LLM merely to check documentation.
|
||||
|
||||
## Runtime Change Checks
|
||||
|
||||
Select checks according to the [testing policy](../policy/testing.md):
|
||||
|
||||
- Configuration or CLI changes: inspect `internal/core/config` tests,
|
||||
`internal/cli` tests, and `cmd/audita` integration tests.
|
||||
- Process/output changes: verify stdout, stderr, exit, output-file, and report
|
||||
behavior against the [CLI contract](../cli.md) and
|
||||
[subprocess guidance](../integrations/subprocess.md), including failures.
|
||||
- Report or diagnostics changes: review [report assembly tests and redaction
|
||||
checks](diagnostics-reporting.md#key-tests), metadata fields, and artifact paths.
|
||||
- Schema or serialization changes: review [output-schema tests](output-schemas.md#key-tests)
|
||||
and `internal/core/schema` tests, including supported formats and rejection of
|
||||
unsupported schemas.
|
||||
- Changes affecting assembled output: inspect controlled HTTP subprocess workflows
|
||||
and retained report/artifact assertions.
|
||||
|
||||
Use the [contributor guide](../development.md#baseline-validation) for baseline
|
||||
commands. These recipes supplement, rather than duplicate, public contracts.
|
||||
63
docs/internal/diagnostics-reporting.md
Normal file
63
docs/internal/diagnostics-reporting.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Diagnostics and Reporting Internals
|
||||
|
||||
The [output-file contract](../integrations/output-files.md) owns public
|
||||
schemas and the [operations guide](../operations.md) owns physical placement.
|
||||
|
||||
`internal/framework/outcomes` contains processing-owned operation references,
|
||||
counts, failure reasons, filtering details, and work states. It imports no
|
||||
reporting, CLI, or provider package. The runner records those facts per initial
|
||||
section and module instance. `internal/framework/processreport` maps them once
|
||||
into `internal/core/reporting.Snapshot`, including nullable counts, grouped
|
||||
work-unit errors, separate run errors, and one recovery per successful logical
|
||||
operation. Reports order stages, sections, validators, and batches by semantic
|
||||
identity, never concurrent completion time. The core reporting package owns
|
||||
Audita's versioned YAML DTOs, fixed Markdown rendering, and brief CLI
|
||||
completion formatter. YAML redaction walks serialized string nodes so numeric
|
||||
and boolean values retain their types. Ordinary reports omit raw causes,
|
||||
transcript text, complete decisions, and token/timing payloads.
|
||||
Validation operations with unavailable decisions report only affected requested
|
||||
indices, even when other candidates in the batch continue. Ignored extra
|
||||
validator entries yield `validation_decisions_filtered` only for a successful
|
||||
operation; they do not count as filtered correction proposals. Failed operations
|
||||
retain their execution counts and never produce a recovery record.
|
||||
|
||||
`internal/core/diagnostics.OutputSession` owns active destination checks,
|
||||
transcript preflight, report initialization, regular-file replacement, and direct
|
||||
stream publication. Transcript input is protected from early report writes but
|
||||
may be the final transcript destination. The LLM runtime records successful reads
|
||||
through PromptKit's profile filesystem and supplies those source paths to CLI;
|
||||
no second filename-based discovery rule is used.
|
||||
CLI composes it after configuration/profile inspection and before reading
|
||||
inputs or dispatching model work. It does not create ordinary report parents.
|
||||
On a final write error it attempts other enabled reports and one failed-status
|
||||
pass; a published transcript is never erased by a later report failure.
|
||||
|
||||
Debug is independent. Only `diagnostics.debug` creates a unique retained child
|
||||
under `diagnostics.work_dir`. CLI passes empty diagnostics paths and nil writers
|
||||
when debug is off. With debug on, source/normalized snapshots, invocation,
|
||||
effective settings, origins, profiles, initial chunk summary, correction ledger,
|
||||
indexed execution/utilization, and model interactions are written. Runner
|
||||
candidate capture includes proposals later rejected or interrupted. Ledger
|
||||
mapping uses optional string pointers so an empty proposed replacement is
|
||||
serialized for every candidate and an empty applied replacement appears only
|
||||
when that candidate applied; see the [public artifact contract](../integrations/output-files.md#debug-only-files).
|
||||
Debug write failures reach the CLI through an explicit concurrency-safe diagnostic
|
||||
callback and produce redacted stderr messages without aborting processing.
|
||||
Completed validator decisions returned with a fatal batch error remain available
|
||||
to the debug ledger; they never authorize applying an incompletely validated edit.
|
||||
Runner decision records carry the validator's explicit approved, rejected, or
|
||||
unavailable disposition into the ledger. Unavailable candidates have a distinct
|
||||
top-level ledger disposition, while fatal interruptions remain interrupted when
|
||||
no rejection or unavailable decision was returned. Successful validation
|
||||
interaction payloads contain the full decoded response, final content, and
|
||||
reconciliation outcomes; ignored indices do not become ledger candidates.
|
||||
Every debug writer uses all configured backend secrets for redaction, including
|
||||
unselected backend credentials and source snapshots. Debug can still contain
|
||||
sensitive transcript and prompt content.
|
||||
|
||||
## Key Tests
|
||||
|
||||
Useful tests: `internal/core/reporting/*_test.go`,
|
||||
`internal/core/diagnostics/*_test.go`,
|
||||
`internal/framework/processreport/*_test.go`, and
|
||||
`cmd/audita/main_integration_test.go`.
|
||||
39
docs/internal/llm-runtime.md
Normal file
39
docs/internal/llm-runtime.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Audita LLM Runtime
|
||||
|
||||
## Client Boundary
|
||||
|
||||
`llm.NewRuntime` assembles one PromptKit engine for both roles. It loads embedded
|
||||
prompt and schema assets, registers application backends, and inspects the
|
||||
selected proposal and validation profiles offline. A role-bound `llm.RoleClient`
|
||||
implements `structuredoutput.Client`; proposal and validator contracts alias that
|
||||
interface. Both roles share engine-local backend capacity.
|
||||
|
||||
For each logical call, the adapter starts an operation context and a diagnostic
|
||||
record before preparation. It supplies the reserved hardening text, the selected
|
||||
profile and resolved backend credential, and the complete embedded schema/repair
|
||||
contract. `PrepareExecution` produces the exact messages and hashes retained in
|
||||
an Audita snapshot. The adapter checks the prepared backend and endpoint before
|
||||
`RunPrepared`. It records available final content, usage, model, and profile
|
||||
metadata and decodes only a validated result. Call hooks expose logical
|
||||
start/finish records and PromptKit execution events for debug utilization.
|
||||
|
||||
The [integration contract](../integrations/openai-compatible-llm.md) describes
|
||||
wire ownership and failure behavior. `structuredoutput.Failure` has a safe
|
||||
message, fixed reason code, typed cause, and recoverable/fatal/canceled class.
|
||||
Counts distinguish provider attempts, transient retries, and structural
|
||||
repairs, including on errors. Secrets from all configured backends, including unselected
|
||||
ones, are available to the diagnostics redaction boundary.
|
||||
|
||||
## Orchestration
|
||||
|
||||
CLI processing supplies two role clients from the same engine to the runner.
|
||||
PromptKit's per-backend admission applies to both roles and every generation,
|
||||
retry, and repair. The runner still processes module instances in order,
|
||||
collects concurrent section work deterministically, and cancels remaining
|
||||
section work only on fatal failures. `llm.DiagnosticsWriter` remains the protected
|
||||
request/response artifact writer. `llm.ObservationCollector` captures metadata
|
||||
events under a short mutex and freezes them after runner work joins. Its logical
|
||||
records include preparation failures; summary usage comes from terminal events
|
||||
once per call and retains knownness and completeness for each field. Runner wall
|
||||
and validator timings remain separate from provider attempts. Ordinary reports
|
||||
derive compact runner outcomes; full observations are debug-only.
|
||||
91
docs/internal/modules.md
Normal file
91
docs/internal/modules.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Audita Modules
|
||||
|
||||
## Scope
|
||||
|
||||
This document covers internal module contracts and packages. User-selectable keys
|
||||
and the default sequence belong to [configuration](../config.md#settings).
|
||||
|
||||
## Module Contract
|
||||
|
||||
Modules implement `contracts.TranscriptModule`:
|
||||
- `Key()`
|
||||
- `ReplacementPolicy()`
|
||||
- `Validators()`
|
||||
- `Propose(ctx, req)`
|
||||
|
||||
Runner resolves configured module specs to module instances through `internal/framework/modules`.
|
||||
|
||||
## Built-In Modules
|
||||
|
||||
Current module packages:
|
||||
- `internal/modules/glossary`
|
||||
- `internal/modules/homophones`
|
||||
- `internal/modules/spoken_word`
|
||||
- `internal/modules/grammar`
|
||||
|
||||
Current replacement policies:
|
||||
- `glossary`: `replace_all`
|
||||
- `homophones`: `require_unique`
|
||||
- `spoken_word`: `require_unique`
|
||||
- `grammar`: `require_unique`
|
||||
|
||||
## Proposal Generation Ownership
|
||||
|
||||
Shared proposal-generation plumbing is centralized in:
|
||||
- `internal/framework/proposal_generation`
|
||||
|
||||
Module packages own:
|
||||
- prompt selection (`internal/prompts` prompt IDs).
|
||||
|
||||
`proposal_generation.BuildProposalVariables` encodes the glossary, selected
|
||||
transcript section, and trimmed description once for all four modules. PromptKit
|
||||
renders their embedded definitions from those variables and validates the
|
||||
correction-set schema before Audita maps proposals. Domain validators still
|
||||
check confidence, applicability, protected glossary terms, and replacement
|
||||
policy. Model-facing segment IDs are one-based positions within the proposal
|
||||
request. Generation maps returned references back to the current chunk's actual
|
||||
segment IDs, preserving response order and multiple proposals per segment.
|
||||
Unknown references become invalid-target candidates for the existing domain
|
||||
checks; they are never interpreted as actual transcript IDs. Debug request
|
||||
metadata records `segment_ids` in local-reference order (reference 1 is the
|
||||
first entry). Shared context encoding lives in `internal/framework/promptcontext`.
|
||||
An empty `corrected_text` deletes the identified span when the resulting segment
|
||||
remains nonblank. Whitespace-only original spans can express spacing corrections;
|
||||
matching stays literal under each module's replacement policy. No automatic
|
||||
whitespace cleanup follows application.
|
||||
|
||||
## Validator Chain Ownership
|
||||
|
||||
Built-in chains are resolved in `internal/validators` per module key.
|
||||
Module packages call the built-in chain resolver at construction.
|
||||
|
||||
## Failure and Outcome Behavior
|
||||
|
||||
Module construction failures are fatal. Recoverable proposal model failures
|
||||
record an unsuccessful operation and yield no candidates for that section;
|
||||
other sections and module instances continue. Fatal adapter or application
|
||||
failures cancel peers and retain partial observations. Consumer-visible
|
||||
outcomes are defined by the [report contract](../integrations/output-files.md).
|
||||
|
||||
## Changing Modules
|
||||
|
||||
1. Add or update the narrowly scoped package under `internal/modules/<module_key>`.
|
||||
2. Keep module prompt selection in the module and its definition in
|
||||
`internal/prompts`; see [prompt assets](prompts.md).
|
||||
3. Wire module registration and catalog resolution through framework module
|
||||
registration and the core module catalog. Update selectable keys in the
|
||||
[configuration contract](../config.md) when they change.
|
||||
4. Verify replacement policy and validator-chain selection against the
|
||||
[architecture requirements](../policy/architecture.md#correction-and-concurrency-invariants).
|
||||
5. Review module, prompt-variable, and proposal-generation tests. Inspect parity
|
||||
and release fixtures when public output changes, choosing sufficient coverage
|
||||
under the [testing policy](../policy/testing.md).
|
||||
6. Update this document for implementation changes and the appropriate public
|
||||
contract owner for externally visible changes.
|
||||
|
||||
## Key Tests
|
||||
|
||||
- `internal/modules/*/module_test.go`
|
||||
- `internal/framework/modules/registry_test.go`
|
||||
- `internal/framework/proposal_generation/*_test.go`
|
||||
- `internal/cli/run_test.go` (pipeline/report integration)
|
||||
34
docs/internal/output-schemas.md
Normal file
34
docs/internal/output-schemas.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Output Encoding Internals
|
||||
|
||||
## Scope and Ownership
|
||||
|
||||
`internal/core/outputschema` owns encoder registration and resolution. External
|
||||
JSON envelopes and segment fields are defined by the
|
||||
[output-file contract](../integrations/output-files.md#corrected-transcript);
|
||||
selectable values and defaults belong to
|
||||
[configuration](../config.md#settings).
|
||||
|
||||
## Resolution and Encoding
|
||||
|
||||
Configuration validation checks registry support. CLI orchestration resolves the
|
||||
selected encoder, passes the final transcript to it, and routes the encoded bytes
|
||||
to the destination defined by the [CLI contract](../cli.md#streams-and-exit-status).
|
||||
An unsupported key fails validation or resolution rather than selecting an
|
||||
implicit fallback.
|
||||
|
||||
The registry delegates bare segment serialization to the transcript schema
|
||||
package and uses an envelope encoder for the versioned form. Report construction
|
||||
receives the selected key separately; see [report assembly](diagnostics-reporting.md).
|
||||
|
||||
## Changing an Encoder
|
||||
|
||||
Update registration, configuration validation, and serialization together. Inspect
|
||||
round-trip and shape tests, then update the external output-file contract if the
|
||||
serialized form changes. Keep internal helper changes separate from decisions
|
||||
about externally visible compatibility.
|
||||
|
||||
## Key Tests
|
||||
|
||||
- `internal/core/outputschema/registry_test.go`
|
||||
- `internal/core/config/config_test.go`
|
||||
- `internal/cli/run_test.go`
|
||||
97
docs/internal/overview.md
Normal file
97
docs/internal/overview.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Audita Internal Overview
|
||||
|
||||
## Scope
|
||||
|
||||
This document owns the implemented component map. For normative boundaries, see
|
||||
[architecture policy](../policy/architecture.md); for task-specific reading and
|
||||
baseline commands, see the [contributor guide](../development.md).
|
||||
|
||||
## Package Map
|
||||
|
||||
Executable and command orchestration:
|
||||
- `cmd/audita`: executable entry point.
|
||||
- `internal/cli`: argument parsing, config commands, streams, filesystem wiring, and process orchestration.
|
||||
|
||||
Core deterministic components:
|
||||
- `internal/core/config`
|
||||
- `internal/core/schema`
|
||||
- `internal/core/normalization`
|
||||
- `internal/core/chunking`
|
||||
- `internal/core/outputschema`
|
||||
- `internal/core/diagnostics`
|
||||
- `internal/core/reporting`
|
||||
- `internal/core/modulecatalog`
|
||||
|
||||
Framework orchestration and contracts:
|
||||
- `internal/framework/contracts`
|
||||
- `internal/framework/modules`
|
||||
- `internal/framework/proposal_generation`
|
||||
- `internal/framework/proposals`
|
||||
- `internal/framework/runner`
|
||||
- `internal/framework/validators`
|
||||
- `internal/framework/llm`
|
||||
- `internal/framework/responseschema`
|
||||
- `internal/framework/structuredoutput`
|
||||
- `internal/framework/processreport`
|
||||
- `internal/framework/promptcontext`
|
||||
- `internal/framework/stagename`
|
||||
|
||||
Domain implementations:
|
||||
- `internal/modules/*`
|
||||
- `internal/validators/*`
|
||||
- `internal/prompts`
|
||||
|
||||
Supporting areas:
|
||||
- `docs/`: canonical documentation.
|
||||
- `examples/`: maintained copyable inputs and configuration.
|
||||
|
||||
## Current Scope
|
||||
|
||||
Runtime state is held in memory; optional debug artifacts are retained only
|
||||
when requested. Audita does
|
||||
not currently implement a plugin framework, generic workflow engine,
|
||||
resume/checkpoint/manifest system, remote storage, or multi-process service mode.
|
||||
Its role-bound PromptKit adapter implements the structured LLM client contract.
|
||||
These are current implementation boundaries, not bans on future work.
|
||||
|
||||
## Main Execution Path (`audita process`)
|
||||
|
||||
The CLI inspects configuration and profiles, preflights and initializes active
|
||||
outputs, optionally creates debug evidence, invokes the runner, and finalizes
|
||||
transcript and reports.
|
||||
The [pipeline](pipeline.md) owns detailed state transitions; the
|
||||
[operations guide](../operations.md) owns the operator workflow and physical
|
||||
artifact lifecycle.
|
||||
|
||||
## Component Responsibilities
|
||||
|
||||
Core components implement configuration defaults/loading/validation/redaction,
|
||||
transcript and glossary schemas, normalization and chunking, output encoding,
|
||||
diagnostics artifact helpers, and public report structures.
|
||||
|
||||
Framework components implement module and validator contracts, proposal
|
||||
generation and application, prompt context, runner orchestration, PromptKit
|
||||
execution and observation mapping, response schemas, and process-report/correction-ledger assembly.
|
||||
Domain packages provide correction modules, built-in validator chains and
|
||||
execution metadata, and embedded prompt assets.
|
||||
|
||||
These describe the implementation; dependency and ownership requirements belong
|
||||
to the [architecture policy](../policy/architecture.md#ownership-and-dependency-direction).
|
||||
|
||||
## Change Recipes
|
||||
|
||||
- [Configuration, CLI, and example changes](cli-config.md)
|
||||
- [Module changes](modules.md#changing-modules)
|
||||
- [Validator changes](validators.md#changing-validators)
|
||||
- Runtime orchestration changes: use [pipeline](pipeline.md), [LLM runtime](llm-runtime.md),
|
||||
or [diagnostics/reporting](diagnostics-reporting.md) and their test references.
|
||||
|
||||
## Related Internal Docs
|
||||
|
||||
- [`docs/internal/pipeline.md`](pipeline.md)
|
||||
- [`docs/internal/modules.md`](modules.md)
|
||||
- [`docs/internal/validators.md`](validators.md)
|
||||
- [`docs/internal/llm-runtime.md`](llm-runtime.md)
|
||||
- [`docs/internal/diagnostics-reporting.md`](diagnostics-reporting.md)
|
||||
- [`docs/internal/prompts.md`](prompts.md)
|
||||
- [`docs/internal/output-schemas.md`](output-schemas.md)
|
||||
45
docs/internal/pipeline.md
Normal file
45
docs/internal/pipeline.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Audita Internal Pipeline
|
||||
|
||||
The [input contract](../integrations/transcript-glossary-files.md) owns input
|
||||
formats; [configuration](../config.md) owns settings; the
|
||||
[output contract](../integrations/output-files.md) owns serialized results.
|
||||
|
||||
1. CLI filesystem adapters read transcript and glossary files. Schema parsing
|
||||
produces source objects; transcript segments enter canonical normalization.
|
||||
2. Normalization sorts and merges segments using configured time and token
|
||||
limits, reassigning IDs where needed.
|
||||
3. The runner partitions the normalized transcript exactly once before its
|
||||
module loop. Initial section identity, segment membership, and token
|
||||
estimates stay fixed while text evolves.
|
||||
4. Module instances execute in configured order. Sections may propose
|
||||
concurrently, but proposal indices follow section order and response order.
|
||||
5. Deterministic validators precede LLM-backed validators. Every submitted
|
||||
candidate receives one decision per validator on a normal return. Fatal returns
|
||||
may preserve a checked subset of completed decisions as diagnostic evidence.
|
||||
Recoverable failed batches mark their candidates unavailable; successful
|
||||
survivors continue through all required validators.
|
||||
6. Only fully approved proposals reach application. Corrections apply in
|
||||
proposal-index order within their owning section. Existing replacement
|
||||
policies and apply-time safety checks resolve stale conflicts.
|
||||
7. CLI encodes the final transcript and publishes active files through the
|
||||
output session. `framework/processreport` builds one snapshot for YAML,
|
||||
Markdown, and CLI totals. Debug evidence is captured separately when enabled.
|
||||
|
||||
`runner.Run` returns the final working transcript, initial section inventory,
|
||||
explicit `not_started`/`interrupted`/`completed` work units, compact model
|
||||
operation outcomes, and per-module results. Candidate payloads are retained
|
||||
in the returned output only when debug capture is requested. A work unit can
|
||||
complete with model errors and applied corrections. Recoverable model failures
|
||||
never trigger shared cancellation. Fatal setup, internal, application, or
|
||||
parent-cancellation errors cancel peers, join workers, and preserve earlier
|
||||
committed module text for partial reports; no completed transcript is published.
|
||||
|
||||
Required transcript/report write failures are fatal. Optional debug writes
|
||||
report safely to stderr without changing decisions or exit status. See
|
||||
[operations](../operations.md) for file placement and failure handling, and
|
||||
[architecture policy](../policy/architecture.md#correction-and-concurrency-invariants)
|
||||
for invariants.
|
||||
|
||||
Key tests: `internal/framework/runner/*_test.go`,
|
||||
`internal/framework/validators/*_test.go`, and
|
||||
`cmd/audita/main_integration_test.go`.
|
||||
59
docs/internal/prompts.md
Normal file
59
docs/internal/prompts.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Audita Prompt Registry
|
||||
|
||||
`internal/prompts` embeds seven PromptKit YAML definitions under
|
||||
`assets/prompts`. The IDs and selected version remain:
|
||||
|
||||
- `modules.glossary.proposal` (`v1`)
|
||||
- `modules.homophones.proposal` (`v1`)
|
||||
- `modules.spoken_word.proposal` (`v1`)
|
||||
- `modules.grammar.proposal` (`v1`)
|
||||
- `validators.spoken_form_plausibility` (`v1`)
|
||||
- `validators.meaning_reversal_review` (`v1`)
|
||||
- `validators.editorial_review` (`v1`)
|
||||
|
||||
PromptKit reads the embedded definitions and renders their system and user
|
||||
messages from named string variables. The role-bound adapter supplies
|
||||
`HardeningPolicy` alongside `ProposalContract` and `ValidationContract` from
|
||||
embedded fragments under `assets/shared`, after caller variables so callers cannot replace those
|
||||
instructions. Common literal-span and identity guidance lives in the proposal
|
||||
fragment; shared candidate-reference, context, and confidence guidance lives in
|
||||
the validation fragment. Module-specific policies and examples remain in YAML.
|
||||
Proposal prompts receive the section JSON, glossary JSON where used, and transcript description block.
|
||||
Validator prompts receive the correction payload and description block.
|
||||
The prompt assets retain the prior task instructions and output-schema
|
||||
association. The role-bound runtime supplies the complete JSON Schema output contract
|
||||
and repair count; the definition does not own an operator-facing repair default.
|
||||
The correction-set schema requires a string replacement and accepts an empty
|
||||
string. Proposal guidance uses it for eligible span deletion and permits literal
|
||||
spacing edits; validator guidance evaluates the full before/after segment under
|
||||
each validator's existing remit. A blank resulting segment remains a domain
|
||||
rejection, not a structural schema error.
|
||||
|
||||
`internal/framework/responseschema` remains the only embedded source for
|
||||
`correction_set.v1.json` and `validator_decision_set.v1.json`. It exposes that
|
||||
filesystem to PromptKit and retains Audita's schema-key lookup. PromptKit's
|
||||
prepared execution supplies definition and rendered hashes; Audita does not
|
||||
recompute or promise equality with hashes from the removed template renderer.
|
||||
The small Audita registry records only prompt ID, version, source, and embedded
|
||||
path. Prepared runtime metadata belongs in diagnostics rather than the registry.
|
||||
|
||||
The structured-call contract carries prompt ID/version, string variables,
|
||||
response-schema key, and logical-call attribution. Module and validator callers
|
||||
pass these values through the role-bound adapter. See the
|
||||
[LLM runtime](llm-runtime.md) for runtime assembly and
|
||||
[configuration](../config.md) for operator-selected profiles.
|
||||
|
||||
Proposal instructions describe literal matching, each module's replacement policy,
|
||||
source-based proposal identity, and confidence in whether an edit is warranted.
|
||||
Proposal `id` and validator `correction_index` values are short, one-based
|
||||
references scoped to each request, not internal transcript/proposal identities.
|
||||
Mapping belongs to [proposal generation](modules.md) and
|
||||
[validator reconciliation](validators.md). Validator instructions distinguish
|
||||
confidence in the verdict from the verdict itself. Compact output examples
|
||||
illustrate the supplied schema without requiring fixed JSON formatting or key
|
||||
order. The grammar article exception and glossary mishearing exception apply
|
||||
consistently across their instructions.
|
||||
|
||||
Only the three active validator definitions are retained. The unused internal
|
||||
`grammar_review` and `spoken_word_review` definitions and type selections were
|
||||
removed; built-in chains and operator configuration are unchanged.
|
||||
156
docs/internal/validators.md
Normal file
156
docs/internal/validators.md
Normal file
@@ -0,0 +1,156 @@
|
||||
# Audita Validators
|
||||
|
||||
## Scope
|
||||
|
||||
This document describes internal validator composition, execution order, and
|
||||
decision handling. These registry keys identify implementation components; they
|
||||
are not independently selectable through [configuration](../config.md#settings).
|
||||
|
||||
## Ownership
|
||||
|
||||
Built-in validator keys and chains:
|
||||
- `internal/validators`
|
||||
|
||||
Shared validator runtime mechanics:
|
||||
- `internal/framework/validators`
|
||||
|
||||
Execution-class metadata:
|
||||
- `internal/validators/metadata`
|
||||
|
||||
## Built-In Validator Keys
|
||||
|
||||
Deterministic:
|
||||
- `proposal_shape`
|
||||
- `confidence_threshold`
|
||||
- `original_text_presence`
|
||||
- `non_empty_resulting_segment` — rejects edits that would leave the segment
|
||||
blank, regardless of replacement-span length.
|
||||
- `no_effect`
|
||||
- `protected_terms`
|
||||
|
||||
LLM-backed:
|
||||
- `spoken_form_plausibility`
|
||||
- `meaning_reversal_review`
|
||||
- `editorial_review`
|
||||
|
||||
## Built-In Chains
|
||||
|
||||
Module chains are defined in `internal/validators/chains.go`.
|
||||
Glossary, homophones, spoken_word, and grammar each resolve a fixed ordered chain.
|
||||
|
||||
## Runtime Execution
|
||||
|
||||
For each module section:
|
||||
1. run deterministic validators;
|
||||
2. run LLM-backed validators;
|
||||
3. record decisions and compact operation outcomes;
|
||||
4. carry only approved proposals forward.
|
||||
|
||||
Decision cardinality is enforced inside Audita: each candidate proposal must
|
||||
receive exactly one outcome per validator it reaches. The runner still rejects
|
||||
duplicate, missing, or unknown identities in an internal validator result.
|
||||
|
||||
## LLM Validator Batching
|
||||
|
||||
LLM validators:
|
||||
- build canonical validation request payloads;
|
||||
- batch using `validation.max_prompt_tokens` and the existing domain token estimator;
|
||||
- select an embedded prompt ID and pass payload/description variables to the
|
||||
role-bound structured client with the validator-decision schema.
|
||||
|
||||
Oversized single inputs are rejected with a consolidated
|
||||
`validation_input_too_large` operation, without a provider call. Recoverable
|
||||
model failures make only their batch candidates unavailable while other
|
||||
batches continue. PromptKit validates each complete response against the
|
||||
validator-decision JSON Schema and performs configured structural repair before
|
||||
Audita receives decoded decisions. Each actual batch presents candidates
|
||||
numbered from 1, independent of their internal proposal indices. Audita then
|
||||
reconciles those local references: one usable entry keeps its
|
||||
approval or editorial rejection; a missing or duplicate requested entry makes
|
||||
only that candidate unavailable; unexpected indices are ignored. An empty list
|
||||
makes all requested candidates unavailable. Decisions and unavailable indices
|
||||
map back to internal proposal identities; results are ordered by request identity
|
||||
and satisfy strict internal cardinality before the runner advances
|
||||
approved candidates. An unavailable candidate never advances as approved.
|
||||
Invalid confidence in a decoded test double also makes only its candidate
|
||||
unavailable; production schema validation still rejects out-of-range confidence
|
||||
before reconciliation. A partially unavailable batch records one failed
|
||||
operation with only those requested indices, while a successful batch with
|
||||
ignored extras records a decision-filtering recovery. Fatal errors stop the
|
||||
chain without returning unchecked candidates as approved. A local result builder
|
||||
retains already-collected decisions and operations on early returns; full
|
||||
cardinality checks and final sorting remain explicit on completed paths.
|
||||
Reconciliation makes no semantic retry or extra model call; guided recovery remains
|
||||
[deferred](../roadmap/future.md#domain-aware-response-recovery).
|
||||
|
||||
Debug request metadata records `proposal_indices` in local-reference order
|
||||
(reference 1 is the first entry). Raw decoded responses and ignored indices use
|
||||
local references; reconciled decisions and unavailable indices use internal
|
||||
proposal indices. Batch token estimates use the same locally numbered payload
|
||||
as prompt encoding.
|
||||
|
||||
## Decision and Rejection Reporting
|
||||
|
||||
Runner collects decisions, rejected candidates, and operation outcomes. Ledger
|
||||
assembly groups decisions by deterministic versus LLM-backed execution metadata.
|
||||
The serialized names and fields belong to the
|
||||
[report and ledger contract](../integrations/output-files.md); implementation mapping
|
||||
is covered by [report assembly](diagnostics-reporting.md).
|
||||
|
||||
## Changing Validators
|
||||
|
||||
1. Implement validator behavior under `internal/validators/<validator_key>`;
|
||||
update registry and chain wiring in `internal/validators`.
|
||||
2. Put shared runtime mechanics in `internal/framework/validators` only when
|
||||
needed. Keep deterministic versus LLM-backed execution metadata explicit.
|
||||
3. Preserve exposed identities and decision semantics under the
|
||||
[architecture policy](../policy/architecture.md#correction-and-concurrency-invariants).
|
||||
4. Review validator, registry, chain, batching, malformed-output, diagnostics,
|
||||
and decision-cardinality tests; update meaningful coverage under the
|
||||
[testing policy](../policy/testing.md).
|
||||
5. Update implementation guidance here and any affected external contract in its
|
||||
[canonical owner](../policy/documentation.md#canonical-ownership).
|
||||
|
||||
## Key Tests
|
||||
|
||||
- `internal/validators/*_test.go`
|
||||
- `internal/framework/validators/*_test.go`
|
||||
- `internal/framework/processreport/correction_ledger_test.go`
|
||||
- `internal/cli/run_test.go`
|
||||
|
||||
## Supplemental Validation Context
|
||||
|
||||
Request construction prepares one segment-position lookup and protected vocabulary
|
||||
for all candidates. Glossary selection remains candidate-specific, including the
|
||||
proposed replacement text.
|
||||
|
||||
Each candidate includes the immediately preceding and following source segments
|
||||
available within its fixed chunk, labeled `preceding` or `following` with speaker,
|
||||
text, and categories, plus glossary entries whose names, aliases, or
|
||||
recognized plurals appear in its original/resulting text or those neighbors.
|
||||
Glossary matching reuses the protected vocabulary; entries retain glossary order.
|
||||
Model-facing candidate and neighboring context omit internal segment IDs.
|
||||
This supplies evidence such as a troupe definition for a proposed `Jesters`
|
||||
correction or an adjacent speaker turn explaining deliberate repetition. A correction
|
||||
already clear from its own segment does not require such evidence. No audio,
|
||||
out-of-chunk context, or complete transcript is implied.
|
||||
|
||||
Context is serialized inside the validation item and included in the existing
|
||||
payload token estimate. If one enriched item exceeds the configured limit, optional
|
||||
neighbors are removed from the end first, then glossary entries from the end,
|
||||
until it fits or only required candidate data remains. Required before/after text
|
||||
is never truncated. Existing oversized-candidate handling still applies if that
|
||||
required data does not fit. Context is supplemental, not a promise that every
|
||||
relevant definition or neighboring utterance always fits. This uses the existing
|
||||
payload estimator, not a new guarantee about the provider's full context window.
|
||||
|
||||
## Protected-Name Repetition
|
||||
|
||||
Spoken-word cleanup may reduce repeated protected-name occurrences when every
|
||||
original protected identity still appears in the resulting segment and surviving
|
||||
spellings satisfy existing capitalization checks. Full-segment preview supports
|
||||
both a replacement of the repeated phrase and deletion of a redundant span. This
|
||||
exception only relaxes the deterministic count guard; editorial and meaning-reversal
|
||||
validation still decide whether the repetition was accidental and the edit preserves
|
||||
meaning. Intentional emphasis and substantive references remain protected by those
|
||||
reviews. Other modules retain their existing protection rules.
|
||||
135
docs/migrations/v2.md
Normal file
135
docs/migrations/v2.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# Migrating to Audita v2
|
||||
|
||||
Audita v2 adopts ConfigKit for configuration and PromptKit for LLM execution.
|
||||
Version-1 configuration files, environment overlays, and retired flags are not
|
||||
accepted. Copy a maintained [local](../../examples/minimal-config.yml) or
|
||||
[service](../../examples/production-config.yml) example, then select real models
|
||||
in the accompanying `examples/profiles/` files. A testing overlay is shown at
|
||||
`examples/overlays/testing.yml`; its model choice carries no cost, speed, or
|
||||
quality guarantee.
|
||||
|
||||
## Configuration and invocation
|
||||
|
||||
Use `version: 2` in a YAML main file. `--config` selects that file; otherwise
|
||||
`process` and `config print-effective` look at
|
||||
`/usr/local/etc/audita/config.yml`, then `/etc/audita/config.yml`.
|
||||
`config validate` requires `--config`. `AUDITA_CONFIG` no longer selects a file.
|
||||
Settings resolve from defaults, main file, optional `--overlay <name>` in
|
||||
`overlays/<name>.yml`, then explicitly supplied setting flags. General `AUDITA_*`
|
||||
environment overlays no longer apply. Unknown fields and version-1 files fail;
|
||||
there is no automatic converter.
|
||||
|
||||
Keep transcript as the positional path and `--glossary` and `--output` as
|
||||
invocation paths. The former `--report-json` output has been replaced by the
|
||||
default `errors.yml`, `recoveries.yml`, and `report.md` bundle; use
|
||||
`--reporting=false` to disable it or `--report-dir` for stdout output. Keep
|
||||
`pipeline.modules` / `--modules` and
|
||||
`output.schema` / `--output-schema`. An explicit `pipeline.modules: []` or
|
||||
`--modules ''` runs no correction modules; omission uses the default sequence.
|
||||
Ordered repetitions still matter.
|
||||
|
||||
Move `llm.proposal.base_url` and `llm.validation.base_url` to a shared
|
||||
`backends.<id>.endpoint` when both roles use one service. Move old role models to
|
||||
PromptKit profile files and select them with `llm.proposal_profile` and
|
||||
`llm.validation_profile`, or `--proposal-profile` and
|
||||
`--validation-profile`. Omitted validation selection inherits the final proposal
|
||||
selection; explicit empty or null is invalid. `profiles_dir` defaults to
|
||||
`profiles` beside the main config. Complete profiles name a registered backend
|
||||
and model. Per-role `--base-url`, `--validation-base-url`, `--model`, and
|
||||
`--validation-model` are retired.
|
||||
|
||||
Move old `llm.*.api_key_env` to `backends.<id>.credential`, a scalar name of a
|
||||
nonempty environment variable, such as `credential: AUDITA_SERVICE_KEY`.
|
||||
Credentials on every surviving backend must resolve, including unselected
|
||||
backends. Omit or set null for an unauthenticated local backend. Profiles cannot
|
||||
perform another key lookup. `--llm-api-key` and `--validation-llm-api-key` are
|
||||
retired. `AUDITA_LLM_API_KEY`, `OPENROUTER_API_KEY`, and
|
||||
`AUDITA_VALIDATION_LLM_API_KEY` have no implicit meaning, though any of those
|
||||
names can be used explicitly as a credential reference.
|
||||
|
||||
Replace `concurrency.total_llm`, `.proposal_llm`, and `.validation_llm` plus
|
||||
`--total-llm-concurrency`, `--llm-concurrency`,
|
||||
`--proposal-llm-concurrency`, and `--validation-llm-concurrency` with
|
||||
`backends.<id>.concurrency` (default 1) and optional `queue_capacity` (default
|
||||
1024; zero means no waiting admission). One backend capacity is shared by both
|
||||
roles and all retry/repair attempts within this Audita process. It does not
|
||||
coordinate other processes.
|
||||
|
||||
Move old role `timeout` values and `--llm-timeout-seconds` /
|
||||
`--validation-llm-timeout-seconds` to profile `timeout_seconds`, a per-attempt
|
||||
limit, and `llm.operation_timeout`, a Go duration such as `15m` covering the
|
||||
whole logical call. Replace old `max_retries` and `--max-retries` /
|
||||
`--validation-max-retries` with common `llm.transient_retries` (additional
|
||||
eligible attempts per generation) and `llm.repair_attempts` (additional
|
||||
generations for structurally invalid JSON). Explicit zero disables either
|
||||
feature. Cancellation and the operation deadline cover capacity waiting,
|
||||
backoff, generation, and repairs. PromptKit owns which failures can retry or
|
||||
repair; Audita does not retry semantic rejections.
|
||||
|
||||
The following domain settings and explicit flags retain their meaning:
|
||||
|
||||
| File field | Explicit flag |
|
||||
| --- | --- |
|
||||
| `validation.max_prompt_tokens` | `--validation-max-prompt-tokens` |
|
||||
| `chunking.target_sections` | `--target-sections` |
|
||||
| `chunking.max_section_tokens`, `.min_section_tokens` | `--max-section-tokens`, `--min-section-tokens` |
|
||||
| `normalization.max_segment_gap`, `.ellipsis_gap`, `.max_segment_duration`, `.max_segment_tokens` | `--normalize-max-segment-gap`, `--normalize-ellipsis-gap`, `--normalize-max-segment-duration`, `--normalize-max-segment-tokens` |
|
||||
| `thresholds.glossary`, `.homophones`, `.spoken_word`, `.grammar` | `--glossary-confidence-threshold`, `--homophones-confidence-threshold`, `--spoken-word-confidence-threshold`, `--grammar-confidence-threshold` |
|
||||
| `context.description` | `--transcript-description` |
|
||||
| `reporting.enabled`, `.stdout_dir` | `--reporting[=true\|false]`, `--report-dir` |
|
||||
| `diagnostics.debug`, `.work_dir` | `--debug[=true\|false]`, `--work-dir` |
|
||||
|
||||
Normalization gaps and durations are **numeric seconds**, so replace `4s`,
|
||||
`3.5s`, and `60s` with `4.0`, `3.5`, and `60.0`. The operation timeout remains a
|
||||
Go duration string. `chunking.target_sections` may be omitted or null for
|
||||
automatic chunking; zero is invalid. Null is not a general synonym for omission:
|
||||
nonoptional scalar settings reject it. Empty `context.description` clears
|
||||
context. Legacy `diagnostics.retention` and `--work-dir-retention` are removed.
|
||||
Debug is off by default and its directory is retained whenever enabled.
|
||||
|
||||
Remove old implicit variables `AUDITA_MODULES`, `AUDITA_MODEL`,
|
||||
`AUDITA_VALIDATION_MODEL`, `AUDITA_BASE_URL`, `AUDITA_VALIDATION_BASE_URL`,
|
||||
`AUDITA_LLM_TIMEOUT_SECONDS`, `AUDITA_VALIDATION_LLM_TIMEOUT_SECONDS`,
|
||||
`AUDITA_MAX_RETRIES`, `AUDITA_VALIDATION_MAX_RETRIES`,
|
||||
`AUDITA_TOTAL_LLM_CONCURRENCY`, `AUDITA_LLM_CONCURRENCY`,
|
||||
`AUDITA_PROPOSAL_LLM_CONCURRENCY`, `AUDITA_VALIDATION_LLM_CONCURRENCY`,
|
||||
`AUDITA_VALIDATION_MAX_PROMPT_TOKENS`, `AUDITA_TARGET_SECTIONS`,
|
||||
`AUDITA_MAX_SECTION_TOKENS`, `AUDITA_MIN_SECTION_TOKENS`,
|
||||
`AUDITA_NORMALIZE_MAX_SEGMENT_GAP`, `AUDITA_NORMALIZE_ELLIPSIS_GAP`,
|
||||
`AUDITA_NORMALIZE_MAX_SEGMENT_DURATION`, `AUDITA_NORMALIZE_MAX_SEGMENT_TOKENS`,
|
||||
`AUDITA_GLOSSARY_CONFIDENCE_THRESHOLD`,
|
||||
`AUDITA_HOMOPHONES_CONFIDENCE_THRESHOLD`,
|
||||
`AUDITA_SPOKEN_WORD_CONFIDENCE_THRESHOLD`,
|
||||
`AUDITA_GRAMMAR_CONFIDENCE_THRESHOLD`, `AUDITA_WORK_DIR`, and
|
||||
`AUDITA_WORK_DIR_RETENTION`. Put those values in the named fields above or pass
|
||||
their surviving explicit flags.
|
||||
|
||||
## Inspecting and operating
|
||||
|
||||
Run `audita config validate --config <file>` before processing. Use
|
||||
`audita config print-effective --config <file> --view settings|profiles|explain`
|
||||
to inspect redacted ConfigKit YAML, selected PromptKit profile controls, or
|
||||
field origins and derivations. Each view resolves both roles offline without
|
||||
calling a provider. `--overlay testing` selects the same overlay for validation,
|
||||
inspection, and processing. The old effective-config JSON format is replaced by
|
||||
YAML; settings YAML alone does not show profile-owned model controls.
|
||||
|
||||
The [ordinary output contract](../integrations/output-files.md) now uses
|
||||
version-1 `audita-errors` and `audita-recoveries` YAML documents plus a fixed
|
||||
Markdown overview. Compact outcomes distinguish logical operations from
|
||||
provider attempts. With debug enabled, utilization remains grouped by backend
|
||||
capacity and usage fields retain known/complete flags. Debug runs write
|
||||
`effective-config.redacted.yaml`, `selected-profiles.yaml`,
|
||||
`config-origins.yaml`, `utilization-diagnostics.json`, and
|
||||
`llm-execution.json`. Request and response artifacts remain redacted debugging
|
||||
material. See [operations](../operations.md#diagnostics-directory) for placement
|
||||
and paths, [configuration](../config.md) for all settings, and the
|
||||
[CLI reference](../cli.md) for current flags.
|
||||
|
||||
Debug ledger consumers should recognize the deterministic validator key
|
||||
`non_empty_resulting_segment` in place of `non_empty_corrected_text`. The
|
||||
`empty_resulting_segment` reason is unchanged. Candidate-backed ledger entries
|
||||
now include `proposed_corrected_text: ""` for an empty replacement, and applied
|
||||
deletions also include `applied_corrected_text: ""`; omitted fields still mean
|
||||
there was no candidate or no applied edit, respectively. See the
|
||||
[debug artifact contract](../integrations/output-files.md#debug-only-files).
|
||||
83
docs/operations.md
Normal file
83
docs/operations.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# Audita Operations
|
||||
|
||||
This guide owns physical output placement and failure handling. The
|
||||
[CLI reference](cli.md) owns flags and streams, [configuration](config.md) owns
|
||||
settings, and the [output contract](integrations/output-files.md) owns schemas.
|
||||
|
||||
## Normal Workflow
|
||||
|
||||
1. Validate a version-2 configuration and its selected profiles with
|
||||
`audita config validate --config config.yml`.
|
||||
2. Prepare a transcript and glossary following the [input contract](integrations/transcript-glossary-files.md).
|
||||
3. Run `audita process input.json --config config.yml --glossary glossary.yaml --output corrected.json`.
|
||||
4. Check the exit status, stderr summary, corrected transcript, and reports.
|
||||
A completed run can contain recoverable model errors and still apply
|
||||
corrections that passed every required validator.
|
||||
|
||||
## Required Output Files
|
||||
|
||||
Reporting is enabled by default. For file transcript output, `errors.yml`,
|
||||
`recoveries.yml`, and `report.md` go in the transcript output's parent directory.
|
||||
For stdout transcript output, they go in `reporting.stdout_dir` (default `.`),
|
||||
overridden by `--report-dir`. `--reporting=false` suppresses all three reports
|
||||
and removes their path requirements. It does not suppress the stderr summary or
|
||||
fatal errors. Stdout contains only transcript JSON; file output leaves it empty.
|
||||
|
||||
Existing report directories and parents for regular transcript files must be
|
||||
writable. Audita prevents report writes from overwriting transcript, glossary,
|
||||
loaded configuration, or loaded profile sources, and rejects conflicting output
|
||||
destinations. The final transcript may intentionally replace its own input after
|
||||
successful processing; other input/configuration/profile sources remain protected.
|
||||
Preparation never truncates an existing transcript. Device and pipe destinations
|
||||
(such as `/dev/null` and named pipes) receive ordinary writes at publication time;
|
||||
they are not opened during preflight or replaced with regular files. A pipe write
|
||||
can wait for its reader, and stream write errors are fatal. With reporting enabled,
|
||||
reports still use the output path's parent; disable reporting when that placement
|
||||
is unsuitable for a stream destination.
|
||||
|
||||
With reporting enabled, all three reports are initialized as `in_progress` before
|
||||
input processing. Output is encoded fully before publication. Each regular output
|
||||
file is replaced through a temporary file on its destination filesystem:
|
||||
transcript first, then `errors.yml`,
|
||||
`recoveries.yml`, and `report.md`. This is per-file replacement, not a
|
||||
multi-file transaction. New files honor the process umask; replacing an existing
|
||||
file preserves its permission bits. A late report error may leave the transcript
|
||||
published; the process exits nonzero and attempts failed-status reports. On fatal processing
|
||||
or cancellation, no completed transcript is published, but partial reports are
|
||||
finalized where possible. An uncatchable termination can leave `in_progress`.
|
||||
|
||||
## Diagnostics Directory
|
||||
|
||||
`--debug` enables detailed evidence independently of reporting. One directory
|
||||
named `run-<id>` is created under `diagnostics.work_dir` (default `/tmp/audita`)
|
||||
and retained on success or failure. Without debug, no directory or payload
|
||||
files are created. The parent is created when needed only for debug. Failure to
|
||||
write optional debug evidence prints a redacted stderr diagnostic but does not
|
||||
change correction decisions or the exit status.
|
||||
|
||||
Debug evidence includes invocation and effective settings, configuration
|
||||
origins, selected profiles, redacted source and normalized snapshots,
|
||||
normalization and initial chunk summaries, all captured proposed candidates
|
||||
and validator decisions in `correction-ledger.json`, execution/utilization
|
||||
records, and model interaction files. Individual artifact writes can fail; a
|
||||
directory's existence does not prove every file was written. These files can
|
||||
contain transcript text and prompt/response payloads. Configured backend
|
||||
credentials are redacted, but the transcript itself is not anonymized. Protect
|
||||
and retain the directory according to the sensitivity of the input.
|
||||
|
||||
## Failure Inspection and Recovery
|
||||
|
||||
Exit `0` means processing and every enabled required output completed. Exit
|
||||
`1` means cancellation, fatal processing, or required-output failure. Exit `2`
|
||||
identifies usage or configuration/destination selection errors. Recoverable
|
||||
model-operation failures appear in `errors.yml` as one record per affected
|
||||
work unit; they do not automatically make the run fail. `recoveries.yml`
|
||||
records successful operations that needed retry, repair, or proposal filtering.
|
||||
`report.md` shows every initial chunk and configured module instance, including
|
||||
interrupted and unattempted work. Ordinary reports omit transcript excerpts and
|
||||
full decision ledgers; enable debug when those are needed.
|
||||
|
||||
Read stderr and report status first. If a required output failed after a
|
||||
transcript was published, do not treat the file alone as proof of a completed
|
||||
run. Fix the input, service, or destination problem and rerun. Audita has no
|
||||
resume/checkpoint API.
|
||||
204
docs/oss/attribution.md
Normal file
204
docs/oss/attribution.md
Normal file
@@ -0,0 +1,204 @@
|
||||
# Open Source Attribution Notices
|
||||
|
||||
## Standard Repository Policies
|
||||
|
||||
Material: All documents under `docs/policy/`, root `AGENTS.md`, and the Policy Reading Guide in `docs/development.md`, adapted for this repository.
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0
|
||||
|
||||
License and notices: [CC BY-SA 4.0](licenses/CC-BY-SA-4.0.txt) |
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/COPYRIGHT) |
|
||||
[LICENSE](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/LICENSE).
|
||||
|
||||
[Source](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843).
|
||||
|
||||
## ConfigKit
|
||||
|
||||
Selected module: `gitea.maximumdirect.net/eric/ConfigKit` at `v0.4.2`.
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
License and notices: [LGPL v3](licenses/LGPL-3.0.txt) |
|
||||
[GPL v3](licenses/GPL-3.0.txt) |
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/67c03690181c5af8dde6be325abac241dae6732f/COPYRIGHT).
|
||||
|
||||
[Source](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/67c03690181c5af8dde6be325abac241dae6732f).
|
||||
|
||||
## Go runtime and standard library
|
||||
|
||||
Selected toolchain: Go 1.25.5 for the distributed Linux binaries.
|
||||
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-Go.txt) |
|
||||
[LICENSE](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/go/commit/fefb02adf45c4bcc879bd406a8d61f2a292c26a9).
|
||||
|
||||
## Go vendored golang.org/x/crypto
|
||||
|
||||
Material: `golang.org/x/crypto` at `v0.39.0` in the Go 1.25.5 standard library.
|
||||
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-Go.txt) |
|
||||
[LICENSE](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/crypto/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/crypto/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/go/commit/fefb02adf45c4bcc879bd406a8d61f2a292c26a9).
|
||||
|
||||
## Go vendored golang.org/x/net
|
||||
|
||||
Material: `golang.org/x/net` at `v0.41.0` in the Go 1.25.5 standard library.
|
||||
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-Go.txt) |
|
||||
[LICENSE](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/net/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/net/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/go/commit/fefb02adf45c4bcc879bd406a8d61f2a292c26a9).
|
||||
|
||||
## Go vendored golang.org/x/sys
|
||||
|
||||
Material: `golang.org/x/sys` at `v0.33.0` in the Go 1.25.5 standard library.
|
||||
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-Go.txt) |
|
||||
[LICENSE](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/sys/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/sys/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/go/commit/fefb02adf45c4bcc879bd406a8d61f2a292c26a9).
|
||||
|
||||
## Go vendored golang.org/x/text
|
||||
|
||||
Material: `golang.org/x/text` at `v0.26.0` in the Go 1.25.5 standard library.
|
||||
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-Go.txt) |
|
||||
[LICENSE](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/text/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/go/blob/fefb02adf45c4bcc879bd406a8d61f2a292c26a9/src/vendor/golang.org/x/text/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/go/commit/fefb02adf45c4bcc879bd406a8d61f2a292c26a9).
|
||||
|
||||
## go-yaml v4
|
||||
|
||||
Selected module: `go.yaml.in/yaml/v4` at `v4.0.0-rc.6`.
|
||||
|
||||
Copyright 2006-2010 Kirill Simonov
|
||||
|
||||
Copyright 2011-2019 Canonical Ltd
|
||||
|
||||
Copyright 2025 The go-yaml Project Contributors
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 AND MIT
|
||||
|
||||
License and notices: [Apache 2.0](licenses/Apache-2.0.txt) |
|
||||
[MIT](licenses/MIT-libyaml-v4.txt) |
|
||||
[NOTICE](https://github.com/yaml/go-yaml/blob/1c17b9cee72bf81ae73a8be50fbd7dd3a9985125/NOTICE).
|
||||
|
||||
[Source](https://github.com/yaml/go-yaml/commit/1c17b9cee72bf81ae73a8be50fbd7dd3a9985125).
|
||||
|
||||
## golang.org/x/text
|
||||
|
||||
Selected module: `golang.org/x/text` at `v0.14.0`.
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause-x-text.txt) |
|
||||
[LICENSE](https://github.com/golang/text/blob/6c97a165dd661335ff7bce6104a008558123c353/LICENSE) |
|
||||
[PATENTS](https://github.com/golang/text/blob/6c97a165dd661335ff7bce6104a008558123c353/PATENTS).
|
||||
|
||||
[Source](https://github.com/golang/text/commit/6c97a165dd661335ff7bce6104a008558123c353).
|
||||
|
||||
## jsonschema/v6
|
||||
|
||||
Selected module: `github.com/santhosh-tekuri/jsonschema/v6` at `v6.0.2`.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
License and notices: [Apache 2.0](licenses/Apache-2.0.txt).
|
||||
|
||||
[Source](https://github.com/santhosh-tekuri/jsonschema/commit/29cbed948d24a04700eb94436416b18a07953b71).
|
||||
|
||||
## PromptKit
|
||||
|
||||
Selected module: `gitea.maximumdirect.net/eric/promptkit` at `v0.11.2`.
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
License and notices: [LGPL v3](licenses/LGPL-3.0.txt) |
|
||||
[GPL v3](licenses/GPL-3.0.txt) |
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit/src/commit/12d6d80024e80c552d122a076c22429bf6f2f6c2/COPYRIGHT).
|
||||
|
||||
[Source](https://gitea.maximumdirect.net/eric/promptkit/src/commit/12d6d80024e80c552d122a076c22429bf6f2f6c2).
|
||||
|
||||
## Promptkit OpenRouter Catalog
|
||||
|
||||
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2` at `v2.20260926.0`.
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
|
||||
License and notices: [MIT](licenses/MIT-Catalogs.txt) |
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3/COPYRIGHT) |
|
||||
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3/LICENSE).
|
||||
|
||||
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3).
|
||||
|
||||
## Promptkit Rakestrawhome Catalog
|
||||
|
||||
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2` at `v2.20260926.0`.
|
||||
|
||||
Copyright (C) 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
|
||||
License and notices: [MIT](licenses/MIT-Catalogs.txt) |
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596/COPYRIGHT) |
|
||||
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596/LICENSE).
|
||||
|
||||
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596).
|
||||
|
||||
## yaml.v3
|
||||
|
||||
Selected module: `gopkg.in/yaml.v3` at `v3.0.1`.
|
||||
|
||||
Copyright (c) 2006-2010 Kirill Simonov
|
||||
|
||||
Copyright (c) 2006-2011 Kirill Simonov
|
||||
|
||||
Copyright (c) 2011-2019 Canonical Ltd
|
||||
|
||||
Copyright 2011-2016 Canonical Ltd.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 AND MIT
|
||||
|
||||
License and notices: [Apache 2.0](licenses/Apache-2.0.txt) |
|
||||
[MIT](licenses/MIT-libyaml.txt) |
|
||||
[LICENSE](https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/LICENSE) |
|
||||
[NOTICE](https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/NOTICE).
|
||||
|
||||
[Source](https://github.com/go-yaml/yaml/commit/f6f7691b1fdeb513f56608cd2c32c51f8194bf51).
|
||||
202
docs/oss/licenses/Apache-2.0.txt
Normal file
202
docs/oss/licenses/Apache-2.0.txt
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
27
docs/oss/licenses/BSD-3-Clause-Go.txt
Normal file
27
docs/oss/licenses/BSD-3-Clause-Go.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright 2009 The Go Authors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google LLC nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
27
docs/oss/licenses/BSD-3-Clause-x-text.txt
Normal file
27
docs/oss/licenses/BSD-3-Clause-x-text.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
170
docs/oss/licenses/CC-BY-SA-4.0.txt
Normal file
170
docs/oss/licenses/CC-BY-SA-4.0.txt
Normal file
@@ -0,0 +1,170 @@
|
||||
Creative Commons Attribution-ShareAlike 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
|
||||
|
||||
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described.
|
||||
|
||||
Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
Section 1 – Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
|
||||
|
||||
h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
|
||||
Section 2 – Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part; and
|
||||
|
||||
B. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
|
||||
C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
|
||||
|
||||
Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
|
||||
Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
|
||||
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
674
docs/oss/licenses/GPL-3.0.txt
Normal file
674
docs/oss/licenses/GPL-3.0.txt
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
165
docs/oss/licenses/LGPL-3.0.txt
Normal file
165
docs/oss/licenses/LGPL-3.0.txt
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
18
docs/oss/licenses/MIT-Catalogs.txt
Normal file
18
docs/oss/licenses/MIT-Catalogs.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Eric Rakestraw
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
19
docs/oss/licenses/MIT-libyaml-v4.txt
Normal file
19
docs/oss/licenses/MIT-libyaml-v4.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2010 Kirill Simonov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
20
docs/oss/licenses/MIT-libyaml.txt
Normal file
20
docs/oss/licenses/MIT-libyaml.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2006-2010 Kirill Simonov
|
||||
Copyright (c) 2006-2011 Kirill Simonov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
101
docs/policy/agents.md
Normal file
101
docs/policy/agents.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Agent Policy
|
||||
|
||||
**Base Policy Version:** 1.3
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies agents](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/agents.md)
|
||||
|
||||
## Purpose
|
||||
|
||||
Agents must read and follow these rules.
|
||||
|
||||
## Implementation Discipline
|
||||
|
||||
**KEY PRINCIPLES:** Write the simplest idiomatic code that satisfies the user's
|
||||
request. Do not implicitly strengthen requirements, restrictions, or guarantees
|
||||
beyond what the user actually requested.
|
||||
|
||||
**Keep implementation machinery proportionate.** Use straightforward,
|
||||
idiomatic code and introduce only the machinery needed to support the requested
|
||||
behavior and flexibility. Optimize for conceptual simplicity and
|
||||
maintainability, not for the fewest lines, fewest options, or narrowest product
|
||||
surface.
|
||||
|
||||
**Do not invent restrictions.** Do not reject, prohibit, constrain, cap,
|
||||
harden, or otherwise narrow behavior unless required by the user, an explicit
|
||||
repository contract, or an unavoidable correctness constraint. Preserve
|
||||
operator and caller choice where policy has not been established. If an
|
||||
additional restriction appears advisable, present it as a decision rather than
|
||||
silently implementing it.
|
||||
|
||||
**Do not invent guarantees.** Do not strengthen public contracts, guarantees,
|
||||
or invariants beyond those expressly requested by the user.
|
||||
|
||||
**Use the standard library.** For example: in almost every case, the best
|
||||
approach to copying files is to use the standard library. Writing custom code to
|
||||
implement power-loss protection at the application level, or to guard against
|
||||
bad actors with privileged and concurrent access to the host's filesystem,
|
||||
is wasteful, unnecessary, and not idiomatic. Stick to the simple, standard, and
|
||||
idiomatic approach unless another path is expressly requested by the user.
|
||||
|
||||
**An implementation detail is not repository policy.** Tests and documentation
|
||||
must not elevate incidental behavior into a durable guarantee or restriction
|
||||
unless that behavior was expressly selected as part of the contract.
|
||||
|
||||
## Codebase Discovery
|
||||
|
||||
This project uses codebase-memory-mcp to maintain a knowledge graph of the
|
||||
codebase. Always prefer its graph tools over grep, glob, or file search for code discovery.
|
||||
If the project is not indexed, run `index_repository` first.
|
||||
|
||||
Use this order:
|
||||
|
||||
1. `search_graph` to find functions, classes, routes, and variables by pattern.
|
||||
2. `trace_path` to trace callers and callees.
|
||||
3. `get_code_snippet` to read a specific function or class.
|
||||
4. `query_graph` for complex graph queries.
|
||||
5. `get_architecture` for the high-level project summary.
|
||||
|
||||
Fall back to grep or glob for string literals, error messages, configuration
|
||||
values, non-code files, or when the graph tools return insufficient results.
|
||||
|
||||
Examples:
|
||||
|
||||
- Find a handler: `search_graph(name_pattern=".*OrderHandler.*")`.
|
||||
- Find callers: `trace_path(function_name="OrderHandler", direction="inbound")`.
|
||||
- Read source: `get_code_snippet(qualified_name="pkg/orders.OrderHandler")`.
|
||||
|
||||
## Git Commit Policy
|
||||
|
||||
By default, commit each completed, nonempty unit of work using a
|
||||
concise, plain-English message describing what changed. This policy is standing
|
||||
authorization to create those local commits; a separate user request is not
|
||||
required. An explicit user instruction to leave work uncommitted takes precedence.
|
||||
|
||||
A unit of work is a focused, reviewable outcome, including its relevant tests and
|
||||
documentation.
|
||||
Complete the appropriate validation before committing. If work is incomplete or
|
||||
validation is blocked, report that state accurately.
|
||||
|
||||
Before committing:
|
||||
|
||||
1. Run `git status --short` and review the relevant diff, including any staged
|
||||
changes. Identify changes that predate the current unit of work.
|
||||
2. Exclude secrets, local environment files, generated junk, and unrelated changes.
|
||||
3. Stage only the files or hunks belonging to the completed unit. Use `git add .`
|
||||
only when every included change belongs to that unit. Preserve unrelated
|
||||
staged and unstaged work.
|
||||
4. Review `git diff --staged` and run appropriate checks for the change. Reuse
|
||||
successful checks for unchanged content.
|
||||
5. Review `git log --oneline -n 10` and use
|
||||
`git commit -m "<concise plain-English commit message>"`.
|
||||
6. Report the commit identifier and any remaining uncommitted work.
|
||||
|
||||
If the unit cannot be safely separated from pre-existing work, leave it uncommitted
|
||||
and explain the overlap rather than silently including that work. If a commit
|
||||
fails, preserve the changes and report the failure; do not bypass hooks.
|
||||
|
||||
Default commit authorization does not authorize pushing, publishing, amending,
|
||||
resetting, reverting, or rewriting history. Those actions require a separate user
|
||||
instruction. Do not use `git commit -a` or `git commit --no-verify` to bypass the
|
||||
staging and validation discipline above.
|
||||
143
docs/policy/architecture.md
Normal file
143
docs/policy/architecture.md
Normal file
@@ -0,0 +1,143 @@
|
||||
# Architecture Policy
|
||||
|
||||
**Base Policy Version:** 1.3
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies architecture](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/architecture.md)
|
||||
|
||||
## Purpose And Ownership
|
||||
|
||||
The adopted policy defines the application's purpose and the architectural
|
||||
constraints contributors must follow. It owns system boundaries, responsibility
|
||||
and dependency rules, established invariants, and explicit non-goals.
|
||||
|
||||
Describe the concrete package inventory and implementation mechanics in internal
|
||||
documentation. Link to canonical public contracts for their exact behavior and
|
||||
to ADRs for decision rationale.
|
||||
|
||||
## Architectural Approach
|
||||
|
||||
Hexagonal architecture is strongly recommended, including encapsulating external
|
||||
integrations and APIs within internal adapters. Keep domain and application
|
||||
logic independent of external integration details, and make dependency direction
|
||||
clear in the adopted policy.
|
||||
|
||||
Implement that separation with proportionate, idiomatic code. Choose interfaces
|
||||
and package layout to serve the application's actual boundaries. Use adapters
|
||||
for collaborators with external integration responsibilities.
|
||||
|
||||
## Adopted Constraints And Implemented Structure
|
||||
|
||||
Architectural constraints govern current and future development. Record
|
||||
implemented structure accurately, proposals and implementation status in the
|
||||
roadmap, and significant decisions and rationale in ADRs. Describe a target
|
||||
structure as implemented when its changes land.
|
||||
|
||||
Constraints must reflect deliberately selected requirements and decisions.
|
||||
Do not promote incidental implementation choices into architectural invariants.
|
||||
|
||||
## Application-Specific Topics
|
||||
|
||||
Audita is a single-process Go CLI for transcript polishing. Its architecture
|
||||
separates deterministic transcript processing from external LLM effects through
|
||||
narrow contracts and adapters. Correction modules and validators remain explicit,
|
||||
composable components in an ordered processing pipeline.
|
||||
|
||||
This policy owns architectural requirements. The [internal overview](../internal/overview.md)
|
||||
owns the implemented component inventory and links to runtime mechanics.
|
||||
[CLI](../cli.md), [configuration](../config.md), [operations](../operations.md),
|
||||
and [integration documentation](../integrations/subprocess.md) own external contracts.
|
||||
|
||||
## Ownership and Dependency Direction
|
||||
|
||||
- **Core:** owns domain data handling and reusable configuration, schema,
|
||||
normalization, chunking, output, diagnostics, and reporting contracts. Domain
|
||||
behavior must not require CLI or provider-transport knowledge.
|
||||
- **Framework:** owns orchestration contracts and shared runtime mechanics for
|
||||
modules, validators, proposals, LLM adapters, and report assembly.
|
||||
It composes domain operations through explicit inputs and outputs.
|
||||
- **Modules:** own narrowly scoped correction behavior and module-specific prompt
|
||||
choices. Keep module packages separate rather than collapsing their distinct
|
||||
responsibilities into a broad generic stage abstraction.
|
||||
- **Validators:** own validation behavior and composition. Deterministic and
|
||||
LLM-backed validators remain explicit, independently composable elements.
|
||||
- **Prompts:** own embedded prompt assets and metadata used by the runtime.
|
||||
- **CLI and adapters:** own command parsing, streams, filesystem wiring, and
|
||||
transport. Keep these concerns outside module, validator, and schema logic.
|
||||
|
||||
LLM transport belongs behind `StructuredLLMClient` and framework adapter
|
||||
boundaries. Prefer small shared helpers over broad rewrites. Keep module and
|
||||
validator inputs, outputs, and configuration dependencies explicit, without
|
||||
hidden global state.
|
||||
|
||||
## Correction and Concurrency Invariants
|
||||
|
||||
- Treat LLM responses as nondeterministic inputs. Preserve deterministic proposal
|
||||
indexing, validator ordering, transcript mutation, reports, and serialization.
|
||||
- Validate corrections before final mutation, including local proposal checks,
|
||||
decision cardinality, and apply-time safety. Provider-side schema enforcement
|
||||
does not replace these checks.
|
||||
- Keep LLM concurrency bounded and context-aware through PromptKit's engine-local
|
||||
per-backend admission. Proposal and validation calls selecting the same backend
|
||||
share that capacity, including retries and repairs. Preserve deterministic
|
||||
collection order. Recoverable model-operation failures stay local to their
|
||||
proposal response or validation batch; fatal invariant/application failure
|
||||
and parent cancellation stop peers and join them.
|
||||
- Keep module and validator identities, reason codes, and execution-class
|
||||
distinctions stable where exposed as contracts.
|
||||
|
||||
The [pipeline](../internal/pipeline.md), [modules](../internal/modules.md),
|
||||
[validators](../internal/validators.md), and [LLM runtime](../internal/llm-runtime.md)
|
||||
describe how these requirements are implemented.
|
||||
|
||||
## State and Compatibility
|
||||
|
||||
Keep transcript mutation and output handling deterministic around external
|
||||
calls. Reports and correction ledgers are derived from processing results.
|
||||
Preserve the separation between transient processing state and filesystem
|
||||
adapters; physical report placement and optional debug retention belong to
|
||||
[operations](../operations.md).
|
||||
|
||||
Public CLI, configuration, output-schema, diagnostics, report, prompt, module,
|
||||
and validator contracts should remain stable unless a change is deliberate and
|
||||
tested. The resilience work intentionally replaced the earlier JSON process
|
||||
report with versioned errors/recoveries YAML and a fixed Markdown overview;
|
||||
future changes should treat those current contracts deliberately. Current implementation
|
||||
limits are documented in the [internal overview](../internal/overview.md#current-scope);
|
||||
they are not additional prohibitions on future development.
|
||||
|
||||
## Trust Boundaries And Threat Scope
|
||||
|
||||
Errors should identify the failed processing phase sufficiently for users and
|
||||
subprocess callers. Preserve the stream and exit behavior defined by the
|
||||
[CLI contract](../cli.md) and the artifact handling defined by
|
||||
[operations](../operations.md).
|
||||
|
||||
Diagnostics, reports, and surfaced errors must not leak configured LLM secrets.
|
||||
Configuration redaction and LLM payload/error redaction have separate
|
||||
responsibilities and should remain separate. Implementation details belong in
|
||||
[diagnostics and reporting](../internal/diagnostics-reporting.md).
|
||||
|
||||
## Dependencies
|
||||
|
||||
Keep Audita dependency-light and prefer the Go standard library for CLI parsing,
|
||||
filesystems, synchronization, and tests. ConfigKit owns configuration loading,
|
||||
presence, provenance, and secret resolution; PromptKit owns prompt/profile
|
||||
loading, OpenAI-compatible transport, retries, repairs, and backend admission.
|
||||
Audita owns domain meaning, role selection, and deterministic processing.
|
||||
|
||||
Do not introduce broad CLI, dependency-injection, workflow, logging, or plugin
|
||||
frameworks without a concrete implemented need and focused tests.
|
||||
|
||||
## Testing and Documentation
|
||||
|
||||
Follow the [testing policy](testing.md) for risk-based sufficiency and stable test
|
||||
boundaries. Keep tests close to the behavior they protect; shared helpers should
|
||||
remove duplication without obscuring component-specific behavior. Relevant
|
||||
internal docs identify component tests and change recipes; the
|
||||
[contributor guide](../development.md) provides baseline validation commands.
|
||||
|
||||
Follow the [documentation policy](documentation.md) for ownership, current versus
|
||||
future behavior, and the ADR lifecycle. Keep architecture concise and normative;
|
||||
use the roadmap for implementation plans rather than maintaining a changelog or
|
||||
future-feature specification here.
|
||||
174
docs/policy/documentation.md
Normal file
174
docs/policy/documentation.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Documentation Policy
|
||||
|
||||
**Base Policy Version:** 1.11
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies documentation](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/documentation.md)
|
||||
|
||||
## Purpose
|
||||
|
||||
This policy assigns each documentation topic to one canonical owner. Its goal is
|
||||
to keep this application's documentation accurate, concise, discoverable, and resistant
|
||||
to drift for users, operators, developers, integrators, and LLM coding agents.
|
||||
|
||||
## Core Rules
|
||||
|
||||
### One Canonical Owner
|
||||
|
||||
Each authoritative fact belongs in one document. A non-owning document may give
|
||||
a short, stable summary for orientation, but it must link to the canonical owner
|
||||
for volatile details.
|
||||
|
||||
Volatile details include commands, flags, configuration fields and defaults,
|
||||
module keys, schemas, file names, paths, status codes, retry behavior, and
|
||||
runtime guarantees. If readers could reasonably treat a statement as a
|
||||
contract, maintain it only in the owning document.
|
||||
|
||||
### Current And Future Behavior
|
||||
|
||||
Outside `docs/roadmap/`, documentation describes implemented behavior only.
|
||||
Partial features may be described only to their implemented boundary.
|
||||
|
||||
Architectural constraints may govern future changes. Describe current structure
|
||||
from implemented behavior.
|
||||
|
||||
ADRs may record an accepted architectural decision before implementation. The
|
||||
roadmap owns implementation status and sequencing until the decision is
|
||||
implemented. Current architecture, user, operator, integration, and internal
|
||||
documentation are updated when the behavior lands.
|
||||
|
||||
### Audience And Detail
|
||||
|
||||
Write for the document's stated audience and include only the detail needed for
|
||||
its owned topic. Keep user and operator docs focused on using and operating the
|
||||
application. Developer docs should link to user-facing and external contracts
|
||||
for their definitions.
|
||||
|
||||
### Examples
|
||||
|
||||
Complete copyable files belong in `examples/`. Documentation may use the
|
||||
smallest illustrative snippet needed to explain its owned topic, but should link
|
||||
to maintained examples for complete copyable files.
|
||||
|
||||
Examples must be valid, secret-free, and tested where practical. Commands and
|
||||
configuration used in documentation should match the application.
|
||||
|
||||
### Security And Privacy
|
||||
|
||||
Documentation and examples must not contain real credentials, private keys,
|
||||
private environment dumps, sensitive source material, or private infrastructure
|
||||
details unless intentionally public. Document secret-handling mechanisms, not
|
||||
secret values.
|
||||
|
||||
## Canonical Ownership
|
||||
|
||||
| Topic | Canonical owner | Owned content | Content owned elsewhere |
|
||||
| --- | --- | --- | --- |
|
||||
| Product orientation and minimal end-to-end quickstart | `README.md` | Purpose, value, shortest successful invocation, and navigation, including licensing and attribution. | Complete command reference, configuration reference, operational procedures, implementation detail. |
|
||||
| Contributor entry point | `docs/development.md` | Task-oriented reading guide, contributor orientation, baseline validation commands, and canonical links. | Package inventory, architecture rules, subsystem behavior, detailed change recipes. |
|
||||
| Application architecture policy | `docs/policy/architecture.md` | System shape, normative ownership, dependency direction, boundaries, invariants, safety properties, and non-goals. | Concrete package inventory, implementation mechanics, contributor procedures, decision history, future work. |
|
||||
| Policy-set provenance and upstream navigation | `docs/policy/meta.md` | Policy-set origin, local authority, adoption baselines, and upstream adoption and update links. | Task-specific reading triggers, detailed adoption procedures, and formal attribution notices. |
|
||||
| Agent policy | `docs/policy/agents.md` | Proportionate, idiomatic implementation; graph-first code discovery, commit discipline, and rules against inventing requirements, restrictions, guarantees, or policy. | Application contracts, architecture, testing policy, and contributor procedures. |
|
||||
| Documentation policy | `docs/policy/documentation.md` | Documentation ownership, audience boundaries, maintenance rules, and ADR/document lifecycle. | Application architecture or product behavior. |
|
||||
| Testing policy | `docs/policy/testing.md` | Test philosophy, risk sufficiency, boundaries, doubles, coverage, regressions, and test maintenance. | Subsystem behavior, application contracts, subsystem-specific test inventories, and implementation plans. |
|
||||
| Release policy | `docs/policy/release.md` | Versioning, compatibility, release integrity and immutability, release documentation, proportionate gates, publication controls, completion, and required versus optional checks. | Repository-specific commands, product installation guidance, CLI version semantics, historical release summaries, and CI implementation detail. |
|
||||
| Open source licensing and attribution policy | `docs/policy/oss.md` | License defaults and author choices, COPYRIGHT and attribution formats, license/notice links, discoverability, maintenance, and concrete exceptions. | Component entries, license texts, release commands, and dependency security review. |
|
||||
| Project copyright and license grant | `COPYRIGHT` | Project identity, copyright holders and years, SPDX expression, grant, warranty disclaimer, and third-party statement. | Complete license texts and upstream component attribution. |
|
||||
| Project license texts | `LICENSE` | Complete project and incorporated companion license texts, with required project-specific fields. | General licensing policy and upstream component attribution. |
|
||||
| Upstream component attribution | `docs/oss/attribution.md` | House Format component entries: identity, material scope and modifications where applicable, copyright, license, required notices, and license, notice, and source links. | General attribution policy, exception reasoning, research narratives, compliance commentary, and complete standard license texts. |
|
||||
| Standard dependency license texts | `docs/oss/licenses/` | Complete, verbatim standard license texts shared by applicable entries. | Project-specific upstream notices, attribution prose, and policy interpretation. |
|
||||
| Repository-specific release procedure | `docs/release.md` | Maintainer prerequisites, candidate preparation, validation and publication commands and automated guards, asynchronous deliverables, delivery status, optional consumer verification, and recovery. | General release requirements, product installation guidance, historical release summaries, and current compatibility contracts. |
|
||||
| CLI contract (if applicable) | `docs/cli.md` | Commands, arguments, flags, invocation semantics, and exit codes. | End-to-end operating procedures, configuration field definitions, runtime filesystem layout, module implementation details. |
|
||||
| Configuration contract (if applicable) | `docs/config.md` | Discovery, precedence, schema, fields, defaults, environment overrides, validation, and selectable module and validator keys. | Complete example files, CLI syntax, runtime state lifecycle, module implementation details. |
|
||||
| Operations (if applicable) | `docs/operations.md` | Runtime workflows, physical filesystem and state layout, output, cache and debug handling, resume, cleanup, permissions, recovery, and limits. | CLI flag syntax, configuration field definitions, logical output schemas, implementation mechanics. |
|
||||
| Integration contracts for external components (if applicable) | `docs/integrations/`, including `docs/integrations/output-files.md` for serialized outputs | External formats and protocols, upstream and downstream contracts, logical output paths and schemas, media types, and compatibility. | Physical runtime placement and lifecycle, internal transformations, CLI syntax, configuration defaults. |
|
||||
| Inventory of implemented internal packages | `docs/internal/overview.md` | Implemented packages and components, responsibilities, and links to focused internal docs. | Normative architecture, contributor reading policy, external contracts. |
|
||||
| Behavior and architecture of internal packages | Other files under `docs/internal/` | Implementation flow, collaborators, state transitions, package-local guarantees and failures, and relevant tests. | Global architecture invariants, configuration definitions and defaults, external schemas, operator procedures. |
|
||||
| Contributor change recipes | Relevant files under `docs/internal/`, including `docs/internal/cli-config.md`, `docs/internal/modules.md`, and `docs/internal/validators.md` | Concrete editing and validation steps for each component. | Contributor orientation, global policy, and definitions of external contracts. |
|
||||
| Architectural decision records | `docs/adr/` | Significant decisions, context, alternatives, rationale, consequences, and supersession history. | Current behavior reference, implementation status, task sequencing. |
|
||||
| Future work and implementation status | `docs/roadmap/` | Proposed, accepted, deferred, or rejected work; implementation status, sequencing, and task breakdowns. | Implemented behavior reference and architectural decision rationale. |
|
||||
| Release-note history | `docs/releases/` | One checked-in summary per source release under the procedure; the note at its immutable tag is the release record. | Current commands, behavior, contracts, and compatibility definitions. |
|
||||
| Complete copyable artifacts | `examples/` | Maintained configuration, inputs, and other copyable or runnable files. | Field-by-field reference, command reference, prose explanation. |
|
||||
|
||||
Create supporting documents for existing interfaces and responsibilities when
|
||||
substantive content is available.
|
||||
Audita has retired its standalone troubleshooting guide; concrete operating and
|
||||
recovery procedures belong in `docs/operations.md`.
|
||||
|
||||
## Boundary Rules
|
||||
|
||||
### Orientation
|
||||
|
||||
Link among orientation, architecture, and internal documents; maintain each
|
||||
package or behavior description in its canonical owner.
|
||||
|
||||
### Commands, Configuration, And Operations
|
||||
|
||||
CLI documentation answers how to invoke the application. Configuration
|
||||
documentation answers what settings mean. Operations answers what happens to
|
||||
runtime state and how to operate or recover the application. When a workflow
|
||||
crosses these topics, choose the document that owns the task and link to the
|
||||
other contracts.
|
||||
|
||||
### Releases
|
||||
|
||||
The release policy defines requirements and invariants that every release must
|
||||
satisfy. The repository-specific release procedure defines the commands and
|
||||
workflow maintainers use to satisfy that policy. Release notes record history
|
||||
at immutable tags. Maintain current behavior in its canonical documentation,
|
||||
update it with the corresponding behavior changes, and keep release procedures
|
||||
consistent with adopted policy.
|
||||
|
||||
### Project Licensing And Upstream Attribution
|
||||
|
||||
README and release documents link to the canonical licensing and attribution
|
||||
materials under the [OSS policy](oss.md). The release procedure owns URL
|
||||
construction and publication mechanics.
|
||||
|
||||
### Contracts And Implementation
|
||||
|
||||
Integration and API documents define externally observable shapes and
|
||||
semantics. Internal documents explain how this application implements or consumes those
|
||||
contracts. Internal docs may name a field, file, or protocol to identify a
|
||||
dependency, but must link to its canonical contract for the definition.
|
||||
|
||||
### Security Topics
|
||||
|
||||
This policy owns what documentation and examples may contain. Architecture owns
|
||||
application security invariants. Configuration owns credential-supply
|
||||
mechanisms. Operations owns permissions and handling of sensitive runtime
|
||||
artifacts. Internal docs own implementation mechanisms only.
|
||||
|
||||
## Architecture Decision Records
|
||||
|
||||
Use sequentially numbered ADR filenames such as
|
||||
`0001-record-architecture-decisions.md`. Follow the lightweight Nygard format:
|
||||
|
||||
1. title;
|
||||
2. status;
|
||||
3. date;
|
||||
4. context;
|
||||
5. decision;
|
||||
6. alternatives considered;
|
||||
7. consequences.
|
||||
|
||||
Treat the decision content of an accepted ADR as immutable. When a decision
|
||||
changes, create a new ADR and update the earlier ADR's status to superseded.
|
||||
Rejected architectural alternatives belong in the ADR; rejected product ideas
|
||||
belong in the roadmap.
|
||||
|
||||
## Maintenance
|
||||
|
||||
When behavior changes, update its canonical owner in the same change. If
|
||||
ownership moves, remove the old definition and replace it with a link where
|
||||
navigation remains useful.
|
||||
|
||||
Before completing documentation work:
|
||||
|
||||
- verify affected behavior and examples;
|
||||
- check commands, flags, fields, defaults, schemas, and paths against their
|
||||
implementation;
|
||||
- keep unimplemented behavior in the roadmap, subject to the ADR exception;
|
||||
- remove stale references and validate links;
|
||||
- confirm that non-owning documents summarize and link rather than redefine;
|
||||
- confirm that no secrets or sensitive private data were added.
|
||||
26
docs/policy/meta.md
Normal file
26
docs/policy/meta.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Policy Set Provenance
|
||||
|
||||
**Base Policy Version:** 1.0
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies meta](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/meta.md)
|
||||
|
||||
## Origin And Local Authority
|
||||
|
||||
This repository's policy set is adapted from
|
||||
[Standard Repository Policies](https://gitea.maximumdirect.net/eric/policy).
|
||||
The adopted local policies govern work in this repository. Upstream revisions
|
||||
become local policy through deliberate adoption, preserving local decisions.
|
||||
Each policy's `Upstream Source` identifies its adopted baseline.
|
||||
|
||||
## Adoption And Updates
|
||||
|
||||
For policy adoption, upstream revision reviews, and updates, consult the
|
||||
[upstream adoption and update guide](https://gitea.maximumdirect.net/eric/policy/src/branch/main/docs/adoption.md).
|
||||
That guide and the reference example collection are maintained upstream and
|
||||
accessed through links. Keep discovery links pointed at the current upstream
|
||||
project and guide; keep adopted-source and example links pinned to commits.
|
||||
|
||||
The local [developer guide](../development.md) routes tasks to applicable
|
||||
policies. Formal credit and licensing notices for the copied policy material
|
||||
belong in the local [attribution document](../oss/attribution.md).
|
||||
219
docs/policy/oss.md
Normal file
219
docs/policy/oss.md
Normal file
@@ -0,0 +1,219 @@
|
||||
# Open Source Licensing And Attribution Policy
|
||||
|
||||
**Base Policy Version:** 1.8
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies oss](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/oss.md)
|
||||
|
||||
## Purpose And Scope
|
||||
|
||||
This policy defines project licensing conventions and a repeatable House Format
|
||||
for upstream attribution and license notices. It covers the project's own code
|
||||
and upstream components incorporated into or distributed with the application
|
||||
or library, including relevant transitive dependencies and copied code,
|
||||
documentation, or assets.
|
||||
Determine treatment from the component's terms and actual use.
|
||||
|
||||
Consulting development guidance or using tooling alone does not require an
|
||||
attribution entry. Copying or adapting documentation for inclusion in the
|
||||
repository is different: preserve its applicable attribution and license terms.
|
||||
A material's role as development guidance does not exempt copied documents.
|
||||
Apply any express permissions for attribution-free reuse of example formatting.
|
||||
|
||||
The baseline is a publicly available source repository with releases published
|
||||
alongside it. The format is independent of language, forge, and build system.
|
||||
It does not require attribution for every development tool, establish license
|
||||
compatibility, or resolve every obligation arising from use or distribution.
|
||||
|
||||
Audita uses the existing GPL-3.0-or-later application grant in
|
||||
[`COPYRIGHT`](../../COPYRIGHT). The Gitea distribution and publication procedure
|
||||
are documented in the [release runbook](../release.md).
|
||||
|
||||
## Canonical Locations
|
||||
|
||||
The [documentation policy](documentation.md) assigns ownership:
|
||||
|
||||
- `COPYRIGHT`: project name, copyright statements, SPDX expression, grant,
|
||||
warranty disclaimer, and third-party statement.
|
||||
- `LICENSE` contains the complete, unmodified project license text, including
|
||||
incorporated companion text. Dependency attribution does not relicense the project.
|
||||
- `docs/oss/attribution.md`: canonical component entries.
|
||||
- `docs/oss/licenses/`: complete, verbatim standard and applicable companion texts.
|
||||
|
||||
Use recognizable license filenames, such as `Apache-2.0.txt` or `LGPL-3.0.txt`.
|
||||
A shared standard text may serve multiple entries. Keep explanations outside
|
||||
license texts and preserve distinct versions and exceptions.
|
||||
|
||||
## Upstream Reference Examples
|
||||
|
||||
Use the commit-pinned upstream examples to create actual project notices.
|
||||
Retain their links and keep the example collection upstream; keep applicable
|
||||
license texts locally as specified above.
|
||||
|
||||
## Project Licensing
|
||||
|
||||
Unless the author specifies otherwise, use **GPL version 3 or later**
|
||||
(`GPL-3.0-or-later`) for applications and **LGPL version 3 or later**
|
||||
(`LGPL-3.0-or-later`) for libraries. An author's explicit choice takes precedence:
|
||||
for example, a one-off script may use MIT. Such a choice requires no exception
|
||||
rationale, additional approval, or compensating controls under this policy.
|
||||
|
||||
These defaults guide new license selection. Adopting this policy does not
|
||||
relicense existing code or override third-party terms. Preserve an existing
|
||||
license unless the author deliberately changes it. For mixed-purpose projects,
|
||||
follow the author's selected scope rather than inferring different licenses for
|
||||
individual packages.
|
||||
|
||||
Use the upstream [application COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/examples/licensing/application/COPYRIGHT)
|
||||
or [library COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/examples/licensing/library/COPYRIGHT)
|
||||
to create the project’s root `COPYRIGHT` file.
|
||||
Use verified project names, contribution years, and copyright holders.
|
||||
For another selected license, adapt the grant, SPDX expression, disclaimer, and
|
||||
text references together to reflect the author's selected grant.
|
||||
|
||||
For GPLv3 projects, copy the complete GPLv3 text into `LICENSE`. For LGPLv3
|
||||
projects, place the complete LGPLv3 text followed by the complete GPLv3 text in
|
||||
`LICENSE`; the LGPL incorporates the GPL terms. Keep the texts unmodified and
|
||||
place project-specific statements in `COPYRIGHT`. For the default grants, the
|
||||
grant and SPDX expression in `COPYRIGHT` must expressly identify `or-later`;
|
||||
follow the author’s choice if a different grant is selected.
|
||||
|
||||
For other licenses, provide their complete text and any required project-specific
|
||||
fields; the standard reference collection remains unchanged. Keep `COPYRIGHT`,
|
||||
`LICENSE`, SPDX expressions, and README descriptions consistent with the actual
|
||||
grant. This convention introduces no blanket requirement for per-file headers;
|
||||
preserve notices or add them where the applicable terms require them.
|
||||
|
||||
Identify separately licensed documentation or assets in the project grant, with
|
||||
links to their attribution and license information. An application's default
|
||||
code license does not override the terms of incorporated documentation.
|
||||
|
||||
## Upstream Attribution House Format
|
||||
|
||||
Begin `docs/oss/attribution.md` with `# Open Source Attribution Notices`,
|
||||
followed directly by component entries. These comprise the complete document.
|
||||
|
||||
Each entry presents these five fields in order, with blank lines between them:
|
||||
|
||||
1. **Project name** as a level-two heading. An optional identification paragraph
|
||||
may follow, such as `Selected module: MODULE at VERSION.` with the module and
|
||||
version in backticks. For copied documentation, a concise `Material:` sentence
|
||||
may identify the affected files and whether they were adapted or copied
|
||||
without modification. A factual qualifier such as `(transitive dependency)`
|
||||
is permitted. Limit optional identification prose to factual component and
|
||||
material scope.
|
||||
2. **Upstream copyright statement or statements**, preserving their wording.
|
||||
Put multiple statements in separate paragraphs. Include this field when the
|
||||
selected upstream source supplies an applicable statement; otherwise, omit it.
|
||||
3. **SPDX license identifier or expression**, when applicable, using
|
||||
`SPDX-License-Identifier: EXPRESSION`.
|
||||
4. **License and notice links**, beginning `License and notices:`, separated
|
||||
by ` | `, and ending with a period. Label local standard texts by license
|
||||
name, such as `MIT` or `Apache 2.0`. Label upstream files by their actual
|
||||
filenames, such as `COPYRIGHT`, `LICENSE`, `NOTICE`, or `PATENTS`.
|
||||
5. **Source repository link**, rendered exactly as `[Source](COMMIT_URL).`.
|
||||
|
||||
Use the upstream [attribution example](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/examples/licensing/attribution.md)
|
||||
to create the project’s `docs/oss/attribution.md`.
|
||||
The example illustrates omitted fields and multiple copyrights and licenses.
|
||||
Replace the uppercase placeholders and illustrative URLs with actual component
|
||||
information. Local license links are relative to the destination
|
||||
`docs/oss/attribution.md`; copy the applicable texts into its `licenses/`
|
||||
directory. Do not copy example entries for components the project does not use.
|
||||
|
||||
These are five fields, not a line limit. Omit the SPDX field when no applicable
|
||||
identifier exists; identify nonstandard terms through the linked text. Preserve
|
||||
licensing alternatives and exceptions, and record a selected option when
|
||||
relevant through the factual license identification. Do not invent an identifier
|
||||
or silently resolve an unsettled licensing choice.
|
||||
|
||||
Keep entries factual. Do not add agent-authored explanations of license
|
||||
expressions, file-level license scope, research performed, retained source
|
||||
notices, or compliance conclusions. Avoid filler such as "none is invented
|
||||
here" and embellished link labels such as "upstream LICENSE", "additional
|
||||
patent grant", or "at the imported commit". Preserve actual required upstream
|
||||
content; this rule excludes editorial additions, not required notices. Policy
|
||||
interpretation and exception reasoning belong in the adopted OSS policy or an
|
||||
appropriate decision record, not the attribution document.
|
||||
|
||||
## License Texts And Upstream Links
|
||||
|
||||
Link standard license texts to their local copies. Link project-specific
|
||||
notices to their upstream copies. Every upstream repository or notice link must
|
||||
identify the exact commit corresponding to the
|
||||
imported version, including the selected source revision for copied material.
|
||||
|
||||
Classify material according to its contents. An upstream `LICENSE`,
|
||||
`COPYING`, or similar file may contain project-specific notices or exceptions
|
||||
in addition to standard wording. Link both the local standard text and the
|
||||
commit-specific upstream file when needed. Make companion license texts directly
|
||||
reachable from the entry.
|
||||
|
||||
For project-specific license and attribution material, this policy accepts
|
||||
direct links to the applicable upstream texts as satisfying reproduction,
|
||||
inclusion, or copy requirements. This is the adopted house interpretation.
|
||||
Agents must apply it without adding local-copy requirements or seeking repeated
|
||||
approval solely because a license uses those terms.
|
||||
|
||||
This interpretation concerns notice reproduction. Concrete obligations such as
|
||||
marking modified files or supplying corresponding source receive their own
|
||||
applicable treatment. Preserve required notices already present in incorporated
|
||||
source files; the central attribution entry does not authorize stripping them.
|
||||
|
||||
## Discoverability
|
||||
|
||||
End the project's README with two friendly statements linking to its actual
|
||||
grant in `COPYRIGHT` and the attribution document. For example, for a project
|
||||
with the stated license:
|
||||
|
||||
```markdown
|
||||
PROJECT_NAME is licensed under the [LGPL v3.0 or later](COPYRIGHT).
|
||||
|
||||
[Open Source attribution notices](docs/oss/attribution.md) are available.
|
||||
```
|
||||
|
||||
Each new checked-in release document and its hosted download page must end
|
||||
with links whose visible text is `COPYRIGHT | LICENSE | ATTRIBUTION`. Use absolute
|
||||
URLs to those files at the release's immutable tag or corresponding immutable source
|
||||
revision so the links work in both locations. This release navigation is distinct
|
||||
from upstream component links, which must use the imported commit.
|
||||
|
||||
Reuse the checked-in release document as the hosted release body where supported.
|
||||
The release procedure owns concrete URLs and publication mechanics for delivering
|
||||
the links through the selected channel. Do not maintain duplicate notice lists.
|
||||
These conventions do not by themselves require separate downloadable license
|
||||
assets, source bundles, or a different binary package format.
|
||||
|
||||
## Maintenance And Exceptions
|
||||
|
||||
Update project licensing statements together when the author changes the grant
|
||||
or its scope. Update upstream notices in the change that adds, removes, upgrades,
|
||||
copies, or changes the distribution of a relevant component. Check the selected source's license
|
||||
and notices rather than assuming they are unchanged. Update affected entries,
|
||||
commit links, and texts; retain historical versions through Git.
|
||||
|
||||
When the toolchain used for distributed binaries changes, check the Go runtime
|
||||
and standard-library entries against that toolchain's exact source revision,
|
||||
including any vendored packages incorporated into those binaries.
|
||||
|
||||
Check affected statements, faithful standard-text copies, and link destinations
|
||||
as part of ordinary change review. For a future release tag, check intended file
|
||||
paths against the candidate source; the tag need not resolve remotely before
|
||||
publication. Do not add publication-time network checks, CI polling, recurring
|
||||
legal sign-offs, mandatory scanners, or a full software bill of materials merely
|
||||
to implement this policy.
|
||||
|
||||
Use the House Format routinely. Raise an exception only for a concrete obligation
|
||||
or unresolved rights question it does not address, including any arising from a
|
||||
particular distribution channel. Record the issue and selected treatment in the
|
||||
adopted OSS policy or an appropriate decision record. Attribution entries
|
||||
contain the resulting factual identification and required material, without
|
||||
repeating that reasoning. Resolve the issue before the affected use or
|
||||
distribution without reopening settled choices.
|
||||
Common ownership of projects is neither required nor a blanket exception.
|
||||
|
||||
Apply the formatting convention prospectively. Do not rewrite published tags,
|
||||
notes, binaries, or checksums to retrofit it. Address actual omissions deliberately
|
||||
under the applicable terms and the [release correction policy](release.md#immutability-and-failure-recovery).
|
||||
Ordinary attribution maintenance and release links are preparation work, not new
|
||||
release approval gates.
|
||||
210
docs/policy/release.md
Normal file
210
docs/policy/release.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# Release Policy
|
||||
|
||||
**Base Policy Version:** 1.4
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies release](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/release.md)
|
||||
|
||||
## Purpose
|
||||
|
||||
This policy defines a proportionate workflow for validating and publishing an
|
||||
intended source revision under a fresh version. Releases should require little
|
||||
routine intervention, avoid repeated work, and preserve published contents.
|
||||
|
||||
The repository-specific commands belong in `docs/release.md`. Historical release
|
||||
summaries belong in `docs/releases/`. The procedure must agree with the adopted
|
||||
policy and link to it rather than introduce additional release requirements.
|
||||
|
||||
## Release Model And Completion
|
||||
|
||||
A source release identifies one exact committed source revision through an
|
||||
immutable version tag and a version-matched, checked-in release note. The
|
||||
primary release branch is `main` unless the adopted policy specifies otherwise.
|
||||
The procedure must name the authoritative publication remote.
|
||||
|
||||
A successful push of the intended tag, with its source commit available on the
|
||||
authoritative primary branch, completes the release. The source commit may be
|
||||
pushed before the tag or published together with it through an atomic push.
|
||||
The procedure must choose and document the supported approach.
|
||||
|
||||
Release commands must finish at successful publication. They must not wait for
|
||||
or poll CI, require successful CI status, inspect downloadable artifacts, or
|
||||
check consumer installation or Go module availability as completion gates.
|
||||
A failed or ambiguous push requires resolving the authoritative remote state
|
||||
before declaring success or retrying; successful pushes do not require a
|
||||
separate remote read-back gate.
|
||||
|
||||
Repositories may publish source only. Additional binaries, images, packages,
|
||||
checksums, or other declared deliverables may be published asynchronously from
|
||||
the tagged source. The procedure must identify those deliverables and the
|
||||
responsibility of their automation. Published deliverables must be traceable
|
||||
to that source and identify the same version.
|
||||
|
||||
Track source-release completion and artifact delivery separately. Report delivery
|
||||
failures and optional investigations under artifact-delivery status.
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
| Platform | Support |
|
||||
| --- | --- |
|
||||
| Linux amd64 | Required production target |
|
||||
| Linux arm64 | Required production target |
|
||||
| macOS arm64 | Best effort for local development; failures do not block a release or Linux artifact publication |
|
||||
|
||||
Windows and macOS amd64 are unsupported. Neither their builds nor tests are
|
||||
release requirements. Native macOS testing and access to a Mac are not release
|
||||
prerequisites.
|
||||
|
||||
## Versioning And Compatibility
|
||||
|
||||
Stable releases use Semantic Versioning in the form `vMAJOR.MINOR.PATCH`, with
|
||||
no leading zeroes. Prereleases require an explicit adopted policy defining
|
||||
their format and use.
|
||||
|
||||
The selected version must be unused locally and on the authoritative remote.
|
||||
Do not require queries to every configured remote or publication service.
|
||||
A version known to have already been published must not be reused, even if the
|
||||
normal guards do not inspect that channel. Adding a distribution channel
|
||||
requires a deliberate update to the policy and procedure where needed.
|
||||
|
||||
For releases at or after `v1.0.0`:
|
||||
|
||||
- a major release may make intentional incompatible changes;
|
||||
- a minor release may add backward-compatible behavior; and
|
||||
- a patch release may make backward-compatible fixes.
|
||||
|
||||
Before `v1.0.0`, a minor release may change a documented public, operational,
|
||||
configuration, data, integration, or compatibility contract when the release
|
||||
note explains the impact and required consumer action. A patch release must
|
||||
not intentionally break those contracts within its minor line.
|
||||
|
||||
Additional compatibility promises and deliberate exceptions belong in the
|
||||
adopted policy or canonical contract documentation. Release notes explain
|
||||
changes; they do not redefine current compatibility contracts.
|
||||
|
||||
## Release Documentation And Preparation
|
||||
|
||||
Every new release must include `docs/releases/<version>.md` in the tagged
|
||||
source tree. Use the complete version tag as the filename and begin with a
|
||||
title containing the product name and that exact version.
|
||||
|
||||
Include a short summary and any relevant compatibility impact or upgrade
|
||||
instructions. Choose sections suited to the release and keep the note
|
||||
proportionate to the change.
|
||||
|
||||
Keep exact current contracts in their canonical documents and update affected
|
||||
documentation with the behavior change. Link to those documents from the note
|
||||
where useful. If annotated tags are used, derive their summary from the
|
||||
checked-in note.
|
||||
|
||||
Include the release footer defined by the [OSS policy](oss.md#discoverability)
|
||||
in each new release document and preserve it on the hosted download page. The
|
||||
release procedure defines the concrete URLs and publication mechanics. Prepare
|
||||
these links with the release note; they do not add a network check or approval
|
||||
gate.
|
||||
|
||||
Handle version selection, release-note content, and retirement of completed
|
||||
roadmaps during preparation. Preserve planned and deferred work and repair
|
||||
affected links when retiring roadmaps. Reuse ordinary change review for
|
||||
unintended files, credentials, and private data. Scope release-content review
|
||||
to the tagged source.
|
||||
|
||||
## Candidate Validation
|
||||
|
||||
Provide one publication command that validates the final committed candidate,
|
||||
checks publication state, and publishes the intended refs. A validation-only
|
||||
mode or command may be provided for diagnosis, but must not be a required step
|
||||
before publication repeats the same checks.
|
||||
|
||||
Run the complete deterministic, offline default test suite once for the final
|
||||
candidate, following the [testing policy](testing.md). For repositories that
|
||||
publish builds, verify the required build targets. Select those targets for
|
||||
the application's actual support commitments; native testing on each platform
|
||||
and access to particular hardware are not default release prerequisites.
|
||||
|
||||
Additional gates must address a concrete risk that the existing checks do not
|
||||
adequately cover. Do not automatically require linting, race testing, module
|
||||
hygiene audits, documentation audits, credential scans, example validation, or
|
||||
expanded platform matrices solely because they are possible. Retain such
|
||||
checks when their distinct protection justifies their cost. A one-time migration
|
||||
check must not silently become a permanent release requirement.
|
||||
|
||||
Release tests must not require real credentials, mutable application services,
|
||||
paid APIs, provider probes, or inference calls. The procedure may describe dependency
|
||||
preparation separately from offline validation.
|
||||
|
||||
Avoid duplicate validation across release phases. Successful checks for the
|
||||
same final candidate need not be repeated solely to satisfy another phase;
|
||||
any reuse must clearly apply to that exact candidate. Persistent validation
|
||||
caches are not required. If the candidate changes, validate the new candidate.
|
||||
Cheap publication-state checks may be repeated immediately before pushing
|
||||
because local or remote state may have changed during validation.
|
||||
|
||||
Automate mechanical guards. Do not require manual approvals, sign-offs, or
|
||||
routine confirmations as release gates. Version selection and
|
||||
a concise release summary remain preparation inputs, not separate approval rounds.
|
||||
|
||||
## Publication Guards
|
||||
|
||||
Automate the checks needed to publish the intended source under a fresh version:
|
||||
|
||||
- the version has the adopted format and is unused locally and on the
|
||||
authoritative remote;
|
||||
- the worktree and index are clean on the primary release branch;
|
||||
- the source being published is the exact candidate that passed validation,
|
||||
including its matching release note;
|
||||
- the remote primary branch already identifies that candidate, or an atomic
|
||||
source/tag push will advance it to that candidate without discarding remote
|
||||
history; and
|
||||
- the tag identifies the validated candidate and only the intended refs are
|
||||
published.
|
||||
|
||||
Fetch the authoritative branch and tag state as needed for these checks.
|
||||
Do not force branch or tag updates to bypass a failed guard. Publish explicit
|
||||
refs rather than all local tags. Do not require CI success, publication-service
|
||||
availability checks, or a separate manual confirmation for each guard.
|
||||
|
||||
## Immutability And Failure Recovery
|
||||
|
||||
Published version tags and published contents are immutable. Do not move,
|
||||
overwrite, recreate, or delete a published tag, or replace a published artifact,
|
||||
checksum, signature, provenance statement, or release note under that version.
|
||||
The checked-in note at the immutable tag is that release's historical record.
|
||||
|
||||
If validation fails before publication, correct and commit the candidate and
|
||||
rerun the publication command. If a push fails or its outcome is ambiguous,
|
||||
inspect the authoritative remote before retrying. Remove an unpublished local
|
||||
tag only after confirming it was never published or used by a release channel.
|
||||
An unavailable remote leaves publication status unknown; do not overwrite a tag
|
||||
to resolve uncertainty.
|
||||
|
||||
Transient network, authentication, CI, or consumer-availability failures do not
|
||||
by themselves require a new version. Asynchronous delivery may be retried from
|
||||
the same immutable tag. Missing artifacts may be published later, provided
|
||||
existing published contents are not replaced and the additions remain consistent
|
||||
with the tagged source and any already-published checksum manifest. If that
|
||||
cannot be achieved, publish a new version.
|
||||
|
||||
A defect requiring changes to published source or contents requires a corrected
|
||||
commit, a new semantically appropriate version, a matching release note, and
|
||||
the release procedure again. Leave the original release intact. A channel's
|
||||
yank, deprecation, or advisory mechanism may warn consumers away from a defective
|
||||
release without replacing its contents or reusing its version.
|
||||
|
||||
## Repository Release Procedure
|
||||
|
||||
Maintain `docs/release.md` as a short, executable maintainer runbook. It must
|
||||
identify:
|
||||
|
||||
1. prerequisites, primary branch, and authoritative remote;
|
||||
2. version and release-note preparation;
|
||||
3. one publication command with its selected local checks and automated guards;
|
||||
4. declared deliverables, required build targets, and automation responsibilities;
|
||||
5. the successful-push completion point and separately reported delivery status;
|
||||
and
|
||||
6. failure handling, ambiguous-push recovery, and asynchronous delivery retries.
|
||||
|
||||
Use copyable commands where practical. Keep optional diagnostics and consumer
|
||||
verification clearly optional. The procedure must not turn preparation work,
|
||||
ordinary change review, or post-publication investigation into additional
|
||||
release gates.
|
||||
263
docs/policy/testing.md
Normal file
263
docs/policy/testing.md
Normal file
@@ -0,0 +1,263 @@
|
||||
# Testing Policy
|
||||
|
||||
**Base Policy Version:** 1.3
|
||||
|
||||
**Last Updated**: 2026-09-28
|
||||
**Upstream Source:** [Standard Repository Policies testing](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/testing.md)
|
||||
|
||||
## Purpose
|
||||
|
||||
Our tests exist to make **incorrect changes expensive and correct changes cheap**.
|
||||
|
||||
We optimize for sufficient confidence in important behavior while minimizing friction on future development.
|
||||
|
||||
## Every test has a cost
|
||||
|
||||
Every test has an immediate and continuing cost: writing, review, execution,
|
||||
diagnosis, fixture maintenance, and updates when legitimate behavior changes.
|
||||
Tests can also constrain refactoring, duplicate policy, and add failure noise.
|
||||
|
||||
A test is warranted only when the confidence it provides justifies these costs.
|
||||
Evaluate that tradeoff at two levels:
|
||||
|
||||
1. **Per test:** What realistic defect does this test detect, how consequential would that defect be, and is that protection worth the test's lifetime cost?
|
||||
2. **Across the suite:** Does this collection provide materially more confidence than a smaller, simpler suite would?
|
||||
|
||||
Some friction is intentional. Tests should make dangerous changes—such as breaking compatibility, corrupting data, violating security boundaries, or reintroducing subtle bugs—require deliberate review. Keep ordinary internal changes inexpensive.
|
||||
|
||||
Evaluate maintenance cost against the specific failure being protected. When omitting a plausible test, be able to state why the protected failure is low-risk, already covered, obvious, reversible, or cheaper to detect elsewhere. For consequential, subtle, or difficult-to-observe behavior, the presumption should favor testing.
|
||||
|
||||
## Default testing style
|
||||
|
||||
Use a **classical/Detroit-style** approach:
|
||||
|
||||
- Test observable behavior, resulting state, contracts, and invariants.
|
||||
- Use real internal collaborators when they are fast and deterministic.
|
||||
- Use fakes, stubs, or mocks primarily at expensive, nondeterministic, destructive, or external boundaries.
|
||||
- Prefer package-level behavioral tests over tests coupled to private helpers or internal call sequences.
|
||||
- Treat exact collaborator interactions as testable behavior only when the interaction itself is a requirement.
|
||||
|
||||
Examples of appropriate seams include clocks, randomness, subprocesses, remote APIs, object storage, email, and paid LLM calls.
|
||||
|
||||
## Test execution requirements
|
||||
|
||||
Tests in the default suite must be deterministic, offline, and independent of real credentials. They must not invoke paid APIs or depend on mutable external services. Tests that require live infrastructure must be explicitly opt-in and clearly separated from the default suite.
|
||||
|
||||
Control clocks, randomness, environment variables, and other process-global or machine-specific state when they affect behavior. Tests should be safe to run repeatedly and alongside other tests without depending on execution order or state left by an earlier test.
|
||||
|
||||
## What deserves tests
|
||||
|
||||
To the extent the following features are present in the application, prioritize tests for:
|
||||
|
||||
1. Public and package-level contracts.
|
||||
2. Domain rules and important invariants.
|
||||
3. Boundary conditions and malformed input.
|
||||
4. Failure handling, cancellation, retries, recovery, and partial success.
|
||||
5. Serialization, schemas, compatibility, and round trips.
|
||||
6. Previously observed or plausible regressions.
|
||||
7. Representative integration and end-to-end workflows.
|
||||
|
||||
A package-level contract comprises behavior relied upon by another package or major collaborator.
|
||||
|
||||
Choose tests for requested behavior and established contracts. Tests must not
|
||||
introduce new restrictions, guarantees, or threat scenarios merely because they
|
||||
could be asserted. Follow the [agent policy](agents.md) when deciding whether a
|
||||
behavior belongs to the contract; current implementation behavior alone is not
|
||||
sufficient authority.
|
||||
|
||||
For established behavior involving **data integrity, destructive operations,
|
||||
compatibility, security, concurrency, idempotency, or recovery**, favor durable
|
||||
tests for realistic failures whose consequences warrant protection. Identify
|
||||
the failure and the existing contract it would violate. These categories call
|
||||
for attention, not an automatic test inventory or permission to strengthen the
|
||||
application's guarantees. Account for protection already provided at other layers.
|
||||
|
||||
Do not add tests merely because a function, branch, or line exists. Do not add a test when the same meaningful risk is already adequately protected elsewhere.
|
||||
|
||||
## Choose the right test boundary
|
||||
|
||||
Choose the narrowest stable boundary that expresses the behavior clearly and
|
||||
provides durable confidence with minimal incidental coupling.
|
||||
|
||||
This is often the package API, but it may instead be:
|
||||
|
||||
- a smaller pure function when dense domain logic is most clearly isolated there;
|
||||
- a package-level operation when several internal collaborators jointly produce the behavior; or
|
||||
- a larger integration boundary when correctness emerges from interaction with a real dependency.
|
||||
|
||||
## Test behavior, not implementation
|
||||
|
||||
A test should protect a selected decision, contract, or invariant.
|
||||
|
||||
A test is suspect when it primarily detects changes to private constants or
|
||||
helpers, equivalent operation ordering, incidental formatting, equivalent
|
||||
algorithms, or internal structure that preserves behavior.
|
||||
|
||||
Behavioral tests should normally remain stable through internal refactoring that preserves the contract.
|
||||
|
||||
## Expected effects of different changes
|
||||
|
||||
Use the following expectations when evaluating test failures and test maintenance:
|
||||
|
||||
| Change | Expected effect on tests |
|
||||
|---|---|
|
||||
| Internal refactor that preserves behavior | Existing tests should normally remain unchanged and continue to pass. |
|
||||
| Change to an internal default with no contractual significance | Behavioral tests should normally remain unchanged; tests should derive expectations from configuration or relationships rather than duplicate the old value. |
|
||||
| Intentional change to public behavior, policy, schema, or compatibility guarantees | The relevant tests should be reviewed and changed deliberately. |
|
||||
| Accidental violation of a contract or invariant | Tests should fail; fix the production code rather than rewriting the tests to accept the defect. |
|
||||
|
||||
A test failing is not the same as a test needing to be edited. Many tests may correctly fail because of one production defect. The maintenance smell is a correct internal change that requires unrelated expectation updates throughout the suite.
|
||||
|
||||
## Separate mechanism from policy
|
||||
|
||||
Derive expectations from test-controlled configuration and relationships.
|
||||
|
||||
For this example, assume the selected contract rejects a request to start more
|
||||
processes than a configured limit. Do not encode its production default indirectly:
|
||||
|
||||
```go
|
||||
// Production default:
|
||||
const maxConcurrency = 4
|
||||
|
||||
// Brittle test:
|
||||
err := startProcesses(5)
|
||||
require.Error(t, err)
|
||||
```
|
||||
|
||||
Instead, test the mechanism relationally:
|
||||
|
||||
```go
|
||||
const limit = 2
|
||||
runner := NewRunner(limit)
|
||||
|
||||
require.NoError(t, runner.Start(limit))
|
||||
require.ErrorIs(t, runner.Start(limit+1), ErrTooMuchConcurrency)
|
||||
```
|
||||
|
||||
For this selected contract, the test should prove:
|
||||
|
||||
- the configured limit is accepted; and
|
||||
- one beyond the configured limit is rejected.
|
||||
|
||||
Rejection is not a general requirement for concurrency control. If the selected
|
||||
contract queues excess work or limits active workers while accepting larger
|
||||
batches, test that behavior instead. Do not add rejection or a configurable
|
||||
limit solely to reproduce this example.
|
||||
|
||||
The production default should be tested exactly only when its literal value is itself a public, operational, safety, protocol, or compatibility requirement.
|
||||
|
||||
Apply the same rule to limits, timeouts, capacities, retry counts, and ranges: test relationships and behavior.
|
||||
|
||||
For established concurrency limits, distinguish these behaviors where the contract requires them:
|
||||
|
||||
1. **Configuration handling:** values are accepted or rejected according to the selected contract.
|
||||
2. **Runtime enforcement:** observed peak concurrency never exceeds the configured limit.
|
||||
|
||||
Use a test-controlled limit and measure the behavior relative to that limit.
|
||||
|
||||
## Assign each behavior a test owner
|
||||
|
||||
Where these layers exist, assign ownership as follows:
|
||||
|
||||
- Parser tests own parsing cases.
|
||||
- Validator tests own validation rules.
|
||||
- Domain tests own transformations and invariants.
|
||||
- Adapter tests own external integration behavior.
|
||||
- Orchestrator tests own coordination and failure propagation.
|
||||
- CLI tests own argument and configuration mapping.
|
||||
- End-to-end tests prove that representative assembled workflows work.
|
||||
|
||||
Give each layer its distinct responsibility and keep expectation updates localized to the contract being changed.
|
||||
|
||||
## Use test doubles deliberately
|
||||
|
||||
Choose the least elaborate test double that provides the required control or observation.
|
||||
|
||||
As a default:
|
||||
|
||||
1. Prefer real collaborators when they are fast and deterministic.
|
||||
2. Use small in-memory fakes when realistic stateful behavior is helpful.
|
||||
3. Use stubs when a dependency only needs to provide controlled responses.
|
||||
4. Use mocks when the interaction itself is contractual.
|
||||
|
||||
Mocks are appropriate when the contract includes facts such as:
|
||||
|
||||
- a notification is sent exactly once;
|
||||
- a transaction is committed only after successful writes;
|
||||
- cancellation reaches a subprocess;
|
||||
- an expensive API is called no more than once; or
|
||||
- a security audit event is emitted.
|
||||
|
||||
## Go-specific guidance
|
||||
|
||||
Select techniques by behavior and risk:
|
||||
|
||||
- table-driven tests for meaningful behavioral categories and boundaries;
|
||||
- `t.TempDir()` for real filesystem behavior;
|
||||
- `httptest.Server` for realistic HTTP interactions;
|
||||
- fuzz tests when exploring broad input spaces, such as parsers or path handling, adds useful protection beyond representative cases;
|
||||
- golden files only when the complete output is intentionally stable;
|
||||
- integration tests where correctness depends on component interaction; and
|
||||
- a small number of representative end-to-end tests when assembled workflows expose meaningful risks not adequately covered at narrower boundaries.
|
||||
|
||||
Prefer `errors.Is`, `errors.As`, typed errors, or structured error fields. Use exact error-wording assertions only when the wording is contractual.
|
||||
|
||||
At CLI boundaries, prefer exit classifications, structured output, and the smallest stable semantic fragment needed to identify the error. Use complete diagnostic snapshots only when the wording is contractual.
|
||||
|
||||
Golden-file updates must require an explicit local flag. CI must not update golden files automatically, and reviewers must inspect the semantic diff before accepting an update.
|
||||
|
||||
Keep tests readable and direct. Size test helpers and fixture frameworks to the maintenance benefit they provide.
|
||||
|
||||
## Coverage
|
||||
|
||||
Use coverage to locate untested critical branches and unexpectedly weak packages. Evaluate test quality through meaningful behavioral protection and choose coverage according to risk.
|
||||
|
||||
Pure domain logic will often warrant higher coverage than CLI wiring or external adapters. Uneven coverage is acceptable when it reflects risk.
|
||||
|
||||
## Regression tests
|
||||
|
||||
A bug fix should normally include a regression test that fails before the fix and passes afterward.
|
||||
|
||||
Retain the test when the defect could realistically recur and its consequences justify the ongoing cost. Prefer the narrowest durable test of the violated contract or invariant.
|
||||
|
||||
Remove or consolidate a test when the underlying design has made recurrence impossible, its protection is redundant, or a stronger invariant test subsumes it.
|
||||
|
||||
## Deleting or rewriting tests
|
||||
|
||||
Delete or rewrite tests when maintenance cost exceeds their continuing
|
||||
protective value.
|
||||
|
||||
Strong candidates include tests that:
|
||||
|
||||
- require updates after harmless internal changes;
|
||||
- assert incidental private constants or snapshot large amounts of incidental output;
|
||||
- verify mock choreography rather than outcomes;
|
||||
- duplicate policy across layers, retest trivial helpers covered by package
|
||||
behavior, or protect risks covered more effectively elsewhere;
|
||||
- are flaky, misleading, obsolete, or disproportionately expensive to diagnose; or
|
||||
- no longer correspond to a plausible failure mode.
|
||||
|
||||
Several brittle tests may encode one genuine requirement. Consolidate them into one durable behavior-level or invariant test.
|
||||
|
||||
## Reviewing a proposed test
|
||||
|
||||
Use the following questions when a proposed test needs closer evaluation. Significant test additions should be reviewable against them; written answers are optional for routine tests.
|
||||
|
||||
1. Which requested behavior or established contract does it protect, and what realistic defect would violate it?
|
||||
2. How likely and consequential is that defect, and is it already protected elsewhere?
|
||||
3. What is the narrowest stable boundary that can test it clearly?
|
||||
4. Would a correct internal refactor or a change to an incidental default require test edits?
|
||||
5. Does its confidence justify its maintenance, execution, and diagnostic cost, or would a smaller test suffice?
|
||||
|
||||
## Definition of sufficient
|
||||
|
||||
A test suite is sufficient when:
|
||||
|
||||
- important requested behavior and established contracts are protected against realistic, consequential failures;
|
||||
- boundaries and component interactions have coverage where they introduce meaningful risks not protected elsewhere;
|
||||
- failures provide useful, distinct signals;
|
||||
- tests usually remain stable through legitimate internal changes; and
|
||||
- additional tests would mostly repeat existing protection or preserve inconsequential implementation details.
|
||||
|
||||
Reassess sufficiency as the application, its users, and the consequences of
|
||||
failure evolve.
|
||||
144
docs/release.md
Normal file
144
docs/release.md
Normal file
@@ -0,0 +1,144 @@
|
||||
# Releasing Audita
|
||||
|
||||
The [release policy](policy/release.md) defines versioning, supported platforms,
|
||||
immutability, and success. This runbook implements it with
|
||||
[scripts/release.sh](../scripts/release.sh). Publication ends after a successful
|
||||
source/tag push; binary delivery runs asynchronously.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Use Bash, Git, and Go 1.25.5 or newer (CI uses Go 1.25.5), with dependencies
|
||||
available locally or downloadable. Tests themselves are offline. Work from a
|
||||
checkout of `main` with permission to push that branch and tags to `origin`.
|
||||
For this repository, `origin` is `https://gitea.maximumdirect.net/eric/audita.git`.
|
||||
The script uses the checkout's configured `origin`; set it correctly before use.
|
||||
The remote must support atomic pushes. No CI credentials or Mac are needed locally.
|
||||
|
||||
CI uses the existing `GITEA_RELEASE_TOKEN` secret for asynchronous asset delivery.
|
||||
macOS arm64 is a best-effort development environment; no macOS binary is published.
|
||||
|
||||
## Prepare the Candidate
|
||||
|
||||
Choose an unused version following the policy. Write
|
||||
`docs/releases/<version>.md`, beginning with `# Audita <version>`, followed by a
|
||||
short summary and any compatibility or upgrade instructions relevant to the
|
||||
release. There are no mandatory boilerplate sections. Update affected canonical
|
||||
documentation with behavior changes.
|
||||
|
||||
End each new note with these links, substituting the selected release version for
|
||||
`<version>`:
|
||||
|
||||
```markdown
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/COPYRIGHT) | [LICENSE](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/LICENSE) | [ATTRIBUTION](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/docs/oss/attribution.md)
|
||||
```
|
||||
|
||||
Check that all three paths exist in the candidate source. Retire completed
|
||||
roadmaps when useful during preparation, preserving planned and deferred work
|
||||
and repairing affected links. This is ordinary preparation, not a script gate.
|
||||
|
||||
Commit the intended changes, including the note, on `main`. The release script
|
||||
requires a clean index and worktree and does not create commits. There is no
|
||||
separate approval round. Published notes describe their tagged release; existing
|
||||
release history does not need to be reconstructed.
|
||||
|
||||
## Validate and Publish
|
||||
|
||||
From the repository root, substitute the chosen version:
|
||||
|
||||
```sh
|
||||
bash scripts/release.sh --publish v0.2.0
|
||||
```
|
||||
|
||||
This single invocation:
|
||||
|
||||
1. Checks the version, branch, clean candidate, matching note title, and tag absence.
|
||||
2. Runs the default offline test suite once, then builds both required Linux targets
|
||||
in a temporary directory using the same build script as CI.
|
||||
3. Checks that the candidate and worktree are unchanged and that it includes the
|
||||
current `origin/main` history.
|
||||
4. Creates the version tag at that commit and atomically pushes the exact source
|
||||
commit to `main` and the exact tag to `origin`.
|
||||
5. Reports release success and exits without polling CI or checking asset availability.
|
||||
|
||||
To validate a prepared candidate without remote access, creating a tag, or pushing:
|
||||
|
||||
```sh
|
||||
bash scripts/release.sh --check v0.2.0
|
||||
```
|
||||
|
||||
This is an optional diagnostic command, not a required step before `--publish`.
|
||||
Publication validates within its own invocation; it does not use persistent cached
|
||||
results. Both modes require the candidate note and a clean `main` checkout.
|
||||
|
||||
## Artifact Delivery
|
||||
|
||||
[Woodpecker](../.woodpecker/release.yml) runs on tag events. It invokes
|
||||
[scripts/build-release.sh](../scripts/build-release.sh), then publishes:
|
||||
|
||||
- `audita-<version>-linux-amd64`
|
||||
- `audita-<version>-linux-arm64`
|
||||
- `SHA256SUMS`
|
||||
|
||||
Builds disable CGO and use the shared script's release flags. The version is in the
|
||||
asset name and source tag; Audita has no CLI version command. Cross-compilation
|
||||
checks compilation, not native execution on each architecture.
|
||||
|
||||
The CI job status and logs show delivery progress or failure. Assets appear on
|
||||
the matching Gitea release page when delivery succeeds. A successful tag push
|
||||
must not be reported as confirmation that these files are available.
|
||||
For a new hosted release, the release plugin uses the checked-in note at the
|
||||
tag as its body, including the footer. On delivery retries it preserves
|
||||
existing release information and skips files that already exist.
|
||||
|
||||
Consumers can download the binary for their Linux architecture and `SHA256SUMS`
|
||||
from that page, check its listed SHA-256 digest with `sha256sum`, and make it
|
||||
executable. Optional consumer checks are not maintainer release gates. Digests
|
||||
detect file mismatches; they are not an independent signature of authenticity.
|
||||
|
||||
## Failure and Retry
|
||||
|
||||
**Local validation fails:** correct the issue, commit any changes, and rerun the
|
||||
publication command. A failure before tag creation publishes nothing. Temporary
|
||||
local build files are removed on exit.
|
||||
|
||||
**Push fails or the connection is interrupted:** the script retains the local tag
|
||||
and reports failure rather than guessing whether publication succeeded. Inspect
|
||||
remote state with the actual version:
|
||||
|
||||
```sh
|
||||
git rev-parse 'v0.2.0^{commit}'
|
||||
git ls-remote origin refs/heads/main refs/tags/v0.2.0
|
||||
```
|
||||
|
||||
If the remote tag identifies the intended candidate and its source is on remote
|
||||
`main`, the release succeeded; no CI waiting is needed. An atomic push normally
|
||||
updates both refs or neither. If `main` has advanced since publication, fetch it
|
||||
and check candidate ancestry rather than requiring tip equality.
|
||||
|
||||
If the tag is absent remotely and was never published or used by a release
|
||||
channel, remove only that unpublished local tag (`git tag -d v0.2.0`), resolve
|
||||
any rejected branch update, and rerun the command. If the remote tag has a
|
||||
different target, do not overwrite it; choose a fresh version. Never force a
|
||||
branch or tag update to bypass the guards.
|
||||
|
||||
**CI delivery fails:** the release remains successful. Inspect the failed tag
|
||||
job's logs and retry that same tagged job for a transient failure. Publication is
|
||||
configured to skip existing filenames and not overwrite assets. Keep the same
|
||||
source and build environment when retrying; inspect any existing assets/checksum
|
||||
manifest before filling gaps. Do not regenerate and replace a published manifest
|
||||
or binary. If an existing manifest cannot describe the missing rebuilt assets,
|
||||
use a new version instead. A pipeline or source defect also requires a corrected
|
||||
commit and new version. An outage does not require moving the tag.
|
||||
|
||||
**A released source defect is discovered:** fix it on `main` and publish a new
|
||||
appropriate version with a note explaining the correction. Leave the old tag and
|
||||
published files intact.
|
||||
|
||||
## Maintaining the Release Workflow
|
||||
|
||||
The shared build script keeps local and CI build settings aligned. Tests in
|
||||
[scripts/release_test.go](../scripts/release_test.go) exercise publication against
|
||||
temporary local Git remotes, including guard failures and rejected pushes, with
|
||||
Go execution stubbed to avoid recursive builds/tests. They run in `go test ./...`.
|
||||
Changes to CI delivery should preserve explicit asset names, checksums, and
|
||||
non-overwriting publication. CI delivery is separate from the local success path.
|
||||
10
docs/releases/README.md
Normal file
10
docs/releases/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Release Notes
|
||||
|
||||
- [Audita v2.0.1](v2.0.1.md)
|
||||
- [Audita v2.0.0](v2.0.0.md)
|
||||
- [Audita v1.1.0](v1.1.0.md)
|
||||
|
||||
See the [release documentation requirements](../policy/release.md#release-documentation-and-preparation).
|
||||
Use the [release procedure](../release.md) to prepare and publish new releases.
|
||||
|
||||
This index does not reconstruct or replace records for existing tags.
|
||||
22
docs/releases/v1.1.0.md
Normal file
22
docs/releases/v1.1.0.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Audita v1.1.0
|
||||
|
||||
This release refreshes Audita's documentation and repository policies and adds a
|
||||
small, automated release workflow. Transcript-processing behavior, CLI syntax,
|
||||
configuration, and serialized output formats are unchanged from v1.0.0.
|
||||
|
||||
- Consolidated CLI, configuration, operations, and integration references, including
|
||||
a dedicated reference for output files and reports.
|
||||
- Added contributor navigation and agent, testing, and release policies; retired
|
||||
speculative troubleshooting documentation and the completed migration roadmap.
|
||||
- Added local release validation and publication scripts, with publication complete
|
||||
after the source and version tag are pushed. CI delivers binaries asynchronously.
|
||||
- Isolated CLI tests from host configuration for a reliable local test baseline.
|
||||
|
||||
Release binaries are now provided only for Linux amd64 and Linux arm64. Windows
|
||||
and Intel macOS are no longer supported. macOS arm64 remains a best-effort local
|
||||
build/development environment; macOS binaries are no longer published.
|
||||
|
||||
Linux users need no configuration or data migration. Users of previously published
|
||||
Windows or macOS binaries should account for the distribution changes above before
|
||||
upgrading. See the [release procedure](../release.md) for artifact delivery and the
|
||||
[contributor guide](../development.md) for local build instructions.
|
||||
38
docs/releases/v2.0.0.md
Normal file
38
docs/releases/v2.0.0.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Audita v2.0.0
|
||||
|
||||
Audita v2 adopts ConfigKit for configuration and PromptKit for LLM execution,
|
||||
adds resilient processing and focused reports, and improves correction prompts
|
||||
and validation. This is an intentional breaking release; existing installations
|
||||
must migrate their configuration and invocation settings.
|
||||
|
||||
- Configuration uses `version: 2` YAML, named backends, PromptKit model profiles,
|
||||
and optional named overlays. Offline configuration validation and inspection
|
||||
expose effective settings, selected profiles, and provenance.
|
||||
- Proposal and validation calls share per-backend capacity. PromptKit handles
|
||||
transport retries and structural response repair within bounded operation
|
||||
timeouts.
|
||||
- Transcript chunks remain fixed through the LLM stages. Recoverable model
|
||||
failures preserve progress and allow other work to continue. If every LLM
|
||||
operation fails recoverably, processing still produces the deterministically
|
||||
normalized transcript without LLM corrections. Cancellation, application
|
||||
failures, and required output failures remain fatal.
|
||||
- Ordinary output includes `errors.yml`, `recoveries.yml`, and `report.md`, plus
|
||||
a brief completion summary. Detailed correction and LLM diagnostics are opt-in
|
||||
with `--debug`; `--reporting=false` suppresses all three ordinary reports.
|
||||
- Empty replacement text supports validated span deletion while preserving a
|
||||
nonblank segment. Validator responses retain usable decisions despite missing,
|
||||
duplicate, or extraneous entries; unavailable decisions never approve an edit.
|
||||
- Prompts use short request-local references, consistent shared instructions,
|
||||
and relevant neighboring/glossary context for validation. Spoken-word cleanup
|
||||
can reduce accidental protected-name repetition subject to validation.
|
||||
|
||||
Follow the [v2 migration guide](../migrations/v2.md) before upgrading. Version-1
|
||||
configuration, implicit environment-setting overlays, retired model/credential/
|
||||
concurrency flags, and the former JSON report interface have no compatibility
|
||||
shim. Start from the maintained examples linked in that guide, configure profiles
|
||||
and credential references, and validate the new configuration. Update report and
|
||||
debug consumers for the [current output contract](../integrations/output-files.md).
|
||||
|
||||
Linux amd64 and arm64 remain the production targets; macOS arm64 is best effort
|
||||
for development. Binary and checksum delivery runs asynchronously after source/tag
|
||||
publication, as described in the [release procedure](../release.md).
|
||||
15
docs/releases/v2.0.1.md
Normal file
15
docs/releases/v2.0.1.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Audita v2.0.1
|
||||
|
||||
This patch release updates the selected ConfigKit and PromptKit libraries and
|
||||
adds complete licensing and attribution information to the source tree. Release
|
||||
notes are now used as the body of new hosted releases.
|
||||
|
||||
- ConfigKit is updated to v0.4.2 and PromptKit to v0.11.2. The selected
|
||||
OpenRouter and Rakestrawhome catalogs are updated to v2.20260926.0.
|
||||
- The [project grant](../../COPYRIGHT) and [upstream attribution](../oss/attribution.md)
|
||||
now identify the application's license, incorporated components, and the
|
||||
separately licensed policy material.
|
||||
- The [release procedure](../release.md) describes the source release and
|
||||
asynchronous Linux binary delivery. Existing release records remain intact.
|
||||
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.1/COPYRIGHT) | [LICENSE](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.1/LICENSE) | [ATTRIBUTION](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.1/docs/oss/attribution.md)
|
||||
171
docs/roadmap/configkit.md
Normal file
171
docs/roadmap/configkit.md
Normal file
@@ -0,0 +1,171 @@
|
||||
# ConfigKit Adoption Roadmap
|
||||
|
||||
**Last updated:** 2026-09-24
|
||||
|
||||
**Status:** Production implementation complete. The selected configuration and
|
||||
overlay model is implemented; [implementation evidence](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md)
|
||||
records verification. No release has been published.
|
||||
|
||||
## Purpose and Direction
|
||||
|
||||
Adopt ConfigKit to harmonize Audita's configuration policy with the other
|
||||
applications in the suite. Consistent configuration conventions are the primary
|
||||
benefit; reducing application-owned configuration infrastructure is a secondary
|
||||
benefit and a useful measure of integration quality.
|
||||
|
||||
This is an intentional breaking migration. There is no goal of backward
|
||||
compatibility with existing installations, configuration files, CLI flags,
|
||||
environment variables, or configuration-inspection output. Provide a migration
|
||||
guide instead of legacy loaders, aliases, dual operating modes, or an ongoing
|
||||
compatibility layer. Retain existing syntax only when it independently suits the
|
||||
new model, not because compatibility requires it.
|
||||
|
||||
The initial review and prototype used ConfigKit v0.3.1, then verified v0.4.0
|
||||
selected overlays. Those findings remain historical; the prototype was removed
|
||||
after production integration. The application depends on a versioned module,
|
||||
without a sibling checkout or local module replacement.
|
||||
|
||||
The shared boundary/prototype unit is complete. Its [selected contract, inventory,
|
||||
and evidence](library-boundary-findings.md) define the detailed target alongside
|
||||
this roadmap. Production configuration migration is complete.
|
||||
|
||||
## Target End State
|
||||
|
||||
- ConfigKit owns strict YAML loading, input presence, default application, explicit
|
||||
override mechanics, recorded resolution, secret references, and safe inspection.
|
||||
- Audita owns its configuration types, field meanings, defaults, schema-version
|
||||
policy, file selection, CLI parsing, domain validation, and runtime initialization.
|
||||
- Adopt ConfigKit's precedence and validation lifecycle rather than reproduce
|
||||
Audita's current per-layer validation and environment-overlay behavior.
|
||||
- General configuration environment overrides are retired. Credentials use typed
|
||||
environment-name secret references; supplied references must resolve according
|
||||
to ConfigKit's contract. File selection follows the application-owned
|
||||
discovery rules in the selected boundary.
|
||||
- Standardize duration representations, explicit empty/null/zero handling, and
|
||||
inheritance on the shared conventions. Express genuine Audita domain rules
|
||||
through the supported resolution and validation APIs.
|
||||
- Retained domain-setting flags and proposal/validation profile flags become
|
||||
explicit ConfigKit overrides according to the migration inventory. Remove old
|
||||
provider/key/retry/concurrency flags and aliases. Credentials use secret references.
|
||||
- Use ConfigKit's redacted effective output and provide source/explanation access
|
||||
through the selected views below. Legacy JSON inspection is replaced.
|
||||
Diagnostic configuration snapshots use the same new model.
|
||||
- Delete superseded loading and override machinery. Do not hide the old model
|
||||
behind adapters that defeat the adoption's consistency benefit.
|
||||
|
||||
Keep Audita's domain capabilities, such as ordered and repeated correction modules,
|
||||
expressible in the new model. Their existing configuration spelling is not binding.
|
||||
Transcript/glossary formats, processing algorithms, and output schemas are outside
|
||||
this migration unless later planning identifies a concrete dependency or an
|
||||
explicitly coordinated change.
|
||||
|
||||
## Selected Overlays for Testing
|
||||
|
||||
Enable ConfigKit's optional selected-overlay feature in the migration. A testing
|
||||
configuration that selects cheaper, faster LLMs is the initial use case. ConfigKit
|
||||
**overlays** modify application settings; PromptKit **execution profiles** still
|
||||
own model and generation settings. Keep `profiles_dir`, the PromptKit `profiles/`
|
||||
directory, and proposal/validation profile names unchanged by this terminology
|
||||
change.
|
||||
|
||||
The planned interface is `--overlay <name>` on `process`, `config validate`, and
|
||||
`config print-effective`. Treat selection as invocation state passed to
|
||||
`Options.Overlay`, not as another persistent setting or environment overlay.
|
||||
Follow ConfigKit v0.4.0's selection contract: omission, an empty name, or `default`
|
||||
selects no overlay; a named selection loads `overlays/<name>.yml` beneath the selected
|
||||
configuration root. A missing selected overlay is an error. Use the library's
|
||||
single-overlay semantics without adding stacking, inheritance, or legacy-directory
|
||||
fallback.
|
||||
|
||||
Precedence is application defaults, main configuration, selected overlay, then
|
||||
explicit setting flags. Perform Audita's role inheritance and semantic validation
|
||||
on the resolved configuration. ConfigKit's base parsing and schema-version checks
|
||||
still precede overlay application; overlays cannot replace the schema version or
|
||||
contain ConfigKit directives. General environment-variable overrides remain retired.
|
||||
Imports and secret-directory bootstrap remain disabled.
|
||||
|
||||
Provide a maintained `overlays/testing.yml` example that selects testing execution
|
||||
profiles through `llm.proposal_profile` and `llm.validation_profile`. Model names and
|
||||
generation controls belong in the corresponding PromptKit profile files. Set both
|
||||
role selections in this example so a base configuration's explicit validation
|
||||
profile cannot accidentally retain the production model. Normal omission-based
|
||||
validation-profile inheritance continues to apply to the final effective settings.
|
||||
The example must make its backend/credential requirements clear and use no real
|
||||
secrets. Model choice is operator-controlled; “testing” does not promise a price,
|
||||
performance level, or equivalent correction quality.
|
||||
|
||||
Overlays may modify other ordinary application settings supported by the schema;
|
||||
they are not restricted to profile selection. The resulting configuration must
|
||||
still satisfy shared backend capacity, credential, and domain rules. Validation,
|
||||
effective-config inspection, selected-profile inspection, and processing must all
|
||||
use the same selected overlay. Preserve overlay provenance in configuration
|
||||
explanations and diagnostics while retaining secret redaction.
|
||||
|
||||
The [recorded overlay results](library-boundary-findings.md#selected-overlay-extension-2026-09-24)
|
||||
prove the representative load, inspection, and HTTP path. Production acceptance
|
||||
requires the same selection to reach both actual LLM roles, with explicit flags
|
||||
winning over overlays and surviving secret references resolved/redacted correctly.
|
||||
The isolated prototype is evidence, not a second supported runtime.
|
||||
|
||||
## Inspection and Invocation Contract
|
||||
|
||||
`process`, `config validate`, and `config print-effective` share file/overlay
|
||||
selection and retained setting overrides. Invocation I/O paths remain process-only.
|
||||
Only explicitly supplied flags override settings. Validation requires an explicit
|
||||
config file; processing and inspection use the selected discovery order. Help is
|
||||
available before configuration loading. All three commands validate selected
|
||||
profiles without requiring a provider call during setup.
|
||||
|
||||
`config print-effective --view settings|profiles|explain` exposes three YAML views:
|
||||
|
||||
- `settings` (default): ConfigKit's redacted effective configuration.
|
||||
- `profiles`: an Audita-owned summary of each selected role's profile, backend,
|
||||
model, temperature, token limit, top-p, timeout, service tier, and reasoning
|
||||
effort where present. Arbitrary extra provider parameters and credentials are
|
||||
omitted; this is a selected-controls view, not every execution input.
|
||||
- `explain`: field paths, sources, and derivation records from ConfigKit, without
|
||||
resolved secret values.
|
||||
|
||||
A ConfigKit snapshot alone does not describe profile-owned controls. Profile
|
||||
inspection must enforce the registered-backend and credential boundary. Diagnostic
|
||||
snapshots use these safe views and preserve overlay/explicit-override provenance.
|
||||
The migration guide explains the intentional replacement of legacy inspection JSON.
|
||||
|
||||
## Integration and Completion Criteria
|
||||
|
||||
ConfigKit and PromptKit form one intentional breaking refactor. Intermediate
|
||||
commits need not build or run. The target contains no temporary old-runtime adapter,
|
||||
compatibility shim, processing gate, dual loader, or automatic legacy conversion.
|
||||
The [combined feature roadmap](library-adoption.md) owns execution/reporting intent;
|
||||
[implementation.md](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md) alone owns stage order and implementation tasks.
|
||||
|
||||
The final application loads all retained domain settings, assembles both selected
|
||||
profiles, and processes through PromptKit. Controlled HTTP evidence must connect
|
||||
configuration selection to actual requests, domain outcomes, safe diagnostics,
|
||||
and shared finite backend capacity. Maintained examples and one migration guide
|
||||
cover the complete file/flag/environment transition. Obsolete application-owned
|
||||
loading, transport, rendering, and scheduler machinery is removed.
|
||||
|
||||
The combined target is Audita v2.0.0. Release compliance and publication remain
|
||||
last and separate from implementing the refactor. Retention and transcript timestamp
|
||||
changes are not included; the selected retry/repair contract resolves the retry
|
||||
follow-up in [runtime behavior](runtime-behavior.md).
|
||||
|
||||
## Scope Boundaries
|
||||
|
||||
- Pin ConfigKit v0.4.0 in production and align Go/toolchain requirements. ConfigKit requires
|
||||
Go 1.25; the combined PromptKit prototype requires Go 1.25.5. Adopting these libraries
|
||||
does not automatically remove Audita's existing YAML dependency used for glossary parsing.
|
||||
- Implement the selected configuration and final PromptKit runtime directly,
|
||||
without temporary runtime adapters, compatibility shims, or process gates.
|
||||
- Enable selected overlays as specified above. Keep imports and secret-directory
|
||||
bootstrap disabled unless a separate concrete requirement justifies them.
|
||||
- Validation and inspection resolve surviving credential references and fail on
|
||||
missing or empty values; no credential-free bypass is planned.
|
||||
- Inspection and diagnostics use the safe selected-profile view and ConfigKit
|
||||
provenance described above. Changed formats are covered by the migration guide.
|
||||
|
||||
The eventual completion test is that Audita follows the suite's ConfigKit
|
||||
conventions while retaining its intended domain capabilities, with a clear
|
||||
migration guide and no ongoing obligation to support the previous configuration
|
||||
model.
|
||||
162
docs/roadmap/decision-set-reconciliation.md
Normal file
162
docs/roadmap/decision-set-reconciliation.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# Partial Success for Validator Decision Sets
|
||||
|
||||
**Last updated:** 2026-09-25
|
||||
|
||||
**Status:** Implemented. This document owns the target behavior and user intent.
|
||||
[historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/91d9be68a7bb3a102900253fdfd8438f0a43f666/docs/roadmap/implementation.md) owns concrete decisions, ordered work,
|
||||
and verification.
|
||||
|
||||
## Purpose and User Intent
|
||||
|
||||
Preserve usable validator decisions when other entries in the same model response
|
||||
have missing, duplicate, or unexpected correction indices. One defective entry
|
||||
should not prevent unrelated candidates from completing their required validation.
|
||||
This extends Audita's existing partial-success approach without another model call.
|
||||
|
||||
Implement this simpler improvement before reconsidering guided domain recovery.
|
||||
Missing validation must never authorize applying a correction, but neither should
|
||||
it invalidate a different candidate's unambiguous approval or editorial rejection.
|
||||
The existing [resilience design](resilience.md) remains the foundation.
|
||||
|
||||
## Historical Baseline
|
||||
|
||||
The reviewed application baseline is `d2a6fcf`:
|
||||
|
||||
- PromptKit validates the complete model response against Audita's embedded JSON
|
||||
Schema and performs its configured structural repairs. Only structurally valid,
|
||||
decoded responses reach domain decision mapping.
|
||||
- `mapLLMResponseToDecisions` in
|
||||
[`llm_validators.go`](../../internal/framework/validators/llm_validators.go)
|
||||
requires exactly one decision for every requested correction index. An empty
|
||||
decision list, missing index, duplicate index, or unexpected index returns an
|
||||
error instead of retaining usable decisions.
|
||||
- `LLMBackedValidator.Validate` consequently marks the entire batch unavailable
|
||||
with `validation_decisions_invalid`. Other batches continue, but usable decisions
|
||||
within that batch are lost.
|
||||
- The runner's cardinality checks enforce an internal contract: each candidate
|
||||
receives one outcome from each validator it reaches. These checks apply to
|
||||
Audita-owned results, not directly to raw model entries.
|
||||
- Deterministic validators already filter individual proposals. Unpreviewable
|
||||
candidates and oversized validation inputs are isolated; recoverable provider
|
||||
failures remain batch-local; application skips individual conflicts.
|
||||
- Ordinary reports distinguish failed operations from successful operations with
|
||||
recoveries. Several failed operations in one stage/chunk share one work-unit
|
||||
error record. The [output contract](../integrations/output-files.md) owns the
|
||||
current counts and serialized representation.
|
||||
|
||||
The defect addressed here is the all-or-nothing domain mapping boundary, not
|
||||
validation itself or the runner's internal consistency checks.
|
||||
|
||||
## Target Decision Semantics
|
||||
|
||||
Reconcile each structurally valid response against the indices actually requested
|
||||
in that particular validator batch. Correction indices, rather than segment IDs
|
||||
or positions in the response array, identify candidates. Several corrections may
|
||||
legitimately target the same segment.
|
||||
|
||||
| Response condition | Target behavior |
|
||||
| --- | --- |
|
||||
| Exactly one valid decision for a requested index | Preserve its approval or rejection and associated decision evidence. |
|
||||
| Requested index omitted | Produce an explicit validation-unavailable outcome for that candidate. |
|
||||
| Requested index appears more than once | Treat that candidate's validation as unavailable; preserve unrelated decisions. |
|
||||
| Index was not requested in this batch | Ignore the extraneous entry and record the handled defect. |
|
||||
| Empty decision list for a nonempty request | Mark all requested candidates unavailable; do not fail the run. |
|
||||
| Decisions appear in a different order | Match by identity and retain deterministic internal results. |
|
||||
|
||||
Duplicate handling does not choose the first or last answer, nor infer a verdict
|
||||
by voting. Even identical duplicates follow the agreed duplicate-index handling;
|
||||
accepting them specially is not needed for this feature. Duplicate extraneous
|
||||
indices remain extraneous entries, not reasons to invalidate requested candidates.
|
||||
|
||||
An unavailable candidate remains unapplied and does not proceed as approved to
|
||||
later validators. It is distinct from a valid `approved: false` decision, which
|
||||
is ordinary editorial processing. Valid approvals continue through the remaining
|
||||
required validators and apply-time checks; this feature grants no bypass.
|
||||
|
||||
The mapper returns one internal outcome for every requested candidate and no
|
||||
outcome for an extraneous index. Preserve strict runner cardinality checks so
|
||||
application bugs are still detected. Do not convert genuine internal invariant
|
||||
failures, cancellation, or fatal setup failures into tolerated model defects.
|
||||
|
||||
## Outcomes and Reporting
|
||||
|
||||
Keep existing work-unit aggregation and operation accounting:
|
||||
|
||||
- If any requested candidate lacks an unambiguous usable decision, record a
|
||||
validation-operation error identifying the affected requested indices. Other
|
||||
candidates' usable decisions from that operation remain effective. An operation
|
||||
error does not mean every candidate in its batch failed.
|
||||
- If all requested candidates have usable decisions and extra entries were
|
||||
ignored, record a successful operation with a recovery for that handled defect.
|
||||
This remains a recovery even if all legitimate decisions are editorial rejections.
|
||||
- If missing/duplicate requested decisions and ignored extras coexist, retain the
|
||||
operation error. Follow the existing rule that failed operations do not also
|
||||
produce recovery records; retain extra-entry details in debug evidence.
|
||||
- A valid complete response with no handled defect adds neither error nor recovery.
|
||||
Valid editorial rejection alone never adds either category.
|
||||
- Preserve actual structural repair and service-retry counts. On successful
|
||||
operations, consolidate applicable recovery reasons in one recovery record.
|
||||
Do not count reconciliation as another LLM operation or structural repair.
|
||||
|
||||
Error attribution must distinguish affected candidates from the rest of the batch.
|
||||
Debug evidence should preserve supplied decisions, ignored entries, and the reason
|
||||
an expected candidate became unavailable. Do not fabricate candidate ledger entries
|
||||
for unknown indices or mislabel missing decisions as deliberate editorial rejection.
|
||||
Ordinary reports must retain safe metadata without raw transcript or response text.
|
||||
|
||||
Use a decision-specific recovery reason rather than treating ignored validator
|
||||
entries as defective correction proposals. Concrete reason names and minimal data
|
||||
model changes belong in the implementation plan. Keep YAML, Markdown, and CLI
|
||||
counts consistent, with the existing reporting-disable and independent debug options.
|
||||
|
||||
## Ownership and Target Architecture
|
||||
|
||||
Audita's validator layer reconciles structurally valid model responses into
|
||||
complete internal candidate outcomes. The runner preserves strict internal
|
||||
cardinality and advances only approved candidates. Reporting consumes operation
|
||||
facts without treating partial validation failure as loss of every decision.
|
||||
Debug evidence distinguishes unavailable validation from editorial rejection.
|
||||
|
||||
The schema/transport boundary remains with PromptKit; reconciliation needs no
|
||||
additional model call. Concrete helper structures, reason names, mapping changes,
|
||||
and verification steps belong in the [historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/91d9be68a7bb3a102900253fdfd8438f0a43f666/docs/roadmap/implementation.md).
|
||||
|
||||
## Scope Boundaries
|
||||
|
||||
PromptKit's whole-response structural validation and repair remain unchanged.
|
||||
A malformed entry, including an extraneous entry that violates the schema, may
|
||||
still invalidate the response and exhaust structural repairs before reconciliation
|
||||
can run. Ignoring schema-valid extras does not promise salvage from malformed JSON,
|
||||
missing required fields, wrong types, or out-of-range values.
|
||||
|
||||
General per-entry structural salvage is a separate design question, not part of
|
||||
this fix. Likewise, guided regeneration remains deferred for reconsideration after
|
||||
this change; no new retries, feedback prompts, budgets, upstream dependency changes,
|
||||
or operator controls are required here.
|
||||
|
||||
Preserve module scope, literal replacement behavior, fixed chunks, stage barriers,
|
||||
span-deletion safeguards, backend capacity limits, and fatal cancellation behavior.
|
||||
No additional restrictions on valid corrections or guarantees about model judgment
|
||||
are introduced. This work does not itself authorize tagging or publishing v2.0.0.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- A schema-valid response can retain usable decisions despite missing, duplicate,
|
||||
or unexpected indices elsewhere in the same batch.
|
||||
- Only the affected requested candidates become unavailable; extras never create
|
||||
candidates or attach decisions to a different batch's candidates.
|
||||
- Valid negative decisions remain editorial outcomes, and every applied correction
|
||||
completes all required validation.
|
||||
- Internal validator results satisfy existing strict cardinality checks.
|
||||
- Missing/duplicate requested decisions yield accurately attributed errors without
|
||||
losing valid work. Extra-only defects yield a consolidated recovery; mixed
|
||||
defects follow existing failed-operation reporting semantics.
|
||||
- Final transcript, debug evidence, YAML reports, Markdown counts, and CLI summary
|
||||
agree about applied work and failures/recoveries.
|
||||
- Reconciliation makes no additional provider calls. Existing structural failures,
|
||||
provider failures, and cancellation retain their documented handling.
|
||||
|
||||
## Open Questions
|
||||
|
||||
No unresolved product-policy questions block implementation. Guided recovery and
|
||||
structural salvage remain separate future decisions.
|
||||
80
docs/roadmap/future.md
Normal file
80
docs/roadmap/future.md
Normal file
@@ -0,0 +1,80 @@
|
||||
# Deferred Feature Work
|
||||
|
||||
**Last updated:** 2026-09-25
|
||||
|
||||
**Status:** Deferred or exploratory work; not implemented or scheduled. These
|
||||
entries preserve scope outside the [resilience roadmap](resilience.md) and
|
||||
[span-deletion consistency roadmap](span-deletion.md). Each entry states its
|
||||
intent; inclusion does not commit us to implementing every capability.
|
||||
|
||||
## Domain-Aware Response Recovery
|
||||
|
||||
The [partial-success decision reconciliation](decision-set-reconciliation.md)
|
||||
preserves usable decisions without another model call. Guided recovery remains
|
||||
deferred pending evidence from failures that remain. General per-entry
|
||||
salvage from structurally invalid responses is also a separate design question;
|
||||
the accepted reconciliation feature retains whole-response structural validation.
|
||||
|
||||
Consider bounded feedback and regeneration for model responses that satisfy the
|
||||
structural schema but leave requested decisions unavailable after reconciliation.
|
||||
The goal would be to recover more usable work before excluding affected
|
||||
candidates, when doing so materially improves outcomes.
|
||||
|
||||
This capability is explicitly deferred. Current behavior retains PromptKit
|
||||
structural repair and per-candidate reconciliation; unavailable requested
|
||||
decisions produce errors while other candidates can succeed.
|
||||
|
||||
Before implementation, define the Audita/PromptKit ownership boundary, which
|
||||
checks are eligible for feedback, how feedback identifies defects without exposing
|
||||
secrets, and how regeneration fits bounded budgets and operation deadlines. Reuse
|
||||
shared library capabilities where appropriate; do not introduce an uncoordinated
|
||||
outer retry loop that multiplies existing retry/repair budgets.
|
||||
|
||||
Ordinary editorial rejection is a valid decision, not a reason to regenerate until
|
||||
an edit is approved. Recovery must preserve required validation, candidate identity,
|
||||
partial-success safety, and truthful error/recovery reporting. Validate with
|
||||
controlled responses that distinguish recoverable protocol defects from valid
|
||||
negative decisions. Exact APIs, budgets, and sequencing remain undecided.
|
||||
|
||||
## Independent Whole-Pipeline Traversal by Chunk
|
||||
|
||||
Explore allowing each fixed chunk to advance through its ordered stages without
|
||||
waiting for other chunks to finish the current stage. This could reduce waiting
|
||||
behind a slow chunk and improve utilization while preserving stage order within
|
||||
each chunk and deterministic final recombination.
|
||||
|
||||
The resilience feature deliberately retains stage barriers: finish a stage across
|
||||
chunks before advancing to the next stage. Fixed boundaries alone do not authorize
|
||||
independent traversal.
|
||||
|
||||
A future design must establish that stages do not depend on other chunks' evolving
|
||||
state, preserve stable identities and partial-success rules, and continue to share
|
||||
PromptKit's per-backend capacity across all roles and stages. Reporting must remain
|
||||
deterministic despite different completion orders, and fatal cancellation must
|
||||
still stop and join active work. Assess whether the scheduling change materially
|
||||
improves real workloads before introducing additional orchestration machinery.
|
||||
No new scheduler, global limiter, or execution mode is selected by this entry.
|
||||
|
||||
## Whole-Segment Removal
|
||||
|
||||
Potential future work, subject first to evaluating whether it is worth implementing
|
||||
at all. Empty replacement text and deletion of a span within a surviving segment
|
||||
are covered by the accepted [span-deletion consistency roadmap](span-deletion.md).
|
||||
That feature does not remove segment records or permit blank resulting segments.
|
||||
|
||||
Before designing segment removal, review representative production examples to
|
||||
establish whether whole-segment deletion is a meaningful unmet need. An empty
|
||||
replacement alone does not establish that intent: it can express ordinary filler
|
||||
or punctuation deletion within a larger segment. Assess how often genuinely
|
||||
expendable whole segments occur after deterministic normalization, the transcript
|
||||
quality benefit of removing them, and the risk of losing substantive speech.
|
||||
Compare those benefits with the implementation and ongoing maintenance costs.
|
||||
Retaining the segment and declining the edit is a valid outcome if the benefit is
|
||||
small or uncertain. No numerical adoption threshold is selected.
|
||||
|
||||
Only if that evaluation supports proceeding should a separate feature design
|
||||
choose a representation, authorization and validation rules, and reporting
|
||||
semantics. It must address meaning preservation and the effects on segment
|
||||
identity, timestamps, fixed chunks, subsequent stages, recombination, and output
|
||||
consumers. Do not infer authorization to remove a segment from an empty string
|
||||
or introduce segment-removal machinery as part of span-deletion consistency.
|
||||
313
docs/roadmap/implementation.md
Normal file
313
docs/roadmap/implementation.md
Normal file
@@ -0,0 +1,313 @@
|
||||
# Implementation Plan: Standard Policy Alignment
|
||||
|
||||
**Last updated:** 2026-09-28
|
||||
|
||||
**Status:** Complete; Stages 1–4 implemented.
|
||||
**Audience:** gpt-5.6-terra coding agent.
|
||||
**Audita planning baseline:** `91d9be68a7bb3a102900253fdfd8438f0a43f666`.
|
||||
**Selected upstream revision:** `d84a38ebab26f048cafbe59a2246700c35d29843`.
|
||||
|
||||
## Scope and Execution
|
||||
|
||||
Implement the accepted [Standard Policy Alignment roadmap](policy.md). It owns
|
||||
the intended end state and reasons for local variations; this plan owns ordered
|
||||
implementation and verification. Complete Stage 1 through Stage 4 in order, each
|
||||
as one focused agent task. Record completion evidence under each stage and commit
|
||||
completed units with short, plain English messages under the agent policy.
|
||||
|
||||
Begin with [development guidance](../development.md) and the
|
||||
[agent policy](../policy/agents.md). Read the policies governing each stage;
|
||||
reuse unchanged policy context. For policy edits, read that policy and affected
|
||||
cross-references. Follow the adopted selective reading guide once installed.
|
||||
Use graph-first discovery for application code; document and shell/configuration
|
||||
inspection does not need a graph lookup.
|
||||
|
||||
Use the public upstream repository at
|
||||
`https://gitea.maximumdirect.net/eric/policy` and check out the exact revision above
|
||||
in a temporary directory outside Audita. Verify its full commit before copying.
|
||||
Read its `docs/adoption.md`, relevant `docs/policy/` files, `COPYRIGHT`, and
|
||||
referenced assets. Do not replace the selected revision with current main or
|
||||
reconstruct prior adoption baselines. The public repository and its attribution
|
||||
are now explicitly approved.
|
||||
|
||||
This plan replaces the completed decision-set plan, preserved at
|
||||
[the planning baseline](https://gitea.maximumdirect.net/eric/audita/src/commit/91d9be68a7bb3a102900253fdfd8438f0a43f666/docs/roadmap/implementation.md).
|
||||
Repair historical roadmap references in Stage 4; do not reopen those features.
|
||||
|
||||
Implement directly toward the final state. Intermediate commits need no temporary
|
||||
policy files, compatibility machinery, or complete dependency inventory. Keep
|
||||
partial work truthful and finish cross-document consistency by Stage 4. Do not
|
||||
release, tag, push, rewrite published material, change dependency versions, or
|
||||
refactor application code as part of this work. No extra approval round is needed
|
||||
between stages. If factual verification uncovers a concrete unresolved rights or
|
||||
publication issue, report it rather than inventing an obligation or claiming it
|
||||
resolved.
|
||||
|
||||
## Common Adoption Decisions
|
||||
|
||||
- Start each policy from the selected upstream file. Preserve shared substantive
|
||||
wording verbatim. Remove its `Base Policy Template` section after fulfilling
|
||||
the instructions; include only the project customizations selected below.
|
||||
- Retain the upstream base version and set `Last Updated` to the actual adoption
|
||||
date. Add `**Upstream Source:**` with a Markdown link to that same file at the
|
||||
full selected commit, using the URL prefix
|
||||
`https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/`.
|
||||
Do not claim this was the source of old local documents.
|
||||
- Keep discovery URLs in `meta.md` pointed to the public repository and
|
||||
`/src/branch/main/docs/adoption.md`. Pin example links in the adopted OSS policy
|
||||
to this selected commit, after checking their paths. Preserve examples upstream.
|
||||
- Explain substantive local variations briefly where they apply. No separate
|
||||
exception register, synchronization system, policy snapshot tests, or legal
|
||||
approval workflow is needed.
|
||||
- Keep policy credit in the single canonical attribution entry. Describe only
|
||||
material adopted so far, expanding it as later stages copy more material.
|
||||
Metadata and template removal mean an adopted file can truthfully be described
|
||||
as adapted even when its substantive rules are verbatim.
|
||||
- Ordinary link/text review is sufficient for documentation changes. Do not run
|
||||
application tests simply because a policy document changed. Each stage ends
|
||||
with `git diff --check` and review of its staged diff before committing.
|
||||
|
||||
## Stage 1 — Establish Provenance and Shared Agent/Testing Policies
|
||||
|
||||
**Completed:** 2026-09-28. Adopted meta 1.0, agents 1.3, and testing 1.3 from
|
||||
the verified upstream commit, preserving Audita's graph-first discovery rule.
|
||||
The initial attribution and scoped copyright notice identify only these three
|
||||
adapted policies; the CC-BY-SA text matches upstream byte-for-byte. Substantive
|
||||
policy text, pinned source paths, local links, and `git diff --check` were checked.
|
||||
|
||||
**Files:** `docs/policy/meta.md`, `docs/policy/agents.md`,
|
||||
`docs/policy/testing.md`, `docs/oss/attribution.md`,
|
||||
`docs/oss/licenses/CC-BY-SA-4.0.txt`, and `COPYRIGHT`.
|
||||
|
||||
1. Adopt meta 1.0, agents 1.3, and testing 1.3 with the common metadata and
|
||||
template-removal rules. Preserve the existing Codebase Discovery section as
|
||||
the one local addition to agents: Audita deliberately uses graph-first
|
||||
discovery. Adopt the remaining agent rules and the testing rules verbatim.
|
||||
2. Create attribution with `# Open Source Attribution Notices`, followed directly
|
||||
by the canonical entry from `examples/licensing/policy-attribution.md`.
|
||||
Substitute the selected commit in its COPYRIGHT, LICENSE, and Source URLs.
|
||||
Initially identify the three newly adapted policy files in its `Material:`
|
||||
sentence. Do not claim the remaining files have already been updated.
|
||||
3. Copy the selected revision's `docs/oss/licenses/CC-BY-SA-4.0.txt` byte-for-byte.
|
||||
Keep the supplied upstream copyright and links to its grant/disclaimer.
|
||||
4. Add the adoption guide's scoped CC-BY-SA notice to Audita's `COPYRIGHT`, with
|
||||
affected material identified through attribution. Preserve Audita's name,
|
||||
copyright, GPL-3.0-or-later application grant, warranty statement, and third-party
|
||||
statement. Leave the root GPLv3 `LICENSE` unchanged.
|
||||
5. Keep metadata local and truthful. `meta.md` points to the local attribution
|
||||
and developer guide even though selective reading guidance is added next.
|
||||
|
||||
**Validation and completion:** Compare the substantive agent/testing text directly
|
||||
with the selected upstream documents, allowing only template removal, metadata,
|
||||
and the identified discovery addition. Verify each new source link's exact file
|
||||
and revision, local attribution links, copied license bytes, and narrow grant
|
||||
scope. No application test or publication is required.
|
||||
|
||||
## Stage 2 — Customize Remaining Policies and Install Selective Orientation
|
||||
|
||||
**Completed:** 2026-09-28. Adopted architecture 1.3, documentation 1.11,
|
||||
release 1.4, and OSS 1.8 with the selected Audita variations. Installed the
|
||||
upstream root orientation and verbatim Policy Reading Guide, expanded the
|
||||
scoped attribution, and repaired the release documentation heading link.
|
||||
Checked versions, provenance and example destinations, local links, policy
|
||||
differences, and `git diff --check`.
|
||||
|
||||
**Files:** `docs/policy/architecture.md`, `docs/policy/documentation.md`,
|
||||
`docs/policy/release.md`, `docs/policy/oss.md`, `AGENTS.md`,
|
||||
`docs/development.md`, `docs/oss/attribution.md`, and `COPYRIGHT` as needed for
|
||||
accurate copied-guidance scope.
|
||||
|
||||
1. Adopt architecture 1.3. Retain the upstream general Purpose And Ownership,
|
||||
Architectural Approach, and Adopted Constraints And Implemented Structure
|
||||
guidance. Replace Application-Specific Topics with Audita's established
|
||||
purpose, ownership/dependency boundaries, correction/concurrency rules,
|
||||
recovery, state/compatibility, secret handling, and selected library ownership.
|
||||
Reuse existing local decisions; avoid duplicating general upstream prose.
|
||||
Replace example threat discussion with the existing secret/input boundaries
|
||||
and canonical links where useful. Do not infer new threat exclusions,
|
||||
filesystem guarantees, interfaces, or package restructuring from the template.
|
||||
2. Adopt documentation 1.11. Keep applicable upstream ownership rows verbatim;
|
||||
omit public HTTP and public Go API rows. Add the existing concrete ownership
|
||||
of `docs/integrations/output-files.md` and contributor change recipes, and
|
||||
retain the deliberate retirement of standalone troubleshooting documentation.
|
||||
Account for the retained agent discovery/commit responsibilities in its owner
|
||||
row. Keep reading triggers in development guidance, not a second policy table.
|
||||
3. Adopt release 1.4. Retain upstream completion, validation, guard, immutability,
|
||||
recovery, and preparation language. Preserve the existing Supported Platforms
|
||||
table and unsupported-platform statement as Audita's support commitment.
|
||||
Replace the upstream discretionary human-gate paragraph with Audita's selected
|
||||
rule against manual approvals, sign-offs, and routine confirmations as release
|
||||
gates. Remove the obsolete list describing now-shared upstream rules as local
|
||||
deviations. Keep concrete atomic-push mechanics in the runbook.
|
||||
4. Adopt OSS 1.8. Add a concise Audita context paragraph identifying the existing
|
||||
GPL-3.0-or-later grant and linking to COPYRIGHT and the release procedure for
|
||||
Gitea distribution. Use the upstream House Format and interpretation language
|
||||
verbatim. Pin application/library COPYRIGHT and attribution examples to the
|
||||
selected upstream commit; remove template-only setup text. No license change
|
||||
to application code or blanket dependency compatibility claim is authorized.
|
||||
5. Replace root orientation with upstream `agents/AGENTS.md` wording while
|
||||
retaining any existing applicable repository instructions. Keep detailed
|
||||
discovery rules in their current agent-policy owner rather than duplicating
|
||||
them in a newly created block.
|
||||
6. Insert the adoption guide's Policy Reading Guide and accompanying reading rules
|
||||
into `docs/development.md` verbatim. Remove the blanket architecture-reading
|
||||
instruction; preserve contributor commands and component-specific task rows.
|
||||
Adjust cross-links that would otherwise contradict selective reading.
|
||||
7. Expand the single policy attribution entry to identify all `docs/policy/`
|
||||
documents, adapted root orientation, and the copied Policy Reading Guide in
|
||||
`docs/development.md`. Scope the COPYRIGHT CC-BY-SA notice to those materials,
|
||||
not unrelated contributor prose or application documentation. Keep the material
|
||||
sentence factual and concise; retain the pinned upstream credit links.
|
||||
8. Find and repair local links to policy headings renamed by adoption, including
|
||||
the release correction heading. Do not edit published historical release
|
||||
notes to retrofit new headings or licensing conventions.
|
||||
|
||||
**Validation and completion:** Compare all seven policies to the pinned source;
|
||||
review every substantive difference against the roadmap's justified variations.
|
||||
Check versions (1.3, 1.3, 1.11, 1.3, 1.4, 1.0, 1.8 for agents, architecture,
|
||||
documentation, testing, release, meta, OSS respectively), file-specific source
|
||||
links, removed template sections, example destinations, ownership consistency,
|
||||
and selective reading. Temporary pending release/attribution implementation is
|
||||
completed by the following stages; do not create scaffolding for it.
|
||||
|
||||
## Stage 3 — Complete Component Attribution and README Navigation
|
||||
|
||||
**Completed:** 2026-09-28. Both CGO-disabled Linux target dependency lists
|
||||
selected the same eight production modules. Inspected their selected source
|
||||
notices and copied assets, excluded test-only dependencies, and resolved the
|
||||
Go 1.25.5 source tag and its four incorporated vendored modules. Added 14
|
||||
House Format entries including policy provenance, complete applicable license
|
||||
texts, and the README footer. Checked 33 pinned source and notice destinations,
|
||||
license bytes, local links, entry shape, and `git diff --check`.
|
||||
|
||||
**Files:** `docs/oss/attribution.md`, applicable texts under
|
||||
`docs/oss/licenses/`, and `README.md`. Add factual exception treatment to the OSS
|
||||
policy only if the actual inventory uncovers a concrete need.
|
||||
|
||||
1. Inventory actual incorporated material using the selected modules, production
|
||||
package dependencies for both Linux targets, source/assets, and shipped Go
|
||||
runtime. Use `go list -deps` for `./cmd/audita` with `CGO_ENABLED=0` and each
|
||||
target architecture, plus source inspection for copied material. Inspect test
|
||||
dependencies where relevant to included material; a go.mod entry or tool use
|
||||
alone is not sufficient reason for attribution. Do not change go.mod/go.sum.
|
||||
2. At the planning baseline, production dependencies include ConfigKit v0.4.1,
|
||||
PromptKit v0.11.1, both catalogs v2.20260926.0, jsonschema/v6 v6.0.2,
|
||||
yaml/v4 v4.0.0-rc.6, x/text v0.14.0, and yaml.v3 v3.0.1. Start with the four
|
||||
verified source commits recorded in the feature roadmap; resolve remaining
|
||||
module versions to exact source commits and inspect their COPYRIGHT, LICENSE,
|
||||
NOTICE, PATENTS, and relevant bundled material as applicable. Account for
|
||||
additional material discovered in that inspection rather than treating this
|
||||
starting list as an exhaustive guarantee.
|
||||
3. For the Go runtime, use the release build's configured Go 1.25.5 source tag
|
||||
and resolve it to its full source commit. Do not silently substitute the
|
||||
inspecting agent's installed toolchain (Go 1.26.8 during planning). Preserve
|
||||
actual runtime/standard-library notices, including relevant bundled third-party
|
||||
material. Document maintenance of this entry when the distributed toolchain
|
||||
changes; do not pin new toolchain behavior or reject other supported local Go
|
||||
versions merely to simplify attribution.
|
||||
4. Add entries following OSS 1.8 exactly, with selected module/version or material
|
||||
scope where useful. Preserve supplied copyrights and accurate license
|
||||
expressions; use the prescribed link labels and `[Source](COMMIT_URL).`
|
||||
spelling. Keep policy attribution first. Order other entries consistently by
|
||||
project name; ordering is presentation, not a new public contract.
|
||||
5. Copy applicable complete standard texts from verified sources, using the
|
||||
pinned reference collection where applicable. Share identical standard texts
|
||||
and include required companions (LGPLv3 and GPLv3 for the two libraries).
|
||||
Include upstream commit links when a file contains project-specific material
|
||||
in addition to standard wording. Preserve existing incorporated notices.
|
||||
6. Apply the adopted house interpretation for project-specific notice links.
|
||||
Put concrete exception reasoning in OSS policy or an appropriate decision
|
||||
record, never in attribution. Do not add missing-copyright filler, research
|
||||
narratives, inferred licensing choices, or legal conclusions to entries.
|
||||
7. End README with the two OSS statements, identifying Audita as GPL v3.0 or later
|
||||
and linking to `COPYRIGHT` and `docs/oss/attribution.md`. The linked grant owns
|
||||
the separately licensed policy scope; no duplicated notice list is needed.
|
||||
|
||||
**Validation and completion:** Inspect entries against selected source evidence,
|
||||
resolve every source/notice commit and path, compare standard license bytes, and
|
||||
check local links. Confirm that actual distributed material is accounted for
|
||||
without blindly including dependency graph or development-tool entries. Record
|
||||
concise inventory/check evidence under this stage; no new SBOM, scanner, durable
|
||||
inventory generator, or test suite is required.
|
||||
|
||||
## Stage 4 — Integrate Release Notes and Finish Cross-Document Validation
|
||||
|
||||
**Completed:** 2026-09-28. Wired the checked-in release note into the hosted
|
||||
release plugin, documented immutable-tag notice links and release preparation,
|
||||
repaired the specified historical roadmap references, and marked the feature
|
||||
roadmap implemented. Parsed the YAML, substituted `v2.0.0` to a tracked note,
|
||||
checked non-overwrite settings and candidate footer paths, reviewed all seven
|
||||
policies against the pinned source, and checked repository-local Markdown links
|
||||
and `git diff --check`. Hosted execution awaits the next real release.
|
||||
|
||||
**Files:** `.woodpecker/release.yml`, `docs/release.md`, affected documentation
|
||||
links, `docs/roadmap/policy.md`, and this plan. Repair the historical references
|
||||
specified below; do not retire unrelated roadmaps in this sprint.
|
||||
|
||||
1. Add this setting to the existing `publish-release` step:
|
||||
|
||||
```yaml
|
||||
note: docs/releases/${CI_COMMIT_TAG}.md
|
||||
```
|
||||
|
||||
The [official release-plugin documentation](https://woodpecker-ci.org/plugins/release)
|
||||
supports a file path in `note`; the
|
||||
[environment reference](https://woodpecker-ci.org/docs/usage/environment)
|
||||
makes `CI_COMMIT_TAG` available for configuration substitution. These interfaces
|
||||
were checked during planning. Use the checked-out tagged note directly; no
|
||||
generator, custom publisher, or additional dependency is needed. Preserve
|
||||
`overwrite: false`, `file-exists: skip`, existing assets/checksum settings,
|
||||
secret reference, image, and step dependency.
|
||||
2. In `docs/release.md`, add the footer preparation instruction with this pattern
|
||||
(substitute the selected release version for `<version>`):
|
||||
|
||||
```markdown
|
||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/COPYRIGHT) | [LICENSE](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/LICENSE) | [ATTRIBUTION](https://gitea.maximumdirect.net/eric/audita/src/tag/<version>/docs/oss/attribution.md)
|
||||
```
|
||||
|
||||
Explain that the plugin uses the checked-in note for new hosted releases and
|
||||
preserves existing release information on retries. Keep old notes and pages
|
||||
intact. Validate intended paths locally during preparation; do not add remote
|
||||
footer checks, a footer parser, or a new release-script gate.
|
||||
3. Align the runbook with the adopted policy: retain `origin`, `main`, atomic
|
||||
source/tag publication, one offline validation pass, required Linux builds,
|
||||
optional check mode, and asynchronous immutable delivery retries. Reference
|
||||
the policy for requirements rather than introducing additional ones. Add
|
||||
proportionate completed-roadmap retirement guidance for future release
|
||||
preparation without making it a script-enforced condition. No release script
|
||||
change is expected from this adoption.
|
||||
4. Repair both current-plan links in `decision-set-reconciliation.md` to the
|
||||
historical plan at the full Audita planning baseline listed above. Remove
|
||||
the stale sentence in `library-adoption.md` saying the current implementation
|
||||
plan covers span deletion. Preserve historical records and deferred work.
|
||||
5. Review the final adoption diff against upstream and the feature roadmap.
|
||||
Check all policy source metadata, template removal, local exception reasons,
|
||||
copied-material scope, license text fidelity, local links/anchors, and pinned
|
||||
upstream destinations. Ensure the feature roadmap records implemented status
|
||||
only after its accepted outcomes are achieved.
|
||||
6. Parse/review the affected YAML using an available YAML parser or Woodpecker
|
||||
linter. Substitute a representative existing release tag locally and confirm
|
||||
the note path resolves to the tracked note; old notes need not have the new
|
||||
footer. Check a temporary example of the new footer against candidate paths.
|
||||
Verify non-overwriting publication settings remain unchanged. Do not call the
|
||||
forge to create a test release, run a plugin with production credentials, or
|
||||
wait for CI. Static configuration and documented plugin-interface validation
|
||||
are sufficient for this wiring change; report that hosted execution awaits
|
||||
the next real release rather than claiming it was exercised.
|
||||
|
||||
**Validation and completion:** Run `git diff --check`, review staged content and
|
||||
all affected links, and record the final verification evidence. No full Go suite
|
||||
or build matrix is required when only documents and the note setting changed.
|
||||
If an actual release-script behavior change becomes necessary, justify its
|
||||
scope and run focused `go test ./scripts` coverage for that behavior rather than
|
||||
inventing additional release gates. Commit the completed work; leave a clean
|
||||
workspace without publishing.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None requiring a policy or design decision before implementation. The upstream
|
||||
revision, local exceptions, attribution arrangement, target documents, and
|
||||
release-body mechanism are selected. Exact component notice details and source
|
||||
revisions are factual verification work in Stage 3, not permission gates. If
|
||||
that inspection reveals an uncovered obligation, follow the adopted exception
|
||||
procedure and identify the concrete decision instead of silently expanding scope.
|
||||
128
docs/roadmap/library-adoption.md
Normal file
128
docs/roadmap/library-adoption.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Coordinated ConfigKit and PromptKit Adoption
|
||||
|
||||
**Last updated:** 2026-09-28
|
||||
|
||||
**Status:** Production implementation complete. ConfigKit v0.4.2 and PromptKit
|
||||
v0.11.2 are adopted; [historical implementation evidence](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md) records the
|
||||
completed checks. Release compliance and publication remain separate work.
|
||||
|
||||
## Goal and Ownership
|
||||
|
||||
Adopt ConfigKit and PromptKit to align Audita with the application suite's shared
|
||||
configuration and LLM execution conventions. Consistency is the primary benefit;
|
||||
removing overlapping application infrastructure is a secondary benefit. Preserve
|
||||
Audita's transcript-correction capabilities and domain protections.
|
||||
|
||||
| Owner | Responsibilities |
|
||||
| --- | --- |
|
||||
| ConfigKit | Strict application configuration loading, presence/default semantics, explicit overrides, recorded resolution, secret references, and safe inspection |
|
||||
| PromptKit | Prompt/profile formats and rendering, provider calls, structural output validation and repair, transient retries, engine-local backend admission, and execution observations |
|
||||
| Audita | Setting meanings, file/CLI selection, role/profile association, normalization/chunking, ordered modules, domain validation, correction application, reports, diagnostic redaction, and artifact lifecycle |
|
||||
|
||||
The [configuration roadmap](configkit.md) owns configuration and inspection policy.
|
||||
The [boundary findings](library-boundary-findings.md) own the selected defaults,
|
||||
full migration inventory, failure mapping, and prototype evidence. The selected
|
||||
production versions are ConfigKit v0.4.2 and PromptKit v0.11.2, with Go 1.25.5 as
|
||||
the minimum. Use published modules, never sibling checkouts or local replacements.
|
||||
The existing YAML dependency remains while glossary parsing needs it.
|
||||
|
||||
## Migration Posture
|
||||
|
||||
This is an intentional breaking transition targeting Audita v2.0.0. No backward
|
||||
compatibility is required for existing installations, config files, CLI flags,
|
||||
environment overlays, or inspection output. Provide one migration guide, without
|
||||
legacy loaders, aliases, dual modes, or automatic conversion tooling.
|
||||
|
||||
Both libraries belong to one refactor. Intermediate commits need not build or run;
|
||||
there is no supported intermediate product state. No temporary adapters, compatibility
|
||||
shims, or processing gates are needed. The complete application must work and pass
|
||||
its checks before the refactor is finished. Release compliance and publication
|
||||
come last, with no intermediate public release.
|
||||
|
||||
## Configuration and Execution Target
|
||||
|
||||
ConfigKit selected overlays enable a testing configuration that chooses cheaper or
|
||||
faster models. The example selects both proposal and validation profiles. ConfigKit
|
||||
application overlays and PromptKit execution profiles remain separate concepts.
|
||||
Complete operator-maintained profiles own model/generation controls; embedded
|
||||
application prompts and schemas are not operator-selected files. No catalog wiring,
|
||||
profile-inheritance feature, ConfigKit imports, or secret-directory bootstrap is
|
||||
part of this migration.
|
||||
|
||||
Capacity controls serve two needs: respecting a local service's hard simultaneous-
|
||||
query limit and bounding concurrent paid API activity. One finite limit per backend
|
||||
is shared across both roles and every initial, retry, and repair attempt. Limits
|
||||
are engine-local, not coordinated across processes. No additional global or
|
||||
per-role limiter or fine-grained scheduling policy is required. Profiles must use
|
||||
registered backends and ConfigKit-resolved credentials; endpoint-only bypass and
|
||||
competing profile credential lookup are excluded.
|
||||
|
||||
Structural repair is enabled by default for both roles because additional attempts
|
||||
to obtain valid output are desired. Transient retries and structural repairs have
|
||||
separate budgets; explicit zero disables the respective behavior. Each generation,
|
||||
including a repair, receives its own transient-retry budget. The Audita logical-call
|
||||
deadline covers preparation, waiting, backoff, all generations, and repairs; profile
|
||||
HTTP timeouts apply per attempt. Exact defaults and bounds are in the
|
||||
[selected contract](library-boundary-findings.md#configuration-and-profile-contract).
|
||||
No Audita outer retry loop restores the old broader retry policy.
|
||||
|
||||
Audita retains all four correction modules, five LLM-validator prompts,
|
||||
deterministic validators, confidence/applicability checks, glossary protection,
|
||||
validation batching/cardinality, deterministic proposal and ledger ordering,
|
||||
transcript encoders, and artifact retention. PromptKit-valid JSON still passes
|
||||
Audita's domain checks. Repair exhaustion, provider failure, and domain rejection
|
||||
follow the [selected failure table](library-boundary-findings.md#execution-and-failure-mapping).
|
||||
Retention and transcript timestamp changes remain separate work; this migration
|
||||
resolves the [retry-count follow-up](runtime-behavior.md).
|
||||
|
||||
## Reporting and Diagnostic Target
|
||||
|
||||
Keep stable Audita-owned serialized records; do not expose raw library structs.
|
||||
Use process report schema `v2` with the existing domain outcomes and a new
|
||||
`llm_summary` separating logical calls, dispatched provider attempts, transient
|
||||
retries, structural repairs, and usage. Transcript schema versions remain unchanged.
|
||||
The implementation plan specifies the concrete new fields and artifact wiring.
|
||||
|
||||
Usage distinguishes known zero, unknown, and incomplete totals. Preserve observations
|
||||
from failed calls even when no final result exists. Count terminal totals once;
|
||||
attempt observations provide diagnosis without being added to those totals again.
|
||||
This is operational evidence, not a complete billing ledger.
|
||||
|
||||
Replace global/role scheduler utilization with per-backend configured capacity and
|
||||
observed queue/generation/retry/logical-call timing. Do not fabricate measurements
|
||||
that the event API does not provide. Keep domain timing and deterministic correction
|
||||
ledger ordering. Record prompt definition/rendered hashes and selected profile/model
|
||||
without promising the old hash values. Callbacks are short, concurrency-safe, and
|
||||
free of blocking I/O or waits on their own execution.
|
||||
|
||||
Effective configuration and selected-profile snapshots remain distinct safe views.
|
||||
Secret values must not escape through inspection, logs, reports, runtime errors,
|
||||
or retained diagnostic files. Observation records exclude payloads, URLs, raw
|
||||
provider messages, prompts, and credentials. Existing artifact lifecycle and
|
||||
partial-failure handling remain Audita responsibilities.
|
||||
|
||||
## Completion Criteria and Release Boundary
|
||||
|
||||
- Both libraries own their selected responsibilities in the production application.
|
||||
Superseded loaders, transport, renderers, schedulers, aliases, and the isolated
|
||||
prototype are gone once its useful evidence is represented in production tests.
|
||||
- Offline tests prove configuration-to-execution routing for both roles, selected
|
||||
overlays and explicit overrides, shared backend capacity, retry/repair outcomes,
|
||||
cancellation/deadlines, domain decisions, redaction, and truthful partial reports.
|
||||
Tests exercise real internal collaborators and controlled HTTP boundaries.
|
||||
- Maintained examples and canonical docs describe the implemented final model.
|
||||
One migration guide covers files, flags, environment inputs, profiles, credentials,
|
||||
overlays, inspection, and changed runtime/report/diagnostic semantics.
|
||||
- The assembled application passes its required checks; Linux amd64 and arm64 build.
|
||||
macOS arm64 remains best effort. No live-provider or CI-success gate is added.
|
||||
|
||||
PromptKit v0.11.0's reviewed retry, observation, and capacity APIs remove the earlier
|
||||
upstream feature prerequisites; no upstream edit is required for adoption. The
|
||||
prototype proved representative behavior, not release compliance or model quality.
|
||||
|
||||
The selected PromptKit release uses LGPL-3.0-or-later. A later release unit must
|
||||
review the actual production dependency graph and distribution requirements,
|
||||
including notices and source/rebuild materials, before binary publication. This
|
||||
implementation plan does not claim that review is complete. Release publication
|
||||
uses the existing [procedure](../release.md) and completes on successful source/tag
|
||||
push, without waiting for CI or artifact delivery.
|
||||
392
docs/roadmap/library-boundary-findings.md
Normal file
392
docs/roadmap/library-boundary-findings.md
Normal file
@@ -0,0 +1,392 @@
|
||||
# Shared Library Boundary: Decisions and Evidence
|
||||
|
||||
**Status:** Boundary and offline prototype completed, 2026-09-23. Selected prototype contract and proposed
|
||||
production migration target; not the current Audita configuration contract.
|
||||
The [bounded roadmap](library-boundary.md) owns scope and completion criteria.
|
||||
|
||||
**Subsequent scope decision:** The [ConfigKit overlay plan](configkit.md#selected-overlays-for-testing)
|
||||
adds optional selected overlays, with v0.4.0 as the migration baseline. It supersedes
|
||||
the original no-overlay decision and adds an input layer between the main file and
|
||||
explicit setting overrides. The v0.3.1 prototype results below remain historical
|
||||
evidence; they do not establish overlay integration.
|
||||
|
||||
## Selected Boundary
|
||||
|
||||
The former prototype is retained in Git history at `590604b`; it was a separate
|
||||
Go module using published ConfigKit v0.4.0, PromptKit v0.11.0, and
|
||||
Audita v1.1.0. The Audita dependency lets this consumer reuse actual internal domain
|
||||
helpers through its Audita module namespace without a local replacement. It does
|
||||
not make those internal packages a new public API. Remove this dependency along
|
||||
with the prototype after equivalent production integration tests landed.
|
||||
|
||||
The initial prototype results below were recorded with ConfigKit v0.3.1. On
|
||||
2026-09-24, upgrading only its ConfigKit pin and sums to v0.4.0 required no source
|
||||
changes. With Go 1.26.8 on linux/amd64, the nested offline `go test ./...` passed
|
||||
and `go run .` still reported one accepted correction, four attempts, zero
|
||||
transient retries, and two structural repairs. This verifies the dependency
|
||||
upgrade, not selected-overlay behavior.
|
||||
|
||||
ConfigKit owns loading, presence, explicit overrides, secret resolution, and
|
||||
redacted effective settings. PromptKit owns profile parsing, rendering, provider
|
||||
execution, transient retries, structural repair, and backend admission. Audita
|
||||
owns file selection, setting meanings, role selection, domain acceptance, and
|
||||
mapping execution facts into reports. Production CLI and runtime remain unchanged.
|
||||
|
||||
## Configuration and Profile Contract
|
||||
|
||||
Selected for the prototype and recommended for production:
|
||||
|
||||
- Main YAML requires integer `version: 2`; absent, null, unknown fields, and older
|
||||
versions fail. No legacy parser, aliases, environment overlays, or automatic
|
||||
conversion. Defaults precede the selected file; explicitly supplied CLI settings
|
||||
become ConfigKit overrides. Validation runs on the resolved result, so an override
|
||||
may repair an invalid lower-precedence setting when decoding succeeds.
|
||||
- Production file selection: explicit `--config`, then
|
||||
`/usr/local/etc/audita/config.yml`, then `/etc/audita/config.yml`. Select one file;
|
||||
do not merge them. Missing system files are skipped; explicit missing or empty
|
||||
paths and inaccessible selected files fail. No selected file fails with a request
|
||||
to configure backend/profile selection: no hidden provider or model default.
|
||||
Remove `AUDITA_CONFIG`. The prototype loads its explicit fixture only; discovery
|
||||
and command parsing belong to the ConfigKit implementation stage.
|
||||
- `profiles_dir` defaults to `profiles`, resolved relative to the selected main
|
||||
configuration file, with absolute paths accepted. PromptKit reads that directory.
|
||||
Prompts and schemas are application-embedded, not operator-selected prompt files.
|
||||
The prototype uses complete application-owned profile files. Catalog profiles and
|
||||
profile inheritance are not needed for this migration; do not add catalog wiring.
|
||||
- `backends.<id>.endpoint` is required. Use one application backend identity per
|
||||
service capacity pool. Do not split proposal and validation into different backend
|
||||
IDs when they use the same service. Limits are engine-local, not shared across
|
||||
multiple Audita processes or other applications.
|
||||
- `backends.<id>.concurrency` defaults to **1**, must be positive, and is shared by
|
||||
both roles and all initial/retry/repair attempts. Operators can select **4** for
|
||||
the described local backend or a suitable finite paid API limit. There is no
|
||||
additional global or per-role limiter. `queue_capacity` defaults to **1024**,
|
||||
following PromptKit; non-negative, with zero meaning no waiting admission.
|
||||
This is an operational escape hatch rather than a second scheduling hierarchy.
|
||||
- `backends.<id>.credential` is an optional ConfigKit secret reference: a scalar
|
||||
environment variable name. Omission or null means no credential. A supplied
|
||||
reference must resolve to a nonempty value, including during validation and
|
||||
inspection. There is no direct key field or CLI key flag. ConfigKit resolves it
|
||||
once and Audita supplies `RunRequest.APIKey`. Profiles must not introduce another
|
||||
`api_key_env` lookup. Backend credentials also support unauthenticated local use.
|
||||
- Profiles own model, temperature, output token limit, top-p, per-generation timeout,
|
||||
service tier, reasoning effort, and extra provider parameters using PromptKit's
|
||||
format. They select the application `backend`; their effective endpoint must
|
||||
equal that backend's endpoint. Endpoint-only execution is rejected because it
|
||||
bypasses the requested finite capacity boundary. A named registered backend is
|
||||
mandatory even if both roles use the same profile.
|
||||
- `llm.proposal_profile` is required. Omitted `llm.validation_profile` inherits the
|
||||
final proposal profile as a whole, with ConfigKit recording the derivation.
|
||||
Explicit empty or null values fail; no individual model/endpoint/key inheritance.
|
||||
- `llm.transient_retries` defaults to **2** additional attempts per generation;
|
||||
explicit zero disables retries; negative is invalid. PromptKit owns which failures
|
||||
are eligible. Do not add an Audita retry loop.
|
||||
- `llm.repair_attempts` defaults to **2** additional generations for both roles;
|
||||
explicit zero disables repair when deliberately requested. PromptKit supports
|
||||
0–3. Positive defaults are exercised in the prototype. Audita owns this common
|
||||
setting and supplies a complete request output contract with the role's embedded
|
||||
schema, avoiding separate user-facing repair defaults in each prompt.
|
||||
- `llm.operation_timeout` defaults to **15m**, must be positive, and uses a Go
|
||||
duration string. It starts before each logical proposal/assessment call and covers
|
||||
preparation, capacity waiting, transient backoff, generation, and repairs. It is
|
||||
separate from whole-process cancellation. Profile `timeout_seconds` defaults to
|
||||
PromptKit's **600** seconds and is applied afresh to each built-in HTTP attempt.
|
||||
It does not bound the combined retry/repair sequence. A stricter caller/transport timeout can
|
||||
also end execution. The two defaults are selected starting points, not throughput
|
||||
measurements. With the default T=2 and R=2, each logical call dispatches at most
|
||||
**9** attempts before deadline/cancellation; proposal plus assessment may use 18.
|
||||
- Omission retains static defaults or invokes the recorded role/backend derivations.
|
||||
Null is not a general synonym for omission: nonoptional scalars reject it. Optional
|
||||
credentials and the future optional section target accept null. Explicit empty
|
||||
module lists will mean an empty correction pipeline, not “restore defaults.”
|
||||
Repeated modules retain their existing ordered meaning.
|
||||
- The original prototype disabled ConfigKit imports, selected configuration layers
|
||||
(then called configuration profiles), and secret-directory bootstrap. Selected
|
||||
overlays are now verified under the linked overlay decision; the other two
|
||||
features remain disabled. PromptKit execution profiles retain their meaning.
|
||||
|
||||
Configuration validation/inspection must assemble and inspect both selected profiles
|
||||
without provider calls. ConfigKit's effective YAML describes only its loaded state;
|
||||
a separate selected-profile view shows effective model controls/backend selection.
|
||||
Do not imply either snapshot alone represents the full execution configuration.
|
||||
The prototype exercises the two APIs but does not implement production subcommands.
|
||||
Do not serialize raw profile/library objects as a permanent Audita report schema.
|
||||
|
||||
## Migration Inventory
|
||||
|
||||
This inventory covers the current configuration and process flags documented in
|
||||
[configuration](../config.md) and [CLI](../cli.md), including environment-only fields.
|
||||
“Retain” below means retain domain meaning in the new schema, not accept old files.
|
||||
All legacy environment overlays listed afterward are removed.
|
||||
|
||||
| Current file field / setting | Current CLI flag(s) | Target and rationale |
|
||||
| --- | --- | --- |
|
||||
| File selection | `--config` | Retain explicit invocation flag; discovery described above. |
|
||||
| Transcript input | positional path | Invocation only; retain one transcript path. |
|
||||
| Glossary input | `--glossary` | Invocation only; retain required glossary path. |
|
||||
| Corrected output | `--output` | Invocation only; retain stdout fallback. |
|
||||
| Report output | `--report-json` | Invocation only; retain separate report file. |
|
||||
| `pipeline.modules` | `--modules` | Retain sequence/default `[glossary, homophones, glossary, spoken_word, grammar]`; explicit empty clears rather than inherits. |
|
||||
| `output.schema` | `--output-schema` | Retain encoder selection/default `bare-segments`. |
|
||||
| `llm.proposal.base_url`, `llm.validation.base_url` | `--base-url`, `--validation-base-url` | Replace with backend endpoint; remove per-role endpoint flags. |
|
||||
| Both `llm.*.model` | `--model`, `--validation-model` | Replace with profile model; new `--proposal-profile` / `--validation-profile` select whole profiles. |
|
||||
| Both `llm.*.api_key_env`, direct runtime keys | `--llm-api-key`, `--validation-llm-api-key` | Replace with backend ConfigKit secret reference; remove direct key flags. |
|
||||
| Both `llm.*.timeout` | `--llm-timeout-seconds`, `--validation-llm-timeout-seconds` | Replace with profile `timeout_seconds`, plus `llm.operation_timeout`; no duplicate timeout flags. |
|
||||
| Both `llm.*.max_retries` | `--max-retries`, `--validation-max-retries` | Replace with common `llm.transient_retries` and distinct `llm.repair_attempts`; remove misleading old flags. |
|
||||
| `concurrency.total_llm` | `--total-llm-concurrency`, `--llm-concurrency` | Replace with per-backend concurrency; remove global/alias flags. |
|
||||
| `concurrency.proposal_llm`, `concurrency.validation_llm` | `--proposal-llm-concurrency`, `--validation-llm-concurrency` | Remove role budgets; shared backend handles service capacity. |
|
||||
| Validation prompt budget (no old YAML field) | `--validation-max-prompt-tokens` | Add `validation.max_prompt_tokens`, default 2048, positive; retain explicit flag override. Audita owns batching. |
|
||||
| `chunking.target_sections` | `--target-sections` | Retain optional positive target; omission/null means automatic, zero invalid. |
|
||||
| `chunking.max_section_tokens` | `--max-section-tokens` | Retain 8192, positive. |
|
||||
| `chunking.min_section_tokens` | `--min-section-tokens` | Retain 2048, positive, no greater than maximum. |
|
||||
| `normalization.max_segment_gap` | `--normalize-max-segment-gap` | Retain 4.0 numeric seconds, non-negative; drop alternate YAML duration syntax for these domain numeric fields. |
|
||||
| `normalization.ellipsis_gap` | `--normalize-ellipsis-gap` | Retain 3.5 numeric seconds, non-negative. |
|
||||
| `normalization.max_segment_duration` | `--normalize-max-segment-duration` | Retain 60.0 numeric seconds, positive. |
|
||||
| `normalization.max_segment_tokens` | `--normalize-max-segment-tokens` | Retain 2048, positive. |
|
||||
| `thresholds.glossary` | `--glossary-confidence-threshold` | Retain 0.8 in [0,1]. |
|
||||
| `thresholds.homophones` | `--homophones-confidence-threshold` | Retain 0.8 in [0,1]. |
|
||||
| `thresholds.spoken_word` | `--spoken-word-confidence-threshold` | Retain 0.8 in [0,1]. |
|
||||
| `thresholds.grammar` | `--grammar-confidence-threshold` | Retain 0.8 in [0,1]. |
|
||||
| `context.description` | `--transcript-description` | Retain trimming and 500-byte limit; empty clears context. |
|
||||
| `diagnostics.work_dir` | `--work-dir` | Retain `/tmp/audita`, nonempty; artifact lifecycle remains Audita-owned. |
|
||||
| `diagnostics.retention` | `--work-dir-retention` | Retain `auto` default and selection; existing `never` follow-up is separate. |
|
||||
| Help/version/config commands | `--help`, `-h` | Retain command purpose; help should parse before loading configuration. Effective-config output intentionally becomes ConfigKit YAML, not legacy JSON. |
|
||||
|
||||
Retained setting flags become explicit ConfigKit overrides only when supplied;
|
||||
CLI parser defaults must not overwrite file values. Normalization flag values stay
|
||||
numeric seconds. Domain values convert into existing domain structs after validation;
|
||||
do not spread ConfigKit or PromptKit types into correction algorithms.
|
||||
|
||||
Complete environment removal map (names remain permissible if explicitly named as
|
||||
secret references; none have implicit configuration meaning):
|
||||
|
||||
| Old environment names | Replacement |
|
||||
| --- | --- |
|
||||
| `AUDITA_CONFIG` | File selection above. |
|
||||
| `AUDITA_MODULES` | `pipeline.modules` / explicit flag. |
|
||||
| `AUDITA_LLM_API_KEY`, `OPENROUTER_API_KEY`, `AUDITA_VALIDATION_LLM_API_KEY` | Explicit backend credential references; no implicit fallback. |
|
||||
| `AUDITA_MODEL`, `AUDITA_VALIDATION_MODEL` | Profile files and role selection. |
|
||||
| `AUDITA_BASE_URL`, `AUDITA_VALIDATION_BASE_URL` | Backend endpoints. |
|
||||
| `AUDITA_LLM_TIMEOUT_SECONDS`, `AUDITA_VALIDATION_LLM_TIMEOUT_SECONDS` | Profile timeout and operation deadline. |
|
||||
| `AUDITA_MAX_RETRIES`, `AUDITA_VALIDATION_MAX_RETRIES` | Common transient/repair settings. |
|
||||
| `AUDITA_TOTAL_LLM_CONCURRENCY`, `AUDITA_LLM_CONCURRENCY`, `AUDITA_PROPOSAL_LLM_CONCURRENCY`, `AUDITA_VALIDATION_LLM_CONCURRENCY` | Backend concurrency; remove alias/role budgets. |
|
||||
| `AUDITA_VALIDATION_MAX_PROMPT_TOKENS` | `validation.max_prompt_tokens` / explicit flag. |
|
||||
| `AUDITA_TARGET_SECTIONS`, `AUDITA_MAX_SECTION_TOKENS`, `AUDITA_MIN_SECTION_TOKENS` | Corresponding chunking fields / flags. |
|
||||
| `AUDITA_NORMALIZE_MAX_SEGMENT_GAP`, `AUDITA_NORMALIZE_ELLIPSIS_GAP`, `AUDITA_NORMALIZE_MAX_SEGMENT_DURATION`, `AUDITA_NORMALIZE_MAX_SEGMENT_TOKENS` | Corresponding normalization fields / flags. |
|
||||
| `AUDITA_GLOSSARY_CONFIDENCE_THRESHOLD`, `AUDITA_HOMOPHONES_CONFIDENCE_THRESHOLD`, `AUDITA_SPOKEN_WORD_CONFIDENCE_THRESHOLD`, `AUDITA_GRAMMAR_CONFIDENCE_THRESHOLD` | Corresponding threshold fields / flags. |
|
||||
| `AUDITA_WORK_DIR`, `AUDITA_WORK_DIR_RETENTION` | Diagnostics fields / flags. |
|
||||
|
||||
## Execution and Failure Mapping
|
||||
|
||||
The executable uses grammar proposal plus grammar review, current response schemas,
|
||||
current hardening text, transcript-section/description helpers, proposal preview, and
|
||||
actual decision-cardinality enforcement from Audita v1.1.0. PromptKit renders the
|
||||
adapted templates; the custom HTTP transport supplies OpenAI-compatible responses.
|
||||
The prototype pre-expands Audita's `hardening` template function into the embedded
|
||||
PromptKit definitions; it passes existing named string variables unchanged. No
|
||||
provider, paid call, or injected high-level LLM client participates.
|
||||
|
||||
Generated JSON is structurally validated/repaired by PromptKit before Audita decodes
|
||||
it. Audita then checks proposal applicability, confidence, and decision identity and
|
||||
cardinality. The demonstration previews corrections without mutation. Production
|
||||
retains every module's full validator chain, glossary protection, batching, and
|
||||
apply-time checks; the representative prototype does not claim to replace them.
|
||||
|
||||
| Outcome | Section/batch effect | Overall run |
|
||||
| --- | --- | --- |
|
||||
| Structural repair succeeds | Continue domain validation. | Normal execution. |
|
||||
| Proposal repair exhausted | No proposals from this section; malformed-output warning. | Continue other work; successful completion may include warnings. |
|
||||
| Assessment repair exhausted | Reject this batch; malformed-output warning. | Continue other work. |
|
||||
| Schema-valid invalid/missing/duplicate decision indices | Reject batch and warn; no semantic retry/repair. | Continue other work. |
|
||||
| Inapplicable/low-confidence proposal or negative assessment | Reject affected proposal; preserve domain reasons. | Continue other work. |
|
||||
| Provider failure, retry exhaustion, transport or malformed HTTP response | Stop affected operation; retain available observations. | Runtime failure; cancel remaining work, retain existing Audita diagnostic handling. |
|
||||
| Deadline, caller cancellation, capacity admission failure | Stop affected operation; no outer retry or fabricated output. | Runtime failure with distinct classified cause. |
|
||||
| Invalid settings/profile/schema setup | Fail before processing where detectable. | Configuration error for user input, runtime error for broken embedded assets. |
|
||||
|
||||
Zero transient retries produces one ordinary provider failure, not
|
||||
`ErrRetriesExhausted`; the latter signals an exhausted **positive** budget.
|
||||
Provider failures retain a typed cause. Do not expose raw provider messages through
|
||||
user diagnostics: continue Audita's separate secret-redaction boundary. A failed
|
||||
logical call may return no result while its observations still record completed
|
||||
attempts or an earlier successful generation. Already completed domain results can
|
||||
remain in diagnostics; failure must not be presented as a fully corrected output.
|
||||
|
||||
## Observation and Report Handoff
|
||||
|
||||
The prototype maps library events into Audita-owned records under a short mutex.
|
||||
Records contain logical run/role/backend/profile identity, generation and attempt
|
||||
indices, dispatch state, queue/generation/retry/wall timing, classified outcomes,
|
||||
HTTP status, exhaustion, repair/retry counts, and each usage field's value,
|
||||
knownness, and completeness. It omits URLs, credentials, payloads, raw provider
|
||||
errors, and prompt text. Identifiers themselves are metadata, not a secret channel.
|
||||
|
||||
Use terminal records once for logical totals; retain attempt records for diagnosis
|
||||
without adding them to terminal totals. A known zero is distinct from unknown;
|
||||
partial totals remain incomplete after unmetered failed attempts. These observations
|
||||
are not a billing ledger. Callback code must not wait on its own run's progress.
|
||||
|
||||
Production report changes must distinguish logical calls from dispatched provider
|
||||
attempts. Replace scheduler utilization fields based on global/proposal/validation
|
||||
pools with per-backend admission/active timing. Preserve deterministic ledger and
|
||||
validator ordering. Map prompt definition/rendered hashes and selected profile/model
|
||||
into request metadata, but do not promise equality with legacy prompt hashes or
|
||||
serialize PromptKit's raw event struct as the stable report contract. Update the
|
||||
output integration reference, report mapper tests, and downstream migration guide
|
||||
when the production representation is implemented.
|
||||
|
||||
## Verification and Remaining Handoff
|
||||
|
||||
The focused matrix is implemented in the nested module:
|
||||
|
||||
| Roadmap scenario | Evidence |
|
||||
| --- | --- |
|
||||
| Successful assembled path | `go run .`; `TestWorkflowBoundaries/repair_both_roles`; actual Audita domain helpers and both selected profiles. |
|
||||
| Presence, overrides, inheritance | `TestConfigurationContract`: omitted role/backend values, explicit zero, null/empty, version, unknown keys, and explicit overrides. |
|
||||
| Credentials | Missing/unset and empty references fail; optional null accepted; effective/profile inspection redacted; HTTP authorization verified; no secret/prompt text in observations. `TestProfilesRespectSharedBackendBoundary` rejects competing lookup and capacity bypass. |
|
||||
| Both roles repaired | `repair_both_roles`: four attempts, two repairs, one accepted correction. |
|
||||
| Repair exhausted | Proposal and assessment exhaustion subtests: bounded counts and selected warning/rejection outcomes. |
|
||||
| Semantic boundary | Missing span, missing/duplicate decision indices, negative assessment; no semantic repair loop. |
|
||||
| Retry/zero/exhaustion | 429 recovery, zero-budget 503, positive-budget exhaustion after completed proposal; typed error assertions. |
|
||||
| Combined budgets | 503 → invalid JSON → repair 503 → valid proposal → assessment: five attempts, two transient retries, one repair. |
|
||||
| Shared capacity | `TestSharedCapacityAndRecovery`: caps four and two, both roles, a retry and repair, queue rejection, measured peak equal to cap, later successful call. |
|
||||
| Waiting/cancellation/deadline | `TestQueuedCancellationAndDeadline`; `TestDeadlineStopsRetryAfter`: no queued dispatch after cancellation/deadline and a 60-second provider retry delay interrupted by the operation deadline. |
|
||||
| Failed-run observations | `TestPartialUsageOnFailedRun`: valid HTTP output with known-zero usage followed by repair failure; nil result, retained events, incomplete known aggregate, correct counts. |
|
||||
| Representative assets | `TestRealPromptRenderingParity` compares both rendered message pairs to Audita v1.1.0; `TestSchemaFixturesMatchAudita` compares schema bytes. |
|
||||
|
||||
Commands executed from `examples/library-adoption` on Linux amd64 with Go 1.26.8:
|
||||
|
||||
```sh
|
||||
GOWORK=off go mod download all
|
||||
GOWORK=off GOPROXY=off GOSUMDB=off go mod verify
|
||||
GOWORK=off GOPROXY=off GOSUMDB=off go run .
|
||||
GOWORK=off GOPROXY=off GOSUMDB=off go test -race ./...
|
||||
GOWORK=off GOPROXY=off GOSUMDB=off go vet ./...
|
||||
```
|
||||
|
||||
All passed. The demonstration reports accepted=1, rejected=0, attempts=4,
|
||||
transient_retries=0, structural_repairs=2. Module verification reports all modules
|
||||
verified. Published tag availability was checked with `git ls-remote --tags` for
|
||||
ConfigKit v0.3.1 and PromptKit v0.11.0; successful module acquisition verifies this
|
||||
is not merely a local-checkout experiment. The module has no replacements.
|
||||
|
||||
The minimum Go 1.25.5 toolchain was also exercised with offline tests and the same
|
||||
successful demonstration. The exact installed-toolchain invocation was:
|
||||
|
||||
```sh
|
||||
GOTOOLCHAIN=local GOWORK=off GOPROXY=off GOSUMDB=off /home/eric/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.5.linux-amd64/bin/go test ./...
|
||||
GOTOOLCHAIN=local GOWORK=off GOPROXY=off GOSUMDB=off /home/eric/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.5.linux-amd64/bin/go run .
|
||||
```
|
||||
|
||||
An initial attempt to select that cached toolchain through `GOTOOLCHAIN=go1.25.5`
|
||||
with checksum verification disabled was rejected by Go's toolchain verifier. Using
|
||||
the installed binary with `GOTOOLCHAIN=local` proved offline execution without
|
||||
weakening dependency checks. The portable README commands assume an installed
|
||||
sufficiently new Go executable on PATH and disable toolchain switching.
|
||||
|
||||
From the Audita root, `go test ./...` and
|
||||
`go build -o ./bin/audita ./cmd/audita` passed. These check existing production code;
|
||||
they do not cover the nested module. Affected relative documentation links,
|
||||
inventory coverage, and `git diff --check` were checked separately.
|
||||
|
||||
### Findings and Limits
|
||||
|
||||
No adoption-blocking upstream API gap was found. Two integration details deserve
|
||||
explicit attention: PromptKit's profile GoDoc calls `timeout_seconds` a generation
|
||||
deadline, but its built-in HTTP path applies it separately to each attempt; the
|
||||
consumer therefore needs the selected total-operation deadline. Also,
|
||||
`APIKeyRequired` is an in-memory profile facility, not a profile-YAML field. The
|
||||
file-profile design uses the presence of ConfigKit's optional credential reference
|
||||
to require local secret resolution; it does not invent a new PromptKit YAML key.
|
||||
|
||||
The chosen defaults are proposed operational policy, not measured model-quality or
|
||||
cost recommendations. Tests use controlled transport responses and synthetic data;
|
||||
they do not establish real provider compatibility, model quality, network behavior,
|
||||
throughput, cross-process coordination, complete billing, or release compliance.
|
||||
Only the representative LLM-facing subset is implemented in the prototype; the
|
||||
inventory specifies the remaining domain fields for the ConfigKit migration.
|
||||
Production file discovery, CLI parsing, full module chains, all nine prompts,
|
||||
filesystem diagnostics/redaction, and serialized report migration remain their
|
||||
assigned production tasks. Those are deliberate scope boundaries, not missing
|
||||
claims of completion for the prototype.
|
||||
|
||||
The new profile/credential/capacity and deadline choices are explicit above; no
|
||||
unresolved upstream requirement prevents starting the ConfigKit implementation
|
||||
plan. Production report field names and final runtime wiring are selected in the
|
||||
[implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md), following the outcome and observation
|
||||
contract here. The coordinated refactor targets both libraries directly; intermediate commits do not require a working legacy runtime.
|
||||
|
||||
### Production Implementation Reference
|
||||
|
||||
The [implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md) owns ordered production work,
|
||||
component changes, tests, and acceptance criteria. The [combined roadmap](library-adoption.md)
|
||||
and [configuration roadmap](configkit.md) own the final target. This evidence does
|
||||
not require an interim runtime bridge or separately runnable configuration migration.
|
||||
|
||||
Retained domain scope includes transcript/glossary schemas, normalization/chunking,
|
||||
output encoding, proposals and apply-time checks, deterministic validators, ordered
|
||||
modules, LLM-validator batching/cardinality, ledger ordering, and artifact lifecycle.
|
||||
The production integration replaces loading, provider execution, prompt rendering,
|
||||
and scheduler composition while preserving those responsibilities. Retention and
|
||||
timestamp changes remain separate work.
|
||||
|
||||
### Distribution Follow-Up
|
||||
|
||||
The pinned graph includes ConfigKit, PromptKit, both PromptKit backend catalogs,
|
||||
jsonschema/v6, yaml.v3, yaml.v4, x/text, and kr/text (including module/test dependency
|
||||
edges). Before distribution, review the actual production dependency graph and
|
||||
its license files, including PromptKit/catalog LGPL-3.0-or-later terms. Decide and
|
||||
verify the notices, license copies, corresponding library source/modifications,
|
||||
and rebuild/relink materials needed for Audita's Go binary/container distribution.
|
||||
This unit does not publish binaries or claim that release compliance is complete.
|
||||
No upstream relicensing request or library implementation change is required for
|
||||
this prototype.
|
||||
|
||||
## Selected-Overlay Extension: 2026-09-24
|
||||
|
||||
The isolated prototype now pins published ConfigKit v0.4.0. ConfigKit loads
|
||||
`overlays/testing.yml` relative to the selected main file; the overlay selects
|
||||
complete PromptKit execution profiles from the separate `profiles/` directory.
|
||||
The original v0.3.1 observations above are historical and do not prove this
|
||||
extension. No production Audita behavior changed.
|
||||
|
||||
With Go 1.26.8 on linux/amd64, from `examples/library-adoption/`, these offline
|
||||
checks passed with `GOTOOLCHAIN=local GOWORK=off GOPROXY=off GOSUMDB=off`:
|
||||
|
||||
```sh
|
||||
go test ./...
|
||||
go test -race ./...
|
||||
go vet ./...
|
||||
go run .
|
||||
go run . --overlay testing
|
||||
go run . --overlay testing --proposal-profile proposal
|
||||
```
|
||||
|
||||
Each demonstration reported one accepted correction, four attempts, zero
|
||||
transient retries, and two structural repairs. The base run selected
|
||||
`synthetic-grammar`/`synthetic-review`; testing selected
|
||||
`synthetic-grammar-testing`/`synthetic-review-testing`; the explicit proposal
|
||||
override restored only `synthetic-grammar`. These are synthetic routing IDs,
|
||||
not price, latency, quality, or provider-compatibility measurements.
|
||||
|
||||
| Requirement | Consumer evidence |
|
||||
| --- | --- |
|
||||
| Base, empty/default, testing selection, role overrides, final inheritance, and relative profile resolution | `TestSelectedOverlayConfiguration` loads temporary on-disk layouts and assembles both roles. |
|
||||
| Actual base/testing/override HTTP models and repairs | `TestDemonstrationSelectsOutboundModels` captures every request body and matches model IDs to the reported selections and domain outcome. |
|
||||
| Missing/invalid selection, version/directive rejection, and ordinary backend-setting validation | `TestOverlayFailuresAndApplicationValidation` checks ConfigKit diagnostic codes and effective backend limits. |
|
||||
| Surviving credential resolution, absent/empty failures, null unauthenticated use, and profile-only switching | `TestOverlayCredentialResolutionAndInspection` controls synthetic environment values and observes HTTP Authorization. |
|
||||
| Redacted effective output, explanation and metadata origin, profile inspection, and observations | `TestOverlayCredentialResolutionAndInspection` and `TestOverlaySelectionProvenance` inspect safe output and overlay/CLI origins. |
|
||||
| Existing retry, repair, domain, capacity, and concurrent-observation behavior | `TestWorkflowBoundaries`, `TestSharedCapacityAndRecovery`, `TestQueuedCancellationAndDeadline`, `TestDeadlineStopsRetryAfter`, and `TestPartialUsageOnFailedRun` pass, including under `-race`. |
|
||||
|
||||
Changing a profile does not remove a backend credential reference from the
|
||||
effective configuration. ConfigKit validates a surviving reference when only
|
||||
profile selection changes. Replacing the reference in an
|
||||
overlay resolves only the replacement; explicit null allows unauthenticated use.
|
||||
This distinction is part of the selected configuration boundary, not an
|
||||
application fallback. Imports and secret-directory bootstrap remain disabled.
|
||||
|
||||
The tests use a controlled built-in HTTP transport and synthetic credentials;
|
||||
there were no live provider calls. The prototype still covers one representative
|
||||
proposal/assessment pair, not all production modules, prompts, CLI paths, or
|
||||
diagnostic artifacts. Root `go test ./...` does not run this nested module. No
|
||||
upstream API gap appeared in this extension. The [production implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md)
|
||||
keeps implementation and release pending.
|
||||
269
docs/roadmap/library-boundary.md
Normal file
269
docs/roadmap/library-boundary.md
Normal file
@@ -0,0 +1,269 @@
|
||||
# Library Adoption: Shared Boundary and Prototype
|
||||
|
||||
**Last updated:** 2026-09-24
|
||||
|
||||
**Status:** Original boundary-design and offline-prototype unit completed;
|
||||
overlay extension and production-planning handoff completed, 2026-09-24.
|
||||
The work packages below retain the original scope;
|
||||
[decisions, evidence, limitations, and handoff](library-boundary-findings.md)
|
||||
record the outcome. The executable prototype was removed after production
|
||||
integration; Git history at `590604b` retains it. No publication or upstream
|
||||
changes were made in that historical unit.
|
||||
|
||||
## Next Unit: Testing Overlays and Production Migration Plan
|
||||
|
||||
**Status:** Complete. The [production implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/cb405f6/docs/roadmap/implementation.md)
|
||||
owns subsequent work; the [overlay findings](library-boundary-findings.md#selected-overlay-extension-2026-09-24)
|
||||
record this unit's checks. The original work packages below remain
|
||||
historical scope for the completed first unit.
|
||||
|
||||
Extend the existing prototype to prove the [selected-overlay contract](configkit.md#selected-overlays-for-testing)
|
||||
with ConfigKit v0.4.0, then turn the verified findings into a detailed production
|
||||
ConfigKit migration plan. Do not repeat the original inventory or redesign the
|
||||
established library boundary without new evidence.
|
||||
|
||||
Required work:
|
||||
|
||||
- Upgrade only the nested prototype module from ConfigKit v0.3.1 to v0.4.0.
|
||||
- Pass an explicit overlay selection through ConfigKit and add `overlays/testing.yml`
|
||||
plus two PromptKit testing profiles. Select both roles and retain one shared
|
||||
finite backend. Synthetic model names demonstrate routing; they do not benchmark
|
||||
real model cost, speed, or quality.
|
||||
- Make the offline executable accept overlay and explicit role-profile selections,
|
||||
and show the selected models alongside domain outcomes and retry/repair counts.
|
||||
- Verify base/overlay/CLI precedence, role inheritance, invalid selections,
|
||||
surviving credential references, safe inspection, and overlay provenance.
|
||||
Prove the actual HTTP request models for both roles; loading changed strings
|
||||
alone is insufficient evidence.
|
||||
- Record new results separately from the historical v0.3.1 findings. Expand the
|
||||
existing ConfigKit roadmap into a concrete production implementation handoff,
|
||||
including final runtime integration and removal of legacy configuration.
|
||||
|
||||
Target end state: reviewers can run the prototype with and without the testing
|
||||
selection and see both LLM roles switch models. The offline test suite establishes
|
||||
that selection, inspection, and execution agree, and the production ConfigKit work
|
||||
has bounded tasks with explicit acceptance criteria.
|
||||
|
||||
Acceptance criteria:
|
||||
|
||||
- The published v0.4.0 dependency is pinned without local replacements; the original
|
||||
no-overlay path and existing integration tests continue to pass.
|
||||
- `testing` switches both roles, explicit profile flags override its selections,
|
||||
and omission/empty/`default` retains base selection according to ConfigKit.
|
||||
- Invalid overlays fail clearly; inheritance and secret resolution use surviving
|
||||
effective settings. Inspection records overlay origin without disclosing keys.
|
||||
- Both selected testing models reach the controlled HTTP transport; structural
|
||||
repair, shared capacity, observations, and Audita domain checks remain active.
|
||||
- Updated examples, executable instructions, findings, and a detailed production
|
||||
migration plan are reviewable. Exact verification commands and limitations are
|
||||
recorded, including the fact that root tests do not cover the nested module.
|
||||
- Production code, root dependencies, and upstream libraries remain unchanged.
|
||||
No release or live provider call is part of this unit.
|
||||
|
||||
This unit ends with a production migration **plan**, not production implementation.
|
||||
The ConfigKit → PromptKit → combined release sequence remains unchanged. Imports
|
||||
and secret-directory bootstrap remain disabled; PromptKit execution profiles keep
|
||||
their existing names and meaning.
|
||||
|
||||
## Objective
|
||||
|
||||
Define and prove the boundary between Audita, ConfigKit, and PromptKit before
|
||||
replacing Audita's production configuration or LLM runtime. This unit covers the
|
||||
shared design and representative prototype supporting the
|
||||
[coordinated adoption roadmap](library-adoption.md). The
|
||||
[ConfigKit roadmap](configkit.md) continues to own the broader configuration scope.
|
||||
|
||||
The deliverable is a concrete target contract supported by an offline executable
|
||||
prototype, sufficient to implement the ConfigKit migration without subsequently
|
||||
redesigning its LLM-facing settings. A successful prototype is not completion of
|
||||
either production migration.
|
||||
|
||||
## Established Direction
|
||||
|
||||
- This is an intentional breaking migration with a migration guide, not legacy
|
||||
configuration support, aliases, or a permanent compatibility mode.
|
||||
- ConfigKit owns shared configuration mechanics; PromptKit owns shared prompt and
|
||||
generation mechanics; Audita retains domain meaning and transcript correction.
|
||||
- Structural repair is enabled from the outset for proposal and LLM-validator calls.
|
||||
Positive default repair budgets must be selected, not silently left at zero.
|
||||
- Transient retries and structural repair are separate. Explicit zero disables
|
||||
transient retries; Audita must not add a second automatic retry loop.
|
||||
- One finite concurrency limit per backend protects local capacity and bounds paid
|
||||
API activity. Calls from both roles share that limit. Fine-grained role budgets
|
||||
and an additional global concurrency control are unnecessary.
|
||||
- Keep the sequence: boundary/prototype, ConfigKit migration, PromptKit migration,
|
||||
then combined major release. No intermediate public release is planned.
|
||||
|
||||
## Scope and Deliverables
|
||||
|
||||
| Deliverable | Required result |
|
||||
| --- | --- |
|
||||
| Configuration inventory and migration map | Every existing setting and invocation option has a proposed destination, replacement, or removal, with rationale. |
|
||||
| Boundary specification | One authoritative source for each setting, explicit precedence/defaults, credential flow, runtime conversion, and failure handling. |
|
||||
| Representative executable prototype | New-style configuration drives one proposal and one assessment through released libraries and a controlled provider. |
|
||||
| Focused behavioral evidence | Retry, repair, capacity, credential, observation, and domain-boundary scenarios below are demonstrated. |
|
||||
| Decision and integration handoff | Concrete choices, measured limitations, affected components, removal plan, and next implementation tasks are recorded. |
|
||||
|
||||
Do not switch the production CLI to the prototype, migrate every module/prompt,
|
||||
redesign transcript/glossary formats, change correction algorithms, modify retention
|
||||
or timestamp behavior, or publish a release in this unit. Do not reproduce the
|
||||
libraries' full test suites. Upstream changes require a separately scoped task if
|
||||
an actual gap is found.
|
||||
|
||||
## Work Package 1: Inventory and Decide Ownership
|
||||
|
||||
Read the current [configuration](../config.md), [CLI](../cli.md),
|
||||
[LLM runtime](../internal/llm-runtime.md), [prompts](../internal/prompts.md),
|
||||
[validators](../internal/validators.md), and [output contracts](../integrations/output-files.md).
|
||||
Use graph-first discovery to verify the relevant code and tests, especially
|
||||
configuration application, prompt construction, structured responses, scheduling,
|
||||
and report assembly.
|
||||
|
||||
Build a migration table grouped by application/domain settings, invocation state,
|
||||
backend settings, execution profiles, output contracts, and inspection. Include
|
||||
current environment settings and aliases without treating their existence as a
|
||||
requirement to preserve them. Identify report fields whose meanings change when
|
||||
one logical generation contains multiple provider attempts.
|
||||
|
||||
Resolve these design decisions explicitly:
|
||||
|
||||
| Decision | Proposed direction to prove |
|
||||
| --- | --- |
|
||||
| File selection and version | Audita selects the main configuration and validates a new schema version; specify discovery and the treatment of old versions. |
|
||||
| Application versus invocation state | ConfigKit loads persistent settings; Audita parses invocation-only input/output paths and translates explicitly supplied setting flags into supported overrides. |
|
||||
| Backend identity | One registration represents the service capacity shared by proposal and validation calls. Avoid separate identities for the same service merely because roles differ. |
|
||||
| Endpoint and capacity ownership | Define them once per backend, with finite limits and an explicit policy for waiting capacity/exhaustion. Do not expose endpoint-only unlimited execution accidentally. |
|
||||
| Execution profiles | Prefer complete application-owned profiles using PromptKit conventions. Decide their source and selection without duplicating model/settings fields in application configuration. Catalog selection remains a deliberate option. |
|
||||
| Role selection and inheritance | Specify how proposal and validation choose profiles, including omission and any inheritance. Do not inherit old behavior solely for compatibility. |
|
||||
| Credentials | Prefer one ConfigKit-owned secret-resolution path passed through PromptKit's supported request credential field. Define backend/profile credential association and avoid competing environment lookups. Validate this against profile requirements. |
|
||||
| Retry, repair, and deadlines | Assign one owner and explicit defaults for each control. Use positive structural-repair defaults and document combined limits and total-operation scope. |
|
||||
| Optional library features | The original prototype omitted imports, selected configuration layers, and secret-directory bootstrap. Selected overlays are now planned for testing; see the [overlay plan](configkit.md#selected-overlays-for-testing). Imports and secret-directory bootstrap remain out. |
|
||||
| Inspection | Define effective configuration and selected-profile inspection without implying that one library's snapshot contains the other's complete state. |
|
||||
|
||||
Choose concrete field names, example values, defaults, units, and omission/null/zero
|
||||
semantics for the prototype. In particular, decide what validation and inspection
|
||||
do when configured credentials are unavailable. Classify choices as proposed,
|
||||
selected, or unresolved; do not present candidates as implemented contracts.
|
||||
|
||||
## Work Package 2: Specify Execution and Reporting Semantics
|
||||
|
||||
Document the flow from selected configuration through backend/profile assembly,
|
||||
prompt inputs, generation, structural validation/repair, typed decoding, and Audita
|
||||
domain validation. Identify which values cross the boundary and which component
|
||||
owns each conversion. Keep library types out of unrelated domain code where a
|
||||
small existing domain value is sufficient.
|
||||
|
||||
Use the current correction-set and validator-decision schemas as representative
|
||||
inputs. Reuse domain checks where practical. Select one real proposal/validator
|
||||
pair; account for prompt helpers, template variables, shared fragments, and schema
|
||||
references rather than testing only an unrelated hello-world prompt.
|
||||
|
||||
Record the following distinctions:
|
||||
|
||||
- Repair seeks output conforming to its structural contract. Success does not
|
||||
establish semantic correctness or authorize applying a correction.
|
||||
- A schema-valid decision set still requires Audita's cardinality and proposal
|
||||
identity checks. Semantic rejection is not automatically another repair request.
|
||||
- Exhausted structural repair yields failed content validation; provider failures,
|
||||
retry exhaustion, cancellation, and capacity rejection have separate outcomes.
|
||||
- Specify each outcome's intended effect on an Audita section/batch and overall run,
|
||||
including warnings, rejected work, partial domain results, and terminal failures.
|
||||
Preserve domain intent without preserving obsolete transport behavior by accident.
|
||||
- For transient retry budget T and structural repair budget R, one logical call can
|
||||
dispatch up to `(T + 1) * (R + 1)` provider attempts. For example, T=2 and R=2
|
||||
permits nine attempts; these illustrative values do not select production defaults.
|
||||
- Choose the total-operation deadline scope for a logical proposal or assessment;
|
||||
distinguish it from per-attempt timeouts and whole-process cancellation. Provider
|
||||
retry timing may exceed local backoff, so deadline behavior must be explicit.
|
||||
|
||||
Design the Audita observation record and aggregation rules. Include logical-call
|
||||
and attempt identity, role/backend correlation, queue/generation/retry timing,
|
||||
repair and retry counts, outcomes, and available usage. Preserve unknown/incomplete
|
||||
usage rather than inventing zeros or complete costs. Do not add terminal totals to
|
||||
attempt totals. Collect events safely across concurrent calls, without blocking
|
||||
callbacks on progress by the same run or persisting raw library events as a stable
|
||||
Audita schema. Transcript-bearing artifacts remain separately governed by Audita.
|
||||
|
||||
## Work Package 3: Build the Bounded Offline Prototype
|
||||
|
||||
Use ConfigKit v0.3.1 and PromptKit v0.11.0 as reviewed starting points; verify their
|
||||
published availability and APIs before pinning the prototype. Recheck the combined
|
||||
Go minimum (the reviewed PromptKit release requires Go 1.25.5). Do not depend on
|
||||
sibling checkouts, an active Go workspace, or committed local module replacements.
|
||||
|
||||
A proposed home is `examples/library-adoption/` as an explicitly experimental,
|
||||
standalone Go module, isolating prototype dependencies from the production binary.
|
||||
Confirm this placement during execution. Its README must give exact offline run
|
||||
and test commands after dependency acquisition; root `go test ./...` must not be
|
||||
claimed to cover a nested module. Keep complete proposed configuration and prompt
|
||||
fixtures with it and clearly label them as prototype-only.
|
||||
|
||||
The prototype should:
|
||||
|
||||
1. Load representative application settings with ConfigKit, using synthetic secret
|
||||
values supplied by the test environment and an application-owned version rule.
|
||||
2. Assemble shared backend registrations and proposal/validation profile selections.
|
||||
3. Supply representative transcript/proposal inputs to PromptKit definitions and
|
||||
actual response schemas using supported sources.
|
||||
4. Use the built-in HTTP generation path with a controlled local endpoint or
|
||||
transport. An injected LLM client alone cannot prove built-in HTTP retry behavior.
|
||||
5. Run proposal generation, decode and check candidates, run assessment, and perform
|
||||
the selected Audita decision checks without modifying real transcript files.
|
||||
6. Collect selected safe observations and show a compact result understandable to a
|
||||
reviewer, including repaired output and final domain acceptance/rejection.
|
||||
|
||||
No paid calls, real credentials, host environment assumptions, persistent caches,
|
||||
or general-purpose test framework are needed. Make concurrency and cancellation
|
||||
checks deterministic through controlled synchronization. Keep delays bounded and
|
||||
use library-supported controls; do not patch library internals to make tests pass.
|
||||
|
||||
## Focused Verification Matrix
|
||||
|
||||
| Scenario | Evidence required |
|
||||
| --- | --- |
|
||||
| Successful assembled path | ConfigKit-loaded selections drive both real prompt roles through PromptKit and Audita checks. |
|
||||
| Presence, overrides, and inheritance | Representative omission, explicit values, and role selection follow the proposed contract; unknown fields and unsupported versions fail clearly. |
|
||||
| Credentials | Required missing/empty references fail as intended; controlled calls receive the chosen synthetic credential; inspection and observations do not expose it. |
|
||||
| Structural repair succeeds | Invalid proposal output and invalid assessment output are repaired in their respective workflows; positive budgets are actually exercised. |
|
||||
| Repair exhausted | Repeated invalid output produces the selected Audita outcome and accurate accounting, without an unbounded outer retry. |
|
||||
| Domain rejection | Structurally valid but unacceptable correction or decision is rejected by Audita, demonstrating the semantic boundary. |
|
||||
| Transient retry and explicit zero | An eligible temporary status recovers; zero makes one attempt. Exhaustion retains a useful classified cause. |
|
||||
| Combined repair and retry | A repaired generation encountering a transient failure respects both budgets and reports distinct counts. |
|
||||
| Shared capacity | Concurrent calls from both roles, including retry/repair activity, stay within one selected backend cap; test a representative local cap of four and a finite API cap. |
|
||||
| Waiting, cancellation, and deadline | Cancellation/deadline stops pending work and retry waits; capacity exhaustion has the intended application outcome and later calls can still proceed. |
|
||||
| Failed-run observations | Completed work remains observable after later failure; unknown usage, known zero, and aggregate counts are mapped correctly. |
|
||||
|
||||
Tests should protect Audita's integration decisions and important assembled behavior.
|
||||
Rely on PromptKit's tests for exhaustive HTTP-status, backoff, and scheduler details;
|
||||
rely on ConfigKit's tests for its parser and presence machinery. Use race testing for
|
||||
new concurrent observation collection. Keep consumer checks offline and credential-free.
|
||||
|
||||
## Completion Criteria and Handoff
|
||||
|
||||
This unit is complete only when:
|
||||
|
||||
- The settings/ownership table and migration inventory are concrete enough to start
|
||||
the ConfigKit migration, including file/profile sources, CLI scope, credentials,
|
||||
defaults, finite backend limits, positive repair budgets, and deadline policy.
|
||||
- The offline prototype and focused matrix demonstrate the selected boundary with
|
||||
both libraries together, including both LLM roles and Audita domain checks.
|
||||
- Exact verification commands, results, limitations, and unresolved upstream gaps
|
||||
are recorded. Missing evidence is not reported as successful integration.
|
||||
- No adoption-critical decision remains hidden in prototype code. If a gap prevents
|
||||
settling the boundary, record it and revise the plan before declaring readiness.
|
||||
- The existing Audita production behavior remains intact in this unit. Temporary
|
||||
code is clearly isolated and has a removal/integration destination during the
|
||||
production migrations; no second supported runtime is introduced.
|
||||
- A component-level follow-up identifies code to replace, domain code to retain,
|
||||
tests to update, documentation/migration-guide work, and direct integration of
|
||||
the final configuration and PromptKit runtime.
|
||||
- Licensing/distribution follow-up for the selected dependency graph is identified
|
||||
for the later release stage; this prototype does not claim release compliance.
|
||||
- Roadmap links and examples resolve, appropriate checks pass, and commits contain
|
||||
only this unit's work. Significant settled architectural choices may be recorded
|
||||
in an ADR under the [documentation policy](../policy/documentation.md), while
|
||||
implementation status stays in the roadmaps.
|
||||
|
||||
Retain the overall adoption order unless evidence or the other planned large changes
|
||||
justifies revising it. Completing this unit enables detailed production migration;
|
||||
it does not authorize an intermediate release or require unrelated runtime fixes.
|
||||
252
docs/roadmap/policy.md
Normal file
252
docs/roadmap/policy.md
Normal file
@@ -0,0 +1,252 @@
|
||||
# Standard Policy Alignment
|
||||
|
||||
**Last updated:** 2026-09-28
|
||||
|
||||
**Status:** Implemented. This roadmap replaces its earlier licensing-only scope
|
||||
and records the accepted end state. [implementation.md](implementation.md)
|
||||
records the ordered work and verification; the adopted policies are in
|
||||
`docs/policy/`.
|
||||
|
||||
## Purpose and Review Revision
|
||||
|
||||
Align Audita with [Standard Repository Policies](https://gitea.maximumdirect.net/eric/policy),
|
||||
using identical policy language except where a substantive, locally significant
|
||||
requirement or decision justifies a variation. Adopt upstream wording verbatim
|
||||
for non-substantive differences. Perform the required template customizations
|
||||
without inventing application contracts, restrictions, or guarantees.
|
||||
|
||||
The accepted review compared Audita's current documents directly against upstream
|
||||
commit **`d84a38ebab26f048cafbe59a2246700c35d29843`**, beginning with the
|
||||
[adoption and update guide at that revision](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/adoption.md).
|
||||
Use that revision for this adoption. Historical adoption baselines need not be
|
||||
reconstructed or assessed. A later upstream revision requires deliberate review,
|
||||
not an automatic substitution during implementation.
|
||||
|
||||
The public upstream repository, discovery links, and copied-policy attribution
|
||||
are part of the accepted direction. This supersedes the earlier instruction to
|
||||
omit references to the policy repository.
|
||||
|
||||
## Current Baseline
|
||||
|
||||
- Audita has five adopted policies: agents 1.0, architecture 1.0, documentation
|
||||
1.1, testing 1.0, and release 1.0. None has per-document `Upstream Source`
|
||||
metadata. `meta.md` and `oss.md` are absent.
|
||||
- [AGENTS.md](../../AGENTS.md) routes readers to the contributor guide and agent
|
||||
policy. [docs/development.md](../development.md) has component-specific reading
|
||||
guidance, but lacks the upstream selective Policy Reading Guide and currently
|
||||
directs all tasks to the architecture policy.
|
||||
- [COPYRIGHT](../../COPYRIGHT) and [LICENSE](../../LICENSE) already establish
|
||||
Audita's GPL-3.0-or-later application grant and full GPLv3 text. The grant does
|
||||
not yet identify the scope of separately licensed copied policy documents.
|
||||
- There is no canonical `docs/oss/attribution.md` or local dependency license-text
|
||||
collection. Relevant component notices still require an evidence-based inventory.
|
||||
- The [README](../../README.md) lacks the prescribed final licensing statements.
|
||||
The [release procedure](../release.md) lacks licensing-footer instructions, and
|
||||
the [release workflow](../../.woodpecker/release.yml) does not explicitly reuse
|
||||
checked-in release notes as hosted release bodies.
|
||||
- Audita already releases through one publication command with an atomic source
|
||||
and tag push. Linux amd64 and arm64 are required; macOS arm64 is best-effort
|
||||
development support. Successful publication completes the release without
|
||||
waiting for CI or artifact delivery.
|
||||
|
||||
## Targeted Policy Set and Justified Customizations
|
||||
|
||||
All seven policy files belong under `docs/policy/`. The versions below are those
|
||||
at the selected upstream revision. No existing policy is wholly unchanged;
|
||||
existing architectural decisions and platform commitments need no substantive
|
||||
revision merely to align the text.
|
||||
|
||||
| Policy | Target version | Required alignment and justified local treatment |
|
||||
| --- | --- | --- |
|
||||
| `agents.md` | 1.3 | Adopt upstream substantive language verbatim. Retain Audita's graph-first Codebase Discovery section because it is an explicitly selected repository workflow. |
|
||||
| `architecture.md` | 1.3 | Adopt general ownership, boundary, and constraint guidance, then perform the template's required application-specific customization. Preserve Audita's ordered pipeline, ConfigKit/PromptKit responsibilities, deterministic processing, recovery, concurrency, and secret-handling decisions. These describe real project requirements rather than stylistic preferences. |
|
||||
| `documentation.md` | 1.11 | Adopt upstream prose and applicable ownership rows. Retain concrete output-contract ownership, contributor change recipes, and the decision to place operating/recovery guidance in operations instead of restoring troubleshooting documentation. Omit HTTP API and public Go API ownership rows because Audita has neither responsibility. |
|
||||
| `testing.md` | 1.3 | Adopt substantive text verbatim. Its distinction between established contracts and invented test requirements needs no local exception. |
|
||||
| `release.md` | 1.4 | Adopt upstream substantive language. Preserve Linux amd64/arm64 requirements, best-effort macOS arm64, unsupported Windows/macOS amd64, and Audita's explicit decision against human release gates. These are selected support and workflow commitments. |
|
||||
| `meta.md` | 1.0 | Adopt provenance, local authority, and public discovery guidance with accurate metadata and local attribution navigation. No additional substantive exception is needed. |
|
||||
| `oss.md` | 1.8 | Adopt the House Format and maintenance rules, with required project-specific facts and reference links. Preserve Audita's GPL-3.0-or-later application grant, Gitea host, and existing distribution channels. |
|
||||
|
||||
Remove each `Base Policy Template` section after carrying out its instructions.
|
||||
Keep local customizations identifiable and explain their project-specific reason
|
||||
in the appropriate policy; do not maintain alternate paraphrases of shared rules.
|
||||
Architecture customization does not authorize a package redesign or additional
|
||||
threat-model guarantees. Supporting documents are warranted by existing
|
||||
responsibilities and substantive content, not by unused template examples.
|
||||
|
||||
Successful-tag-push completion, asynchronous artifacts, minimal automated gates,
|
||||
and proportionate validation are now shared upstream rules. Replace Audita's
|
||||
parallel explanations with the upstream language rather than describing these
|
||||
as continuing exceptions. Keep concrete commands, remotes, build targets, and
|
||||
publication mechanics in the release procedure with appropriate policy links.
|
||||
|
||||
## Provenance and Selective Reading
|
||||
|
||||
For every adopted policy, retain the selected upstream `Base Policy Version`,
|
||||
set `Last Updated` to its actual local adoption date, and introduce `Upstream
|
||||
Source` linking to that exact file at the selected full commit. The URL pattern is:
|
||||
|
||||
```text
|
||||
https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/<filename>.md
|
||||
```
|
||||
|
||||
Substitute each of `agents`, `architecture`, `documentation`, `testing`, `release`,
|
||||
`meta`, and `oss`; a repository-root or shared generic source link is insufficient.
|
||||
These links describe the source actually incorporated, not a reconstructed claim
|
||||
about older local documents. Git and per-document metadata are sufficient; no
|
||||
separate synchronization registry or recurring check is required.
|
||||
|
||||
In `meta.md`, retain these public discovery destinations:
|
||||
|
||||
- [Standard Repository Policies](https://gitea.maximumdirect.net/eric/policy).
|
||||
- [Current adoption and update guide](https://gitea.maximumdirect.net/eric/policy/src/branch/main/docs/adoption.md).
|
||||
|
||||
Discovery links follow the current upstream project and guide. Adopted-source,
|
||||
notice, and example links remain commit-pinned. Preserve valid pinned example
|
||||
references supplied by the selected policy, or pin them to this review revision
|
||||
after checking the referenced assets; do not turn them into moving-branch links.
|
||||
|
||||
Adapt upstream `agents/AGENTS.md` into Audita's root orientation, retaining its
|
||||
existing applicable instructions. Add the adoption guide's Policy Reading Guide
|
||||
to `docs/development.md` and retain the component-specific task guide. Route
|
||||
policy adoption and updates to `meta.md`, repository recommendations and changes
|
||||
to agents, application-code or structure work to architecture, validation choices
|
||||
to testing, documentation work to documentation, dependency/licensing work to
|
||||
OSS, and release/versioning work to release policy. Read applicable policies
|
||||
before their decisions, reuse unchanged context, and expand reading with scope.
|
||||
Do not require reading the entire suite for every task.
|
||||
|
||||
## Copied Policy Licensing and Local Material
|
||||
|
||||
Follow the selected revision's
|
||||
[canonical policy attribution entry](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/examples/licensing/policy-attribution.md)
|
||||
and [project grant](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/COPYRIGHT).
|
||||
Insert the entry beneath the title in `docs/oss/attribution.md`, substitute the
|
||||
full review commit in all three URLs, and accurately identify copied/adapted
|
||||
material, including orientation or reading-guide text where copied. Preserve
|
||||
supplied creator, copyright, license, disclaimer notices, and modification
|
||||
indications. Keep the material statement concise.
|
||||
|
||||
Copy `CC-BY-SA-4.0.txt` into `docs/oss/licenses/`. Add the adoption guide's scoped
|
||||
notice to `COPYRIGHT`, identifying the adapted policies as CC-BY-SA-4.0 and
|
||||
routing readers to attribution for the affected material. Account accurately for
|
||||
other copied guidance in that scope. Audita's application code remains
|
||||
GPL-3.0-or-later; unrelated documentation is not automatically relicensed.
|
||||
The root GPLv3 `LICENSE` needs no change.
|
||||
|
||||
| Material | Destination or treatment |
|
||||
| --- | --- |
|
||||
| Applicable policies, including `meta.md` and `oss.md` | Copy and customize under `docs/policy/`, retaining provenance. |
|
||||
| Upstream `agents/AGENTS.md` | Adapt into root `AGENTS.md`. |
|
||||
| Selective reading guidance | Integrate into Audita's own `docs/development.md`. |
|
||||
| Upstream README, root AGENTS.md, developer guide, and adoption guide | Keep upstream and consult through links; do not copy as local guides. |
|
||||
| Licensing example collection | Keep upstream with commit-pinned references; use it to create actual notices. Original example formatting is CC0 and alone needs no policy attribution entry. |
|
||||
| Applicable standard and companion license texts | Copy complete, unmodified texts locally; no blanket collection. |
|
||||
|
||||
## Component Attribution
|
||||
|
||||
Complete the previously agreed inventory of relevant incorporated or distributed
|
||||
components: direct and transitive dependencies, copied code/documentation/assets,
|
||||
and applicable Go runtime notices. Determine inclusion from actual material and
|
||||
use, not simply presence in `go.mod`; tooling or consultation alone does not
|
||||
require an entry. Inspect selected sources directly rather than copying a
|
||||
dependency's attribution document wholesale.
|
||||
|
||||
Use the exact House Format in OSS policy 1.8: the prescribed title followed by
|
||||
component entries, factual identification, applicable supplied copyrights and
|
||||
SPDX expressions, standard license/notice labels, and `[Source](COMMIT_URL).`
|
||||
links. Omit unavailable optional fields instead of adding explanatory filler.
|
||||
Preserve required upstream material, license alternatives, and exceptions.
|
||||
Keep research narratives, compliance conclusions, and exception reasoning out
|
||||
of attribution; place reasoning in the OSS policy or an appropriate decision
|
||||
record. This replaces the older roadmap's permission to put exception reasoning
|
||||
in a component entry.
|
||||
|
||||
Upstream component and notice links identify exact imported commits. Local
|
||||
standard texts include directly reachable companions, such as GPLv3 for LGPLv3.
|
||||
Apply the adopted house interpretation of notice links without blanket extra
|
||||
local-copy requirements or repeated approval. Concrete obligations beyond notice
|
||||
reproduction receive their own applicable treatment; the format alone does not
|
||||
certify compatibility or resolve every distribution obligation.
|
||||
|
||||
The reviewed dependency revisions remain useful starting evidence, subject to
|
||||
checking the dependencies selected when implementation occurs:
|
||||
|
||||
| Component | Reviewed version | Source commit |
|
||||
| --- | --- | --- |
|
||||
| ConfigKit | v0.4.1 | `0adb94f59e44827908eff401d4381a398fe17107` |
|
||||
| PromptKit | v0.11.1 | `15e40679546f2e21b6f51cc84b6f0a087a8486db` |
|
||||
| OpenRouter catalog | v2.20260926.0 | `4f731d217e0bc39151c010f50fb5912706e7b6b3` |
|
||||
| Rakestrawhome catalog | v2.20260926.0 | `48918a3ad39fd99843cda94a86133b1b3881d596` |
|
||||
|
||||
These library patches changed licensing/documentation rather than library code
|
||||
or catalog profiles. ConfigKit and PromptKit identify LGPL-3.0-or-later; the
|
||||
selected catalogs identify MIT. Other relevant dependencies still need inventory.
|
||||
|
||||
## Discoverability and Release Integration
|
||||
|
||||
End README with the project-license and attribution statements prescribed by the
|
||||
OSS policy, using Audita's actual grant. `COPYRIGHT` owns the separately licensed
|
||||
policy scope; README links to that grant and the attribution document.
|
||||
|
||||
Update `docs/release.md` to specify the final `COPYRIGHT | LICENSE | ATTRIBUTION`
|
||||
links in every new release note and hosted download page. Use absolute Gitea URLs
|
||||
at the release's immutable tag or source commit. Reuse the checked-in note as the
|
||||
hosted body where supported; verify the publication plugin's supported mechanism
|
||||
and make the necessary focused `.woodpecker/release.yml` change. Avoid separately
|
||||
maintained release prose or notice lists.
|
||||
|
||||
Preserve the current atomic source/tag publication approach, supported targets,
|
||||
and completion point. Align procedure wording with upstream's preparation,
|
||||
ambiguous-push recovery, and asynchronous retry rules. Handle completed-roadmap
|
||||
retirement during preparation, preserving planned/deferred work and repairing
|
||||
links; this roadmap update does not authorize deleting other roadmaps now.
|
||||
|
||||
Check intended future-tag paths against the candidate source without requiring
|
||||
the tag to resolve before publication. Apply the formatting convention
|
||||
prospectively; leave published tags, notes, artifacts, and checksums intact.
|
||||
Concrete historical omissions, if discovered, receive deliberate treatment under
|
||||
their applicable terms and release correction rules.
|
||||
|
||||
## Work Required and Acceptance Criteria
|
||||
|
||||
Implementation covers the seven policy documents, `AGENTS.md`,
|
||||
`docs/development.md`, `COPYRIGHT`, `docs/oss/attribution.md`, applicable files in
|
||||
`docs/oss/licenses/`, README, the release procedure, and focused hosted-body
|
||||
publication wiring. Update this roadmap's implementation status when appropriate.
|
||||
The [implementation plan](implementation.md) owns the editing sequence and
|
||||
verification steps.
|
||||
|
||||
The work is complete when:
|
||||
|
||||
- Shared policy language matches the selected upstream revision after required
|
||||
template removal and customization; retained variations have substantive
|
||||
Audita-specific reasons as identified above.
|
||||
- All seven policies have accurate versions, adoption dates, and file-specific
|
||||
commit-pinned source links. Public discovery links and selective orientation
|
||||
are in place, with no leftover template-only instructions or broken links.
|
||||
- Copied policy/guidance scope, modification status, credit, CC-BY-SA text, and
|
||||
root grant notice follow the documented upstream arrangement while preserving
|
||||
Audita's application license.
|
||||
- Relevant components have verified House Format entries, exact source/notice
|
||||
commits, and complete applicable license texts, without editorial commentary.
|
||||
- README and future release documentation provide the required navigation, and
|
||||
hosted release content comes from the checked-in note through a verified
|
||||
publication mechanism.
|
||||
- Audita's application contracts, architectural decisions, platform commitments,
|
||||
release completion semantics, and published history are preserved.
|
||||
- Affected text, links, license copies, metadata, and publication configuration
|
||||
pass proportionate review and validation. No release is needed solely to test
|
||||
adoption; behavioral workflow changes receive focused validation if required.
|
||||
|
||||
## Scope Boundaries and Open Questions
|
||||
|
||||
No policy decisions remain open for the agreed scope. Component-specific notices
|
||||
and the publication plugin's supported release-body mechanism require factual
|
||||
verification during implementation. Raise a decision only for a concrete
|
||||
unresolved obligation or material tradeoff uncovered by that work.
|
||||
|
||||
This feature does not require application refactoring, dependency upgrades,
|
||||
mandatory scanners, a full SBOM, recurring legal approvals, synchronization
|
||||
checks, additional human release gates, publication-time network checks, or CI
|
||||
waiting. The documentation convention alone does not require downloadable
|
||||
license assets, source bundles, or a different binary package format.
|
||||
161
docs/roadmap/remediation.md
Normal file
161
docs/roadmap/remediation.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# Maintainability Audit: Findings and Recommended Changes
|
||||
|
||||
**Reviewed:** 2026-09-25, source commit `011b021`.
|
||||
**Scope:** Recent partial-decision reconciliation, validation context, prompt
|
||||
alignment, and request-local reference changes, including related existing code.
|
||||
**Status:** R27–R30 addressed; see the resolution record below. Previous findings and resolution records remain in Git
|
||||
history through `011b021`.
|
||||
|
||||
## Architecture Assessment
|
||||
|
||||
The recent changes fit Audita's existing boundaries. Proposal generation,
|
||||
validation, prompt assets, and outcome reporting already have suitable owners;
|
||||
this audit does not recommend a new common package or a broad refactor.
|
||||
|
||||
The strongest opportunities are shared prompt instructions and request-scoped
|
||||
validation context preparation. Two smaller improvements concern recovery-reason
|
||||
classification and partial-result assembly; both predate the latest commits.
|
||||
These are bounded maintenance recommendations, not new release gates or changes
|
||||
to correction policy, response acceptance, or reporting semantics.
|
||||
|
||||
## R27 — P2: Consolidate Shared Prompt Instructions
|
||||
|
||||
**Category:** Repeated behavioral-contract text; risk of future drift.
|
||||
|
||||
**Evidence:** The four [proposal prompts](../../internal/prompts/assets/prompts/modules.grammar.proposal.yaml)
|
||||
repeat literal source-span matching, request-local identity, replacement-text,
|
||||
source-based proposal, and confidence instructions. The three active
|
||||
[validator prompts](../../internal/prompts/assets/prompts/validators.editorial_review.yaml)
|
||||
repeat candidate-reference, supplemental-context, and verdict-confidence guidance.
|
||||
Recent contract changes required coordinated edits across these assets. The
|
||||
[prompt registry](../../internal/prompts/registry.go) already provides a shared
|
||||
hardening fragment supplied through the role-bound adapter.
|
||||
|
||||
**Recommended change:** Extract genuinely common passages into embedded fragments
|
||||
under `internal/prompts/assets/shared`, following the existing fragment-supply
|
||||
approach. Keep the fragments owned by `internal/prompts` and use the existing
|
||||
PromptKit rendering path. Keep module-specific examples, replacement-policy
|
||||
instructions, protected-name exceptions, and semantic criteria in their individual
|
||||
prompt definitions. Do not merge similar-looking rules with different meanings.
|
||||
|
||||
**Acceptance:** Common instructions have one maintained source and appear in all
|
||||
intended rendered prompts. The existing module and validator distinctions remain
|
||||
intact, including glossary replace-all behavior and the spoken-word protected-name
|
||||
exception. Focused rendering checks cover fragment inclusion and representative
|
||||
module-specific guidance without requiring exact-prose snapshots or introducing
|
||||
a separate templating framework.
|
||||
|
||||
## R28 — P2: Prepare Validation Context Once Per Request
|
||||
|
||||
**Category:** Repeated computation and overlapping segment lookup.
|
||||
|
||||
**Evidence:** [BuildLLMValidationRequest](../../internal/framework/validators/llm_validators.go)
|
||||
already indexes transcript segments, but
|
||||
[validationContext](../../internal/framework/validators/llm_context.go) scans the
|
||||
transcript again for each candidate. It also calls
|
||||
[NewProtectedVocabulary](../../internal/framework/validators/protected_terms.go)
|
||||
for each candidate, rebuilding the same vocabulary and compiling its matching
|
||||
expression repeatedly. This is duplicated preparation rather than copied code.
|
||||
|
||||
**Recommended change:** Prepare a segment-position lookup and protected vocabulary
|
||||
once per validation request, then pass that prepared context into the existing
|
||||
context-selection helper. Keep the implementation within `framework/validators`.
|
||||
Continue selecting glossary evidence for each candidate individually because its
|
||||
proposed replacement can mention different terms. A process-wide cache or new
|
||||
context-management package is unnecessary for this cleanup.
|
||||
|
||||
**Acceptance:** Candidates in one validation request reuse the prepared lookup and
|
||||
vocabulary. Context still consists of the available immediate neighbors within the
|
||||
current chunk and relevant glossary entries in glossary order. Candidate-specific
|
||||
replacement text still participates in glossary selection. Existing optional-context
|
||||
trimming, token estimation, and oversized-input handling retain their behavior.
|
||||
Verify these outcomes with focused behavioral tests rather than assertions about
|
||||
private helper call counts or unmeasured performance guarantees.
|
||||
|
||||
## R29 — P3: Share Execution-Recovery Classification
|
||||
|
||||
**Category:** Duplicate reporting rule; predates the latest commits.
|
||||
|
||||
**Evidence:** [Proposal generation](../../internal/framework/proposal_generation/generate.go)
|
||||
and [LLM validation](../../internal/framework/validators/llm_validators.go)
|
||||
independently translate structural-repair and transient-retry counts into
|
||||
`output_repaired` and `service_recovered` reasons. The conversion is the same in
|
||||
both locations; the surrounding success and domain-outcome decisions differ.
|
||||
|
||||
**Recommended change:** Place a small conversion helper in the existing
|
||||
`framework/outcomes` package and use it from both callers. Keep the decision to
|
||||
record recoveries at the call sites, along with domain-specific reasons such as
|
||||
filtered validator decisions. Do not combine proposal and validation orchestration
|
||||
or move domain-success classification into this helper.
|
||||
|
||||
**Acceptance:** Both callers use the same execution-count conversion. Existing
|
||||
reason ordering, successful-operation reporting, and domain-specific additions
|
||||
remain intact. A partially unavailable validation batch continues to record its
|
||||
failure and execution counts without acquiring recovery records merely because a
|
||||
repair or retry occurred. Existing outcome tests should continue to protect these
|
||||
distinctions.
|
||||
|
||||
## R30 — P3: Centralize Partial Validator Result Assembly
|
||||
|
||||
**Category:** Repeated early-return construction; predates the latest commits.
|
||||
|
||||
**Evidence:** Several early returns in
|
||||
[LLMBackedValidator.Validate](../../internal/framework/validators/llm_validators.go)
|
||||
repeat nested slice appends to combine immediate decisions, oversized-input
|
||||
decisions, and decisions from completed model batches, together with accumulated
|
||||
operation outcomes. This makes it easier for a future failure path to omit facts
|
||||
already collected by the validator.
|
||||
|
||||
**Recommended change:** Use a small local result-building helper to assemble the
|
||||
partial result consistently. Keep error handling, batching, success-path ordering,
|
||||
and cardinality enforcement explicit. A general-purpose result-aggregation package
|
||||
is not needed.
|
||||
|
||||
**Acceptance:** Cancellation and failure paths retain the same previously collected
|
||||
decisions and operations. Result ordering and cardinality behavior remain unchanged;
|
||||
the helper does not enforce complete cardinality on interrupted work. Retain the
|
||||
existing partial-progress and fatal-failure coverage, adding tests only for a
|
||||
material gap exposed by the refactor.
|
||||
|
||||
## Boundaries to Preserve
|
||||
|
||||
- Keep proposal and validator reference mapping separate. Proposals can target the
|
||||
same segment repeatedly; duplicate validator decisions make that candidate
|
||||
unavailable. Similar indexing arithmetic alone does not justify a generic
|
||||
reference-management abstraction.
|
||||
- Keep distinct protected-term policy checks separate. They already share the
|
||||
vocabulary implementation and intentionally apply different policies.
|
||||
- Preserve exact source-span matching, request-local references, batching, and
|
||||
partial-success behavior. Consolidation is not a reason to strengthen contracts
|
||||
or broaden the accepted correction scope.
|
||||
|
||||
## Review Verification and Limits
|
||||
|
||||
- This is a source-level maintainability audit, not a finding of demonstrated
|
||||
production failures or a measured performance assessment.
|
||||
- No application tests were rerun for the original read-only audit; its roadmap
|
||||
update used documentation link and whitespace checks. Implementation validation
|
||||
is recorded below.
|
||||
- Future remediation should run focused behavioral tests and the broader suite
|
||||
appropriate to the actual change, following the testing policy. No live-provider
|
||||
evaluation or new evaluation framework is required by these recommendations.
|
||||
- The findings above describe the audited baseline. Implementation and validation
|
||||
are recorded below; no release publication is included.
|
||||
|
||||
## Resolution Record
|
||||
|
||||
Implemented as focused changes within the existing packages. Proposal and validator
|
||||
reference mapping and distinct protected-term policies remain separate.
|
||||
|
||||
| Finding | Resolution and evidence |
|
||||
| --- | --- |
|
||||
| R27 | Common proposal and validation instructions live in two embedded shared fragments, supplied through the existing role-bound PromptKit adapter. Individual YAML definitions retain policy differences and examples. Rendering tests check fragment inclusion once per applicable prompt and representative module-specific guidance. |
|
||||
| R28 | Validation request construction builds one segment-position lookup and protected vocabulary, reused by context selection for every candidate. A new test verifies that two replacements of the same source span receive their own relevant glossary entries. Existing neighbor, glossary-order, chunk-boundary, and budget tests pass. |
|
||||
| R29 | Both proposal generation and validation use `outcomes.ExecutionRecoveries`. Call sites still control success and domain-specific recovery reasons. Existing tests cover combined recoveries and failed validation with repair counts but no recovery record. |
|
||||
| R30 | A local result builder combines collected decisions and operation outcomes for partial returns and completed validation. Sorting and full cardinality checks remain outside it. Existing fatal-batch, partial-progress, runner, and reporting tests pass. |
|
||||
|
||||
Validation: `go test ./...` passed, including PromptKit preparation, partial-decision
|
||||
reconciliation, subprocess reports, and fatal-progress coverage. Documentation
|
||||
links and whitespace checks passed. No live model evaluation or performance
|
||||
measurement was performed; the changes make no new model-quality or latency
|
||||
promise.
|
||||
290
docs/roadmap/resilience.md
Normal file
290
docs/roadmap/resilience.md
Normal file
@@ -0,0 +1,290 @@
|
||||
# Resilient Processing and Focused Run Reports
|
||||
|
||||
**Last updated:** 2026-09-24
|
||||
|
||||
**Status:** Implemented. This document records the selected behavior and user
|
||||
intent. Concrete design decisions and completion evidence are in
|
||||
[historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/a83a518/docs/roadmap/implementation.md).
|
||||
|
||||
## Purpose and User Intent
|
||||
|
||||
Audita should reliably produce a useful transcript even when its LLM services
|
||||
cannot improve it. Exhausted retries or unusable model responses must not turn
|
||||
an otherwise processable transcript into a failed production run.
|
||||
|
||||
> Failure of every LLM operation across every stage and chunk still produces a
|
||||
> successful output containing the deterministically normalized transcript, with
|
||||
> no LLM corrections applied. Partial success preserves as many fully validated,
|
||||
> applicable corrections as possible.
|
||||
|
||||
Deterministic normalization remains intentional and may change segment layout,
|
||||
identifiers, and text before LLM work begins. Output uses the selected transcript
|
||||
encoder; byte-for-byte preservation of the original input and mapping corrections
|
||||
back to pre-normalization segmentation are not requirements.
|
||||
|
||||
The overriding goal is to minimize how much useful processing is lost because of
|
||||
one problematic transcript segment. A stage/chunk work unit is an attribution
|
||||
boundary, not an all-or-nothing transaction.
|
||||
|
||||
Existing reports contain useful information, but there are no compatibility
|
||||
obligations for reporting or debug output. Reuse existing machinery only when it
|
||||
makes the implementation simpler and clearer; preservation is not itself a goal.
|
||||
Internal structures and measurements must serve Audita's processing workflow.
|
||||
The reporting package adapts those outcomes to structured and human-facing
|
||||
presentations, rather than reshaping processing around a reporting convenience.
|
||||
|
||||
## Historical Baseline and Implemented Change
|
||||
|
||||
The [pipeline](../internal/pipeline.md), [LLM integration](../integrations/openai-compatible-llm.md),
|
||||
[report assembly](../internal/diagnostics-reporting.md), and
|
||||
[artifact lifecycle](../operations.md) describe current behavior.
|
||||
|
||||
Before this work, exhausted structural repairs could become warnings and skipped
|
||||
proposals or rejected validation batches. Other model runtime failures canceled
|
||||
peer work, stopped subsequent modules, and prevented final transcript output.
|
||||
Successful repairs appeared in execution observations rather than a dedicated
|
||||
recovery classification. Detailed artifacts were written during ordinary runs
|
||||
and could later be removed by retention. The working transcript was re-chunked
|
||||
between modules.
|
||||
|
||||
This feature changed those behaviors. It builds on the completed
|
||||
[library adoption](library-adoption.md) and [review remediation](remediation.md).
|
||||
Fatal cancellation remains necessary; unsuccessful model work must be separated
|
||||
from failures that actually require cancellation of the run.
|
||||
|
||||
## Fixed Chunks and Ordered Stages
|
||||
|
||||
Normalize first, then partition the transcript once. Preserve chunk boundaries,
|
||||
segment membership, segment identity, and ordering throughout LLM processing.
|
||||
Text evolves as accepted corrections are applied. Recombine chunks in original
|
||||
order after the LLM stages finish.
|
||||
|
||||
A stage is a configured module instance. Repeated instances of the same module
|
||||
have distinct identities. Proposal generation and each validator are operations
|
||||
within a stage; validation may use multiple batches within a chunk. A work unit
|
||||
is one stage instance applied to one chunk.
|
||||
|
||||
Preserve the overall stage sequence: finish a stage across its chunks before
|
||||
advancing to the next stage. Concurrent chunk work shares PromptKit's backend
|
||||
capacity. Failure in one unit does not prevent other chunks or later stages
|
||||
from executing.
|
||||
|
||||
Retain operator control over chunk size and the current defaults. Production
|
||||
experience indicates that chunk size affects model latency nonlinearly and that
|
||||
useful settings are well below backend context limits. Tuning is an empirical
|
||||
operator decision. Do not add automatic headroom calculations, cross-profile
|
||||
sizing, adaptive repartitioning, or automatic tuning in this feature. A later
|
||||
operation that cannot process its input follows the same safe error handling;
|
||||
it does not silently alter chunk boundaries. Validation batching within a chunk
|
||||
remains supported.
|
||||
|
||||
Independent whole-pipeline traversal by chunks and domain-aware response repair
|
||||
are explicitly deferred in [future work](future.md). Read-only neighboring
|
||||
context, cross-chunk edits, and transcript-wide restructuring are outside this
|
||||
unit, without becoming permanent prohibitions on future capabilities.
|
||||
|
||||
## Partial Success and Failure Isolation
|
||||
|
||||
- Keep bounded transport retries, structural repairs, operation deadlines, and
|
||||
shared backend capacity. Completion comes from safe fallback, not unlimited
|
||||
attempts or an outer retry loop around PromptKit.
|
||||
- Apply a correction only after it passes every required validator and the
|
||||
application checks. Failed validation must never be treated as approval.
|
||||
- If a validation batch fails, exclude its affected candidates while allowing
|
||||
other candidates to continue through the remaining validators. Preserve fully
|
||||
validated, applicable corrections from successful batches in the same unit.
|
||||
- Track candidates by stable proposal identity. Batch membership can change
|
||||
between validators; equal batch numbers do not establish candidate identity.
|
||||
- A failed proposal-generation operation leaves its chunk unchanged for that
|
||||
stage because there are no reliable proposals to salvage. Failures later in
|
||||
validation need not discard unrelated successful candidates.
|
||||
- Preserve earlier stages' corrections and other chunks' successful work.
|
||||
Record partial success explicitly; a unit can apply corrections and have errors.
|
||||
- Continue despite model-operation failures, including exhausted repairs/retries,
|
||||
unusable model decisions, provider/transport failures, local operation deadlines,
|
||||
and admission failures. An operation need not exhaust its attempt budget to fail.
|
||||
- A valid empty proposal list or valid assessments rejecting all corrections is
|
||||
successful processing. Correction count alone does not determine failure.
|
||||
- Keep safe filtering of defective proposals. Do not retry ordinary editorial
|
||||
rejections. For now, an unusable validator decision set excludes the affected
|
||||
candidates and records an error after existing permitted recovery. New bounded
|
||||
feedback/regeneration for domain-invalid responses belongs to future work.
|
||||
- Retain fatal treatment for invalid input/configuration, internal defects,
|
||||
explicit run cancellation, and inability to produce/write the transcript.
|
||||
Caller cancellation is distinct from a local model-operation timeout.
|
||||
- Completed runs with model errors return success. Required report-write failures
|
||||
are an additional fatal output condition when reporting is enabled, as below.
|
||||
|
||||
PromptKit owns transport, transient retries, structural repair, and admission.
|
||||
Audita owns domain acceptance, partial outcomes, fallback, and classification.
|
||||
ConfigKit owns configuration resolution. Debug and reporting choices must not
|
||||
change correction decisions, retry budgets, or continuation.
|
||||
|
||||
## Errors, Recoveries, and Debug
|
||||
|
||||
Classify by eventual outcome and impact. These are three reporting categories;
|
||||
debug is evidence, not a failure severity. Whether execution continues is a
|
||||
separate property.
|
||||
|
||||
| Category | Meaning | Representative cases |
|
||||
| --- | --- | --- |
|
||||
| Errors | Intended work could not complete reliably, or a fatal run-level operation failed. Affected candidates are excluded; other corrections can succeed. | Exhausted repair; unavailable provider; unusable validation decisions; operation deadline. |
|
||||
| Recoveries | A problem was handled successfully through retries, repair, or safe filtering. No operator intervention is implied. | Invalid output repaired; transient service failure recovered; defective proposals safely discarded. |
|
||||
| Debug | Detailed evidence of processing and ordinary decisions. | Proposals, applied corrections, validator decisions, prompts/responses, individual attempts, execution traces. |
|
||||
|
||||
Normal editorial disagreement belongs in debug. A validator correctly rejecting
|
||||
a meaning-changing edit is expected behavior. A proposal referring to nonexistent
|
||||
original text is defective; safely filtering it is a recovery. An unresolved
|
||||
missing/duplicate decision-index response is an error, not a recovery.
|
||||
|
||||
Record an operation's eventual outcome once. Several failed attempts followed by
|
||||
success produce a consolidated recovery. Attempts ending in failure contribute
|
||||
to error details, not additional recoveries. Earlier operations that recovered
|
||||
remain recorded if a later operation introduces an error in the same unit.
|
||||
|
||||
Separate output-quality recovery, defective-proposal filtering, and service
|
||||
recovery with structured reasons. Network instability must not look like a prompt
|
||||
defect. Do not introduce an arbitrary warning threshold or a fourth category.
|
||||
|
||||
### Counting and Processing Volume
|
||||
|
||||
- Count error-bearing work units once per stage/chunk, consolidating underlying
|
||||
operation failures as details. A partially successful unit still counts once.
|
||||
- Count recoveries once per recovered operation. Aggregate defective-proposal
|
||||
filtering per proposal response, retaining affected-proposal counts as detail.
|
||||
Attempts and individual discarded proposals are not independent incidents.
|
||||
- Keep work-unit coverage separate from operation/recovery counts. Show processing
|
||||
volume with explicitly labeled denominators; do not divide recovered-operation
|
||||
counts by work-unit counts and call that a recovery rate.
|
||||
- Report fatal run-level errors separately from the stage/chunk grid when they
|
||||
cannot be attributed to a work unit. Do not invent a chunk to accommodate them.
|
||||
- Derive YAML records, Markdown summaries, and CLI counts from actual processing
|
||||
outcomes with deterministic ordering, rather than independently calculating them.
|
||||
|
||||
## Production Outputs, Placement, and Lifecycle
|
||||
|
||||
Reporting is enabled by default. The ordinary bundle is:
|
||||
|
||||
- `errors.yml`: structured error-bearing units, their underlying failures, and
|
||||
applicable run-level failures.
|
||||
- `recoveries.yml`: structured recovered operations and pertinent counts.
|
||||
- `report.md`: a concise human-facing summary of outcome, corrections, processing
|
||||
volume, errors, recoveries, and their locations in the pipeline.
|
||||
|
||||
Write all three documents, including empty event lists for uneventful completed
|
||||
runs. Use Audita-owned schemas with safe explanations and stable reason codes;
|
||||
retain run, stage-instance, chunk, operation, and validator/batch identities where
|
||||
applicable. The implementation plan specifies the versioned schemas; neither old
|
||||
report formats nor raw library structures define the new output contract.
|
||||
|
||||
Place reports beside the output transcript. Retain transcript-to-stdout support
|
||||
with an explicit report-directory selection, defaulting to the invocation working
|
||||
directory. Preserve the existing overwrite convention: a new run can replace files
|
||||
at its selected destinations. Do not add a mandatory fresh-directory restriction
|
||||
or compatibility exports.
|
||||
|
||||
Before model work, create initial versions of all three reports carrying a common
|
||||
run identifier and explicit `in_progress` status (rendered as prose in Markdown).
|
||||
Fail immediately if initialization fails. Also check the transcript destination;
|
||||
creating neighboring reports does not prove that an existing transcript file is
|
||||
writable. Preflight must not prematurely destroy an existing transcript.
|
||||
|
||||
Finalize all required outputs and check every final write. Initial write success
|
||||
cannot guarantee later success if space or permissions change. Failure to write
|
||||
the transcript or finalize a required report returns nonzero and must not erase
|
||||
an already produced transcript. Where possible, finalize available reports with
|
||||
an explicit failed status on fatal termination. Abrupt termination may leave
|
||||
`in_progress`; elaborate crash-recovery machinery is not required.
|
||||
|
||||
Provide an option to disable reporting entirely. It suppresses all three files
|
||||
(`errors.yml`, `recoveries.yml`, and `report.md`), including initialization and
|
||||
final writes, while retaining the brief CLI summary and independently selectable
|
||||
debug output. Disabled reporting must not create or require a writable report
|
||||
destination, and must not remove reports from earlier runs.
|
||||
Transcript output failures remain fatal regardless of reporting selection.
|
||||
|
||||
Ordinary reports survive independently of debug cleanup. Reporting configuration
|
||||
and finalization must not depend on retaining a debug run directory.
|
||||
|
||||
## Debug and Internal Boundaries
|
||||
|
||||
Production issue records are compact. Full responses, transcript excerpts,
|
||||
correction lists, and complete validation decisions are opt-in debug evidence.
|
||||
Use a single ConfigKit-backed debug boolean with a `--debug` CLI override. Debug
|
||||
artifacts may use JSON where useful. Preserve configured-secret redaction in every
|
||||
presentation.
|
||||
|
||||
Debug-off prevents detailed artifact persistence; writing and later deleting
|
||||
those files is insufficient. In-memory domain state needed to process candidates
|
||||
correctly is not debug output. Debug and ordinary reporting are independent
|
||||
selections and do not alter processing behavior.
|
||||
|
||||
There is no obligation to retain `--report-json`, old artifact layouts, parallel
|
||||
exports, or old retention settings. Reuse code only where useful to the new
|
||||
workflow. Enabled debug output is retained on success or failure; disabled debug
|
||||
creates no debug directory. This supersedes the retention question in the
|
||||
[runtime follow-up](runtime-behavior.md). The legacy `never` behavior is not the
|
||||
meaning of the new reporting-disable option. Optional debug-write failures produce
|
||||
a safe stderr diagnostic without changing correction decisions or the run exit
|
||||
status; ordinary report and transcript-write failures retain their fatal semantics.
|
||||
|
||||
## Deterministic Human-Facing Presentation
|
||||
|
||||
Use the CLI style:
|
||||
|
||||
> Completed: 18 corrections applied; 3 work units with errors; 7 recoveries.
|
||||
|
||||
Do not say that all error-bearing units were skipped: some apply valid corrections.
|
||||
Include report locations when reporting is enabled and the files exist. Send the
|
||||
summary to stderr so stdout remains exclusively available for transcript output.
|
||||
Disabled reporting does not suppress the summary or fatal-error messages.
|
||||
|
||||
Keep `report.md` concise and high-level. Use separate error and recovery matrices
|
||||
with stages as columns and chunks as rows. Include every chunk in fixed order;
|
||||
retain configured stage order and distinct labels for repeated module instances.
|
||||
No automatic width detection, thresholds, adaptive omission, or table splitting.
|
||||
A wide or long table is acceptable.
|
||||
|
||||
The error matrix counts error-bearing work units: each attempted cell is 0 or 1.
|
||||
Recovery cells count recovered operations and can exceed 1. An error cell may
|
||||
coexist with recoveries and successfully applied corrections in the same unit.
|
||||
Distinguish completed work with zero events from unattempted work; do not portray
|
||||
canceled/unavailable processing as clean completion. Include totals, processing
|
||||
volume, and a short reason breakdown. Detailed inspection belongs in YAML or debug.
|
||||
|
||||
## Target Acceptance Criteria
|
||||
|
||||
- Total LLM failure still returns success and the encoded normalized transcript,
|
||||
provided required output writes succeed.
|
||||
- Mixed-success runs preserve independently validated, applicable corrections
|
||||
within the same stage/chunk as a failed batch. No candidate bypasses a required
|
||||
validator; later validators handle survivors by stable proposal identity.
|
||||
- Subsequent stages and unaffected chunks execute after recoverable failures.
|
||||
Fatal errors and explicit cancellation stop and join active work appropriately.
|
||||
- Chunk boundaries and identity remain fixed, with operator-selected sizing and
|
||||
unchanged defaults; final recombination preserves ordering.
|
||||
- Valid no-change/editorial-rejection outcomes are successful. Repaired/filtered
|
||||
output and unresolved failures receive distinct classifications and counts.
|
||||
- YAML, Markdown, and CLI agree on partial outcomes and totals; error matrices
|
||||
count affected work units, recovery matrices count recovered operations.
|
||||
- With reporting enabled, all three reports are initialized before model work,
|
||||
finalized and retained, including empty lists. Initial or final required-output
|
||||
write failures produce nonzero exits without destroying completed transcript output.
|
||||
- Reporting can be disabled without requiring its destination. Debug can be enabled
|
||||
independently; neither selection changes processing outcomes. Debug-off writes
|
||||
no detailed debug artifacts, and stdout transcript output remains supported.
|
||||
- Reports use the fixed deterministic layout without adaptive presentation logic.
|
||||
- Meaningful controlled-provider tests cover exhausted recovery, failed validation
|
||||
batches with successful survivors, total failure, fatal cancellation, output
|
||||
failures, and reporting/debug selections. Preserve domain safeguards, capacity
|
||||
limits, and redaction.
|
||||
- Canonical CLI, configuration, operations, integration, internal, and architecture
|
||||
documentation describes the implemented final behavior.
|
||||
|
||||
## Implementation Reference
|
||||
|
||||
The product decisions are settled. The [historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/a83a518/docs/roadmap/implementation.md) defines
|
||||
the selected settings and precedence, YAML schemas, counts and ordering, interrupted
|
||||
work presentation, destination checks, and output finalization. It also owns the
|
||||
ordered implementation stages and validation work. This document remains the
|
||||
reference for the desired behavior and its acceptance criteria.
|
||||
18
docs/roadmap/runtime-behavior.md
Normal file
18
docs/roadmap/runtime-behavior.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Runtime Behavior Decisions
|
||||
|
||||
**Last updated:** 2026-09-24
|
||||
|
||||
The documentation migration identified existing behaviors for separate product
|
||||
consideration. The resilience implementation resolved the diagnostics-retention
|
||||
question; the input-timestamp question remains open.
|
||||
|
||||
- Resolved: legacy `auto`/`always`/`never` retention settings were removed.
|
||||
Debug is explicitly enabled with `diagnostics.debug` or `--debug`, creates no
|
||||
directory when disabled, and retains its directory on every outcome when enabled.
|
||||
- Resolved: [configuration](../config.md) now treats explicit zero as disabling
|
||||
transient retries or structural repair independently; PromptKit performs both.
|
||||
- Decide whether missing or null input timestamps should be rejected; current
|
||||
decoding is documented in the [input contract](../integrations/transcript-glossary-files.md).
|
||||
|
||||
These decisions are independent of the completed documentation migration and
|
||||
release workflow.
|
||||
203
docs/roadmap/span-deletion.md
Normal file
203
docs/roadmap/span-deletion.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# Consistent Span Deletion
|
||||
|
||||
**Last updated:** 2026-09-25
|
||||
|
||||
**Status:** Implemented. This document owns the desired behavior and user intent.
|
||||
The [historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/60e2fe7/docs/roadmap/implementation.md)
|
||||
records the concrete steps, selected implementation details, and completion
|
||||
evidence.
|
||||
|
||||
## Purpose and User Intent
|
||||
|
||||
Align proposal prompts, the LLM response schema, internal validation, and
|
||||
application behavior so legitimate text-span deletions can be considered and
|
||||
applied through the ordinary correction workflow. An empty replacement should
|
||||
not trigger structural repair merely because it is empty, nor invalidate other
|
||||
usable corrections returned alongside it.
|
||||
|
||||
This is a consistency fix within Audita's current editing scope. It does not
|
||||
authorize whole-segment removal, broaden module responsibilities, or introduce
|
||||
new recovery machinery. The accepted [resilience behavior](resilience.md) remains
|
||||
in effect, including partial success, fixed chunks, and validation before mutation.
|
||||
|
||||
## Historical Baseline (`0b6cd98`)
|
||||
|
||||
The source reviewed at `0b6cd98` contains a mismatch:
|
||||
|
||||
- The [spoken-word prompt](../../internal/prompts/assets/prompts/modules.spoken_word.proposal.yaml)
|
||||
permits removing fillers and asks for the exact affected span and replacement,
|
||||
without explaining how to represent deletion. Grammar permits punctuation and
|
||||
spacing changes, which can also naturally involve deletion.
|
||||
- The shared [correction response schema](../../internal/framework/responseschema/assets/correction_set.v1.json)
|
||||
requires `corrected_text` to have at least one character. Every built-in proposal
|
||||
module uses that schema. An empty replacement invalidates the response before
|
||||
Audita evaluates individual proposals.
|
||||
- PromptKit performs bounded structural repair. If repair does not produce a
|
||||
valid response, the proposal operation fails and yields no candidates, including
|
||||
otherwise valid proposals in the same response. The current resilience path
|
||||
records the error and continues other work.
|
||||
- [CorrectionProposal](../../internal/framework/proposals/proposal.go) already
|
||||
allows empty replacement text. The
|
||||
[preview/application logic](../../internal/framework/proposals/preview.go)
|
||||
supports literal span deletion when the resulting segment remains nonblank.
|
||||
- Domain shape checks currently reject whitespace-only original spans, although
|
||||
the response schema permits them and grammar prompts permit spacing cleanup.
|
||||
This is another restriction to align with the target contract below.
|
||||
- The validator named `non_empty_corrected_text` actually checks the resulting
|
||||
segment, not the replacement string. Both this check and application prevent
|
||||
a segment from becoming empty or whitespace-only. Application changes segment
|
||||
text; it does not remove segment records.
|
||||
|
||||
A temporary controlled-provider review reproduced whole-response rejection for
|
||||
an empty replacement alongside a valid correction, and immediate schema acceptance
|
||||
for a space-only replacement. Existing proposal tests confirm internal support for
|
||||
partial deletion and rejection of blank resulting segments. These observations
|
||||
explain a plausible production failure mechanism; they do not establish the cause
|
||||
of any particular historical incident without its payload and running version.
|
||||
|
||||
## Target Correction Contract
|
||||
|
||||
- `original_text` identifies an existing, nonempty literal span in the current
|
||||
target segment. Whitespace-only spans are eligible; an empty string identifies
|
||||
no source span and remains invalid. Matching and ambiguity checks still apply
|
||||
under the module's replacement policy: `require_unique` for grammar, spoken-word,
|
||||
and homophones; `replace_all` for glossary.
|
||||
- `corrected_text` remains a required string. An empty string means delete the
|
||||
identified span; it does not mean remove the segment record or skip validation.
|
||||
Missing fields and non-string values remain structurally invalid.
|
||||
- After applying a correction, the segment must contain non-whitespace text.
|
||||
Enforce this using the source segment and replacement result in Audita, not a
|
||||
minimum replacement length in the structural schema.
|
||||
- Every accepted deletion passes the same required validators as other edits in
|
||||
its module, including confidence, protected terms, editorial review, and meaning
|
||||
preservation where applicable. Empty replacement is neither automatic approval
|
||||
nor an automatic rejection.
|
||||
- Application preserves segment identity, speaker, timing, membership, ordering,
|
||||
and fixed chunk boundaries. Recheck applicability against text produced by
|
||||
earlier accepted corrections, retaining existing conflict handling.
|
||||
- Preserve literal replacement behavior. Prompts should select spans and
|
||||
replacements that handle adjacent whitespace and punctuation appropriately;
|
||||
this feature does not add automatic trimming or a second normalization pass.
|
||||
Neither side of a correction is rejected solely for containing only whitespace.
|
||||
For example, reducing a uniquely identified run of two spaces to one space may
|
||||
be appropriate; validity still depends on the resulting text and domain checks.
|
||||
|
||||
Preserve the intended safeguards and outcomes, not every detail of the current
|
||||
implementation. Validator ordering, internal structure, and payload construction
|
||||
may change when needed to achieve this consistent contract. Existing behavior or
|
||||
a passing test does not justify retaining a conflicting restriction.
|
||||
|
||||
Illustrative cases:
|
||||
|
||||
| Segment | Original span | Replacement | Intended handling |
|
||||
| --- | --- | --- | --- |
|
||||
| `uh hello` | `uh ` | empty string | Structurally valid; may produce `hello` after required validation. |
|
||||
| `uh hello` | `uh hello` | `hello` | Remains a valid representation of the same cleanup, subject to validation. |
|
||||
| `hello world` | two spaces | one space | Eligible spacing correction, subject to unique matching and required validation. |
|
||||
| `uh` | `uh` | empty string | Structurally valid proposal, then filtered because the resulting segment would be blank. |
|
||||
| `hello world` | `hello world` | spaces only | Filtered because the resulting segment would be blank. |
|
||||
|
||||
These examples describe eligibility and mechanical results, not unconditional
|
||||
editorial approval. An unchanged segment or valid empty correction list remains
|
||||
a successful no-change outcome.
|
||||
|
||||
## Prompt and Module Alignment
|
||||
|
||||
Review relevant prompt definitions for consistency and edit only those needing
|
||||
clarification. Where needed, explain empty-string deletion, whitespace-only spans,
|
||||
and the resulting-segment limit with a concise, module-appropriate example. The
|
||||
model should omit a correction that would leave a blank segment rather than invent
|
||||
padding or replacement content. Consistent guidance is the goal; adding deletion
|
||||
language to every prompt is not a requirement.
|
||||
|
||||
Retain each module's existing scope:
|
||||
|
||||
- Spoken-word cleanup can propose appropriate filler or dysfluency deletion while
|
||||
preserving substantive content and intentional emphasis.
|
||||
- Grammar can propose permitted punctuation or spacing deletion; allowing an
|
||||
empty replacement does not authorize word removal or spoken-word cleanup.
|
||||
- Glossary and homophone modules retain their existing correction purposes.
|
||||
Shared deletion syntax does not grant them new editorial responsibilities.
|
||||
|
||||
Review the active LLM-validator prompts and their input construction as well as
|
||||
proposal prompts. Validators must understand the before/after effect of deletion
|
||||
and assess it under their existing criteria. A correct negative editorial decision
|
||||
remains ordinary processing, not a defect that should be regenerated until approved.
|
||||
|
||||
The resulting-segment validator's name and documented identity should describe
|
||||
that responsibility accurately, rather than imply that the replacement string
|
||||
itself must be nonempty. Preserve the existing blank-result failure reason and
|
||||
safeguard while making that deliberate identity change; current chain position
|
||||
and preview implementation are not independent product requirements.
|
||||
|
||||
## Outcomes and Reporting
|
||||
|
||||
A legitimate deletion is an ordinary correction. Empty replacement alone must
|
||||
produce neither structural repair nor a recovery classification. If another
|
||||
problem required successful repair or filtering, retain that actual recovery.
|
||||
|
||||
A schema-valid proposal that would blank its stage-input segment is a defective
|
||||
proposal handled through existing safe filtering. Preserve the
|
||||
`empty_resulting_segment` reason
|
||||
and consolidated `proposals_filtered` recovery behavior; other usable proposals
|
||||
in the response continue through required validation. Ordinary editorial rejection
|
||||
remains debug evidence rather than a model error or filtering recovery.
|
||||
|
||||
A stage can propose several edits to one segment in the same response. Each edit
|
||||
is evaluated against the stage input, then approved edits are applied sequentially.
|
||||
If a proposal was applicable to that input but an earlier accepted edit makes it
|
||||
unsafe, skip it as an apply-time conflict. Do not count that conflict as a defective
|
||||
proposal, model error, or filtering recovery. For example, in `"uh um"`, deleting
|
||||
`"uh "` and deleting `"um"` each leaves text individually; after the first deletion,
|
||||
the second must be skipped to prevent a blank result. Retain the skipped decision
|
||||
in debug evidence. The existing runner already distinguishes this situation.
|
||||
|
||||
Debug evidence must accurately retain the empty replacement and the corresponding
|
||||
validation/application outcome. Ordinary reports retain their existing counts and
|
||||
purpose; no new report schema, incident category, or deletion-specific counter is
|
||||
needed. Unrelated structural defects may still exhaust PromptKit repair and produce
|
||||
an error for the operation, as today.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- A controlled valid response containing an empty replacement reaches Audita's
|
||||
domain validation without structural repair solely due to that empty string.
|
||||
- A permitted span deletion can pass the required validators and reach the final
|
||||
transcript while preserving segment metadata and fixed chunk membership.
|
||||
- A mixed response can apply an approved deletion and another approved correction;
|
||||
an empty replacement does not invalidate the whole response.
|
||||
- A proposal that would blank its stage-input segment is filtered independently,
|
||||
retains the existing reason, and does not prevent unrelated valid candidates
|
||||
from succeeding. A proposal made unsafe only by an earlier accepted edit is
|
||||
skipped without adding an error or filtering recovery; a blank result is still
|
||||
prevented and the conflict remains visible in debug evidence.
|
||||
- A uniquely matching whitespace-only original span can reach validation and
|
||||
application. Empty originals remain invalid, ambiguous matches remain subject
|
||||
to module policy, and whitespace-only resulting segments remain disallowed.
|
||||
- Protected-term and meaning-changing deletions remain subject to their normal
|
||||
rejection rules. No candidate bypasses required validation.
|
||||
- A deletion needing no recovery counts as an ordinary applied correction; actual
|
||||
repair/filtering and editorial rejection retain their existing classifications.
|
||||
Debug evidence represents the empty replacement faithfully.
|
||||
- Schema and domain tests distinguish an empty string from missing/non-string
|
||||
replacement values and distinguish empty replacement from blank resulting text.
|
||||
- Prompt guidance and validator naming express the same contract as the code.
|
||||
Tests protect outcomes rather than exact prompt prose or incidental formatting.
|
||||
|
||||
Use deterministic, offline controlled responses for behavioral integration tests;
|
||||
no live-provider or paid evaluation is a prerequisite. Representative production
|
||||
examples can inform prompt quality without expanding this into an evaluation
|
||||
framework or guaranteeing that models always follow the instructions.
|
||||
|
||||
## Deferred Work
|
||||
|
||||
[Whole-segment removal](future.md#whole-segment-removal) is only potential future
|
||||
work and first requires deciding whether its benefit warrants implementation.
|
||||
Domain-aware regeneration and independent whole-pipeline traversal also remain
|
||||
in [future.md](future.md). This feature changes neither retry budgets nor the
|
||||
Audita/PromptKit ownership boundary and requires no upstream library feature.
|
||||
|
||||
Implementation sequencing and concrete names belong to the
|
||||
[historical implementation plan](https://gitea.maximumdirect.net/eric/audita/src/commit/60e2fe7/docs/roadmap/implementation.md).
|
||||
The target remains consistent deletion of spans within surviving segments, with
|
||||
no new operator controls or report types.
|
||||
12
examples/minimal-config.yml
Normal file
12
examples/minimal-config.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
backends:
|
||||
local:
|
||||
endpoint: http://127.0.0.1:11434/v1
|
||||
concurrency: 1
|
||||
llm:
|
||||
proposal_profile: local-proposal
|
||||
validation_profile: local-validation
|
||||
pipeline:
|
||||
modules: [grammar]
|
||||
output:
|
||||
schema: bare-segments
|
||||
3
examples/overlays/testing.yml
Normal file
3
examples/overlays/testing.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
llm:
|
||||
proposal_profile: service-proposal-testing
|
||||
validation_profile: service-validation-testing
|
||||
40
examples/production-config.yml
Normal file
40
examples/production-config.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
version: 2
|
||||
backends:
|
||||
service:
|
||||
endpoint: https://openrouter.ai/api/v1
|
||||
credential: AUDITA_SERVICE_KEY
|
||||
concurrency: 2
|
||||
queue_capacity: 1024
|
||||
llm:
|
||||
proposal_profile: service-proposal
|
||||
validation_profile: service-validation
|
||||
transient_retries: 2
|
||||
repair_attempts: 2
|
||||
operation_timeout: 15m
|
||||
pipeline:
|
||||
modules: [glossary, homophones, glossary, spoken_word, grammar]
|
||||
output:
|
||||
schema: audita-v1
|
||||
chunking:
|
||||
# Requires at least this many normalized segments; omit for automatic chunking.
|
||||
target_sections: 8
|
||||
max_section_tokens: 8192
|
||||
min_section_tokens: 2048
|
||||
normalization:
|
||||
max_segment_gap: 4.0
|
||||
ellipsis_gap: 3.5
|
||||
max_segment_duration: 60.0
|
||||
max_segment_tokens: 2048
|
||||
thresholds:
|
||||
glossary: 0.8
|
||||
homophones: 0.8
|
||||
spoken_word: 0.8
|
||||
grammar: 0.8
|
||||
context:
|
||||
description: "General context for domain vocabulary and speaker names."
|
||||
reporting:
|
||||
enabled: true
|
||||
stdout_dir: .
|
||||
diagnostics:
|
||||
debug: false
|
||||
work_dir: /tmp/audita
|
||||
7
examples/profiles/local-proposal.yaml
Normal file
7
examples/profiles/local-proposal.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: local-proposal
|
||||
backend: local
|
||||
model: replace-with-local-model
|
||||
temperature: 0
|
||||
max_tokens: 2048
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
7
examples/profiles/local-validation.yaml
Normal file
7
examples/profiles/local-validation.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: local-validation
|
||||
backend: local
|
||||
model: replace-with-local-model
|
||||
temperature: 0
|
||||
max_tokens: 1024
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
7
examples/profiles/service-proposal-testing.yaml
Normal file
7
examples/profiles/service-proposal-testing.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: service-proposal-testing
|
||||
backend: service
|
||||
model: replace-with-testing-model
|
||||
temperature: 0
|
||||
max_tokens: 2048
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
7
examples/profiles/service-proposal.yaml
Normal file
7
examples/profiles/service-proposal.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: service-proposal
|
||||
backend: service
|
||||
model: replace-with-provider-model
|
||||
temperature: 0
|
||||
max_tokens: 2048
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
7
examples/profiles/service-validation-testing.yaml
Normal file
7
examples/profiles/service-validation-testing.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: service-validation-testing
|
||||
backend: service
|
||||
model: replace-with-testing-model
|
||||
temperature: 0
|
||||
max_tokens: 1024
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
7
examples/profiles/service-validation.yaml
Normal file
7
examples/profiles/service-validation.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
id: service-validation
|
||||
backend: service
|
||||
model: replace-with-provider-model
|
||||
temperature: 0
|
||||
max_tokens: 1024
|
||||
top_p: 1
|
||||
timeout_seconds: 120
|
||||
6
examples/tiny-glossary.yaml
Normal file
6
examples/tiny-glossary.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
glossary:
|
||||
- name: Audita
|
||||
aliases:
|
||||
- audita
|
||||
category: product
|
||||
summary: The Audita transcript correction CLI.
|
||||
9
examples/tiny-transcript.json
Normal file
9
examples/tiny-transcript.json
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"speaker": "A",
|
||||
"start": 0.0,
|
||||
"end": 1.2,
|
||||
"text": "hello world"
|
||||
}
|
||||
]
|
||||
20
go.mod
Normal file
20
go.mod
Normal file
@@ -0,0 +1,20 @@
|
||||
module gitea.maximumdirect.net/eric/audita
|
||||
|
||||
go 1.25.5
|
||||
|
||||
require (
|
||||
gitea.maximumdirect.net/eric/ConfigKit v0.4.2
|
||||
gitea.maximumdirect.net/eric/promptkit v0.11.2
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0 // indirect
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
)
|
||||
33
go.sum
Normal file
33
go.sum
Normal file
@@ -0,0 +1,33 @@
|
||||
gitea.maximumdirect.net/eric/ConfigKit v0.4.2 h1:ZMxmv8pOnLtAx2hFTf8Z+pHKUbR89xErkBhwjr4yK24=
|
||||
gitea.maximumdirect.net/eric/ConfigKit v0.4.2/go.mod h1:tYWpsrbLyu05r8+1MapWp5fN6ZrX9I8hU2xEPedYmYk=
|
||||
gitea.maximumdirect.net/eric/promptkit v0.11.2 h1:2RqI+KtflvSh7vLQaTAQCmMaFQscEA7EPwPazyvXRoY=
|
||||
gitea.maximumdirect.net/eric/promptkit v0.11.2/go.mod h1:onm/FBPUKQ8/NSPwTEk26Ut+dVX2iXcq8vEseB+g/0E=
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0 h1:wdab+R+lgMZxzYwhbAuCrW7zdSQ1cW9ovBR6UzLmZR4=
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0/go.mod h1:a3VBbh9oaGXD6ruxhtwHj+AWW6DY/SSyby1QtMmYSUo=
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0 h1:baCCIB6Ee5t0S4Zc++NTBIPcJEv5UPS6DlSrpZfykwg=
|
||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0/go.mod h1:mtgD1E0SGm0e/I8Ffhz+AYX7GN7RKUWJXehNFIKHs4Y=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
222
internal/cli/config_input.go
Normal file
222
internal/cli/config_input.go
Normal file
@@ -0,0 +1,222 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/config"
|
||||
)
|
||||
|
||||
var systemConfigPaths = []string{"/usr/local/etc/audita/config.yml", "/etc/audita/config.yml"}
|
||||
|
||||
type configInput struct {
|
||||
ConfigPath string
|
||||
ConfigPathSet bool
|
||||
Overlay string
|
||||
View string
|
||||
TranscriptPath string
|
||||
GlossaryPath string
|
||||
OutputPath string
|
||||
Overrides []ck.Override
|
||||
}
|
||||
|
||||
type selectedConfig struct {
|
||||
Path string
|
||||
Source string
|
||||
Result *ck.Result[config.Config]
|
||||
}
|
||||
|
||||
// parseConfigInput owns the common setting flags and process-only path flags.
|
||||
// A transcript before flags and one after flags are both accepted.
|
||||
func parseConfigInput(command string, args []string, output io.Writer) (configInput, bool, error) {
|
||||
var input configInput
|
||||
fs := flag.NewFlagSet(command, flag.ContinueOnError)
|
||||
fs.SetOutput(output)
|
||||
configPath := fs.String("config", "", "Main configuration YAML file")
|
||||
overlay := fs.String("overlay", "", "Selected configuration overlay")
|
||||
if command == "print-effective" {
|
||||
fs.String("view", "settings", "Effective view: settings, profiles, or explain")
|
||||
}
|
||||
settingPaths := map[string]ck.Path{
|
||||
"proposal-profile": ck.Keys("llm", "proposal_profile"),
|
||||
"validation-profile": ck.Keys("llm", "validation_profile"),
|
||||
"output-schema": ck.Keys("output", "schema"),
|
||||
"validation-max-prompt-tokens": ck.Keys("validation", "max_prompt_tokens"),
|
||||
"target-sections": ck.Keys("chunking", "target_sections"),
|
||||
"max-section-tokens": ck.Keys("chunking", "max_section_tokens"),
|
||||
"min-section-tokens": ck.Keys("chunking", "min_section_tokens"),
|
||||
"normalize-max-segment-gap": ck.Keys("normalization", "max_segment_gap"),
|
||||
"normalize-ellipsis-gap": ck.Keys("normalization", "ellipsis_gap"),
|
||||
"normalize-max-segment-duration": ck.Keys("normalization", "max_segment_duration"),
|
||||
"normalize-max-segment-tokens": ck.Keys("normalization", "max_segment_tokens"),
|
||||
"glossary-confidence-threshold": ck.Keys("thresholds", "glossary"),
|
||||
"homophones-confidence-threshold": ck.Keys("thresholds", "homophones"),
|
||||
"spoken-word-confidence-threshold": ck.Keys("thresholds", "spoken_word"),
|
||||
"grammar-confidence-threshold": ck.Keys("thresholds", "grammar"),
|
||||
"transcript-description": ck.Keys("context", "description"),
|
||||
"reporting": ck.Keys("reporting", "enabled"),
|
||||
"report-dir": ck.Keys("reporting", "stdout_dir"),
|
||||
"debug": ck.Keys("diagnostics", "debug"),
|
||||
"work-dir": ck.Keys("diagnostics", "work_dir"),
|
||||
"modules": ck.Keys("pipeline", "modules"),
|
||||
}
|
||||
for name := range settingPaths {
|
||||
switch name {
|
||||
case "reporting", "debug":
|
||||
fs.Bool(name, false, "Setting override")
|
||||
case "validation-max-prompt-tokens", "target-sections", "max-section-tokens", "min-section-tokens", "normalize-max-segment-tokens":
|
||||
fs.Int(name, 0, "Setting override")
|
||||
case "normalize-max-segment-gap", "normalize-ellipsis-gap", "normalize-max-segment-duration", "glossary-confidence-threshold", "homophones-confidence-threshold", "spoken-word-confidence-threshold", "grammar-confidence-threshold":
|
||||
fs.Float64(name, 0, "Setting override")
|
||||
default:
|
||||
fs.String(name, "", "Setting override")
|
||||
}
|
||||
}
|
||||
if command == "process" {
|
||||
fs.String("glossary", "", "Glossary YAML file")
|
||||
fs.String("output", "", "Corrected transcript output file")
|
||||
}
|
||||
parseArgs := args
|
||||
front := ""
|
||||
if command == "process" && len(args) > 0 && !strings.HasPrefix(args[0], "-") {
|
||||
front, parseArgs = args[0], args[1:]
|
||||
}
|
||||
if err := fs.Parse(parseArgs); err != nil {
|
||||
if errors.Is(err, flag.ErrHelp) {
|
||||
return configInput{}, true, nil
|
||||
}
|
||||
return configInput{}, false, err
|
||||
}
|
||||
positions := fs.Args()
|
||||
if front != "" {
|
||||
positions = append([]string{front}, positions...)
|
||||
}
|
||||
if command == "process" {
|
||||
if len(positions) != 1 {
|
||||
return configInput{}, false, fmt.Errorf("expected exactly one transcript JSON path")
|
||||
}
|
||||
input.TranscriptPath = positions[0]
|
||||
input.GlossaryPath = fs.Lookup("glossary").Value.String()
|
||||
input.OutputPath = fs.Lookup("output").Value.String()
|
||||
if strings.TrimSpace(input.GlossaryPath) == "" {
|
||||
return configInput{}, false, fmt.Errorf("--glossary is required")
|
||||
}
|
||||
} else if len(positions) != 0 {
|
||||
return configInput{}, false, fmt.Errorf("unexpected positional arguments")
|
||||
}
|
||||
input.ConfigPath, input.Overlay = *configPath, *overlay
|
||||
if command == "print-effective" {
|
||||
input.View = fs.Lookup("view").Value.String()
|
||||
switch input.View {
|
||||
case "settings", "profiles", "explain":
|
||||
default:
|
||||
return configInput{}, false, fmt.Errorf("unknown effective view %q", input.View)
|
||||
}
|
||||
}
|
||||
fs.Visit(func(f *flag.Flag) {
|
||||
if f.Name == "config" {
|
||||
input.ConfigPathSet = true
|
||||
}
|
||||
path, ok := settingPaths[f.Name]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var value any = f.Value.String()
|
||||
switch f.Name {
|
||||
case "reporting", "debug":
|
||||
value, _ = strconv.ParseBool(f.Value.String())
|
||||
case "modules":
|
||||
modules, err := config.ParseModulesCSV(f.Value.String())
|
||||
if err != nil {
|
||||
value = err
|
||||
} else {
|
||||
values := make([]any, len(modules))
|
||||
for i, module := range modules {
|
||||
values[i] = module
|
||||
}
|
||||
value = values
|
||||
}
|
||||
case "validation-max-prompt-tokens", "target-sections", "max-section-tokens", "min-section-tokens", "normalize-max-segment-tokens":
|
||||
value, _ = strconv.Atoi(f.Value.String())
|
||||
case "normalize-max-segment-gap", "normalize-ellipsis-gap", "normalize-max-segment-duration", "glossary-confidence-threshold", "homophones-confidence-threshold", "spoken-word-confidence-threshold", "grammar-confidence-threshold":
|
||||
value, _ = strconv.ParseFloat(f.Value.String(), 64)
|
||||
}
|
||||
input.Overrides = append(input.Overrides, ck.Override{Path: path, Value: value, Flag: "--" + f.Name})
|
||||
})
|
||||
for _, override := range input.Overrides {
|
||||
if err, ok := override.Value.(error); ok {
|
||||
return configInput{}, false, fmt.Errorf("%s: %w", override.Flag, err)
|
||||
}
|
||||
}
|
||||
return input, false, nil
|
||||
}
|
||||
|
||||
func selectConfigPath(explicit string, set bool, stat func(string) (os.FileInfo, error), candidates []string) (string, string, error) {
|
||||
if set {
|
||||
if strings.TrimSpace(explicit) == "" {
|
||||
return "", "", fmt.Errorf("--config requires a nonempty path")
|
||||
}
|
||||
if _, err := stat(explicit); err != nil {
|
||||
return "", "", fmt.Errorf("config file %q: %w", explicit, err)
|
||||
}
|
||||
return explicit, "flag", nil
|
||||
}
|
||||
for _, path := range candidates {
|
||||
if _, err := stat(path); err == nil {
|
||||
return path, "default", nil
|
||||
} else if !os.IsNotExist(err) {
|
||||
return "", "", fmt.Errorf("config file %q: %w", path, err)
|
||||
}
|
||||
}
|
||||
return "", "", fmt.Errorf("no configuration file found; select a config with backend and profile settings")
|
||||
}
|
||||
|
||||
func loadConfigInput(input configInput, command string) (selectedConfig, error) {
|
||||
if command == "validate" && (!input.ConfigPathSet || strings.TrimSpace(input.ConfigPath) == "") {
|
||||
return selectedConfig{}, fmt.Errorf("--config is required")
|
||||
}
|
||||
path, source, err := selectConfigPath(input.ConfigPath, input.ConfigPathSet, os.Stat, systemConfigPaths)
|
||||
if err != nil {
|
||||
return selectedConfig{}, err
|
||||
}
|
||||
loaded, err := config.Load(ck.File(path), input.Overlay, input.Overrides...)
|
||||
if err != nil {
|
||||
return selectedConfig{}, err
|
||||
}
|
||||
return selectedConfig{Path: path, Source: source, Result: loaded}, nil
|
||||
}
|
||||
|
||||
func configInputError(err error) string {
|
||||
var loadErr *ck.LoadError
|
||||
if !errors.As(err, &loadErr) {
|
||||
return err.Error()
|
||||
}
|
||||
var messages []string
|
||||
for _, diagnostic := range loadErr.Diagnostics() {
|
||||
messages = append(messages, diagnostic.Message)
|
||||
}
|
||||
if len(messages) == 0 {
|
||||
return err.Error()
|
||||
}
|
||||
return strings.Join(messages, "; ")
|
||||
}
|
||||
|
||||
func selectedReportDir(cfg config.Config, outputPath string) (string, error) {
|
||||
if !cfg.Reporting.Enabled {
|
||||
return "", nil
|
||||
}
|
||||
if outputPath != "" {
|
||||
return filepath.Dir(outputPath), nil
|
||||
}
|
||||
if strings.TrimSpace(cfg.Reporting.StdoutDir) == "" {
|
||||
return "", fmt.Errorf("report directory is required when reporting is enabled and transcript output is stdout")
|
||||
}
|
||||
return cfg.Reporting.StdoutDir, nil
|
||||
}
|
||||
250
internal/cli/config_input_test.go
Normal file
250
internal/cli/config_input_test.go
Normal file
@@ -0,0 +1,250 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/config"
|
||||
)
|
||||
|
||||
func TestSharedConfigInput(t *testing.T) {
|
||||
for _, command := range []string{"process", "validate", "print-effective"} {
|
||||
t.Run(command, func(t *testing.T) {
|
||||
args := []string{"--config", "main.yml", "--overlay", "testing", "--proposal-profile", "economy", "--modules", "", "--target-sections", "0"}
|
||||
if command == "process" {
|
||||
args = append([]string{"transcript.json", "--glossary", "glossary.yml"}, args...)
|
||||
}
|
||||
input, help, err := parseConfigInput(command, args, io.Discard)
|
||||
if err != nil || help {
|
||||
t.Fatalf("parse: %+v %v %v", input, help, err)
|
||||
}
|
||||
if !input.ConfigPathSet || input.ConfigPath != "main.yml" || input.Overlay != "testing" || len(input.Overrides) != 3 {
|
||||
t.Fatalf("selection: %+v", input)
|
||||
}
|
||||
for _, override := range input.Overrides {
|
||||
switch override.Path.String() {
|
||||
case ck.Keys("pipeline", "modules").String():
|
||||
if values, ok := override.Value.([]any); !ok || len(values) != 0 {
|
||||
t.Fatalf("empty modules: %#v", override.Value)
|
||||
}
|
||||
case ck.Keys("chunking", "target_sections").String():
|
||||
if override.Value != 0 {
|
||||
t.Fatalf("zero target: %#v", override.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigInputRejectsRemovedAndProcessOnlyFlags(t *testing.T) {
|
||||
for _, command := range []string{"process", "validate", "print-effective"} {
|
||||
for _, flag := range []string{"--model", "--llm-api-key", "--max-retries", "--llm-concurrency", "--report-json", "--work-dir-retention"} {
|
||||
args := []string{flag, "value"}
|
||||
if command == "process" {
|
||||
args = append([]string{"transcript.json", "--glossary", "glossary.yml"}, args...)
|
||||
}
|
||||
if _, _, err := parseConfigInput(command, args, io.Discard); err == nil {
|
||||
t.Fatalf("%s accepted %s", command, flag)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, command := range []string{"validate", "print-effective"} {
|
||||
if _, _, err := parseConfigInput(command, []string{"--glossary", "glossary.yml"}, io.Discard); err == nil {
|
||||
t.Fatalf("%s accepted process path", command)
|
||||
}
|
||||
if _, _, err := parseConfigInput(command, []string{"transcript.json"}, io.Discard); err == nil {
|
||||
t.Fatalf("%s accepted positional", command)
|
||||
}
|
||||
}
|
||||
for _, command := range []string{"process", "validate", "print-effective"} {
|
||||
_, help, err := parseConfigInput(command, []string{"--help"}, io.Discard)
|
||||
if err != nil || !help {
|
||||
t.Fatalf("%s help: %v %v", command, help, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigSelection(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
first, second := filepath.Join(dir, "first.yml"), filepath.Join(dir, "second.yml")
|
||||
if err := os.WriteFile(second, []byte("version: 2\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path, source, err := selectConfigPath("", false, os.Stat, []string{first, second})
|
||||
if err != nil || path != second || source != "default" {
|
||||
t.Fatalf("discovery: %q %q %v", path, source, err)
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
explicit string
|
||||
set bool
|
||||
candidates []string
|
||||
}{
|
||||
{"", true, []string{second}}, {first, true, []string{second}}, {"", false, []string{first}},
|
||||
} {
|
||||
if _, _, err := selectConfigPath(tc.explicit, tc.set, os.Stat, tc.candidates); err == nil {
|
||||
t.Fatalf("accepted unavailable selection: %+v", tc)
|
||||
}
|
||||
}
|
||||
statDenied := func(string) (os.FileInfo, error) { return nil, os.ErrPermission }
|
||||
if _, _, err := selectConfigPath("", false, statDenied, []string{first}); !errors.Is(err, os.ErrPermission) {
|
||||
t.Fatalf("inaccessible candidate: %v", err)
|
||||
}
|
||||
path, source, err = selectConfigPath(second, true, os.Stat, []string{first})
|
||||
if err != nil || path != second || source != "flag" {
|
||||
t.Fatalf("explicit path: %q %q %v", path, source, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyEnvironmentDoesNotSelectConfig(t *testing.T) {
|
||||
t.Setenv("AUDITA_CONFIG", filepath.Join(t.TempDir(), "legacy.yml"))
|
||||
_, _, err := selectConfigPath("", false, os.Stat, []string{filepath.Join(t.TempDir(), "missing.yml")})
|
||||
if err == nil || !strings.Contains(err.Error(), "no configuration file") {
|
||||
t.Fatalf("legacy environment changed discovery: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectiveViewParsing(t *testing.T) {
|
||||
for _, view := range []string{"settings", "profiles", "explain"} {
|
||||
input, _, err := parseConfigInput("print-effective", []string{"--view", view}, io.Discard)
|
||||
if err != nil || input.View != view {
|
||||
t.Fatalf("%q: %+v %v", view, input, err)
|
||||
}
|
||||
}
|
||||
if _, _, err := parseConfigInput("print-effective", []string{"--view", "raw"}, io.Discard); err == nil {
|
||||
t.Fatal("unknown view accepted")
|
||||
}
|
||||
if _, _, err := parseConfigInput("validate", []string{"--view", "profiles"}, io.Discard); err == nil {
|
||||
t.Fatal("validate accepted inspection-only flag")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSharedLoadingUsesSelectedFileOverlayAndVisitedOverrides(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "overlays"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main := filepath.Join(dir, "config.yml")
|
||||
base := "version: 2\nbackends:\n local:\n endpoint: https://local.invalid/v1\nllm:\n proposal_profile: base\nchunking:\n max_section_tokens: 900\n"
|
||||
if err := os.WriteFile(main, []byte(base), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "overlays", "testing.yml"), []byte("llm:\n proposal_profile: testing\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, command := range []string{"process", "validate", "print-effective"} {
|
||||
args := []string{"--config", main, "--overlay", "testing", "--min-section-tokens", "500"}
|
||||
if command == "process" {
|
||||
args = append([]string{"input.json", "--glossary", "glossary.yml"}, args...)
|
||||
}
|
||||
input, _, err := parseConfigInput(command, args, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
selected, err := loadConfigInput(input, command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := selected.Result.Config
|
||||
if c.LLM.ProposalProfile != "testing" || c.LLM.ValidationProfile != "testing" || c.Chunking.MinSectionTokens != 500 || c.Chunking.MaxSectionTokens != 900 {
|
||||
t.Fatalf("%s resolved %+v", command, c)
|
||||
}
|
||||
}
|
||||
input, _, err := parseConfigInput("validate", []string{"--overlay", "testing"}, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := loadConfigInput(input, "validate"); err == nil {
|
||||
t.Fatal("validate accepted discovery")
|
||||
}
|
||||
input, _, err = parseConfigInput("validate", []string{"--config", main}, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := loadConfigInput(input, "validate"); err == nil {
|
||||
t.Fatal("unmodified invalid lower-precedence section relation accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportingAndDebugOverridesRemainIndependent(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "overlays"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main := filepath.Join(dir, "config.yml")
|
||||
base := "version: 2\nbackends:\n local:\n endpoint: https://local.invalid/v1\nllm:\n proposal_profile: base\n"
|
||||
if err := os.WriteFile(main, []byte(base), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "overlays", "testing.yml"), []byte("reporting:\n enabled: true\n stdout_dir: reports\ndiagnostics:\n debug: true\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defaultInput, _, err := parseConfigInput("validate", []string{"--config", main}, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defaults, err := loadConfigInput(defaultInput, "validate")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !defaults.Result.Config.Reporting.Enabled || defaults.Result.Config.Reporting.StdoutDir != "." || defaults.Result.Config.Diagnostics.Debug {
|
||||
t.Fatalf("unexpected defaults: %+v", defaults.Result.Config)
|
||||
}
|
||||
for _, command := range []string{"process", "validate", "print-effective"} {
|
||||
args := []string{"--config", main, "--overlay", "testing", "--reporting=false", "--debug=false"}
|
||||
if command == "process" {
|
||||
args = append([]string{"input.json", "--glossary", "glossary.yml"}, args...)
|
||||
}
|
||||
input, _, err := parseConfigInput(command, args, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(input.Overrides) != 2 || input.Overrides[0].Value != false || input.Overrides[1].Value != false {
|
||||
t.Fatalf("boolean overrides must remain typed: %+v", input.Overrides)
|
||||
}
|
||||
selected, err := loadConfigInput(input, command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if selected.Result.Config.Reporting.Enabled || selected.Result.Config.Diagnostics.Debug || selected.Result.Config.Reporting.StdoutDir != "reports" {
|
||||
t.Fatalf("%s did not honor explicit false: %+v", command, selected.Result.Config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportDirectorySelectionOnlyUsesActiveDestination(t *testing.T) {
|
||||
cfg := config.Config{Reporting: config.Reporting{Enabled: true, StdoutDir: "reports"}}
|
||||
if got, err := selectedReportDir(cfg, ""); err != nil || got != "reports" {
|
||||
t.Fatalf("stdout destination: %q %v", got, err)
|
||||
}
|
||||
cfg.Reporting.StdoutDir = ""
|
||||
if got, err := selectedReportDir(cfg, filepath.Join("out", "corrected.json")); err != nil || got != "out" {
|
||||
t.Fatalf("file destination ignored stdout setting: %q %v", got, err)
|
||||
}
|
||||
if _, err := selectedReportDir(cfg, ""); err == nil {
|
||||
t.Fatal("enabled stdout reporting accepted blank destination")
|
||||
}
|
||||
cfg.Reporting.Enabled = false
|
||||
if got, err := selectedReportDir(cfg, ""); err != nil || got != "" {
|
||||
t.Fatalf("disabled reporting probed destination: %q %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBareBooleanFlagsAndReportDirectoryOverride(t *testing.T) {
|
||||
input, _, err := parseConfigInput("process", []string{"input.json", "--glossary", "glossary.yml", "--reporting", "--debug", "--report-dir", "reports"}, io.Discard)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
values := map[string]any{}
|
||||
for _, override := range input.Overrides {
|
||||
values[override.Path.String()] = override.Value
|
||||
}
|
||||
if values[ck.Keys("reporting", "enabled").String()] != true || values[ck.Keys("diagnostics", "debug").String()] != true || values[ck.Keys("reporting", "stdout_dir").String()] != "reports" {
|
||||
t.Fatalf("incorrect visited overrides: %+v", values)
|
||||
}
|
||||
}
|
||||
442
internal/cli/process.go
Normal file
442
internal/cli/process.go
Normal file
@@ -0,0 +1,442 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/chunking"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/diagnostics"
|
||||
coreio "gitea.maximumdirect.net/eric/audita/internal/core/io"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/normalization"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/outputschema"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/redaction"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/reporting"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/llm"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/modules"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/processreport"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/runner"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/structuredoutput"
|
||||
)
|
||||
|
||||
func runProcess(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
input, help, err := parseConfigInput("process", args, stderr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
if help {
|
||||
writeProcessUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
selected, err := loadConfigInput(input, "process")
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
cfg := selected.Result.Config
|
||||
reportDir, err := selectedReportDir(cfg, input.OutputPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 2
|
||||
}
|
||||
if cfg.Diagnostics.Debug && strings.TrimSpace(cfg.Diagnostics.WorkDir) == "" {
|
||||
fmt.Fprintln(stderr, "audita process: debug work directory is required")
|
||||
return 2
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", err)
|
||||
return 1
|
||||
}
|
||||
runtime, err := llm.NewRuntime(ctx, cfg, selected.Path, nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
if ctx.Err() != nil || llm.IsAssetError(err) {
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
specs, err := contracts.ResolveModuleRunSpecs(cfg.Pipeline.Modules)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 2
|
||||
}
|
||||
runID, err := generateRunID()
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: run ID: %s\n", llm.RedactError(err, cfg))
|
||||
return 1
|
||||
}
|
||||
started := time.Now().UTC()
|
||||
state := &processState{cfg: cfg, runtime: runtime, specs: specs, runID: runID, started: started,
|
||||
transcriptPath: input.TranscriptPath, glossaryPath: input.GlossaryPath, outputPath: input.OutputPath,
|
||||
selected: selected, overlay: input.Overlay, stderr: stderr, stdout: stdout, ctx: ctx}
|
||||
protected := []string{input.GlossaryPath}
|
||||
for _, source := range selected.Result.Sources() {
|
||||
if source.Path != "" {
|
||||
protected = append(protected, source.Path)
|
||||
}
|
||||
}
|
||||
protected = append(protected, runtime.ProfilePaths...)
|
||||
session, err := diagnostics.PrepareOutput(diagnostics.OutputSelection{InputTranscriptPath: input.TranscriptPath, TranscriptPath: input.OutputPath,
|
||||
ReportDir: reportDir, ReportingEnabled: cfg.Reporting.Enabled, ProtectedPaths: protected})
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 2
|
||||
}
|
||||
state.session = session
|
||||
initial := state.snapshot(reporting.StatusInProgress, nil, nil)
|
||||
initialBundle, err := state.bundle(initial)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 1
|
||||
}
|
||||
initFailure := []processreport.RunFailure{{Phase: "initialization", Reason: outcomes.ReasonInternalFailure}}
|
||||
failedInit, err := state.bundle(state.snapshot(reporting.StatusFailed, nil, initFailure))
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 1
|
||||
}
|
||||
if err := session.Initialize(initialBundle, failedInit); err != nil {
|
||||
fmt.Fprintf(stderr, "audita process: %s\n", llm.RedactError(err, cfg))
|
||||
return 1
|
||||
}
|
||||
state.startDebug()
|
||||
return state.execute()
|
||||
}
|
||||
|
||||
type processState struct {
|
||||
cfg config.Config
|
||||
runtime *llm.Runtime
|
||||
specs []contracts.ModuleRunSpec
|
||||
runID string
|
||||
started time.Time
|
||||
transcriptPath string
|
||||
glossaryPath string
|
||||
outputPath string
|
||||
selected selectedConfig
|
||||
overlay string
|
||||
ctx context.Context
|
||||
stdout io.Writer
|
||||
stderr io.Writer
|
||||
session *diagnostics.OutputSession
|
||||
debugDir *diagnostics.RunDirectory
|
||||
debugWarnings []string
|
||||
debugMu sync.Mutex
|
||||
runOutput *runner.RunOutput
|
||||
}
|
||||
|
||||
func generateRunID() (string, error) {
|
||||
var random [12]byte
|
||||
if _, err := rand.Read(random[:]); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "run-" + hex.EncodeToString(random[:]), nil
|
||||
}
|
||||
|
||||
func (s *processState) snapshot(status string, completed *time.Time, failures []processreport.RunFailure) reporting.Snapshot {
|
||||
return processreport.Build(processreport.BuildInput{RunID: s.runID, Status: status, StartedAt: s.started,
|
||||
CompletedAt: completed, TranscriptPath: s.transcriptPath, GlossaryPath: s.glossaryPath,
|
||||
OutputPath: s.outputPath, ModuleSpecs: s.specs, RunOutput: s.runOutput, RunFailures: failures})
|
||||
}
|
||||
|
||||
func (s *processState) bundle(snapshot reporting.Snapshot) (diagnostics.ReportBundle, error) {
|
||||
if !s.cfg.Reporting.Enabled {
|
||||
return diagnostics.ReportBundle{}, nil
|
||||
}
|
||||
secrets := llm.ConfiguredSecrets(&s.cfg)
|
||||
errorsYAML, err := reporting.YAML(snapshot.ErrorsDocument(), secrets...)
|
||||
if err != nil {
|
||||
return diagnostics.ReportBundle{}, err
|
||||
}
|
||||
recoveriesYAML, err := reporting.YAML(snapshot.RecoveriesDocument(), secrets...)
|
||||
if err != nil {
|
||||
return diagnostics.ReportBundle{}, err
|
||||
}
|
||||
return diagnostics.ReportBundle{Errors: errorsYAML, Recoveries: recoveriesYAML,
|
||||
Markdown: reporting.Markdown(snapshot, secrets...)}, nil
|
||||
}
|
||||
|
||||
func (s *processState) debugWrite(label string, write func(*diagnostics.RunDirectory) error) {
|
||||
if s.debugDir == nil {
|
||||
return
|
||||
}
|
||||
if err := write(s.debugDir); err != nil {
|
||||
s.reportDiagnosticError(fmt.Errorf("%s: %w", label, err))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *processState) startDebug() {
|
||||
if !s.cfg.Diagnostics.Debug {
|
||||
return
|
||||
}
|
||||
dir, err := diagnostics.NewRunDirectory(s.cfg.Diagnostics.WorkDir, s.runID, llm.ConfiguredSecrets(&s.cfg)...)
|
||||
if err != nil {
|
||||
s.reportDiagnosticError(fmt.Errorf("directory: %w", err))
|
||||
return
|
||||
}
|
||||
s.debugDir = dir
|
||||
s.debugWrite("invocation", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteInvocationMetadata(diagnostics.InvocationMetadata{
|
||||
Operation: "process", TranscriptPath: s.transcriptPath, GlossaryPath: s.glossaryPath,
|
||||
OutputPath: s.outputPath, ConfigPath: s.selected.Path, ConfigSource: s.selected.Source,
|
||||
Overlay: s.overlay, ConfigVersion: &s.cfg.Version, TranscriptDescription: s.cfg.Context.Description,
|
||||
Modules: append([]string(nil), s.cfg.Pipeline.Modules...), RunID: s.runID, StartedAt: s.started,
|
||||
})
|
||||
})
|
||||
var effective bytes.Buffer
|
||||
if err := s.selected.Result.WriteEffective(&effective); err == nil {
|
||||
s.debugWrite("effective settings", func(d *diagnostics.RunDirectory) error { return d.WriteEffectiveConfig(effective.Bytes()) })
|
||||
} else {
|
||||
s.reportDiagnosticError(fmt.Errorf("effective settings: %w", err))
|
||||
}
|
||||
if origins, err := llm.ExplanationYAML(s.selected.Result); err == nil {
|
||||
s.debugWrite("configuration origins", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteYAMLArtifact(diagnostics.ArtifactConfigOrigins, origins)
|
||||
})
|
||||
} else {
|
||||
s.reportDiagnosticError(fmt.Errorf("configuration origins: %w", err))
|
||||
}
|
||||
if profiles, err := s.runtime.SelectedProfilesYAML(); err == nil {
|
||||
s.debugWrite("selected profiles", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteYAMLArtifact(diagnostics.ArtifactSelectedProfiles, profiles)
|
||||
})
|
||||
} else {
|
||||
s.reportDiagnosticError(fmt.Errorf("selected profiles: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *processState) debugPath() string {
|
||||
if s.debugDir == nil {
|
||||
return ""
|
||||
}
|
||||
return s.debugDir.Path()
|
||||
}
|
||||
|
||||
func (s *processState) execute() int {
|
||||
transcriptBytes, err := coreio.ReadRequiredFile(s.transcriptPath, "transcript")
|
||||
if err != nil {
|
||||
return s.fail("input", outcomes.ReasonInternalFailure, err)
|
||||
}
|
||||
glossaryBytes, err := coreio.ReadRequiredFile(s.glossaryPath, "glossary")
|
||||
if err != nil {
|
||||
return s.fail("input", outcomes.ReasonInternalFailure, err)
|
||||
}
|
||||
source, err := schema.ParseSourceTranscriptJSON(transcriptBytes)
|
||||
if err != nil {
|
||||
return s.fail("input", outcomes.ReasonInputInvalid, err)
|
||||
}
|
||||
glossary, err := schema.ParseGlossaryYAML(glossaryBytes)
|
||||
if err != nil {
|
||||
return s.fail("input", outcomes.ReasonInputInvalid, err)
|
||||
}
|
||||
s.debugWrite("source transcript", func(d *diagnostics.RunDirectory) error { return d.WriteSourceTranscript(source, transcriptBytes) })
|
||||
normalizer := normalization.NewNormalizer(normalization.NormalizationConfig{
|
||||
MaxSegmentGap: s.cfg.Normalization.MaxSegmentGap, EllipsisGap: s.cfg.Normalization.EllipsisGap,
|
||||
MaxSegmentDuration: s.cfg.Normalization.MaxSegmentDuration, MaxSegmentTokens: s.cfg.Normalization.MaxSegmentTokens,
|
||||
})
|
||||
normalized, normSummary := normalizer.Normalize(sourceToCanonicalTranscript(source))
|
||||
s.debugWrite("normalized transcript", func(d *diagnostics.RunDirectory) error { return d.WriteNormalizedTranscript(normalized) })
|
||||
s.debugWrite("normalization summary", func(d *diagnostics.RunDirectory) error { return d.WriteNormalizationSummary(normSummary) })
|
||||
if err := s.ctx.Err(); err != nil {
|
||||
return s.fail("processing", outcomes.ReasonCanceled, err)
|
||||
}
|
||||
observations := llm.NewObservationCollector()
|
||||
proposalClient, err := s.runtime.NewRoleClient("proposal", observations.Hooks())
|
||||
if err != nil {
|
||||
return s.fail("processing", outcomes.ReasonSetupFailure, err)
|
||||
}
|
||||
validationClient, err := s.runtime.NewRoleClient("validation", observations.Hooks())
|
||||
if err != nil {
|
||||
return s.fail("processing", outcomes.ReasonSetupFailure, err)
|
||||
}
|
||||
factory := modules.NewFactory(modules.Dependencies{Config: &s.cfg, Glossary: glossary, DiagnosticsDir: s.debugPath()})
|
||||
result, runErr := runner.New(factory).Run(s.ctx, runner.RunInput{
|
||||
Config: &s.cfg, Transcript: normalized, Glossary: glossary, ModuleSpecs: s.specs,
|
||||
ProposalLLMClient: proposalClient, ProposalDiagnosticsDir: s.debugPath(),
|
||||
ValidationLLMClient: validationClient, ValidationDiagnosticsDir: s.debugPath(),
|
||||
CaptureCandidates: s.debugDir != nil,
|
||||
ReportDiagnosticError: s.reportDiagnosticError,
|
||||
})
|
||||
result.Observations = observations.Snapshot()
|
||||
result.ObservationsAvailable = true
|
||||
result.LLMSummary = llm.Summarize(result.Observations)
|
||||
s.runOutput = &result
|
||||
s.writeExecutionEvidence()
|
||||
if len(result.Sections) > 0 || runErr == nil {
|
||||
s.writeChunkSummary(result.Sections)
|
||||
}
|
||||
if runErr != nil {
|
||||
return s.fail("processing", fatalReason(s.ctx, runErr), runErr)
|
||||
}
|
||||
encoder, err := outputschema.Resolve(s.cfg.Output.Schema)
|
||||
if err != nil {
|
||||
return s.fail("encoding", outcomes.ReasonSetupFailure, err)
|
||||
}
|
||||
outputBytes, err := encoder.Encoder(result.FinalTranscript)
|
||||
if err != nil {
|
||||
return s.fail("encoding", outcomes.ReasonInternalFailure, err)
|
||||
}
|
||||
return s.finish(outputBytes)
|
||||
}
|
||||
|
||||
func (s *processState) writeChunkSummary(inventory []contracts.SectionMetadata) {
|
||||
if s.debugDir == nil {
|
||||
return
|
||||
}
|
||||
sections := make([]chunking.Section, len(inventory))
|
||||
for i, metadata := range inventory {
|
||||
sections[i] = chunking.Section{Index: metadata.Index, StartSegmentID: metadata.StartSegmentID,
|
||||
EndSegmentID: metadata.EndSegmentID, EstimatedTokens: metadata.EstimatedTokens,
|
||||
Segments: make([]schema.Segment, metadata.SegmentCount)}
|
||||
}
|
||||
config := chunking.ChunkingConfig{TargetSections: s.cfg.Chunking.TargetSections,
|
||||
MaxSectionTokens: s.cfg.Chunking.MaxSectionTokens, MinSectionTokens: s.cfg.Chunking.MinSectionTokens}
|
||||
summary := chunking.ComputeDetailedSummary(sections, config)
|
||||
s.debugWrite("chunking summary", func(d *diagnostics.RunDirectory) error { return d.WriteChunkingSummary(&summary) })
|
||||
}
|
||||
|
||||
func (s *processState) writeExecutionEvidence() {
|
||||
if s.debugDir == nil || s.runOutput == nil {
|
||||
return
|
||||
}
|
||||
output := s.runOutput
|
||||
s.debugWrite("model execution", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteJSONArtifact(diagnostics.ArtifactLLMExecution, processreport.BuildLLMExecution(output.Observations))
|
||||
})
|
||||
s.debugWrite("utilization", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteJSONArtifact(diagnostics.ArtifactUtilizationSummary, processreport.BuildUtilization(output, s.cfg.Backends))
|
||||
})
|
||||
s.debugWrite("correction ledger", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteJSONArtifact(diagnostics.ArtifactCorrectionLedger, processreport.BuildCorrectionLedger(processreport.CorrectionLedgerInput{
|
||||
RunDirectoryPath: d.Path(), RunOutput: output}))
|
||||
})
|
||||
}
|
||||
|
||||
func fatalReason(ctx context.Context, err error) outcomes.ReasonCode {
|
||||
if ctx.Err() != nil || errors.Is(err, context.Canceled) {
|
||||
return outcomes.ReasonCanceled
|
||||
}
|
||||
var failure *structuredoutput.Failure
|
||||
if errors.As(err, &failure) && failure.Reason != "" {
|
||||
return failure.Reason
|
||||
}
|
||||
return outcomes.ReasonInternalFailure
|
||||
}
|
||||
|
||||
func (s *processState) fail(phase string, reason outcomes.ReasonCode, cause error) int {
|
||||
s.debugWrite("error log", func(d *diagnostics.RunDirectory) error {
|
||||
return d.WriteErrorLog(phase + ": " + llm.RedactError(cause, s.cfg))
|
||||
})
|
||||
failures := []processreport.RunFailure{{Phase: phase, Reason: reason}}
|
||||
completed := time.Now().UTC()
|
||||
base, err := s.bundle(s.snapshot(reporting.StatusFailed, &completed, failures))
|
||||
if err != nil {
|
||||
fmt.Fprintf(s.stderr, "audita process: %s\n", llm.RedactError(err, s.cfg))
|
||||
}
|
||||
writeFailures := s.session.Finalize(nil, base, func(extra []diagnostics.FileFailure) diagnostics.ReportBundle {
|
||||
all := append(append([]processreport.RunFailure(nil), failures...), mapWriteFailures(extra)...)
|
||||
bundle, renderErr := s.bundle(s.snapshot(reporting.StatusFailed, &completed, all))
|
||||
if renderErr != nil {
|
||||
return base
|
||||
}
|
||||
return bundle
|
||||
})
|
||||
fmt.Fprintf(s.stderr, "audita process: %s\n", llm.RedactError(cause, s.cfg))
|
||||
s.printFailures(writeFailures)
|
||||
s.printDebugWarnings()
|
||||
if s.debugDir != nil {
|
||||
fmt.Fprintf(s.stderr, "audita process: diagnostics: %s\n", s.safePath(s.debugDir.Path()))
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
func (s *processState) finish(outputBytes []byte) int {
|
||||
completed := time.Now().UTC()
|
||||
snapshot := s.snapshot(reporting.StatusCompleted, &completed, nil)
|
||||
complete, err := s.bundle(snapshot)
|
||||
if err != nil {
|
||||
return s.fail("report_write", outcomes.ReasonInternalFailure, err)
|
||||
}
|
||||
if s.session.TranscriptPath() == "" {
|
||||
if _, err := s.stdout.Write(outputBytes); err != nil {
|
||||
return s.fail("transcript_write", outcomes.ReasonInternalFailure, err)
|
||||
}
|
||||
outputBytes = nil
|
||||
}
|
||||
writeFailures := s.session.Finalize(outputBytes, complete, func(extra []diagnostics.FileFailure) diagnostics.ReportBundle {
|
||||
failed, renderErr := s.bundle(s.snapshot(reporting.StatusFailed, &completed, mapWriteFailures(extra)))
|
||||
if renderErr != nil {
|
||||
return diagnostics.ReportBundle{}
|
||||
}
|
||||
return failed
|
||||
})
|
||||
if len(writeFailures) > 0 {
|
||||
s.printFailures(writeFailures)
|
||||
s.printDebugWarnings()
|
||||
if s.debugDir != nil {
|
||||
fmt.Fprintf(s.stderr, "audita process: diagnostics: %s\n", s.safePath(s.debugDir.Path()))
|
||||
}
|
||||
return 1
|
||||
}
|
||||
fmt.Fprintln(s.stderr, reporting.CompletionLine(snapshot))
|
||||
for _, path := range s.session.ReportPaths() {
|
||||
fmt.Fprintf(s.stderr, "Report: %s\n", s.safePath(path))
|
||||
}
|
||||
if s.debugDir != nil {
|
||||
fmt.Fprintf(s.stderr, "Debug: %s\n", s.safePath(s.debugDir.Path()))
|
||||
}
|
||||
s.printDebugWarnings()
|
||||
return 0
|
||||
}
|
||||
|
||||
func mapWriteFailures(failures []diagnostics.FileFailure) []processreport.RunFailure {
|
||||
out := make([]processreport.RunFailure, len(failures))
|
||||
for i, failure := range failures {
|
||||
phase := "report_write"
|
||||
if failure.Kind == "transcript write" {
|
||||
phase = "transcript_write"
|
||||
}
|
||||
out[i] = processreport.RunFailure{Phase: phase, Reason: outcomes.ReasonInternalFailure, OutputPath: failure.Path}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *processState) printFailures(failures []diagnostics.FileFailure) {
|
||||
for _, failure := range failures {
|
||||
fmt.Fprintf(s.stderr, "audita process: %s\n", llm.RedactError(failure, s.cfg))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *processState) printDebugWarnings() {
|
||||
s.debugMu.Lock()
|
||||
defer s.debugMu.Unlock()
|
||||
for _, warning := range s.debugWarnings {
|
||||
fmt.Fprintf(s.stderr, "audita process: %s\n", warning)
|
||||
}
|
||||
}
|
||||
|
||||
// safePath sanitizes presentation only; filesystem destinations remain literal.
|
||||
func (s *processState) safePath(path string) string {
|
||||
return redaction.New(llm.ConfiguredSecrets(&s.cfg)).String(path)
|
||||
}
|
||||
|
||||
func (s *processState) reportDiagnosticError(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
message := "debug " + llm.RedactError(err, s.cfg)
|
||||
s.debugMu.Lock()
|
||||
defer s.debugMu.Unlock()
|
||||
s.debugWarnings = append(s.debugWarnings, message)
|
||||
}
|
||||
233
internal/cli/run.go
Normal file
233
internal/cli/run.go
Normal file
@@ -0,0 +1,233 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/llm"
|
||||
)
|
||||
|
||||
func sourceToCanonicalTranscript(source *schema.SourceTranscript) *schema.Transcript {
|
||||
segments := make([]schema.Segment, len(source.Segments))
|
||||
for i, s := range source.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
return &schema.Transcript{Segments: segments}
|
||||
}
|
||||
|
||||
// Run executes the Audita CLI with the provided arguments and streams.
|
||||
func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
if len(args) == 0 {
|
||||
writeRootUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
if len(args) == 2 && args[0] == "help" {
|
||||
switch args[1] {
|
||||
case "process":
|
||||
writeProcessUsage(stdout)
|
||||
return 0
|
||||
case "config":
|
||||
writeConfigUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
if isHelpCommand(args) {
|
||||
writeRootUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
|
||||
if args[0] == "process" {
|
||||
return runProcess(ctx, args[1:], stdout, stderr)
|
||||
}
|
||||
if args[0] == "config" {
|
||||
return runConfig(ctx, args[1:], stdout, stderr)
|
||||
}
|
||||
|
||||
fmt.Fprintf(stderr, "audita: unknown command %q\n\n", args[0])
|
||||
writeRootUsage(stderr)
|
||||
return 2
|
||||
}
|
||||
|
||||
func runConfig(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
if len(args) == 0 || isHelpCommand(args) || args[0] == "--help" || args[0] == "-h" {
|
||||
writeConfigUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
case "validate":
|
||||
return runConfigValidate(ctx, args[1:], stdout, stderr)
|
||||
case "print-effective":
|
||||
return runConfigPrintEffective(ctx, args[1:], stdout, stderr)
|
||||
default:
|
||||
fmt.Fprintf(stderr, "audita config: unknown command %q\n\n", args[0])
|
||||
writeConfigUsage(stderr)
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
func runConfigValidate(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
input, help, err := parseConfigInput("validate", args, stderr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config validate: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
if help {
|
||||
writeConfigValidateUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
selected, err := loadConfigInput(input, "validate")
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config validate: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
if _, err := llm.NewRuntime(ctx, selected.Result.Config, selected.Path, nil); err != nil {
|
||||
fmt.Fprintf(stderr, "audita config validate: %s\n", llm.RedactError(err, selected.Result.Config))
|
||||
if llm.IsAssetError(err) {
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
fmt.Fprintln(stdout, "config is valid")
|
||||
return 0
|
||||
}
|
||||
|
||||
func runConfigPrintEffective(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
input, help, err := parseConfigInput("print-effective", args, stderr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config print-effective: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
if help {
|
||||
writeConfigPrintEffectiveUsage(stdout)
|
||||
return 0
|
||||
}
|
||||
selected, err := loadConfigInput(input, "print-effective")
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config print-effective: %s\n", configInputError(err))
|
||||
return 2
|
||||
}
|
||||
llmRuntime, err := llm.NewRuntime(ctx, selected.Result.Config, selected.Path, nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config print-effective: %s\n", llm.RedactError(err, selected.Result.Config))
|
||||
if llm.IsAssetError(err) {
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
if input.View == "settings" {
|
||||
err = selected.Result.WriteEffective(stdout)
|
||||
} else {
|
||||
var output []byte
|
||||
if input.View == "profiles" {
|
||||
output, err = llmRuntime.SelectedProfilesYAML()
|
||||
} else {
|
||||
output, err = llm.ExplanationYAML(selected.Result)
|
||||
}
|
||||
if err == nil {
|
||||
_, err = stdout.Write(output)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "audita config print-effective: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func isHelpCommand(args []string) bool {
|
||||
if len(args) == 0 {
|
||||
return false
|
||||
}
|
||||
if len(args) == 1 {
|
||||
switch args[0] {
|
||||
case "help", "-h", "--help":
|
||||
return true
|
||||
}
|
||||
}
|
||||
if len(args) == 2 && args[0] == "help" {
|
||||
switch args[1] {
|
||||
case "process":
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func writeRootUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "Audita is a transcript processing CLI.")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Usage:")
|
||||
fmt.Fprintln(w, " audita <command> [options]")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Commands:")
|
||||
fmt.Fprintln(w, " process Process a transcript JSON file")
|
||||
fmt.Fprintln(w, " config Validate and inspect config")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Example:")
|
||||
fmt.Fprintln(w, " audita process transcript.json --glossary glossary.yaml --output corrected.json")
|
||||
}
|
||||
|
||||
func writeConfigUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "Validate and inspect Audita config.")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Usage:")
|
||||
fmt.Fprintln(w, " audita config <command> [flags]")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Commands:")
|
||||
fmt.Fprintln(w, " validate Validate a versioned YAML config file")
|
||||
fmt.Fprintln(w, " print-effective Print redacted effective settings YAML")
|
||||
}
|
||||
|
||||
func writeConfigValidateUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "Validate a versioned YAML config file.")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Usage:")
|
||||
fmt.Fprintln(w, " audita config validate --config <path> [--overlay <name>] [setting flags]")
|
||||
}
|
||||
|
||||
func writeConfigPrintEffectiveUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "Print redacted effective settings YAML.")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Usage:")
|
||||
fmt.Fprintln(w, " audita config print-effective [--config <path>] [--overlay <name>] [setting flags]")
|
||||
}
|
||||
|
||||
func writeProcessUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "Process a transcript JSON file.")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Usage:")
|
||||
fmt.Fprintln(w, " audita process <transcript.json> [flags]")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Flags:")
|
||||
for _, name := range []string{
|
||||
"config", "overlay", "glossary", "output",
|
||||
"proposal-profile", "validation-profile", "modules", "output-schema",
|
||||
"validation-max-prompt-tokens", "target-sections", "max-section-tokens", "min-section-tokens",
|
||||
"normalize-max-segment-gap", "normalize-ellipsis-gap", "normalize-max-segment-duration", "normalize-max-segment-tokens",
|
||||
"glossary-confidence-threshold", "homophones-confidence-threshold", "spoken-word-confidence-threshold", "grammar-confidence-threshold",
|
||||
"transcript-description", "work-dir",
|
||||
} {
|
||||
fmt.Fprintf(w, " --%s\n", name)
|
||||
}
|
||||
fmt.Fprintln(w, " --reporting[=true|false] Write the three-file report bundle (default true)")
|
||||
fmt.Fprintln(w, " --report-dir DIR Report directory for stdout output only; ignored with --output or --reporting=false")
|
||||
fmt.Fprintln(w, " --debug[=true|false] Persist detailed diagnostics (default false)")
|
||||
fmt.Fprintln(w)
|
||||
fmt.Fprintln(w, "Example:")
|
||||
fmt.Fprintln(w, " audita process transcript.json --glossary glossary.yaml --output corrected.json")
|
||||
}
|
||||
1
internal/cli/testdata/malformed_transcript.json
vendored
Normal file
1
internal/cli/testdata/malformed_transcript.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"segments":[{"id":1,"text":"oops"}
|
||||
6
internal/cli/testdata/tiny_glossary.yaml
vendored
Normal file
6
internal/cli/testdata/tiny_glossary.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
glossary:
|
||||
- name: Audita
|
||||
aliases:
|
||||
- audita
|
||||
category: product
|
||||
summary: The Audita transcript correction CLI.
|
||||
9
internal/cli/testdata/tiny_transcript.json
vendored
Normal file
9
internal/cli/testdata/tiny_transcript.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"speaker": "A",
|
||||
"start": 0.0,
|
||||
"end": 1.2,
|
||||
"text": "hello world"
|
||||
}
|
||||
]
|
||||
312
internal/core/chunking/sections.go
Normal file
312
internal/core/chunking/sections.go
Normal file
@@ -0,0 +1,312 @@
|
||||
package chunking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
// Section represents a contiguous chunk of transcript segments with metadata.
|
||||
type Section struct {
|
||||
// Index is the 0-based section index within the chunked transcript
|
||||
Index int `json:"section_index"`
|
||||
|
||||
// StartSegmentID is the ID of the first segment in this section
|
||||
StartSegmentID int `json:"start_segment_id"`
|
||||
|
||||
// EndSegmentID is the ID of the last segment in this section
|
||||
EndSegmentID int `json:"end_segment_id"`
|
||||
|
||||
// EstimatedTokens is the approximate token count for this section
|
||||
EstimatedTokens int `json:"estimated_tokens"`
|
||||
|
||||
// Segments contains the segments in this section, in order
|
||||
Segments []schema.Segment `json:"segments"`
|
||||
}
|
||||
|
||||
// ChunkingConfig holds configuration for transcript chunking.
|
||||
type ChunkingConfig struct {
|
||||
// MaxSectionTokens is the maximum allowed tokens per section
|
||||
MaxSectionTokens int
|
||||
|
||||
// MinSectionTokens is a validated soft lower-bound setting retained for
|
||||
// configuration/reporting compatibility.
|
||||
MinSectionTokens int
|
||||
|
||||
// TargetSections is an optional target number of sections
|
||||
// If nil, section count is derived from total/max token budgeting.
|
||||
TargetSections *int
|
||||
}
|
||||
|
||||
// Chunker performs deterministic chunking of normalized transcript segments.
|
||||
type Chunker struct {
|
||||
config ChunkingConfig
|
||||
estimator TokenEstimator
|
||||
}
|
||||
|
||||
// NewChunker creates a new chunker with the given configuration.
|
||||
func NewChunker(config ChunkingConfig) *Chunker {
|
||||
return &Chunker{
|
||||
config: config,
|
||||
estimator: NewSimpleTokenEstimator(),
|
||||
}
|
||||
}
|
||||
|
||||
// NewChunkerWithEstimator creates a new chunker with a custom estimator.
|
||||
func NewChunkerWithEstimator(config ChunkingConfig, estimator TokenEstimator) *Chunker {
|
||||
return &Chunker{
|
||||
config: config,
|
||||
estimator: estimator,
|
||||
}
|
||||
}
|
||||
|
||||
// ChunkTranscript divides a normalized transcript into contiguous token-bounded
|
||||
// sections using a deterministic balanced forward pass.
|
||||
//
|
||||
// Behavior:
|
||||
// - preserve segment order and never split segments;
|
||||
// - estimate per-segment tokens once, then compute total;
|
||||
// - derive desired section count from ceil(total/max_section_tokens), unless
|
||||
// target_sections is explicitly set;
|
||||
// - prefer section sizes near ceil(total/section_count) while never exceeding
|
||||
// max_section_tokens unless a section consists of a single oversized segment.
|
||||
//
|
||||
// Returns an error if explicit target_sections is impossible under constraints.
|
||||
// The input transcript is never mutated.
|
||||
func (c *Chunker) ChunkTranscript(transcript *schema.Transcript) ([]Section, error) {
|
||||
if transcript == nil || len(transcript.Segments) == 0 {
|
||||
return []Section{}, nil
|
||||
}
|
||||
|
||||
// Validate configuration
|
||||
if c.config.MaxSectionTokens <= 0 {
|
||||
return nil, fmt.Errorf("max_section_tokens must be positive, got %d", c.config.MaxSectionTokens)
|
||||
}
|
||||
|
||||
if c.config.MinSectionTokens < 0 {
|
||||
return nil, fmt.Errorf("min_section_tokens must be non-negative, got %d", c.config.MinSectionTokens)
|
||||
}
|
||||
|
||||
if c.config.MinSectionTokens > c.config.MaxSectionTokens {
|
||||
return nil, fmt.Errorf("min_section_tokens (%d) cannot exceed max_section_tokens (%d)",
|
||||
c.config.MinSectionTokens, c.config.MaxSectionTokens)
|
||||
}
|
||||
|
||||
// Calculate token counts for each segment (deterministic).
|
||||
segmentTokens := make([]int, len(transcript.Segments))
|
||||
totalTokens := 0
|
||||
for i, seg := range transcript.Segments {
|
||||
segmentTokens[i] = c.estimator.EstimateTokens(seg.Text)
|
||||
totalTokens += segmentTokens[i]
|
||||
}
|
||||
|
||||
minPossibleSections := c.calculateMinPossibleSections(segmentTokens)
|
||||
|
||||
var desiredSections int
|
||||
useExplicitTarget := false
|
||||
if c.config.TargetSections != nil {
|
||||
desiredSections = *c.config.TargetSections
|
||||
useExplicitTarget = true
|
||||
if desiredSections <= 0 {
|
||||
return nil, fmt.Errorf("target_sections must be positive, got %d", desiredSections)
|
||||
}
|
||||
if err := c.validateTargetSections(desiredSections, segmentTokens); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
desiredSections = ceilDiv(totalTokens, c.config.MaxSectionTokens)
|
||||
if desiredSections < minPossibleSections {
|
||||
desiredSections = minPossibleSections
|
||||
}
|
||||
if desiredSections < 1 {
|
||||
desiredSections = 1
|
||||
}
|
||||
if desiredSections > len(transcript.Segments) {
|
||||
desiredSections = len(transcript.Segments)
|
||||
}
|
||||
}
|
||||
|
||||
targetTokensPerSection := ceilDiv(totalTokens, desiredSections)
|
||||
if useExplicitTarget {
|
||||
return c.buildSectionsWithExplicitTarget(
|
||||
transcript.Segments,
|
||||
segmentTokens,
|
||||
desiredSections,
|
||||
targetTokensPerSection,
|
||||
)
|
||||
}
|
||||
|
||||
return c.buildSectionsBalanced(transcript.Segments, segmentTokens, targetTokensPerSection), nil
|
||||
}
|
||||
|
||||
// validateTargetSections checks if the target section count is achievable.
|
||||
func (c *Chunker) validateTargetSections(target int, segmentTokens []int) error {
|
||||
// Maximum possible sections: limited by segment count
|
||||
maxPossibleSections := len(segmentTokens)
|
||||
|
||||
if target > maxPossibleSections {
|
||||
return fmt.Errorf(
|
||||
"target_sections (%d) is impossible: cannot have more sections than segments (%d)",
|
||||
target, maxPossibleSections)
|
||||
}
|
||||
|
||||
// Minimum possible sections: each segment must fit within max bounds
|
||||
minPossibleSections := c.calculateMinPossibleSections(segmentTokens)
|
||||
|
||||
if target < minPossibleSections {
|
||||
return fmt.Errorf(
|
||||
"target_sections (%d) is impossible: need at least %d sections to respect max_section_tokens (%d)",
|
||||
target, minPossibleSections, c.config.MaxSectionTokens)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// buildSectionsBalanced creates sections with a deterministic single-pass policy.
|
||||
func (c *Chunker) buildSectionsBalanced(segments []schema.Segment, segmentTokens []int, targetTokensPerSection int) []Section {
|
||||
var sections []Section
|
||||
var currentSegments []schema.Segment
|
||||
currentTokens := 0
|
||||
|
||||
for i, seg := range segments {
|
||||
tokens := segmentTokens[i]
|
||||
|
||||
// Empty section: always accept the next segment, including oversized.
|
||||
if len(currentSegments) == 0 {
|
||||
currentSegments = append(currentSegments, seg)
|
||||
currentTokens = tokens
|
||||
continue
|
||||
}
|
||||
|
||||
// If adding next segment would exceed max, close current section.
|
||||
if currentTokens+tokens > c.config.MaxSectionTokens {
|
||||
sections = append(sections, c.buildSection(len(sections), currentSegments, currentTokens))
|
||||
currentSegments = []schema.Segment{seg}
|
||||
currentTokens = tokens
|
||||
continue
|
||||
}
|
||||
|
||||
// Prefer staying near target tokens per section.
|
||||
if targetTokensPerSection == 0 || currentTokens < targetTokensPerSection {
|
||||
currentSegments = append(currentSegments, seg)
|
||||
currentTokens += tokens
|
||||
continue
|
||||
}
|
||||
|
||||
sections = append(sections, c.buildSection(len(sections), currentSegments, currentTokens))
|
||||
currentSegments = []schema.Segment{seg}
|
||||
currentTokens = tokens
|
||||
}
|
||||
|
||||
if len(currentSegments) > 0 {
|
||||
sections = append(sections, c.buildSection(len(sections), currentSegments, currentTokens))
|
||||
}
|
||||
|
||||
return sections
|
||||
}
|
||||
|
||||
// buildSection creates a Section from segments.
|
||||
func (c *Chunker) buildSection(index int, segments []schema.Segment, tokens int) Section {
|
||||
return Section{
|
||||
Index: index,
|
||||
StartSegmentID: segments[0].ID,
|
||||
EndSegmentID: segments[len(segments)-1].ID,
|
||||
EstimatedTokens: tokens,
|
||||
Segments: segments,
|
||||
}
|
||||
}
|
||||
|
||||
// calculateMinPossibleSections calculates the minimum number of sections needed
|
||||
// to ensure no section exceeds max tokens.
|
||||
func (c *Chunker) calculateMinPossibleSections(segmentTokens []int) int {
|
||||
sections := 0
|
||||
currentTokens := 0
|
||||
|
||||
for _, tokens := range segmentTokens {
|
||||
if tokens > c.config.MaxSectionTokens {
|
||||
// Each oversized segment needs its own section
|
||||
if currentTokens > 0 {
|
||||
sections++
|
||||
currentTokens = 0
|
||||
}
|
||||
sections++
|
||||
} else if currentTokens+tokens > c.config.MaxSectionTokens {
|
||||
sections++
|
||||
currentTokens = tokens
|
||||
} else {
|
||||
currentTokens += tokens
|
||||
}
|
||||
}
|
||||
|
||||
if currentTokens > 0 {
|
||||
sections++
|
||||
}
|
||||
|
||||
return sections
|
||||
}
|
||||
|
||||
// buildSectionsWithExplicitTarget builds exactly desiredSections when feasible.
|
||||
func (c *Chunker) buildSectionsWithExplicitTarget(
|
||||
segments []schema.Segment,
|
||||
segmentTokens []int,
|
||||
desiredSections int,
|
||||
targetTokensPerSection int,
|
||||
) ([]Section, error) {
|
||||
n := len(segments)
|
||||
cursor := 0
|
||||
sections := make([]Section, 0, desiredSections)
|
||||
|
||||
for sectionIdx := 0; sectionIdx < desiredSections; sectionIdx++ {
|
||||
if cursor >= n {
|
||||
break
|
||||
}
|
||||
|
||||
remainingSectionsAfter := desiredSections - sectionIdx - 1
|
||||
currentSegments := []schema.Segment{segments[cursor]}
|
||||
currentTokens := segmentTokens[cursor]
|
||||
cursor++
|
||||
|
||||
for cursor < n {
|
||||
remainingSegments := n - cursor
|
||||
|
||||
// Reserve one segment per future section to avoid empty sections.
|
||||
if remainingSegments == remainingSectionsAfter {
|
||||
break
|
||||
}
|
||||
|
||||
nextTokens := segmentTokens[cursor]
|
||||
if currentTokens+nextTokens > c.config.MaxSectionTokens {
|
||||
break
|
||||
}
|
||||
if targetTokensPerSection == 0 || currentTokens < targetTokensPerSection {
|
||||
currentSegments = append(currentSegments, segments[cursor])
|
||||
currentTokens += nextTokens
|
||||
cursor++
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
sections = append(sections, c.buildSection(len(sections), currentSegments, currentTokens))
|
||||
}
|
||||
|
||||
if cursor != n || len(sections) != desiredSections {
|
||||
return nil, fmt.Errorf(
|
||||
"target_sections (%d) is impossible under current constraints (got %d sections)",
|
||||
desiredSections,
|
||||
len(sections),
|
||||
)
|
||||
}
|
||||
|
||||
return sections, nil
|
||||
}
|
||||
|
||||
func ceilDiv(numerator int, denominator int) int {
|
||||
if denominator <= 0 {
|
||||
return 0
|
||||
}
|
||||
if numerator <= 0 {
|
||||
return 0
|
||||
}
|
||||
return (numerator + denominator - 1) / denominator
|
||||
}
|
||||
518
internal/core/chunking/sections_test.go
Normal file
518
internal/core/chunking/sections_test.go
Normal file
@@ -0,0 +1,518 @@
|
||||
package chunking
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
// mapTokenEstimator provides deterministic per-segment token counts for tests.
|
||||
type mapTokenEstimator struct {
|
||||
byText map[string]int
|
||||
}
|
||||
|
||||
func (e *mapTokenEstimator) EstimateTokens(text string) int {
|
||||
if e.byText == nil {
|
||||
return 0
|
||||
}
|
||||
if tokens, ok := e.byText[text]; ok {
|
||||
return tokens
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func makeSegments(texts []string) []schema.Segment {
|
||||
segments := make([]schema.Segment, len(texts))
|
||||
for i, text := range texts {
|
||||
segments[i] = schema.Segment{
|
||||
ID: i + 1,
|
||||
Speaker: "DM",
|
||||
Start: float64(i * 10),
|
||||
End: float64(i*10 + 5),
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
return segments
|
||||
}
|
||||
|
||||
func makeTranscript(segments []schema.Segment) *schema.Transcript {
|
||||
return &schema.Transcript{Segments: segments}
|
||||
}
|
||||
|
||||
func intPtr(i int) *int {
|
||||
return &i
|
||||
}
|
||||
|
||||
func assertSegmentCoverageAndOrder(t *testing.T, input []schema.Segment, sections []Section) {
|
||||
t.Helper()
|
||||
|
||||
seen := make([]schema.Segment, 0, len(input))
|
||||
for _, sec := range sections {
|
||||
seen = append(seen, sec.Segments...)
|
||||
}
|
||||
|
||||
if len(seen) != len(input) {
|
||||
t.Fatalf("expected %d total segment occurrences, got %d", len(input), len(seen))
|
||||
}
|
||||
|
||||
for i := range input {
|
||||
if seen[i].ID != input[i].ID {
|
||||
t.Fatalf("segment order mismatch at index %d: got id=%d want id=%d", i, seen[i].ID, input[i].ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertSectionMetadataConsistent(t *testing.T, sections []Section) {
|
||||
t.Helper()
|
||||
|
||||
for i, sec := range sections {
|
||||
if sec.Index != i {
|
||||
t.Fatalf("section %d: expected index=%d got=%d", i, i, sec.Index)
|
||||
}
|
||||
if len(sec.Segments) == 0 {
|
||||
t.Fatalf("section %d: section must not be empty", i)
|
||||
}
|
||||
if sec.StartSegmentID != sec.Segments[0].ID {
|
||||
t.Fatalf("section %d: start_segment_id mismatch", i)
|
||||
}
|
||||
if sec.EndSegmentID != sec.Segments[len(sec.Segments)-1].ID {
|
||||
t.Fatalf("section %d: end_segment_id mismatch", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertMaxBoundExceptSingletonOversized(t *testing.T, sections []Section, max int) {
|
||||
t.Helper()
|
||||
|
||||
for i, sec := range sections {
|
||||
if sec.EstimatedTokens <= max {
|
||||
continue
|
||||
}
|
||||
if len(sec.Segments) != 1 {
|
||||
t.Fatalf("section %d exceeds max tokens (%d>%d) with %d segments", i, sec.EstimatedTokens, max, len(sec.Segments))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func imbalance(sections []Section) int {
|
||||
if len(sections) == 0 {
|
||||
return 0
|
||||
}
|
||||
minTokens := sections[0].EstimatedTokens
|
||||
maxTokens := sections[0].EstimatedTokens
|
||||
for _, sec := range sections {
|
||||
if sec.EstimatedTokens < minTokens {
|
||||
minTokens = sec.EstimatedTokens
|
||||
}
|
||||
if sec.EstimatedTokens > maxTokens {
|
||||
maxTokens = sec.EstimatedTokens
|
||||
}
|
||||
}
|
||||
return maxTokens - minTokens
|
||||
}
|
||||
|
||||
func greedyMaxFillSections(segments []schema.Segment, tokens []int, max int) []Section {
|
||||
sections := make([]Section, 0)
|
||||
var current []schema.Segment
|
||||
currentTokens := 0
|
||||
|
||||
for i, seg := range segments {
|
||||
tok := tokens[i]
|
||||
if len(current) == 0 {
|
||||
current = append(current, seg)
|
||||
currentTokens = tok
|
||||
continue
|
||||
}
|
||||
if currentTokens+tok > max {
|
||||
sections = append(sections, Section{
|
||||
Index: len(sections),
|
||||
StartSegmentID: current[0].ID,
|
||||
EndSegmentID: current[len(current)-1].ID,
|
||||
EstimatedTokens: currentTokens,
|
||||
Segments: append([]schema.Segment(nil), current...),
|
||||
})
|
||||
current = []schema.Segment{seg}
|
||||
currentTokens = tok
|
||||
continue
|
||||
}
|
||||
current = append(current, seg)
|
||||
currentTokens += tok
|
||||
}
|
||||
|
||||
if len(current) > 0 {
|
||||
sections = append(sections, Section{
|
||||
Index: len(sections),
|
||||
StartSegmentID: current[0].ID,
|
||||
EndSegmentID: current[len(current)-1].ID,
|
||||
EstimatedTokens: currentTokens,
|
||||
Segments: append([]schema.Segment(nil), current...),
|
||||
})
|
||||
}
|
||||
|
||||
return sections
|
||||
}
|
||||
|
||||
func TestChunkEmptyTranscript(t *testing.T) {
|
||||
chunker := NewChunker(ChunkingConfig{MaxSectionTokens: 100, MinSectionTokens: 10})
|
||||
|
||||
sections, err := chunker.ChunkTranscript(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript(nil): %v", err)
|
||||
}
|
||||
if len(sections) != 0 {
|
||||
t.Fatalf("expected 0 sections for nil transcript, got %d", len(sections))
|
||||
}
|
||||
|
||||
sections, err = chunker.ChunkTranscript(makeTranscript(nil))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript(empty): %v", err)
|
||||
}
|
||||
if len(sections) != 0 {
|
||||
t.Fatalf("expected 0 sections for empty transcript, got %d", len(sections))
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkSingleSegment(t *testing.T) {
|
||||
segments := makeSegments([]string{"s1"})
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 100, MinSectionTokens: 10},
|
||||
&mapTokenEstimator{byText: map[string]int{"s1": 7}},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 1 {
|
||||
t.Fatalf("expected 1 section, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 7 {
|
||||
t.Fatalf("expected estimated_tokens=7, got %d", sections[0].EstimatedTokens)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertSectionMetadataConsistent(t, sections)
|
||||
}
|
||||
|
||||
func TestChunkSingleOversizedSegment(t *testing.T) {
|
||||
segments := makeSegments([]string{"big"})
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 50, MinSectionTokens: 5},
|
||||
&mapTokenEstimator{byText: map[string]int{"big": 120}},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 1 {
|
||||
t.Fatalf("expected 1 section, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 120 {
|
||||
t.Fatalf("expected oversized singleton section, got %d", sections[0].EstimatedTokens)
|
||||
}
|
||||
assertMaxBoundExceptSingletonOversized(t, sections, 50)
|
||||
}
|
||||
|
||||
func TestChunkTotalBelowMaxSingleSection(t *testing.T) {
|
||||
segments := makeSegments([]string{"a", "b", "c"})
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 50, MinSectionTokens: 5},
|
||||
&ConstTokenEstimator{Tokens: 10},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 1 {
|
||||
t.Fatalf("expected 1 section, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 30 {
|
||||
t.Fatalf("expected 30 section tokens, got %d", sections[0].EstimatedTokens)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
}
|
||||
|
||||
func TestChunkTotalExactlyDivisibleByMax(t *testing.T) {
|
||||
segments := makeSegments([]string{"a", "b", "c", "d"})
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: 1},
|
||||
&ConstTokenEstimator{Tokens: 5},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 2 {
|
||||
t.Fatalf("expected 2 sections, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 10 || sections[1].EstimatedTokens != 10 {
|
||||
t.Fatalf("expected [10,10] tokens, got [%d,%d]", sections[0].EstimatedTokens, sections[1].EstimatedTokens)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertMaxBoundExceptSingletonOversized(t, sections, 10)
|
||||
}
|
||||
|
||||
func TestChunkTotalNotDivisibleByMax(t *testing.T) {
|
||||
segments := makeSegments([]string{"a", "b", "c", "d", "e"})
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: 1},
|
||||
&ConstTokenEstimator{Tokens: 5},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 3 {
|
||||
t.Fatalf("expected 3 sections, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 10 || sections[1].EstimatedTokens != 10 || sections[2].EstimatedTokens != 5 {
|
||||
t.Fatalf("expected [10,10,5] tokens, got [%d,%d,%d]", sections[0].EstimatedTokens, sections[1].EstimatedTokens, sections[2].EstimatedTokens)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertMaxBoundExceptSingletonOversized(t, sections, 10)
|
||||
}
|
||||
|
||||
func TestChunkTargetSectionsPrecedenceAndSuccess(t *testing.T) {
|
||||
segments := makeSegments([]string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"})
|
||||
target := 3
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 200, MinSectionTokens: 1, TargetSections: &target},
|
||||
&ConstTokenEstimator{Tokens: 10},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != target {
|
||||
t.Fatalf("expected %d sections from explicit target, got %d", target, len(sections))
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertSectionMetadataConsistent(t, sections)
|
||||
}
|
||||
|
||||
func TestChunkTargetSectionsImpossibleTooMany(t *testing.T) {
|
||||
segments := makeSegments([]string{"1", "2", "3", "4", "5"})
|
||||
target := 10
|
||||
chunker := NewChunker(ChunkingConfig{MaxSectionTokens: 100, MinSectionTokens: 1, TargetSections: &target})
|
||||
|
||||
_, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err == nil {
|
||||
t.Fatal("expected error for impossible target_sections")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "cannot have more sections than segments") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkTargetSectionsImpossibleTooFew(t *testing.T) {
|
||||
segments := makeSegments([]string{"1", "2", "3"})
|
||||
target := 1
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 50, MinSectionTokens: 1, TargetSections: &target},
|
||||
&ConstTokenEstimator{Tokens: 30},
|
||||
)
|
||||
|
||||
_, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err == nil {
|
||||
t.Fatal("expected error for impossible target_sections")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "need at least 3 sections") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkManySmallSegmentsBalanced(t *testing.T) {
|
||||
texts := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}
|
||||
segments := makeSegments(texts)
|
||||
chunker := NewChunkerWithEstimator(
|
||||
ChunkingConfig{MaxSectionTokens: 50, MinSectionTokens: 1},
|
||||
&ConstTokenEstimator{Tokens: 10},
|
||||
)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 3 {
|
||||
t.Fatalf("expected 3 sections, got %d", len(sections))
|
||||
}
|
||||
if sections[0].EstimatedTokens != 40 || sections[1].EstimatedTokens != 40 || sections[2].EstimatedTokens != 30 {
|
||||
t.Fatalf("expected [40,40,30], got [%d,%d,%d]", sections[0].EstimatedTokens, sections[1].EstimatedTokens, sections[2].EstimatedTokens)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertMaxBoundExceptSingletonOversized(t, sections, 50)
|
||||
}
|
||||
|
||||
func TestChunkMixedLargeAndSmallSegments(t *testing.T) {
|
||||
segments := makeSegments([]string{"big1", "s1", "s2", "s3", "big2", "s4"})
|
||||
estimator := &mapTokenEstimator{byText: map[string]int{
|
||||
"big1": 120,
|
||||
"s1": 10,
|
||||
"s2": 10,
|
||||
"s3": 10,
|
||||
"big2": 120,
|
||||
"s4": 10,
|
||||
}}
|
||||
chunker := NewChunkerWithEstimator(ChunkingConfig{MaxSectionTokens: 100, MinSectionTokens: 1}, estimator)
|
||||
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
if len(sections) != 4 {
|
||||
t.Fatalf("expected 4 sections, got %d", len(sections))
|
||||
}
|
||||
if len(sections[0].Segments) != 1 || sections[0].Segments[0].Text != "big1" {
|
||||
t.Fatalf("expected first oversized segment in singleton section, got %+v", sections[0].Segments)
|
||||
}
|
||||
if len(sections[2].Segments) != 1 || sections[2].Segments[0].Text != "big2" {
|
||||
t.Fatalf("expected second oversized segment in singleton section, got %+v", sections[2].Segments)
|
||||
}
|
||||
assertSegmentCoverageAndOrder(t, segments, sections)
|
||||
assertMaxBoundExceptSingletonOversized(t, sections, 100)
|
||||
}
|
||||
|
||||
func TestChunkDeterministicOrdering(t *testing.T) {
|
||||
segments := makeSegments([]string{"a", "b", "c", "d", "e", "f"})
|
||||
chunkerCfg := ChunkingConfig{MaxSectionTokens: 15, MinSectionTokens: 1}
|
||||
estimator := &ConstTokenEstimator{Tokens: 5}
|
||||
|
||||
var first []Section
|
||||
for i := 0; i < 5; i++ {
|
||||
chunker := NewChunkerWithEstimator(chunkerCfg, estimator)
|
||||
sections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("iteration %d: %v", i, err)
|
||||
}
|
||||
if i == 0 {
|
||||
first = sections
|
||||
continue
|
||||
}
|
||||
if len(sections) != len(first) {
|
||||
t.Fatalf("iteration %d: section count mismatch (%d vs %d)", i, len(sections), len(first))
|
||||
}
|
||||
for j := range sections {
|
||||
if sections[j].Index != first[j].Index ||
|
||||
sections[j].StartSegmentID != first[j].StartSegmentID ||
|
||||
sections[j].EndSegmentID != first[j].EndSegmentID ||
|
||||
sections[j].EstimatedTokens != first[j].EstimatedTokens ||
|
||||
len(sections[j].Segments) != len(first[j].Segments) {
|
||||
t.Fatalf("iteration %d section %d mismatch", i, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkNoMutationOfInput(t *testing.T) {
|
||||
segments := makeSegments([]string{"original one", "original two"})
|
||||
transcript := makeTranscript(segments)
|
||||
original := make([]string, len(transcript.Segments))
|
||||
for i := range transcript.Segments {
|
||||
original[i] = transcript.Segments[i].Text
|
||||
}
|
||||
|
||||
chunker := NewChunker(ChunkingConfig{MaxSectionTokens: 50, MinSectionTokens: 1})
|
||||
if _, err := chunker.ChunkTranscript(transcript); err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
for i := range transcript.Segments {
|
||||
if transcript.Segments[i].Text != original[i] {
|
||||
t.Fatalf("segment %d mutated", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkConfigValidation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config ChunkingConfig
|
||||
errContains string
|
||||
}{
|
||||
{
|
||||
name: "zero max tokens",
|
||||
config: ChunkingConfig{MaxSectionTokens: 0, MinSectionTokens: 1},
|
||||
errContains: "max_section_tokens must be positive",
|
||||
},
|
||||
{
|
||||
name: "negative max tokens",
|
||||
config: ChunkingConfig{MaxSectionTokens: -1, MinSectionTokens: 1},
|
||||
errContains: "max_section_tokens must be positive",
|
||||
},
|
||||
{
|
||||
name: "negative min tokens",
|
||||
config: ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: -1},
|
||||
errContains: "min_section_tokens must be non-negative",
|
||||
},
|
||||
{
|
||||
name: "min exceeds max",
|
||||
config: ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: 11},
|
||||
errContains: "min_section_tokens (11) cannot exceed max_section_tokens (10)",
|
||||
},
|
||||
{
|
||||
name: "zero target sections",
|
||||
config: ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: 1, TargetSections: intPtr(0)},
|
||||
errContains: "target_sections must be positive",
|
||||
},
|
||||
{
|
||||
name: "negative target sections",
|
||||
config: ChunkingConfig{MaxSectionTokens: 10, MinSectionTokens: 1, TargetSections: intPtr(-1)},
|
||||
errContains: "target_sections must be positive",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
chunker := NewChunker(tt.config)
|
||||
_, err := chunker.ChunkTranscript(makeTranscript(makeSegments([]string{"x"})))
|
||||
if err == nil {
|
||||
t.Fatalf("expected error containing %q", tt.errContains)
|
||||
}
|
||||
if !strings.Contains(err.Error(), tt.errContains) {
|
||||
t.Fatalf("expected error containing %q, got %q", tt.errContains, err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkBalancedAlgorithmBeatsGreedyMaxFillOnUnevenTranscript(t *testing.T) {
|
||||
segments := makeSegments([]string{"s1", "s2", "s3", "s4", "s5", "s6"})
|
||||
tokenMap := map[string]int{
|
||||
"s1": 50,
|
||||
"s2": 10,
|
||||
"s3": 10,
|
||||
"s4": 10,
|
||||
"s5": 10,
|
||||
"s6": 10,
|
||||
}
|
||||
estimator := &mapTokenEstimator{byText: tokenMap}
|
||||
chunker := NewChunkerWithEstimator(ChunkingConfig{MaxSectionTokens: 80, MinSectionTokens: 1}, estimator)
|
||||
|
||||
balancedSections, err := chunker.ChunkTranscript(makeTranscript(segments))
|
||||
if err != nil {
|
||||
t.Fatalf("ChunkTranscript: %v", err)
|
||||
}
|
||||
|
||||
tokens := make([]int, 0, len(segments))
|
||||
for _, seg := range segments {
|
||||
tokens = append(tokens, tokenMap[seg.Text])
|
||||
}
|
||||
greedySections := greedyMaxFillSections(segments, tokens, 80)
|
||||
|
||||
balancedImbalance := imbalance(balancedSections)
|
||||
greedyImbalance := imbalance(greedySections)
|
||||
if balancedImbalance >= greedyImbalance {
|
||||
t.Fatalf(
|
||||
"expected balanced chunking to improve over greedy max-fill; balanced=%d greedy=%d",
|
||||
balancedImbalance,
|
||||
greedyImbalance,
|
||||
)
|
||||
}
|
||||
|
||||
assertSegmentCoverageAndOrder(t, segments, balancedSections)
|
||||
assertMaxBoundExceptSingletonOversized(t, balancedSections, 80)
|
||||
}
|
||||
84
internal/core/chunking/summary.go
Normal file
84
internal/core/chunking/summary.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package chunking
|
||||
|
||||
// Summary provides a concise overview of chunking results for reports
|
||||
type Summary struct {
|
||||
ChunkCount int `json:"chunk_count"`
|
||||
MinEstimatedTokens int `json:"min_estimated_chunk_tokens"`
|
||||
MaxEstimatedTokens int `json:"max_estimated_chunk_tokens"`
|
||||
TotalEstimatedTokens int `json:"total_estimated_transcript_tokens"`
|
||||
TargetSections *int `json:"target_sections,omitempty"`
|
||||
MaxSectionTokens int `json:"max_section_tokens"`
|
||||
MinSectionTokens int `json:"min_section_tokens"`
|
||||
}
|
||||
|
||||
// ChunkSummary represents a single chunk's metadata for diagnostics
|
||||
type ChunkSummary struct {
|
||||
Index int `json:"index"`
|
||||
StartSegmentID int `json:"start_segment_id"`
|
||||
EndSegmentID int `json:"end_segment_id"`
|
||||
EstimatedTokens int `json:"estimated_tokens"`
|
||||
SegmentCount int `json:"segment_count"`
|
||||
}
|
||||
|
||||
// DetailedSummary provides per-chunk details for diagnostics
|
||||
type DetailedSummary struct {
|
||||
Summary `json:",inline"`
|
||||
Chunks []ChunkSummary `json:"chunks"`
|
||||
}
|
||||
|
||||
// ComputeSummary creates a Summary from sections and config
|
||||
func ComputeSummary(sections []Section, config ChunkingConfig) Summary {
|
||||
if len(sections) == 0 {
|
||||
return Summary{
|
||||
ChunkCount: 0,
|
||||
MaxSectionTokens: config.MaxSectionTokens,
|
||||
MinSectionTokens: config.MinSectionTokens,
|
||||
TargetSections: config.TargetSections,
|
||||
}
|
||||
}
|
||||
|
||||
minTokens := sections[0].EstimatedTokens
|
||||
maxTokens := sections[0].EstimatedTokens
|
||||
totalTokens := 0
|
||||
|
||||
for _, sec := range sections {
|
||||
if sec.EstimatedTokens < minTokens {
|
||||
minTokens = sec.EstimatedTokens
|
||||
}
|
||||
if sec.EstimatedTokens > maxTokens {
|
||||
maxTokens = sec.EstimatedTokens
|
||||
}
|
||||
totalTokens += sec.EstimatedTokens
|
||||
}
|
||||
|
||||
return Summary{
|
||||
ChunkCount: len(sections),
|
||||
MinEstimatedTokens: minTokens,
|
||||
MaxEstimatedTokens: maxTokens,
|
||||
TotalEstimatedTokens: totalTokens,
|
||||
TargetSections: config.TargetSections,
|
||||
MaxSectionTokens: config.MaxSectionTokens,
|
||||
MinSectionTokens: config.MinSectionTokens,
|
||||
}
|
||||
}
|
||||
|
||||
// ComputeDetailedSummary creates a DetailedSummary from sections and config
|
||||
func ComputeDetailedSummary(sections []Section, config ChunkingConfig) DetailedSummary {
|
||||
summary := ComputeSummary(sections, config)
|
||||
|
||||
chunks := make([]ChunkSummary, len(sections))
|
||||
for i, sec := range sections {
|
||||
chunks[i] = ChunkSummary{
|
||||
Index: sec.Index,
|
||||
StartSegmentID: sec.StartSegmentID,
|
||||
EndSegmentID: sec.EndSegmentID,
|
||||
EstimatedTokens: sec.EstimatedTokens,
|
||||
SegmentCount: len(sec.Segments),
|
||||
}
|
||||
}
|
||||
|
||||
return DetailedSummary{
|
||||
Summary: summary,
|
||||
Chunks: chunks,
|
||||
}
|
||||
}
|
||||
148
internal/core/chunking/summary_test.go
Normal file
148
internal/core/chunking/summary_test.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package chunking
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
func TestComputeSummary(t *testing.T) {
|
||||
config := ChunkingConfig{
|
||||
MaxSectionTokens: 100,
|
||||
MinSectionTokens: 10,
|
||||
}
|
||||
|
||||
sections := []Section{
|
||||
{Index: 0, EstimatedTokens: 30, StartSegmentID: 1, EndSegmentID: 2},
|
||||
{Index: 1, EstimatedTokens: 50, StartSegmentID: 3, EndSegmentID: 4},
|
||||
{Index: 2, EstimatedTokens: 20, StartSegmentID: 5, EndSegmentID: 5},
|
||||
}
|
||||
|
||||
summary := ComputeSummary(sections, config)
|
||||
|
||||
if summary.ChunkCount != 3 {
|
||||
t.Errorf("expected chunk_count=3, got %d", summary.ChunkCount)
|
||||
}
|
||||
if summary.MinEstimatedTokens != 20 {
|
||||
t.Errorf("expected min_estimated_tokens=20, got %d", summary.MinEstimatedTokens)
|
||||
}
|
||||
if summary.MaxEstimatedTokens != 50 {
|
||||
t.Errorf("expected max_estimated_tokens=50, got %d", summary.MaxEstimatedTokens)
|
||||
}
|
||||
if summary.TotalEstimatedTokens != 100 {
|
||||
t.Errorf("expected total_estimated_tokens=100, got %d", summary.TotalEstimatedTokens)
|
||||
}
|
||||
if summary.MaxSectionTokens != 100 {
|
||||
t.Errorf("expected max_section_tokens=100, got %d", summary.MaxSectionTokens)
|
||||
}
|
||||
if summary.MinSectionTokens != 10 {
|
||||
t.Errorf("expected min_section_tokens=10, got %d", summary.MinSectionTokens)
|
||||
}
|
||||
if summary.TargetSections != nil {
|
||||
t.Errorf("expected target_sections=nil, got %v", summary.TargetSections)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeSummaryWithTarget(t *testing.T) {
|
||||
target := 5
|
||||
config := ChunkingConfig{
|
||||
MaxSectionTokens: 100,
|
||||
MinSectionTokens: 10,
|
||||
TargetSections: &target,
|
||||
}
|
||||
|
||||
sections := []Section{
|
||||
{Index: 0, EstimatedTokens: 30, StartSegmentID: 1, EndSegmentID: 2},
|
||||
}
|
||||
|
||||
summary := ComputeSummary(sections, config)
|
||||
|
||||
if summary.TargetSections == nil || *summary.TargetSections != 5 {
|
||||
t.Errorf("expected target_sections=5, got %v", summary.TargetSections)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeSummaryEmptySections(t *testing.T) {
|
||||
config := ChunkingConfig{
|
||||
MaxSectionTokens: 100,
|
||||
MinSectionTokens: 10,
|
||||
}
|
||||
|
||||
sections := []Section{}
|
||||
|
||||
summary := ComputeSummary(sections, config)
|
||||
|
||||
if summary.ChunkCount != 0 {
|
||||
t.Errorf("expected chunk_count=0, got %d", summary.ChunkCount)
|
||||
}
|
||||
if summary.MinEstimatedTokens != 0 {
|
||||
t.Errorf("expected min_estimated_tokens=0 for empty, got %d", summary.MinEstimatedTokens)
|
||||
}
|
||||
if summary.MaxSectionTokens != 100 {
|
||||
t.Errorf("expected max_section_tokens preserved, got %d", summary.MaxSectionTokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeDetailedSummary(t *testing.T) {
|
||||
config := ChunkingConfig{
|
||||
MaxSectionTokens: 100,
|
||||
MinSectionTokens: 10,
|
||||
}
|
||||
|
||||
sections := []Section{
|
||||
{
|
||||
Index: 0,
|
||||
EstimatedTokens: 30,
|
||||
StartSegmentID: 1,
|
||||
EndSegmentID: 2,
|
||||
Segments: make([]schema.Segment, 2), // 2 segments
|
||||
},
|
||||
{
|
||||
Index: 1,
|
||||
EstimatedTokens: 50,
|
||||
StartSegmentID: 3,
|
||||
EndSegmentID: 5,
|
||||
Segments: make([]schema.Segment, 3), // 3 segments
|
||||
},
|
||||
}
|
||||
|
||||
detailed := ComputeDetailedSummary(sections, config)
|
||||
|
||||
if detailed.ChunkCount != 2 {
|
||||
t.Errorf("expected chunk_count=2, got %d", detailed.ChunkCount)
|
||||
}
|
||||
if len(detailed.Chunks) != 2 {
|
||||
t.Fatalf("expected 2 chunk entries, got %d", len(detailed.Chunks))
|
||||
}
|
||||
|
||||
// Check first chunk
|
||||
if detailed.Chunks[0].Index != 0 {
|
||||
t.Errorf("expected chunk[0].index=0, got %d", detailed.Chunks[0].Index)
|
||||
}
|
||||
if detailed.Chunks[0].StartSegmentID != 1 {
|
||||
t.Errorf("expected chunk[0].start_segment_id=1, got %d", detailed.Chunks[0].StartSegmentID)
|
||||
}
|
||||
if detailed.Chunks[0].EndSegmentID != 2 {
|
||||
t.Errorf("expected chunk[0].end_segment_id=2, got %d", detailed.Chunks[0].EndSegmentID)
|
||||
}
|
||||
if detailed.Chunks[0].EstimatedTokens != 30 {
|
||||
t.Errorf("expected chunk[0].estimated_tokens=30, got %d", detailed.Chunks[0].EstimatedTokens)
|
||||
}
|
||||
if detailed.Chunks[0].SegmentCount != 2 {
|
||||
t.Errorf("expected chunk[0].segment_count=2, got %d", detailed.Chunks[0].SegmentCount)
|
||||
}
|
||||
|
||||
// Check second chunk
|
||||
if detailed.Chunks[1].Index != 1 {
|
||||
t.Errorf("expected chunk[1].index=1, got %d", detailed.Chunks[1].Index)
|
||||
}
|
||||
if detailed.Chunks[1].StartSegmentID != 3 {
|
||||
t.Errorf("expected chunk[1].start_segment_id=3, got %d", detailed.Chunks[1].StartSegmentID)
|
||||
}
|
||||
if detailed.Chunks[1].EndSegmentID != 5 {
|
||||
t.Errorf("expected chunk[1].end_segment_id=5, got %d", detailed.Chunks[1].EndSegmentID)
|
||||
}
|
||||
if detailed.Chunks[1].SegmentCount != 3 {
|
||||
t.Errorf("expected chunk[1].segment_count=3, got %d", detailed.Chunks[1].SegmentCount)
|
||||
}
|
||||
}
|
||||
55
internal/core/chunking/tokens.go
Normal file
55
internal/core/chunking/tokens.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package chunking
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// TokenEstimator provides a deterministic token estimation suitable for prompt budgeting.
|
||||
// The estimator is approximate but stable, isolated, and replaceable.
|
||||
type TokenEstimator interface {
|
||||
EstimateTokens(text string) int
|
||||
}
|
||||
|
||||
// SimpleTokenEstimator provides a basic deterministic token estimation.
|
||||
// This uses a simple heuristic based on word count and punctuation.
|
||||
type SimpleTokenEstimator struct{}
|
||||
|
||||
// NewSimpleTokenEstimator creates a new simple token estimator.
|
||||
func NewSimpleTokenEstimator() *SimpleTokenEstimator {
|
||||
return &SimpleTokenEstimator{}
|
||||
}
|
||||
|
||||
// EstimateTokens provides a rough estimate of the number of tokens in the given text.
|
||||
// This implementation uses a simple heuristic: count words and punctuation as tokens.
|
||||
// The estimate is deterministic and stable for the same input text.
|
||||
func (e *SimpleTokenEstimator) EstimateTokens(text string) int {
|
||||
if text == "" {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Simple heuristic: split on whitespace and count non-empty segments
|
||||
words := strings.Fields(text)
|
||||
tokenCount := len(words)
|
||||
|
||||
// Add some estimate for punctuation that might be separate tokens
|
||||
punctuationCount := 0
|
||||
for _, r := range text {
|
||||
if unicode.IsPunct(r) && r != '\'' && r != '-' && r != '_' {
|
||||
punctuationCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Rough estimate: each word is a token, plus half the punctuation as separate tokens
|
||||
return tokenCount + (punctuationCount / 2)
|
||||
}
|
||||
|
||||
// ConstTokenEstimator returns a constant token count for testing purposes.
|
||||
type ConstTokenEstimator struct {
|
||||
Tokens int
|
||||
}
|
||||
|
||||
// EstimateTokens returns the configured constant token count.
|
||||
func (e *ConstTokenEstimator) EstimateTokens(text string) int {
|
||||
return e.Tokens
|
||||
}
|
||||
59
internal/core/chunking/tokens_test.go
Normal file
59
internal/core/chunking/tokens_test.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package chunking
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSimpleTokenEstimator(t *testing.T) {
|
||||
estimator := NewSimpleTokenEstimator()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
text string
|
||||
expected int
|
||||
}{
|
||||
{"empty string", "", 0},
|
||||
{"single word", "hello", 1},
|
||||
{"two words", "hello world", 2},
|
||||
{"with punctuation", "hello, world!", 3}, // 2 words + 2 punctuation/2 = 3
|
||||
{"multiple sentences", "Hello world. This is a test.", 7}, // 7 words + 2 punctuation/2 = 8? Actually "Hello world." has 3 punctuation
|
||||
{"with apostrophes", "don't won't can't", 3},
|
||||
{"with hyphens", "well-known state-of-the-art", 2}, // hyphens don't count
|
||||
{"unicode text", "café naïve", 2},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := estimator.EstimateTokens(tt.text)
|
||||
if got != tt.expected {
|
||||
t.Errorf("EstimateTokens(%q) = %d, want %d", tt.text, got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstTokenEstimator(t *testing.T) {
|
||||
estimator := &ConstTokenEstimator{Tokens: 42}
|
||||
|
||||
if got := estimator.EstimateTokens("any text"); got != 42 {
|
||||
t.Errorf("ConstTokenEstimator.EstimateTokens = %d, want 42", got)
|
||||
}
|
||||
|
||||
if got := estimator.EstimateTokens(""); got != 42 {
|
||||
t.Errorf("ConstTokenEstimator.EstimateTokens(empty) = %d, want 42", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenEstimatorDeterminism(t *testing.T) {
|
||||
estimator := NewSimpleTokenEstimator()
|
||||
text := "The quick brown fox jumps over the lazy dog. Hello, world!"
|
||||
|
||||
// Run multiple times and verify same result
|
||||
first := estimator.EstimateTokens(text)
|
||||
for i := 0; i < 10; i++ {
|
||||
got := estimator.EstimateTokens(text)
|
||||
if got != first {
|
||||
t.Errorf("EstimateTokens not deterministic: iteration %d got %d, first was %d", i, got, first)
|
||||
}
|
||||
}
|
||||
}
|
||||
189
internal/core/config/config.go
Normal file
189
internal/core/config/config.go
Normal file
@@ -0,0 +1,189 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/modulecatalog"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/outputschema"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultModulesCSV = "glossary,homophones,glossary,spoken_word,grammar"
|
||||
DefaultTranscriptDescriptionMaxChars = 500
|
||||
DefaultValidationMaxPromptTokens = 2048
|
||||
)
|
||||
|
||||
// Config is the version-2 application configuration. Invocation paths are not settings.
|
||||
type Config struct {
|
||||
Version int `yaml:"version"`
|
||||
ProfilesDir string `yaml:"profiles_dir"`
|
||||
Backends map[string]Backend `yaml:"backends"`
|
||||
LLM LLM `yaml:"llm"`
|
||||
Pipeline Pipeline `yaml:"pipeline"`
|
||||
Output Output `yaml:"output"`
|
||||
Validation Validation `yaml:"validation"`
|
||||
Chunking Chunking `yaml:"chunking"`
|
||||
Normalization Normalization `yaml:"normalization"`
|
||||
Thresholds Thresholds `yaml:"thresholds"`
|
||||
Context Context `yaml:"context"`
|
||||
Reporting Reporting `yaml:"reporting"`
|
||||
Diagnostics Diagnostics `yaml:"diagnostics"`
|
||||
}
|
||||
|
||||
type Backend struct {
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
Concurrency int `yaml:"concurrency"`
|
||||
QueueCapacity int `yaml:"queue_capacity"`
|
||||
Credential *ck.Secret `yaml:"credential"`
|
||||
}
|
||||
type LLM struct {
|
||||
ProposalProfile string `yaml:"proposal_profile"`
|
||||
ValidationProfile string `yaml:"validation_profile"`
|
||||
TransientRetries int `yaml:"transient_retries"`
|
||||
RepairAttempts int `yaml:"repair_attempts"`
|
||||
OperationTimeout time.Duration `yaml:"operation_timeout"`
|
||||
}
|
||||
type Pipeline struct {
|
||||
Modules []string `yaml:"modules"`
|
||||
}
|
||||
type Output struct {
|
||||
Schema string `yaml:"schema"`
|
||||
}
|
||||
type Validation struct {
|
||||
MaxPromptTokens int `yaml:"max_prompt_tokens"`
|
||||
}
|
||||
type Chunking struct {
|
||||
TargetSections *int `yaml:"target_sections"`
|
||||
MaxSectionTokens int `yaml:"max_section_tokens"`
|
||||
MinSectionTokens int `yaml:"min_section_tokens"`
|
||||
}
|
||||
type Normalization struct {
|
||||
MaxSegmentGap float64 `yaml:"max_segment_gap"`
|
||||
EllipsisGap float64 `yaml:"ellipsis_gap"`
|
||||
MaxSegmentDuration float64 `yaml:"max_segment_duration"`
|
||||
MaxSegmentTokens int `yaml:"max_segment_tokens"`
|
||||
}
|
||||
type Thresholds struct {
|
||||
Glossary float64 `yaml:"glossary"`
|
||||
Homophones float64 `yaml:"homophones"`
|
||||
SpokenWord float64 `yaml:"spoken_word"`
|
||||
Grammar float64 `yaml:"grammar"`
|
||||
}
|
||||
type Context struct {
|
||||
Description string `yaml:"description"`
|
||||
}
|
||||
type Diagnostics struct {
|
||||
Debug bool `yaml:"debug"`
|
||||
WorkDir string `yaml:"work_dir"`
|
||||
}
|
||||
type Reporting struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
StdoutDir string `yaml:"stdout_dir"`
|
||||
}
|
||||
|
||||
func defaults() Config {
|
||||
return Config{
|
||||
ProfilesDir: "profiles",
|
||||
LLM: LLM{TransientRetries: 2, RepairAttempts: 2, OperationTimeout: 15 * time.Minute},
|
||||
Pipeline: Pipeline{Modules: []string{"glossary", "homophones", "glossary", "spoken_word", "grammar"}},
|
||||
Output: Output{Schema: "bare-segments"},
|
||||
Validation: Validation{MaxPromptTokens: DefaultValidationMaxPromptTokens},
|
||||
Chunking: Chunking{MaxSectionTokens: 8192, MinSectionTokens: 2048},
|
||||
Normalization: Normalization{MaxSegmentGap: 4, EllipsisGap: 3.5, MaxSegmentDuration: 60, MaxSegmentTokens: 2048},
|
||||
Thresholds: Thresholds{Glossary: .8, Homophones: .8, SpokenWord: .8, Grammar: .8},
|
||||
Reporting: Reporting{Enabled: true, StdoutDir: "."},
|
||||
Diagnostics: Diagnostics{WorkDir: "/tmp/audita"},
|
||||
}
|
||||
}
|
||||
|
||||
// Load resolves the selected main file, optional overlay, and explicit setting overrides.
|
||||
// Its result retains safe effective output and provenance for CLI composition.
|
||||
func Load(source ck.Source, overlay string, overrides ...ck.Override) (*ck.Result[Config], error) {
|
||||
return ck.Load(source, ck.Options[Config]{
|
||||
Overlay: overlay, Overrides: overrides,
|
||||
Definition: ck.Definition[Config]{
|
||||
Defaults: defaults,
|
||||
Version: &ck.VersionRule{Path: ck.Keys("version"), Check: func(version ck.Version, v *ck.Validation) error {
|
||||
if !version.Present || version.Null || version.Text != "2" {
|
||||
v.Error(ck.Keys("version"), "version 2 is required; see docs/migrations/v2.md")
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
Resolve: func(c *Config, r *ck.Resolution) error {
|
||||
ck.Default(r, ck.Keys("llm", "validation_profile"), &c.LLM.ValidationProfile, c.LLM.ProposalProfile, "validation uses the final proposal profile when omitted", ck.Keys("llm", "proposal_profile"))
|
||||
for id, backend := range c.Backends {
|
||||
changed := false
|
||||
if !r.IsExplicit(ck.Keys("backends", id, "concurrency")) {
|
||||
backend.Concurrency = 1
|
||||
changed = true
|
||||
}
|
||||
if !r.IsExplicit(ck.Keys("backends", id, "queue_capacity")) {
|
||||
backend.QueueCapacity = 1024
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
c.Backends[id] = backend
|
||||
r.Record(ck.Keys("backends", id), ck.ChangeDerivedDefault, "finite backend defaults")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Validate: validate,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func validate(c *Config, v *ck.Validation) {
|
||||
check := func(ok bool, path ck.Path, message string) {
|
||||
if !ok {
|
||||
v.Error(path, message)
|
||||
}
|
||||
}
|
||||
check(strings.TrimSpace(c.ProfilesDir) != "", ck.Keys("profiles_dir"), "profile directory is required")
|
||||
check(strings.TrimSpace(c.LLM.ProposalProfile) != "", ck.Keys("llm", "proposal_profile"), "proposal profile is required")
|
||||
check(strings.TrimSpace(c.LLM.ValidationProfile) != "", ck.Keys("llm", "validation_profile"), "validation profile is required")
|
||||
check(c.LLM.TransientRetries >= 0, ck.Keys("llm", "transient_retries"), "retry budget must be non-negative")
|
||||
check(c.LLM.RepairAttempts >= 0 && c.LLM.RepairAttempts <= 3, ck.Keys("llm", "repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(c.LLM.OperationTimeout > 0, ck.Keys("llm", "operation_timeout"), "operation timeout must be positive")
|
||||
check(len(c.Backends) > 0, ck.Keys("backends"), "at least one backend is required")
|
||||
for id, b := range c.Backends {
|
||||
p := ck.Keys("backends", id)
|
||||
check(strings.TrimSpace(b.Endpoint) != "", p.Key("endpoint"), "backend endpoint is required")
|
||||
check(b.Concurrency > 0, p.Key("concurrency"), "backend concurrency must be positive")
|
||||
check(b.QueueCapacity >= 0, p.Key("queue_capacity"), "queue capacity must be non-negative")
|
||||
}
|
||||
for i, module := range c.Pipeline.Modules {
|
||||
check(modulecatalog.IsSupported(module), ck.Keys("pipeline", "modules").Index(i), "unsupported module key")
|
||||
}
|
||||
check(outputschema.IsSupported(c.Output.Schema), ck.Keys("output", "schema"), "unsupported output schema")
|
||||
check(c.Validation.MaxPromptTokens > 0, ck.Keys("validation", "max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
check(c.Chunking.MaxSectionTokens > 0, ck.Keys("chunking", "max_section_tokens"), "maximum section tokens must be positive")
|
||||
check(c.Chunking.MinSectionTokens > 0 && c.Chunking.MinSectionTokens <= c.Chunking.MaxSectionTokens, ck.Keys("chunking", "min_section_tokens"), "minimum section tokens must be positive and no greater than maximum")
|
||||
check(c.Chunking.TargetSections == nil || *c.Chunking.TargetSections > 0, ck.Keys("chunking", "target_sections"), "target sections must be positive when set")
|
||||
check(c.Normalization.MaxSegmentGap >= 0, ck.Keys("normalization", "max_segment_gap"), "maximum segment gap must be non-negative")
|
||||
check(c.Normalization.EllipsisGap >= 0, ck.Keys("normalization", "ellipsis_gap"), "ellipsis gap must be non-negative")
|
||||
check(c.Normalization.MaxSegmentDuration > 0, ck.Keys("normalization", "max_segment_duration"), "maximum segment duration must be positive")
|
||||
check(c.Normalization.MaxSegmentTokens > 0, ck.Keys("normalization", "max_segment_tokens"), "maximum segment tokens must be positive")
|
||||
for name, threshold := range map[string]float64{"glossary": c.Thresholds.Glossary, "homophones": c.Thresholds.Homophones, "spoken_word": c.Thresholds.SpokenWord, "grammar": c.Thresholds.Grammar} {
|
||||
check(threshold >= 0 && threshold <= 1, ck.Keys("thresholds", name), "confidence threshold must be between zero and one")
|
||||
}
|
||||
check(len(strings.TrimSpace(c.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, ck.Keys("context", "description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
}
|
||||
|
||||
// ParseModulesCSV is used only for an explicitly supplied --modules override.
|
||||
func ParseModulesCSV(raw string) ([]string, error) {
|
||||
if raw == "" {
|
||||
return []string{}, nil
|
||||
}
|
||||
parts := strings.Split(raw, ",")
|
||||
for i := range parts {
|
||||
parts[i] = strings.TrimSpace(parts[i])
|
||||
if parts[i] == "" {
|
||||
return nil, fmt.Errorf("modules list contains an empty value")
|
||||
}
|
||||
}
|
||||
return parts, nil
|
||||
}
|
||||
145
internal/core/config/config_test.go
Normal file
145
internal/core/config/config_test.go
Normal file
@@ -0,0 +1,145 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
)
|
||||
|
||||
const base = "version: 2\nbackends:\n local:\n endpoint: https://local.invalid/v1\nllm:\n proposal_profile: proposal\n"
|
||||
|
||||
func loadText(text, overlay string, overrides ...ck.Override) (*ck.Result[Config], error) {
|
||||
return Load(ck.Bytes("config.yml", []byte(text)), overlay, overrides...)
|
||||
}
|
||||
|
||||
func TestDefaultsAndDomainSettings(t *testing.T) {
|
||||
loaded, err := loadText(base, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := loaded.Config
|
||||
if c.LLM.ValidationProfile != "proposal" || c.Backends["local"].Concurrency != 1 || c.Backends["local"].QueueCapacity != 1024 {
|
||||
t.Fatalf("derived settings: %+v %+v", c.LLM, c.Backends)
|
||||
}
|
||||
if !reflect.DeepEqual(c.Pipeline.Modules, []string{"glossary", "homophones", "glossary", "spoken_word", "grammar"}) {
|
||||
t.Fatalf("module order: %v", c.Pipeline.Modules)
|
||||
}
|
||||
if explanation, ok := loaded.Explain(ck.Keys("llm", "validation_profile")); !ok || len(explanation.History) == 0 {
|
||||
t.Fatal("validation inheritance has no recorded derivation")
|
||||
}
|
||||
if _, err := loadText(base+"pipeline:\n modules: []\n", ""); err != nil {
|
||||
t.Fatalf("empty pipeline: %v", err)
|
||||
}
|
||||
if _, err := loadText(base+"pipeline:\n modules: [grammar, glossary, grammar]\n", ""); err != nil {
|
||||
t.Fatalf("repeated modules: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStrictInputAndConstraints(t *testing.T) {
|
||||
for _, tc := range []struct{ name, text string }{
|
||||
{"old version", strings.Replace(base, "version: 2", "version: 1", 1)},
|
||||
{"missing version", strings.Replace(base, "version: 2\n", "", 1)},
|
||||
{"null version", strings.Replace(base, "version: 2", "version: null", 1)},
|
||||
{"quoted version", strings.Replace(base, "version: 2", "version: '2'", 1)},
|
||||
{"unknown field", base + "mystery: true\n"},
|
||||
{"empty validation profile", base + " validation_profile: ''\n"},
|
||||
{"null validation profile", base + " validation_profile: null\n"},
|
||||
{"null proposal profile", strings.Replace(base, "proposal_profile: proposal", "proposal_profile: null", 1)},
|
||||
{"zero backend concurrency", base + " concurrency: 0\n"},
|
||||
{"invalid target", base + "chunking:\n target_sections: 0\n"},
|
||||
{"invalid section relation", base + "chunking:\n min_section_tokens: 10000\n"},
|
||||
{"string normalization", base + "normalization:\n max_segment_gap: 4s\n"},
|
||||
{"invalid threshold", base + "thresholds:\n glossary: 1.1\n"},
|
||||
{"removed retention", base + "diagnostics:\n retention: always\n"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if _, err := loadText(tc.text, ""); err == nil {
|
||||
t.Fatal("invalid config accepted")
|
||||
}
|
||||
})
|
||||
}
|
||||
_, err := loadText(strings.Replace(base, "version: 2", "version: 1", 1), "")
|
||||
var loadErr *ck.LoadError
|
||||
if !errors.As(err, &loadErr) || len(loadErr.Diagnostics()) == 0 || !strings.Contains(loadErr.Diagnostics()[0].Message, "docs/migrations/v2.md") {
|
||||
t.Fatalf("migration guidance: %v", err)
|
||||
}
|
||||
for _, tc := range []struct{ name, text string }{
|
||||
{"optional target null", base + "chunking:\n target_sections: null\n"},
|
||||
{"zero queue", strings.Replace(base, "llm:\n", " queue_capacity: 0\nllm:\n", 1)},
|
||||
{"zero retries", base + " transient_retries: 0\n repair_attempts: 0\n"},
|
||||
{"zero threshold", base + "thresholds:\n grammar: 0\n"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if _, err := loadText(tc.text, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOverlayOverrideAndInheritance(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "overlays"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main := filepath.Join(dir, "config.yml")
|
||||
if err := os.WriteFile(main, []byte(base), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "overlays", "testing.yml"), []byte("llm:\n proposal_profile: testing\nchunking:\n max_section_tokens: 1000\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := Load(ck.File(main), "testing", ck.Override{Path: ck.Keys("llm", "proposal_profile"), Value: "explicit", Flag: "--proposal-profile"}, ck.Override{Path: ck.Keys("chunking", "min_section_tokens"), Value: 500, Flag: "--min-section-tokens"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.Config.LLM.ProposalProfile != "explicit" || loaded.Config.LLM.ValidationProfile != "explicit" || loaded.Config.Chunking.MaxSectionTokens != 1000 || loaded.Config.Chunking.MinSectionTokens != 500 {
|
||||
t.Fatalf("resolved: %+v", loaded.Config)
|
||||
}
|
||||
if got, _ := loaded.Metadata().Lookup(ck.Keys("llm", "proposal_profile")); got.Origin.Layer != ck.LayerCLI {
|
||||
t.Fatalf("override origin: %+v", got)
|
||||
}
|
||||
if got, _ := loaded.Metadata().Lookup(ck.Keys("chunking", "max_section_tokens")); got.Origin.Layer != ck.LayerOverlay {
|
||||
t.Fatalf("overlay origin: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSurvivingCredentials(t *testing.T) {
|
||||
t.Setenv("BASE_SECRET", "")
|
||||
t.Setenv("NEW_SECRET", "synthetic-secret")
|
||||
withSecret := strings.Replace(base, "llm:\n", " other:\n endpoint: https://other.invalid/v1\n credential: BASE_SECRET\nllm:\n", 1)
|
||||
if _, err := loadText(withSecret, ""); err == nil {
|
||||
t.Fatal("missing unselected backend secret accepted")
|
||||
}
|
||||
replacement := ck.Override{Path: ck.Keys("backends", "other", "credential"), Value: "NEW_SECRET", Flag: "--credential"}
|
||||
loaded, err := loadText(withSecret, "", replacement)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := loaded.Config.Backends["other"].Credential.Value(); got != "synthetic-secret" {
|
||||
t.Fatalf("resolved secret: %q", got)
|
||||
}
|
||||
var effective bytes.Buffer
|
||||
if err := loaded.WriteEffective(&effective); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(effective.String(), "synthetic-secret") {
|
||||
t.Fatal("effective output leaked a secret")
|
||||
}
|
||||
null := ck.Override{Path: ck.Keys("backends", "other", "credential"), Value: nil, Flag: "--credential"}
|
||||
loaded, err = loadText(withSecret, "", null)
|
||||
if err != nil || loaded.Config.Backends["other"].Credential != nil {
|
||||
t.Fatalf("null credential: %+v %v", loaded, err)
|
||||
}
|
||||
t.Setenv("AUDITA_MODEL", "legacy-model")
|
||||
loaded, err = loadText(base, "")
|
||||
if err != nil || loaded.Config.LLM.ProposalProfile != "proposal" {
|
||||
t.Fatalf("legacy environment affected loading: %+v %v", loaded, err)
|
||||
}
|
||||
}
|
||||
17
internal/core/diagnostics/artifacts.go
Normal file
17
internal/core/diagnostics/artifacts.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package diagnostics
|
||||
|
||||
const (
|
||||
ArtifactSourceTranscript = "source-transcript.json"
|
||||
ArtifactParsedSourceTranscript = "source-transcript-parsed.json"
|
||||
ArtifactNormalizedTranscript = "normalized-transcript.json"
|
||||
ArtifactNormalizationSummary = "normalization-summary.json"
|
||||
ArtifactChunkingSummary = "chunking-summary.json"
|
||||
ArtifactUtilizationSummary = "utilization-diagnostics.json"
|
||||
ArtifactLLMExecution = "llm-execution.json"
|
||||
ArtifactSelectedProfiles = "selected-profiles.yaml"
|
||||
ArtifactConfigOrigins = "config-origins.yaml"
|
||||
ArtifactCorrectionLedger = "correction-ledger.json"
|
||||
ArtifactInvocationMetadata = "invocation.json"
|
||||
ArtifactEffectiveConfig = "effective-config.redacted.yaml"
|
||||
ArtifactErrorLog = "error.log"
|
||||
)
|
||||
313
internal/core/diagnostics/output_session.go
Normal file
313
internal/core/diagnostics/output_session.go
Normal file
@@ -0,0 +1,313 @@
|
||||
package diagnostics
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorsFile = "errors.yml"
|
||||
RecoveriesFile = "recoveries.yml"
|
||||
MarkdownFile = "report.md"
|
||||
)
|
||||
|
||||
// OutputSelection contains only active destinations. ProtectedPaths are inputs
|
||||
// and loaded configuration/profile sources that must never be overwritten.
|
||||
// InputTranscriptPath may be replaced by final transcript publication, but not reports.
|
||||
type OutputSelection struct {
|
||||
InputTranscriptPath string
|
||||
TranscriptPath string
|
||||
ReportDir string
|
||||
ReportingEnabled bool
|
||||
ProtectedPaths []string
|
||||
}
|
||||
|
||||
type ReportBundle struct {
|
||||
Errors []byte
|
||||
Recoveries []byte
|
||||
Markdown []byte
|
||||
}
|
||||
|
||||
type FileFailure struct {
|
||||
Path string
|
||||
Kind string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (f FileFailure) Error() string { return fmt.Sprintf("%s %q: %v", f.Kind, f.Path, f.Err) }
|
||||
func (f FileFailure) Unwrap() error { return f.Err }
|
||||
|
||||
// OutputSession owns checked destinations and per-file publication. Filesystem
|
||||
// failures remain typed so CLI can present safe, redacted diagnostics.
|
||||
type OutputSession struct {
|
||||
transcript string
|
||||
reports [3]string
|
||||
enabled bool
|
||||
replace func(string, []byte) error
|
||||
}
|
||||
|
||||
func PrepareOutput(selection OutputSelection) (*OutputSession, error) {
|
||||
session := &OutputSession{enabled: selection.ReportingEnabled, replace: atomicReplace}
|
||||
active := make([]string, 0, 4)
|
||||
if selection.TranscriptPath != "" {
|
||||
session.transcript = selection.TranscriptPath
|
||||
active = append(active, session.transcript)
|
||||
}
|
||||
if session.enabled {
|
||||
if strings.TrimSpace(selection.ReportDir) == "" {
|
||||
return nil, fmt.Errorf("report directory is required")
|
||||
}
|
||||
info, err := os.Stat(selection.ReportDir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("report directory: %w", err)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return nil, fmt.Errorf("report destination is not a directory")
|
||||
}
|
||||
session.reports = [3]string{
|
||||
filepath.Join(selection.ReportDir, ErrorsFile),
|
||||
filepath.Join(selection.ReportDir, RecoveriesFile),
|
||||
filepath.Join(selection.ReportDir, MarkdownFile),
|
||||
}
|
||||
active = append(active, session.reports[:]...)
|
||||
}
|
||||
protected := make([]string, 0, len(selection.ProtectedPaths))
|
||||
for _, path := range selection.ProtectedPaths {
|
||||
if path != "" {
|
||||
protected = append(protected, path)
|
||||
}
|
||||
}
|
||||
for i, path := range active {
|
||||
if path != session.transcript {
|
||||
if info, err := os.Stat(path); err == nil {
|
||||
if !info.Mode().IsRegular() {
|
||||
return nil, fmt.Errorf("report output %q is not a regular file", path)
|
||||
}
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
return nil, fmt.Errorf("report output %q: %w", path, err)
|
||||
}
|
||||
}
|
||||
sources := protected
|
||||
if path != session.transcript && selection.InputTranscriptPath != "" {
|
||||
sources = append(append([]string(nil), protected...), selection.InputTranscriptPath)
|
||||
}
|
||||
for _, source := range sources {
|
||||
collision, err := sameDestination(path, source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if collision {
|
||||
return nil, fmt.Errorf("output destination %q conflicts with input %q", path, source)
|
||||
}
|
||||
}
|
||||
for _, prior := range active[:i] {
|
||||
collision, err := sameDestination(path, prior)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if collision {
|
||||
return nil, fmt.Errorf("output destinations %q and %q conflict", path, prior)
|
||||
}
|
||||
}
|
||||
}
|
||||
if session.transcript != "" {
|
||||
if err := preflightTranscript(session.transcript); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (s *OutputSession) ReportPaths() []string {
|
||||
if s == nil || !s.enabled {
|
||||
return nil
|
||||
}
|
||||
return []string{s.reports[0], s.reports[1], s.reports[2]}
|
||||
}
|
||||
|
||||
func (s *OutputSession) TranscriptPath() string {
|
||||
if s == nil {
|
||||
return ""
|
||||
}
|
||||
return s.transcript
|
||||
}
|
||||
|
||||
// Initialize writes all report destinations before input/model processing. On
|
||||
// failure it makes one best-effort pass to mark already-created reports failed.
|
||||
func (s *OutputSession) Initialize(initial, failed ReportBundle) error {
|
||||
if s == nil || !s.enabled {
|
||||
return nil
|
||||
}
|
||||
created := make([]int, 0, len(s.reports))
|
||||
for i, payload := range bundleParts(initial) {
|
||||
if err := s.replace(s.reports[i], payload); err != nil {
|
||||
for _, prior := range created {
|
||||
_ = s.replace(s.reports[prior], bundleParts(failed)[prior])
|
||||
}
|
||||
return FileFailure{Path: s.reports[i], Kind: "report initialization", Err: err}
|
||||
}
|
||||
created = append(created, i)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Finalize publishes the transcript first, then errors, recoveries, and Markdown.
|
||||
// An empty transcript payload means processing failed and no transcript is written.
|
||||
// Every enabled report is attempted even after an earlier write failure.
|
||||
func (s *OutputSession) Finalize(transcript []byte, reports ReportBundle, failed func([]FileFailure) ReportBundle) []FileFailure {
|
||||
if s == nil {
|
||||
return []FileFailure{{Kind: "output finalization", Err: fmt.Errorf("output session is required")}}
|
||||
}
|
||||
failures := make([]FileFailure, 0)
|
||||
if transcript != nil && s.transcript != "" {
|
||||
if err := s.writeTranscript(transcript); err != nil {
|
||||
failures = append(failures, FileFailure{Path: s.transcript, Kind: "transcript write", Err: err})
|
||||
}
|
||||
}
|
||||
if s.enabled {
|
||||
for i, payload := range bundleParts(reports) {
|
||||
if err := s.replace(s.reports[i], payload); err != nil {
|
||||
failures = append(failures, FileFailure{Path: s.reports[i], Kind: "report write", Err: err})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
for i, payload := range bundleParts(failed(failures)) {
|
||||
_ = s.replace(s.reports[i], payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failures
|
||||
}
|
||||
|
||||
// Stream destinations use ordinary writes; replacing their directory entry would
|
||||
// destroy the device or pipe. Regular files retain per-file replacement.
|
||||
func (s *OutputSession) writeTranscript(payload []byte) error {
|
||||
info, err := os.Stat(s.transcript)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
}
|
||||
if err == nil && !info.Mode().IsRegular() {
|
||||
file, err := os.OpenFile(s.transcript, os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := file.Write(payload)
|
||||
return errors.Join(writeErr, file.Close())
|
||||
}
|
||||
return s.replace(s.transcript, payload)
|
||||
}
|
||||
|
||||
func bundleParts(bundle ReportBundle) [3][]byte {
|
||||
return [3][]byte{bundle.Errors, bundle.Recoveries, bundle.Markdown}
|
||||
}
|
||||
|
||||
func preflightTranscript(path string) error {
|
||||
info, err := os.Stat(path)
|
||||
if err == nil {
|
||||
if info.IsDir() {
|
||||
return fmt.Errorf("transcript output %q is a directory", path)
|
||||
}
|
||||
if !info.Mode().IsRegular() {
|
||||
// Opening a pipe here can block before its reader is ready.
|
||||
return nil
|
||||
}
|
||||
file, openErr := os.OpenFile(path, os.O_WRONLY, 0)
|
||||
if openErr != nil {
|
||||
return fmt.Errorf("transcript output %q cannot be opened: %w", path, openErr)
|
||||
}
|
||||
if closeErr := file.Close(); closeErr != nil {
|
||||
return fmt.Errorf("transcript output %q cannot be closed: %w", path, closeErr)
|
||||
}
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
return fmt.Errorf("transcript output %q: %w", path, err)
|
||||
}
|
||||
parent := filepath.Dir(path)
|
||||
probe, err := os.CreateTemp(parent, ".audita-probe-*")
|
||||
if err != nil {
|
||||
return fmt.Errorf("transcript output parent %q: %w", parent, err)
|
||||
}
|
||||
name := probe.Name()
|
||||
closeErr := probe.Close()
|
||||
removeErr := os.Remove(name)
|
||||
if closeErr != nil {
|
||||
return fmt.Errorf("transcript output probe close: %w", closeErr)
|
||||
}
|
||||
if removeErr != nil {
|
||||
return fmt.Errorf("transcript output probe removal: %w", removeErr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sameDestination(a, b string) (bool, error) {
|
||||
ca, err := canonicalDestination(a)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
cb, err := canonicalDestination(b)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if ca == cb {
|
||||
return true, nil
|
||||
}
|
||||
ai, ae := os.Stat(a)
|
||||
bi, be := os.Stat(b)
|
||||
return ae == nil && be == nil && os.SameFile(ai, bi), nil
|
||||
}
|
||||
|
||||
func canonicalDestination(path string) (string, error) {
|
||||
abs, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
abs = filepath.Clean(abs)
|
||||
if resolved, err := filepath.EvalSymlinks(abs); err == nil {
|
||||
return resolved, nil
|
||||
}
|
||||
parent, err := filepath.EvalSymlinks(filepath.Dir(abs))
|
||||
if err == nil {
|
||||
return filepath.Join(parent, filepath.Base(abs)), nil
|
||||
}
|
||||
return abs, nil
|
||||
}
|
||||
|
||||
func atomicReplace(path string, payload []byte) error {
|
||||
publishPath, err := canonicalDestination(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// A private temporary directory lets ordinary file creation apply the umask
|
||||
// without reading or changing process-global state. Rename stays on the same
|
||||
// filesystem, and the incomplete payload is not accessible through the parent.
|
||||
dir, err := os.MkdirTemp(filepath.Dir(publishPath), ".audita-write-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(dir)
|
||||
name := filepath.Join(dir, "payload")
|
||||
temp, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(name)
|
||||
if info, err := os.Stat(publishPath); err == nil {
|
||||
if err := temp.Chmod(info.Mode().Perm()); err != nil {
|
||||
_ = temp.Close()
|
||||
return err
|
||||
}
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
_ = temp.Close()
|
||||
return err
|
||||
}
|
||||
if _, err := temp.Write(payload); err != nil {
|
||||
_ = temp.Close()
|
||||
return err
|
||||
}
|
||||
if err := temp.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(name, publishPath)
|
||||
}
|
||||
257
internal/core/diagnostics/output_session_test.go
Normal file
257
internal/core/diagnostics/output_session_test.go
Normal file
@@ -0,0 +1,257 @@
|
||||
package diagnostics
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrepareOutputAllowsInPlaceTranscriptButRejectsReportCollisions(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
input := filepath.Join(dir, "input.json")
|
||||
if err := os.WriteFile(input, []byte("source"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
alias := filepath.Join(dir, "alias.json")
|
||||
if err := os.Symlink(input, alias); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hardlink := filepath.Join(dir, "hardlink.json")
|
||||
if err := os.Link(input, hardlink); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, output := range []string{input, alias, hardlink} {
|
||||
if _, err := PrepareOutput(OutputSelection{TranscriptPath: output, InputTranscriptPath: input}); err != nil {
|
||||
t.Fatalf("in-place output rejected: %s: %v", output, err)
|
||||
}
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{TranscriptPath: filepath.Join(dir, ErrorsFile), ReportDir: dir, ReportingEnabled: true}); err == nil {
|
||||
t.Fatal("report/transcript collision accepted")
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{ReportDir: dir, ReportingEnabled: true, ProtectedPaths: []string{filepath.Join(dir, ErrorsFile)}}); err == nil {
|
||||
t.Fatal("report/source collision accepted")
|
||||
}
|
||||
if err := os.Symlink(input, filepath.Join(dir, ErrorsFile)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{ReportDir: dir, ReportingEnabled: true, InputTranscriptPath: input}); err == nil {
|
||||
t.Fatal("report/input alias accepted")
|
||||
}
|
||||
if err := os.Remove(filepath.Join(dir, ErrorsFile)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Mkdir(filepath.Join(dir, MarkdownFile), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{ReportDir: dir, ReportingEnabled: true}); err == nil {
|
||||
t.Fatal("directory report target accepted")
|
||||
}
|
||||
if got, err := os.ReadFile(input); err != nil || string(got) != "source" {
|
||||
t.Fatalf("source changed: %s %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareOutputPreservesExistingTranscriptAndChecksParent(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
output := filepath.Join(dir, "out.json")
|
||||
if err := os.WriteFile(output, []byte("old content"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: output})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, err := os.ReadFile(output); err != nil || string(got) != "old content" {
|
||||
t.Fatalf("preflight truncated output: %s %v", got, err)
|
||||
}
|
||||
if failures := session.Finalize([]byte("new content"), ReportBundle{}, func([]FileFailure) ReportBundle { return ReportBundle{} }); len(failures) != 0 {
|
||||
t.Fatal(failures)
|
||||
}
|
||||
if got, err := os.ReadFile(output); err != nil || string(got) != "new content" {
|
||||
t.Fatalf("publication: %s %v", got, err)
|
||||
}
|
||||
if info, _ := os.Stat(output); info.Mode().Perm() != 0600 {
|
||||
t.Fatalf("permission changed: %v", info.Mode())
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{TranscriptPath: filepath.Join(dir, "missing", "out.json")}); err == nil {
|
||||
t.Fatal("absent parent accepted")
|
||||
}
|
||||
if _, err := PrepareOutput(OutputSelection{TranscriptPath: dir}); err == nil {
|
||||
t.Fatal("directory target accepted")
|
||||
}
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if strings.HasPrefix(entry.Name(), ".audita-") {
|
||||
t.Fatalf("probe left behind: %s", entry.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAtomicReplacementCleansTemporaryFileAfterRenameFailure(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
blocked := filepath.Join(dir, "directory-target")
|
||||
if err := os.Mkdir(blocked, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := atomicReplace(blocked, []byte("new content")); err == nil {
|
||||
t.Fatal("directory replacement unexpectedly succeeded")
|
||||
}
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if strings.HasPrefix(entry.Name(), ".audita-write-") {
|
||||
t.Fatalf("replacement left temporary file: %s", entry.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisabledReportingIgnoresUnusableDirectory(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: filepath.Join(dir, "out.json"), ReportDir: filepath.Join(dir, "missing"), ReportingEnabled: false})
|
||||
if err != nil || len(session.ReportPaths()) != 0 {
|
||||
t.Fatalf("disabled reports probed: %+v %v", session, err)
|
||||
}
|
||||
if err := session.Initialize(ReportBundle{}, ReportBundle{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(dir, "missing")); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("disabled destination created: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnabledReportingRequiresExistingDirectory(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if _, err := PrepareOutput(OutputSelection{ReportDir: filepath.Join(dir, "missing"), ReportingEnabled: true}); err == nil {
|
||||
t.Fatal("missing report directory accepted")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(dir, "missing")); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("report parent created: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStdoutModeInitializesAndFinalizesReports(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
session, err := PrepareOutput(OutputSelection{ReportDir: dir, ReportingEnabled: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
initial := ReportBundle{Errors: []byte("in progress errors"), Recoveries: []byte("in progress recoveries"), Markdown: []byte("in progress report")}
|
||||
finished := ReportBundle{Errors: []byte("completed errors"), Recoveries: []byte("completed recoveries"), Markdown: []byte("completed report")}
|
||||
if err := session.Initialize(initial, ReportBundle{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if session.TranscriptPath() != "" {
|
||||
t.Fatal("stdout mode acquired transcript path")
|
||||
}
|
||||
for i, path := range session.ReportPaths() {
|
||||
got, err := os.ReadFile(path)
|
||||
if err != nil || string(got) != string(bundleParts(initial)[i]) {
|
||||
t.Fatalf("initial %s: %s %v", path, got, err)
|
||||
}
|
||||
}
|
||||
if failures := session.Finalize(nil, finished, func([]FileFailure) ReportBundle { return ReportBundle{} }); len(failures) != 0 {
|
||||
t.Fatal(failures)
|
||||
}
|
||||
for i, path := range session.ReportPaths() {
|
||||
got, err := os.ReadFile(path)
|
||||
if err != nil || string(got) != string(bundleParts(finished)[i]) {
|
||||
t.Fatalf("final %s: %s %v", path, got, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInitializeFailureMarksPriorReportFailedBeforeModelWork(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
session, err := PrepareOutput(OutputSelection{ReportDir: dir, ReportingEnabled: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
actual := session.replace
|
||||
session.replace = func(path string, payload []byte) error {
|
||||
if filepath.Base(path) == RecoveriesFile && string(payload) == "initial" {
|
||||
return os.ErrPermission
|
||||
}
|
||||
return actual(path, payload)
|
||||
}
|
||||
modelCalled := false
|
||||
if err := session.Initialize(ReportBundle{Errors: []byte("initial"), Recoveries: []byte("initial"), Markdown: []byte("initial")}, ReportBundle{Errors: []byte("failed"), Recoveries: []byte("failed"), Markdown: []byte("failed")}); err == nil {
|
||||
modelCalled = true
|
||||
}
|
||||
if modelCalled {
|
||||
t.Fatal("model work continued after initialization failure")
|
||||
}
|
||||
got, err := os.ReadFile(filepath.Join(dir, ErrorsFile))
|
||||
if err != nil || string(got) != "failed" {
|
||||
t.Fatalf("prior report not failed: %s %v", got, err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(dir, MarkdownFile)); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("later report created: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalizationCollectsFailuresAndRetainsPublishedTranscript(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
output := filepath.Join(dir, "output.json")
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: output, ReportDir: dir, ReportingEnabled: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := session.Initialize(ReportBundle{Errors: []byte("initial"), Recoveries: []byte("initial"), Markdown: []byte("initial")}, ReportBundle{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
actual := session.replace
|
||||
session.replace = func(path string, payload []byte) error {
|
||||
if filepath.Base(path) == ErrorsFile && string(payload) == "complete" {
|
||||
return os.ErrPermission
|
||||
}
|
||||
return actual(path, payload)
|
||||
}
|
||||
complete := ReportBundle{Errors: []byte("complete"), Recoveries: []byte("complete"), Markdown: []byte("complete")}
|
||||
failed := ReportBundle{Errors: []byte("failed"), Recoveries: []byte("failed"), Markdown: []byte("failed")}
|
||||
failures := session.Finalize([]byte("transcript"), complete, func([]FileFailure) ReportBundle { return failed })
|
||||
if len(failures) != 1 || failures[0].Path != filepath.Join(dir, ErrorsFile) {
|
||||
t.Fatalf("failures: %+v", failures)
|
||||
}
|
||||
if got, err := os.ReadFile(output); err != nil || string(got) != "transcript" {
|
||||
t.Fatalf("transcript erased: %s %v", got, err)
|
||||
}
|
||||
for _, path := range session.ReportPaths() {
|
||||
if got, err := os.ReadFile(path); err != nil || string(got) != "failed" {
|
||||
t.Fatalf("failed-status pass %s: %s %v", path, got, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugRunDirectoryUsesSuppliedIDAndIsRetained(t *testing.T) {
|
||||
parent := filepath.Join(t.TempDir(), "debug")
|
||||
if _, err := os.Stat(parent); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("unexpected parent: %v", err)
|
||||
}
|
||||
run, err := NewRunDirectory(parent, "run-123", "secret")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if run.Path() != filepath.Join(parent, "run-123") {
|
||||
t.Fatalf("run ID changed: %s", run.Path())
|
||||
}
|
||||
if _, err := NewRunDirectory(parent, "run-123"); err == nil {
|
||||
t.Fatal("duplicate run ID accepted")
|
||||
}
|
||||
if err := run.WriteJSONArtifact(ArtifactCorrectionLedger, map[string]string{"proposal": "secret"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
contents, err := os.ReadFile(filepath.Join(run.Path(), ArtifactCorrectionLedger))
|
||||
if err != nil || strings.Contains(string(contents), "secret") {
|
||||
t.Fatalf("debug artifact: %s %v", contents, err)
|
||||
}
|
||||
if _, err := os.Stat(run.Path()); err != nil {
|
||||
t.Fatalf("debug directory removed: %v", err)
|
||||
}
|
||||
}
|
||||
69
internal/core/diagnostics/output_stream_test.go
Normal file
69
internal/core/diagnostics/output_stream_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
//go:build linux || darwin
|
||||
|
||||
package diagnostics
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTranscriptStreamDestinations(t *testing.T) {
|
||||
fifo := filepath.Join(t.TempDir(), "transcript.pipe")
|
||||
if err := syscall.Mkfifo(fifo, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{os.DevNull, fifo} {
|
||||
t.Run(filepath.Base(path), func(t *testing.T) {
|
||||
before, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Preparation must finish even though the pipe has no reader yet.
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: path})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var reader *os.File
|
||||
if path == fifo {
|
||||
// Keep both ends open in the test so publication and reading can be
|
||||
// sequential; the small payload fits in the pipe buffer.
|
||||
reader, err = os.OpenFile(path, os.O_RDWR|syscall.O_NONBLOCK, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer reader.Close()
|
||||
}
|
||||
payload := []byte("transcript")
|
||||
if failures := session.Finalize(payload, ReportBundle{}, nil); len(failures) != 0 {
|
||||
t.Fatal(failures)
|
||||
}
|
||||
after, err := os.Stat(path)
|
||||
if err != nil || !os.SameFile(before, after) || before.Mode() != after.Mode() {
|
||||
t.Fatalf("stream replaced: %v", err)
|
||||
}
|
||||
if reader != nil {
|
||||
got := make([]byte, len(payload))
|
||||
if _, err := io.ReadFull(reader, got); err != nil || string(got) != string(payload) {
|
||||
t.Fatalf("pipe delivery: %q %v", got, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTranscriptStreamWriteFailure(t *testing.T) {
|
||||
if _, err := os.Stat("/dev/full"); os.IsNotExist(err) {
|
||||
t.Skip("/dev/full unavailable")
|
||||
}
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: "/dev/full"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
failures := session.Finalize([]byte("transcript"), ReportBundle{}, nil)
|
||||
if len(failures) != 1 || failures[0].Kind != "transcript write" {
|
||||
t.Fatalf("write failure lost: %+v", failures)
|
||||
}
|
||||
}
|
||||
205
internal/core/diagnostics/run_dir.go
Normal file
205
internal/core/diagnostics/run_dir.go
Normal file
@@ -0,0 +1,205 @@
|
||||
package diagnostics
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/chunking"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/normalization"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/redaction"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
// RunDirectory represents a per-run diagnostics directory
|
||||
type RunDirectory struct {
|
||||
redactor redaction.Redactor
|
||||
path string
|
||||
createdAt time.Time
|
||||
}
|
||||
|
||||
// InvocationMetadata captures non-secret invocation details for diagnostics.
|
||||
type InvocationMetadata struct {
|
||||
Operation string `json:"operation"`
|
||||
TranscriptPath string `json:"transcript_path"`
|
||||
GlossaryPath string `json:"glossary_path"`
|
||||
OutputPath string `json:"output_path,omitempty"`
|
||||
ConfigPath string `json:"config_path,omitempty"`
|
||||
ConfigSource string `json:"config_source,omitempty"`
|
||||
Overlay string `json:"overlay,omitempty"`
|
||||
ConfigVersion *int `json:"config_version,omitempty"`
|
||||
TranscriptDescription string `json:"transcript_description,omitempty"`
|
||||
Modules []string `json:"modules"`
|
||||
RunID string `json:"run_id"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
}
|
||||
|
||||
// NewRunDirectory creates a new run directory under the configured work dir
|
||||
func NewRunDirectory(workDir, runID string, secrets ...string) (*RunDirectory, error) {
|
||||
if strings.TrimSpace(workDir) == "" {
|
||||
return nil, fmt.Errorf("debug work directory is required")
|
||||
}
|
||||
if strings.TrimSpace(runID) == "" || filepath.Base(runID) != runID || runID == "." || runID == ".." {
|
||||
return nil, fmt.Errorf("valid run ID is required")
|
||||
}
|
||||
|
||||
// Create work directory if it doesn't exist
|
||||
if err := os.MkdirAll(workDir, 0o755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create work directory %q: %w", workDir, err)
|
||||
}
|
||||
|
||||
runPath := filepath.Join(workDir, runID)
|
||||
|
||||
if err := os.Mkdir(runPath, 0o755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create run directory %q: %w", runPath, err)
|
||||
}
|
||||
|
||||
return &RunDirectory{
|
||||
path: runPath,
|
||||
redactor: redaction.New(secrets),
|
||||
createdAt: time.Now().UTC(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Path returns the run directory path
|
||||
func (r *RunDirectory) Path() string {
|
||||
return r.path
|
||||
}
|
||||
|
||||
func (r *RunDirectory) runID() string {
|
||||
return filepath.Base(r.path)
|
||||
}
|
||||
|
||||
// WriteInvocationMetadata writes invocation metadata for this run.
|
||||
func (r *RunDirectory) WriteInvocationMetadata(metadata InvocationMetadata) error {
|
||||
if metadata.RunID == "" {
|
||||
metadata.RunID = r.runID()
|
||||
}
|
||||
if metadata.StartedAt.IsZero() {
|
||||
metadata.StartedAt = r.createdAt
|
||||
}
|
||||
|
||||
path := filepath.Join(r.path, ArtifactInvocationMetadata)
|
||||
bytes, err := r.redactor.JSON(metadata)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal invocation metadata: %w", err)
|
||||
}
|
||||
bytes = append(bytes, '\n')
|
||||
if err := os.WriteFile(path, bytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write invocation metadata: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteEffectiveConfig writes redacted effective config metadata for this run.
|
||||
func (r *RunDirectory) WriteEffectiveConfig(effectiveYAML []byte) error {
|
||||
return r.WriteYAMLArtifact(ArtifactEffectiveConfig, effectiveYAML)
|
||||
}
|
||||
|
||||
// WriteSourceTranscript writes the source transcript artifact
|
||||
func (r *RunDirectory) WriteSourceTranscript(transcript *schema.SourceTranscript, raw []byte) error {
|
||||
// Preserve the source snapshot without copying unredacted input bytes.
|
||||
var source any
|
||||
decoder := json.NewDecoder(strings.NewReader(string(raw)))
|
||||
decoder.UseNumber()
|
||||
if err := decoder.Decode(&source); err != nil {
|
||||
return fmt.Errorf("decode source snapshot: %w", err)
|
||||
}
|
||||
sourceBytes, err := r.redactor.JSON(source)
|
||||
if err != nil {
|
||||
return fmt.Errorf("redact source snapshot: %w", err)
|
||||
}
|
||||
sourcePath := filepath.Join(r.path, ArtifactSourceTranscript)
|
||||
if err := os.WriteFile(sourcePath, append(sourceBytes, '\n'), 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write source transcript: %w", err)
|
||||
}
|
||||
|
||||
// Write parsed source for debugging
|
||||
parsedPath := filepath.Join(r.path, ArtifactParsedSourceTranscript)
|
||||
parsedBytes, err := r.redactor.JSON(transcript)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal parsed source transcript: %w", err)
|
||||
}
|
||||
parsedBytes = append(parsedBytes, '\n')
|
||||
if err := os.WriteFile(parsedPath, parsedBytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write parsed source transcript: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteNormalizedTranscript writes the normalized transcript artifact
|
||||
func (r *RunDirectory) WriteNormalizedTranscript(transcript *schema.Transcript) error {
|
||||
normalizedPath := filepath.Join(r.path, ArtifactNormalizedTranscript)
|
||||
bytes, err := r.redactor.JSON(transcript)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to serialize normalized transcript: %w", err)
|
||||
}
|
||||
if err := os.WriteFile(normalizedPath, bytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write normalized transcript: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteNormalizationSummary writes the normalization summary artifact
|
||||
func (r *RunDirectory) WriteNormalizationSummary(summary *normalization.NormalizationSummary) error {
|
||||
summaryPath := filepath.Join(r.path, ArtifactNormalizationSummary)
|
||||
bytes, err := r.redactor.JSON(summary)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal normalization summary: %w", err)
|
||||
}
|
||||
bytes = append(bytes, '\n')
|
||||
if err := os.WriteFile(summaryPath, bytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write normalization summary: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteErrorLog writes an error log on failure
|
||||
func (r *RunDirectory) WriteErrorLog(errorMessage string) error {
|
||||
errorPath := filepath.Join(r.path, ArtifactErrorLog)
|
||||
return os.WriteFile(errorPath, []byte(r.redactor.String(errorMessage)+"\n"), 0o644)
|
||||
}
|
||||
|
||||
// WriteChunkingSummary writes the chunking summary artifact
|
||||
func (r *RunDirectory) WriteChunkingSummary(summary *chunking.DetailedSummary) error {
|
||||
summaryPath := filepath.Join(r.path, ArtifactChunkingSummary)
|
||||
bytes, err := r.redactor.JSON(summary)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal chunking summary: %w", err)
|
||||
}
|
||||
bytes = append(bytes, '\n')
|
||||
if err := os.WriteFile(summaryPath, bytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write chunking summary: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RunDirectory) WriteJSONArtifact(name string, payload any) error {
|
||||
artifactPath := filepath.Join(r.path, name)
|
||||
bytes, err := r.redactor.JSON(payload)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal %s: %w", name, err)
|
||||
}
|
||||
bytes = append(bytes, '\n')
|
||||
if err := os.WriteFile(artifactPath, bytes, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write %s: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteYAMLArtifact writes a sanitized YAML diagnostic artifact.
|
||||
func (r *RunDirectory) WriteYAMLArtifact(name string, payload []byte) error {
|
||||
var err error
|
||||
payload, err = r.redactor.YAML(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(r.path, name), payload, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write %s: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
29
internal/core/io/files.go
Normal file
29
internal/core/io/files.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package io
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func ReadRequiredFile(path string, label string) ([]byte, error) {
|
||||
contents, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read %s file %q: %w", label, path, err)
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func ValidateWellFormedJSON(path string, raw []byte) error {
|
||||
if !json.Valid(raw) {
|
||||
return fmt.Errorf("transcript file %q is not valid JSON", path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func WriteFile(path string, contents []byte) error {
|
||||
if err := os.WriteFile(path, contents, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write output file %q: %w", path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
35
internal/core/modulecatalog/catalog.go
Normal file
35
internal/core/modulecatalog/catalog.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package modulecatalog
|
||||
|
||||
import "strings"
|
||||
|
||||
const (
|
||||
KeyGlossary = "glossary"
|
||||
KeyHomophones = "homophones"
|
||||
KeySpokenWord = "spoken_word"
|
||||
KeyGrammar = "grammar"
|
||||
)
|
||||
|
||||
var supportedKeys = []string{
|
||||
KeyGlossary,
|
||||
KeyHomophones,
|
||||
KeySpokenWord,
|
||||
KeyGrammar,
|
||||
}
|
||||
|
||||
var supportedKeySet = map[string]struct{}{
|
||||
KeyGlossary: {},
|
||||
KeyHomophones: {},
|
||||
KeySpokenWord: {},
|
||||
KeyGrammar: {},
|
||||
}
|
||||
|
||||
func SupportedKeys() []string {
|
||||
out := make([]string, len(supportedKeys))
|
||||
copy(out, supportedKeys)
|
||||
return out
|
||||
}
|
||||
|
||||
func IsSupported(key string) bool {
|
||||
_, ok := supportedKeySet[strings.TrimSpace(key)]
|
||||
return ok
|
||||
}
|
||||
24
internal/core/modulecatalog/catalog_test.go
Normal file
24
internal/core/modulecatalog/catalog_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package modulecatalog
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSupportedKeys(t *testing.T) {
|
||||
want := []string{KeyGlossary, KeyHomophones, KeySpokenWord, KeyGrammar}
|
||||
if got := SupportedKeys(); !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("unexpected supported keys: got=%v want=%v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSupported(t *testing.T) {
|
||||
for _, key := range SupportedKeys() {
|
||||
if !IsSupported(key) {
|
||||
t.Fatalf("expected key %q to be supported", key)
|
||||
}
|
||||
}
|
||||
if IsSupported("made_up") {
|
||||
t.Fatalf("did not expect made_up to be supported")
|
||||
}
|
||||
}
|
||||
206
internal/core/normalization/normalize.go
Normal file
206
internal/core/normalization/normalize.go
Normal file
@@ -0,0 +1,206 @@
|
||||
package normalization
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
// NormalizationConfig holds configuration parameters for transcript normalization
|
||||
type NormalizationConfig struct {
|
||||
MaxSegmentGap float64 // Maximum gap between segments to consider for merging (seconds)
|
||||
EllipsisGap float64 // Gap threshold above which to insert ellipsis (seconds)
|
||||
MaxSegmentDuration float64 // Maximum duration for a merged segment (seconds)
|
||||
MaxSegmentTokens int // Maximum token estimate for a merged segment
|
||||
}
|
||||
|
||||
// NormalizationSummary records the results and statistics of normalization
|
||||
type NormalizationSummary struct {
|
||||
InputSegmentCount int `json:"input_segment_count"`
|
||||
OutputSegmentCount int `json:"output_segment_count"`
|
||||
MergesPerformed int `json:"merges_performed"`
|
||||
IDsReassigned int `json:"ids_reassigned"`
|
||||
SkippedMerges struct {
|
||||
DifferentSpeakers int `json:"different_speakers"`
|
||||
GapTooLarge int `json:"gap_too_large"`
|
||||
DurationExceeded int `json:"duration_exceeded"`
|
||||
TokenLimitExceeded int `json:"token_limit_exceeded"`
|
||||
} `json:"skipped_merges"`
|
||||
}
|
||||
|
||||
// NormalizeTranscript performs deterministic normalization on a transcript
|
||||
type NormalizeTranscript struct {
|
||||
config NormalizationConfig
|
||||
estimator *SimpleTokenEstimator
|
||||
}
|
||||
|
||||
// NewNormalizer creates a new transcript normalizer with the given configuration
|
||||
func NewNormalizer(config NormalizationConfig) *NormalizeTranscript {
|
||||
return &NormalizeTranscript{
|
||||
config: config,
|
||||
estimator: &SimpleTokenEstimator{},
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize performs deterministic normalization on the given transcript
|
||||
func (n *NormalizeTranscript) Normalize(transcript *schema.Transcript) (*schema.Transcript, *NormalizationSummary) {
|
||||
summary := &NormalizationSummary{
|
||||
InputSegmentCount: len(transcript.Segments),
|
||||
}
|
||||
|
||||
if len(transcript.Segments) == 0 {
|
||||
return transcript, summary
|
||||
}
|
||||
|
||||
// Sort segments chronologically
|
||||
sortedSegments := make([]schema.Segment, len(transcript.Segments))
|
||||
copy(sortedSegments, transcript.Segments)
|
||||
sort.Slice(sortedSegments, func(i, j int) bool {
|
||||
return sortedSegments[i].Start < sortedSegments[j].Start
|
||||
})
|
||||
|
||||
// Merge same-speaker adjacent segments
|
||||
var normalizedSegments []schema.Segment
|
||||
var currentSegment schema.Segment
|
||||
|
||||
for i, segment := range sortedSegments {
|
||||
if i == 0 {
|
||||
// Initialize with first segment
|
||||
currentSegment = segment
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if we should merge with current segment
|
||||
gap := segment.Start - currentSegment.End
|
||||
merge, reason := shouldMergeWithReason(n.config, n.estimator, ¤tSegment, &segment, gap)
|
||||
if merge {
|
||||
summary.MergesPerformed++
|
||||
currentSegment = mergeSegments(¤tSegment, &segment, gap, n.config.EllipsisGap)
|
||||
} else {
|
||||
// Track the reason for not merging
|
||||
switch reason {
|
||||
case "different_speakers":
|
||||
summary.SkippedMerges.DifferentSpeakers++
|
||||
case "gap_too_large":
|
||||
summary.SkippedMerges.GapTooLarge++
|
||||
case "duration_exceeded":
|
||||
summary.SkippedMerges.DurationExceeded++
|
||||
case "token_limit_exceeded":
|
||||
summary.SkippedMerges.TokenLimitExceeded++
|
||||
}
|
||||
// Finalize current segment and start new one
|
||||
normalizedSegments = append(normalizedSegments, currentSegment)
|
||||
currentSegment = segment
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last segment
|
||||
if len(currentSegment.Text) > 0 {
|
||||
normalizedSegments = append(normalizedSegments, currentSegment)
|
||||
}
|
||||
|
||||
// Reassign sequential IDs starting at 1
|
||||
for i, segment := range normalizedSegments {
|
||||
if segment.ID != i+1 {
|
||||
summary.IDsReassigned++
|
||||
}
|
||||
normalizedSegments[i].ID = i + 1
|
||||
}
|
||||
|
||||
summary.OutputSegmentCount = len(normalizedSegments)
|
||||
|
||||
return &schema.Transcript{Segments: normalizedSegments}, summary
|
||||
}
|
||||
|
||||
func shouldMerge(config NormalizationConfig, estimator *SimpleTokenEstimator,
|
||||
current, next *schema.Segment, gap float64) bool {
|
||||
|
||||
// Don't merge if different speakers
|
||||
if current.Speaker != next.Speaker {
|
||||
return false
|
||||
}
|
||||
|
||||
// Don't merge if gap is too large
|
||||
if gap > config.MaxSegmentGap {
|
||||
return false
|
||||
}
|
||||
|
||||
// Calculate what the merged segment would look like
|
||||
mergedText := current.Text
|
||||
if gap >= config.EllipsisGap {
|
||||
mergedText += "... "
|
||||
} else {
|
||||
mergedText += " "
|
||||
}
|
||||
mergedText += next.Text
|
||||
|
||||
mergedDuration := next.End - current.Start
|
||||
|
||||
// Don't merge if duration would be exceeded
|
||||
if mergedDuration > config.MaxSegmentDuration {
|
||||
return false
|
||||
}
|
||||
|
||||
// Don't merge if token estimate would be exceeded
|
||||
tokenEstimate := estimator.EstimateTokens(mergedText)
|
||||
if tokenEstimate > config.MaxSegmentTokens {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func shouldMergeWithReason(config NormalizationConfig, estimator *SimpleTokenEstimator,
|
||||
current, next *schema.Segment, gap float64) (bool, string) {
|
||||
|
||||
if current.Speaker != next.Speaker {
|
||||
return false, "different_speakers"
|
||||
}
|
||||
if gap > config.MaxSegmentGap {
|
||||
return false, "gap_too_large"
|
||||
}
|
||||
|
||||
mergedText := current.Text
|
||||
if gap >= config.EllipsisGap {
|
||||
mergedText += "... "
|
||||
} else {
|
||||
mergedText += " "
|
||||
}
|
||||
mergedText += next.Text
|
||||
|
||||
mergedDuration := next.End - current.Start
|
||||
if mergedDuration > config.MaxSegmentDuration {
|
||||
return false, "duration_exceeded"
|
||||
}
|
||||
|
||||
tokenEstimate := estimator.EstimateTokens(mergedText)
|
||||
if tokenEstimate > config.MaxSegmentTokens {
|
||||
return false, "token_limit_exceeded"
|
||||
}
|
||||
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func mergeSegments(current, next *schema.Segment, gap, ellipsisGap float64) schema.Segment {
|
||||
mergedText := current.Text
|
||||
if gap >= ellipsisGap {
|
||||
mergedText += "... "
|
||||
} else {
|
||||
mergedText += " "
|
||||
}
|
||||
mergedText += next.Text
|
||||
|
||||
// Merge categories
|
||||
categories := make([]string, 0, len(current.Categories)+len(next.Categories))
|
||||
categories = append(categories, current.Categories...)
|
||||
categories = append(categories, next.Categories...)
|
||||
|
||||
return schema.Segment{
|
||||
ID: current.ID, // Will be reassigned later
|
||||
Speaker: current.Speaker,
|
||||
Start: current.Start,
|
||||
End: next.End,
|
||||
Text: mergedText,
|
||||
Categories: categories,
|
||||
}
|
||||
}
|
||||
684
internal/core/normalization/normalize_test.go
Normal file
684
internal/core/normalization/normalize_test.go
Normal file
@@ -0,0 +1,684 @@
|
||||
package normalization
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
func TestNormalizationNoOp(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Bob", Start: 2.0, End: 3.0, Text: "Hi"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should be no-op since different speakers
|
||||
if len(normalized.Segments) != 2 {
|
||||
t.Errorf("expected 2 segments, got %d", len(normalized.Segments))
|
||||
}
|
||||
if summary.InputSegmentCount != 2 {
|
||||
t.Errorf("expected input count 2, got %d", summary.InputSegmentCount)
|
||||
}
|
||||
if summary.OutputSegmentCount != 2 {
|
||||
t.Errorf("expected output count 2, got %d", summary.OutputSegmentCount)
|
||||
}
|
||||
if summary.MergesPerformed != 0 {
|
||||
t.Errorf("expected 0 merges, got %d", summary.MergesPerformed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationSameSpeakerMergeWithinGap(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Alice", Start: 1.5, End: 2.5, Text: "world"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should merge since same speaker and small gap
|
||||
if len(normalized.Segments) != 1 {
|
||||
t.Errorf("expected 1 merged segment, got %d", len(normalized.Segments))
|
||||
}
|
||||
if summary.MergesPerformed != 1 {
|
||||
t.Errorf("expected 1 merge, got %d", summary.MergesPerformed)
|
||||
}
|
||||
if !strings.Contains(normalized.Segments[0].Text, "Hello") || !strings.Contains(normalized.Segments[0].Text, "world") {
|
||||
t.Errorf("expected merged text to contain both parts, got %q", normalized.Segments[0].Text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationEllipsisInsertionAboveThreshold(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 0.5,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Alice", Start: 2.0, End: 3.0, Text: "world"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(transcript)
|
||||
|
||||
// Should merge with ellipsis since gap (1.0) > ellipsis threshold (0.5)
|
||||
if len(normalized.Segments) != 1 {
|
||||
t.Errorf("expected 1 merged segment, got %d", len(normalized.Segments))
|
||||
}
|
||||
if !strings.Contains(normalized.Segments[0].Text, "...") {
|
||||
t.Errorf("expected ellipsis in merged text, got %q", normalized.Segments[0].Text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationNoMergeDifferentSpeakers(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Bob", Start: 1.5, End: 2.5, Text: "Hi"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should NOT merge since different speakers
|
||||
if len(normalized.Segments) != 2 {
|
||||
t.Errorf("expected 2 segments, got %d", len(normalized.Segments))
|
||||
}
|
||||
if summary.SkippedMerges.DifferentSpeakers != 1 {
|
||||
t.Errorf("expected 1 skipped merge for different speakers, got %d", summary.SkippedMerges.DifferentSpeakers)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationNoMergeWhenMaxDurationExceeded(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 1.0, // Very small max duration
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 0.5, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Alice", Start: 0.6, End: 1.5, Text: "world"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should NOT merge since merged duration (1.5) > max duration (1.0)
|
||||
if len(normalized.Segments) != 2 {
|
||||
t.Errorf("expected 2 segments, got %d", len(normalized.Segments))
|
||||
}
|
||||
if summary.SkippedMerges.DurationExceeded != 1 {
|
||||
t.Errorf("expected 1 skipped merge for duration exceeded, got %d", summary.SkippedMerges.DurationExceeded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationNoMergeWhenTokenLimitExceeded(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 1, // Very small token limit
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 2, Speaker: "Alice", Start: 1.5, End: 2.5, Text: "world"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should NOT merge since merged token count would exceed limit
|
||||
if len(normalized.Segments) != 2 {
|
||||
t.Errorf("expected 2 segments, got %d", len(normalized.Segments))
|
||||
}
|
||||
if summary.SkippedMerges.TokenLimitExceeded != 1 {
|
||||
t.Errorf("expected 1 skipped merge for token limit exceeded, got %d", summary.SkippedMerges.TokenLimitExceeded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationChronologicalOrdering(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 2, Speaker: "Alice", Start: 5.0, End: 6.0, Text: "Later"},
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "First"},
|
||||
{ID: 3, Speaker: "Alice", Start: 2.0, End: 3.0, Text: "Middle"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(transcript)
|
||||
|
||||
// Should be sorted chronologically
|
||||
if len(normalized.Segments) != 1 {
|
||||
t.Errorf("expected 1 merged segment, got %d", len(normalized.Segments))
|
||||
}
|
||||
if normalized.Segments[0].Start != 0.0 {
|
||||
t.Errorf("expected first segment to start at 0.0, got %f", normalized.Segments[0].Start)
|
||||
}
|
||||
if normalized.Segments[0].End != 6.0 {
|
||||
t.Errorf("expected merged segment to end at 6.0, got %f", normalized.Segments[0].End)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationSequentialIDReassignment(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 5, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello"},
|
||||
{ID: 10, Speaker: "Bob", Start: 2.0, End: 3.0, Text: "Hi"},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, summary := normalizer.Normalize(transcript)
|
||||
|
||||
// Should have sequential IDs starting at 1
|
||||
if len(normalized.Segments) != 2 {
|
||||
t.Errorf("expected 2 segments, got %d", len(normalized.Segments))
|
||||
}
|
||||
if normalized.Segments[0].ID != 1 {
|
||||
t.Errorf("expected first segment ID 1, got %d", normalized.Segments[0].ID)
|
||||
}
|
||||
if normalized.Segments[1].ID != 2 {
|
||||
t.Errorf("expected second segment ID 2, got %d", normalized.Segments[1].ID)
|
||||
}
|
||||
if summary.IDsReassigned != 2 {
|
||||
t.Errorf("expected 2 IDs reassigned, got %d", summary.IDsReassigned)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationCategoryPreservation(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
transcript := &schema.Transcript{
|
||||
Segments: []schema.Segment{
|
||||
{ID: 1, Speaker: "Alice", Start: 0.0, End: 1.0, Text: "Hello", Categories: []string{"greeting"}},
|
||||
{ID: 2, Speaker: "Alice", Start: 1.5, End: 2.5, Text: "world", Categories: []string{"response"}},
|
||||
},
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(transcript)
|
||||
|
||||
// Should merge and preserve both categories
|
||||
if len(normalized.Segments) != 1 {
|
||||
t.Errorf("expected 1 merged segment, got %d", len(normalized.Segments))
|
||||
}
|
||||
if len(normalized.Segments[0].Categories) != 2 {
|
||||
t.Errorf("expected 2 categories, got %d", len(normalized.Segments[0].Categories))
|
||||
}
|
||||
if normalized.Segments[0].Categories[0] != "greeting" || normalized.Segments[0].Categories[1] != "response" {
|
||||
t.Errorf("expected preserved categories, got %v", normalized.Segments[0].Categories)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenBareArrayTranscript(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/bare_array_transcript.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/bare_array_transcript.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenObjectWithSegmentsTranscript(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/object_with_segments_transcript.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/object_with_segments_transcript.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenTranscriptWithCategories(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/transcript_with_categories.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/transcript_with_categories.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenTranscriptWithOriginalIDs(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/transcript_with_original_ids.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/transcript_with_original_ids.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenSameSpeakerMerge(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/transcript_same_speaker_merge.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/transcript_same_speaker_merge.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenEllipsisMerge(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/transcript_ellipsis_merge.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/transcript_ellipsis_merge.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func TestNormalizationGoldenDifferentSpeakersNoMerge(t *testing.T) {
|
||||
config := NormalizationConfig{
|
||||
MaxSegmentGap: 2.0,
|
||||
EllipsisGap: 1.0,
|
||||
MaxSegmentDuration: 60.0,
|
||||
MaxSegmentTokens: 100,
|
||||
}
|
||||
normalizer := NewNormalizer(config)
|
||||
|
||||
raw, err := os.ReadFile("testdata/transcript_different_speakers_no_merge.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test fixture: %v", err)
|
||||
}
|
||||
|
||||
transcript, err := schema.ParseSourceTranscriptJSON(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse source transcript: %v", err)
|
||||
}
|
||||
|
||||
converted := &schema.Transcript{
|
||||
Segments: make([]schema.Segment, len(transcript.Segments)),
|
||||
}
|
||||
for i, s := range transcript.Segments {
|
||||
id := i + 1
|
||||
if s.ID != nil {
|
||||
id = *s.ID
|
||||
}
|
||||
converted.Segments[i] = schema.Segment{
|
||||
ID: id,
|
||||
Speaker: s.Speaker,
|
||||
Start: s.Start,
|
||||
End: s.End,
|
||||
Text: s.Text,
|
||||
Categories: s.Categories,
|
||||
}
|
||||
}
|
||||
|
||||
normalized, _ := normalizer.Normalize(converted)
|
||||
|
||||
// Compare with golden output semantically
|
||||
expectedRaw, err := os.ReadFile("testdata/transcript_different_speakers_no_merge.golden.json")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read golden fixture: %v", err)
|
||||
}
|
||||
|
||||
expectedTranscript, err := schema.ParseTranscriptJSON(expectedRaw)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse golden transcript: %v", err)
|
||||
}
|
||||
|
||||
assertTranscriptsEqual(t, normalized, expectedTranscript)
|
||||
}
|
||||
|
||||
func assertTranscriptsEqual(t *testing.T, actual, expected *schema.Transcript) {
|
||||
t.Helper()
|
||||
|
||||
if len(actual.Segments) != len(expected.Segments) {
|
||||
t.Errorf("segment count mismatch: expected %d, got %d", len(expected.Segments), len(actual.Segments))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range actual.Segments {
|
||||
a := actual.Segments[i]
|
||||
e := expected.Segments[i]
|
||||
|
||||
if a.ID != e.ID {
|
||||
t.Errorf("segment %d: ID mismatch: expected %d, got %d", i, e.ID, a.ID)
|
||||
}
|
||||
if a.Speaker != e.Speaker {
|
||||
t.Errorf("segment %d: speaker mismatch: expected %q, got %q", i, e.Speaker, a.Speaker)
|
||||
}
|
||||
if a.Start != e.Start {
|
||||
t.Errorf("segment %d: start mismatch: expected %f, got %f", i, e.Start, a.Start)
|
||||
}
|
||||
if a.End != e.End {
|
||||
t.Errorf("segment %d: end mismatch: expected %f, got %f", i, e.End, a.End)
|
||||
}
|
||||
if a.Text != e.Text {
|
||||
t.Errorf("segment %d: text mismatch: expected %q, got %q", i, e.Text, a.Text)
|
||||
}
|
||||
if len(a.Categories) != len(e.Categories) {
|
||||
t.Errorf("segment %d: categories count mismatch: expected %d, got %d", i, len(e.Categories), len(a.Categories))
|
||||
continue
|
||||
}
|
||||
for j, cat := range a.Categories {
|
||||
if j >= len(e.Categories) || cat != e.Categories[j] {
|
||||
t.Errorf("segment %d: category %d mismatch: expected %q, got %q", i, j, e.Categories[j], cat)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user