Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/ADDING_A_SITE.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ and do it in a separate behavior-preserving commit.
| NexusPHP forks, including TJUPT | Cookie sessions match `cookie_header`, and HTML responses match the existing ports. | Page recognition and parsers for that fork, with synthetic fixtures. Forks differ, so do not assume TJUPT's pages. |
| Unit3D | Cookie-session web pages fit. | Using its token-authenticated API instead runs into the gaps below. |
| Gazelle-based trackers | Cookie sessions fit; their JSON responses need a JSON parser rather than HTML recognition. | Where an API key replaces the session cookie, the gaps below apply. |
| M-Team | Status, account, search, detail, and the signed-link metafile download are implemented in `internal/site/mteam` over the JSON API with an API key. | Bonus commands and reconciliation: the open gaps below. |
| M-Team | Status, account, search, detail, the signed-link metafile download, and live-site reconciliation are implemented in `internal/site/mteam` over the JSON API with an API key. | Bonus commands: the open gaps below. |

## Gaps for API-token sites

Expand All @@ -274,8 +274,8 @@ or a security control, so it needs its own review.
| Gap | Status | Where | What is left |
|---|---|---|---|
| Only one auth method existed | Done | `domain.AuthMethodAPIKeyHeader` (`api_key_header`); `knownAuthMethod` in `internal/site/descriptor.go` | Nothing. |
| Credential input was cookie-only | Partly done | `--api-key-stdin` and `readAPIKeyCredential` in `internal/cli` serve `site status`, `account`, `search`, and `detail`; `site metafile fetch` reads it with `readEffectfulAPIKeyCredential` | Bonus commands and `reconcile` (`--site-cookie-stdin`, the bundle's `site_cookie`) still take cookies only. |
| The CLI gated on cookies | Partly done | `siteRead` in `internal/cli/site.go`, `site detail`, and `site metafile fetch` check the method the caller chose | Three `SupportsAuth(domain.AuthMethodCookieHeader)` checks remain, in `site_bonus.go`, `site_bonus_exchange.go`, and `reconcile.go`. |
| Credential input was cookie-only | Partly done | `--api-key-stdin` and `readAPIKeyCredential` in `internal/cli` serve `site status`, `account`, `search`, and `detail`; `site metafile fetch` reads it with `readEffectfulAPIKeyCredential`; `reconcile` takes `--site-api-key-stdin`, `--site-live`, and the bundle's `site_api_key` | Bonus commands still take cookies only. |
| The CLI gated on cookies | Partly done | `siteRead` in `internal/cli/site.go`, `site detail`, `site metafile fetch`, and `reconcile` check the method the caller chose | Two `SupportsAuth(domain.AuthMethodCookieHeader)` checks remain, in `site_bonus.go` and `site_bonus_exchange.go`. |
| The transport only sent `Cookie` | Done | `httpguard.NewWithHeaderCredential` binds one validated, non-reserved header | Nothing. |
| Redaction did not know the header | Done | `security.Redact` covers `x-api-key` header lines and `apiKey`-style fields | Nothing. |
| No JSON requests | Done | `httpguard.Client.PostReadOnce`: one bounded, non-replayable POST with no redirect and no retry, covered in the threat model | Nothing for reads. Effectful API calls still need their own acknowledged port. |
Expand Down
12 changes: 7 additions & 5 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@ requests and never selected by ref, time, or enumeration. A valid historical
binding does not upgrade any storage/client/path axis and does not change the
downloader raw-metafile relation; a mismatch conflicts, while unavailable or
corrupt authority prevents overall consistency. A bare `--site-ref` remains a
non-gating declaration. Explicit `--site-cookie-stdin` makes the live detail
axis gating: failure is incomplete, while success adds only a current site
claim. With a downloader in the same invocation, one strict bounded
`--credential-bundle-stdin` object supplies both secrets so stdin is consumed
exactly once; all credential-free gates run first.
non-gating declaration. Explicit `--site-live`, `--site-cookie-stdin`, or
`--site-api-key-stdin` makes the live detail axis gating: failure is
incomplete, while success adds only a current site claim. `--site-live` reads
the credential `site login` saved, so with a downloader stdin carries only the
downloader password. Otherwise, with a downloader in the same invocation, one
strict bounded `--credential-bundle-stdin` object supplies both secrets so
stdin is consumed exactly once; all credential-free gates run first.

qBittorrent's generic `hash` is an opaque job key. The adapter derives typed
claims only from strictly bounded magnet `xt` values: BTIH is 20 bytes and
Expand Down
9 changes: 6 additions & 3 deletions docs/AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ Every later `site` command for that site, including `site metafile fetch` and
`site bonus exchange submit`, then uses the saved credential without a flag.
An agent saves one without a terminal by piping it,
`site login --cookie-stdin SITE` or `site login --api-key-stdin SITE`, and
`ptctl site logout SITE` deletes it. An explicit stdin flag below always takes
`ptctl site logout SITE` deletes it. `reconcile report` uses the saved
credential when given `--site-live`, and then reads only the downloader
password from stdin. An explicit stdin flag below always takes
precedence over the saved credential, and a saved credential never stands in
for an acknowledgement flag.

Expand All @@ -110,8 +112,9 @@ for an acknowledgement flag.
| `--cookie-stdin` | `site` reads, `site bonus exchange submit` for cookie-only sites, `site metafile fetch` for cookie sites (TJUPT) | The complete `Cookie` header value |
| `--api-key-stdin` | `site status`, `site account`, `site search`, `site detail`, and `site metafile fetch` for sites that authenticate with an API key (M-Team) | The site-issued API key |
| `--password-stdin` | `client` commands, `seed retire` commands that contact a downloader, and `reconcile` with a downloader | The downloader password |
| `--site-cookie-stdin` | `reconcile report` with a live site observation and no downloader | The complete `Cookie` header value |
| `--credential-bundle-stdin` | `reconcile report` with both a live site observation and a downloader | `{"schema":"ptctl.credentials/v1","site_cookie":"...","downloader_password":"..."}` |
| `--site-cookie-stdin` | `reconcile report` with a live site observation and no downloader, on a cookie site (TJUPT) | The complete `Cookie` header value |
| `--site-api-key-stdin` | `reconcile report` with a live site observation and no downloader, on an API-key site (M-Team) | The site-issued API key |
| `--credential-bundle-stdin` | `reconcile report` with both a live site observation and a downloader | `{"schema":"ptctl.credentials/v1","site_cookie":"...","downloader_password":"..."}`, or `site_api_key` in place of `site_cookie` |
| `--credential-bundle-stdin` | `site bonus exchange submit` for sites that confirm with the account password (TJUPT) | `{"schema":"ptctl.credentials/v1","site_cookie":"...","site_password":"..."}` |
| `--credential-bundle-stdin` | `site login` | `{"schema":"ptctl.credentials/v1","site_username":"...","site_password":"...","site_totp":"123456"}`; `site_totp` is optional |
| `--cookie-stdin`, `--api-key-stdin` | `site login` | The credential to save; one status read checks it first and nothing is saved when it fails |
Expand Down
21 changes: 14 additions & 7 deletions docs/MTEAM_ADAPTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ requested ID. `DOWNLOAD REFERENCE` is always `false`, because the API answer has
no download link to observe. An ID with no visible torrent stops as
`not_found`; the API reports it as code `1` with a fixed message, and only that
exact pair is read as not found, because the API uses code `1` for other
refusals too. Live-site reconciliation still reads site detail only with a
cookie, so it does not support M-Team yet.
refusals too. Live-site reconciliation reads the same detail, as described
in [Reconciliation](#reconciliation).

**Times.** The API returns times without a zone, such as `2026-10-14
09:30:00`. ptctl reads them as UTC+8, the site's time zone, and reports them in
Expand Down Expand Up @@ -248,13 +248,20 @@ private store instead. The file contains your passkey, so keep it private:
ptctl metafile store import --store "$PTCTL_STORE" release.torrent
```

## Not supported yet
## Reconciliation

`reconcile report --site-ref mteam/ID --site-live` adds the live detail read
to a reconciliation report with the saved API key, and reads nothing from
stdin. With a downloader in the same command, add `--password-stdin` and pipe
only the downloader password. A script that keeps the key itself pipes it with
`--site-api-key-stdin`, or, with a downloader, uses `--credential-bundle-stdin`
with `site_api_key` in place of `site_cookie`. The read is the one
`/api/torrent/detail` request above; it never asks for a signed download link.
See [Reconciliation](guide/reconcile.md).

**Reconciliation.** `reconcile` reads live site detail with a cookie only, so
`--site-ref mteam/ID` is refused. `site detail` works on its own.
## Not supported yet

**Everything else.** Bonus exchange, RSS, seeding lists, and messages are not
implemented.
Bonus exchange, RSS, seeding lists, and messages are not implemented.

## Fixtures

Expand Down
3 changes: 2 additions & 1 deletion docs/THREAT_MODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ user config directory, a plaintext file of mode `0600` in a `0700` directory,
written through an owner-only temporary file and renamed into place. Every
`site` command for that site, including metafile fetch and bonus exchange
submit, reads it when no stdin credential flag is given; an explicit flag
always wins. This is a deliberate trade: anyone who can read the file as the
always wins. `reconcile report` reads it only with an explicit `--site-live`,
after every credential-free gate has passed. This is a deliberate trade: anyone who can read the file as the
user, or any process the user runs, can act as the user on that site until the
session expires or the key is revoked. An M-Team API key does not expire on its
own, so its file is worth more than a TJUPT session cookie.
Expand Down
6 changes: 4 additions & 2 deletions docs/TJUPT_ADAPTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ may include promotion decoration; names, peer counts, size, snatches, and
links are site claims. It is not a metafile identity, proof of the site's current private
variant, a site signature, or storage-content proof, and it is not persisted.
The typed port returns opaque process-local authority. An explicitly
requested `reconcile report --site-ref tjupt/ID --site-cookie-stdin` may consume
requested `reconcile report --site-ref tjupt/ID --site-live` (or `--site-cookie-stdin`) may consume
that authority in the same invocation, but only to record that the selected
remote-ID page was observed; JSON replay cannot recreate it and it never proves
which private `.torrent` variant the site currently serves.
Expand Down Expand Up @@ -464,7 +464,9 @@ only and cannot upgrade incomplete storage/client/path axes or make the
downloader's raw private metafile observable.

When live site detail and a read-only downloader are requested together,
reconciliation requires `--credential-bundle-stdin` and accepts exactly:
`--site-live --password-stdin` uses the saved cookie and pipes only the
downloader password. Without a saved cookie, reconciliation requires
`--credential-bundle-stdin` and accepts exactly:

```json
{"schema":"ptctl.credentials/v1","site_cookie":"SID=...","downloader_password":"..."}
Expand Down
23 changes: 17 additions & 6 deletions docs/guide/reconcile.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,28 @@ metafile binding. Neither read adapter exposes the raw private metafile through
its ledger, so `metafile_variant_relation` remains `unobservable` even when
typed infohashes agree.

To observe that remote ID live without a downloader, add
`--site-cookie-stdin`. To observe both the site and a downloader in one command,
use `--credential-bundle-stdin` instead of the two single-secret flags and pipe
one bounded strict JSON object:
To observe that remote ID live without a downloader, add `--site-live`. It
uses the credential `ptctl site login SITE` saved for the site, so nothing is
read from stdin; this is the simplest form, and the one M-Team uses with its
saved API key. A script that keeps the secret itself pipes it instead, with
`--site-cookie-stdin` for a cookie site (TJUPT) or `--site-api-key-stdin` for
an API-key site (M-Team).

To observe both the site and a downloader in one command, add `--site-live`
next to `--password-stdin`: the saved site credential leaves stdin to the
downloader password. Without a saved credential, use
`--credential-bundle-stdin` instead of the two single-secret flags and pipe
one bounded strict JSON object with either `site_cookie` or `site_api_key`:

```json
{"schema":"ptctl.credentials/v1","site_cookie":"SID=...","downloader_password":"..."}
{"schema":"ptctl.credentials/v1","site_api_key":"...","downloader_password":"..."}
```

Unknown, duplicate, missing, trailing, oversized, invalid-UTF-8, and unpaired
surrogate input is rejected. All adapter capability/origin/ref, metafile,
The four site sources are mutually exclusive. A bundle with both site fields
or neither, and unknown, duplicate, missing, trailing, oversized,
invalid-UTF-8, and unpaired surrogate input, is rejected. A site credential
of a method the site does not accept is a usage error before any request. All adapter capability/origin/ref, metafile,
store, storage-profile, mapping, endpoint, and budget checks finish before this
stdin is read. The site detail request runs first. Its opaque same-invocation
authority adds only a current remote-ID site claim to `site_metafile`; the
Expand Down
Loading
Loading