177 lines
7.1 KiB
Markdown
177 lines
7.1 KiB
Markdown
# 1C Form Command Binding Learning
|
|
|
|
This runbook tracks the two remaining `ТестНастройки` SQL/XML gaps after the
|
|
form decoder reached zero missing items and zero mismatches.
|
|
|
|
## Target
|
|
|
|
- Base: `upo_test`
|
|
- Adapter: `http://docker.cin.su:8011`
|
|
- Saved-state table: `ConfigCASSave`
|
|
- Form payload file:
|
|
`f96a0c45-3eff-11f1-8287-005056b0d483__25c39fbf-35a4-4b43-8e3f-cd1f91082c88.0`
|
|
- Form: `ТестНастройки`
|
|
- Current baseline payload SHA1:
|
|
`0ca61aa4ed041fc4219cada0126d5f144e59d30d`
|
|
|
|
## Before Captures
|
|
|
|
The baseline captures were created on 2026-07-02.
|
|
|
|
| Learning ID | Element | Expected XML binding | Snapshot |
|
|
| --- | --- | --- | --- |
|
|
| `form-command-binding-standard-customize-form` | `ТЗИзменитьФорму` | `Form.StandardCommand.CustomizeForm` | `38cab2dc00c9465e9dc42a17548d3170` |
|
|
| `form-command-binding-local-apply-command` | `ФормаКомандаОбновить` | `Form.Command.КомандаПрименить` | `e312ccc2e6ed45fbb6ebac187d30ba7a` |
|
|
|
|
Adapter-side capture paths:
|
|
|
|
- `/data/adapter-write-learning/form-command-binding-standard-customize-form/before-38cab2dc00c9465e9dc42a17548d3170.json`
|
|
- `/data/adapter-write-learning/form-command-binding-local-apply-command/before-e312ccc2e6ed45fbb6ebac187d30ba7a.json`
|
|
|
|
## XML Fixture Workflow
|
|
|
|
Use the XML workflow first, matching the moxel discovery flow: edit/generate XML,
|
|
load it into the test extension, then inspect the changed SQL payload.
|
|
|
|
Generate fixtures:
|
|
|
|
```powershell
|
|
python scripts/create_1c_form_command_binding_xml_fixtures.py
|
|
```
|
|
|
|
Generated files:
|
|
|
|
| Fixture | Purpose |
|
|
| --- | --- |
|
|
| `reports/1c-sql/upo_test/xml-command-binding-fixtures/00-original/Form.xml` | baseline copy |
|
|
| `reports/1c-sql/upo_test/xml-command-binding-fixtures/01-local-button-command-example1/Form.xml` | changes `ФормаКомандаОбновить` to `Form.Command.КомандаПример1` |
|
|
| `reports/1c-sql/upo_test/xml-command-binding-fixtures/02-standard-button-to-local-command/Form.xml` | changes `ТЗИзменитьФорму` to `Form.Command.КомандаПример1` |
|
|
| `reports/1c-sql/upo_test/xml-command-binding-fixtures/03-combined-command-binding-switches/Form.xml` | applies both existing-button changes |
|
|
| `reports/1c-sql/upo_test/xml-command-binding-fixtures/04-add-two-learning-buttons/Form.xml` | adds two new learning buttons under `Группа2` |
|
|
|
|
Preferred first load:
|
|
|
|
1. Load `01-local-button-command-example1/Form.xml` into
|
|
`фс_ДоработкиОбщее.DataProcessor.фс_НастройкаУсловногоОформления.Forms.ТестНастройки`.
|
|
2. Update/save the extension so `ConfigCASSave` receives a new form payload.
|
|
3. Run:
|
|
|
|
```powershell
|
|
python scripts/run_1c_form_command_binding_learning.py `
|
|
--wait-for-sha-change 0ca61aa4ed041fc4219cada0126d5f144e59d30d `
|
|
--max-wait-seconds 300 `
|
|
--report reports/1c-sql/upo_test/form-command-binding-learning-run.json
|
|
```
|
|
|
|
Then use the adapter diff/inference output to promote a decoder/write rule.
|
|
If the first load is clean, repeat with `02-standard-button-to-local-command`
|
|
or `03-combined-command-binding-switches`.
|
|
|
|
## Experiment A: Standard Command Binding
|
|
|
|
Goal: learn where marker `34` stores a standard command binding.
|
|
|
|
After any manual save, the preferred one-command runner is:
|
|
|
|
```powershell
|
|
python scripts/run_1c_form_command_binding_learning.py `
|
|
--wait-for-sha-change 0ca61aa4ed041fc4219cada0126d5f144e59d30d `
|
|
--max-wait-seconds 300 `
|
|
--report reports/1c-sql/upo_test/form-command-binding-learning-run.json
|
|
```
|
|
|
|
Manual edit in Designer:
|
|
|
|
1. Open form `ТестНастройки`.
|
|
2. Select button `ТЗИзменитьФорму`.
|
|
3. Change only `CommandName` from `Form.StandardCommand.CustomizeForm` to a
|
|
different standard command if Designer allows it.
|
|
4. Save the form once.
|
|
|
|
After save, capture:
|
|
|
|
```powershell
|
|
@'
|
|
import json, urllib.request
|
|
payload = {
|
|
"base_id": "upo_test",
|
|
"learning_id": "form-command-binding-standard-customize-form",
|
|
"table": "ConfigCASSave",
|
|
"file_name": "f96a0c45-3eff-11f1-8287-005056b0d483__25c39fbf-35a4-4b43-8e3f-cd1f91082c88.0",
|
|
"form": "ТестНастройки",
|
|
"element": "ТЗИзменитьФорму",
|
|
"property": "ИмяКоманды",
|
|
"timeout_seconds": 60,
|
|
"max_items": 5000
|
|
}
|
|
req = urllib.request.Request("http://docker.cin.su:8011/rpc", data=json.dumps({"method":"metadata.write_learning.capture_after","payload":payload}, ensure_ascii=False).encode("utf-8"), headers={"Content-Type":"application/json"})
|
|
print(urllib.request.urlopen(req, timeout=90).read().decode("utf-8"))
|
|
'@ | python -
|
|
```
|
|
|
|
Then run:
|
|
|
|
```powershell
|
|
@'
|
|
import json, urllib.request
|
|
for method in ("metadata.write_learning.diff", "metadata.write_learning.infer_rule"):
|
|
payload = {"learning_id": "form-command-binding-standard-customize-form"}
|
|
req = urllib.request.Request("http://docker.cin.su:8011/rpc", data=json.dumps({"method": method, "payload": payload}, ensure_ascii=False).encode("utf-8"), headers={"Content-Type":"application/json"})
|
|
print(urllib.request.urlopen(req, timeout=90).read().decode("utf-8"))
|
|
'@ | python -
|
|
```
|
|
|
|
## Experiment B: Local Form Command Binding
|
|
|
|
Goal: learn where marker `34` stores a local form command binding.
|
|
|
|
Use the same one-command runner above after the manual save.
|
|
|
|
Manual edit in Designer:
|
|
|
|
1. Open form `ТестНастройки`.
|
|
2. Select button `ФормаКомандаОбновить`.
|
|
3. Change only `CommandName` from `Form.Command.КомандаПрименить` to
|
|
`Form.Command.КомандаПример1` or `Form.Command.КомандаПример2`.
|
|
4. Save the form once.
|
|
|
|
After save, capture:
|
|
|
|
```powershell
|
|
@'
|
|
import json, urllib.request
|
|
payload = {
|
|
"base_id": "upo_test",
|
|
"learning_id": "form-command-binding-local-apply-command",
|
|
"table": "ConfigCASSave",
|
|
"file_name": "f96a0c45-3eff-11f1-8287-005056b0d483__25c39fbf-35a4-4b43-8e3f-cd1f91082c88.0",
|
|
"form": "ТестНастройки",
|
|
"element": "ФормаКомандаОбновить",
|
|
"property": "ИмяКоманды",
|
|
"timeout_seconds": 60,
|
|
"max_items": 5000
|
|
}
|
|
req = urllib.request.Request("http://docker.cin.su:8011/rpc", data=json.dumps({"method":"metadata.write_learning.capture_after","payload":payload}, ensure_ascii=False).encode("utf-8"), headers={"Content-Type":"application/json"})
|
|
print(urllib.request.urlopen(req, timeout=90).read().decode("utf-8"))
|
|
'@ | python -
|
|
```
|
|
|
|
Then run:
|
|
|
|
```powershell
|
|
@'
|
|
import json, urllib.request
|
|
for method in ("metadata.write_learning.diff", "metadata.write_learning.infer_rule"):
|
|
payload = {"learning_id": "form-command-binding-local-apply-command"}
|
|
req = urllib.request.Request("http://docker.cin.su:8011/rpc", data=json.dumps({"method": method, "payload": payload}, ensure_ascii=False).encode("utf-8"), headers={"Content-Type":"application/json"})
|
|
print(urllib.request.urlopen(req, timeout=90).read().decode("utf-8"))
|
|
'@ | python -
|
|
```
|
|
|
|
## Promotion Gate
|
|
|
|
Promote a decoder/write rule only when the after capture changes exactly one
|
|
intended command binding. If `metadata.write_learning.diff` reports
|
|
`no_changes`, use low-level `payload.diff` against the baseline payload SHA1
|
|
and implement a dedicated command-binding decoder from the scalar tree diff.
|