Repository navigation
Description
Purpose
Implement ADR #32 by replacing the current general-purpose LDAP server/parser dependency stack with a small first-party compatibility implementation for the documented ClickHouse LDAP profiles.
This is the execution tracker for ADR #32. It is intentionally implementation-oriented and may be delivered as one or several PRs.
Architectural decisions belong in #32. If implementation discovers evidence that invalidates an architectural assumption, stop and bring that evidence back to #32 rather than silently expanding scope here.
Preconditions
- ADR ADR: Own the ClickHouse LDAP compatibility profile and remove general LDAP dependencies #32 is accepted before production cutover.
- ci: add required PR-time Go/race/security gates; keep Docker ClickHouse matrix separate #23, or an equivalent required PR-time gate, is active and enforced before production parser replacement code merges.
- Existing supported ClickHouse integration/release gates remain available during the migration.
Architectural constraints inherited from #32
The implementation MUST preserve these decisions:
- ClickHouse is the supported LDAP client; this is not a general LDAP server.
- Support is defined by documented ClickHouse compatibility profiles.
- Required operations are LDAPv3 simple Bind, the documented bounded Search shapes, Abandon as a no-response compatibility operation, and Unbind.
- Connection handling remains bounded and simple; do not recreate generic per-request scheduling, Cancel/Abandon control-plane capacity, a generic route mux, or a generic recursive filter engine.
- Authentication state is connection-local. Failed re-Bind clears prior auth state; successful re-Bind replaces it.
- JWT/password bytes are not retained after verification and must never reach logs.
- Role mapping remains a Bind-time snapshot, and Search size-limit overflow remains fail-closed rather than silently truncating roles.
- Production
ch-oauth-ldapmust no longer depend on the current general LDAP server/client/BER stack. cryptobyteis preferred for low-level ASN.1 primitives unless supported ClickHouse wire evidence demonstrates incompatibility.- If the implementation starts becoming a general LDAP parser/server, stop and revisit ADR: Own the ClickHouse LDAP compatibility profile and remove general LDAP dependencies #32.
Phase 1 — freeze evidence and select the primitive layer
1.1 Reconstruct the supported wire profile
Review the relevant supported ClickHouse source and the exact product configuration. Include OpenLDAP/libldap source where ClickHouse delegates behavior to it.
The profile evidence should cover, for every tracked ClickHouse line:
- Bind operation and LDAP version;
- Search request fields actually emitted by the supported configuration;
- scope, dereference mode, size/time limits,
typesOnly, requested attributes, controls; - filter structure and placeholder behavior;
- MessageID behavior, including 127/128 boundaries;
- Unbind;
- timeout-triggered Abandon;
- any version-specific differences that matter to the server.
Create a committed human-readable wire-profile document and non-secret raw fixtures. A suggested layout is:
docs/clickhouse-ldap-wire-profile.md
internal/ldap/testdata/clickhouse-wire/<clickhouse-line>/...
The exact layout may change if another structure is cleaner, but the evidence must be committed and testable rather than existing only in notes or packet captures outside the repository.
Add a contract test so the documented supported ClickHouse lines cannot silently drift away from the committed fixture set, following the same anti-drift principle already used by internal/securitytest/docs_contract_test.go.
1.2 Resolve cryptobyte vs local BER primitives
OpenLDAP currently initializes request BER with:
ld->ld_lberoptions = LBER_USE_DER
This is a strong prior that ClickHouse/libldap request encodings will be accepted by DER-oriented golang.org/x/crypto/cryptobyte helpers.
Prototype every supported raw request fixture through cryptobyte.
Decision rule:
all supported fixtures accepted safely
-> use cryptobyte + first-party LDAP profile
any valid supported fixture requires a BER form cryptobyte rejects
-> use a tiny bounded first-party BER cursor
Do not introduce another general-purpose ASN.1/BER packet-tree library as a substitute for the dependencies being removed.
1.3 Record baselines
Before replacement work changes the tree, record:
go list -deps ./cmd/ch-oauth-ldap;- current production LDAP LOC and the exact counting method;
- current redaction/security inventory relevant to
internal/ldapand the vendored forks; - current supported ClickHouse matrix results.
Phase 2 — implement the compatibility profile
Keep the implementation under the existing internal/ldap ownership boundary unless a package split has a concrete security/readability benefit.
2.1 Connection/framing model
Target model:
accept loop
-> one goroutine per admitted connection
-> read one bounded request
-> process synchronously
-> write bounded response
-> repeat
Preserve or improve the current resource bounds:
- maximum admitted connections: 256;
- maximum LDAP message body: 64 KiB before body allocation;
- read deadline: 30 s;
- write deadline: 30 s.
The named pre-authentication message-body budget remains:
256 * 64 KiB = 16 MiB
This is a body-buffer bound, not a total RSS claim. Avoid proportional duplicate copies of attacker-controlled message bodies.
2.2 Supported operations
Implement only the supported profile:
- LDAPv3 simple Bind;
- documented Search shapes;
- AbandonRequest recognition/drop with no response;
- Unbind/close;
- re-Bind semantics already described above.
Malformed framing should close the connection.
For a recognizable but unsupported LDAP operation, a single small protocol-correct error response is acceptable only if it can be emitted using common envelope/result primitives without adding operation-specific decoding. If diagnostics start expanding the decoder, close the connection instead.
Unsupported operations must never invoke OAuth verification or role logic.
2.3 Search/filter handling
Do not build a generic LDAP filter AST/evaluator.
For the current role-mapping profile, decode and validate the structural equivalent of:
AND
├── objectClass == groupOfNames
└── member == currentBoundDN
Either child order is acceptable. Reject missing, duplicate, additional, or different predicates.
Honor the supported Search fields exactly as reconstructed from ClickHouse/libldap evidence.
Preserve size-limit behavior: emit at most N eligible entries, and if another valid role exists return sizeLimitExceeded so ClickHouse does not accept a silently truncated role set.
2.4 DN ownership and the {bind_dn} pipeline
Remove production dependence on github.com/go-ldap/ldap/v3.
Implement only the DN grammar required by documented ClickHouse profiles. Do not claim arbitrary RFC 4514 normalization compatibility.
Preserve the important ClickHouse/libldap escaping pipeline:
username
-> ClickHouse escapeForDN
-> bind DN string
-> ClickHouse escapeForFilter
-> libldap parses RFC 4515 filter escapes
-> BER equalityMatch assertionValue contains DN text
-> server decodes restricted DN form
-> structural comparison with authenticated BoundDN
Example:
username: a,b
Bind DN text: uid=a\,b,ou=users,...
ClickHouse filter text: member=uid=a\5C,b,ou=users,...
BER assertion value: uid=a\,b,ou=users,...
The server therefore must not add a general RFC 4515 filter-text unescaper; that transformation has already happened inside libldap before transmission.
Required DN behavior includes:
- validate configured bases at startup;
- require the supported leading user RDN shape;
- reject unsupported multi-valued RDNs unless later requirements explicitly add them;
- reject malformed DN escapes;
- avoid loose suffix/string-split authorization checks;
- preserve exact successful BoundDN for connection state;
- compare Search membership DN structurally under the supported grammar;
- safely escape synthetic group-entry CN values.
2.5 Result encoding
Implement only the response forms needed by the supported profile:
- BindResponse;
- SearchResultEntry;
- SearchResultDone;
- the minimal common error result needed by the chosen unsupported-operation policy.
MessageID must round-trip exactly, including values >= 128.
Phase 2 testing
Adapt the existing black-box TCP tests rather than recreating tests for generic machinery that is being deliberately removed.
Delete tests coupled to concepts that no longer exist, such as generic route handling, broad critical-control dispatch, request maps, Cancel scheduling, or generic recursive filter parsing.
Add native Go fuzzing for the new parser/security boundary. Suggested targets include:
FuzzLDAPFrame
FuzzBindRequest
FuzzSearchRequest
FuzzRestrictedDN
FuzzMemberAssertionDN
Exact target names may change; the required coverage does not.
Seeds should include:
- committed supported ClickHouse wire fixtures;
- MessageID 127/128 boundaries;
- previous fork vulnerability shapes;
- truncated and oversized lengths;
- escaped/special-character DN cases;
- equivalent and non-equivalent member DNs.
Required property:
arbitrary input results in a supported bounded response, bounded rejection, or connection close; never panic, unbounded allocation/concurrency, credential leakage, or stuck shutdown.
Temporary differential oracle
A small Phase-2-only differential harness is allowed and encouraged for profile-valid generated inputs:
same supported input
-> current decoder
-> new decoder
-> compare normalized semantic result
Use it for supported valid messages and boundary encodings only.
Do NOT require equivalence for arbitrary malformed BER, unsupported generic LDAP operations, generic filters, or behavior that exists only because of bugs/overbreadth in the old parser.
Delete the differential oracle when the old implementation/dependencies are removed in Phase 4.
Phase 3 — security, compatibility, and release gates
Before cutover, all of the following must be green on the replacement implementation:
- required PR-time CI from ci: add required PR-time Go/race/security gates; keep Docker ClickHouse matrix separate #23;
- normal Go build/vet/race tests;
phase5releasesecurity gate without weakened scope;- existing supported ClickHouse integration matrix;
- relevant HA tests;
- relevant LDAPS/TLS tests when LDAPS/TLS auth-proxy deployment mode: standalone ch-oauth-ldap on customer premises for any ClickHouse's native LDAP auth #31 is in scope;
- authentication/re-Bind/session semantics;
- role snapshot and fail-closed search-limit behavior;
- adversarial resource-bound tests;
- credential/redaction tests;
- committed wire-fixture compatibility tests;
- fuzz smoke targets.
Redaction/security inventory re-baseline
When the vendored forks are removed:
- remove vendored logger scanning only because those source files no longer exist;
- delete stale
third_partyinventory rows; - keep replacement first-party parser/server sinks AST-enumerated;
- add marker proofs for every credential-reachable local sink;
- do not weaken the
phase5releasegate merely to accommodate the rewrite.
Passing the gate must mean the new implementation is audited, not that the old inventory was simply deleted.
Dependency closure contract
Add a committed security test, suggested name:
internal/securitytest/dependency_contract_test.go
TestDependencyContract_ProductionClosureHasNoGeneralLDAP
It must inspect the actual production closure (go list -deps ./cmd/ch-oauth-ldap) and fail if it contains:
github.com/vjeantet/ldapserver
github.com/vjeantet/goldap
github.com/go-ldap/ldap/v3
github.com/go-asn1-ber/asn1-ber
github.com/Azure/go-ntlmssp
or if the contract check becomes vacuous.
If another general-purpose LDAP server/client or generic BER tree library is introduced under a different module name, extend the contract/review accordingly rather than treating the literal denylist as exhaustive policy.
LOC/scope guardrail
Count all non-test production Go code under the LDAP implementation reachable from ./cmd/ch-oauth-ldap, excluding independent TLS transport plumbing introduced specifically for #31.
Expected post-rewrite landing zone is approximately 2,000–2,500 LOC.
If the implementation grows beyond approximately 3,500 LOC before independent TLS plumbing, pause for architecture review. This is a scope-creep indicator, not a claim that LOC itself measures security.
Phase 4 — cut over and delete the old stack
Only after Phase 3 is green:
- switch the production command to the new implementation;
- remove the vendored
third_party/ldapserverandthird_party/goldapcode; - remove their
replacedirectives; - remove production
go-ldapusage; - verify
go-asn1-berandgo-ntlmsspdisappear from the production command closure unless another unrelated production dependency genuinely requires them; - keep any independent LDAP client used for black-box testing test-only and outside the released command closure;
- delete the temporary differential oracle and tests for machinery that no longer exists;
- rerun all PR/security/ClickHouse/release gates.
The cutover and dependency deletion should be one coherent final migration step so the repository does not permanently carry two production LDAP parsers.
Rollback
Do not add a permanent runtime switch between old and new parsers; that would retain both attack surfaces and dependency trees.
Rollback is operational/source-level:
revert the cutover change
or
redeploy the previous known-good release
Keep the immediately previous release/artifact available according to normal release practice until the replacement has proven stable.
Suggested PR slicing
Agents may implement this as one PR or several. A reasonable split is:
- evidence + committed fixtures + primitive-layer decision;
- new parser/profile implementation + tests/fuzz/differential harness while old production path remains active;
- security/dependency/redaction gates and full compatibility validation;
- production cutover + deletion of old forks/dependencies.
This is guidance, not an architectural requirement. Smaller or combined PRs are acceptable if reviewability and rollback remain clear.
Definition of done
- ADR: Own the ClickHouse LDAP compatibility profile and remove general LDAP dependencies #32 is accepted.
- ci: add required PR-time Go/race/security gates; keep Docker ClickHouse matrix separate #23/equivalent required PR-time gate is active before production parser replacement merges.
- Supported ClickHouse/libldap behavior is documented from source and committed non-secret wire evidence.
-
cryptobyteis selected or rejected based on those fixtures, with the result recorded. - First-party bounded Bind/Search/Abandon/Unbind profile is implemented.
- Restricted DN handling replaces production
go-ldapusage and preserves the{bind_dn}security semantics. - Existing auth/session/role semantics remain unchanged.
- Size-limit overflow remains fail-closed.
- Resource invariants remain at least as strong as 256 connections / 64 KiB body / 30 s read-write deadlines.
- Native fuzzing and malformed-input/resource tests cover the new parser boundary.
- Redaction inventory and
phase5releasegate are re-baselined without weakening coverage. - Production dependency-closure contract is committed and enforced in CI.
- Supported ClickHouse matrix and relevant HA/TLS gates pass on the replacement.
- Production LDAP implementation remains comfortably below the ~3,500 LOC architecture-review trigger, or a review explicitly accepts the exception.
- Old LDAP forks/replaces and production
go-ldapusage are deleted. - Temporary differential machinery is deleted at cutover.
- Rollback procedure is documented as revert/redeploy, not a permanent dual-parser mode.
Related: #32 (ADR), #23 (required PR CI), #30 (ClickHouse version compatibility), #31 (LDAPS/TLS deployment mode), #19 (original implementation).
Activity
BorisTyshkevich commentedon Aug 30, 2026
Prerequisite satisfied — the PR-time gate from #23 is active and enforced
#23 shipped in PR #34 (merge commit
e9c7c3c). This issue's gating precondition requiredthree things, and all three now hold:
.github/workflows/pr-gate.yml, workflowPR gate, one jobRequired PR gate, runninggo build ./...,go vet ./...,go test -race ./...,go test -tags phase5release ./internal/securitytest -count=1, andbash integration/clickhouse/tests/lib-tests.shon every pull request and every pushto
main, with no path filters;push-event run observed onmain— run 33283876015at
e9c7c3c, all five steps green;mainis protected, required context is exactlyRequired PR gatebound to thegithub-actionsapp (id15368, observed rather thanguessed),
strict: true,enforce_admins: true, no review requirement. Read backfresh from the API; the full table is in ci: add required PR-time Go/race/security gates; keep Docker ClickHouse matrix separate #23's body.
Phase 2 parser-replacement work here is no longer blocked on CI enforcement.
Three things from #23 worth folding into this issue's plan
1.
go test -race ./...does not reach the vendored LDAP forks — and that is where theparser you are replacing lives.
third_party/goldapandthird_party/ldapserverareseparate Go modules consumed by the root
go.modonly throughreplacedirectives, so theroot module pattern never compiles their test suites. #23's issue text was corrected to say
this explicitly. Consequence: parser tests intended to be gated must live inside the root
module, or this issue must add a command for those modules to
pr-gate.yml. A test thatlives only under
third_party/**is not gated by anything today.Related and pre-existing:
third_party/ldapserver's own suite cannot currently runstandalone at all —
go test ./...there fails withmissing go.sum entry for module providing package github.com/vjeantet/goldap/message. Its six test files(
cancel_test.go,client_close_test.go,client_test.go,e2e_test.go,packet_test.go,server_test.go) are effectively unrunnable. Worth fixing if this issueplans to keep any tests there.
2. The planned
TestDependencyContract_ProductionClosureHasNoGeneralLDAPwill be pickedup automatically. The gate names the whole
./internal/securitytestpackage with-count=1and no-runfilter or allowlist, so a new tagged or untagged contract testthere enters the gate with no workflow edit. This was proven during #23: a newly added
fatal test turned the required command red with zero workflow change.
3. The gate is not tamper-resistant, by design — do not lean on it as one. A pull
request runs its own copy of the workflow, and a job skipped by a job-level conditional
reports Success to branch protection. So it enforces process for trusted maintainers and
catches ordinary regressions, but an authorized author can neutralize both the workflow and
its self-test in the same PR.
internal/securitytest/pr_gate_contract_test.gois anaccidental-drift detector and says so in its own doc comment. If this issue's threat model
needs more than that, the mechanism is an organization-level required-workflow ruleset
sourced outside this repository, not more in-repo tests.
Also note two operational constraints recorded in the workflow itself: repository
automation must not retarget a pull request's base using
GITHUB_TOKEN(that producesno gate run, leaves the head SHA unchanged, and can let a prior green check stand — a real
fail-open), and if a merge queue is ever enabled, the workflow needs a
merge_group:trigger or queue entries stall waiting for a check that is never reported.
Full detail, including every review finding and the complete run ledger, is in #23's
ship log.
BorisTyshkevich commentedon Aug 30, 2026
Ship log — #33
Phase 1 — handoff
Status: Accepted;Required PR gateis the required status check onmain(strict:true).feat/33-phase1-wire-profileofforigin/main@ e9c7c3c):docs/clickhouse-ldap-wire-profile.md(source-reconstructed profile for 24.8.11.51285 / 25.8.28.10001 altinitystable incl. per-line commit + blob SHAs andcontrib/openldappins 2.5.16 / 2.6.10; decision marker<!-- ldap-primitive-decision: … -->); committed non-secret fixturesinternal/ldap/testdata/clickhouse-wire/{24.8,25.8}/{success,timeout-abandon}+constructed/message-id-boundary(127 →02 01 7f, 128 →02 02 00 80);internal/wirefixture(schema,Stable*projections, constructed builder, config-element hash);integration/clickhouse/wire 8 capture< 10BC8 /code> (ldap-wire-recorder: serve/sanitize/construct/compare) +compose-wirecapture.yml+capture-ldap-wire.sh --mode generate|verify+ reciprocalch-wirecap*preflights inrun.sh/run-ha.sh+ 3 daemon-free shell cases;internal/securitytest/{wire_profile_contract_test.go,dependency_contract_test.go}+ redactionscopeDirsextended to both new packages; baselines ininternal/ldap/testdata/phase1-baseline/(production deps, LOC 8614 via committed script, security inventory, ClickHouse matrix, source head, toolchain). Productioncmd/ch-oauth-ldap, non-testinternal/ldap,third_party/**are byte-identical tomain.TestClickHouseWireCryptobyteDecision(internal/ldap/clickhouse_wire_cryptobyte_test.go) as the single computational owner of the doc marker — every committed fixture parses throughgolang.org/x/crypto/cryptobyte(DER-form checks: definite minimal lengths, minimal INTEGER incl.00 80for 128, context tags).golang.org/x/cryptomoved indirect → direct ingo.modfor that test only;TestDependencyContract_NoNonStandardCryptobyteproves it is outside the production closure. Phase 2 should read the marker value from the doc rather than this log.REVISE, blocker: none; human ruled "approve with the 7 pass-5 findings as binding amendments" (recorded in the plan's## Coordinator-approved amendments (binding); precedent Implement LDAP OAuth helper for ephemeral ClickHouse users and dynamic roles #19 phase 4). Conversation: https://chatgpt.com/c/6a93ea5b-fafc-83eb-ac9c-58a499894698sanitizevia stdin only; onlysanitized/is exported; host-sidelib/leakscan.shruns over transcript/diagnostics/service logs/export while the token is live; Bind password bytes are replaced by a length-preservingxrun. Committed corpus contains no JWT-shaped bytes (scanner test).wirefixture.BuildConstructedSimpleBind, labelled as such, and must regenerate byte-identically (TestWireProfileContract_ConstructedMessageIDFixturesReproduce).LDAP_TIMEOUTin synchronous search); the recorder'sstall-after-bindmode only withholds the Search result — it never fabricates an Abandon.session.jsoncarriestoken_claim_recipe(wirefixture.FixedTokenClaimRecipe) and per-PDUexpected_semantics; both are stable-compared fields, so verify-mode also pins the minted claim set.docs/clickhouse-ldap-wire-profile.mdis engineering evidence owned bywire_profile_contract_test.go, deliberately not a third operator document underdocs_contract_test.go(no config fences allowed in it)./shipscript, fixed ine4da1ea chore(ship), which rides in this PR as tooling).integration/clickhouse/ha/session-probe(pre-existing credential-handling integration tool) stays outside redactionscopeDirs; recorded, not claimed.cryptobyteselected/rejected with result recorded" → Phases 2–4. Phase 3's dependency-closure contract now has a live predecessor (dependency_contract_test.go+internal/securitytest/testdata/production-nonstdlib-deps.txt) that Phase 4's cutover must update, not delete.capture-ldap-wire.sh --mode verify→ all four captured sessionscompare OK, leak scans clean, noch-wirecapleftovers;run-all-builds.sh→ both tracked images PASS =clickhouse-matrix.tsv.731bbb6/92b21b7); security review: no findings.edebb6d(merged head3240069),Required PR gategreen at every pushed head (92b21b7,ceb674e,3e8d4ea,3240069). Code review: 3 formalpr-mode passes, none certifying on its own — pass 1 (head92b21b7, feat(#33): freeze ClickHouse LDAP wire evidence and select the primitive layer (phase 1) #37 (comment)): 6 findings, 4 accepted+fixed (f70d340: derefAliases/Controls documented;FixedTokenClaimRecipegroups=→roles=+ independent derivation from synthetic-IdP source; TLS setter table corrected; cryptobyte decision test dual-outcome-reachable), 2 rejected (40-char scanner print — taken anyway as hardening inceb674e; bundledchore(ship)commit — disclosed, kept); pass 2 (headceb674e, feat(#33): freeze ClickHouse LDAP wire evidence and select the primitive layer (phase 1) #37 (comment)): 3 findings, 2 accepted+fixed (3e8d4ea: independent goldap well-formedness decode gates the local-BER-cursor fallback + discriminating sabotage test; derefAliases/Controls machine-checked against raw fixture bytes), 1 carried rebuttal; pass 3 (head3e8d4ea, feat(#33): freeze ClickHouse LDAP wire evidence and select the primitive layer (phase 1) #37 (review)): 3 findings, 1 accepted+fixed (3240069: Search filter of every captured session tied structurally to AND(objectClass=groupOfNames, member=<that session's decoded Bind DN>) + AND→OR sabotage test), 2 rejected (sandbox disclosure; scope note). Certified via the mandatory post-cap architecture consultation (VERDICT: SHIP,reported_reviewed_sha=3240069, same conversation https://chatgpt.com/c/6a93ea5b-fafc-83eb-ac9c-58a499894698): "the architecture is sound; the three passes exposed insufficiently discriminating evidence checks, not evidence that the compatibility-profile premise is wrong"; no plan change needed. Unresolved findings: none.internal/ldap/clickhouse_wire_cryptobyte_test.goandinternal/securitytest/wire_profile_contract_test.gonow import the vendoredthird_party/goldap/messageas the independent second decoder (test-only). Deleting the fork in Phase 4 must replace that oracle (e.g. with the Phase 2 first-party decoder or a bounded test-only cursor) — do not silently drop the well-formedness/filter-structure checks.Phase 2 — handoff
feat/33-phase2-compat-profileofforigin/main@ edebb6d (Phase 1 merge).REVISE, blocker: none (7 specificity findings). Conversation: https://chatgpt.com/c/6a945528-4f08-83eb-87e8-0f23e2bd086e## Coordinator-approved amendments (binding)): add the 64 KiB response cap (adminLimitExceeded) and the startupUserRDNAttributedescriptor regex to the Phase 3 acceptance list of deliberate narrowings; Bind auth choice[3] sasl → result 7, any other tag → close, out-of-range ENUMERATED scope/deref → malformed/close vs!=0 → 50disambiguated; closedreason=log vocabulary enumerated, legacy literals preserved byte-identically, AST-enforced likediagnostic;go vet -tags phase5release ./internal/securitytestin the validation list; Phase 4 disposition names invertingTestDependencyContract_ProfileImplementationIsNotProduction, flippingNoNonStandardCryptobyte, regeneratingproduction-nonstdlib-deps.txt; Abandon[APPLICATION 16] IMPLICITinteger read under the application tag then validated by the shared minimal-positive-INTEGER rule; test-fake ownership resolved without a non-testtestsupportpackage.internal/ldap/profile(cryptobyte primitives; outside thecmd/ch-oauth-ldapclosure until Phase 4 cutover; no runtime switch), per-file LOC guardrail table, differential oracle vs vendored goldap (Phase-2-only), fuzz targets seeded frominternal/wirefixture. Risk High, Large → decompose-and-implement loop.feat/33-phase2-compat-profileofforigin/main@ edebb6d, headd273414): dormant packageinternal/ldap/profile(framing/envelope/Controls on cryptobyte, restricted DN grammar, Bind + re-Bind state machine, fixed-shape Search with fail-closed size limit, Abandon/Unbind, encoders with exact ≥128 MessageID round-trip, closed reason/diagnostic log vocabularies, 2,659 physical production LOC measured perwc -lover the 11 non-test files); both-backend real-TCP compat tests; differential oracle vs vendored goldap (Phase-2-only); wire replay of the whole committed corpus; 5 fuzz targets seeded from it; dependency contracts (profile+cryptobyte absent from production closure; profile closure requires cryptobyte, forbids general-LDAP modules); AST architecture contracts; redaction inventory extended. Productioncmd/, legacy non-testinternal/ldap,third_party/**,go.moduntouched.config.go/doc.go; well below ADR ADR: Own the ClickHouse LDAP compatibility profile and remove general LDAP dependencies #32's ~3,500 architecture-review trigger; consolidation review folds into Phase 4's deletion. Recorded indocs/clickhouse-ldap-wire-profile.md§11.1.adminLimitExceeded,UserRDNAttributestartup regex, version-0-closes decode note).d273414: write-stall vstimeLimitExceededclassification, DN-error input-byte stripping (redaction rows updated), ASCII-only wire descriptor folding, narrowing/LOC records. Security review: no findings ≥0.7 (deliberate parity noted: token expiry not re-evaluated mid-connection, matches legacy).TestDependencyContract_ProfileImplementationIsNotProduction; flipTestDependencyContract_NoNonStandardCryptobyte; regenerateinternal/securitytest/testdata/production-nonstdlib-deps.txt; deletedifferential_test.go; transform compat tests; replace the test-only goldap oracles (also the Phase 1 ones inclickhouse_wire_cryptobyte_test.go/wire_profile_contract_test.go).d273414, feat(#33): first-party ClickHouse LDAP compatibility profile as dormant internal/ldap/profile (phase 2) #38 (comment) — comment landed despite a null return field): 3 findings, 2 accepted+fixed (ba8862d: AST guards extended to inferred make()/method-value shapes; CLAUDE.md closure claim scoped, §11.4 decoder roles un-swapped, Bind version ≥128 delta recorded), 1 rejected (SASL-before-version ordering — legacy also never reads version on non-simple; coverage cell added later). Pass 2 (headba8862d, #issuecomment-5471642821 sibling): 5 findings, 4 accepted+fixed (1dbaa59: streamed pre-auth AttributeSelection + allocation regression test; size/time-limit precedence reordered to legacy loop order with simultaneous-limit tests; remaining inferred map/chan forms; v2×SASL coverage), 1 rejected (modifydncasing — closed lowercase op vocabulary). Pass 3 (head1dbaa59, #issuecomment-5471745093): 2 accepted+fixed (685fdf0: var-composite-literal/result-type detection; transitive-alias/interface-parameter closure), 1 rejected (simultaneous-limit two-backend seam — poor complexity-to-assurance return, later endorsed by the consultation). Post-cap architecture consultation (same conversation,reported_reviewed_sha=685fdf0):VERDICT: REVISEwith a single concern — the AST-only checker cannot exhaustively establish the four type-semantic invariants it advertised as mechanical; no remaining runtime/parser concern; plan needs no architectural change.go/types(stdlib export-data importer viago list -deps -export -json,go.moduntouched), keep syntactic invariants AST-based, reconcile every "exhaustive/mechanical" claim; then re-certify in a freshpr-mode session continuing the same conversation (sanctioned continuation per review-loops.md). Fallback if type-checking proves infeasible: downgrade the checker claim to heuristic drift detection + mandatory Phase 3 typed-check gate item.e26e30f(merged headb62c1c2),Required PR gategreen at every pushed head. Session 1 (3 passes, headsd273414→ba8862d→1dbaa59→685fdf0): 11 findings, 8 accepted+fixed, 3 rejected with recorded rebuttals. First post-cap consultation:REVISE— sole concern the AST checker's exhaustiveness claim; no runtime/parser concern. Coordinator ruling: type-aware rewrite (landedf3bf13b: go/types over stdlib export-data importer,go.moduntouched; AST file keeps only syntactic invariants). Session 2 (fresh 3-pass budget, same conversation, headsf3bf13b→aef938b→78570aa→b62c1c2): 6 findings, all accepted+fixed — every one a soundness refinement of the new checker (TypeParam/Union terms; generic NamedTypeArgs(); direct-call kind for the Verify/Roles singleton) or doc/PR-description staleness; zero runtime findings across 6 formal passes + 2 consultations. Second post-cap consultation: recommendation "proceed with the current implementation architecture atb62c1c2; do not turn selection enumeration into whole-program reachability analysis" — verdict line initially missing (fail-closed), explicitVERDICT: SHIPobtained in the same session (reported_reviewed_sha=b62c1c2). Certified via post-cap consultation, conversation https://chatgpt.com/c/6a945528-4f08-83eb-87e8-0f23e2bd086e. Unresolved findings: none.Phase 3 — handoff (in progress)
feat/33-phase3-gatesofforigin/main@ e26e30f (Phase 2 merge).6040290): temporaryphase3profilecompile-time seam incmd/ch-oauth-ldap(ldap_backend_legacy.gosole default importer ofinternal/ldap;ldap_backend_phase3profile.gosole tagged importer ofinternal/ldap/profile; backend-neutralconfig.go; lifecycle preserved verbatim); integration image's helper build line is the tag's ONLY consumer, so the whole Docker suite exercises the replacement; untagged securitytest contracts (tagged composition compiles/tests in CI; staged general-LDAP denylist over the tagged closure with Phase 4 production flip recorded; selector contract pinning the tag to exactly one Dockerfile line and to zero occurrences in the publish path; §11.5 evidence-shape contract incl. independently recomputed certified-surface digest); evidence record (§11.1 LOC correction: merged Phase 2 baseline 2,682 @ e26e30f, Phase 3 final 2,702; §11.3 eleven-row narrowing ACCEPT disposition; §11.4a generation freeze; §11.5 Stage C evidence,tested_behavior_head e4deecd); docs sync (operator guide §8.1/§10, README, CLAUDE.md); Bind version 127/128 boundary subtest (row 1a citation now exact).6040290—run-all-builds.shboth tracked images PASS (expectations unedited);run-ha.shPASS (all Docker HA claims, leak scans clean);capture-ldap-wire.sh --mode verifyPASS ×4 sessions, Search-precedes-Abandon confirmed; fuzz smoke 5×20 s PASS, no crashers; no Docker leftovers; tree unchanged. Raw logs retained at/Users/altinity/tmp/p3-attest/.6040290; nit: tagged_test.gofiles sit outside every CI compile path — documented residual, carried below). Security review: no findings ≥0.7 (sub-threshold notes: no untagged type-assertion onnewLDAPServer;deterministicGoListEnvdoesn't pinGOFLAGS— both fail closed).phase3profileseam (both adapter files, tagged tests, the Dockerfile tag) at cutover; flip the staged denylist to the production closure and regenerateinternal/securitytest/testdata/production-nonstdlib-deps.txt; note the tagged test files' CI-compile residual disappears with the seam.6040290, feat(#33): certify the replacement against all release gates via a temporary phase3profile integration tag (phase 3) #39 (comment)): 3 findings accepted+fixed (0bd5564: untagged backstop RUNS the tagged command tests; selector bounds total helper-build lines and/out/ch-oauth-ldapwriters; §11.5 table extractor anchored to its subsection). Pass 2 (head0bd5564): 2 accepted+fixed (73452c9: compound-single-RUN artifact-writer decomposition incl. go install/cp/mv/redirects; exact runtime-COPY tuple; Phase 4 handoff lists gain…CommandTests). Pass 3 (head73452c9, #issuecomment-5473427481): 2 accepted+fixed (9b5396c:GOBIN=… go installwriter form; CLAUDE.md tagged-gate prose sync). Post-cap consultation (reported_reviewed_sha=9b5396c):VERDICT: REVISE— single required change: selector must also rejectCOPY/ADDinstructions writing/out/ch-oauth-ldap(first-class Dockerfile writers, not shell tricks); explicitly: no architectural change needed, staged-closure interpretation correct, retaining the6040290Docker attestation defensible (later commits are contracts/docs only), and simplify rather than generalize the selector. Coordinator ruling (standing authorization): apply the surgical COPY/ADD fix, then re-certify in a freshpr-mode session continuing the same conversation.88c96bb(merged headc9547db),Required PR gategreen at every pushed head. Session 1 (3 passes, heads6040290→0bd5564→73452c9→9b5396c): 8 findings, all accepted+fixed. Post-cap consultation:REVISEwith one required change (COPY/ADD writer hole); explicitly no architectural change, staged-closure interpretation endorsed,6040290Docker attestation retention endorsed. Coordinator ruling: surgical fix (6f98cff) + fresh session. Session 2 (heads6f98cff→a87795a→c9547db): pass 1 — 3 accepted+fixed (JSON-array COPY/ADD; denylist cardinality guard; PR-body attestation SHA named); pass 2 — 1 accepted+fixed (directory-destination cp/mv + trailing-slash GOBIN normalization); pass 3 —certified-pending-proofsatc9547db(the run's first formal certification; no findings), feat(#33): certify the replacement against all release gates via a temporary phase3profile integration tag (phase 3) #39 (comment). Unresolved findings: none. Conversation: https://chatgpt.com/c/6a94c8b3-a2c4-83eb-a64b-a8fa06cec23ccmd/ch-oauth-ldap's default build tointernal/ldap/profileand delete thephase3profileseam (both adapter files, tagged test files become untagged, the integration Dockerfile tag,TestDependencyContract_Phase3ReplacementCommandBuilds+…CommandTests, the wholephase3_selector_contract_test.go); removethird_party/goldap+third_party/ldapserver+ theirreplacedirectives and productiongo-ldap/go-asn1-ber/go-ntlmssp; flipTestDependencyContract_ProductionClosureHasNoGeneralLDAPtopostPhase4and regenerateinternal/securitytest/testdata/production-nonstdlib-deps.txt; invertTestDependencyContract_ProfileImplementationIsNotProduction, flipTestDependencyContract_NoNonStandardCryptobyte; replace the test-only goldap oracles (clickhouse_wire_cryptobyte_test.go'sindependentlyWellFormedBER,wire_profile_contract_test.go's decode legs, the differential harness — deletedifferential_test.go); transformprofile_compat_test.go(legacy backend gone); delete legacyinternal/ldapand its tests; redaction-inventory re-baseline (dropthird_partyrows because the files no longer exist, keep profile rows); docs/CLAUDE.md sync; rerun all gates incl. Docker matrix/HA/wire-verify on the now-default replacement; rollback = revert/redeploy, no dual-parser mode.Phase 4 — handoff (in progress)
feat/33-phase4-cutoverofforigin/main@ 88c96bb (Phase 3 merge).0ccbd43): defaultcmd/ch-oauth-ldapnow constructsinternal/ldap/profile.Server(ldap_backend.go= the Phase-3-certified adapter minus the tag);third_party/goldap+third_party/ldapserver+replacedirectives, legacyinternal/ldappackage, productiongo-ldap/go-asn1-ber/go-ntlmsspall deleted (−28,994 lines;go mod tidyno-op); oracles replaced not dropped (Oracle A bounded cursor in the relocated primitive-decision test; Oracle B independent semantic cursor inwire_oracle_b_test.go); differential + compat harnesses deleted after transplant audit; raw-PDU TCP client + raw net.Conn HA probe replace all go-ldap usage; contracts inverted (ProductionClosureHasNoGeneralLDAPunconditional — the stage enum deleted outright, stronger than the plannedpostPhase4flip;ProfileIsProductionImplementation; cryptobyte-required;production-nonstdlib-deps.txtregenerated, 40 entries, reviewer-recomputed exact) plus new root test-graph + go.mod-metadata denylists andch_oauth_ldap_build_contract_test.go(retired selector may never reappear in the build/publish path); §11.5 historicalized, §11.6 Phase 4 evidence added (final LOC 2757 = profile 2693 + adapter 64, reviewer-recomputed exact); redaction inventory re-baselined (26 legacy + 22 fork + 3 adapter rows removed with their files, 1 adapter row added, profile rows untouched); docs synced; fuzz targets relocated with the package.76e8bcc(every later commit is comment/doc/test-only; §11.6 records the digest refresh honestly):run-all-builds.shboth tracked images PASS;run-ha.shPASS (leak scans clean);capture-ldap-wire.sh --mode verifyPASS ×4; fuzz 5×20 s PASS. Logs at/Users/altinity/tmp/p4-attest/.0ccbd43; stalethird_party/**publish-workflow path-filter pair deferred to new issue ci: drop stale third_party/** path filter from build-ch-oauth-ldap.yml (+ helm assertion pair) #40). Security review: no findings ≥0.7 (cutover parity logic-identical; every deleted legacy security suite has a profile owner; oracles strictly stricter; contracts non-vacuous).c2902fc(merged head154b8ab) — issue Implement ADR #32: replace general LDAP stack with ClickHouse compatibility profile #33 closed by this merge. Code review (one session, conversation https://chatgpt.com/c/6a9504f8-4c90-83eb-9e5c-ee1e9a5e6416): pass 1 (head0ccbd43, #issuecomment-5475047580) — 1 finding rejected with evidence (the §11.6 digest refresh was a disclosed comment-only update); pass 2 (#issuecomment-5475116061) — 1 accepted+fixed (25089e0: digest mechanically bound totested_behavior_headvia git-object reads + reachability check; head advanced to the digest's true commit); pass 3 (#issuecomment-5475273487) — 2 accepted+fixed (154b8ab:fetch-depth: 0on the PR gate's checkout + gate-contract pin, fixing the one red CI run of the entire issue — run 33368931796, shallow clone couldn't resolve the recorded head; §11.6 gains a distinctmanual_verification_head(3c12ab7) and the attestation sentence names it). Certified via the post-cap architecture consultation ("I would merge feat(#33): cut production over to internal/ldap/profile and delete the general LDAP stack (phase 4) #41 once the normal merge conditions are satisfied, update the Implement ADR #32: replace general LDAP stack with ClickHouse compatibility profile #33 ship log to the actual merged SHA, and close Implement ADR #32: replace general LDAP stack with ClickHouse compatibility profile #33"; explicitVERDICT: SHIPobtained in the same session after the verdict line was initially omitted; evaluated head154b8abnamed in the response). Unresolved findings: none. Follow-up filed during review: ci: drop stale third_party/** path filter from build-ch-oauth-ldap.yml (+ helm assertion pair) #40 (stalethird_party/**publish path filter + helm assertion pair). Consultation's open suggestion for the maintainer: decide whether §11.6 remains a permanent live recertification gate or becomes frozen historical evidence like §11.5.test(#33): refuse to start normal/HA fixtures while ch-wirecap resour…
test(#33): record historical ClickHouse acceptance matrix baseline
chore(#33): record immutable phase-1 baselines
feat(#33): add internal/wirefixture shared fixture schema and constru…
merge: baseline-snapshots (#33)
merge: baseline-clickhouse-matrix (#33)
merge: wirefixture-package (#33)
merge: harness-collision-preflights (#33)
test(#33): add live production dependency contract
feat(#33): add ldap-wire-recorder capture tooling
merge: dependency-contract (#33)
merge: wirecapture-tool (#33)
fix(#33): reconcile wirecapture with the wirefixture schema API
80 remaining items
merge: t4-compat-transplant (#33)
merge: t5-session-probe (#33)
feat(#33): atomic production cutover to internal/ldap/profile
fix(#33): include the content edits dropped by a bad git-add pathspec
test(#33): add root test-graph and go.mod metadata module denylist co…
docs(#33): final current-state docs and comments for the phase 4 cutover
merge: t7-module-denylist (#33)
merge: t8-docs-comments (#33)
docs(#33): historicalize §11.5 framing and record §11.4's permanent o…
docs(#33): populate §11.6 Phase 4 production-cutover release-gate evi…
docs(#33): historicalize two stale goldap comments and refresh the §1…
fix(#33 phase 4): address review pass 2 findings
fix(#33 phase 4): address review pass 3 findings
Merge pull request #41 from Altinity/feat/33-phase4-cutover