fix(ui): distinguish booked traffic balances from the latest sample

go
codex 13 hours ago
parent 2b1f796766
commit c8201e11a6

@ -155,16 +155,16 @@ The primary user values are:
- the next expiry time and the unused bytes that will be forfeited then;
- last trusted observation and network-restriction state.
The read model also projects one accounting-freshness state from the same
durable pool, cursor, scan-failure and settlement-bucket evidence. User and
administrator views must use that shared state; neither may infer freshness
from browser request time. The user surface exposes only `current`, `delayed`
or `attention` plus the last confirmed timestamp. Shared quota, consumption,
balance and overage are labelled as last-confirmed values whenever newer
instance counters are still settling or require review. Per-instance RX/TX
samples remain visible as raw observations and are never relabelled as settled
pool accounting. Internal failure codes, subject identifiers and repair
details are administrator-only evidence.
Pool balances and accounting status are read in one short database snapshot.
The quota, used bytes, available balance and overage are the amounts currently
booked in the ledger. The user sees the status (`current`, `delayed` or
`attention`) and, when available, the latest sample time among live members.
That timestamp dates an observation. Historical balances cannot be inferred
from it. Per-instance RX/TX are raw observations. A live sample with unchanged
counters requires no cursor write. Deleted instances keep their unexpired paid
entitlements and outstanding final bytes are settled. Once final counters match,
the deleted member no longer contributes to sample staleness. Administrator
views also show unsettled instances and failures requiring investigation.
Lifetime or calendar-month usage is a separate statistic. It must not be
divided by the currently active quota because expired entitlements legitimately

