# agent refactor metadata

## guidelines

* **Imports Order & logalot**:
  * Imports should be organized in the following order:
    1. non-@ibgib external dependencies
    2. blank line
    3. @ibgib external dependencies (order: helper-gib, ts-gib, encrypt-gib, core-gib, node-gib, web-gib)
    4. blank line
    5. `import { GLOBAL_LOG_A_LOT } from '../path/to/constants/file.mts';` (if applicable)
    6. other local file imports
    7. blank line
    8. `const logalot = GLOBAL_LOG_A_LOT` (if applicable)
    9. blank line
  * So the `GLOBAL_LOG_A_LOT` is a local import, and this should be first iif the file contains any functions with logging.
* **Destructured params and logging**:
  * Use destructured arguments for functions (unless it's an extremely small helper with a single obvious param).
  * Harness most functions with `try/catch/finally` blocks and logging using `if (logalot)`.
  * Define `const lc = \`[${functionName.name}]\`;` at the top of the function.
  * In the `catch` block, explicitly log using `console.error(\`${lc} ${extractErrorMsg(error)}\`);` and `throw error;` (Do NOT add a UUID here).
  * For Promises, include a `reject` inside the catch block.
* **Tag Logging Messages with UUIDs**:
  * Tag ALL logging messages, warnings, and errors with the proper prefix (e.g., I:, W:, E:) and a uuid inside parens, e.g., `(I: cfe7c7f220c84bd832bad493a9453826)`. Note: we will use `generate-id.js` for this.

## libs/core-gib/src/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mts

[changes will go here]

### 2026/02/27 - 10:17 AM

#### line 1 - Imports Order & logalot

```typescript
import * as http2 from 'http2';

import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';

import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs';
import { SyncPeerHttpReceiver_V1 } from './sync-peer-http-receiver-v1.mjs';
import { SyncSagaContextIbGib_V1 } from '../../sync-saga-context/sync-saga-context-types.mjs';

const logalot = GLOBAL_LOG_A_LOT;
```

#### lines 55-274 - Destructured params and logging / Tag Logging Messages

```typescript
    // Wrapped functions matching the try/catch/finally logging pattern:
    public async start(): Promise<void> { ... }
    public async stop(): Promise<void> { ... }
    protected async handleRequest(...) { ... }
    protected async handleSseStreamRequest(...) { ... }
    protected async handleSyncFrameRequest(...) { ... }
    protected readRequestBody(...) { ... }

    // Example of changes applied to methods:
    public async start(): Promise<void> {
        const lc = `[${this.start.name}]`;
        return new Promise((resolve, reject) => {
            try {
                if (logalot) { console.log(`${lc} starting... (I: fc09bcef98bda9d91429161355c2e626)`); }
                // ...
            } catch (error) {
                console.error(`${lc} ${extractErrorMsg(error)}`);
                reject(error);
            } finally {
                if (logalot) { console.log(`${lc} complete. (I: 1d9e40501e6c191b186ae32edf151526)`); }
            }
        });
    }
```
