Repository navigation
Commit 0fdbf88
C2 seam extraction — instance-free request/auth path for the live captcha wiring (#71)
* Extract the request/auth seam to module level for the C2 live captcha path
C1 decided what things mean; C2 is making the transport structurally capable
of carrying that decision, not making any new decisions. This commit is the
structural half only — no classification logic, no C1 semantics.
The live captcha wiring must build `submit_captcha_fn` BEFORE
MoltbookHTTPTransport exists, because the Note E fail-closed presence check
takes it as a constructor argument. It therefore cannot reach a bound method,
and `_real_request` was trapped behind an instance it does not yet have. The
factory shape was never the problem; the trapped default was.
Extraction only:
- `real_request(base_url, method, path, body, headers)` at module level,
containing `_real_request`'s prior body with ONLY the Note D comment
relocated into the docstring. No logic, HTTP semantics, redirect posture,
error handling, or timeout change.
- Deliberately no leading underscore. This module uses underscore at module
level to mean "internal, do not import" (`_collapse_letter_runs`,
`_normalize_captcha_prompt`, `_word_number_value`); one here would signal
the opposite of why it was extracted.
- `real_request` is NOT itself a `request_fn` — the seam signature is
(method, path, json_body, headers); callers partially apply the base_url.
- `auth_headers(api_key)` at module level, transport-scoped.
- `_real_request()` / `_auth_headers()` reduced to one-line delegations,
each carrying a guard comment stating that instance-specific behavior does
not belong in the wrapper.
One HTTP path, not two: the write path and the live verify path now build on
the same function, so retry/redirect/timeout posture cannot diverge between
them (C1 §5's concern).
Tests: 613 passed, 7 xfailed. Two added. The existing two `_real_request`
tests are deliberately untouched — they now cover the delegation, which is
the regression evidence that extraction changed no behaviour. The new
module-level test pins the one property they cannot: callable with no
transport instance in existence. Those two would still pass if an instance
dependency were reintroduced, because they hold an instance; this one would
not, which makes the "pure delegation" guard mechanical rather than a comment
asking the next editor to remember.
DELIBERATE DEFERRALS — recorded as policy, not omissions:
1. Redirect posture. `_real_request`/`request_fn` follow redirects via
urllib's default opener. Verified on CPython 3.12.10: on POST it redirects
for 301/302/303 only and rebuilds the Request WITHOUT `data`, so the
captcha answer body is never resubmitted and C1 §5 is not violated; 307/308
raise HTTPError and fall to C1 §4 residual, which is correct. The open
concern is classification fidelity — a followed redirect means the status
reaching the classifier may not be `/verify`'s own (a 303 landing on 404
would classify as C1-4 CONFIRMED_FAILURE, a C1 §9 stop condition, from a
response `/verify` never gave). Also note `docs/moltbook_api_spec.md` §1:
a bare-domain request triggers a redirect that STRIPS the Authorization
header, so redirect behaviour here carries a documented credential-safety
dimension too. PARKED, unresolved, not touched in this commit.
2. `moltbook/client.py:144` `_auth_header()` duplicates
`f"Bearer {api_key}"`, and its comment calls itself "the ONLY place the
key is touched", which `transport.py` has made inaccurate. The DRY helper
here is deliberately transport-scoped and does NOT consolidate it; fixing
it would reach outside C2 and ripple into
tests/test_moltbook_credential_integrity.py:196. PARKED alongside (1).
3. Test-count sync. CLAUDE.md, TODO.md and README.md all still read 611.
613 is an intermediate count inside active C2 work, not a completed state
the docs failed to follow — unlike PR #69's situation. Syncing now would
only be resynced when the classification tests land. DEFERRED by decision
to the C2-complete commit, to be synced once.
Structurally scoped throughout: no C1 decision introduced, no
`submit_captcha_fn` policy beyond making the live path authenticable, no
`TransportResult.rate_limit` change, no Note E constructor invariant touched,
no write-path behaviour changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Track the three C2 parked items as recorded decisions, not omissions
The redirect finding and the client.py auth duplication were tracked nowhere —
they existed only in the review conversation and in 203c016's commit body.
That is the state where a later reviewer has to reconstruct a deferral by
noticing a mismatch, which is what PR #69 had to do for the test counts.
Adds a new "M7 — §C / C2 parked items" subsection. Deliberately NOT filed
under "post-GO engineering debt (NOT prerequisites for GO-1)": GO-1 is
already granted, so that heading's qualifier is spent, and the redirect item
may bear on GO-2. Classifying it as post-GO would assert a readiness
decision that belongs to the operator and to
docs/m7_operator_go_checklist.md, not to this tracker — which its own
readiness-authority note at the top already says.
Three items:
1. Redirect posture — filed as open, with the verified facts separated from
the unresolved ones: C1 §5 is provably not violated (POST redirects drop
`data` on 301/302/303; 307/308 raise and fall to §4 residual), while
classification fidelity and a documented credential dimension
(moltbook_api_spec §1: bare-domain redirect strips Authorization) remain
open. Whether it gates GO-2 is explicitly not decided here.
2. client.py:144's duplicate `f"Bearer {api_key}"` and its stale "the ONLY
place the key is touched" comment — recorded with why C2's helper is
transport-scoped rather than consolidating it.
3. Test-count sync — recorded as deferred to the C2-complete commit by
decision, with the reason it differs from #69's case.
Contains no test count. Item 3 states that the documented count has moved
without restating a number, so this commit cannot itself become a stale
count needing a later correction.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 88d92b7 commit 0fdbf88
3 files changed
Lines changed: 156 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
27 | 70 | | |
28 | 71 | | |
29 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1053 | 1112 | | |
1054 | 1113 | | |
1055 | 1114 | | |
| |||
1109 | 1168 | | |
1110 | 1169 | | |
1111 | 1170 | | |
1112 | | - | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
1113 | 1175 | | |
1114 | 1176 | | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
1134 | 1182 | | |
1135 | 1183 | | |
1136 | 1184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
471 | 473 | | |
472 | 474 | | |
473 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
474 | 519 | | |
475 | 520 | | |
476 | 521 | | |
| |||
0 commit comments