NetworkReconciler
in package
The `network` namespace of a §27.6 manifest (CONTRACT.md §27.6.2, contract 1.62): what `plan` reads, and how `apply` writes the three kinds — the tenant's policy, its segments and their reply profiles — through the generated {@see NetworkApi}.
Rules this class keeps, each one the contract's:
- Reads are
GETs, walked to exhaustion (get_policy,list_segments,list_profiles), and every stated member is judged on the value as read: a profile'ssession_timeout_secsis the effective, clamped one. No hidden or stored value is compared and none is kept. - An
Updateis a full, version-conditional replacement built from the read — the stated members replace the read's, the unstated ones are carried from it, a member stated as none (PHPnullin the entity's fields) is left out of the body — sent with theversionplanread, exactly. A segment'skind,site_keyandnameare never in it. - A profile carries its segment's
version, and when this sameapplywrote the segment that is the write's response's, not the oneplanread (NetworkApplyState). - Nothing is retried, re-read or adjusted. A
409(a ConflictError with itsreason_code) or a403is the action's failure, andapplystops there.
Table of Contents
Constants
- POLICY_KEY : mixed = 'network'
- The one manifest-local key (and name) of the singleton policy.
- UNRECOGNISED_KEY : mixed = 'unrecognised_values'
- The row key holding the raw strings of open-enum members the SDK has no name for (C163-10).
Methods
- __construct() : mixed
- applyPolicy() : string
- Creates or replaces the tenant's policy, returning the tenant id (a policy has no id of its own). `replace_policy` sends the version `plan` read — `0` for a tenant that has never written one, which is the first write.
- applyProfile() : string
- Creates or replaces one segment's reply profile, returning its id (the segment's).
- applySegment() : string
- Creates or replaces one segment, returning its id and recording the write's `version`.
- readPolicy() : array<string, array<string, mixed>>
- The tenant's policy, as `get_policy` reads it (it always exists: the default until the tenant first writes one).
- readProfiles() : array<string, array<string, mixed>>
- Every reply profile of the tenant, walked to exhaustion and matched to its segment by `segment_id`. Each row also carries `id` (the segment's, which is the profile's address).
- readSegments() : array<string, array<string, mixed>>
- Every segment of the tenant, walked to exhaustion.
- segmentKey() : string
- The identity of a segment: site + kind + name, `kind` in its WIRE spelling.
Constants
POLICY_KEY
The one manifest-local key (and name) of the singleton policy.
public
mixed
POLICY_KEY
= 'network'
UNRECOGNISED_KEY
The row key holding the raw strings of open-enum members the SDK has no name for (C163-10).
public
mixed
UNRECOGNISED_KEY
= 'unrecognised_values'
Methods
__construct()
public
__construct(NetworkApi $network) : mixed
Parameters
- $network : NetworkApi
-
The generated namespace handle the reads and writes go through.
applyPolicy()
Creates or replaces the tenant's policy, returning the tenant id (a policy has no id of its own). `replace_policy` sends the version `plan` read — `0` for a tenant that has never written one, which is the first write.
public
applyPolicy(array<string, mixed> $fields, NetworkApplyState $state) : string
Parameters
- $fields : array<string, mixed>
-
The stated members (the whole declaration on a first write).
- $state : NetworkApplyState
Return values
stringapplyProfile()
Creates or replaces one segment's reply profile, returning its id (the segment's).
public
applyProfile(PlannedChange $change, ManifestEntity $entity, string $segmentKey, string $segmentId, NetworkApplyState $state) : string
The profile is written against its segment's newest known version
(NetworkApplyState), and a replacement also carries the profile's own version
as plan read it.
Parameters
- $change : PlannedChange
- $entity : ManifestEntity
- $segmentKey : string
-
The segment's key (self::segmentKey()).
- $segmentId : string
-
The segment's server id: read, or just returned by its write.
- $state : NetworkApplyState
Return values
stringapplySegment()
Creates or replaces one segment, returning its id and recording the write's `version`.
public
applySegment(PlannedChange $change, ManifestEntity $entity, NetworkApplyState $state) : string
Parameters
- $change : PlannedChange
- $entity : ManifestEntity
- $state : NetworkApplyState
Return values
stringreadPolicy()
The tenant's policy, as `get_policy` reads it (it always exists: the default until the tenant first writes one).
public
readPolicy() : array<string, array<string, mixed>>
Return values
array<string, array<string, mixed>> —self::POLICY_KEY => wire object
readProfiles()
Every reply profile of the tenant, walked to exhaustion and matched to its segment by `segment_id`. Each row also carries `id` (the segment's, which is the profile's address).
public
readProfiles(array<string, array<string, mixed>> $segments) : array<string, array<string, mixed>>
Parameters
- $segments : array<string, array<string, mixed>>
-
self::readSegments()'s result.
Return values
array<string, array<string, mixed>> —segment key => wire object
readSegments()
Every segment of the tenant, walked to exhaustion.
public
readSegments() : array<string, array<string, mixed>>
Return values
array<string, array<string, mixed>> —segment key => wire object
segmentKey()
The identity of a segment: site + kind + name, `kind` in its WIRE spelling.
public
static segmentKey(string $site, string $kind, string $name) : string
Encoded as JSON so that no value of the three can be confused with a delimiter: the server judges the values, and this key must not decide that two different triples are one.
Parameters
- $site : string
- $kind : string
- $name : string