@ -212,14 +212,19 @@ checks in enforced mode with controlled test instances:
`service_expired` or `admin_hold`;
- the user page exposes only enforced groups and never presents shadow data as
an active shared allowance;
- delayed or attention accounting is visible as a last-confirmed balance with
its confirmation time, while per-instance raw samples remain available;
- user pools, instance details and administrator lines distinguish the booked
balance from the latest live sample time, including delayed or attention states;
- pool or cursor attention prevents an untrusted automatic network restore;
- repeated lifecycle ticks neither double-charge usage nor create duplicate
network mutations;
- an Agent outage or unknown sample fails open for traffic accounting while
ordinary service expiry remains enforceable.
After deploying, review the nine shared `traffic.freshness.*` entries under
user-interface translation feedback. Publish the target languages for the
pool list and instance detail together. Translations that display a sampling
time must preserve the `{sample_time}` placeholder.
Static and local checks do not replace a controlled Agent/network acceptance
test. Record the release commit, group revision, involved instance IDs, sample
timestamps, task IDs and operation IDs.
@ -352,7 +357,10 @@ exists. If the plan is clean, execute that exact generation once:
php xcat cloudTrafficSettlementRecovery apply --plan-hash=<hash> --apply
```
Any intervening state change invalidates the hash and requires a new inspect.
The writer checks each approved action again at settlement. A changed action
stops the run with a nonzero exit code and reports completed and remaining IDs.
An inspected scan failure is cleared only after its subject has settled and
only if the same failure generation still exists. Inspect again after a partial run.
Apply uses only the ordinary bucket sealing, period reconciliation and usage
settlement interfaces. It cannot delete or rewrite an immutable ledger event,
change an entitlement balance manually, clear attention, or dispatch an Agent
@ -416,8 +424,9 @@ policy decision. Deploy it as a clean schema/code boundary:
6. Deploy the matching code and restart lifecycle. Open the administrator
task page and run its read-only health check. The “流量结算与存储” row exposes
overdue open buckets, longest accounting delay, event-identity conflicts,
unsettled and stale-cursor instances, recent accounting failures, due
compaction rows and cursor attention without exposing IDs or payloads.
unsettled instances, aging unbooked samples, live instances with stale
sampling, recent scan failures, due compaction rows and all attention
cursors without exposing IDs or payloads.
7. Keep the pool in its existing rollout state while observing at least one
complete collection, accounting, settlement-compaction and
checkpoint-compaction pass. A backlog less than one hour beyond its

@ -885,6 +885,7 @@ final class CloudPageController
'.',
''
)),
'traffic_accounting' => CloudUserPageView::trafficAccounting($pool),
'traffic_pool_name' => $accountingMode === 'pooled'
? trim((string) ($pool['name'] ?? '')) : '',
];

@ -506,6 +506,7 @@ final class CloudAdminTrafficPoolService
}
}
$staleBefore = $now - self::SAMPLE_FRESHNESS_SECONDS;
$activeInstanceCount = 0;
foreach ($activePeriods as $instanceId => $period) {
$instance = $instances[$instanceId] ?? null;
if ($instance === null || !in_array($instance->status, ['active', 'deleted'], true)) {
@ -513,6 +514,9 @@ final class CloudAdminTrafficPoolService
continue;
}
$expectsSample = CloudTrafficAccountingEvidence::expectsSample($instance->status);
if ($expectsSample) {
$activeInstanceCount++;
}
if ($expectsSample && !in_array((string) $instance->network_status, [
'active', 'blocked_traffic', 'blocked_expired',
], true)) {
@ -612,7 +616,7 @@ final class CloudAdminTrafficPoolService
'line_count' => $lineCount,
'pool_count' => count($poolById),
'period_count' => count($periodIds),
'active_instance_count' => count($activePeriods),
'active_instance_count' => $activeInstanceCount,
'blockers' => $list,
];
}

@ -180,7 +180,6 @@ final class CloudTrafficPoolFreshness
$code = 'current';
$unsettled = [];
$stale = [];
$confirmed = [];
$latestSample = 0;
$pendingEntitlement = false;
if ((string) $snapshot['state'] === 'attention') {
@ -215,11 +214,6 @@ final class CloudTrafficPoolFreshness
(int) $fact->lifetime_download_bytes, (int) $fact->lifetime_upload_bytes,
(int) $fact->accounted_download_bytes, (int) $fact->accounted_upload_bytes
);
if ($expectsSample && (int) $fact->last_observed_at > 0) {
$confirmed[] = $counters === 'settled'
? max((int) $fact->traffic_synced_at, (int) $fact->last_observed_at)
: (int) $fact->last_observed_at;
}
if ($fact->cursor_state !== 'ready' || $counters === 'regression') {
$unsettled[$instanceId] = true;
$status = 'attention';
@ -260,19 +254,12 @@ final class CloudTrafficPoolFreshness
$status = 'delayed';
$code = 'settlement_delayed';
}
$lastConfirmed = $confirmed === []
? ((($factsByKey[$key] ?? []) === [])
? (($snapshot['last_observed_at'] ?? null) === null
? null : (int) $snapshot['last_observed_at'])
: null)
: min($confirmed);
$result[$key] = [
'status' => $status,
'last_confirmed_at' => $lastConfirmed,
'last_sample_at' => $latestSample ?: null,
'projection_pending' => $pendingEntitlement,
'unsettled_instance_count' => count($unsettled),
'stale_cursor_count' => count($stale),
'stale_sample_count' => count($stale),
'overdue_bucket_count' => (int) $due['count'],
'safe_code' => $code,
];
@ -356,7 +343,6 @@ final class CloudTrafficPoolFreshness
}
$rank = ['current' => 0, 'delayed' => 1, 'attention' => 2];
$status = 'current';
$lastConfirmed = [];
$latestSample = 0;
$unsettled = 0;
$stale = 0;
@ -366,20 +352,15 @@ final class CloudTrafficPoolFreshness
$status = $snapshot['status'];
}
$latestSample = max($latestSample, (int) $snapshot['last_sample_at']);
if ($snapshot['last_confirmed_at'] !== null) {
$lastConfirmed[] = (int) $snapshot['last_confirmed_at'];
}
$unsettled += (int) $snapshot['unsettled_instance_count'];
$stale += (int) $snapshot['stale_cursor_count'];
$stale += (int) $snapshot['stale_sample_count'];
$overdue += (int) $snapshot['overdue_bucket_count'];
}
return [
'status' => $status,
'last_sample_at' => $latestSample ?: null,
'last_confirmed_at' => count($lastConfirmed) === count($snapshots)
? min($lastConfirmed) : null,
'unsettled_instance_count' => $unsettled,
'stale_cursor_count' => $stale,
'stale_sample_count' => $stale,
'overdue_bucket_count' => $overdue,
'safe_code' => $status === 'current'
? 'current' : 'group_' . $status,
@ -392,11 +373,10 @@ final class CloudTrafficPoolFreshness
{
return [
'status' => $code === 'no_pools' ? 'current' : 'delayed',
'last_confirmed_at' => null,
'last_sample_at' => null,
'projection_pending' => $code === 'projection_pending',
'unsettled_instance_count' => 0,
'stale_cursor_count' => 0,
'stale_sample_count' => 0,
'overdue_bucket_count' => 0,
'safe_code' => $code,
];

@ -305,9 +305,6 @@ final class CloudTrafficPoolReadModel
'status' => !$projectionReady && ($freshness['status'] ?? '') === 'current'
? 'delayed' : (string) ($freshness['status'] ?? 'delayed'),
'last_sample_at' => $freshness['last_sample_at'] ?? null,
'last_confirmed_at' =>
($freshness['last_confirmed_at'] ?? null) === null
? null : (int) $freshness['last_confirmed_at'],
],
'network_restriction_state' => $networkState,
'instances' => array_values($instances),
@ -318,9 +315,9 @@ final class CloudTrafficPoolReadModel
{
return [
'status' => 'delayed',
'last_confirmed_at' => null,
'last_sample_at' => null,
'unsettled_instance_count' => 0,
'stale_cursor_count' => 0,
'stale_sample_count' => 0,
'safe_code' => 'projection_pending',
];
}

@ -128,23 +128,27 @@ final class CloudUserPageView
];
}
public static function trafficAccounting(array $pool): array
{
$evidence = $pool['accounting_freshness'] ?? [];
$status = $evidence['status'] ?? null;
if (!in_array($status, ['current', 'delayed', 'attention'], true)) {
$status = 'attention';
}
$sample = (int) ($evidence['last_sample_at'] ?? 0);
$label = 'traffic.freshness.' . $status;
return [
'status' => $status,
'label_key' => $label,
'message_key' => $label . ($sample > 0 ? '_at' : '_without_time'),
'sample_display' => $sample > 0 ? gmdate('Y-m-d H:i', $sample) . ' UTC' : '',
];
}
/** @return array<string,mixed> */
private static function trafficPool(array $pool): array
{
$projectionReady = ($pool['projection_ready'] ?? false) === true;
$freshness = is_array($pool['accounting_freshness'] ?? null)
? $pool['accounting_freshness'] : [];
$freshnessStatus = (string) ($freshness['status'] ?? 'delayed');
if (!in_array(
$freshnessStatus,
['current', 'delayed', 'attention'],
true
)) {
$freshnessStatus = 'attention';
}
$confirmedAt = max(0, (int) (
$freshness['last_confirmed_at'] ?? 0
));
[$stateLabel, $stateClass] = self::state(
(string) ($pool['state'] ?? ''),
[
@ -213,10 +217,7 @@ final class CloudUserPageView
'state_class' => $stateClass,
'network_label' => $networkLabel,
'network_class' => $networkClass,
'accounting_status' => $freshnessStatus,
'accounting_confirmed_display' => $confirmedAt > 0
? self::date($confirmedAt) : '',
'accounting_has_confirmation' => $confirmedAt > 0,
'accounting' => self::trafficAccounting($pool),
'entitlement_display' => $projectionReady ? self::bytes(
$pool['active_entitlement_bytes'] ?? null
) : '正在准备',

@ -7,12 +7,14 @@ function versionedModuleUrl(path) {
return url.href;
}
const [toastModule, taskObserver, instanceService] = await Promise.all([
const [toastModule, taskObserver, instanceService, trafficAccounting] = await Promise.all([
import(versionedModuleUrl('./toast.js')),
import(versionedModuleUrl('./task-observer.js')),
import(versionedModuleUrl('./instance-service.js')),
import(versionedModuleUrl('./traffic-accounting.js')),
]);
const { toast } = toastModule;
const { renderAccountingFreshness } = trafficAccounting;
const { formatServiceDate, servicePaused, serviceTimestamp } = instanceService;
const i18n = globalThis.VenixUserCopy;
const t = (key, parameters = {}) => i18n.text(key, parameters);
@ -447,6 +449,12 @@ function renderVmService(vm) {
: unlimited
? t('instance_detail.traffic.unlimited_pair')
: `${formatBytes(data.quota)} / ${formatBytes(data.remaining)}`);
const accounting = byId('vm-detail-traffic-accounting');
if (accounting) {
accounting.hidden = !pooled;
if (pooled) accounting.replaceChildren(renderAccountingFreshness(data.pool));
else accounting.replaceChildren();
}
const poolLink = byId('vm-detail-traffic-pool-link');
if (poolLink) {
poolLink.hidden = !pooled;
@ -2492,7 +2500,7 @@ export {
drawVmTrafficDaily, hydrateVmDetailBootstrap, initializeSession,
loadGlobalTemplates, loadKeys, loadVmMetrics, loadVmTrafficDaily,
loadVm, loadVmStatus, loadVms, navigate, openCreate, openReinstall, reinstall,
readBootstrap, renderVMs, renderVmDetail, renderVmMetrics, selectVmByApiId, selectedVm,
readBootstrap, renderAccountingFreshness, renderVMs, renderVmDetail, renderVmMetrics, selectVmByApiId, selectedVm,
setVmDetailTab, showError, state, stopVmMetrics,
stopVmTrafficDaily, toast, trafficDailyViewVisible, vmIp,
vmPagePath,

@ -0,0 +1,39 @@
// Shared by the traffic-pool list and the instance detail status refresh.
export function accountingFreshness(pool, catalog = globalThis.VenixUserCopy) {
const evidence = pool?.accounting_freshness;
const status = ['current', 'delayed', 'attention'].includes(evidence?.status)
? evidence.status : 'attention';
const sample = Number(evidence?.last_sample_at);
const hasSample = Number.isFinite(sample) && sample > 0;
return {
status,
label: catalog.text(`traffic.freshness.${status}`),
message: catalog.text(`traffic.freshness.${status}_${hasSample ? 'at' : 'without_time'}`,
hasSample ? { sample_time: catalog.date(sample) } : {}),
};
}
export function renderAccountingFreshness(pool, document = globalThis.document, catalog = globalThis.VenixUserCopy) {
const freshness = accountingFreshness(pool, catalog);
function element(tag, className, text) {
const node = document.createElement(tag);
node.className = className;
if (text !== undefined) node.textContent = text;
return node;
}
const box = element('div',
`cloud-traffic-accounting cloud-traffic-accounting-${freshness.status}`);
const icon = element('span', 'cloud-traffic-accounting-icon');
const marker = element('i', freshness.status === 'current'
? 'mdi mdi-check-circle-outline'
: freshness.status === 'delayed'
? 'mdi mdi-clock-alert-outline'
: 'mdi mdi-alert-circle-outline');
marker.setAttribute('aria-hidden', 'true');
icon.append(marker);
const copy = element('span', 'cloud-traffic-accounting-copy');
copy.append(element('strong', '', freshness.label),
element('small', '', freshness.message));
box.append(icon, copy);
return box;
}

@ -8,7 +8,7 @@ function versionedModuleUrl(path) {
}
const {
api, byId, initializeSession, readBootstrap, showError,
api, byId, initializeSession, readBootstrap, showError, renderAccountingFreshness,
} = await import(versionedModuleUrl('./runtime.js'));
const i18n = globalThis.VenixUserCopy;
const t = (key, parameters = {}) => i18n.text(key, parameters);
@ -82,43 +82,6 @@ function linePoolState(value) {
})[String(value || '')] || [t('traffic.status.unknown'), 'other'];
}
function accountingFreshness(pool) {
const freshness = pool?.accounting_freshness;
const status = ['current', 'delayed', 'attention'].includes(freshness?.status)
? freshness.status : 'attention';
const confirmedAt = Number(freshness?.last_confirmed_at);
const hasConfirmation = Number.isFinite(confirmedAt) && confirmedAt > 0;
const labelKey = `traffic.freshness.${status}`;
const messageKey = `traffic.freshness.${status}_${hasConfirmation
? 'at' : 'without_time'}`;
return {
status,
label: t(labelKey),
message: t(messageKey, hasConfirmation ? {
date: formatDate(confirmedAt, t('traffic.value.time_missing')),
} : {}),
};
}
function renderAccountingFreshness(pool) {
const freshness = accountingFreshness(pool);
const box = element('div',
`cloud-traffic-accounting cloud-traffic-accounting-${freshness.status}`);
const icon = element('span', 'cloud-traffic-accounting-icon');
const marker = element('i', freshness.status === 'current'
? 'mdi mdi-check-circle-outline'
: freshness.status === 'delayed'
? 'mdi mdi-clock-alert-outline'
: 'mdi mdi-alert-circle-outline');
marker.setAttribute('aria-hidden', 'true');
icon.append(marker);
const copy = element('span', 'cloud-traffic-accounting-copy');
copy.append(element('strong', '', freshness.label),
element('small', '', freshness.message));
box.append(icon, copy);
return box;
}
function instanceNetwork(value) {
return ({
active: [t('traffic.status.instance.active'), 'running'],

@ -124,22 +124,22 @@ return [
$entry('traffic.coverage.label', 'traffic', 'cloud.traffic', '覆盖:{regions}', 'description', ['regions' => 'string']),
$entry('traffic.coverage.unknown', 'traffic', 'cloud.traffic', '覆盖地区待核查', 'status', []),
$entry('traffic.intro', 'traffic', 'cloud.traffic', '最早到期的有效额度优先消耗;当前线路内的实例共同使用可用余额。', 'description', []),
$entry('traffic.fact.entitlement', 'traffic', 'cloud.traffic', '最后确认有效额度', 'label', []),
$entry('traffic.fact.consumed', 'traffic', 'cloud.traffic', '最后确认已消耗', 'label', []),
$entry('traffic.fact.available', 'traffic', 'cloud.traffic', '最后确认可用余额', 'label', []),
$entry('traffic.fact.overage', 'traffic', 'cloud.traffic', '最后确认超额流量', 'label', []),
$entry('traffic.fact.entitlement', 'traffic', 'cloud.traffic', '当前有效额度', 'label', []),
$entry('traffic.fact.consumed', 'traffic', 'cloud.traffic', '已入账用量', 'label', []),
$entry('traffic.fact.available', 'traffic', 'cloud.traffic', '已入账可用余额', 'label', []),
$entry('traffic.fact.overage', 'traffic', 'cloud.traffic', '已入账超额流量', 'label', []),
$entry('traffic.fact.next_expiry', 'traffic', 'cloud.traffic', '下一批到期', 'label', []),
$entry('traffic.fact.expiry_note', 'traffic', 'cloud.traffic', '届时作废 {amount}', 'help', ['amount' => 'string']),
$entry('traffic.fact.last_observed', 'traffic', 'cloud.traffic', '最近实例采样', 'label', []),
$entry('traffic.freshness.current', 'traffic', 'cloud.traffic', '账务已确认', 'status', []),
$entry('traffic.freshness.delayed', 'traffic', 'cloud.traffic', '账务结算延迟', 'status', []),
$entry('traffic.freshness.attention', 'traffic', 'cloud.traffic', '账务需要核对', 'status', []),
$entry('traffic.freshness.current_at', 'traffic', 'cloud.traffic', '共享额度已确认至 {date}。', 'help', ['date' => 'string']),
$entry('traffic.freshness.current_without_time', 'traffic', 'cloud.traffic', '共享额度已完成确认。', 'help', []),
$entry('traffic.freshness.delayed_at', 'traffic', 'cloud.traffic', '最新采样正在结算;以下共享额度为 {date} 的最后确认结果。', 'help', ['date' => 'string']),
$entry('traffic.freshness.delayed_without_time', 'traffic', 'cloud.traffic', '最新采样正在结算;以下共享额度为最后确认结果,确认时间暂未记录。', 'help', []),
$entry('traffic.freshness.attention_at', 'traffic', 'cloud.traffic', '账务正在核对;以下共享额度为 {date} 的最后确认结果。', 'help', ['date' => 'string']),
$entry('traffic.freshness.attention_without_time', 'traffic', 'cloud.traffic', '账务正在核对;以下共享额度为最后确认结果,确认时间暂未记录。', 'help', []),
$entry('traffic.fact.last_observed', 'traffic', 'cloud.traffic', '最近纳入结算的采样', 'label', []),
$entry('traffic.freshness.current', 'traffic_accounting', 'cloud.traffic', '账务已结算', 'status', []),
$entry('traffic.freshness.delayed', 'traffic_accounting', 'cloud.traffic', '结算延迟', 'status', []),
$entry('traffic.freshness.attention', 'traffic_accounting', 'cloud.traffic', '账务待核对', 'status', []),
$entry('traffic.freshness.current_at', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额。最近实例采样于 {sample_time}。', 'help', ['sample_time' => 'string'], 'required', false, null, 'feedback'),
$entry('traffic.freshness.current_without_time', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额。', 'help', [], 'required', false, null, 'feedback'),
$entry('traffic.freshness.delayed_at', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额,新的流量可能尚未计入。最近实例采样于 {sample_time}。', 'help', ['sample_time' => 'string'], 'required', false, null, 'feedback'),
$entry('traffic.freshness.delayed_without_time', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额,新的流量可能尚未计入。', 'help', [], 'required', false, null, 'feedback'),
$entry('traffic.freshness.attention_at', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额,核对后可能调整。最近实例采样于 {sample_time}。', 'help', ['sample_time' => 'string'], 'required', false, null, 'feedback'),
$entry('traffic.freshness.attention_without_time', 'traffic_accounting', 'cloud.traffic', '当前显示已入账余额,核对后可能调整。', 'help', [], 'required', false, null, 'feedback'),
$entry('traffic.instances.title', 'traffic', 'cloud.traffic', '当前实例', 'label', []),
$entry('traffic.instances.count', 'traffic', 'cloud.traffic', '{count} 台', 'status', ['count' => 'integer']),
$entry('traffic.instances.aria', 'traffic', 'cloud.traffic', '{name} 的实例', 'aria_label', ['name' => 'string']),

@ -581,7 +581,7 @@ foreach ([
'instance_detail.traffic.pooled_description' => '实例流量计入同线路共享池;余额与到期批次以流量池页面为准。',
'instance_detail.traffic.pool_initializing' => '共享流量池额度正在初始化,实例流量采样不受影响。',
'instance_detail.traffic.instance_sample_total' => '本实例本期采样合计',
'instance_detail.traffic.pool_total_remaining' => '共享池有效额度 / 可用余额',
'instance_detail.traffic.pool_total_remaining' => '共享池有效额度 / 已入账可用余额',
'instance_detail.traffic.preparing_pair' => '正在准备 / 正在准备',
'instance_detail.traffic.unlimited_pair' => '不限流量 / 不限流量',
'instance_detail.traffic.shared_pool' => '共享流量池',

@ -61,7 +61,7 @@ return [
'auth.register' => ['label' => '注册页', 'scopes' => ['common', 'auth']],
'cloud.backups' => ['label' => '云备份页', 'scopes' => ['common', 'backups']],
'cloud.deploy' => ['label' => '实例部署页', 'scopes' => ['common', 'deploy']],
'cloud.detail' => ['label' => '实例详情页', 'scopes' => ['common', 'instance_detail']],
'cloud.detail' => ['label' => '实例详情页', 'scopes' => ['common', 'instance_detail', 'traffic_accounting']],
'cloud.invoice_detail' => ['label' => '账单详情页', 'scopes' => ['common', 'billing']],
'cloud.invoices' => ['label' => '账单列表页', 'scopes' => ['common', 'billing']],
'cloud.instances' => ['label' => '实例列表页', 'scopes' => ['common', 'instances']],
@ -69,7 +69,7 @@ return [
'cloud.keys' => ['label' => 'SSH公钥页', 'scopes' => ['common', 'ssh_keys']],
'cloud.reinstall' => ['label' => '重装系统页', 'scopes' => ['common', 'reinstall']],
'cloud.snapshots' => ['label' => '云快照页', 'scopes' => ['common', 'snapshots']],
'cloud.traffic' => ['label' => '流量池页', 'scopes' => ['common', 'traffic']],
'cloud.traffic' => ['label' => '流量池页', 'scopes' => ['common', 'traffic', 'traffic_accounting']],
'cloud.vpcs' => ['label' => 'VPC私网页', 'scopes' => ['common', 'vpc']],
'legal.privacy' => ['label' => '隐私政策页', 'scopes' => ['common', 'legal']],
'legal.terms' => ['label' => '服务条款页', 'scopes' => ['common', 'legal']],

@ -168,6 +168,14 @@
<div>{foreach $resource_page.traffic_pools.lines as $line}{if $line.traffic_pool_group_id == $group.id}<span class="admin-traffic-line-chip">{$line.region_name|escape} · {$line.name|escape} <code>{$line.code|escape}</code></span>{/if}{foreachelse}<span class="text-muted fs-12">尚无可用线路</span>{/foreach}{if $group.line_count == 0}<span class="text-muted fs-12">尚未绑定线路</span>{/if}</div>
</div>
{assign var=fresh value=$group.accounting_freshness}
<p class="admin-traffic-readiness {if $fresh.status == 'current'}is-ready{else}is-blocked{/if}">
<strong>流量结算</strong>
{if $fresh.pool_count == 0 && $fresh.status == 'current'}暂无账本池{elseif $fresh.status == 'current'}已结算{elseif $fresh.status == 'delayed'}结算延迟{else}账务待核对{/if}
· 待结算实例 {$fresh.unsettled_instance_count|escape} 台 · 采样滞后 {$fresh.stale_sample_count|escape} 台 · 到期未封账 {$fresh.overdue_bucket_count|escape} 个
{if $fresh.last_sample_at} · 最近实例采样 {$fresh.last_sample_at|date_format:'%Y-%m-%d %H:%M %Z'|escape}{/if}
</p>
{if $group.readiness.ready}
<p class="admin-traffic-readiness is-ready"><i class="mdi mdi-check-circle-outline" aria-hidden="true"></i>{if $group.mode == 'shadow'}就绪门禁已通过,可以进入强制执行。{elseif $group.mode == 'enforced'}强制执行中的账本与网络状态已通过校验。{else}当前配置未发现就绪阻断项。{/if}</p>
{else}

@ -266,6 +266,11 @@
<div><dt id="vm-detail-traffic-used-label">{if $cloud_vm_view.traffic_used_label_copy_key|default:'' != ''}{user_copy key=$cloud_vm_view.traffic_used_label_copy_key}{else}{user_copy key='instance_detail.traffic.used'}{/if}</dt><dd id="vm-detail-traffic-used">{if $cloud_vm_view.traffic_used_display|default:'' != ''}{$cloud_vm_view.traffic_used_display|escape:"html"}{else}{user_copy key='instance_detail.value.unavailable'}{/if}</dd></div>
<div><dt id="vm-detail-traffic-total-label">{if $cloud_vm_view.traffic_total_label_copy_key|default:'' != ''}{user_copy key=$cloud_vm_view.traffic_total_label_copy_key}{else}{user_copy key='instance_detail.traffic.total_remaining'}{/if}</dt><dd id="vm-detail-traffic-total-remaining">{if $cloud_vm_view.traffic_total_remaining_copy_key|default:'' != ''}{user_copy key=$cloud_vm_view.traffic_total_remaining_copy_key}{elseif $cloud_vm_view.traffic_total_remaining_display|default:'' != ''}{$cloud_vm_view.traffic_total_remaining_display|escape:"html"}{else}{user_copy key='instance_detail.value.unavailable'}{/if}</dd></div>
</dl>
<div id="vm-detail-traffic-accounting"{if $cloud_vm_view.traffic_accounting_mode|default:'legacy' != 'pooled'} hidden{/if}>
{if !empty($cloud_vm_view.traffic_accounting) && $cloud_vm_view.traffic_accounting_mode|default:'legacy' == 'pooled'}
{include file='cloud/partials/traffic-accounting.tpl' evidence=$cloud_vm_view.traffic_accounting}
{/if}
</div>
<div id="vm-detail-traffic-progress" class="vm-traffic-progress" role="progressbar" aria-label="{if $cloud_vm_view.traffic_accounting_mode|default:'legacy' == 'pooled'}{user_copy key='instance_detail.traffic.pool_usage'}{else}{user_copy key='instance_detail.traffic.plan_usage'}{/if}" aria-valuemin="0" aria-valuemax="100"{if $cloud_vm_view.traffic_ratio|default:'' == ''} hidden{else} aria-valuenow="{$cloud_vm_view.traffic_ratio|escape:"html"}"{/if}><span id="vm-detail-traffic-progress-bar"{if $cloud_vm_view.traffic_ratio|default:'' != ''} style="width:{$cloud_vm_view.traffic_ratio|escape:"html"}%"{/if}></span></div>
</section>
<section class="inventory-panel vm-traffic-daily" aria-labelledby="vm-traffic-daily-title">

@ -27,7 +27,7 @@
<div class="cloud-traffic-line-body">
<article class="cloud-traffic-card cloud-traffic-line-content">
<div class="cloud-traffic-line-intro"><p{user_copy_binding key='traffic.intro'}>{user_copy key='traffic.intro'}</p><div class="cloud-traffic-state-group"><span class="state-pill {$pool.state_class|escape:'html'}">{$pool.state_label|escape:'html'}</span><span class="state-pill {$pool.network_class|escape:'html'}">{$pool.network_label|escape:'html'}</span></div></div>
<div class="cloud-traffic-accounting cloud-traffic-accounting-{$pool.accounting_status|escape:'html'}"><span class="cloud-traffic-accounting-icon"><i class="mdi {if $pool.accounting_status == 'current'}mdi-check-circle-outline{elseif $pool.accounting_status == 'delayed'}mdi-clock-alert-outline{else}mdi-alert-circle-outline{/if}" aria-hidden="true"></i></span><span class="cloud-traffic-accounting-copy"><strong>{if $pool.accounting_status == 'current'}{user_copy key='traffic.freshness.current'}{elseif $pool.accounting_status == 'delayed'}{user_copy key='traffic.freshness.delayed'}{else}{user_copy key='traffic.freshness.attention'}{/if}</strong><small>{if $pool.accounting_status == 'current'}{if $pool.accounting_has_confirmation}{user_copy key='traffic.freshness.current_at' date=$pool.accounting_confirmed_display}{else}{user_copy key='traffic.freshness.current_without_time'}{/if}{elseif $pool.accounting_status == 'delayed'}{if $pool.accounting_has_confirmation}{user_copy key='traffic.freshness.delayed_at' date=$pool.accounting_confirmed_display}{else}{user_copy key='traffic.freshness.delayed_without_time'}{/if}{else}{if $pool.accounting_has_confirmation}{user_copy key='traffic.freshness.attention_at' date=$pool.accounting_confirmed_display}{else}{user_copy key='traffic.freshness.attention_without_time'}{/if}{/if}</small></span></div>
{include file='cloud/partials/traffic-accounting.tpl' evidence=$pool.accounting}
<dl class="cloud-traffic-facts"><div><dt{user_copy_binding key='traffic.fact.entitlement'}>{user_copy key='traffic.fact.entitlement'}</dt><dd>{$pool.entitlement_display|escape:'html'}</dd></div><div><dt{user_copy_binding key='traffic.fact.consumed'}>{user_copy key='traffic.fact.consumed'}</dt><dd>{$pool.consumed_display|escape:'html'}</dd></div><div><dt{user_copy_binding key='traffic.fact.available'}>{user_copy key='traffic.fact.available'}</dt><dd>{$pool.available_display|escape:'html'}</dd></div><div><dt{user_copy_binding key='traffic.fact.overage'}>{user_copy key='traffic.fact.overage'}</dt><dd>{$pool.overage_display|escape:'html'}</dd></div><div><dt{user_copy_binding key='traffic.fact.next_expiry'}>{user_copy key='traffic.fact.next_expiry'}</dt><dd>{$pool.next_expiry_display|escape:'html'}<small>{$pool.next_expiry_note|escape:'html'}</small></dd></div><div><dt{user_copy_binding key='traffic.fact.last_observed'}>{user_copy key='traffic.fact.last_observed'}</dt><dd>{$pool.last_observed_display|escape:'html'}</dd></div></dl>
<section class="cloud-traffic-instances" aria-label="{user_copy key='traffic.instances.aria' name=$pool.name}">
<div class="cloud-traffic-instances-heading"><h4{user_copy_binding key='traffic.instances.title'}>{user_copy key='traffic.instances.title'}</h4><span>{user_copy key='traffic.instances.count' count=$pool.instances|@count}</span></div>

@ -0,0 +1,7 @@
<div class="cloud-traffic-accounting cloud-traffic-accounting-{$evidence.status|escape:'html'}">
<span class="cloud-traffic-accounting-icon" aria-hidden="true"><i class="mdi {if $evidence.status == 'current'}mdi-check-circle-outline{elseif $evidence.status == 'delayed'}mdi-clock-alert-outline{else}mdi-alert-circle-outline{/if}"></i></span>
<span class="cloud-traffic-accounting-copy">
<strong>{user_copy key=$evidence.label_key}</strong>
<small>{if $evidence.sample_display != ''}{user_copy key=$evidence.message_key sample_time=$evidence.sample_display}{else}{user_copy key=$evidence.message_key}{/if}</small>
</span>
</div>

@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026111701' scope='global'}
{assign var=venix_asset_version value='2026111801' scope='global'}

@ -482,7 +482,7 @@ Capsule::table('cloud_traffic_ledger_events')->insert([
]);
$ready = CloudAdminTrafficPoolService::readiness($groupId, $now);
$assert($ready['ready'] === true && $ready['blockers'] === [],
$assert($ready['ready'] === true && $ready['blockers'] === [] && $ready['active_instance_count'] === 0,
'A complete shadow projection did not pass readiness.');
Capsule::table('cloud_traffic_entitlements')->where('id', 25)->update([
'state' => 'active',
@ -599,7 +599,7 @@ Capsule::table('cloud_traffic_instance_cursors')->where(
'accounted_upload_bytes' => 20,
]);
$ready = CloudAdminTrafficPoolService::readiness($groupId, $now);
$assert($ready['ready'] === true && $ready['blockers'] === [],
$assert($ready['ready'] === true && $ready['blockers'] === [] && $ready['active_instance_count'] === 1,
'A fully settled active projection did not pass readiness.');
$quietCursor = Capsule::table('cloud_traffic_instance_cursors')->where('instance_id', 100);
$quietVm = Capsule::table('cloud_instances')->where('id', 100);
@ -607,8 +607,9 @@ $quietCursor->update(['last_observed_at' => $now - 9000]);
$assert(CloudAdminTrafficPoolService::readiness($groupId, $now)['ready'],
'A quiet instance incorrectly blocks enforcement.');
$quietVm->update(['status' => 'deleted', 'traffic_synced_at' => $now - 8000]);
$assert(CloudAdminTrafficPoolService::readiness($groupId, $now)['ready'],
'A deleted instance with a valid paid period incorrectly blocks enforcement.');
$retired = CloudAdminTrafficPoolService::readiness($groupId, $now);
$assert($retired['ready'] && $retired['active_instance_count'] === 0,
'A deleted instance with a valid paid period blocked enforcement or counted as active.');
$quietVm->update(['lifetime_upload_bytes' => 320]);
$assert(in_array('usage_unsettled', array_column(CloudAdminTrafficPoolService::readiness($groupId, $now)['blockers'], 'code'), true),
'Deleted tail usage bypassed enforcement readiness.');

@ -110,4 +110,7 @@ $assert(str_contains($styles,
&& str_contains($styles, '@media (max-width: 767.98px)'),
'Traffic-pool administration must remain responsive.');
$assert(str_contains($template, 'value=$group.accounting_freshness') && str_contains($template, '$fresh.last_sample_at')
&& str_contains($template, '$fresh.unsettled_instance_count') && str_contains($template, '$group.readiness.ready'),
'The separate line accounting and enforcement readiness projections must both be visible.');
echo "Administrator shared traffic-pool UI contracts passed.\n";

@ -71,6 +71,9 @@ namespace {
$table->integer('traffic_quota_bytes')->default(0);
$table->integer('traffic_download_bytes')->default(0);
$table->integer('traffic_upload_bytes')->default(0);
$table->integer('lifetime_download_bytes')->default(0);
$table->integer('lifetime_upload_bytes')->default(0);
$table->integer('traffic_synced_at')->default(0);
$table->text('spec_json');
$table->text('sealed_credential')->nullable();
$table->integer('created_at');
@ -141,6 +144,17 @@ namespace {
$table->integer('version')->default(1);
$table->integer('updated_at');
});
$schema->create('cloud_traffic_scan_failures', static function (Blueprint $table): void {
$table->increments('id');
$table->string('scan_kind');
$table->integer('subject_id');
});
$schema->create('cloud_traffic_usage_settlement_buckets', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('pool_id');
$table->string('state');
$table->integer('seal_at');
});
$schema->create('cloud_instance_network_restrictions', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('instance_id');

@ -117,7 +117,7 @@ Capsule::table('cloud_traffic_instance_cursors')->insert([
$current = CloudTrafficPoolFreshness::snapshot(7, 3, $now);
$assert($current['status'] === 'current'
&& $current['safe_code'] === 'current'
&& $current['last_confirmed_at'] === $now - 60
&& $current['last_sample_at'] === $now - 60
&& $current['unsettled_instance_count'] === 0,
'Fully accounted counters were not projected as current.');
@ -129,8 +129,8 @@ $delayed = CloudTrafficPoolFreshness::snapshot(7, 3, $now);
$assert($delayed['status'] === 'delayed'
&& $delayed['safe_code'] === 'settlement_delayed'
&& $delayed['unsettled_instance_count'] === 1
&& $delayed['last_confirmed_at'] === $now - 60,
'Persisted but unsettled counters did not retain the last confirmation.');
&& $delayed['last_sample_at'] === $now - 10,
'Persisted but unsettled counters did not expose the newest sample independently of booked balance.');
Capsule::table('cloud_traffic_instance_cursors')->where('instance_id', 20)
->update(['state' => 'attention']);
@ -156,11 +156,11 @@ $assert($stale['safe_code'] === 'sample_stale' && !$stale['unsettled_instance_co
'An old live sample was counted as pending traffic.');
$vm->update(['status' => 'deleted']);
$retired = CloudTrafficPoolFreshness::snapshot(7, 3, $now);
$assert($retired['status'] === 'current' && !$retired['stale_cursor_count']
&& $retired['last_confirmed_at'] === null, 'A retired VM pinned pool freshness.');
$assert($retired['status'] === 'current' && !$retired['stale_sample_count']
&& $retired['last_sample_at'] === null, 'A retired VM pinned pool freshness.');
$vm->update(['lifetime_download_bytes' => 400]);
$tail = CloudTrafficPoolFreshness::snapshot(7, 3, $now);
$assert($tail['unsettled_instance_count'] === 1 && !$tail['stale_cursor_count'],
$assert($tail['unsettled_instance_count'] === 1 && !$tail['stale_sample_count'],
'A deleted VM lost its final unaccounted 300 bytes.');
$vm->update(['lifetime_download_bytes' => 99, 'lifetime_upload_bytes' => 21]);
$assert(CloudTrafficPoolFreshness::snapshot(7, 3, $now)['status'] === 'attention',
@ -184,7 +184,7 @@ $assert($overdueAttention['status'] === 'attention'
$pending = CloudTrafficPoolFreshness::snapshot(9, 3, $now);
$assert($pending['status'] === 'delayed'
&& $pending['safe_code'] === 'projection_pending'
&& $pending['last_confirmed_at'] === null,
&& $pending['last_sample_at'] === null,
'Missing projection fabricated current accounting.');
$group = CloudTrafficPoolFreshness::forGroup(3, $now);
$assert($group['status'] === 'attention'

@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import vm from 'node:vm';
import { renderAccountingFreshness } from '../public/cloud/traffic-accounting.js';
const moduleSource = await readFile(
new URL('../public/cloud/traffic.js', import.meta.url),
@ -62,7 +63,7 @@ const translate = (key, parameters = {}) => {
if (key === 'traffic.coverage.regions') return `${parameters.count} 个地区`;
if (key === 'traffic.coverage.instances') return `${parameters.count} 台实例`;
if (key === 'traffic.instances.count') return `${parameters.count} 台`;
if (key.endsWith('_at')) return `confirmed ${parameters.date}`;
if (key.endsWith('_at')) return `sample ${parameters.sample_time}`;
return key;
};
const i18n = {
@ -82,6 +83,7 @@ const context = vm.createContext({
readBootstrap: () => ({}),
showError() {},
i18n,
renderAccountingFreshness: pool => renderAccountingFreshness(pool, document, i18n),
t: translate,
});
vm.runInContext(`${source}\nglobalThis.traffic = { applyPayload };`, context, {
@ -101,7 +103,7 @@ const pool = (id, name = `线路 ${id}`) => ({
next_expiry_at: null,
next_expiry_bytes: 0,
last_observed_at: null,
accounting_freshness: { status: 'current', last_confirmed_at: 100 },
accounting_freshness: { status: 'current', last_sample_at: 100 },
instances: [],
key: `line-group:${id}`,
coverage_regions: [{ code: 'hkg', name: '香港' }],
@ -173,7 +175,7 @@ assert.deepEqual(details().map(item => item.open), [false, true, true],
context.traffic.applyPayload(payload([
linePool(4, {
accounting_freshness: { status: 'delayed', last_confirmed_at: 80 },
accounting_freshness: { status: 'delayed', last_sample_at: 80 },
summary_state: 'delayed', requires_attention: true, default_open: true,
instance_count: 1,
instances: [{
@ -187,7 +189,7 @@ context.traffic.applyPayload(payload([
const delayedContent = details()[0].textContent;
assert.match(delayedContent, /traffic\.freshness\.delayed/,
'A delayed accounting projection was not made visible.');
assert.match(delayedContent, /confirmed date-80/,
assert.match(delayedContent, /sample date-80/,
'The delayed projection hid its last confirmed timestamp.');
assert.match(delayedContent, /traffic\.instance\.period_quota/,
'Freshness messaging replaced the per-instance raw sample list.');

@ -450,7 +450,6 @@ $assert($lineA['active_entitlement_bytes'] === 1500
$assert($lineA['accounting_freshness'] === [
'status' => 'delayed',
'last_sample_at' => null,
'last_confirmed_at' => $now - 5,
],
'User projection did not expose the bounded actor-safe freshness state.');
$assert(count($lineA['instances']) === 1

@ -38,7 +38,7 @@ $assert(str_contains($readModel,
&& str_contains($readModel, 'CloudTrafficPoolAccounting::snapshots(')
&& str_contains($readModel, 'CloudTrafficPoolFreshness::snapshots(')
&& str_contains($readModel, "'accounting_freshness' => [")
&& str_contains($readModel, "'last_confirmed_at' =>")
&& str_contains($readModel, "'last_sample_at' =>")
&& str_contains($freshness, 'public const DELAY_SECONDS = 300;')
&& str_contains($freshness, 'public const ATTENTION_SECONDS = 3600;')
&& str_contains($readModel,
@ -118,11 +118,8 @@ $assert(str_contains($sidebar, 'href="/user/cloud/traffic"')
&& str_contains($template,
"{user_copy key='traffic.instance.expiry' region=\$instance.region_label date=\$instance.expires_display}")
&& str_contains($template, "{user_copy key='traffic.intro'}")
&& str_contains($template, 'cloud-traffic-accounting-')
&& str_contains($template,
"{user_copy key='traffic.freshness.delayed_at'")
&& str_contains($template,
"{user_copy key='traffic.freshness.attention_without_time'}")
&& str_contains($template, "cloud/partials/traffic-accounting.tpl")
&& str_contains($read('resources/views/venix/cloud/partials/traffic-accounting.tpl'), 'user_copy key=$evidence.message_key')
&& !str_contains($template, 'cloud-traffic-region'),
'The user traffic-pool page lacks SSR first paint, navigation or clear shared-vs-instance copy.');
@ -149,8 +146,9 @@ $assert(str_contains($script,
&& str_contains($script, 'pool.active_consumed_bytes')
&& str_contains($script, 'pool.available_bytes')
&& str_contains($script, 'pool.projection_ready === true')
&& str_contains($script, 'function accountingFreshness(pool)')
&& str_contains($script, 'function renderAccountingFreshness(pool)')
&& str_contains($read('public/cloud/traffic-accounting.js'), 'function accountingFreshness(')
&& str_contains($read('public/cloud/traffic-accounting.js'), 'export function renderAccountingFreshness(')
&& str_contains($runtime, 'accounting.replaceChildren(renderAccountingFreshness(data.pool))')
&& str_contains($script,
'renderAccountingFreshness(pool), facts, instances')
&& str_contains($script,

@ -96,7 +96,7 @@ $traffic = ['line_pools' => [[
'next_expiry_at' => null, 'next_expiry_bytes' => 0,
'last_observed_at' => 1793404900,
'accounting_freshness' => [
'status' => 'delayed', 'last_confirmed_at' => 1793404800,
'status' => 'delayed', 'last_sample_at' => 1793404800,
],
'coverage_regions' => [['code' => 'hkg', 'name' => '香港']],
'coverage_region_count' => 1, 'instance_count' => 1,
@ -114,13 +114,24 @@ $xpath = $render('traffic', [
]);
$trafficText = $one($xpath, 'cloud-traffic-list')->textContent;
$assert($xpath->query('//*[contains(concat(" ", normalize-space(@class), " "), " cloud-traffic-accounting-delayed ")]')->length === 1
&& str_contains($trafficText, '账务结算延迟')
&& str_contains($trafficText, '最后确认可用余额')
&& str_contains($trafficText, '以下共享额度为')
&& str_contains($trafficText, '结算延迟')
&& str_contains($trafficText, '已入账可用余额')
&& str_contains($trafficText, '新的流量可能尚未计入')
&& str_contains($trafficText, 'vm-traffic')
&& str_contains($trafficText, '512 B'),
'Traffic-pool first paint hid delayed accounting, confirmed balances or raw instance samples.');
foreach (['current', 'delayed', 'attention'] as $status) {
foreach ([null, 1793404800] as $sample) {
$evidence = CloudUserPageView::trafficAccounting(['accounting_freshness' => ['status' => $status, 'last_sample_at' => $sample]]);
$xpath = $render('detail', ['cloud_vm_view' => ['traffic_accounting_mode' => 'pooled', 'traffic_accounting' => $evidence]]);
$card = $one($xpath, 'vm-detail-traffic-accounting');
$assert(!$card->hasAttribute('hidden') && str_contains($card->textContent, '已入账余额')
&& str_contains($card->textContent, ' UTC') === ($sample !== null), 'Instance SSR lost the booked balance or sample time.');
}
}
$xpath = $render('detail', ['cloud_vm_view' => ['traffic_accounting_mode' => 'unlimited']]);
$assert($one($xpath, 'vm-detail-traffic-accounting')->hasAttribute('hidden'), 'Non-pooled VM displayed pool accounting.');
$vpc = ['vpc_key' => $key, 'name' => 'vpc-before-js', 'region_id' => 1,
'region_name' => '香港', 'cidr' => '10.0.1.0/24', 'gateway' => '10.0.1.1', 'state' => 'active', 'port_count' => 1];
$member = ['id' => '7', 'name' => 'vm-member', 'region_id' => 1, 'public_ipv4' => '192.0.2.7',

@ -40,6 +40,7 @@ $templatePaths = [
'web/resources/views/venix/cloud/pages/keys.tpl',
'web/resources/views/venix/cloud/pages/reinstall.tpl',
'web/resources/views/venix/cloud/pages/traffic.tpl',
'web/resources/views/venix/cloud/partials/traffic-accounting.tpl',
'web/resources/views/venix/cloud/pages/vpcs.tpl',
'web/resources/views/venix/components/site_brand_mark.tpl',
'web/resources/views/venix/home/language_switch.tpl',
@ -102,6 +103,7 @@ $browserPaths = [
'web/public/cloud/ticket-upload.js',
'web/public/cloud/toast.js',
'web/public/cloud/traffic.js',
'web/public/cloud/traffic-accounting.js',
'web/public/cloud/user-copy-runtime.js',
'web/public/cloud/user-dialog.js',
'web/public/cloud/vpcs.js',

@ -46,12 +46,25 @@ $assert($surfaceCounts === [
'accessibility' => 102,
'admin' => 110,
'dialog' => 56,
'feedback' => 618,
'page' => 1477,
'feedback' => 624,
'page' => 1471,
'shared' => 38,
'task' => 53,
],
'User-copy authoring surface census drifted from the reviewed taxonomy.');
foreach (['cloud.traffic', 'cloud.detail'] as $page) {
$assert(in_array('traffic_accounting', $manifest['pages'][$page]['scopes'], true),
'The shared accounting status catalog is unavailable in ' . $page);
}
foreach (['current', 'delayed', 'attention'] as $status) {
foreach (['', '_at', '_without_time'] as $suffix) {
$key = 'traffic.freshness.' . $status . $suffix;
$entry = $loadedEntries[$key];
$assert($entry['scope'] === 'traffic_accounting' && $entry['editor_surface'] === 'feedback'
&& $entry['parameters'] === ($suffix === '_at' ? ['sample_time' => 'string'] : []),
'The shared editable traffic message or its sampling-time placeholder drifted: ' . $key);
}
}
foreach ($loadedEntries as $copyKey => $entry) {
$assert(is_string($entry['editor_surface'] ?? null)
&& is_string($entry['editor_group'] ?? null),

Loading…
Cancel
Save